Mercurial > mplayer.hg
annotate libmpcodecs/ad_faad.c @ 17799:02139a9b7c7b
drop max_frame_size
author | michael |
---|---|
date | Fri, 10 Mar 2006 14:28:11 +0000 |
parents | 934380353fd6 |
children | caac2ca98168 |
rev | line source |
---|---|
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
1 /* ad_faad.c - MPlayer AAC decoder using libfaad2 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
2 * This file is part of MPlayer, see http://mplayerhq.hu/ for info. |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
3 * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
4 * File licensed under the GPL, see http://www.fsf.org/ for more info. |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
5 */ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
6 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
7 #include <stdio.h> |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
8 #include <stdlib.h> |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
9 #include <unistd.h> |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
10 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
11 #include "config.h" |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
12 #include "ad_internal.h" |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
13 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
14 #ifdef HAVE_FAAD |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
15 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
16 static ad_info_t info = |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
17 { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
18 "AAC (MPEG2/4 Advanced Audio Coding)", |
7174 | 19 "faad", |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
20 "Felix Buenemann", |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
21 "faad2", |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
22 "uses libfaad2" |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
23 }; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
24 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
25 LIBAD_EXTERN(faad) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
26 |
10921 | 27 #ifndef USE_INTERNAL_FAAD |
28 #include <faad.h> | |
29 #else | |
17012 | 30 #include "libfaad2/faad.h" |
10921 | 31 #endif |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
32 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
33 /* configure maximum supported channels, * |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
34 * this is theoretically max. 64 chans */ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
35 #define FAAD_MAX_CHANNELS 6 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
36 #define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
37 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
38 //#define AAC_DUMP_COMPRESSED |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
39 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
40 static faacDecHandle faac_hdec; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
41 static faacDecFrameInfo faac_finfo; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
42 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
43 static int preinit(sh_audio_t *sh) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
44 { |
12095
cef97e8c85c0
Support for HE-AAC. Patch by Loren Merritt <lorenm at u dot washington anotherdot edu>.
mosu
parents:
10921
diff
changeset
|
45 sh->audio_out_minsize=8192*FAAD_MAX_CHANNELS; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
46 sh->audio_in_minsize=FAAD_BUFFLEN; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
47 return 1; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
48 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
49 |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
50 static int aac_probe(unsigned char *buffer, int len) |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
51 { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
52 int i = 0, pos = 0; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
53 mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC_PROBE: %d bytes\n", len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
54 while(i <= len-4) { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
55 if( |
15708
bdb826438aa8
fixed wrong binary mask: it precluded the syncword of adts-4 from being recognized as valid
nicodvb
parents:
15019
diff
changeset
|
56 ((buffer[i] == 0xff) && ((buffer[i+1] & 0xf6) == 0xf0)) || |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
57 (buffer[i] == 'A' && buffer[i+1] == 'D' && buffer[i+2] == 'I' && buffer[i+3] == 'F') |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
58 ) { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
59 pos = i; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
60 break; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
61 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
62 mp_msg(MSGT_DECAUDIO,MSGL_V, "AUDIO PAYLOAD: %x %x %x %x\n", buffer[i], buffer[i+1], buffer[i+2], buffer[i+3]); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
63 i++; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
64 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
65 mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC_PROBE: ret %d\n", pos); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
66 return pos; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
67 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
68 |
15019 | 69 extern int audio_output_channels; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
70 static int init(sh_audio_t *sh) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
71 { |
7648
7ee8239bfcc0
I think libfaad2 changed recently. The functions faacDecInit() and
arpi
parents:
7191
diff
changeset
|
72 unsigned long faac_samplerate; |
7ee8239bfcc0
I think libfaad2 changed recently. The functions faacDecInit() and
arpi
parents:
7191
diff
changeset
|
73 unsigned char faac_channels; |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
74 int faac_init, pos = 0; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
75 faac_hdec = faacDecOpen(); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
76 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
77 // If we don't get the ES descriptor, try manual config |
12473
6f11d107f7b8
If demuxer does not fill codecdata try to get if from waveformatex
rtognimp
parents:
12095
diff
changeset
|
78 if(!sh->codecdata_len && sh->wf) { |
6f11d107f7b8
If demuxer does not fill codecdata try to get if from waveformatex
rtognimp
parents:
12095
diff
changeset
|
79 sh->codecdata_len = sh->wf->cbSize; |
6f11d107f7b8
If demuxer does not fill codecdata try to get if from waveformatex
rtognimp
parents:
12095
diff
changeset
|
80 sh->codecdata = (char*)(sh->wf+1); |
6f11d107f7b8
If demuxer does not fill codecdata try to get if from waveformatex
rtognimp
parents:
12095
diff
changeset
|
81 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: codecdata extracted from WAVEFORMATEX\n"); |
6f11d107f7b8
If demuxer does not fill codecdata try to get if from waveformatex
rtognimp
parents:
12095
diff
changeset
|
82 } |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
83 if(!sh->codecdata_len) { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
84 #if 1 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
85 faacDecConfigurationPtr faac_conf; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
86 /* Set the default object type and samplerate */ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
87 /* This is useful for RAW AAC files */ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
88 faac_conf = faacDecGetCurrentConfiguration(faac_hdec); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
89 if(sh->samplerate) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
90 faac_conf->defSampleRate = sh->samplerate; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
91 /* XXX: FAAD support FLOAT output, how do we handle |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
92 * that (FAAD_FMT_FLOAT)? ::atmos |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
93 */ |
15019 | 94 if (audio_output_channels <= 2) faac_conf->downMatrix = 1; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
95 switch(sh->samplesize){ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
96 case 1: // 8Bit |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
97 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n"); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
98 default: |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
13307
diff
changeset
|
99 sh->samplesize=2; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
100 case 2: // 16Bit |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
101 faac_conf->outputFormat = FAAD_FMT_16BIT; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
102 break; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
103 case 3: // 24Bit |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
104 faac_conf->outputFormat = FAAD_FMT_24BIT; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
105 break; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
106 case 4: // 32Bit |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
107 faac_conf->outputFormat = FAAD_FMT_32BIT; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
108 break; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
109 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
110 //faac_conf->defObjectType = LTP; // => MAIN, LC, SSR, LTP available. |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
111 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
112 faacDecSetConfiguration(faac_hdec, faac_conf); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
113 #endif |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
114 |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
115 sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size); |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
116 pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
117 if(pos) { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
118 sh->a_in_buffer_len -= pos; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
119 memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
120 sh->a_in_buffer_len += |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
121 demux_read_data(sh->ds,&(sh->a_in_buffer[sh->a_in_buffer_len]), |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
122 sh->a_in_buffer_size - sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
123 pos = 0; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
124 } |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
125 |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
126 /* init the codec */ |
9321
6fa743f3094b
libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c
arpi
parents:
7648
diff
changeset
|
127 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer, |
6fa743f3094b
libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c
arpi
parents:
7648
diff
changeset
|
128 sh->a_in_buffer_len, &faac_samplerate, &faac_channels); |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
129 |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
130 sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
131 // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
132 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
133 } else { // We have ES DS in codecdata |
15019 | 134 faacDecConfigurationPtr faac_conf = faacDecGetCurrentConfiguration(faac_hdec); |
135 if (audio_output_channels <= 2) { | |
136 faac_conf->downMatrix = 1; | |
137 faacDecSetConfiguration(faac_hdec, faac_conf); | |
138 } | |
139 | |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
140 /*int i; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
141 for(i = 0; i < sh_audio->codecdata_len; i++) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
142 printf("codecdata_dump %d: 0x%02X\n", i, sh_audio->codecdata[i]);*/ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
143 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
144 faac_init = faacDecInit2(faac_hdec, sh->codecdata, |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
145 sh->codecdata_len, &faac_samplerate, &faac_channels); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
146 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
147 if(faac_init < 0) { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
148 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to initialize the decoder!\n"); // XXX: deal with cleanup! |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
149 faacDecClose(faac_hdec); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
150 // XXX: free a_in_buffer here or in uninit? |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
151 return 0; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
152 } else { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
153 mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Decoder init done (%dBytes)!\n", sh->a_in_buffer_len); // XXX: remove or move to debug! |
17366 | 154 mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Negotiated samplerate: %ldHz channels: %d\n", faac_samplerate, faac_channels); |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
155 sh->channels = faac_channels; |
15019 | 156 if (audio_output_channels <= 2) sh->channels = faac_channels > 1 ? 2 : 1; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
157 sh->samplerate = faac_samplerate; |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
13307
diff
changeset
|
158 sh->samplesize=2; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
159 //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
160 if(!sh->i_bps) { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
161 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
162 sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
163 } else |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
164 mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
165 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
166 return 1; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
167 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
168 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
169 static void uninit(sh_audio_t *sh) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
170 { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
171 mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Closing decoder!\n"); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
172 faacDecClose(faac_hdec); |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
173 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
174 |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
175 static int aac_sync(sh_audio_t *sh) |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
176 { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
177 int pos = 0; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
178 if(!sh->codecdata_len) { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
179 if(sh->a_in_buffer_len < sh->a_in_buffer_size){ |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
180 sh->a_in_buffer_len += |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
181 demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
182 sh->a_in_buffer_size - sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
183 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
184 pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
185 if(pos) { |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
186 sh->a_in_buffer_len -= pos; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
187 memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), sh->a_in_buffer_len); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
188 mp_msg(MSGT_DECAUDIO,MSGL_V, "\nAAC SYNC AFTER %d bytes\n", pos); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
189 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
190 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
191 return pos; |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
192 } |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
193 |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
194 static int control(sh_audio_t *sh,int cmd,void* arg, ...) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
195 { |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
196 switch(cmd) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
197 { |
14564
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
198 case ADCTRL_RESYNC_STREAM: |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
199 aac_sync(sh); |
f85875877de9
tries to sync to ADTS/ADIF header before initializing the decoder; implement SYNC
nicodvb
parents:
13427
diff
changeset
|
200 return CONTROL_TRUE; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
201 #if 0 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
202 case ADCTRL_SKIP_FRAME: |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
203 return CONTROL_TRUE; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
204 #endif |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
205 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
206 return CONTROL_UNKNOWN; |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
207 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
208 |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
209 #define MAX_FAAD_ERRORS 10 |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
210 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen) |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
211 { |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
212 int j = 0, len = 0, last_dec_len = 1, errors = 0; |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
213 void *faac_sample_buffer; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
214 |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
215 while(len < minlen && last_dec_len > 0 && errors < MAX_FAAD_ERRORS) { |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
216 |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
217 /* update buffer for raw aac streams: */ |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
218 if(!sh->codecdata_len) |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
219 if(sh->a_in_buffer_len < sh->a_in_buffer_size){ |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
220 sh->a_in_buffer_len += |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
221 demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
222 sh->a_in_buffer_size - sh->a_in_buffer_len); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
223 } |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
224 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
225 #ifdef DUMP_AAC_COMPRESSED |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
226 {int i; |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
227 for (i = 0; i < 16; i++) |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
228 printf ("%02X ", sh->a_in_buffer[i]); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
229 printf ("\n");} |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
230 #endif |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
231 |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
232 if(!sh->codecdata_len){ |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
233 // raw aac stream: |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
234 do { |
9321
6fa743f3094b
libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c
arpi
parents:
7648
diff
changeset
|
235 faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer+j, sh->a_in_buffer_len); |
6fa743f3094b
libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c
arpi
parents:
7648
diff
changeset
|
236 |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
237 /* update buffer index after faacDecDecode */ |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
238 if(faac_finfo.bytesconsumed >= sh->a_in_buffer_len) { |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
239 sh->a_in_buffer_len=0; |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
240 } else { |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
241 sh->a_in_buffer_len-=faac_finfo.bytesconsumed; |
15978
c8dc500e078e
memcpy and memmove both copy memory, but when using memcpy the source and destination must not overlap, but here, they did overlap.
gpoirier
parents:
15708
diff
changeset
|
242 memmove(sh->a_in_buffer,&sh->a_in_buffer[faac_finfo.bytesconsumed],sh->a_in_buffer_len); |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
243 } |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
244 |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
245 if(faac_finfo.error > 0) { |
13307
b94f228dfed6
output faad error message in case of a decoder error
reimar
parents:
12473
diff
changeset
|
246 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: error: %s, trying to resync!\n", |
b94f228dfed6
output faad error message in case of a decoder error
reimar
parents:
12473
diff
changeset
|
247 faacDecGetErrorMessage(faac_finfo.error)); |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
248 j++; |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
249 errors++; |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
250 } else |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
251 break; |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
252 } while(j < FAAD_BUFFLEN && errors < MAX_FAAD_ERRORS); |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
253 } else { |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
254 // packetized (.mp4) aac stream: |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
255 unsigned char* bufptr=NULL; |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
256 int buflen=ds_get_packet(sh->ds, &bufptr); |
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
257 if(buflen<=0) break; |
9321
6fa743f3094b
libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c
arpi
parents:
7648
diff
changeset
|
258 faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr, buflen); |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
259 } |
15019 | 260 //for (j=0;j<faac_finfo.channels;j++) printf("%d:%d\n", j, faac_finfo.channel_position[j]); |
6894
a32870fd043b
support for packetized aac streams (used in .mp4 files)
arpi
parents:
5458
diff
changeset
|
261 |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
262 if(faac_finfo.error > 0) { |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
263 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to decode frame: %s \n", |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
264 faacDecGetErrorMessage(faac_finfo.error)); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
265 } else if (faac_finfo.samples == 0) { |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
266 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: Decoded zero samples!\n"); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
267 } else { |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
268 /* XXX: samples already multiplied by channels! */ |
17366 | 269 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: Successfully decoded frame (%ld Bytes)!\n", |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
270 sh->samplesize*faac_finfo.samples); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
271 memcpy(buf+len,faac_sample_buffer, sh->samplesize*faac_finfo.samples); |
16337
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
272 last_dec_len = sh->samplesize*faac_finfo.samples; |
7252d024193b
* really keep track on how many samples were decoded last round (fix 10l)
attila
parents:
16336
diff
changeset
|
273 len += last_dec_len; |
5357
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
274 //printf("FAAD: buffer: %d bytes consumed: %d \n", k, faac_finfo.bytesconsumed); |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
275 } |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
276 } |
3c5d5626d3a1
Don't kill me, pure indent change as I forgot to reindent when copy and pasting from dec_audio.c, as this is the first revision it doesn't break changelog!
atmos4
parents:
5356
diff
changeset
|
277 return len; |
5356
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
278 } |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
279 |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
280 #endif /* !HAVE_FAAD */ |
739cad21c32c
Port dec_audio.c faad aac decoder to libmpcodecs, cleaned up code, improved buffering scheme.
atmos4
parents:
diff
changeset
|
281 |