Added AC3 decoder to FFMPEG plugin
parent
fd9d9a7065
commit
de467b38d6
|
@ -306,6 +306,31 @@
|
|||
833C37D718032EA500CBA602 /* idct_xvid.h in Headers */ = {isa = PBXBuildFile; fileRef = 833C37D618032EA500CBA602 /* idct_xvid.h */; };
|
||||
8384904D1807898200E7332D /* apedec.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384904C1807898200E7332D /* apedec.c */; };
|
||||
8384904F1807898A00E7332D /* ape.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384904E1807898A00E7332D /* ape.c */; };
|
||||
8384905C1807AF0100E7332D /* ac3_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490501807AF0100E7332D /* ac3_parser.c */; };
|
||||
8384905D1807AF0100E7332D /* ac3_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490511807AF0100E7332D /* ac3_parser.h */; };
|
||||
8384905E1807AF0100E7332D /* ac3.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490521807AF0100E7332D /* ac3.c */; };
|
||||
8384905F1807AF0100E7332D /* ac3.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490531807AF0100E7332D /* ac3.h */; };
|
||||
838490601807AF0100E7332D /* ac3dec_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490541807AF0100E7332D /* ac3dec_data.c */; };
|
||||
838490611807AF0100E7332D /* ac3dec_data.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490551807AF0100E7332D /* ac3dec_data.h */; };
|
||||
838490621807AF0100E7332D /* ac3dec.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490561807AF0100E7332D /* ac3dec.c */; };
|
||||
838490631807AF0100E7332D /* ac3dec.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490571807AF0100E7332D /* ac3dec.h */; };
|
||||
838490641807AF0100E7332D /* ac3dsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490581807AF0100E7332D /* ac3dsp.c */; };
|
||||
838490651807AF0100E7332D /* ac3dsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490591807AF0100E7332D /* ac3dsp.h */; };
|
||||
838490661807AF0100E7332D /* ac3tab.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384905A1807AF0100E7332D /* ac3tab.c */; };
|
||||
838490671807AF0100E7332D /* ac3tab.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384905B1807AF0100E7332D /* ac3tab.h */; };
|
||||
838490691807AF5800E7332D /* ac3dec.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490681807AF5800E7332D /* ac3dec.c */; };
|
||||
8384906C1807AFB800E7332D /* aac_ac3_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384906A1807AFB800E7332D /* aac_ac3_parser.c */; };
|
||||
8384906D1807AFB800E7332D /* aac_ac3_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384906B1807AFB800E7332D /* aac_ac3_parser.h */; };
|
||||
838490701807B04200E7332D /* lfg.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384906E1807B04200E7332D /* lfg.c */; };
|
||||
838490711807B04200E7332D /* lfg.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384906F1807B04200E7332D /* lfg.h */; };
|
||||
838490741807B07000E7332D /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490721807B07000E7332D /* md5.c */; };
|
||||
838490751807B07000E7332D /* md5.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490731807B07000E7332D /* md5.h */; };
|
||||
838490781807B13000E7332D /* kbdwin.c in Sources */ = {isa = PBXBuildFile; fileRef = 838490761807B13000E7332D /* kbdwin.c */; };
|
||||
838490791807B13000E7332D /* kbdwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 838490771807B13000E7332D /* kbdwin.h */; };
|
||||
8384907F1807B17500E7332D /* eac3_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 8384907A1807B17500E7332D /* eac3_data.c */; };
|
||||
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 */; };
|
||||
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 */; };
|
||||
|
@ -643,6 +668,31 @@
|
|||
833C37D618032EA500CBA602 /* idct_xvid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = idct_xvid.h; sourceTree = "<group>"; };
|
||||
8384904C1807898200E7332D /* apedec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = apedec.c; sourceTree = "<group>"; };
|
||||
8384904E1807898A00E7332D /* ape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ape.c; sourceTree = "<group>"; };
|
||||
838490501807AF0100E7332D /* ac3_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3_parser.c; sourceTree = "<group>"; };
|
||||
838490511807AF0100E7332D /* ac3_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3_parser.h; sourceTree = "<group>"; };
|
||||
838490521807AF0100E7332D /* ac3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3.c; sourceTree = "<group>"; };
|
||||
838490531807AF0100E7332D /* ac3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3.h; sourceTree = "<group>"; };
|
||||
838490541807AF0100E7332D /* ac3dec_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3dec_data.c; sourceTree = "<group>"; };
|
||||
838490551807AF0100E7332D /* ac3dec_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3dec_data.h; sourceTree = "<group>"; };
|
||||
838490561807AF0100E7332D /* ac3dec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3dec.c; sourceTree = "<group>"; };
|
||||
838490571807AF0100E7332D /* ac3dec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3dec.h; sourceTree = "<group>"; };
|
||||
838490581807AF0100E7332D /* ac3dsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3dsp.c; sourceTree = "<group>"; };
|
||||
838490591807AF0100E7332D /* ac3dsp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3dsp.h; sourceTree = "<group>"; };
|
||||
8384905A1807AF0100E7332D /* ac3tab.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3tab.c; sourceTree = "<group>"; };
|
||||
8384905B1807AF0100E7332D /* ac3tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac3tab.h; sourceTree = "<group>"; };
|
||||
838490681807AF5800E7332D /* ac3dec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac3dec.c; sourceTree = "<group>"; };
|
||||
8384906A1807AFB800E7332D /* aac_ac3_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aac_ac3_parser.c; sourceTree = "<group>"; };
|
||||
8384906B1807AFB800E7332D /* aac_ac3_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aac_ac3_parser.h; sourceTree = "<group>"; };
|
||||
8384906E1807B04200E7332D /* lfg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lfg.c; sourceTree = "<group>"; };
|
||||
8384906F1807B04200E7332D /* lfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lfg.h; sourceTree = "<group>"; };
|
||||
838490721807B07000E7332D /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = "<group>"; };
|
||||
838490731807B07000E7332D /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = "<group>"; };
|
||||
838490761807B13000E7332D /* kbdwin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kbdwin.c; sourceTree = "<group>"; };
|
||||
838490771807B13000E7332D /* kbdwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kbdwin.h; sourceTree = "<group>"; };
|
||||
8384907A1807B17500E7332D /* eac3_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eac3_data.c; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
|
@ -755,6 +805,25 @@
|
|||
830F0B8E17FC4FB900042E8F /* libavcodec */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8384907A1807B17500E7332D /* eac3_data.c */,
|
||||
8384907B1807B17500E7332D /* eac3_data.h */,
|
||||
8384907C1807B17500E7332D /* eac3dec.c */,
|
||||
838490761807B13000E7332D /* kbdwin.c */,
|
||||
838490771807B13000E7332D /* kbdwin.h */,
|
||||
8384906A1807AFB800E7332D /* aac_ac3_parser.c */,
|
||||
8384906B1807AFB800E7332D /* aac_ac3_parser.h */,
|
||||
838490501807AF0100E7332D /* ac3_parser.c */,
|
||||
838490511807AF0100E7332D /* ac3_parser.h */,
|
||||
838490521807AF0100E7332D /* ac3.c */,
|
||||
838490531807AF0100E7332D /* ac3.h */,
|
||||
838490541807AF0100E7332D /* ac3dec_data.c */,
|
||||
838490551807AF0100E7332D /* ac3dec_data.h */,
|
||||
838490561807AF0100E7332D /* ac3dec.c */,
|
||||
838490571807AF0100E7332D /* ac3dec.h */,
|
||||
838490581807AF0100E7332D /* ac3dsp.c */,
|
||||
838490591807AF0100E7332D /* ac3dsp.h */,
|
||||
8384905A1807AF0100E7332D /* ac3tab.c */,
|
||||
8384905B1807AF0100E7332D /* ac3tab.h */,
|
||||
8384904C1807898200E7332D /* apedec.c */,
|
||||
8393B81518052E9900913C76 /* mpegaudiodsp_fixed.c */,
|
||||
8393B81318052E7400913C76 /* mpegaudiodsp.c */,
|
||||
|
@ -929,6 +998,7 @@
|
|||
830F0BAD17FC4FB900042E8F /* libavformat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
838490681807AF5800E7332D /* ac3dec.c */,
|
||||
8384904E1807898A00E7332D /* ape.c */,
|
||||
8393B7DF18052BB000913C76 /* mp3dec.c */,
|
||||
8393B7E018052BB000913C76 /* mpeg.c */,
|
||||
|
@ -1001,6 +1071,10 @@
|
|||
830F0BBA17FC4FB900042E8F /* libavutil */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
838490721807B07000E7332D /* md5.c */,
|
||||
838490731807B07000E7332D /* md5.h */,
|
||||
8384906E1807B04200E7332D /* lfg.c */,
|
||||
8384906F1807B04200E7332D /* lfg.h */,
|
||||
83BCB8DF17FCA64400760340 /* avconfig.h */,
|
||||
83BCB8E017FCA64400760340 /* timecode.c */,
|
||||
83BCB8E117FCA64400760340 /* timecode.h */,
|
||||
|
@ -1123,6 +1197,7 @@
|
|||
830F0D0717FC80B400042E8F /* x86 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
838490841807B17C00E7332D /* ac3dsp_init.c */,
|
||||
8393B80D18052BD500913C76 /* mpegaudiodsp.c */,
|
||||
833C37D618032EA500CBA602 /* idct_xvid.h */,
|
||||
833C37D218032E4800CBA602 /* dsputil_init.c */,
|
||||
|
@ -1198,6 +1273,7 @@
|
|||
8393B7FF18052BC200913C76 /* mpegaudiodata.h in Headers */,
|
||||
830F0CD417FC7F1E00042E8F /* dct32.h in Headers */,
|
||||
830F0CCF17FC7F1E00042E8F /* copy_block.h in Headers */,
|
||||
838490801807B17500E7332D /* eac3_data.h in Headers */,
|
||||
830F0D9317FC8EAC00042E8F /* dvdata.h in Headers */,
|
||||
830F0CEA17FC7F1E00042E8F /* imgconvert.h in Headers */,
|
||||
8393B7FB18052BC200913C76 /* mpegaudio_tablegen.h in Headers */,
|
||||
|
@ -1207,6 +1283,8 @@
|
|||
830F0D1417FC815000042E8F /* constants.h in Headers */,
|
||||
830F0C7717FC7DCB00042E8F /* avstring.h in Headers */,
|
||||
830F0BF917FC4FB900042E8F /* os_support.h in Headers */,
|
||||
8384906D1807AFB800E7332D /* aac_ac3_parser.h in Headers */,
|
||||
838490611807AF0100E7332D /* ac3dec_data.h in Headers */,
|
||||
830F0D2217FC82AB00042E8F /* eval.h in Headers */,
|
||||
830F0C2A17FC54F800042E8F /* rtpdec.h in Headers */,
|
||||
830F0CFF17FC7F1E00042E8F /* wma.h in Headers */,
|
||||
|
@ -1225,6 +1303,7 @@
|
|||
830F0C7217FC7DB100042E8F /* rc4.h in Headers */,
|
||||
830F0C2517FC527400042E8F /* bswap.h in Headers */,
|
||||
833C379F18032A2700CBA602 /* unary.h in Headers */,
|
||||
8384905F1807AF0100E7332D /* ac3.h in Headers */,
|
||||
830F0CDD17FC7F1E00042E8F /* faandct.h in Headers */,
|
||||
830F0D0B17FC80B400042E8F /* lsp_mips.h in Headers */,
|
||||
830F0C2B17FC54F800042E8F /* srtp.h in Headers */,
|
||||
|
@ -1235,7 +1314,9 @@
|
|||
830F0D3D17FC846C00042E8F /* random_seed.h in Headers */,
|
||||
830F0CCA17FC7F1E00042E8F /* bytestream.h in Headers */,
|
||||
830F0D0317FC7F4000042E8F /* sinewin_tablegen.h in Headers */,
|
||||
838490651807AF0100E7332D /* ac3dsp.h in Headers */,
|
||||
833C37C518032CF600CBA602 /* dirac_dwt.h in Headers */,
|
||||
838490751807B07000E7332D /* md5.h in Headers */,
|
||||
830F0CDF17FC7F1E00042E8F /* faanidct.h in Headers */,
|
||||
830F0DD217FC934D00042E8F /* spdif.h in Headers */,
|
||||
830F0BDE17FC4FB900042E8F /* parser.h in Headers */,
|
||||
|
@ -1251,7 +1332,9 @@
|
|||
830F0CF517FC7F1E00042E8F /* rdft.h in Headers */,
|
||||
830F0D1F17FC82AB00042E8F /* cpu_internal.h in Headers */,
|
||||
830F0C1A17FC523000042E8F /* rtp.h in Headers */,
|
||||
838490711807B04200E7332D /* lfg.h in Headers */,
|
||||
830F0D8817FC8E8B00042E8F /* aac_tablegen_decl.h in Headers */,
|
||||
838490671807AF0100E7332D /* ac3tab.h in Headers */,
|
||||
830F0BE917FC4FB900042E8F /* wmaprodata.h in Headers */,
|
||||
830F0C4917FC7CA300042E8F /* asf.h in Headers */,
|
||||
830F0DCA17FC931700042E8F /* pcm.h in Headers */,
|
||||
|
@ -1260,6 +1343,7 @@
|
|||
830F0BD717FC4FB900042E8F /* get_bits.h in Headers */,
|
||||
830F0C2417FC527400042E8F /* atomic.h in Headers */,
|
||||
830F0C5D17FC7CEA00042E8F /* id3v1.h in Headers */,
|
||||
838490631807AF0100E7332D /* ac3dec.h in Headers */,
|
||||
830F0C6A17FC7DB100042E8F /* avassert.h in Headers */,
|
||||
830F0D6D17FC8C0700042E8F /* aactab.h in Headers */,
|
||||
830F0BEC17FC4FB900042E8F /* wmavoice_data.h in Headers */,
|
||||
|
@ -1308,6 +1392,7 @@
|
|||
830F0D8A17FC8E8B00042E8F /* aacps.h in Headers */,
|
||||
833C37C818032CF600CBA602 /* dirac.h in Headers */,
|
||||
830F0BD617FC4FB900042E8F /* fft.h in Headers */,
|
||||
838490791807B13000E7332D /* kbdwin.h in Headers */,
|
||||
830F0CE317FC7F1E00042E8F /* frame_thread_encoder.h in Headers */,
|
||||
830F0BE617FC4FB900042E8F /* wmadata.h in Headers */,
|
||||
830F0C5717FC7CC300042E8F /* avlanguage.h in Headers */,
|
||||
|
@ -1322,6 +1407,7 @@
|
|||
830F0CC517FC7F1E00042E8F /* acelp_pitch_delay.h in Headers */,
|
||||
830F0D8F17FC8E8B00042E8F /* sbrdsp.h in Headers */,
|
||||
830F0CCE17FC7F1E00042E8F /* celp_math.h in Headers */,
|
||||
8384905D1807AF0100E7332D /* ac3_parser.h in Headers */,
|
||||
833C37B718032AEF00CBA602 /* dsputil_x86.h in Headers */,
|
||||
830F0CFA17FC7F1E00042E8F /* sinewin.h in Headers */,
|
||||
830F0CC717FC7F1E00042E8F /* acelp_vectors.h in Headers */,
|
||||
|
@ -1392,6 +1478,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
833C37A918032AAD00CBA602 /* img2.c in Sources */,
|
||||
838490701807B04200E7332D /* lfg.c in Sources */,
|
||||
830F0D6717FC8A3300042E8F /* options.c in Sources */,
|
||||
830F0DAF17FC8FBD00042E8F /* fmtconvert_init.c in Sources */,
|
||||
830F0DD617FC93E400042E8F /* xwma.c in Sources */,
|
||||
|
@ -1406,6 +1493,7 @@
|
|||
830F0D5A17FC893E00042E8F /* rawdec.c in Sources */,
|
||||
830F0DAE17FC8FBD00042E8F /* fft_init.c in Sources */,
|
||||
830F0D2F17FC841B00042E8F /* error.c in Sources */,
|
||||
838490781807B13000E7332D /* kbdwin.c in Sources */,
|
||||
830F0BDB17FC4FB900042E8F /* mdct.c in Sources */,
|
||||
833C37A618032A5000CBA602 /* apetag.c in Sources */,
|
||||
830F0D5817FC893E00042E8F /* bitstream.c in Sources */,
|
||||
|
@ -1414,10 +1502,12 @@
|
|||
830F0DCD17FC933100042E8F /* w64.c in Sources */,
|
||||
833C37D518032E7000CBA602 /* jrevdct.c in Sources */,
|
||||
830F0BE217FC4FB900042E8F /* utils.c in Sources */,
|
||||
838490741807B07000E7332D /* md5.c in Sources */,
|
||||
8393B80E18052BD500913C76 /* mpegaudiodsp.c in Sources */,
|
||||
8393B81418052E7400913C76 /* mpegaudiodsp.c in Sources */,
|
||||
830F0CF917FC7F1E00042E8F /* sinewin.c in Sources */,
|
||||
833C37C418032CF600CBA602 /* dirac_dwt.c in Sources */,
|
||||
838490851807B17C00E7332D /* ac3dsp_init.c in Sources */,
|
||||
830F0CE417FC7F1E00042E8F /* h264chroma_template.c in Sources */,
|
||||
830F0BEF17FC4FB900042E8F /* asf.c in Sources */,
|
||||
830F0BD517FC4FB900042E8F /* fft.c in Sources */,
|
||||
|
@ -1431,6 +1521,7 @@
|
|||
830F0CE217FC7F1E00042E8F /* frame_thread_encoder.c in Sources */,
|
||||
8393B80118052BC200913C76 /* mpegaudiodec.c in Sources */,
|
||||
830F0C3817FC554D00042E8F /* buffer.c in Sources */,
|
||||
8384905C1807AF0100E7332D /* ac3_parser.c in Sources */,
|
||||
830F0C6B17FC7DB100042E8F /* bprint.c in Sources */,
|
||||
830F0BE017FC4FB900042E8F /* simple_idct.c in Sources */,
|
||||
830F0D6917FC8A3D00042E8F /* avpicture.c in Sources */,
|
||||
|
@ -1438,6 +1529,7 @@
|
|||
830F0CDA17FC7F1E00042E8F /* error_resilience.c in Sources */,
|
||||
830F0D3317FC841B00042E8F /* opt.c in Sources */,
|
||||
830F0D7317FC8C1300042E8F /* astdec.c in Sources */,
|
||||
8384905E1807AF0100E7332D /* ac3.c in Sources */,
|
||||
830F0D5317FC891800042E8F /* file_open.c in Sources */,
|
||||
833C379D180328B300CBA602 /* takdec.c in Sources */,
|
||||
830F0D7B17FC8E2400042E8F /* avidec.c in Sources */,
|
||||
|
@ -1455,6 +1547,8 @@
|
|||
830F0D1317FC815000042E8F /* constants.c in Sources */,
|
||||
830F0BE417FC4FB900042E8F /* wma_common.c in Sources */,
|
||||
8393B7FA18052BC200913C76 /* mpegaudio_tablegen.c in Sources */,
|
||||
838490601807AF0100E7332D /* ac3dec_data.c in Sources */,
|
||||
8384907F1807B17500E7332D /* eac3_data.c in Sources */,
|
||||
830F0C5617FC7CC300042E8F /* avlanguage.c in Sources */,
|
||||
830F0C5117FC7CA300042E8F /* riffdec.c in Sources */,
|
||||
830F0D4617FC85ED00042E8F /* integer.c in Sources */,
|
||||
|
@ -1476,10 +1570,12 @@
|
|||
830F0D2117FC82AB00042E8F /* eval.c in Sources */,
|
||||
830F0C2317FC527400042E8F /* atomic.c in Sources */,
|
||||
830F0D4D17FC862400042E8F /* time.c in Sources */,
|
||||
838490661807AF0100E7332D /* ac3tab.c in Sources */,
|
||||
830F0C0817FC4FB900042E8F /* mem.c in Sources */,
|
||||
830F0CDE17FC7F1E00042E8F /* faanidct.c in Sources */,
|
||||
833C379B180328B300CBA602 /* tak.c in Sources */,
|
||||
830F0CC917FC7F1E00042E8F /* bit_depth_template.c in Sources */,
|
||||
8384906C1807AFB800E7332D /* aac_ac3_parser.c in Sources */,
|
||||
8393B7E318052BB000913C76 /* mpeg.c in Sources */,
|
||||
830F0D4017FC848D00042E8F /* sha.c in Sources */,
|
||||
830F0BF417FC4FB900042E8F /* aviobuf.c in Sources */,
|
||||
|
@ -1487,6 +1583,7 @@
|
|||
830F0DC617FC92FA00042E8F /* wavdec.c in Sources */,
|
||||
830F0BDA17FC4FB900042E8F /* mathtables.c in Sources */,
|
||||
830F0C5917FC7CC300042E8F /* utils.c in Sources */,
|
||||
838490641807AF0100E7332D /* ac3dsp.c in Sources */,
|
||||
830F0CDC17FC7F1E00042E8F /* faandct.c in Sources */,
|
||||
830F0CE017FC7F1E00042E8F /* fmtconvert.c in Sources */,
|
||||
830F0C6F17FC7DB100042E8F /* pixdesc.c in Sources */,
|
||||
|
@ -1510,6 +1607,7 @@
|
|||
830F0CFC17FC7F1E00042E8F /* videodsp.c in Sources */,
|
||||
830F0D8C17FC8E8B00042E8F /* dv_profile.c in Sources */,
|
||||
833C37B118032AEF00CBA602 /* diracdsp.c in Sources */,
|
||||
838490691807AF5800E7332D /* ac3dec.c in Sources */,
|
||||
830F0CD017FC7F1E00042E8F /* dct.c in Sources */,
|
||||
833C3795180328A300CBA602 /* takdec.c in Sources */,
|
||||
830F0DC217FC929E00042E8F /* mux.c in Sources */,
|
||||
|
@ -1532,10 +1630,12 @@
|
|||
8393B7FC18052BC200913C76 /* mpegaudio.c in Sources */,
|
||||
833C37C618032CF600CBA602 /* dirac_parser.c in Sources */,
|
||||
830F0CED17FC7F1E00042E8F /* mpeg12data.c in Sources */,
|
||||
838490811807B17500E7332D /* eac3dec.c in Sources */,
|
||||
833C37C718032CF600CBA602 /* dirac.c in Sources */,
|
||||
830F0D7E17FC8E4800042E8F /* dv.c in Sources */,
|
||||
830F0C7B17FC7E4E00042E8F /* crc.c in Sources */,
|
||||
830F0BE817FC4FB900042E8F /* wmalosslessdec.c in Sources */,
|
||||
838490621807AF0100E7332D /* ac3dec.c in Sources */,
|
||||
83BCB8E317FCA64400760340 /* timecode.c in Sources */,
|
||||
8393B80B18052BC200913C76 /* mpegaudioenc.c in Sources */,
|
||||
830F0D3517FC841B00042E8F /* samplefmt.c in Sources */,
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#define ARCH_ALPHA 0
|
||||
#define ARCH_BFIN 0
|
||||
#define ARCH_SH4 0
|
||||
#define ARCH_MIPS 0
|
||||
|
||||
#define HAVE_BIGENDIAN 0
|
||||
#define HAVE_FAST_UNALIGNED 1
|
||||
|
||||
#define HAVE_VIS 0
|
||||
|
||||
#define TUNECPU generic
|
||||
|
@ -18,6 +23,7 @@
|
|||
#define HAVE_SSSE3_EXTERNAL 0
|
||||
#define HAVE_SSE4_EXTERNAL 0
|
||||
#define emms_c()
|
||||
#define HAVE_MMX_EXTERNAL 0
|
||||
#define HAVE_MMX2 0
|
||||
#define HAVE_MMXEXT 0
|
||||
#define HAVE_MMXEXT_EXTERNAL 0
|
||||
|
@ -382,7 +388,7 @@
|
|||
#define CONFIG_AAC_DECODER 0
|
||||
#define CONFIG_AAC_LATM_DECODER 0
|
||||
#define CONFIG_AC3_ENCODER 0
|
||||
#define CONFIG_AC3_DECODER 0
|
||||
#define CONFIG_AC3_DECODER 1
|
||||
#define CONFIG_AC3_FIXED_ENCODER 0
|
||||
#define CONFIG_ALAC_ENCODER 0
|
||||
#define CONFIG_ALAC_DECODER 0
|
||||
|
@ -400,7 +406,7 @@
|
|||
#define CONFIG_DCA_DECODER 0
|
||||
#define CONFIG_DSICINAUDIO_DECODER 0
|
||||
#define CONFIG_EAC3_ENCODER 0
|
||||
#define CONFIG_EAC3_DECODER 0
|
||||
#define CONFIG_EAC3_DECODER 1
|
||||
#define CONFIG_EVRC_DECODER 0
|
||||
#define CONFIG_FFWAVESYNTH_DECODER 0
|
||||
#define CONFIG_FLAC_ENCODER 0
|
||||
|
@ -651,7 +657,7 @@
|
|||
|
||||
#define CONFIG_AAC_PARSER 0
|
||||
#define CONFIG_AAC_LATM_PARSER 0
|
||||
#define CONFIG_AC3_PARSER 0
|
||||
#define CONFIG_AC3_PARSER 1
|
||||
#define CONFIG_ADX_PARSER 0
|
||||
#define CONFIG_BMP_PARSER 0
|
||||
#define CONFIG_CAVSVIDEO_PARSER 0
|
||||
|
@ -700,7 +706,7 @@
|
|||
#define CONFIG_A64_MUXER 0
|
||||
#define CONFIG_AAC_DEMUXER 0
|
||||
#define CONFIG_AC3_MUXER 0
|
||||
#define CONFIG_AC3_DEMUXER 0
|
||||
#define CONFIG_AC3_DEMUXER 1
|
||||
#define CONFIG_ACT_DEMUXER 0
|
||||
#define CONFIG_ADF_DEMUXER 0
|
||||
#define CONFIG_ADP_DEMUXER 0
|
||||
|
@ -769,7 +775,7 @@
|
|||
#define CONFIG_EA_DEMUXER 0
|
||||
#define CONFIG_EA_CDATA_DEMUXER 0
|
||||
#define CONFIG_EAC3_MUXER 0
|
||||
#define CONFIG_EAC3_DEMUXER 0
|
||||
#define CONFIG_EAC3_DEMUXER 1
|
||||
#define CONFIG_EPAF_DEMUXER 0
|
||||
#define CONFIG_F4V_MUXER 0
|
||||
#define CONFIG_FFM_MUXER 0
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Common AAC and AC-3 parser
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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 "libavutil/common.h"
|
||||
#include "parser.h"
|
||||
#include "aac_ac3_parser.h"
|
||||
|
||||
int ff_aac_ac3_parse(AVCodecParserContext *s1,
|
||||
AVCodecContext *avctx,
|
||||
const uint8_t **poutbuf, int *poutbuf_size,
|
||||
const uint8_t *buf, int buf_size)
|
||||
{
|
||||
AACAC3ParseContext *s = s1->priv_data;
|
||||
ParseContext *pc = &s->pc;
|
||||
int len, i;
|
||||
int new_frame_start;
|
||||
|
||||
get_next:
|
||||
i=END_NOT_FOUND;
|
||||
if(s->remaining_size <= buf_size){
|
||||
if(s->remaining_size && !s->need_next_header){
|
||||
i= s->remaining_size;
|
||||
s->remaining_size = 0;
|
||||
}else{ //we need a header first
|
||||
len=0;
|
||||
for(i=s->remaining_size; i<buf_size; i++){
|
||||
s->state = (s->state<<8) + buf[i];
|
||||
if((len=s->sync(s->state, s, &s->need_next_header, &new_frame_start)))
|
||||
break;
|
||||
}
|
||||
if(len<=0){
|
||||
i=END_NOT_FOUND;
|
||||
}else{
|
||||
s->state=0;
|
||||
i-= s->header_size -1;
|
||||
s->remaining_size = len;
|
||||
if(!new_frame_start || pc->index+i<=0){
|
||||
s->remaining_size += i;
|
||||
goto get_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ff_combine_frame(pc, i, &buf, &buf_size)<0){
|
||||
s->remaining_size -= FFMIN(s->remaining_size, buf_size);
|
||||
*poutbuf = NULL;
|
||||
*poutbuf_size = 0;
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
*poutbuf = buf;
|
||||
*poutbuf_size = buf_size;
|
||||
|
||||
/* update codec info */
|
||||
if(s->codec_id)
|
||||
avctx->codec_id = s->codec_id;
|
||||
|
||||
/* Due to backwards compatible HE-AAC the sample rate, channel count,
|
||||
and total number of samples found in an AAC ADTS header are not
|
||||
reliable. Bit rate is still accurate because the total frame duration in
|
||||
seconds is still correct (as is the number of bits in the frame). */
|
||||
if (avctx->codec_id != AV_CODEC_ID_AAC) {
|
||||
avctx->sample_rate = s->sample_rate;
|
||||
|
||||
/* allow downmixing to stereo (or mono for AC-3) */
|
||||
if(avctx->request_channels > 0 &&
|
||||
avctx->request_channels < s->channels &&
|
||||
(avctx->request_channels <= 2 ||
|
||||
(avctx->request_channels == 1 &&
|
||||
(avctx->codec_id == AV_CODEC_ID_AC3 ||
|
||||
avctx->codec_id == AV_CODEC_ID_EAC3)))) {
|
||||
avctx->channels = avctx->request_channels;
|
||||
} else {
|
||||
avctx->channels = s->channels;
|
||||
avctx->channel_layout = s->channel_layout;
|
||||
}
|
||||
s1->duration = s->samples;
|
||||
avctx->audio_service_type = s->service_type;
|
||||
}
|
||||
|
||||
avctx->bit_rate = s->bit_rate;
|
||||
|
||||
return i;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Common AAC and AC-3 parser prototypes
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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_AAC_AC3_PARSER_H
|
||||
#define AVCODEC_AAC_AC3_PARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "avcodec.h"
|
||||
#include "parser.h"
|
||||
|
||||
typedef enum {
|
||||
AAC_AC3_PARSE_ERROR_SYNC = -0x1030c0a,
|
||||
AAC_AC3_PARSE_ERROR_BSID = -0x2030c0a,
|
||||
AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
|
||||
AAC_AC3_PARSE_ERROR_FRAME_SIZE = -0x4030c0a,
|
||||
AAC_AC3_PARSE_ERROR_FRAME_TYPE = -0x5030c0a,
|
||||
AAC_AC3_PARSE_ERROR_CRC = -0x6030c0a,
|
||||
AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -0x7030c0a,
|
||||
} AACAC3ParseError;
|
||||
|
||||
typedef struct AACAC3ParseContext {
|
||||
ParseContext pc;
|
||||
int frame_size;
|
||||
int header_size;
|
||||
int (*sync)(uint64_t state, struct AACAC3ParseContext *hdr_info,
|
||||
int *need_next_header, int *new_frame_start);
|
||||
|
||||
int channels;
|
||||
int sample_rate;
|
||||
int bit_rate;
|
||||
int samples;
|
||||
uint64_t channel_layout;
|
||||
int service_type;
|
||||
|
||||
int remaining_size;
|
||||
uint64_t state;
|
||||
|
||||
int need_next_header;
|
||||
enum AVCodecID codec_id;
|
||||
} AACAC3ParseContext;
|
||||
|
||||
int ff_aac_ac3_parse(AVCodecParserContext *s1,
|
||||
AVCodecContext *avctx,
|
||||
const uint8_t **poutbuf, int *poutbuf_size,
|
||||
const uint8_t *buf, int buf_size);
|
||||
|
||||
#endif /* AVCODEC_AAC_AC3_PARSER_H */
|
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* Common code between the AC-3 encoder and decoder
|
||||
* Copyright (c) 2000 Fabrice Bellard
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Common code between the AC-3 encoder and decoder.
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "ac3.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
/**
|
||||
* Starting frequency coefficient bin for each critical band.
|
||||
*/
|
||||
const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
|
||||
34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
|
||||
79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
|
||||
};
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
|
||||
/**
|
||||
* Map each frequency coefficient bin to the critical band that contains it.
|
||||
*/
|
||||
const uint8_t ff_ac3_bin_to_band_tab[253] = {
|
||||
0,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30,
|
||||
31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34,
|
||||
35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
|
||||
37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
|
||||
39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
||||
43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
|
||||
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
|
||||
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
|
||||
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
|
||||
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
|
||||
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
|
||||
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
|
||||
};
|
||||
|
||||
#else /* CONFIG_HARDCODED_TABLES */
|
||||
uint8_t ff_ac3_bin_to_band_tab[253];
|
||||
#endif
|
||||
|
||||
static inline int calc_lowcomp1(int a, int b0, int b1, int c)
|
||||
{
|
||||
if ((b0 + 256) == b1) {
|
||||
a = c;
|
||||
} else if (b0 > b1) {
|
||||
a = FFMAX(a - 64, 0);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline int calc_lowcomp(int a, int b0, int b1, int bin)
|
||||
{
|
||||
if (bin < 7) {
|
||||
return calc_lowcomp1(a, b0, b1, 384);
|
||||
} else if (bin < 20) {
|
||||
return calc_lowcomp1(a, b0, b1, 320);
|
||||
} else {
|
||||
return FFMAX(a - 128, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *band_psd)
|
||||
{
|
||||
int bin, band;
|
||||
|
||||
/* exponent mapping to PSD */
|
||||
for (bin = start; bin < end; bin++) {
|
||||
psd[bin]=(3072 - (exp[bin] << 7));
|
||||
}
|
||||
|
||||
/* PSD integration */
|
||||
bin = start;
|
||||
band = ff_ac3_bin_to_band_tab[start];
|
||||
do {
|
||||
int v = psd[bin++];
|
||||
int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end);
|
||||
for (; bin < band_end; bin++) {
|
||||
int max = FFMAX(v, psd[bin]);
|
||||
/* logadd */
|
||||
int adr = FFMIN(max - ((v + psd[bin] + 1) >> 1), 255);
|
||||
v = max + ff_ac3_log_add_tab[adr];
|
||||
}
|
||||
band_psd[band++] = v;
|
||||
} while (end > ff_ac3_band_start_tab[band]);
|
||||
}
|
||||
|
||||
int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int start, int end, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
|
||||
uint8_t *dba_lengths, uint8_t *dba_values,
|
||||
int16_t *mask)
|
||||
{
|
||||
int16_t excite[AC3_CRITICAL_BANDS]; /* excitation */
|
||||
int band;
|
||||
int band_start, band_end, begin, end1;
|
||||
int lowcomp, fastleak, slowleak;
|
||||
|
||||
/* excitation function */
|
||||
band_start = ff_ac3_bin_to_band_tab[start];
|
||||
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
|
||||
|
||||
if (band_start == 0) {
|
||||
lowcomp = 0;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
|
||||
excite[0] = band_psd[0] - fast_gain - lowcomp;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
|
||||
excite[1] = band_psd[1] - fast_gain - lowcomp;
|
||||
begin = 7;
|
||||
for (band = 2; band < 7; band++) {
|
||||
if (!(is_lfe && band == 6))
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[band], band_psd[band+1], 384);
|
||||
fastleak = band_psd[band] - fast_gain;
|
||||
slowleak = band_psd[band] - s->slow_gain;
|
||||
excite[band] = fastleak - lowcomp;
|
||||
if (!(is_lfe && band == 6)) {
|
||||
if (band_psd[band] <= band_psd[band+1]) {
|
||||
begin = band + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end1 = FFMIN(band_end, 22);
|
||||
for (band = begin; band < end1; band++) {
|
||||
if (!(is_lfe && band == 6))
|
||||
lowcomp = calc_lowcomp(lowcomp, band_psd[band], band_psd[band+1], band);
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
|
||||
excite[band] = FFMAX(fastleak - lowcomp, slowleak);
|
||||
}
|
||||
begin = 22;
|
||||
} else {
|
||||
/* coupling channel */
|
||||
begin = band_start;
|
||||
fastleak = (s->cpl_fast_leak << 8) + 768;
|
||||
slowleak = (s->cpl_slow_leak << 8) + 768;
|
||||
}
|
||||
|
||||
for (band = begin; band < band_end; band++) {
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
|
||||
excite[band] = FFMAX(fastleak, slowleak);
|
||||
}
|
||||
|
||||
/* compute masking curve */
|
||||
|
||||
for (band = band_start; band < band_end; band++) {
|
||||
int tmp = s->db_per_bit - band_psd[band];
|
||||
if (tmp > 0) {
|
||||
excite[band] += tmp >> 2;
|
||||
}
|
||||
mask[band] = FFMAX(ff_ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
|
||||
}
|
||||
|
||||
/* delta bit allocation */
|
||||
|
||||
if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
|
||||
int i, seg, delta;
|
||||
if (dba_nsegs > 8)
|
||||
return -1;
|
||||
band = band_start;
|
||||
for (seg = 0; seg < dba_nsegs; seg++) {
|
||||
band += dba_offsets[seg];
|
||||
if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
|
||||
return -1;
|
||||
if (dba_values[seg] >= 4) {
|
||||
delta = (dba_values[seg] - 3) << 7;
|
||||
} else {
|
||||
delta = (dba_values[seg] - 4) << 7;
|
||||
}
|
||||
for (i = 0; i < dba_lengths[seg]; i++) {
|
||||
mask[band++] += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize some tables.
|
||||
* note: This function must remain thread safe because it is called by the
|
||||
* AVParser init code.
|
||||
*/
|
||||
av_cold void ff_ac3_common_init(void)
|
||||
{
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
/* compute ff_ac3_bin_to_band_tab from ff_ac3_band_start_tab */
|
||||
int bin = 0, band;
|
||||
for (band = 0; band < AC3_CRITICAL_BANDS; band++) {
|
||||
int band_end = ff_ac3_band_start_tab[band+1];
|
||||
while (bin < band_end)
|
||||
ff_ac3_bin_to_band_tab[bin++] = band;
|
||||
}
|
||||
#endif /* !CONFIG_HARDCODED_TABLES */
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Common code between the AC-3 encoder and decoder
|
||||
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Common code between the AC-3 encoder and decoder.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3_H
|
||||
#define AVCODEC_AC3_H
|
||||
|
||||
#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
|
||||
#define AC3_MAX_CHANNELS 7 /**< maximum number of channels, including coupling channel */
|
||||
#define CPL_CH 0 /**< coupling channel index */
|
||||
|
||||
#define AC3_MAX_COEFS 256
|
||||
#define AC3_BLOCK_SIZE 256
|
||||
#define AC3_MAX_BLOCKS 6
|
||||
#define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
|
||||
#define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
|
||||
#define AC3_CRITICAL_BANDS 50
|
||||
#define AC3_MAX_CPL_BANDS 18
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
#include "avcodec.h"
|
||||
#include "ac3tab.h"
|
||||
|
||||
/* exponent encoding strategy */
|
||||
#define EXP_REUSE 0
|
||||
#define EXP_NEW 1
|
||||
|
||||
#define EXP_D15 1
|
||||
#define EXP_D25 2
|
||||
#define EXP_D45 3
|
||||
|
||||
/* pre-defined gain values */
|
||||
#define LEVEL_PLUS_3DB 1.4142135623730950
|
||||
#define LEVEL_PLUS_1POINT5DB 1.1892071150027209
|
||||
#define LEVEL_MINUS_1POINT5DB 0.8408964152537145
|
||||
#define LEVEL_MINUS_3DB 0.7071067811865476
|
||||
#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
|
||||
#define LEVEL_MINUS_6DB 0.5000000000000000
|
||||
#define LEVEL_MINUS_9DB 0.3535533905932738
|
||||
#define LEVEL_ZERO 0.0000000000000000
|
||||
#define LEVEL_ONE 1.0000000000000000
|
||||
|
||||
/** Delta bit allocation strategy */
|
||||
typedef enum {
|
||||
DBA_REUSE = 0,
|
||||
DBA_NEW,
|
||||
DBA_NONE,
|
||||
DBA_RESERVED
|
||||
} AC3DeltaStrategy;
|
||||
|
||||
/** Channel mode (audio coding mode) */
|
||||
typedef enum {
|
||||
AC3_CHMODE_DUALMONO = 0,
|
||||
AC3_CHMODE_MONO,
|
||||
AC3_CHMODE_STEREO,
|
||||
AC3_CHMODE_3F,
|
||||
AC3_CHMODE_2F1R,
|
||||
AC3_CHMODE_3F1R,
|
||||
AC3_CHMODE_2F2R,
|
||||
AC3_CHMODE_3F2R
|
||||
} AC3ChannelMode;
|
||||
|
||||
typedef struct AC3BitAllocParameters {
|
||||
int sr_code;
|
||||
int sr_shift;
|
||||
int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
|
||||
int cpl_fast_leak, cpl_slow_leak;
|
||||
} AC3BitAllocParameters;
|
||||
|
||||
/**
|
||||
* @struct AC3HeaderInfo
|
||||
* Coded AC-3 header values up to the lfeon element, plus derived values.
|
||||
*/
|
||||
typedef struct AC3HeaderInfo {
|
||||
/** @name Coded elements
|
||||
* @{
|
||||
*/
|
||||
uint16_t sync_word;
|
||||
uint16_t crc1;
|
||||
uint8_t sr_code;
|
||||
uint8_t bitstream_id;
|
||||
uint8_t bitstream_mode;
|
||||
uint8_t channel_mode;
|
||||
uint8_t lfe_on;
|
||||
uint8_t frame_type;
|
||||
int substreamid; ///< substream identification
|
||||
int center_mix_level; ///< Center mix level index
|
||||
int surround_mix_level; ///< Surround mix level index
|
||||
uint16_t channel_map;
|
||||
int num_blocks; ///< number of audio blocks
|
||||
/** @} */
|
||||
|
||||
/** @name Derived values
|
||||
* @{
|
||||
*/
|
||||
uint8_t sr_shift;
|
||||
uint16_t sample_rate;
|
||||
uint32_t bit_rate;
|
||||
uint8_t channels;
|
||||
uint16_t frame_size;
|
||||
uint64_t channel_layout;
|
||||
/** @} */
|
||||
} AC3HeaderInfo;
|
||||
|
||||
typedef enum {
|
||||
EAC3_FRAME_TYPE_INDEPENDENT = 0,
|
||||
EAC3_FRAME_TYPE_DEPENDENT,
|
||||
EAC3_FRAME_TYPE_AC3_CONVERT,
|
||||
EAC3_FRAME_TYPE_RESERVED
|
||||
} EAC3FrameType;
|
||||
|
||||
void ff_ac3_common_init(void);
|
||||
|
||||
/**
|
||||
* Calculate the log power-spectral density of the input signal.
|
||||
* This gives a rough estimate of signal power in the frequency domain by using
|
||||
* the spectral envelope (exponents). The psd is also separately grouped
|
||||
* into critical bands for use in the calculating the masking curve.
|
||||
* 128 units in psd = -6 dB. The dbknee parameter in AC3BitAllocParameters
|
||||
* determines the reference level.
|
||||
*
|
||||
* @param[in] exp frequency coefficient exponents
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[out] psd signal power for each frequency bin
|
||||
* @param[out] band_psd signal power for each critical band
|
||||
*/
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *band_psd);
|
||||
|
||||
/**
|
||||
* Calculate the masking curve.
|
||||
* First, the excitation is calculated using parameters in s and the signal
|
||||
* power in each critical band. The excitation is compared with a predefined
|
||||
* hearing threshold table to produce the masking curve. If delta bit
|
||||
* allocation information is provided, it is used for adjusting the masking
|
||||
* curve, usually to give a closer match to a better psychoacoustic model.
|
||||
*
|
||||
* @param[in] s adjustable bit allocation parameters
|
||||
* @param[in] band_psd signal power for each critical band
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] fast_gain fast gain (estimated signal-to-mask ratio)
|
||||
* @param[in] is_lfe whether or not the channel being processed is the LFE
|
||||
* @param[in] dba_mode delta bit allocation mode (none, reuse, or new)
|
||||
* @param[in] dba_nsegs number of delta segments
|
||||
* @param[in] dba_offsets location offsets for each segment
|
||||
* @param[in] dba_lengths length of each segment
|
||||
* @param[in] dba_values delta bit allocation for each segment
|
||||
* @param[out] mask calculated masking curve
|
||||
* @return returns 0 for success, non-zero for error
|
||||
*/
|
||||
int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int start, int end, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
|
||||
uint8_t *dba_lengths, uint8_t *dba_values,
|
||||
int16_t *mask);
|
||||
|
||||
#endif /* AVCODEC_AC3_H */
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* AC-3 parser
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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 "libavutil/channel_layout.h"
|
||||
#include "parser.h"
|
||||
#include "ac3_parser.h"
|
||||
#include "aac_ac3_parser.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
|
||||
#define AC3_HEADER_SIZE 7
|
||||
|
||||
|
||||
static const uint8_t eac3_blocks[4] = {
|
||||
1, 2, 3, 6
|
||||
};
|
||||
|
||||
/**
|
||||
* Table for center mix levels
|
||||
* reference: Section 5.4.2.4 cmixlev
|
||||
*/
|
||||
static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
|
||||
|
||||
/**
|
||||
* Table for surround mix levels
|
||||
* reference: Section 5.4.2.5 surmixlev
|
||||
*/
|
||||
static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
|
||||
|
||||
|
||||
int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
|
||||
{
|
||||
int frame_size_code;
|
||||
|
||||
memset(hdr, 0, sizeof(*hdr));
|
||||
|
||||
hdr->sync_word = get_bits(gbc, 16);
|
||||
if(hdr->sync_word != 0x0B77)
|
||||
return AAC_AC3_PARSE_ERROR_SYNC;
|
||||
|
||||
/* read ahead to bsid to distinguish between AC-3 and E-AC-3 */
|
||||
hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F;
|
||||
if(hdr->bitstream_id > 16)
|
||||
return AAC_AC3_PARSE_ERROR_BSID;
|
||||
|
||||
hdr->num_blocks = 6;
|
||||
|
||||
/* set default mix levels */
|
||||
hdr->center_mix_level = 5; // -4.5dB
|
||||
hdr->surround_mix_level = 6; // -6.0dB
|
||||
|
||||
if(hdr->bitstream_id <= 10) {
|
||||
/* Normal AC-3 */
|
||||
hdr->crc1 = get_bits(gbc, 16);
|
||||
hdr->sr_code = get_bits(gbc, 2);
|
||||
if(hdr->sr_code == 3)
|
||||
return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
|
||||
|
||||
frame_size_code = get_bits(gbc, 6);
|
||||
if(frame_size_code > 37)
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||||
|
||||
skip_bits(gbc, 5); // skip bsid, already got it
|
||||
|
||||
hdr->bitstream_mode = get_bits(gbc, 3);
|
||||
hdr->channel_mode = get_bits(gbc, 3);
|
||||
|
||||
if(hdr->channel_mode == AC3_CHMODE_STEREO) {
|
||||
skip_bits(gbc, 2); // skip dsurmod
|
||||
} else {
|
||||
if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO)
|
||||
hdr-> center_mix_level = center_levels[get_bits(gbc, 2)];
|
||||
if(hdr->channel_mode & 4)
|
||||
hdr->surround_mix_level = surround_levels[get_bits(gbc, 2)];
|
||||
}
|
||||
hdr->lfe_on = get_bits1(gbc);
|
||||
|
||||
hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;
|
||||
hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
|
||||
hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift;
|
||||
hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
|
||||
hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2;
|
||||
hdr->frame_type = EAC3_FRAME_TYPE_AC3_CONVERT; //EAC3_FRAME_TYPE_INDEPENDENT;
|
||||
hdr->substreamid = 0;
|
||||
} else {
|
||||
/* Enhanced AC-3 */
|
||||
hdr->crc1 = 0;
|
||||
hdr->frame_type = get_bits(gbc, 2);
|
||||
if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED)
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
|
||||
|
||||
hdr->substreamid = get_bits(gbc, 3);
|
||||
|
||||
hdr->frame_size = (get_bits(gbc, 11) + 1) << 1;
|
||||
if(hdr->frame_size < AC3_HEADER_SIZE)
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||||
|
||||
hdr->sr_code = get_bits(gbc, 2);
|
||||
if (hdr->sr_code == 3) {
|
||||
int sr_code2 = get_bits(gbc, 2);
|
||||
if(sr_code2 == 3)
|
||||
return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
|
||||
hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;
|
||||
hdr->sr_shift = 1;
|
||||
} else {
|
||||
hdr->num_blocks = eac3_blocks[get_bits(gbc, 2)];
|
||||
hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code];
|
||||
hdr->sr_shift = 0;
|
||||
}
|
||||
|
||||
hdr->channel_mode = get_bits(gbc, 3);
|
||||
hdr->lfe_on = get_bits1(gbc);
|
||||
|
||||
hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate /
|
||||
(hdr->num_blocks * 256.0));
|
||||
hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
|
||||
}
|
||||
hdr->channel_layout = avpriv_ac3_channel_layout_tab[hdr->channel_mode];
|
||||
if (hdr->lfe_on)
|
||||
hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
|
||||
int *need_next_header, int *new_frame_start)
|
||||
{
|
||||
int err;
|
||||
union {
|
||||
uint64_t u64;
|
||||
uint8_t u8[8];
|
||||
} tmp = { av_be2ne64(state) };
|
||||
AC3HeaderInfo hdr;
|
||||
GetBitContext gbc;
|
||||
|
||||
init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
|
||||
err = avpriv_ac3_parse_header(&gbc, &hdr);
|
||||
|
||||
if(err < 0)
|
||||
return 0;
|
||||
|
||||
hdr_info->sample_rate = hdr.sample_rate;
|
||||
hdr_info->bit_rate = hdr.bit_rate;
|
||||
hdr_info->channels = hdr.channels;
|
||||
hdr_info->channel_layout = hdr.channel_layout;
|
||||
hdr_info->samples = hdr.num_blocks * 256;
|
||||
hdr_info->service_type = hdr.bitstream_mode;
|
||||
if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
|
||||
hdr_info->service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
|
||||
if(hdr.bitstream_id>10)
|
||||
hdr_info->codec_id = AV_CODEC_ID_EAC3;
|
||||
else if (hdr_info->codec_id == AV_CODEC_ID_NONE)
|
||||
hdr_info->codec_id = AV_CODEC_ID_AC3;
|
||||
|
||||
*need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT);
|
||||
*new_frame_start = (hdr.frame_type != EAC3_FRAME_TYPE_DEPENDENT);
|
||||
return hdr.frame_size;
|
||||
}
|
||||
|
||||
static av_cold int ac3_parse_init(AVCodecParserContext *s1)
|
||||
{
|
||||
AACAC3ParseContext *s = s1->priv_data;
|
||||
s->header_size = AC3_HEADER_SIZE;
|
||||
s->sync = ac3_sync;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
AVCodecParser ff_ac3_parser = {
|
||||
.codec_ids = { AV_CODEC_ID_AC3, AV_CODEC_ID_EAC3 },
|
||||
.priv_data_size = sizeof(AACAC3ParseContext),
|
||||
.parser_init = ac3_parse_init,
|
||||
.parser_parse = ff_aac_ac3_parse,
|
||||
.parser_close = ff_parse_close,
|
||||
};
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* AC-3 parser prototypes
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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_AC3_PARSER_H
|
||||
#define AVCODEC_AC3_PARSER_H
|
||||
|
||||
#include "ac3.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
/**
|
||||
* Parse AC-3 frame header.
|
||||
* Parse the header up to the lfeon element, which is the first 52 or 54 bits
|
||||
* depending on the audio coding mode.
|
||||
* @param[in] gbc BitContext containing the first 54 bits of the frame.
|
||||
* @param[out] hdr Pointer to struct where header info is written.
|
||||
* @return Returns 0 on success, -1 if there is a sync word mismatch,
|
||||
* -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate)
|
||||
* element is invalid, or -4 if the frmsizecod (bit rate) element is invalid.
|
||||
*/
|
||||
int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
|
||||
|
||||
#endif /* AVCODEC_AC3_PARSER_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* Common code between the AC-3 and E-AC-3 decoders
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Common code between the AC-3 and E-AC-3 decoders.
|
||||
*
|
||||
* Summary of MDCT Coefficient Grouping:
|
||||
* The individual MDCT coefficient indices are often referred to in the
|
||||
* (E-)AC-3 specification as frequency bins. These bins are grouped together
|
||||
* into subbands of 12 coefficients each. The subbands are grouped together
|
||||
* into bands as defined in the bitstream by the band structures, which
|
||||
* determine the number of bands and the size of each band. The full spectrum
|
||||
* of 256 frequency bins is divided into 1 DC bin + 21 subbands = 253 bins.
|
||||
* This system of grouping coefficients is used for channel bandwidth, stereo
|
||||
* rematrixing, channel coupling, enhanced coupling, and spectral extension.
|
||||
*
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* |1| |12| | [12|12|12|12] | | | | | | | | | | | | |3|
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* ~~~ ~~~~ ~~~~~~~~~~~~~ ~~~
|
||||
* | | | |
|
||||
* | | | 3 unused frequency bins--+
|
||||
* | | |
|
||||
* | | +--1 band containing 4 subbands
|
||||
* | |
|
||||
* | +--1 subband of 12 frequency bins
|
||||
* |
|
||||
* +--DC frequency bin
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3DEC_H
|
||||
#define AVCODEC_AC3DEC_H
|
||||
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/lfg.h"
|
||||
#include "ac3.h"
|
||||
#include "ac3dsp.h"
|
||||
#include "get_bits.h"
|
||||
#include "dsputil.h"
|
||||
#include "fft.h"
|
||||
#include "fmtconvert.h"
|
||||
|
||||
#define AC3_OUTPUT_LFEON 8
|
||||
|
||||
#define SPX_MAX_BANDS 17
|
||||
|
||||
/** Large enough for maximum possible frame size when the specification limit is ignored */
|
||||
#define AC3_FRAME_BUFFER_SIZE 32768
|
||||
|
||||
typedef struct AC3DecodeContext {
|
||||
AVClass *class; ///< class for AVOptions
|
||||
AVCodecContext *avctx; ///< parent context
|
||||
GetBitContext gbc; ///< bitstream reader
|
||||
|
||||
///@name Bit stream information
|
||||
///@{
|
||||
int frame_type; ///< frame type (strmtyp)
|
||||
int substreamid; ///< substream identification
|
||||
int frame_size; ///< current frame size, in bytes
|
||||
int bit_rate; ///< stream bit rate, in bits-per-second
|
||||
int sample_rate; ///< sample frequency, in Hz
|
||||
int num_blocks; ///< number of audio blocks
|
||||
int bitstream_mode; ///< bitstream mode (bsmod)
|
||||
int channel_mode; ///< channel mode (acmod)
|
||||
int channel_layout; ///< channel layout
|
||||
int lfe_on; ///< lfe channel in use
|
||||
int channel_map; ///< custom channel map
|
||||
int center_mix_level; ///< Center mix level index
|
||||
int surround_mix_level; ///< Surround mix level index
|
||||
int eac3; ///< indicates if current frame is E-AC-3
|
||||
///@}
|
||||
|
||||
int preferred_stereo_downmix;
|
||||
float ltrt_center_mix_level;
|
||||
float ltrt_surround_mix_level;
|
||||
float loro_center_mix_level;
|
||||
float loro_surround_mix_level;
|
||||
|
||||
///@name Frame syntax parameters
|
||||
int snr_offset_strategy; ///< SNR offset strategy (snroffststr)
|
||||
int block_switch_syntax; ///< block switch syntax enabled (blkswe)
|
||||
int dither_flag_syntax; ///< dither flag syntax enabled (dithflage)
|
||||
int bit_allocation_syntax; ///< bit allocation model syntax enabled (bamode)
|
||||
int fast_gain_syntax; ///< fast gain codes enabled (frmfgaincode)
|
||||
int dba_syntax; ///< delta bit allocation syntax enabled (dbaflde)
|
||||
int skip_syntax; ///< skip field syntax enabled (skipflde)
|
||||
///@}
|
||||
|
||||
///@name Standard coupling
|
||||
int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu)
|
||||
int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre)
|
||||
int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl)
|
||||
int phase_flags_in_use; ///< phase flags in use (phsflginu)
|
||||
int phase_flags[AC3_MAX_CPL_BANDS]; ///< phase flags (phsflg)
|
||||
int num_cpl_bands; ///< number of coupling bands (ncplbnd)
|
||||
uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band
|
||||
int firstchincpl; ///< first channel in coupling
|
||||
int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states (firstcplcos)
|
||||
int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; ///< coupling coordinates (cplco)
|
||||
///@}
|
||||
|
||||
///@name Spectral extension
|
||||
///@{
|
||||
int spx_in_use; ///< spectral extension in use (spxinu)
|
||||
uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx)
|
||||
int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
|
||||
int spx_src_start_freq; ///< spx start frequency bin
|
||||
int spx_dst_end_freq; ///< spx end frequency bin
|
||||
int spx_dst_start_freq; ///< spx starting frequency bin for copying (copystartmant)
|
||||
///< the copy region ends at the start of the spx region.
|
||||
int num_spx_bands; ///< number of spx bands (nspxbnds)
|
||||
uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
|
||||
uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
|
||||
float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
|
||||
float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
|
||||
///@}
|
||||
|
||||
///@name Adaptive hybrid transform
|
||||
int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
|
||||
int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas
|
||||
///@}
|
||||
|
||||
///@name Channel
|
||||
int fbw_channels; ///< number of full-bandwidth channels
|
||||
int channels; ///< number of total channels
|
||||
int lfe_ch; ///< index of LFE channel
|
||||
float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients
|
||||
int downmixed; ///< indicates if coeffs are currently downmixed
|
||||
int output_mode; ///< output channel configuration
|
||||
int out_channels; ///< number of output channels
|
||||
///@}
|
||||
|
||||
///@name Dynamic range
|
||||
float dynamic_range[2]; ///< dynamic range
|
||||
float drc_scale; ///< percentage of dynamic range compression to be applied
|
||||
///@}
|
||||
|
||||
///@name Bandwidth
|
||||
int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant)
|
||||
int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
|
||||
///@}
|
||||
|
||||
///@name Rematrixing
|
||||
int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd)
|
||||
int rematrixing_flags[4]; ///< rematrixing flags (rematflg)
|
||||
///@}
|
||||
|
||||
///@name Exponents
|
||||
int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp)
|
||||
int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents
|
||||
int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr)
|
||||
///@}
|
||||
|
||||
///@name Bit allocation
|
||||
AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters
|
||||
int first_cpl_leak; ///< first coupling leak state (firstcplleak)
|
||||
int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets (snroffst)
|
||||
int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain)
|
||||
uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers
|
||||
int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents
|
||||
int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents
|
||||
int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< masking curve values
|
||||
int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode
|
||||
int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments
|
||||
uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
|
||||
uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
|
||||
uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment
|
||||
///@}
|
||||
|
||||
///@name Zero-mantissa dithering
|
||||
int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags (dithflg)
|
||||
AVLFG dith_state; ///< for dither generation
|
||||
///@}
|
||||
|
||||
///@name IMDCT
|
||||
int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw)
|
||||
FFTContext imdct_512; ///< for 512 sample IMDCT
|
||||
FFTContext imdct_256; ///< for 256 sample IMDCT
|
||||
///@}
|
||||
|
||||
///@name Optimization
|
||||
DSPContext dsp; ///< for optimization
|
||||
AVFloatDSPContext fdsp;
|
||||
AC3DSPContext ac3dsp;
|
||||
FmtConvertContext fmt_conv; ///< optimized conversion functions
|
||||
///@}
|
||||
|
||||
float *outptr[AC3_MAX_CHANNELS];
|
||||
float *xcfptr[AC3_MAX_CHANNELS];
|
||||
float *dlyptr[AC3_MAX_CHANNELS];
|
||||
|
||||
///@name Aligned arrays
|
||||
DECLARE_ALIGNED(16, int32_t, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
|
||||
DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
|
||||
DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
|
||||
DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients
|
||||
DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
|
||||
DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
|
||||
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
|
||||
///@}
|
||||
} AC3DecodeContext;
|
||||
|
||||
/**
|
||||
* Parse the E-AC-3 frame header.
|
||||
* This parses both the bit stream info and audio frame header.
|
||||
*/
|
||||
int ff_eac3_parse_header(AC3DecodeContext *s);
|
||||
|
||||
/**
|
||||
* Decode mantissas in a single channel for the entire frame.
|
||||
* This is used when AHT mode is enabled.
|
||||
*/
|
||||
void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
|
||||
|
||||
/**
|
||||
* Apply spectral extension to each channel by copying lower frequency
|
||||
* coefficients to higher frequency bins and applying side information to
|
||||
* approximate the original high frequency signal.
|
||||
*/
|
||||
void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_H */
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* AC-3 and E-AC-3 decoder tables
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tables taken directly from the AC-3 spec.
|
||||
*/
|
||||
|
||||
#include "ac3dec_data.h"
|
||||
#include "ac3.h"
|
||||
|
||||
/**
|
||||
* Table used to ungroup 3 values stored in 5 bits.
|
||||
* Used by bap=1 mantissas and GAQ.
|
||||
* ff_ac3_ungroup_3_in_5_bits_tab[i] = { i/9, (i%9)/3, (i%9)%3 }
|
||||
*/
|
||||
const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3] = {
|
||||
{ 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 1, 0 },
|
||||
{ 0, 1, 1 }, { 0, 1, 2 }, { 0, 2, 0 }, { 0, 2, 1 },
|
||||
{ 0, 2, 2 }, { 1, 0, 0 }, { 1, 0, 1 }, { 1, 0, 2 },
|
||||
{ 1, 1, 0 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 2, 0 },
|
||||
{ 1, 2, 1 }, { 1, 2, 2 }, { 2, 0, 0 }, { 2, 0, 1 },
|
||||
{ 2, 0, 2 }, { 2, 1, 0 }, { 2, 1, 1 }, { 2, 1, 2 },
|
||||
{ 2, 2, 0 }, { 2, 2, 1 }, { 2, 2, 2 }, { 3, 0, 0 },
|
||||
{ 3, 0, 1 }, { 3, 0, 2 }, { 3, 1, 0 }, { 3, 1, 1 }
|
||||
};
|
||||
|
||||
const uint8_t ff_eac3_hebap_tab[64] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
|
||||
8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
|
||||
11, 11, 11, 12, 12, 12, 12, 13, 13, 13,
|
||||
13, 14, 14, 14, 14, 15, 15, 15, 15, 16,
|
||||
16, 16, 16, 17, 17, 17, 17, 18, 18, 18,
|
||||
18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 19,
|
||||
};
|
||||
|
||||
/**
|
||||
* Table E2.15 Default Spectral Extension Banding Structure
|
||||
*/
|
||||
const uint8_t ff_eac3_default_spx_band_struct[17] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* AC-3 and E-AC-3 decoder tables
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3DEC_DATA_H
|
||||
#define AVCODEC_AC3DEC_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
|
||||
|
||||
extern const uint8_t ff_eac3_hebap_tab[64];
|
||||
extern const uint8_t ff_eac3_default_spx_band_struct[17];
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_DATA_H */
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* AC-3 DSP utils
|
||||
* Copyright (c) 2011 Justin Ruggles
|
||||
*
|
||||
* 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 "libavutil/avassert.h"
|
||||
#include "avcodec.h"
|
||||
#include "ac3.h"
|
||||
#include "ac3dsp.h"
|
||||
#include "mathops.h"
|
||||
|
||||
static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
|
||||
{
|
||||
int blk, i;
|
||||
|
||||
if (!num_reuse_blocks)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nb_coefs; i++) {
|
||||
uint8_t min_exp = *exp;
|
||||
uint8_t *exp1 = exp + 256;
|
||||
for (blk = 0; blk < num_reuse_blocks; blk++) {
|
||||
uint8_t next_exp = *exp1;
|
||||
if (next_exp < min_exp)
|
||||
min_exp = next_exp;
|
||||
exp1 += 256;
|
||||
}
|
||||
*exp++ = min_exp;
|
||||
}
|
||||
}
|
||||
|
||||
static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
|
||||
{
|
||||
int i, v = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
v |= abs(src[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
|
||||
unsigned int shift)
|
||||
{
|
||||
uint32_t *src32 = (uint32_t *)src;
|
||||
const uint32_t mask = ~(((1 << shift) - 1) << 16);
|
||||
int i;
|
||||
len >>= 1;
|
||||
for (i = 0; i < len; i += 8) {
|
||||
src32[i ] = (src32[i ] << shift) & mask;
|
||||
src32[i+1] = (src32[i+1] << shift) & mask;
|
||||
src32[i+2] = (src32[i+2] << shift) & mask;
|
||||
src32[i+3] = (src32[i+3] << shift) & mask;
|
||||
src32[i+4] = (src32[i+4] << shift) & mask;
|
||||
src32[i+5] = (src32[i+5] << shift) & mask;
|
||||
src32[i+6] = (src32[i+6] << shift) & mask;
|
||||
src32[i+7] = (src32[i+7] << shift) & mask;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac3_rshift_int32_c(int32_t *src, unsigned int len,
|
||||
unsigned int shift)
|
||||
{
|
||||
do {
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
*src++ >>= shift;
|
||||
len -= 8;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
|
||||
{
|
||||
const float scale = 1 << 24;
|
||||
do {
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
*dst++ = lrintf(*src++ * scale);
|
||||
len -= 8;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
|
||||
int start, int end,
|
||||
int snr_offset, int floor,
|
||||
const uint8_t *bap_tab, uint8_t *bap)
|
||||
{
|
||||
int bin, band, band_end;
|
||||
|
||||
/* special case, if snr offset is -960, set all bap's to zero */
|
||||
if (snr_offset == -960) {
|
||||
memset(bap, 0, AC3_MAX_COEFS);
|
||||
return;
|
||||
}
|
||||
|
||||
bin = start;
|
||||
band = ff_ac3_bin_to_band_tab[start];
|
||||
do {
|
||||
int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
|
||||
band_end = ff_ac3_band_start_tab[++band];
|
||||
band_end = FFMIN(band_end, end);
|
||||
|
||||
for (; bin < band_end; bin++) {
|
||||
int address = av_clip((psd[bin] - m) >> 5, 0, 63);
|
||||
bap[bin] = bap_tab[address];
|
||||
}
|
||||
} while (end > band_end);
|
||||
}
|
||||
|
||||
static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap,
|
||||
int len)
|
||||
{
|
||||
while (len-- > 0)
|
||||
mant_cnt[bap[len]]++;
|
||||
}
|
||||
|
||||
DECLARE_ALIGNED(16, const uint16_t, ff_ac3_bap_bits)[16] = {
|
||||
0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
|
||||
};
|
||||
|
||||
static int ac3_compute_mantissa_size_c(uint16_t mant_cnt[6][16])
|
||||
{
|
||||
int blk, bap;
|
||||
int bits = 0;
|
||||
|
||||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
|
||||
// bap=1 : 3 mantissas in 5 bits
|
||||
bits += (mant_cnt[blk][1] / 3) * 5;
|
||||
// bap=2 : 3 mantissas in 7 bits
|
||||
// bap=4 : 2 mantissas in 7 bits
|
||||
bits += ((mant_cnt[blk][2] / 3) + (mant_cnt[blk][4] >> 1)) * 7;
|
||||
// bap=3 : 1 mantissa in 3 bits
|
||||
bits += mant_cnt[blk][3] * 3;
|
||||
// bap=5 to 15 : get bits per mantissa from table
|
||||
for (bap = 5; bap < 16; bap++)
|
||||
bits += mant_cnt[blk][bap] * ff_ac3_bap_bits[bap];
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
static void ac3_extract_exponents_c(uint8_t *exp, int32_t *coef, int nb_coefs)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nb_coefs; i++) {
|
||||
int v = abs(coef[i]);
|
||||
exp[i] = v ? 23 - av_log2(v) : 24;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac3_sum_square_butterfly_int32_c(int64_t sum[4],
|
||||
const int32_t *coef0,
|
||||
const int32_t *coef1,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
sum[0] = sum[1] = sum[2] = sum[3] = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
int lt = coef0[i];
|
||||
int rt = coef1[i];
|
||||
int md = lt + rt;
|
||||
int sd = lt - rt;
|
||||
MAC64(sum[0], lt, lt);
|
||||
MAC64(sum[1], rt, rt);
|
||||
MAC64(sum[2], md, md);
|
||||
MAC64(sum[3], sd, sd);
|
||||
}
|
||||
}
|
||||
|
||||
static void ac3_sum_square_butterfly_float_c(float sum[4],
|
||||
const float *coef0,
|
||||
const float *coef1,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
sum[0] = sum[1] = sum[2] = sum[3] = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
float lt = coef0[i];
|
||||
float rt = coef1[i];
|
||||
float md = lt + rt;
|
||||
float sd = lt - rt;
|
||||
sum[0] += lt * lt;
|
||||
sum[1] += rt * rt;
|
||||
sum[2] += md * md;
|
||||
sum[3] += sd * sd;
|
||||
}
|
||||
}
|
||||
|
||||
static void ac3_downmix_c(float **samples, float (*matrix)[2],
|
||||
int out_ch, int in_ch, int len)
|
||||
{
|
||||
int i, j;
|
||||
float v0, v1;
|
||||
if (out_ch == 2) {
|
||||
for (i = 0; i < len; i++) {
|
||||
v0 = v1 = 0.0f;
|
||||
for (j = 0; j < in_ch; j++) {
|
||||
v0 += samples[j][i] * matrix[j][0];
|
||||
v1 += samples[j][i] * matrix[j][1];
|
||||
}
|
||||
samples[0][i] = v0;
|
||||
samples[1][i] = v1;
|
||||
}
|
||||
} else if (out_ch == 1) {
|
||||
for (i = 0; i < len; i++) {
|
||||
v0 = 0.0f;
|
||||
for (j = 0; j < in_ch; j++)
|
||||
v0 += samples[j][i] * matrix[j][0];
|
||||
samples[0][i] = v0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
|
||||
{
|
||||
c->ac3_exponent_min = ac3_exponent_min_c;
|
||||
c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c;
|
||||
c->ac3_lshift_int16 = ac3_lshift_int16_c;
|
||||
c->ac3_rshift_int32 = ac3_rshift_int32_c;
|
||||
c->float_to_fixed24 = float_to_fixed24_c;
|
||||
c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_c;
|
||||
c->update_bap_counts = ac3_update_bap_counts_c;
|
||||
c->compute_mantissa_size = ac3_compute_mantissa_size_c;
|
||||
c->extract_exponents = ac3_extract_exponents_c;
|
||||
c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c;
|
||||
c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c;
|
||||
c->downmix = ac3_downmix_c;
|
||||
|
||||
if (ARCH_ARM)
|
||||
ff_ac3dsp_init_arm(c, bit_exact);
|
||||
if (ARCH_X86)
|
||||
ff_ac3dsp_init_x86(c, bit_exact);
|
||||
if (ARCH_MIPS)
|
||||
ff_ac3dsp_init_mips(c, bit_exact);
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* AC-3 DSP utils
|
||||
* Copyright (c) 2011 Justin Ruggles
|
||||
*
|
||||
* 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_AC3DSP_H
|
||||
#define AVCODEC_AC3DSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Number of mantissa bits written for each bap value.
|
||||
* bap values with fractional bits are set to 0 and are calculated separately.
|
||||
*/
|
||||
extern const uint16_t ff_ac3_bap_bits[16];
|
||||
|
||||
typedef struct AC3DSPContext {
|
||||
/**
|
||||
* Set each encoded exponent in a block to the minimum of itself and the
|
||||
* exponents in the same frequency bin of up to 5 following blocks.
|
||||
* @param exp pointer to the start of the current block of exponents.
|
||||
* constraints: align 16
|
||||
* @param num_reuse_blocks number of blocks that will reuse exponents from the current block.
|
||||
* constraints: range 0 to 5
|
||||
* @param nb_coefs number of frequency coefficients.
|
||||
*/
|
||||
void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
||||
|
||||
/**
|
||||
* Calculate the maximum MSB of the absolute value of each element in an
|
||||
* array of int16_t.
|
||||
* @param src input array
|
||||
* constraints: align 16. values must be in range [-32767,32767]
|
||||
* @param len number of values in the array
|
||||
* constraints: multiple of 16 greater than 0
|
||||
* @return a value with the same MSB as max(abs(src[]))
|
||||
*/
|
||||
int (*ac3_max_msb_abs_int16)(const int16_t *src, int len);
|
||||
|
||||
/**
|
||||
* Left-shift each value in an array of int16_t by a specified amount.
|
||||
* @param src input array
|
||||
* constraints: align 16
|
||||
* @param len number of values in the array
|
||||
* constraints: multiple of 32 greater than 0
|
||||
* @param shift left shift amount
|
||||
* constraints: range [0,15]
|
||||
*/
|
||||
void (*ac3_lshift_int16)(int16_t *src, unsigned int len, unsigned int shift);
|
||||
|
||||
/**
|
||||
* Right-shift each value in an array of int32_t by a specified amount.
|
||||
* @param src input array
|
||||
* constraints: align 16
|
||||
* @param len number of values in the array
|
||||
* constraints: multiple of 16 greater than 0
|
||||
* @param shift right shift amount
|
||||
* constraints: range [0,31]
|
||||
*/
|
||||
void (*ac3_rshift_int32)(int32_t *src, unsigned int len, unsigned int shift);
|
||||
|
||||
/**
|
||||
* Convert an array of float in range [-1.0,1.0] to int32_t with range
|
||||
* [-(1<<24),(1<<24)]
|
||||
*
|
||||
* @param dst destination array of int32_t.
|
||||
* constraints: 16-byte aligned
|
||||
* @param src source array of float.
|
||||
* constraints: 16-byte aligned
|
||||
* @param len number of elements to convert.
|
||||
* constraints: multiple of 32 greater than zero
|
||||
*/
|
||||
void (*float_to_fixed24)(int32_t *dst, const float *src, unsigned int len);
|
||||
|
||||
/**
|
||||
* Calculate bit allocation pointers.
|
||||
* The SNR is the difference between the masking curve and the signal. AC-3
|
||||
* uses this value for each frequency bin to allocate bits. The snroffset
|
||||
* parameter is a global adjustment to the SNR for all bins.
|
||||
*
|
||||
* @param[in] mask masking curve
|
||||
* @param[in] psd signal power for each frequency bin
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] snr_offset SNR adjustment
|
||||
* @param[in] floor noise floor
|
||||
* @param[in] bap_tab look-up table for bit allocation pointers
|
||||
* @param[out] bap bit allocation pointers
|
||||
*/
|
||||
void (*bit_alloc_calc_bap)(int16_t *mask, int16_t *psd, int start, int end,
|
||||
int snr_offset, int floor,
|
||||
const uint8_t *bap_tab, uint8_t *bap);
|
||||
|
||||
/**
|
||||
* Update bap counts using the supplied array of bap.
|
||||
*
|
||||
* @param[out] mant_cnt bap counts for 1 block
|
||||
* @param[in] bap array of bap, pointing to start coef bin
|
||||
* @param[in] len number of elements to process
|
||||
*/
|
||||
void (*update_bap_counts)(uint16_t mant_cnt[16], uint8_t *bap, int len);
|
||||
|
||||
/**
|
||||
* Calculate the number of bits needed to encode a set of mantissas.
|
||||
*
|
||||
* @param[in] mant_cnt bap counts for all blocks
|
||||
* @return mantissa bit count
|
||||
*/
|
||||
int (*compute_mantissa_size)(uint16_t mant_cnt[6][16]);
|
||||
|
||||
void (*extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
|
||||
void (*sum_square_butterfly_int32)(int64_t sum[4], const int32_t *coef0,
|
||||
const int32_t *coef1, int len);
|
||||
|
||||
void (*sum_square_butterfly_float)(float sum[4], const float *coef0,
|
||||
const float *coef1, int len);
|
||||
|
||||
void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
|
||||
int in_ch, int len);
|
||||
} AC3DSPContext;
|
||||
|
||||
void ff_ac3dsp_init (AC3DSPContext *c, int bit_exact);
|
||||
void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact);
|
||||
void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact);
|
||||
void ff_ac3dsp_init_mips(AC3DSPContext *c, int bit_exact);
|
||||
|
||||
#endif /* AVCODEC_AC3DSP_H */
|
|
@ -0,0 +1,314 @@
|
|||
/*
|
||||
* AC-3 tables
|
||||
* copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* tables taken directly from the AC-3 spec.
|
||||
*/
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "avcodec.h"
|
||||
#include "ac3tab.h"
|
||||
|
||||
/**
|
||||
* Possible frame sizes.
|
||||
* from ATSC A/52 Table 5.18 Frame Size Code Table.
|
||||
*/
|
||||
const uint16_t ff_ac3_frame_size_tab[38][3] = {
|
||||
{ 64, 69, 96 },
|
||||
{ 64, 70, 96 },
|
||||
{ 80, 87, 120 },
|
||||
{ 80, 88, 120 },
|
||||
{ 96, 104, 144 },
|
||||
{ 96, 105, 144 },
|
||||
{ 112, 121, 168 },
|
||||
{ 112, 122, 168 },
|
||||
{ 128, 139, 192 },
|
||||
{ 128, 140, 192 },
|
||||
{ 160, 174, 240 },
|
||||
{ 160, 175, 240 },
|
||||
{ 192, 208, 288 },
|
||||
{ 192, 209, 288 },
|
||||
{ 224, 243, 336 },
|
||||
{ 224, 244, 336 },
|
||||
{ 256, 278, 384 },
|
||||
{ 256, 279, 384 },
|
||||
{ 320, 348, 480 },
|
||||
{ 320, 349, 480 },
|
||||
{ 384, 417, 576 },
|
||||
{ 384, 418, 576 },
|
||||
{ 448, 487, 672 },
|
||||
{ 448, 488, 672 },
|
||||
{ 512, 557, 768 },
|
||||
{ 512, 558, 768 },
|
||||
{ 640, 696, 960 },
|
||||
{ 640, 697, 960 },
|
||||
{ 768, 835, 1152 },
|
||||
{ 768, 836, 1152 },
|
||||
{ 896, 975, 1344 },
|
||||
{ 896, 976, 1344 },
|
||||
{ 1024, 1114, 1536 },
|
||||
{ 1024, 1115, 1536 },
|
||||
{ 1152, 1253, 1728 },
|
||||
{ 1152, 1254, 1728 },
|
||||
{ 1280, 1393, 1920 },
|
||||
{ 1280, 1394, 1920 },
|
||||
};
|
||||
|
||||
/**
|
||||
* Map audio coding mode (acmod) to number of full-bandwidth channels.
|
||||
* from ATSC A/52 Table 5.8 Audio Coding Mode
|
||||
*/
|
||||
const uint8_t ff_ac3_channels_tab[8] = {
|
||||
2, 1, 2, 3, 3, 4, 4, 5
|
||||
};
|
||||
|
||||
/**
|
||||
* Map audio coding mode (acmod) to channel layout mask.
|
||||
*/
|
||||
const uint16_t avpriv_ac3_channel_layout_tab[8] = {
|
||||
AV_CH_LAYOUT_STEREO,
|
||||
AV_CH_LAYOUT_MONO,
|
||||
AV_CH_LAYOUT_STEREO,
|
||||
AV_CH_LAYOUT_SURROUND,
|
||||
AV_CH_LAYOUT_2_1,
|
||||
AV_CH_LAYOUT_4POINT0,
|
||||
AV_CH_LAYOUT_2_2,
|
||||
AV_CH_LAYOUT_5POINT0
|
||||
};
|
||||
|
||||
#define COMMON_CHANNEL_MAP \
|
||||
{ { 0, 1, }, { 0, 1, 2, } },\
|
||||
{ { 0, }, { 0, 1, } },\
|
||||
{ { 0, 1, }, { 0, 1, 2, } },\
|
||||
{ { 0, 2, 1, }, { 0, 2, 1, 3, } },\
|
||||
{ { 0, 1, 2, }, { 0, 1, 3, 2, } },\
|
||||
{ { 0, 2, 1, 3, }, { 0, 2, 1, 4, 3, } },
|
||||
|
||||
/**
|
||||
* Table to remap channels from SMPTE order to AC-3 order.
|
||||
* [channel_mode][lfe][ch]
|
||||
*/
|
||||
const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
|
||||
COMMON_CHANNEL_MAP
|
||||
{ { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } },
|
||||
{ { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
|
||||
};
|
||||
|
||||
/**
|
||||
* Table to remap channels from AC-3 order to SMPTE order.
|
||||
* [channel_mode][lfe][ch]
|
||||
*/
|
||||
const uint8_t ff_ac3_dec_channel_map[8][2][6] = {
|
||||
COMMON_CHANNEL_MAP
|
||||
{ { 0, 1, 2, 3, }, { 0, 1, 4, 2, 3, } },
|
||||
{ { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } },
|
||||
};
|
||||
|
||||
/* possible frequencies */
|
||||
const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
|
||||
|
||||
/* possible bitrates */
|
||||
const uint16_t ff_ac3_bitrate_tab[19] = {
|
||||
32, 40, 48, 56, 64, 80, 96, 112, 128,
|
||||
160, 192, 224, 256, 320, 384, 448, 512, 576, 640
|
||||
};
|
||||
|
||||
/**
|
||||
* Table of bin locations for rematrixing bands
|
||||
* reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
|
||||
*/
|
||||
const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
|
||||
|
||||
/**
|
||||
* Table E2.16 Default Coupling Banding Structure
|
||||
*/
|
||||
const uint8_t ff_eac3_default_cpl_band_struct[18] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
/* AC-3 MDCT window */
|
||||
|
||||
/* MDCT window */
|
||||
DECLARE_ALIGNED(16, const int16_t, ff_ac3_window)[AC3_WINDOW_SIZE/2] = {
|
||||
4, 7, 12, 16, 21, 28, 34, 42,
|
||||
51, 61, 72, 84, 97, 111, 127, 145,
|
||||
164, 184, 207, 231, 257, 285, 315, 347,
|
||||
382, 419, 458, 500, 544, 591, 641, 694,
|
||||
750, 810, 872, 937, 1007, 1079, 1155, 1235,
|
||||
1318, 1406, 1497, 1593, 1692, 1796, 1903, 2016,
|
||||
2132, 2253, 2379, 2509, 2644, 2783, 2927, 3076,
|
||||
3230, 3389, 3552, 3721, 3894, 4072, 4255, 4444,
|
||||
4637, 4835, 5038, 5246, 5459, 5677, 5899, 6127,
|
||||
6359, 6596, 6837, 7083, 7334, 7589, 7848, 8112,
|
||||
8380, 8652, 8927, 9207, 9491, 9778,10069,10363,
|
||||
10660,10960,11264,11570,11879,12190,12504,12820,
|
||||
13138,13458,13780,14103,14427,14753,15079,15407,
|
||||
15735,16063,16392,16720,17049,17377,17705,18032,
|
||||
18358,18683,19007,19330,19651,19970,20287,20602,
|
||||
20914,21225,21532,21837,22139,22438,22733,23025,
|
||||
23314,23599,23880,24157,24430,24699,24964,25225,
|
||||
25481,25732,25979,26221,26459,26691,26919,27142,
|
||||
27359,27572,27780,27983,28180,28373,28560,28742,
|
||||
28919,29091,29258,29420,29577,29729,29876,30018,
|
||||
30155,30288,30415,30538,30657,30771,30880,30985,
|
||||
31086,31182,31274,31363,31447,31528,31605,31678,
|
||||
31747,31814,31877,31936,31993,32046,32097,32145,
|
||||
32190,32232,32272,32310,32345,32378,32409,32438,
|
||||
32465,32490,32513,32535,32556,32574,32592,32608,
|
||||
32623,32636,32649,32661,32671,32681,32690,32698,
|
||||
32705,32712,32718,32724,32729,32733,32737,32741,
|
||||
32744,32747,32750,32752,32754,32756,32757,32759,
|
||||
32760,32761,32762,32763,32764,32764,32765,32765,
|
||||
32766,32766,32766,32766,32767,32767,32767,32767,
|
||||
32767,32767,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767,32767,32767,32767,32767,32767,32767,
|
||||
};
|
||||
|
||||
const uint8_t ff_ac3_log_add_tab[260]= {
|
||||
0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,
|
||||
0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f,
|
||||
0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27,
|
||||
0x26,0x26,0x25,0x24,0x24,0x23,0x23,0x22,0x21,0x21,
|
||||
0x20,0x20,0x1f,0x1e,0x1e,0x1d,0x1d,0x1c,0x1c,0x1b,
|
||||
0x1b,0x1a,0x1a,0x19,0x19,0x18,0x18,0x17,0x17,0x16,
|
||||
0x16,0x15,0x15,0x15,0x14,0x14,0x13,0x13,0x13,0x12,
|
||||
0x12,0x12,0x11,0x11,0x11,0x10,0x10,0x10,0x0f,0x0f,
|
||||
0x0f,0x0e,0x0e,0x0e,0x0d,0x0d,0x0d,0x0d,0x0c,0x0c,
|
||||
0x0c,0x0c,0x0b,0x0b,0x0b,0x0b,0x0a,0x0a,0x0a,0x0a,
|
||||
0x0a,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x08,0x08,
|
||||
0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x06,
|
||||
0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,0x05,0x05,
|
||||
0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,
|
||||
0x04,0x04,0x04,0x04,0x04,0x03,0x03,0x03,0x03,0x03,
|
||||
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
|
||||
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
|
||||
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
|
||||
const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3]= {
|
||||
{ 0x04d0,0x04f0,0x0580 },
|
||||
{ 0x04d0,0x04f0,0x0580 },
|
||||
{ 0x0440,0x0460,0x04b0 },
|
||||
{ 0x0400,0x0410,0x0450 },
|
||||
{ 0x03e0,0x03e0,0x0420 },
|
||||
{ 0x03c0,0x03d0,0x03f0 },
|
||||
{ 0x03b0,0x03c0,0x03e0 },
|
||||
{ 0x03b0,0x03b0,0x03d0 },
|
||||
{ 0x03a0,0x03b0,0x03c0 },
|
||||
{ 0x03a0,0x03a0,0x03b0 },
|
||||
{ 0x03a0,0x03a0,0x03b0 },
|
||||
{ 0x03a0,0x03a0,0x03b0 },
|
||||
{ 0x03a0,0x03a0,0x03a0 },
|
||||
{ 0x0390,0x03a0,0x03a0 },
|
||||
{ 0x0390,0x0390,0x03a0 },
|
||||
{ 0x0390,0x0390,0x03a0 },
|
||||
{ 0x0380,0x0390,0x03a0 },
|
||||
{ 0x0380,0x0380,0x03a0 },
|
||||
{ 0x0370,0x0380,0x03a0 },
|
||||
{ 0x0370,0x0380,0x03a0 },
|
||||
{ 0x0360,0x0370,0x0390 },
|
||||
{ 0x0360,0x0370,0x0390 },
|
||||
{ 0x0350,0x0360,0x0390 },
|
||||
{ 0x0350,0x0360,0x0390 },
|
||||
{ 0x0340,0x0350,0x0380 },
|
||||
{ 0x0340,0x0350,0x0380 },
|
||||
{ 0x0330,0x0340,0x0380 },
|
||||
{ 0x0320,0x0340,0x0370 },
|
||||
{ 0x0310,0x0320,0x0360 },
|
||||
{ 0x0300,0x0310,0x0350 },
|
||||
{ 0x02f0,0x0300,0x0340 },
|
||||
{ 0x02f0,0x02f0,0x0330 },
|
||||
{ 0x02f0,0x02f0,0x0320 },
|
||||
{ 0x02f0,0x02f0,0x0310 },
|
||||
{ 0x0300,0x02f0,0x0300 },
|
||||
{ 0x0310,0x0300,0x02f0 },
|
||||
{ 0x0340,0x0320,0x02f0 },
|
||||
{ 0x0390,0x0350,0x02f0 },
|
||||
{ 0x03e0,0x0390,0x0300 },
|
||||
{ 0x0420,0x03e0,0x0310 },
|
||||
{ 0x0460,0x0420,0x0330 },
|
||||
{ 0x0490,0x0450,0x0350 },
|
||||
{ 0x04a0,0x04a0,0x03c0 },
|
||||
{ 0x0460,0x0490,0x0410 },
|
||||
{ 0x0440,0x0460,0x0470 },
|
||||
{ 0x0440,0x0440,0x04a0 },
|
||||
{ 0x0520,0x0480,0x0460 },
|
||||
{ 0x0800,0x0630,0x0440 },
|
||||
{ 0x0840,0x0840,0x0450 },
|
||||
{ 0x0840,0x0840,0x04e0 },
|
||||
};
|
||||
|
||||
const uint8_t ff_ac3_bap_tab[64]= {
|
||||
0, 1, 1, 1, 1, 1, 2, 2, 3, 3,
|
||||
3, 4, 4, 5, 5, 6, 6, 6, 6, 7,
|
||||
7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
|
||||
9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
|
||||
12, 12, 12, 13, 13, 13, 13, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15,
|
||||
};
|
||||
|
||||
const uint8_t ff_ac3_slow_decay_tab[4]={
|
||||
0x0f, 0x11, 0x13, 0x15,
|
||||
};
|
||||
|
||||
const uint8_t ff_ac3_fast_decay_tab[4]={
|
||||
0x3f, 0x53, 0x67, 0x7b,
|
||||
};
|
||||
|
||||
const uint16_t ff_ac3_slow_gain_tab[4]= {
|
||||
0x540, 0x4d8, 0x478, 0x410,
|
||||
};
|
||||
|
||||
const uint16_t ff_ac3_db_per_bit_tab[4]= {
|
||||
0x000, 0x700, 0x900, 0xb00,
|
||||
};
|
||||
|
||||
const int16_t ff_ac3_floor_tab[8]= {
|
||||
0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
|
||||
};
|
||||
|
||||
const uint16_t ff_ac3_fast_gain_tab[8]= {
|
||||
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
|
||||
};
|
||||
|
||||
/**
|
||||
* Default channel map for a dependent substream defined by acmod
|
||||
*/
|
||||
const uint16_t ff_eac3_default_chmap[8] = {
|
||||
AC3_CHMAP_L | AC3_CHMAP_R, // FIXME Ch1+Ch2
|
||||
AC3_CHMAP_C,
|
||||
AC3_CHMAP_L | AC3_CHMAP_R,
|
||||
AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
|
||||
AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
|
||||
AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
|
||||
AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR,
|
||||
AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR
|
||||
};
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* AC-3 tables
|
||||
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* 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_AC3TAB_H
|
||||
#define AVCODEC_AC3TAB_H
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "ac3.h"
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
# define HCONST const
|
||||
#else
|
||||
# define HCONST
|
||||
#endif
|
||||
|
||||
extern const uint16_t ff_ac3_frame_size_tab[38][3];
|
||||
extern const uint8_t ff_ac3_channels_tab[8];
|
||||
extern av_export const uint16_t avpriv_ac3_channel_layout_tab[8];
|
||||
extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
|
||||
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
|
||||
extern const uint16_t ff_ac3_sample_rate_tab[3];
|
||||
extern const uint16_t ff_ac3_bitrate_tab[19];
|
||||
extern const uint8_t ff_ac3_rematrix_band_tab[5];
|
||||
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
|
||||
extern const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2];
|
||||
extern const uint8_t ff_ac3_log_add_tab[260];
|
||||
extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
|
||||
extern const uint8_t ff_ac3_bap_tab[64];
|
||||
extern const uint8_t ff_ac3_slow_decay_tab[4];
|
||||
extern const uint8_t ff_ac3_fast_decay_tab[4];
|
||||
extern const uint16_t ff_ac3_slow_gain_tab[4];
|
||||
extern const uint16_t ff_ac3_db_per_bit_tab[4];
|
||||
extern const int16_t ff_ac3_floor_tab[8];
|
||||
extern const uint16_t ff_ac3_fast_gain_tab[8];
|
||||
extern const uint16_t ff_eac3_default_chmap[8];
|
||||
extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
|
||||
extern HCONST uint8_t ff_ac3_bin_to_band_tab[253];
|
||||
|
||||
/** Custom channel map locations bitmask
|
||||
* Other channels described in documentation:
|
||||
* Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair,
|
||||
* Lw/Rw pair, Lvh/Rvh pair, Cvh, Reserved, LFE2
|
||||
*/
|
||||
enum CustomChannelMapLocation{
|
||||
AC3_CHMAP_L= 1<<(15-0),
|
||||
AC3_CHMAP_C= 1<<(15-1),
|
||||
AC3_CHMAP_R= 1<<(15-2),
|
||||
AC3_CHMAP_L_SUR= 1<<(15-3),
|
||||
AC3_CHMAP_R_SUR = 1<<(15-4),
|
||||
AC3_CHMAP_C_SUR= 1<<(15-7),
|
||||
AC3_CHMAP_LFE = 1<<(15-15)
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AC3TAB_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* E-AC-3 tables
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.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
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_EAC3_DATA_H
|
||||
#define AVCODEC_EAC3_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint8_t ff_eac3_bits_vs_hebap[20];
|
||||
extern const int16_t ff_eac3_gaq_remap_1[12];
|
||||
extern const int16_t ff_eac3_gaq_remap_2_4_a[9][2];
|
||||
extern const int16_t ff_eac3_gaq_remap_2_4_b[9][2];
|
||||
|
||||
extern const int16_t (* const ff_eac3_mantissa_vq[8])[6];
|
||||
extern const uint8_t ff_eac3_frm_expstr[32][6];
|
||||
extern const float ff_eac3_spx_atten_tab[32][3];
|
||||
|
||||
#endif /* AVCODEC_EAC3_DATA_H */
|
|
@ -0,0 +1,607 @@
|
|||
/*
|
||||
* E-AC-3 decoder
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
|
||||
* Copyright (c) 2008 Justin Ruggles
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* There are several features of E-AC-3 that this decoder does not yet support.
|
||||
*
|
||||
* Enhanced Coupling
|
||||
* No known samples exist. If any ever surface, this feature should not be
|
||||
* too difficult to implement.
|
||||
*
|
||||
* Reduced Sample Rates
|
||||
* No known samples exist. The spec also does not give clear information
|
||||
* on how this is to be implemented.
|
||||
*
|
||||
* Dependent Streams
|
||||
* Only the independent stream is currently decoded. Any dependent
|
||||
* streams are skipped. We have only come across two examples of this, and
|
||||
* they are both just test streams, one for HD-DVD and the other for
|
||||
* Blu-ray.
|
||||
*
|
||||
* Transient Pre-noise Processing
|
||||
* This is side information which a decoder should use to reduce artifacts
|
||||
* caused by transients. There are samples which are known to have this
|
||||
* information, but this decoder currently ignores it.
|
||||
*/
|
||||
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "aac_ac3_parser.h"
|
||||
#include "ac3.h"
|
||||
#include "ac3_parser.h"
|
||||
#include "ac3dec.h"
|
||||
#include "ac3dec_data.h"
|
||||
#include "eac3_data.h"
|
||||
|
||||
/** gain adaptive quantization mode */
|
||||
typedef enum {
|
||||
EAC3_GAQ_NO =0,
|
||||
EAC3_GAQ_12,
|
||||
EAC3_GAQ_14,
|
||||
EAC3_GAQ_124
|
||||
} EAC3GaqMode;
|
||||
|
||||
#define EAC3_SR_CODE_REDUCED 3
|
||||
|
||||
void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
|
||||
{
|
||||
int bin, bnd, ch, i;
|
||||
uint8_t wrapflag[SPX_MAX_BANDS]={1,0,}, num_copy_sections, copy_sizes[SPX_MAX_BANDS];
|
||||
float rms_energy[SPX_MAX_BANDS];
|
||||
|
||||
/* Set copy index mapping table. Set wrap flags to apply a notch filter at
|
||||
wrap points later on. */
|
||||
bin = s->spx_dst_start_freq;
|
||||
num_copy_sections = 0;
|
||||
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
|
||||
int copysize;
|
||||
int bandsize = s->spx_band_sizes[bnd];
|
||||
if (bin + bandsize > s->spx_src_start_freq) {
|
||||
copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
|
||||
bin = s->spx_dst_start_freq;
|
||||
wrapflag[bnd] = 1;
|
||||
}
|
||||
for (i = 0; i < bandsize; i += copysize) {
|
||||
if (bin == s->spx_src_start_freq) {
|
||||
copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
|
||||
bin = s->spx_dst_start_freq;
|
||||
}
|
||||
copysize = FFMIN(bandsize - i, s->spx_src_start_freq - bin);
|
||||
bin += copysize;
|
||||
}
|
||||
}
|
||||
copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
|
||||
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++) {
|
||||
if (!s->channel_uses_spx[ch])
|
||||
continue;
|
||||
|
||||
/* Copy coeffs from normal bands to extension bands */
|
||||
bin = s->spx_src_start_freq;
|
||||
for (i = 0; i < num_copy_sections; i++) {
|
||||
memcpy(&s->transform_coeffs[ch][bin],
|
||||
&s->transform_coeffs[ch][s->spx_dst_start_freq],
|
||||
copy_sizes[i]*sizeof(float));
|
||||
bin += copy_sizes[i];
|
||||
}
|
||||
|
||||
/* Calculate RMS energy for each SPX band. */
|
||||
bin = s->spx_src_start_freq;
|
||||
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
|
||||
int bandsize = s->spx_band_sizes[bnd];
|
||||
float accum = 0.0f;
|
||||
for (i = 0; i < bandsize; i++) {
|
||||
float coeff = s->transform_coeffs[ch][bin++];
|
||||
accum += coeff * coeff;
|
||||
}
|
||||
rms_energy[bnd] = sqrtf(accum / bandsize);
|
||||
}
|
||||
|
||||
/* Apply a notch filter at transitions between normal and extension
|
||||
bands and at all wrap points. */
|
||||
if (s->spx_atten_code[ch] >= 0) {
|
||||
const float *atten_tab = ff_eac3_spx_atten_tab[s->spx_atten_code[ch]];
|
||||
bin = s->spx_src_start_freq - 2;
|
||||
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
|
||||
if (wrapflag[bnd]) {
|
||||
float *coeffs = &s->transform_coeffs[ch][bin];
|
||||
coeffs[0] *= atten_tab[0];
|
||||
coeffs[1] *= atten_tab[1];
|
||||
coeffs[2] *= atten_tab[2];
|
||||
coeffs[3] *= atten_tab[1];
|
||||
coeffs[4] *= atten_tab[0];
|
||||
}
|
||||
bin += s->spx_band_sizes[bnd];
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply noise-blended coefficient scaling based on previously
|
||||
calculated RMS energy, blending factors, and SPX coordinates for
|
||||
each band. */
|
||||
bin = s->spx_src_start_freq;
|
||||
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
|
||||
float nscale = s->spx_noise_blend[ch][bnd] * rms_energy[bnd] * (1.0f / INT32_MIN);
|
||||
float sscale = s->spx_signal_blend[ch][bnd];
|
||||
for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
|
||||
float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);
|
||||
s->transform_coeffs[ch][bin] *= sscale;
|
||||
s->transform_coeffs[ch][bin++] += noise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** lrint(M_SQRT2*cos(2*M_PI/12)*(1<<23)) */
|
||||
#define COEFF_0 10273905LL
|
||||
|
||||
/** lrint(M_SQRT2*cos(0*M_PI/12)*(1<<23)) = lrint(M_SQRT2*(1<<23)) */
|
||||
#define COEFF_1 11863283LL
|
||||
|
||||
/** lrint(M_SQRT2*cos(5*M_PI/12)*(1<<23)) */
|
||||
#define COEFF_2 3070444LL
|
||||
|
||||
/**
|
||||
* Calculate 6-point IDCT of the pre-mantissas.
|
||||
* All calculations are 24-bit fixed-point.
|
||||
*/
|
||||
static void idct6(int pre_mant[6])
|
||||
{
|
||||
int tmp;
|
||||
int even0, even1, even2, odd0, odd1, odd2;
|
||||
|
||||
odd1 = pre_mant[1] - pre_mant[3] - pre_mant[5];
|
||||
|
||||
even2 = ( pre_mant[2] * COEFF_0) >> 23;
|
||||
tmp = ( pre_mant[4] * COEFF_1) >> 23;
|
||||
odd0 = ((pre_mant[1] + pre_mant[5]) * COEFF_2) >> 23;
|
||||
|
||||
even0 = pre_mant[0] + (tmp >> 1);
|
||||
even1 = pre_mant[0] - tmp;
|
||||
|
||||
tmp = even0;
|
||||
even0 = tmp + even2;
|
||||
even2 = tmp - even2;
|
||||
|
||||
tmp = odd0;
|
||||
odd0 = tmp + pre_mant[1] + pre_mant[3];
|
||||
odd2 = tmp + pre_mant[5] - pre_mant[3];
|
||||
|
||||
pre_mant[0] = even0 + odd0;
|
||||
pre_mant[1] = even1 + odd1;
|
||||
pre_mant[2] = even2 + odd2;
|
||||
pre_mant[3] = even2 - odd2;
|
||||
pre_mant[4] = even1 - odd1;
|
||||
pre_mant[5] = even0 - odd0;
|
||||
}
|
||||
|
||||
void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch)
|
||||
{
|
||||
int bin, blk, gs;
|
||||
int end_bap, gaq_mode;
|
||||
GetBitContext *gbc = &s->gbc;
|
||||
int gaq_gain[AC3_MAX_COEFS];
|
||||
|
||||
gaq_mode = get_bits(gbc, 2);
|
||||
end_bap = (gaq_mode < 2) ? 12 : 17;
|
||||
|
||||
/* if GAQ gain is used, decode gain codes for bins with hebap between
|
||||
8 and end_bap */
|
||||
gs = 0;
|
||||
if (gaq_mode == EAC3_GAQ_12 || gaq_mode == EAC3_GAQ_14) {
|
||||
/* read 1-bit GAQ gain codes */
|
||||
for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
|
||||
if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < end_bap)
|
||||
gaq_gain[gs++] = get_bits1(gbc) << (gaq_mode-1);
|
||||
}
|
||||
} else if (gaq_mode == EAC3_GAQ_124) {
|
||||
/* read 1.67-bit GAQ gain codes (3 codes in 5 bits) */
|
||||
int gc = 2;
|
||||
for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
|
||||
if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < 17) {
|
||||
if (gc++ == 2) {
|
||||
int group_code = get_bits(gbc, 5);
|
||||
if (group_code > 26) {
|
||||
av_log(s->avctx, AV_LOG_WARNING, "GAQ gain group code out-of-range\n");
|
||||
group_code = 26;
|
||||
}
|
||||
gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][0];
|
||||
gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][1];
|
||||
gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][2];
|
||||
gc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gs=0;
|
||||
for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
|
||||
int hebap = s->bap[ch][bin];
|
||||
int bits = ff_eac3_bits_vs_hebap[hebap];
|
||||
if (!hebap) {
|
||||
/* zero-mantissa dithering */
|
||||
for (blk = 0; blk < 6; blk++) {
|
||||
s->pre_mantissa[ch][bin][blk] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
|
||||
}
|
||||
} else if (hebap < 8) {
|
||||
/* Vector Quantization */
|
||||
int v = get_bits(gbc, bits);
|
||||
for (blk = 0; blk < 6; blk++) {
|
||||
s->pre_mantissa[ch][bin][blk] = ff_eac3_mantissa_vq[hebap][v][blk] << 8;
|
||||
}
|
||||
} else {
|
||||
/* Gain Adaptive Quantization */
|
||||
int gbits, log_gain;
|
||||
if (gaq_mode != EAC3_GAQ_NO && hebap < end_bap) {
|
||||
log_gain = gaq_gain[gs++];
|
||||
} else {
|
||||
log_gain = 0;
|
||||
}
|
||||
gbits = bits - log_gain;
|
||||
|
||||
for (blk = 0; blk < 6; blk++) {
|
||||
int mant = get_sbits(gbc, gbits);
|
||||
if (log_gain && mant == -(1 << (gbits-1))) {
|
||||
/* large mantissa */
|
||||
int b;
|
||||
int mbits = bits - (2 - log_gain);
|
||||
mant = get_sbits(gbc, mbits);
|
||||
mant <<= (23 - (mbits - 1));
|
||||
/* remap mantissa value to correct for asymmetric quantization */
|
||||
if (mant >= 0)
|
||||
b = 1 << (23 - log_gain);
|
||||
else
|
||||
b = ff_eac3_gaq_remap_2_4_b[hebap-8][log_gain-1] << 8;
|
||||
mant += ((ff_eac3_gaq_remap_2_4_a[hebap-8][log_gain-1] * (int64_t)mant) >> 15) + b;
|
||||
} else {
|
||||
/* small mantissa, no GAQ, or Gk=1 */
|
||||
mant <<= 24 - bits;
|
||||
if (!log_gain) {
|
||||
/* remap mantissa value for no GAQ or Gk=1 */
|
||||
mant += (ff_eac3_gaq_remap_1[hebap-8] * (int64_t)mant) >> 15;
|
||||
}
|
||||
}
|
||||
s->pre_mantissa[ch][bin][blk] = mant;
|
||||
}
|
||||
}
|
||||
idct6(s->pre_mantissa[ch][bin]);
|
||||
}
|
||||
}
|
||||
|
||||
int ff_eac3_parse_header(AC3DecodeContext *s)
|
||||
{
|
||||
int i, blk, ch;
|
||||
int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
|
||||
int parse_transient_proc_info;
|
||||
int num_cpl_blocks;
|
||||
GetBitContext *gbc = &s->gbc;
|
||||
|
||||
/* An E-AC-3 stream can have multiple independent streams which the
|
||||
application can select from. each independent stream can also contain
|
||||
dependent streams which are used to add or replace channels. */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
|
||||
avpriv_request_sample(s->avctx, "Dependent substream decoding");
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
|
||||
} else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
|
||||
}
|
||||
|
||||
/* The substream id indicates which substream this frame belongs to. each
|
||||
independent stream has its own substream id, and the dependent streams
|
||||
associated to an independent stream have matching substream id's. */
|
||||
if (s->substreamid) {
|
||||
/* only decode substream with id=0. skip any additional substreams. */
|
||||
avpriv_request_sample(s->avctx, "Additional substreams");
|
||||
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
|
||||
}
|
||||
|
||||
if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
|
||||
/* The E-AC-3 specification does not tell how to handle reduced sample
|
||||
rates in bit allocation. The best assumption would be that it is
|
||||
handled like AC-3 DolbyNet, but we cannot be sure until we have a
|
||||
sample which utilizes this feature. */
|
||||
avpriv_request_sample(s->avctx, "Reduced sampling rate");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
skip_bits(gbc, 5); // skip bitstream id
|
||||
|
||||
/* volume control params */
|
||||
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
|
||||
skip_bits(gbc, 5); // skip dialog normalization
|
||||
if (get_bits1(gbc)) {
|
||||
skip_bits(gbc, 8); // skip compression gain word
|
||||
}
|
||||
}
|
||||
|
||||
/* dependent stream channel map */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
|
||||
if (get_bits1(gbc)) {
|
||||
skip_bits(gbc, 16); // skip custom channel map
|
||||
}
|
||||
}
|
||||
|
||||
/* mixing metadata */
|
||||
if (get_bits1(gbc)) {
|
||||
/* center and surround mix levels */
|
||||
if (s->channel_mode > AC3_CHMODE_STEREO) {
|
||||
skip_bits(gbc, 2); // skip preferred stereo downmix mode
|
||||
if (s->channel_mode & 1) {
|
||||
/* if three front channels exist */
|
||||
skip_bits(gbc, 3); //skip Lt/Rt center mix level
|
||||
s->center_mix_level = get_bits(gbc, 3);
|
||||
}
|
||||
if (s->channel_mode & 4) {
|
||||
/* if a surround channel exists */
|
||||
skip_bits(gbc, 3); //skip Lt/Rt surround mix level
|
||||
s->surround_mix_level = get_bits(gbc, 3);
|
||||
}
|
||||
}
|
||||
|
||||
/* lfe mix level */
|
||||
if (s->lfe_on && get_bits1(gbc)) {
|
||||
// TODO: use LFE mix level
|
||||
skip_bits(gbc, 5); // skip LFE mix level code
|
||||
}
|
||||
|
||||
/* info for mixing with other streams and substreams */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
|
||||
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
|
||||
// TODO: apply program scale factor
|
||||
if (get_bits1(gbc)) {
|
||||
skip_bits(gbc, 6); // skip program scale factor
|
||||
}
|
||||
}
|
||||
if (get_bits1(gbc)) {
|
||||
skip_bits(gbc, 6); // skip external program scale factor
|
||||
}
|
||||
/* skip mixing parameter data */
|
||||
switch(get_bits(gbc, 2)) {
|
||||
case 1: skip_bits(gbc, 5); break;
|
||||
case 2: skip_bits(gbc, 12); break;
|
||||
case 3: {
|
||||
int mix_data_size = (get_bits(gbc, 5) + 2) << 3;
|
||||
skip_bits_long(gbc, mix_data_size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* skip pan information for mono or dual mono source */
|
||||
if (s->channel_mode < AC3_CHMODE_STEREO) {
|
||||
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
|
||||
if (get_bits1(gbc)) {
|
||||
/* note: this is not in the ATSC A/52B specification
|
||||
reference: ETSI TS 102 366 V1.1.1
|
||||
section: E.1.3.1.25 */
|
||||
skip_bits(gbc, 8); // skip pan mean direction index
|
||||
skip_bits(gbc, 6); // skip reserved paninfo bits
|
||||
}
|
||||
}
|
||||
}
|
||||
/* skip mixing configuration information */
|
||||
if (get_bits1(gbc)) {
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
if (s->num_blocks == 1 || get_bits1(gbc)) {
|
||||
skip_bits(gbc, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* informational metadata */
|
||||
if (get_bits1(gbc)) {
|
||||
s->bitstream_mode = get_bits(gbc, 3);
|
||||
skip_bits(gbc, 2); // skip copyright bit and original bitstream bit
|
||||
if (s->channel_mode == AC3_CHMODE_STEREO) {
|
||||
skip_bits(gbc, 4); // skip Dolby surround and headphone mode
|
||||
}
|
||||
if (s->channel_mode >= AC3_CHMODE_2F2R) {
|
||||
skip_bits(gbc, 2); // skip Dolby surround EX mode
|
||||
}
|
||||
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
|
||||
if (get_bits1(gbc)) {
|
||||
skip_bits(gbc, 8); // skip mix level, room type, and A/D converter type
|
||||
}
|
||||
}
|
||||
if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
|
||||
skip_bits1(gbc); // skip source sample rate code
|
||||
}
|
||||
}
|
||||
|
||||
/* converter synchronization flag
|
||||
If frames are less than six blocks, this bit should be turned on
|
||||
once every 6 blocks to indicate the start of a frame set.
|
||||
reference: RFC 4598, Section 2.1.3 Frame Sets */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) {
|
||||
skip_bits1(gbc); // skip converter synchronization flag
|
||||
}
|
||||
|
||||
/* original frame size code if this stream was converted from AC-3 */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
|
||||
(s->num_blocks == 6 || get_bits1(gbc))) {
|
||||
skip_bits(gbc, 6); // skip frame size code
|
||||
}
|
||||
|
||||
/* additional bitstream info */
|
||||
if (get_bits1(gbc)) {
|
||||
int addbsil = get_bits(gbc, 6);
|
||||
for (i = 0; i < addbsil + 1; i++) {
|
||||
skip_bits(gbc, 8); // skip additional bit stream info
|
||||
}
|
||||
}
|
||||
|
||||
/* audio frame syntax flags, strategy data, and per-frame data */
|
||||
|
||||
if (s->num_blocks == 6) {
|
||||
ac3_exponent_strategy = get_bits1(gbc);
|
||||
parse_aht_info = get_bits1(gbc);
|
||||
} else {
|
||||
/* less than 6 blocks, so use AC-3-style exponent strategy syntax, and
|
||||
do not use AHT */
|
||||
ac3_exponent_strategy = 1;
|
||||
parse_aht_info = 0;
|
||||
}
|
||||
|
||||
s->snr_offset_strategy = get_bits(gbc, 2);
|
||||
parse_transient_proc_info = get_bits1(gbc);
|
||||
|
||||
s->block_switch_syntax = get_bits1(gbc);
|
||||
if (!s->block_switch_syntax)
|
||||
memset(s->block_switch, 0, sizeof(s->block_switch));
|
||||
|
||||
s->dither_flag_syntax = get_bits1(gbc);
|
||||
if (!s->dither_flag_syntax) {
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++)
|
||||
s->dither_flag[ch] = 1;
|
||||
}
|
||||
s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0;
|
||||
|
||||
s->bit_allocation_syntax = get_bits1(gbc);
|
||||
if (!s->bit_allocation_syntax) {
|
||||
/* set default bit allocation parameters */
|
||||
s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
|
||||
s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
|
||||
s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
|
||||
s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
|
||||
s->bit_alloc_params.floor = ff_ac3_floor_tab [7];
|
||||
}
|
||||
|
||||
s->fast_gain_syntax = get_bits1(gbc);
|
||||
s->dba_syntax = get_bits1(gbc);
|
||||
s->skip_syntax = get_bits1(gbc);
|
||||
parse_spx_atten_data = get_bits1(gbc);
|
||||
|
||||
/* coupling strategy occurrence and coupling use per block */
|
||||
num_cpl_blocks = 0;
|
||||
if (s->channel_mode > 1) {
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc));
|
||||
if (s->cpl_strategy_exists[blk]) {
|
||||
s->cpl_in_use[blk] = get_bits1(gbc);
|
||||
} else {
|
||||
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
|
||||
}
|
||||
num_cpl_blocks += s->cpl_in_use[blk];
|
||||
}
|
||||
} else {
|
||||
memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use));
|
||||
}
|
||||
|
||||
/* exponent strategy data */
|
||||
if (ac3_exponent_strategy) {
|
||||
/* AC-3-style exponent strategy syntax */
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
|
||||
s->exp_strategy[blk][ch] = get_bits(gbc, 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* LUT-based exponent strategy syntax */
|
||||
for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
|
||||
int frmchexpstr = get_bits(gbc, 5);
|
||||
for (blk = 0; blk < 6; blk++) {
|
||||
s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
|
||||
}
|
||||
}
|
||||
}
|
||||
/* LFE exponent strategy */
|
||||
if (s->lfe_on) {
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc);
|
||||
}
|
||||
}
|
||||
/* original exponent strategies if this stream was converted from AC-3 */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
|
||||
(s->num_blocks == 6 || get_bits1(gbc))) {
|
||||
skip_bits(gbc, 5 * s->fbw_channels); // skip converter channel exponent strategy
|
||||
}
|
||||
|
||||
/* determine which channels use AHT */
|
||||
if (parse_aht_info) {
|
||||
/* For AHT to be used, all non-zero blocks must reuse exponents from
|
||||
the first block. Furthermore, for AHT to be used in the coupling
|
||||
channel, all blocks must use coupling and use the same coupling
|
||||
strategy. */
|
||||
s->channel_uses_aht[CPL_CH]=0;
|
||||
for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) {
|
||||
int use_aht = 1;
|
||||
for (blk = 1; blk < 6; blk++) {
|
||||
if ((s->exp_strategy[blk][ch] != EXP_REUSE) ||
|
||||
(!ch && s->cpl_strategy_exists[blk])) {
|
||||
use_aht = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s->channel_uses_aht[ch] = use_aht && get_bits1(gbc);
|
||||
}
|
||||
} else {
|
||||
memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
|
||||
}
|
||||
|
||||
/* per-frame SNR offset */
|
||||
if (!s->snr_offset_strategy) {
|
||||
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
|
||||
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
|
||||
for (ch = 0; ch <= s->channels; ch++)
|
||||
s->snr_offset[ch] = snroffst;
|
||||
}
|
||||
|
||||
/* transient pre-noise processing data */
|
||||
if (parse_transient_proc_info) {
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++) {
|
||||
if (get_bits1(gbc)) { // channel in transient processing
|
||||
skip_bits(gbc, 10); // skip transient processing location
|
||||
skip_bits(gbc, 8); // skip transient processing length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* spectral extension attenuation data */
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++) {
|
||||
if (parse_spx_atten_data && get_bits1(gbc)) {
|
||||
s->spx_atten_code[ch] = get_bits(gbc, 5);
|
||||
} else {
|
||||
s->spx_atten_code[ch] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* block start information */
|
||||
if (s->num_blocks > 1 && get_bits1(gbc)) {
|
||||
/* reference: Section E2.3.2.27
|
||||
nblkstrtbits = (numblks - 1) * (4 + ceiling(log2(words_per_frame)))
|
||||
The spec does not say what this data is or what it's used for.
|
||||
It is likely the offset of each block within the frame. */
|
||||
int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2));
|
||||
skip_bits_long(gbc, block_start_bits);
|
||||
avpriv_request_sample(s->avctx, "Block start info");
|
||||
}
|
||||
|
||||
/* syntax state initialization */
|
||||
for (ch = 1; ch <= s->fbw_channels; ch++) {
|
||||
s->first_spx_coords[ch] = 1;
|
||||
s->first_cpl_coords[ch] = 1;
|
||||
}
|
||||
s->first_cpl_leak = 1;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 "libavutil/avassert.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "kbdwin.h"
|
||||
|
||||
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
|
||||
|
||||
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
|
||||
{
|
||||
int i, j;
|
||||
double sum = 0.0, bessel, tmp;
|
||||
double local_window[FF_KBD_WINDOW_MAX];
|
||||
double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
|
||||
|
||||
av_assert0(n <= FF_KBD_WINDOW_MAX);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
tmp = i * (n - i) * alpha2;
|
||||
bessel = 1.0;
|
||||
for (j = BESSEL_I0_ITER; j > 0; j--)
|
||||
bessel = bessel * tmp / (j * j) + 1;
|
||||
sum += bessel;
|
||||
local_window[i] = sum;
|
||||
}
|
||||
|
||||
sum++;
|
||||
for (i = 0; i < n; i++)
|
||||
window[i] = sqrt(local_window[i] / sum);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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_KBDWIN_H
|
||||
#define AVCODEC_KBDWIN_H
|
||||
|
||||
/**
|
||||
* Maximum window size for ff_kbd_window_init.
|
||||
*/
|
||||
#define FF_KBD_WINDOW_MAX 1024
|
||||
|
||||
/**
|
||||
* Generate a Kaiser-Bessel Derived Window.
|
||||
* @param window pointer to half window
|
||||
* @param alpha determines window shape
|
||||
* @param n size of half window, max FF_KBD_WINDOW_MAX
|
||||
*/
|
||||
void ff_kbd_window_init(float *window, float alpha, int n);
|
||||
|
||||
#endif /* AVCODEC_KBDWIN_H */
|
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* x86-optimized AC-3 DSP utils
|
||||
* Copyright (c) 2011 Justin Ruggles
|
||||
*
|
||||
* 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 "libavutil/mem.h"
|
||||
#include "libavutil/x86/asm.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
#include "dsputil_x86.h"
|
||||
#include "libavcodec/ac3.h"
|
||||
#include "libavcodec/ac3dsp.h"
|
||||
|
||||
void ff_ac3_exponent_min_mmx (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
||||
void ff_ac3_exponent_min_mmxext(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
||||
void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
||||
|
||||
int ff_ac3_max_msb_abs_int16_mmx (const int16_t *src, int len);
|
||||
int ff_ac3_max_msb_abs_int16_mmxext(const int16_t *src, int len);
|
||||
int ff_ac3_max_msb_abs_int16_sse2 (const int16_t *src, int len);
|
||||
int ff_ac3_max_msb_abs_int16_ssse3(const int16_t *src, int len);
|
||||
|
||||
void ff_ac3_lshift_int16_mmx (int16_t *src, unsigned int len, unsigned int shift);
|
||||
void ff_ac3_lshift_int16_sse2(int16_t *src, unsigned int len, unsigned int shift);
|
||||
|
||||
void ff_ac3_rshift_int32_mmx (int32_t *src, unsigned int len, unsigned int shift);
|
||||
void ff_ac3_rshift_int32_sse2(int32_t *src, unsigned int len, unsigned int shift);
|
||||
|
||||
void ff_float_to_fixed24_3dnow(int32_t *dst, const float *src, unsigned int len);
|
||||
void ff_float_to_fixed24_sse (int32_t *dst, const float *src, unsigned int len);
|
||||
void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, unsigned int len);
|
||||
|
||||
int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]);
|
||||
|
||||
void ff_ac3_extract_exponents_3dnow(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
|
||||
#if ARCH_X86_32 && defined(__INTEL_COMPILER)
|
||||
# undef HAVE_7REGS
|
||||
# define HAVE_7REGS 0
|
||||
#endif
|
||||
|
||||
#if HAVE_SSE_INLINE && HAVE_7REGS
|
||||
|
||||
#define IF1(x) x
|
||||
#define IF0(x)
|
||||
|
||||
#define MIX5(mono, stereo) \
|
||||
__asm__ volatile ( \
|
||||
"movss 0(%1), %%xmm5 \n" \
|
||||
"movss 8(%1), %%xmm6 \n" \
|
||||
"movss 24(%1), %%xmm7 \n" \
|
||||
"shufps $0, %%xmm5, %%xmm5 \n" \
|
||||
"shufps $0, %%xmm6, %%xmm6 \n" \
|
||||
"shufps $0, %%xmm7, %%xmm7 \n" \
|
||||
"1: \n" \
|
||||
"movaps (%0, %2), %%xmm0 \n" \
|
||||
"movaps (%0, %3), %%xmm1 \n" \
|
||||
"movaps (%0, %4), %%xmm2 \n" \
|
||||
"movaps (%0, %5), %%xmm3 \n" \
|
||||
"movaps (%0, %6), %%xmm4 \n" \
|
||||
"mulps %%xmm5, %%xmm0 \n" \
|
||||
"mulps %%xmm6, %%xmm1 \n" \
|
||||
"mulps %%xmm5, %%xmm2 \n" \
|
||||
"mulps %%xmm7, %%xmm3 \n" \
|
||||
"mulps %%xmm7, %%xmm4 \n" \
|
||||
stereo("addps %%xmm1, %%xmm0 \n") \
|
||||
"addps %%xmm1, %%xmm2 \n" \
|
||||
"addps %%xmm3, %%xmm0 \n" \
|
||||
"addps %%xmm4, %%xmm2 \n" \
|
||||
mono("addps %%xmm2, %%xmm0 \n") \
|
||||
"movaps %%xmm0, (%0, %2) \n" \
|
||||
stereo("movaps %%xmm2, (%0, %3) \n") \
|
||||
"add $16, %0 \n" \
|
||||
"jl 1b \n" \
|
||||
: "+&r"(i) \
|
||||
: "r"(matrix), \
|
||||
"r"(samples[0] + len), \
|
||||
"r"(samples[1] + len), \
|
||||
"r"(samples[2] + len), \
|
||||
"r"(samples[3] + len), \
|
||||
"r"(samples[4] + len) \
|
||||
: XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
|
||||
"%xmm4", "%xmm5", "%xmm6", "%xmm7",) \
|
||||
"memory" \
|
||||
);
|
||||
|
||||
#define MIX_MISC(stereo) \
|
||||
__asm__ volatile ( \
|
||||
"mov %5, %2 \n" \
|
||||
"1: \n" \
|
||||
"mov -%c7(%6, %2, %c8), %3 \n" \
|
||||
"movaps (%3, %0), %%xmm0 \n" \
|
||||
stereo("movaps %%xmm0, %%xmm1 \n") \
|
||||
"mulps %%xmm4, %%xmm0 \n" \
|
||||
stereo("mulps %%xmm5, %%xmm1 \n") \
|
||||
"2: \n" \
|
||||
"mov (%6, %2, %c8), %1 \n" \
|
||||
"movaps (%1, %0), %%xmm2 \n" \
|
||||
stereo("movaps %%xmm2, %%xmm3 \n") \
|
||||
"mulps (%4, %2, 8), %%xmm2 \n" \
|
||||
stereo("mulps 16(%4, %2, 8), %%xmm3 \n") \
|
||||
"addps %%xmm2, %%xmm0 \n" \
|
||||
stereo("addps %%xmm3, %%xmm1 \n") \
|
||||
"add $4, %2 \n" \
|
||||
"jl 2b \n" \
|
||||
"mov %5, %2 \n" \
|
||||
stereo("mov (%6, %2, %c8), %1 \n") \
|
||||
"movaps %%xmm0, (%3, %0) \n" \
|
||||
stereo("movaps %%xmm1, (%1, %0) \n") \
|
||||
"add $16, %0 \n" \
|
||||
"jl 1b \n" \
|
||||
: "+&r"(i), "=&r"(j), "=&r"(k), "=&r"(m) \
|
||||
: "r"(matrix_simd + in_ch), \
|
||||
"g"((intptr_t) - 4 * (in_ch - 1)), \
|
||||
"r"(samp + in_ch), \
|
||||
"i"(sizeof(float *)), "i"(sizeof(float *)/4) \
|
||||
: "memory" \
|
||||
);
|
||||
|
||||
static void ac3_downmix_sse(float **samples, float (*matrix)[2],
|
||||
int out_ch, int in_ch, int len)
|
||||
{
|
||||
int (*matrix_cmp)[2] = (int(*)[2])matrix;
|
||||
intptr_t i, j, k, m;
|
||||
|
||||
i = -len * sizeof(float);
|
||||
if (in_ch == 5 && out_ch == 2 &&
|
||||
!(matrix_cmp[0][1] | matrix_cmp[2][0] |
|
||||
matrix_cmp[3][1] | matrix_cmp[4][0] |
|
||||
(matrix_cmp[1][0] ^ matrix_cmp[1][1]) |
|
||||
(matrix_cmp[0][0] ^ matrix_cmp[2][1]))) {
|
||||
MIX5(IF0, IF1);
|
||||
} else if (in_ch == 5 && out_ch == 1 &&
|
||||
matrix_cmp[0][0] == matrix_cmp[2][0] &&
|
||||
matrix_cmp[3][0] == matrix_cmp[4][0]) {
|
||||
MIX5(IF1, IF0);
|
||||
} else {
|
||||
DECLARE_ALIGNED(16, float, matrix_simd)[AC3_MAX_CHANNELS][2][4];
|
||||
float *samp[AC3_MAX_CHANNELS];
|
||||
|
||||
for (j = 0; j < in_ch; j++)
|
||||
samp[j] = samples[j] + len;
|
||||
|
||||
j = 2 * in_ch * sizeof(float);
|
||||
__asm__ volatile (
|
||||
"1: \n"
|
||||
"sub $8, %0 \n"
|
||||
"movss (%2, %0), %%xmm4 \n"
|
||||
"movss 4(%2, %0), %%xmm5 \n"
|
||||
"shufps $0, %%xmm4, %%xmm4 \n"
|
||||
"shufps $0, %%xmm5, %%xmm5 \n"
|
||||
"movaps %%xmm4, (%1, %0, 4) \n"
|
||||
"movaps %%xmm5, 16(%1, %0, 4) \n"
|
||||
"jg 1b \n"
|
||||
: "+&r"(j)
|
||||
: "r"(matrix_simd), "r"(matrix)
|
||||
: "memory"
|
||||
);
|
||||
if (out_ch == 2) {
|
||||
MIX_MISC(IF1);
|
||||
} else {
|
||||
MIX_MISC(IF0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_SSE_INLINE && HAVE_7REGS */
|
||||
|
||||
av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_MMX(cpu_flags)) {
|
||||
c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
|
||||
c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx;
|
||||
c->ac3_lshift_int16 = ff_ac3_lshift_int16_mmx;
|
||||
c->ac3_rshift_int32 = ff_ac3_rshift_int32_mmx;
|
||||
}
|
||||
if (EXTERNAL_AMD3DNOW(cpu_flags)) {
|
||||
if (!bit_exact) {
|
||||
c->float_to_fixed24 = ff_float_to_fixed24_3dnow;
|
||||
}
|
||||
}
|
||||
if (EXTERNAL_MMXEXT(cpu_flags)) {
|
||||
c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
|
||||
c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext;
|
||||
}
|
||||
if (EXTERNAL_SSE(cpu_flags)) {
|
||||
c->float_to_fixed24 = ff_float_to_fixed24_sse;
|
||||
}
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
|
||||
c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2;
|
||||
c->float_to_fixed24 = ff_float_to_fixed24_sse2;
|
||||
c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
|
||||
c->extract_exponents = ff_ac3_extract_exponents_sse2;
|
||||
if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
|
||||
c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2;
|
||||
c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2;
|
||||
}
|
||||
}
|
||||
if (EXTERNAL_SSSE3(cpu_flags)) {
|
||||
c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3;
|
||||
if (!(cpu_flags & AV_CPU_FLAG_ATOM)) {
|
||||
c->extract_exponents = ff_ac3_extract_exponents_ssse3;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_SSE_INLINE && HAVE_7REGS
|
||||
if (INLINE_SSE(cpu_flags)) {
|
||||
c->downmix = ac3_downmix_sse;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* RAW AC-3 and E-AC-3 demuxer
|
||||
* Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.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 "libavutil/crc.h"
|
||||
#include "libavcodec/ac3_parser.h"
|
||||
#include "avformat.h"
|
||||
#include "rawdec.h"
|
||||
|
||||
static int ac3_eac3_probe(AVProbeData *p, enum AVCodecID expected_codec_id)
|
||||
{
|
||||
int max_frames, first_frames = 0, frames;
|
||||
const uint8_t *buf, *buf2, *end;
|
||||
AC3HeaderInfo hdr;
|
||||
GetBitContext gbc;
|
||||
enum AVCodecID codec_id = AV_CODEC_ID_AC3;
|
||||
|
||||
max_frames = 0;
|
||||
buf = p->buf;
|
||||
end = buf + p->buf_size;
|
||||
|
||||
for(; buf < end; buf++) {
|
||||
if(buf > p->buf && !(buf[0] == 0x0B && buf[1] == 0x77)
|
||||
&& !(buf[0] == 0x77 && buf[1] == 0x0B) )
|
||||
continue;
|
||||
buf2 = buf;
|
||||
|
||||
for(frames = 0; buf2 < end; frames++) {
|
||||
uint8_t buf3[4096];
|
||||
int i;
|
||||
if(!memcmp(buf2, "\x1\x10\0\0\0\0\0\0", 8))
|
||||
buf2+=16;
|
||||
if (buf[0] == 0x77 && buf[1] == 0x0B) {
|
||||
for(i=0; i<8; i+=2) {
|
||||
buf3[i ] = buf[i+1];
|
||||
buf3[i+1] = buf[i ];
|
||||
}
|
||||
init_get_bits(&gbc, buf3, 54);
|
||||
}else
|
||||
init_get_bits(&gbc, buf2, 54);
|
||||
if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)
|
||||
break;
|
||||
if(buf2 + hdr.frame_size > end)
|
||||
break;
|
||||
if (buf[0] == 0x77 && buf[1] == 0x0B) {
|
||||
av_assert0(hdr.frame_size <= sizeof(buf3));
|
||||
for(i=8; i<hdr.frame_size; i+=2) {
|
||||
buf3[i ] = buf[i+1];
|
||||
buf3[i+1] = buf[i ];
|
||||
}
|
||||
}
|
||||
if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, gbc.buffer + 2, hdr.frame_size - 2))
|
||||
break;
|
||||
if (hdr.bitstream_id > 10)
|
||||
codec_id = AV_CODEC_ID_EAC3;
|
||||
buf2 += hdr.frame_size;
|
||||
}
|
||||
max_frames = FFMAX(max_frames, frames);
|
||||
if(buf == p->buf)
|
||||
first_frames = frames;
|
||||
}
|
||||
if(codec_id != expected_codec_id) return 0;
|
||||
// keep this in sync with mp3 probe, both need to avoid
|
||||
// issues with MPEG-files!
|
||||
if (first_frames>=4) return AVPROBE_SCORE_EXTENSION + 1;
|
||||
else if(max_frames>200)return AVPROBE_SCORE_EXTENSION;
|
||||
else if(max_frames>=4) return AVPROBE_SCORE_EXTENSION/2;
|
||||
else if(max_frames>=1) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_AC3_DEMUXER
|
||||
static int ac3_probe(AVProbeData *p)
|
||||
{
|
||||
return ac3_eac3_probe(p, AV_CODEC_ID_AC3);
|
||||
}
|
||||
|
||||
AVInputFormat ff_ac3_demuxer = {
|
||||
.name = "ac3",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw AC-3"),
|
||||
.read_probe = ac3_probe,
|
||||
.read_header = ff_raw_audio_read_header,
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.flags= AVFMT_GENERIC_INDEX,
|
||||
.extensions = "ac3",
|
||||
.raw_codec_id = AV_CODEC_ID_AC3,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if CONFIG_EAC3_DEMUXER
|
||||
static int eac3_probe(AVProbeData *p)
|
||||
{
|
||||
return ac3_eac3_probe(p, AV_CODEC_ID_EAC3);
|
||||
}
|
||||
|
||||
AVInputFormat ff_eac3_demuxer = {
|
||||
.name = "eac3",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"),
|
||||
.read_probe = eac3_probe,
|
||||
.read_header = ff_raw_audio_read_header,
|
||||
.read_packet = ff_raw_read_partial_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
.extensions = "eac3",
|
||||
.raw_codec_id = AV_CODEC_ID_EAC3,
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Lagged Fibonacci PRNG
|
||||
* Copyright (c) 2008 Michael Niedermayer
|
||||
*
|
||||
* 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 <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include "lfg.h"
|
||||
#include "md5.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "attributes.h"
|
||||
|
||||
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
|
||||
{
|
||||
uint8_t tmp[16] = { 0 };
|
||||
int i;
|
||||
|
||||
for (i = 8; i < 64; i += 4) {
|
||||
AV_WL32(tmp, seed);
|
||||
tmp[4] = i;
|
||||
av_md5_sum(tmp, tmp, 16);
|
||||
c->state[i ] = AV_RL32(tmp);
|
||||
c->state[i + 1] = AV_RL32(tmp + 4);
|
||||
c->state[i + 2] = AV_RL32(tmp + 8);
|
||||
c->state[i + 3] = AV_RL32(tmp + 12);
|
||||
}
|
||||
c->index = 0;
|
||||
}
|
||||
|
||||
void av_bmg_get(AVLFG *lfg, double out[2])
|
||||
{
|
||||
double x1, x2, w;
|
||||
|
||||
do {
|
||||
x1 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
|
||||
x2 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while (w >= 1.0);
|
||||
|
||||
w = sqrt((-2.0 * log(w)) / w);
|
||||
out[0] = x1 * w;
|
||||
out[1] = x2 * w;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include "log.h"
|
||||
#include "timer.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x = 0;
|
||||
int i, j;
|
||||
AVLFG state;
|
||||
|
||||
av_lfg_init(&state, 0xdeadbeef);
|
||||
for (j = 0; j < 10000; j++) {
|
||||
START_TIMER
|
||||
for (i = 0; i < 624; i++) {
|
||||
//av_log(NULL, AV_LOG_ERROR, "%X\n", av_lfg_get(&state));
|
||||
x += av_lfg_get(&state);
|
||||
}
|
||||
STOP_TIMER("624 calls of av_lfg_get");
|
||||
}
|
||||
av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
|
||||
|
||||
/* BMG usage example */
|
||||
{
|
||||
double mean = 1000;
|
||||
double stddev = 53;
|
||||
|
||||
av_lfg_init(&state, 42);
|
||||
|
||||
for (i = 0; i < 1000; i += 2) {
|
||||
double bmg_out[2];
|
||||
av_bmg_get(&state, bmg_out);
|
||||
av_log(NULL, AV_LOG_INFO,
|
||||
"%f\n%f\n",
|
||||
bmg_out[0] * stddev + mean,
|
||||
bmg_out[1] * stddev + mean);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Lagged Fibonacci PRNG
|
||||
* Copyright (c) 2008 Michael Niedermayer
|
||||
*
|
||||
* 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 AVUTIL_LFG_H
|
||||
#define AVUTIL_LFG_H
|
||||
|
||||
typedef struct AVLFG {
|
||||
unsigned int state[64];
|
||||
int index;
|
||||
} AVLFG;
|
||||
|
||||
void av_lfg_init(AVLFG *c, unsigned int seed);
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using an ALFG.
|
||||
*
|
||||
* Please also consider a simple LCG like state= state*1664525+1013904223,
|
||||
* it may be good enough and faster for your specific use case.
|
||||
*/
|
||||
static inline unsigned int av_lfg_get(AVLFG *c){
|
||||
c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
|
||||
return c->state[c->index++ & 63];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using a MLFG.
|
||||
*
|
||||
* Please also consider av_lfg_get() above, it is faster.
|
||||
*/
|
||||
static inline unsigned int av_mlfg_get(AVLFG *c){
|
||||
unsigned int a= c->state[(c->index-55) & 63];
|
||||
unsigned int b= c->state[(c->index-24) & 63];
|
||||
return c->state[c->index++ & 63] = 2*a*b+a+b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next two numbers generated by a Box-Muller Gaussian
|
||||
* generator using the random numbers issued by lfg.
|
||||
*
|
||||
* @param out array where the two generated numbers are placed
|
||||
*/
|
||||
void av_bmg_get(AVLFG *lfg, double out[2]);
|
||||
|
||||
#endif /* AVUTIL_LFG_H */
|
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* Copyright (C) 2006 Michael Niedermayer (michaelni@gmx.at)
|
||||
* Copyright (C) 2003-2005 by Christopher R. Hertel (crh@ubiqx.mn.org)
|
||||
*
|
||||
* References:
|
||||
* IETF RFC 1321: The MD5 Message-Digest Algorithm
|
||||
* Ron Rivest. IETF, April, 1992
|
||||
*
|
||||
* based on http://ubiqx.org/libcifs/source/Auth/MD5.c
|
||||
* from Christopher R. Hertel (crh@ubiqx.mn.org)
|
||||
* Simplified, cleaned and IMO redundant comments removed by michael.
|
||||
*
|
||||
* If you use gcc, then version 4.1 or later and -fomit-frame-pointer is
|
||||
* strongly recommended.
|
||||
*
|
||||
* 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 "config.h"
|
||||
#include "bswap.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "md5.h"
|
||||
#include "mem.h"
|
||||
|
||||
typedef struct AVMD5{
|
||||
uint64_t len;
|
||||
uint8_t block[64];
|
||||
uint32_t ABCD[4];
|
||||
} AVMD5;
|
||||
|
||||
const int av_md5_size = sizeof(AVMD5);
|
||||
|
||||
struct AVMD5 *av_md5_alloc(void)
|
||||
{
|
||||
return av_mallocz(sizeof(struct AVMD5));
|
||||
}
|
||||
|
||||
static const uint8_t S[4][4] = {
|
||||
{ 7, 12, 17, 22 }, /* round 1 */
|
||||
{ 5, 9, 14, 20 }, /* round 2 */
|
||||
{ 4, 11, 16, 23 }, /* round 3 */
|
||||
{ 6, 10, 15, 21 } /* round 4 */
|
||||
};
|
||||
|
||||
static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* round 1 */
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* round 2 */
|
||||
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* round 3 */
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* round 4 */
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
||||
};
|
||||
|
||||
#define CORE(i, a, b, c, d) do { \
|
||||
t = S[i >> 4][i & 3]; \
|
||||
a += T[i]; \
|
||||
\
|
||||
if (i < 32) { \
|
||||
if (i < 16) a += (d ^ (b & (c ^ d))) + X[ i & 15]; \
|
||||
else a += ((d & b) | (~d & c)) + X[(1 + 5*i) & 15]; \
|
||||
} else { \
|
||||
if (i < 48) a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \
|
||||
else a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \
|
||||
} \
|
||||
a = b + (a << t | a >> (32 - t)); \
|
||||
} while (0)
|
||||
|
||||
static void body(uint32_t ABCD[4], uint32_t *src, int nblocks)
|
||||
{
|
||||
int i av_unused;
|
||||
int n;
|
||||
uint32_t a, b, c, d, t, *X;
|
||||
|
||||
for (n = 0; n < nblocks; n++) {
|
||||
a = ABCD[3];
|
||||
b = ABCD[2];
|
||||
c = ABCD[1];
|
||||
d = ABCD[0];
|
||||
|
||||
X = src + n * 16;
|
||||
|
||||
#if HAVE_BIGENDIAN
|
||||
for (i = 0; i < 16; i++)
|
||||
X[i] = av_bswap32(X[i]);
|
||||
#endif
|
||||
|
||||
#if CONFIG_SMALL
|
||||
for (i = 0; i < 64; i++) {
|
||||
CORE(i, a, b, c, d);
|
||||
t = d;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
#else
|
||||
#define CORE2(i) \
|
||||
CORE( i, a,b,c,d); CORE((i+1),d,a,b,c); \
|
||||
CORE((i+2),c,d,a,b); CORE((i+3),b,c,d,a)
|
||||
#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12))
|
||||
CORE4(0); CORE4(16); CORE4(32); CORE4(48);
|
||||
#endif
|
||||
|
||||
ABCD[0] += d;
|
||||
ABCD[1] += c;
|
||||
ABCD[2] += b;
|
||||
ABCD[3] += a;
|
||||
}
|
||||
}
|
||||
|
||||
void av_md5_init(AVMD5 *ctx)
|
||||
{
|
||||
ctx->len = 0;
|
||||
|
||||
ctx->ABCD[0] = 0x10325476;
|
||||
ctx->ABCD[1] = 0x98badcfe;
|
||||
ctx->ABCD[2] = 0xefcdab89;
|
||||
ctx->ABCD[3] = 0x67452301;
|
||||
}
|
||||
|
||||
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
|
||||
{
|
||||
const uint8_t *end;
|
||||
int j;
|
||||
|
||||
j = ctx->len & 63;
|
||||
ctx->len += len;
|
||||
|
||||
if (j) {
|
||||
int cnt = FFMIN(len, 64 - j);
|
||||
memcpy(ctx->block + j, src, cnt);
|
||||
src += cnt;
|
||||
len -= cnt;
|
||||
if (j + cnt < 64)
|
||||
return;
|
||||
body(ctx->ABCD, (uint32_t *)ctx->block, 1);
|
||||
}
|
||||
|
||||
end = src + (len & ~63);
|
||||
if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) {
|
||||
while (src < end) {
|
||||
memcpy(ctx->block, src, 64);
|
||||
body(ctx->ABCD, (uint32_t *) ctx->block, 1);
|
||||
src += 64;
|
||||
}
|
||||
} else {
|
||||
int nblocks = len / 64;
|
||||
body(ctx->ABCD, (uint32_t *)src, nblocks);
|
||||
src = end;
|
||||
}
|
||||
len &= 63;
|
||||
if (len > 0)
|
||||
memcpy(ctx->block, src, len);
|
||||
}
|
||||
|
||||
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
|
||||
{
|
||||
int i;
|
||||
uint64_t finalcount = av_le2ne64(ctx->len << 3);
|
||||
|
||||
av_md5_update(ctx, (const unsigned char *) "\200", 1);
|
||||
while ((ctx->len & 63) != 56)
|
||||
av_md5_update(ctx, (const unsigned char *) "", 1);
|
||||
|
||||
av_md5_update(ctx, (uint8_t *)&finalcount, 8);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
AV_WL32(dst + 4*i, ctx->ABCD[3 - i]);
|
||||
}
|
||||
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
|
||||
{
|
||||
AVMD5 ctx;
|
||||
|
||||
av_md5_init(&ctx);
|
||||
av_md5_update(&ctx, src, len);
|
||||
av_md5_final(&ctx, dst);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <stdio.h>
|
||||
|
||||
static void print_md5(uint8_t *md5)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%02x", md5[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(void){
|
||||
uint8_t md5val[16];
|
||||
int i;
|
||||
uint8_t in[1000];
|
||||
|
||||
for (i = 0; i < 1000; i++)
|
||||
in[i] = i * i;
|
||||
av_md5_sum(md5val, in, 1000); print_md5(md5val);
|
||||
av_md5_sum(md5val, in, 63); print_md5(md5val);
|
||||
av_md5_sum(md5val, in, 64); print_md5(md5val);
|
||||
av_md5_sum(md5val, in, 65); print_md5(md5val);
|
||||
for (i = 0; i < 1000; i++)
|
||||
in[i] = i % 127;
|
||||
av_md5_sum(md5val, in, 999); print_md5(md5val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* copyright (c) 2006 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 AVUTIL_MD5_H
|
||||
#define AVUTIL_MD5_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_md5 MD5
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_md5_size;
|
||||
|
||||
struct AVMD5;
|
||||
|
||||
/**
|
||||
* Allocate an AVMD5 context.
|
||||
*/
|
||||
struct AVMD5 *av_md5_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize MD5 hashing.
|
||||
*
|
||||
* @param ctx pointer to the function context (of size av_md5_size)
|
||||
*/
|
||||
void av_md5_init(struct AVMD5 *ctx);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param ctx hash function context
|
||||
* @param src input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param ctx hash function context
|
||||
* @param dst buffer where output digest value is stored
|
||||
*/
|
||||
void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
|
||||
|
||||
/**
|
||||
* Hash an array of data.
|
||||
*
|
||||
* @param dst The output buffer to write the digest into
|
||||
* @param src The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
*/
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MD5_H */
|
|
@ -139,6 +139,7 @@ StringList FileRef::defaultFileExtensions()
|
|||
l.append("ape");
|
||||
l.append("opus");
|
||||
l.append("tak");
|
||||
l.append("ac3");
|
||||
l.append("apl");
|
||||
|
||||
return l;
|
||||
|
@ -235,7 +236,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 == "APL")
|
||||
if(ext == "TAK" || ext == "AC3" || ext == "APL")
|
||||
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", nil];
|
||||
return [NSArray arrayWithObjects:@"wma", @"asf", @"xwma", @"tak", @"mp3", @"mp2", @"m2a", @"mpa", @"ape", @"ac3", 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", 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", 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", @"apl", nil];
|
||||
return [NSArray arrayWithObjects:@"ape", @"asf", @"wma", @"ogg", @"opus", @"mpc", @"flac", @"m4a", @"mp3", @"tak", @"ac3", @"apl", 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-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", nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue