Added DCA/DTS/DTS-HD support
parent
de467b38d6
commit
21b78fde9f
|
@ -331,6 +331,18 @@
|
|||
838490801807B17500E7332D /* eac3_data.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384907B1807B17500E7332D /* eac3_data.h */; };
|
||||
838490811807B17500E7332D /* eac3dec.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384907C1807B17500E7332D /* eac3dec.c */; };
|
||||
838490851807B17C00E7332D /* ac3dsp_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490841807B17C00E7332D /* ac3dsp_init.c */; };
|
||||
8384908E1807BC9400E7332D /* dca_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490861807BC9400E7332D /* dca_parser.c */; };
|
||||
8384908F1807BC9400E7332D /* dca.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490871807BC9400E7332D /* dca.c */; };
|
||||
838490901807BC9400E7332D /* dca.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490881807BC9400E7332D /* dca.h */; };
|
||||
838490911807BC9400E7332D /* dcadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490891807BC9400E7332D /* dcadata.h */; };
|
||||
838490921807BC9400E7332D /* dcadec.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384908A1807BC9400E7332D /* dcadec.c */; };
|
||||
838490931807BC9400E7332D /* dcadsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384908B1807BC9400E7332D /* dcadsp.c */; };
|
||||
838490941807BC9400E7332D /* dcadsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384908C1807BC9400E7332D /* dcadsp.h */; };
|
||||
838490951807BC9400E7332D /* dcahuff.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384908D1807BC9400E7332D /* dcahuff.h */; };
|
||||
838490981807BC9C00E7332D /* dtshddec.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490961807BC9C00E7332D /* dtshddec.c */; };
|
||||
838490991807BC9C00E7332D /* dtsdec.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490971807BC9C00E7332D /* dtsdec.c */; };
|
||||
8384909C1807BE1300E7332D /* synth_filter.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384909A1807BE1300E7332D /* synth_filter.c */; };
|
||||
8384909D1807BE1300E7332D /* synth_filter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384909B1807BE1300E7332D /* synth_filter.h */; };
|
||||
8393B7E218052BB000913C76 /* mp3dec.c in Sources */ = {isa = PBXBuildFile; fileRef = 8393B7DF18052BB000913C76 /* mp3dec.c */; };
|
||||
8393B7E318052BB000913C76 /* mpeg.c in Sources */ = {isa = PBXBuildFile; fileRef = 8393B7E018052BB000913C76 /* mpeg.c */; };
|
||||
8393B7E418052BB000913C76 /* mpeg.h in Headers */ = {isa = PBXBuildFile; fileRef = 8393B7E118052BB000913C76 /* mpeg.h */; };
|
||||
|
@ -693,6 +705,18 @@
|
|||
8384907B1807B17500E7332D /* eac3_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eac3_data.h; sourceTree = "<group>"; };
|
||||
8384907C1807B17500E7332D /* eac3dec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eac3dec.c; sourceTree = "<group>"; };
|
||||
838490841807B17C00E7332D /* ac3dsp_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3dsp_init.c; sourceTree = "<group>"; };
|
||||
838490861807BC9400E7332D /* dca_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dca_parser.c; sourceTree = "<group>"; };
|
||||
838490871807BC9400E7332D /* dca.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dca.c; sourceTree = "<group>"; };
|
||||
838490881807BC9400E7332D /* dca.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dca.h; sourceTree = "<group>"; };
|
||||
838490891807BC9400E7332D /* dcadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dcadata.h; sourceTree = "<group>"; };
|
||||
8384908A1807BC9400E7332D /* dcadec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dcadec.c; sourceTree = "<group>"; };
|
||||
8384908B1807BC9400E7332D /* dcadsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dcadsp.c; sourceTree = "<group>"; };
|
||||
8384908C1807BC9400E7332D /* dcadsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dcadsp.h; sourceTree = "<group>"; };
|
||||
8384908D1807BC9400E7332D /* dcahuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dcahuff.h; sourceTree = "<group>"; };
|
||||
838490961807BC9C00E7332D /* dtshddec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dtshddec.c; sourceTree = "<group>"; };
|
||||
838490971807BC9C00E7332D /* dtsdec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dtsdec.c; sourceTree = "<group>"; };
|
||||
8384909A1807BE1300E7332D /* synth_filter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = synth_filter.c; sourceTree = "<group>"; };
|
||||
8384909B1807BE1300E7332D /* synth_filter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = synth_filter.h; sourceTree = "<group>"; };
|
||||
8393B7DF18052BB000913C76 /* mp3dec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mp3dec.c; sourceTree = "<group>"; };
|
||||
8393B7E018052BB000913C76 /* mpeg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mpeg.c; sourceTree = "<group>"; };
|
||||
8393B7E118052BB000913C76 /* mpeg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mpeg.h; sourceTree = "<group>"; };
|
||||
|
@ -805,6 +829,16 @@
|
|||
830F0B8E17FC4FB900042E8F /* libavcodec */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8384909A1807BE1300E7332D /* synth_filter.c */,
|
||||
8384909B1807BE1300E7332D /* synth_filter.h */,
|
||||
838490861807BC9400E7332D /* dca_parser.c */,
|
||||
838490871807BC9400E7332D /* dca.c */,
|
||||
838490881807BC9400E7332D /* dca.h */,
|
||||
838490891807BC9400E7332D /* dcadata.h */,
|
||||
8384908A1807BC9400E7332D /* dcadec.c */,
|
||||
8384908B1807BC9400E7332D /* dcadsp.c */,
|
||||
8384908C1807BC9400E7332D /* dcadsp.h */,
|
||||
8384908D1807BC9400E7332D /* dcahuff.h */,
|
||||
8384907A1807B17500E7332D /* eac3_data.c */,
|
||||
8384907B1807B17500E7332D /* eac3_data.h */,
|
||||
8384907C1807B17500E7332D /* eac3dec.c */,
|
||||
|
@ -998,6 +1032,8 @@
|
|||
830F0BAD17FC4FB900042E8F /* libavformat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
838490961807BC9C00E7332D /* dtshddec.c */,
|
||||
838490971807BC9C00E7332D /* dtsdec.c */,
|
||||
838490681807AF5800E7332D /* ac3dec.c */,
|
||||
8384904E1807898A00E7332D /* ape.c */,
|
||||
8393B7DF18052BB000913C76 /* mp3dec.c */,
|
||||
|
@ -1258,6 +1294,7 @@
|
|||
830F0BFB17FC4FB900042E8F /* avutil.h in Headers */,
|
||||
830F0C0D17FC4FB900042E8F /* samplefmt.h in Headers */,
|
||||
830F0BFD17FC4FB900042E8F /* buffer.h in Headers */,
|
||||
838490911807BC9400E7332D /* dcadata.h in Headers */,
|
||||
8393B80A18052BC200913C76 /* mpegaudiodsp.h in Headers */,
|
||||
830F0C1217FC4FF400042E8F /* avfft.h in Headers */,
|
||||
830F0BF017FC4FB900042E8F /* avformat.h in Headers */,
|
||||
|
@ -1286,6 +1323,7 @@
|
|||
8384906D1807AFB800E7332D /* aac_ac3_parser.h in Headers */,
|
||||
838490611807AF0100E7332D /* ac3dec_data.h in Headers */,
|
||||
830F0D2217FC82AB00042E8F /* eval.h in Headers */,
|
||||
8384909D1807BE1300E7332D /* synth_filter.h in Headers */,
|
||||
830F0C2A17FC54F800042E8F /* rtpdec.h in Headers */,
|
||||
830F0CFF17FC7F1E00042E8F /* wma.h in Headers */,
|
||||
830F0C4E17FC7CA300042E8F /* metadata.h in Headers */,
|
||||
|
@ -1349,6 +1387,7 @@
|
|||
830F0BEC17FC4FB900042E8F /* wmavoice_data.h in Headers */,
|
||||
833C37D118032D4800CBA602 /* dirac_dwt.h in Headers */,
|
||||
8393B80318052BC200913C76 /* mpegaudiodecheader.h in Headers */,
|
||||
838490901807BC9400E7332D /* dca.h in Headers */,
|
||||
830F0D7917FC8C7300042E8F /* mpeg4audio.h in Headers */,
|
||||
830F0C3A17FC554D00042E8F /* des.h in Headers */,
|
||||
830F0BF117FC4FB900042E8F /* avi.h in Headers */,
|
||||
|
@ -1373,7 +1412,9 @@
|
|||
830F0D8B17FC8E8B00042E8F /* aacpsdsp.h in Headers */,
|
||||
830F0CD617FC7F1E00042E8F /* dctref.h in Headers */,
|
||||
830F0C1917FC523000042E8F /* rdt.h in Headers */,
|
||||
838490941807BC9400E7332D /* dcadsp.h in Headers */,
|
||||
8393B80C18052BC200913C76 /* mpegaudiotab.h in Headers */,
|
||||
838490951807BC9400E7332D /* dcahuff.h in Headers */,
|
||||
830F0CF117FC7F1E00042E8F /* ratecontrol.h in Headers */,
|
||||
830F0C1417FC500B00042E8F /* fft-internal.h in Headers */,
|
||||
830F0D8E17FC8E8B00042E8F /* sbr.h in Headers */,
|
||||
|
@ -1479,6 +1520,7 @@
|
|||
files = (
|
||||
833C37A918032AAD00CBA602 /* img2.c in Sources */,
|
||||
838490701807B04200E7332D /* lfg.c in Sources */,
|
||||
838490981807BC9C00E7332D /* dtshddec.c in Sources */,
|
||||
830F0D6717FC8A3300042E8F /* options.c in Sources */,
|
||||
830F0DAF17FC8FBD00042E8F /* fmtconvert_init.c in Sources */,
|
||||
830F0DD617FC93E400042E8F /* xwma.c in Sources */,
|
||||
|
@ -1504,6 +1546,7 @@
|
|||
830F0BE217FC4FB900042E8F /* utils.c in Sources */,
|
||||
838490741807B07000E7332D /* md5.c in Sources */,
|
||||
8393B80E18052BD500913C76 /* mpegaudiodsp.c in Sources */,
|
||||
8384909C1807BE1300E7332D /* synth_filter.c in Sources */,
|
||||
8393B81418052E7400913C76 /* mpegaudiodsp.c in Sources */,
|
||||
830F0CF917FC7F1E00042E8F /* sinewin.c in Sources */,
|
||||
833C37C418032CF600CBA602 /* dirac_dwt.c in Sources */,
|
||||
|
@ -1524,10 +1567,12 @@
|
|||
8384905C1807AF0100E7332D /* ac3_parser.c in Sources */,
|
||||
830F0C6B17FC7DB100042E8F /* bprint.c in Sources */,
|
||||
830F0BE017FC4FB900042E8F /* simple_idct.c in Sources */,
|
||||
838490991807BC9C00E7332D /* dtsdec.c in Sources */,
|
||||
830F0D6917FC8A3D00042E8F /* avpicture.c in Sources */,
|
||||
8393B80518052BC200913C76 /* mpegaudiodsp_data.c in Sources */,
|
||||
830F0CDA17FC7F1E00042E8F /* error_resilience.c in Sources */,
|
||||
830F0D3317FC841B00042E8F /* opt.c in Sources */,
|
||||
838490921807BC9400E7332D /* dcadec.c in Sources */,
|
||||
830F0D7317FC8C1300042E8F /* astdec.c in Sources */,
|
||||
8384905E1807AF0100E7332D /* ac3.c in Sources */,
|
||||
830F0D5317FC891800042E8F /* file_open.c in Sources */,
|
||||
|
@ -1542,6 +1587,8 @@
|
|||
830F0C1B17FC523000042E8F /* url.c in Sources */,
|
||||
830F0CC417FC7F1E00042E8F /* acelp_pitch_delay.c in Sources */,
|
||||
8393B80218052BC200913C76 /* mpegaudiodecheader.c in Sources */,
|
||||
8384908E1807BC9400E7332D /* dca_parser.c in Sources */,
|
||||
8384908F1807BC9400E7332D /* dca.c in Sources */,
|
||||
833C37C218032CF600CBA602 /* dirac_arith.c in Sources */,
|
||||
830F0CEB17FC7F1E00042E8F /* lsp.c in Sources */,
|
||||
830F0D1317FC815000042E8F /* constants.c in Sources */,
|
||||
|
@ -1617,6 +1664,7 @@
|
|||
830F0D2E17FC841B00042E8F /* channel_layout.c in Sources */,
|
||||
830F0CE517FC7F1E00042E8F /* h264chroma.c in Sources */,
|
||||
830F0BE717FC4FB900042E8F /* wmadec.c in Sources */,
|
||||
838490931807BC9400E7332D /* dcadsp.c in Sources */,
|
||||
830F0CC617FC7F1E00042E8F /* acelp_vectors.c in Sources */,
|
||||
830F0DC417FC92EE00042E8F /* videodsp_init.c in Sources */,
|
||||
833C379A180328B300CBA602 /* tak_parser.c in Sources */,
|
||||
|
|
|
@ -403,7 +403,7 @@
|
|||
#define CONFIG_BMV_AUDIO_DECODER 0
|
||||
#define CONFIG_COOK_DECODER 0
|
||||
#define CONFIG_DCA_ENCODER 0
|
||||
#define CONFIG_DCA_DECODER 0
|
||||
#define CONFIG_DCA_DECODER 1
|
||||
#define CONFIG_DSICINAUDIO_DECODER 0
|
||||
#define CONFIG_EAC3_ENCODER 0
|
||||
#define CONFIG_EAC3_DECODER 1
|
||||
|
@ -662,7 +662,7 @@
|
|||
#define CONFIG_BMP_PARSER 0
|
||||
#define CONFIG_CAVSVIDEO_PARSER 0
|
||||
#define CONFIG_COOK_PARSER 0
|
||||
#define CONFIG_DCA_PARSER 0
|
||||
#define CONFIG_DCA_PARSER 1
|
||||
#define CONFIG_DIRAC_PARSER 1
|
||||
#define CONFIG_DNXHD_PARSER 0
|
||||
#define CONFIG_DVBSUB_PARSER 0
|
||||
|
@ -767,8 +767,8 @@
|
|||
#define CONFIG_DNXHD_DEMUXER 0
|
||||
#define CONFIG_DSICIN_DEMUXER 0
|
||||
#define CONFIG_DTS_MUXER 0
|
||||
#define CONFIG_DTS_DEMUXER 0
|
||||
#define CONFIG_DTSHD_DEMUXER 0
|
||||
#define CONFIG_DTS_DEMUXER 1
|
||||
#define CONFIG_DTSHD_DEMUXER 1
|
||||
#define CONFIG_DV_MUXER 0
|
||||
#define CONFIG_DV_DEMUXER 0
|
||||
#define CONFIG_DXA_DEMUXER 0
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* DCA compatible decoder data
|
||||
* Copyright (C) 2004 Gildas Bazin
|
||||
* Copyright (C) 2004 Benjamin Zores
|
||||
* Copyright (C) 2006 Benjamin Larsson
|
||||
* Copyright (C) 2007 Konstantin Shishkov
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "put_bits.h"
|
||||
#include "dca.h"
|
||||
|
||||
const uint32_t avpriv_dca_sample_rates[16] =
|
||||
{
|
||||
0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
|
||||
12000, 24000, 48000, 96000, 192000
|
||||
};
|
||||
|
||||
int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
|
||||
int max_size)
|
||||
{
|
||||
uint32_t mrk;
|
||||
int i, tmp;
|
||||
const uint16_t *ssrc = (const uint16_t *) src;
|
||||
uint16_t *sdst = (uint16_t *) dst;
|
||||
PutBitContext pb;
|
||||
|
||||
if ((unsigned) src_size > (unsigned) max_size)
|
||||
src_size = max_size;
|
||||
|
||||
mrk = AV_RB32(src);
|
||||
switch (mrk) {
|
||||
case DCA_MARKER_RAW_BE:
|
||||
memcpy(dst, src, src_size);
|
||||
return src_size;
|
||||
case DCA_MARKER_RAW_LE:
|
||||
for (i = 0; i < (src_size + 1) >> 1; i++)
|
||||
*sdst++ = av_bswap16(*ssrc++);
|
||||
return src_size;
|
||||
case DCA_MARKER_14B_BE:
|
||||
case DCA_MARKER_14B_LE:
|
||||
init_put_bits(&pb, dst, max_size);
|
||||
for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
|
||||
tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
|
||||
put_bits(&pb, 14, tmp);
|
||||
}
|
||||
flush_put_bits(&pb);
|
||||
return (put_bits_count(&pb) + 7) >> 3;
|
||||
default:
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* DCA compatible decoder
|
||||
* Copyright (C) 2004 Gildas Bazin
|
||||
* Copyright (C) 2004 Benjamin Zores
|
||||
* Copyright (C) 2006 Benjamin Larsson
|
||||
* Copyright (C) 2007 Konstantin Shishkov
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DCA_H
|
||||
#define AVCODEC_DCA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/internal.h"
|
||||
|
||||
/** DCA syncwords, also used for bitstream type detection */
|
||||
#define DCA_MARKER_RAW_BE 0x7FFE8001
|
||||
#define DCA_MARKER_RAW_LE 0xFE7F0180
|
||||
#define DCA_MARKER_14B_BE 0x1FFFE800
|
||||
#define DCA_MARKER_14B_LE 0xFF1F00E8
|
||||
|
||||
/** DCA-HD specific block starts with this marker. */
|
||||
#define DCA_HD_MARKER 0x64582025
|
||||
|
||||
extern av_export const uint32_t avpriv_dca_sample_rates[16];
|
||||
|
||||
/**
|
||||
* Convert bitstream to one representation based on sync marker
|
||||
*/
|
||||
int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
|
||||
int max_size);
|
||||
|
||||
#endif /* AVCODEC_DCA_H */
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* DCA parser
|
||||
* Copyright (C) 2004 Gildas Bazin
|
||||
* Copyright (C) 2004 Benjamin Zores
|
||||
* Copyright (C) 2006 Benjamin Larsson
|
||||
* Copyright (C) 2007 Konstantin Shishkov
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "parser.h"
|
||||
#include "dca.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
typedef struct DCAParseContext {
|
||||
ParseContext pc;
|
||||
uint32_t lastmarker;
|
||||
int size;
|
||||
int framesize;
|
||||
int hd_pos;
|
||||
} DCAParseContext;
|
||||
|
||||
#define IS_MARKER(state, i, buf, buf_size) \
|
||||
((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \
|
||||
|| (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \
|
||||
|| state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE || state == DCA_HD_MARKER)
|
||||
|
||||
/**
|
||||
* Find the end of the current frame in the bitstream.
|
||||
* @return the position of the first byte of the next frame, or -1
|
||||
*/
|
||||
static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
|
||||
int buf_size)
|
||||
{
|
||||
int start_found, i;
|
||||
uint32_t state;
|
||||
ParseContext *pc = &pc1->pc;
|
||||
|
||||
start_found = pc->frame_start_found;
|
||||
state = pc->state;
|
||||
|
||||
i = 0;
|
||||
if (!start_found) {
|
||||
for (i = 0; i < buf_size; i++) {
|
||||
state = (state << 8) | buf[i];
|
||||
if (IS_MARKER(state, i, buf, buf_size)) {
|
||||
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
|
||||
start_found = 1;
|
||||
pc1->lastmarker = state;
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start_found) {
|
||||
for (; i < buf_size; i++) {
|
||||
pc1->size++;
|
||||
state = (state << 8) | buf[i];
|
||||
if (state == DCA_HD_MARKER && !pc1->hd_pos)
|
||||
pc1->hd_pos = pc1->size;
|
||||
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
|
||||
if(pc1->framesize > pc1->size)
|
||||
continue;
|
||||
pc->frame_start_found = 0;
|
||||
pc->state = -1;
|
||||
pc1->size = 0;
|
||||
return i - 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
pc->frame_start_found = start_found;
|
||||
pc->state = state;
|
||||
return END_NOT_FOUND;
|
||||
}
|
||||
|
||||
static av_cold int dca_parse_init(AVCodecParserContext * s)
|
||||
{
|
||||
DCAParseContext *pc1 = s->priv_data;
|
||||
|
||||
pc1->lastmarker = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
|
||||
int *sample_rate, int *framesize)
|
||||
{
|
||||
GetBitContext gb;
|
||||
uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
|
||||
int ret, sample_blocks, sr_code;
|
||||
|
||||
if (buf_size < 12)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if ((ret = ff_dca_convert_bitstream(buf, 12, hdr, 12)) < 0)
|
||||
return ret;
|
||||
|
||||
init_get_bits(&gb, hdr, 96);
|
||||
|
||||
skip_bits_long(&gb, 39);
|
||||
sample_blocks = get_bits(&gb, 7) + 1;
|
||||
if (sample_blocks < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
*duration = 256 * (sample_blocks / 8);
|
||||
|
||||
*framesize = get_bits(&gb, 14) + 1;
|
||||
if (*framesize < 95)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
skip_bits(&gb, 6);
|
||||
sr_code = get_bits(&gb, 4);
|
||||
*sample_rate = avpriv_dca_sample_rates[sr_code];
|
||||
if (*sample_rate == 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dca_parse(AVCodecParserContext * s,
|
||||
AVCodecContext * avctx,
|
||||
const uint8_t ** poutbuf, int *poutbuf_size,
|
||||
const uint8_t * buf, int buf_size)
|
||||
{
|
||||
DCAParseContext *pc1 = s->priv_data;
|
||||
ParseContext *pc = &pc1->pc;
|
||||
int next, duration, sample_rate;
|
||||
|
||||
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||
next = buf_size;
|
||||
} else {
|
||||
next = dca_find_frame_end(pc1, buf, buf_size);
|
||||
|
||||
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
|
||||
*poutbuf = NULL;
|
||||
*poutbuf_size = 0;
|
||||
return buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the duration and sample rate from the frame header */
|
||||
if (!dca_parse_params(buf, buf_size, &duration, &sample_rate, &pc1->framesize)) {
|
||||
s->duration = duration;
|
||||
avctx->sample_rate = sample_rate;
|
||||
} else
|
||||
s->duration = 0;
|
||||
|
||||
*poutbuf = buf;
|
||||
*poutbuf_size = buf_size;
|
||||
return next;
|
||||
}
|
||||
|
||||
AVCodecParser ff_dca_parser = {
|
||||
.codec_ids = { AV_CODEC_ID_DTS },
|
||||
.priv_data_size = sizeof(DCAParseContext),
|
||||
.parser_init = dca_parse_init,
|
||||
.parser_parse = dca_parse,
|
||||
.parser_close = ff_parse_close,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2004 Gildas Bazin
|
||||
* Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "dcadsp.h"
|
||||
|
||||
static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
|
||||
int decifactor, float scale)
|
||||
{
|
||||
float *out2 = out + decifactor;
|
||||
const float *cf0 = coefs;
|
||||
const float *cf1 = coefs + 256;
|
||||
int j, k;
|
||||
|
||||
/* One decimated sample generates 2*decifactor interpolated ones */
|
||||
for (k = 0; k < decifactor; k++) {
|
||||
float v0 = 0.0;
|
||||
float v1 = 0.0;
|
||||
for (j = 0; j < 256 / decifactor; j++) {
|
||||
float s = in[-j];
|
||||
v0 += s * *cf0++;
|
||||
v1 += s * *--cf1;
|
||||
}
|
||||
*out++ = v0 * scale;
|
||||
*out2++ = v1 * scale;
|
||||
}
|
||||
}
|
||||
|
||||
static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
|
||||
SynthFilterContext *synth, FFTContext *imdct,
|
||||
float synth_buf_ptr[512],
|
||||
int *synth_buf_offset, float synth_buf2[32],
|
||||
const float window[512], float *samples_out,
|
||||
float raXin[32], float scale)
|
||||
{
|
||||
int i;
|
||||
int subindex;
|
||||
|
||||
for (i = sb_act; i < 32; i++)
|
||||
raXin[i] = 0.0;
|
||||
|
||||
/* Reconstructed channel sample index */
|
||||
for (subindex = 0; subindex < 8; subindex++) {
|
||||
/* Load in one sample from each subband and clear inactive subbands */
|
||||
for (i = 0; i < sb_act; i++) {
|
||||
unsigned sign = (i - 1) & 2;
|
||||
uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30;
|
||||
AV_WN32A(&raXin[i], v);
|
||||
}
|
||||
|
||||
synth->synth_filter_float(imdct, synth_buf_ptr, synth_buf_offset,
|
||||
synth_buf2, window, samples_out, raXin, scale);
|
||||
samples_out += 32;
|
||||
}
|
||||
}
|
||||
|
||||
av_cold void ff_dcadsp_init(DCADSPContext *s)
|
||||
{
|
||||
s->lfe_fir = dca_lfe_fir_c;
|
||||
s->qmf_32_subbands = dca_qmf_32_subbands;
|
||||
if (ARCH_ARM) ff_dcadsp_init_arm(s);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DCADSP_H
|
||||
#define AVCODEC_DCADSP_H
|
||||
|
||||
#include "avfft.h"
|
||||
#include "synth_filter.h"
|
||||
|
||||
typedef struct DCADSPContext {
|
||||
void (*lfe_fir)(float *out, const float *in, const float *coefs,
|
||||
int decifactor, float scale);
|
||||
void (*qmf_32_subbands)(float samples_in[32][8], int sb_act,
|
||||
SynthFilterContext *synth, FFTContext *imdct,
|
||||
float synth_buf_ptr[512],
|
||||
int *synth_buf_offset, float synth_buf2[32],
|
||||
const float window[512], float *samples_out,
|
||||
float raXin[32], float scale);
|
||||
} DCADSPContext;
|
||||
|
||||
void ff_dcadsp_init(DCADSPContext *s);
|
||||
void ff_dcadsp_init_arm(DCADSPContext *s);
|
||||
|
||||
#endif /* AVCODEC_DCADSP_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "fft.h"
|
||||
#include "synth_filter.h"
|
||||
|
||||
static void synth_filter_float(FFTContext *imdct,
|
||||
float *synth_buf_ptr, int *synth_buf_offset,
|
||||
float synth_buf2[32], const float window[512],
|
||||
float out[32], const float in[32], float scale)
|
||||
{
|
||||
float *synth_buf= synth_buf_ptr + *synth_buf_offset;
|
||||
int i, j;
|
||||
|
||||
imdct->imdct_half(imdct, synth_buf, in);
|
||||
|
||||
for (i = 0; i < 16; i++){
|
||||
float a= synth_buf2[i ];
|
||||
float b= synth_buf2[i + 16];
|
||||
float c= 0;
|
||||
float d= 0;
|
||||
for (j = 0; j < 512 - *synth_buf_offset; j += 64){
|
||||
a += window[i + j ]*(-synth_buf[15 - i + j ]);
|
||||
b += window[i + j + 16]*( synth_buf[ i + j ]);
|
||||
c += window[i + j + 32]*( synth_buf[16 + i + j ]);
|
||||
d += window[i + j + 48]*( synth_buf[31 - i + j ]);
|
||||
}
|
||||
for ( ; j < 512; j += 64){
|
||||
a += window[i + j ]*(-synth_buf[15 - i + j - 512]);
|
||||
b += window[i + j + 16]*( synth_buf[ i + j - 512]);
|
||||
c += window[i + j + 32]*( synth_buf[16 + i + j - 512]);
|
||||
d += window[i + j + 48]*( synth_buf[31 - i + j - 512]);
|
||||
}
|
||||
out[i ] = a*scale;
|
||||
out[i + 16] = b*scale;
|
||||
synth_buf2[i ] = c;
|
||||
synth_buf2[i + 16] = d;
|
||||
}
|
||||
*synth_buf_offset= (*synth_buf_offset - 32)&511;
|
||||
}
|
||||
|
||||
av_cold void ff_synth_filter_init(SynthFilterContext *c)
|
||||
{
|
||||
c->synth_filter_float = synth_filter_float;
|
||||
|
||||
if (ARCH_ARM) ff_synth_filter_init_arm(c);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_SYNTH_FILTER_H
|
||||
#define AVCODEC_SYNTH_FILTER_H
|
||||
|
||||
#include "fft.h"
|
||||
|
||||
typedef struct SynthFilterContext {
|
||||
void (*synth_filter_float)(FFTContext *imdct,
|
||||
float *synth_buf_ptr, int *synth_buf_offset,
|
||||
float synth_buf2[32], const float window[512],
|
||||
float out[32], const float in[32],
|
||||
float scale);
|
||||
} SynthFilterContext;
|
||||
|
||||
void ff_synth_filter_init(SynthFilterContext *c);
|
||||
void ff_synth_filter_init_arm(SynthFilterContext *c);
|
||||
|
||||
#endif /* AVCODEC_SYNTH_FILTER_H */
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* RAW DTS demuxer
|
||||
* Copyright (c) 2008 Benjamin Larsson
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/bytestream.h"
|
||||
#include "avformat.h"
|
||||
#include "rawdec.h"
|
||||
|
||||
#define DCA_MARKER_14B_BE 0x1FFFE800
|
||||
#define DCA_MARKER_14B_LE 0xFF1F00E8
|
||||
#define DCA_MARKER_RAW_BE 0x7FFE8001
|
||||
#define DCA_MARKER_RAW_LE 0xFE7F0180
|
||||
|
||||
static int dts_probe(AVProbeData *p)
|
||||
{
|
||||
const uint8_t *buf, *bufp;
|
||||
uint32_t state = -1;
|
||||
int markers[3] = {0};
|
||||
int sum, max;
|
||||
int64_t diff = 0;
|
||||
|
||||
buf = p->buf;
|
||||
|
||||
for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
|
||||
bufp = buf;
|
||||
state = (state << 16) | bytestream_get_be16(&bufp);
|
||||
|
||||
/* regular bitstream */
|
||||
if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
|
||||
markers[0]++;
|
||||
|
||||
/* 14 bits big-endian bitstream */
|
||||
if (state == DCA_MARKER_14B_BE)
|
||||
if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
|
||||
markers[1]++;
|
||||
|
||||
/* 14 bits little-endian bitstream */
|
||||
if (state == DCA_MARKER_14B_LE)
|
||||
if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
|
||||
markers[2]++;
|
||||
|
||||
if (buf - p->buf >= 4)
|
||||
diff += FFABS(AV_RL16(buf) - AV_RL16(buf-4));
|
||||
}
|
||||
sum = markers[0] + markers[1] + markers[2];
|
||||
max = markers[1] > markers[0];
|
||||
max = markers[2] > markers[max] ? 2 : max;
|
||||
if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
|
||||
markers[max] * 4 > sum * 3 &&
|
||||
diff / p->buf_size > 200)
|
||||
return AVPROBE_SCORE_EXTENSION + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVInputFormat ff_dts_demuxer = {
|
||||
.name = "dts",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw DTS"),
|
||||
.read_probe = dts_probe,
|
||||
.read_header = ff_raw_audio_read_header,
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "dts",
|
||||
.raw_codec_id = AV_CODEC_ID_DTS,
|
||||
};
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Raw DTS-HD demuxer
|
||||
* Copyright (c) 2012 Paul B Mahol
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "avformat.h"
|
||||
|
||||
#define AUPR_HDR 0x415550522D484452
|
||||
#define AUPRINFO 0x41555052494E464F
|
||||
#define BITSHVTB 0x4249545348565442
|
||||
#define BLACKOUT 0x424C41434B4F5554
|
||||
#define BRANCHPT 0x4252414E43485054
|
||||
#define BUILDVER 0x4255494C44564552
|
||||
#define CORESSMD 0x434F524553534D44
|
||||
#define DTSHDHDR 0x4454534844484452
|
||||
#define EXTSS_MD 0x45585453535f4d44
|
||||
#define FILEINFO 0x46494C45494E464F
|
||||
#define NAVI_TBL 0x4E4156492D54424C
|
||||
#define STRMDATA 0x5354524D44415441
|
||||
#define TIMECODE 0x54494D45434F4445
|
||||
|
||||
typedef struct DTSHDDemuxContext {
|
||||
uint64_t data_end;
|
||||
} DTSHDDemuxContext;
|
||||
|
||||
static int dtshd_probe(AVProbeData *p)
|
||||
{
|
||||
if (AV_RB64(p->buf) == DTSHDHDR)
|
||||
return AVPROBE_SCORE_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dtshd_read_header(AVFormatContext *s)
|
||||
{
|
||||
DTSHDDemuxContext *dtshd = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
uint64_t chunk_type, chunk_size;
|
||||
AVStream *st;
|
||||
int ret;
|
||||
char *value;
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
st->codec->codec_id = AV_CODEC_ID_DTS;
|
||||
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||
|
||||
while (!url_feof(pb)) {
|
||||
chunk_type = avio_rb64(pb);
|
||||
chunk_size = avio_rb64(pb);
|
||||
|
||||
if (chunk_size < 4) {
|
||||
av_log(s, AV_LOG_ERROR, "chunk size too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (chunk_size > ((uint64_t)1 << 61)) {
|
||||
av_log(s, AV_LOG_ERROR, "chunk size too big\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
switch (chunk_type) {
|
||||
case STRMDATA:
|
||||
dtshd->data_end = chunk_size + avio_tell(pb);
|
||||
if (dtshd->data_end <= chunk_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 0;
|
||||
break;
|
||||
case FILEINFO:
|
||||
if (chunk_size > INT_MAX)
|
||||
goto skip;
|
||||
value = av_malloc(chunk_size);
|
||||
if (!value)
|
||||
goto skip;
|
||||
avio_read(pb, value, chunk_size);
|
||||
value[chunk_size - 1] = 0;
|
||||
av_dict_set(&s->metadata, "fileinfo", value,
|
||||
AV_DICT_DONT_STRDUP_VAL);
|
||||
break;
|
||||
default:
|
||||
skip:
|
||||
ret = avio_skip(pb, chunk_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
return AVERROR_EOF;
|
||||
}
|
||||
|
||||
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
DTSHDDemuxContext *dtshd = s->priv_data;
|
||||
int64_t size, left;
|
||||
int ret;
|
||||
|
||||
left = dtshd->data_end - avio_tell(s->pb);
|
||||
size = FFMIN(left, 1024);
|
||||
if (size <= 0)
|
||||
return AVERROR_EOF;
|
||||
|
||||
ret = av_get_packet(s->pb, pkt, size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
pkt->stream_index = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVInputFormat ff_dtshd_demuxer = {
|
||||
.name = "dtshd",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw DTS-HD"),
|
||||
.priv_data_size = sizeof(DTSHDDemuxContext),
|
||||
.read_probe = dtshd_probe,
|
||||
.read_header = dtshd_read_header,
|
||||
.read_packet = raw_read_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "dtshd",
|
||||
.raw_codec_id = AV_CODEC_ID_DTS,
|
||||
};
|
|
@ -141,6 +141,8 @@ StringList FileRef::defaultFileExtensions()
|
|||
l.append("tak");
|
||||
l.append("ac3");
|
||||
l.append("apl");
|
||||
l.append("dts");
|
||||
l.append("dtshd");
|
||||
|
||||
return l;
|
||||
}
|
||||
|
@ -236,7 +238,7 @@ File *FileRef::create(FileName fileName, bool readAudioProperties,
|
|||
return new ASF::File(fileName, readAudioProperties, audioPropertiesStyle);
|
||||
if(ext == "APE")
|
||||
return new APE::File(fileName, readAudioProperties, audioPropertiesStyle);
|
||||
if(ext == "TAK" || ext == "AC3" || ext == "APL")
|
||||
if(ext == "TAK" || ext == "AC3" || ext == "APL" || ext == "DTS" || ext == "DTSHD")
|
||||
return new APE::File(fileName, false, audioPropertiesStyle);
|
||||
}
|
||||
|
||||
|
|
|
@ -310,12 +310,12 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
|||
|
||||
+ (NSArray *)fileTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects:@"wma", @"asf", @"xwma", @"tak", @"mp3", @"mp2", @"m2a", @"mpa", @"ape", @"ac3", nil];
|
||||
return [NSArray arrayWithObjects:@"wma", @"asf", @"xwma", @"tak", @"mp3", @"mp2", @"m2a", @"mpa", @"ape", @"ac3", @"dts", @"dtshd", nil];
|
||||
}
|
||||
|
||||
+ (NSArray *)mimeTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects:@"application/wma", @"application/x-wma", @"audio/x-wma", @"audio/x-ms-wma", @"audio/x-tak", @"audio/mpeg", @"audio/x-mp3", @"audio/x-mp2", @"audio/x-ape", @"audio/x-ac3", nil];
|
||||
return [NSArray arrayWithObjects:@"application/wma", @"application/x-wma", @"audio/x-wma", @"audio/x-ms-wma", @"audio/x-tak", @"audio/mpeg", @"audio/x-mp3", @"audio/x-mp2", @"audio/x-ape", @"audio/x-ac3", @"audio/x-dts", @"audio/x-dtshd", nil];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -130,12 +130,12 @@
|
|||
+ (NSArray *)fileTypes
|
||||
{
|
||||
//May be a way to get a list of supported formats
|
||||
return [NSArray arrayWithObjects:@"ape", @"asf", @"wma", @"ogg", @"opus", @"mpc", @"flac", @"m4a", @"mp3", @"tak", @"ac3", @"apl", nil];
|
||||
return [NSArray arrayWithObjects:@"ape", @"asf", @"wma", @"ogg", @"opus", @"mpc", @"flac", @"m4a", @"mp3", @"tak", @"ac3", @"apl", @"dts", @"dtshd", nil];
|
||||
}
|
||||
|
||||
+ (NSArray *)mimeTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects:@"audio/x-ape", @"audio/x-ms-wma", @"application/ogg", @"application/x-ogg", @"audio/x-vorbis+ogg", @"audio/x-musepack", @"audio/x-flac", @"audio/x-m4a", @"audio/mpeg", @"audio/x-mp3", @"audio/x-tak", @"audio/x-ac3", @"audio/x-apl", nil];
|
||||
return [NSArray arrayWithObjects:@"audio/x-ape", @"audio/x-ms-wma", @"application/ogg", @"application/x-ogg", @"audio/x-vorbis+ogg", @"audio/x-musepack", @"audio/x-flac", @"audio/x-m4a", @"audio/mpeg", @"audio/x-mp3", @"audio/x-tak", @"audio/x-ac3", @"audio/x-apl", @"audio/x-dts", @"audio/x-dtshd", nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue