annotate libmpcodecs/ad_ffmpeg.c @ 25523:47a9e9cccebb

Remove redundant extern declarations, fixes the warnings: vo_vesa.c:55: warning: redundant redeclaration of #monitor_hfreq_str# video_out.h:252: warning: previous declaration of #monitor_hfreq_str# was here vo_vesa.c:56: warning: redundant redeclaration of #monitor_vfreq_str# video_out.h:253: warning: previous declaration of #monitor_vfreq_str# was here vo_vesa.c:57: warning: redundant redeclaration of #monitor_dotclock_str# video_out.h:254: warning: previous declaration of #monitor_dotclock_str# was here
author diego
date Sun, 30 Dec 2007 12:12:47 +0000
parents dfa8a510c81c
children afa125da85cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
1 #include <stdio.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
2 #include <stdlib.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
3 #include <unistd.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
4
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
5 #include "config.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
6 #include "mp_msg.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
7 #include "help_mp.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
8
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
9 #include "ad_internal.h"
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
10 #include "libaf/reorder_ch.h"
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
11
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
12 #include "mpbswap.h"
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
13
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
14 static ad_info_t info =
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
15 {
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
16 "FFmpeg/libavcodec audio decoders",
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
17 "ffmpeg",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
18 "Nick Kurshev",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19 "ffmpeg.sf.net",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
20 ""
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
21 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
22
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
23 LIBAD_EXTERN(ffmpeg)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
24
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
25 #define assert(x)
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
26
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
27 #ifdef USE_LIBAVCODEC_SO
7004
8eff71f38685 dynamic libavcodec.so support updated by
arpi
parents: 5480
diff changeset
28 #include <ffmpeg/avcodec.h>
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
29 #else
16165
a9f7eff9e437 Support new static libavcodec (depends on libavutil).
al
parents: 14922
diff changeset
30 #include "avcodec.h"
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
31 #endif
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
32
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
33 extern int avcodec_inited;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
34
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
35 static int preinit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
36 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
37 sh->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
38 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
39 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
40
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
41 static int init(sh_audio_t *sh_audio)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
42 {
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
43 int x;
5480
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
44 AVCodecContext *lavc_context;
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
45 AVCodec *lavc_codec;
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
46
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
47 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n");
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 if(!avcodec_inited){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
49 avcodec_init();
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
50 avcodec_register_all();
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
51 avcodec_inited=1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
52 }
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
53
5480
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
54 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll);
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
55 if(!lavc_codec){
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
56 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
57 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 }
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
59
7940
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
60 lavc_context = avcodec_alloc_context();
5480
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
61 sh_audio->context=lavc_context;
7940
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
62
24226
352d7d9422b5 Set sample_rate and bit_rate from sh_audio as fallback in case sh_audio->wf
reimar
parents: 24108
diff changeset
63 lavc_context->sample_rate = sh_audio->samplerate;
352d7d9422b5 Set sample_rate and bit_rate from sh_audio as fallback in case sh_audio->wf
reimar
parents: 24108
diff changeset
64 lavc_context->bit_rate = sh_audio->i_bps * 8;
8590
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
65 if(sh_audio->wf){
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
66 lavc_context->channels = sh_audio->wf->nChannels;
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
67 lavc_context->sample_rate = sh_audio->wf->nSamplesPerSec;
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
68 lavc_context->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8;
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
69 lavc_context->block_align = sh_audio->wf->nBlockAlign;
14922
ed06939c5217 alac support via lavc decoder
rtognimp
parents: 14633
diff changeset
70 lavc_context->bits_per_sample = sh_audio->wf->wBitsPerSample;
8590
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
71 }
24108
51cd49ee92d6 Use new request_channels
reimar
parents: 23978
diff changeset
72 lavc_context->request_channels = audio_output_channels;
9547
3b3b7b6fdb22 merging fourcc with codec_tag
michael
parents: 8590
diff changeset
73 lavc_context->codec_tag = sh_audio->format; //FOURCC
8590
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
74 lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi
7940
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
75
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
76 /* alloc extra data */
8590
0328af0565bf ffmp2 (with mpeg files) sig11 fixed
arpi
parents: 8108
diff changeset
77 if (sh_audio->wf && sh_audio->wf->cbSize > 0) {
17226
255b14c0bc36 malloc padding to avoid access beyond allocated memory
henry
parents: 16165
diff changeset
78 lavc_context->extradata = av_mallocz(sh_audio->wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE);
7940
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
79 lavc_context->extradata_size = sh_audio->wf->cbSize;
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
80 memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX),
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
81 lavc_context->extradata_size);
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
82 }
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
83
14633
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
84 // for QDM2
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
85 if (sh_audio->codecdata_len && sh_audio->codecdata && !lavc_context->extradata)
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
86 {
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
87 lavc_context->extradata = av_malloc(sh_audio->codecdata_len);
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
88 lavc_context->extradata_size = sh_audio->codecdata_len;
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
89 memcpy(lavc_context->extradata, (char *)sh_audio->codecdata,
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
90 lavc_context->extradata_size);
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
91 }
bde5c3261037 pass wave extradata to the codec..
alex
parents: 14431
diff changeset
92
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
93 /* open it */
5480
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
94 if (avcodec_open(lavc_context, lavc_codec) < 0) {
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
95 mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
96 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
97 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
98 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n");
8101
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
99
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
100 // printf("\nFOURCC: 0x%X\n",sh_audio->format);
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
101 if(sh_audio->format==0x3343414D){
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
102 // MACE 3:1
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
103 sh_audio->ds->ss_div = 2*3; // 1 samples/packet
8108
d9b2b39e5c06 Fix stereo MACE files
rtognimp
parents: 8101
diff changeset
104 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet
8101
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
105 } else
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
106 if(sh_audio->format==0x3643414D){
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
107 // MACE 6:1
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
108 sh_audio->ds->ss_div = 2*6; // 1 samples/packet
8108
d9b2b39e5c06 Fix stereo MACE files
rtognimp
parents: 8101
diff changeset
109 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet
8101
1bce6e325946 MACE fix
arpi
parents: 7958
diff changeset
110 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
111
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
112 // Decode at least 1 byte: (to get header filled)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
113 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
114 if(x>0) sh_audio->a_buffer_len=x;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
115
5480
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
116 sh_audio->channels=lavc_context->channels;
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
117 sh_audio->samplerate=lavc_context->sample_rate;
df12f6eb80e3 removed useless contect struct -> code simplified
arpi
parents: 5447
diff changeset
118 sh_audio->i_bps=lavc_context->bit_rate/8;
17995
92c4247cc902 Trust the demuxer instead of the decoder for samplerate detection.
diego
parents: 17523
diff changeset
119 if(sh_audio->wf){
18150
710d4bc5f8c9 Using channel count, samplerate and input bps values from the container
diego
parents: 17995
diff changeset
120 // If the decoder uses the wrong number of channels all is lost anyway.
710d4bc5f8c9 Using channel count, samplerate and input bps values from the container
diego
parents: 17995
diff changeset
121 // sh_audio->channels=sh_audio->wf->nChannels;
20328
5d9f47834495 Do not use sh_audio->wf values if they are definitely invalid
reimar
parents: 18242
diff changeset
122 if (sh_audio->wf->nSamplesPerSec)
17995
92c4247cc902 Trust the demuxer instead of the decoder for samplerate detection.
diego
parents: 17523
diff changeset
123 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
20328
5d9f47834495 Do not use sh_audio->wf values if they are definitely invalid
reimar
parents: 18242
diff changeset
124 if (sh_audio->wf->nAvgBytesPerSec)
17995
92c4247cc902 Trust the demuxer instead of the decoder for samplerate detection.
diego
parents: 17523
diff changeset
125 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
92c4247cc902 Trust the demuxer instead of the decoder for samplerate detection.
diego
parents: 17523
diff changeset
126 }
13427
9d0b052c4f74 setting samplesize to 2 in decoders where neccessary.
reimar
parents: 12142
diff changeset
127 sh_audio->samplesize=2;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
128 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
129 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
130
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
131 static void uninit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
132 {
7940
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
133 AVCodecContext *lavc_context = sh->context;
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
134
26fd599d4bad pass extradata to the codec
arpi
parents: 7191
diff changeset
135 if (avcodec_close(lavc_context) < 0)
5447
63082aa173f8 using sh->context
alex
parents: 5343
diff changeset
136 mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
14431
0c10f923746e change malloc and free to av_ variants where needed.
reimar
parents: 13427
diff changeset
137 av_freep(&lavc_context->extradata);
0c10f923746e change malloc and free to av_ variants where needed.
reimar
parents: 13427
diff changeset
138 av_freep(&lavc_context);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
139 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
140
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
141 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
142 {
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
143 AVCodecContext *lavc_context = sh->context;
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
144 switch(cmd){
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
145 case ADCTRL_RESYNC_STREAM:
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
146 avcodec_flush_buffers(lavc_context);
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
147 return CONTROL_TRUE;
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
148 }
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
149 return CONTROL_UNKNOWN;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
150 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
151
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
152 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
153 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
154 unsigned char *start=NULL;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
155 int y,len=-1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
156 while(len<minlen){
23456
1582297cc3d2 Use avcodec_decode_audio2 in ad_ffmpeg.c
reimar
parents: 21507
diff changeset
157 int len2=maxlen;
18242
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
158 double pts;
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
159 int x=ds_get_packet_pts(sh_audio->ds,&start, &pts);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
160 if(x<=0) break; // error
18242
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
161 if (pts != MP_NOPTS_VALUE) {
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
162 sh_audio->pts = pts;
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
163 sh_audio->pts_bytes = 0;
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
164 }
23456
1582297cc3d2 Use avcodec_decode_audio2 in ad_ffmpeg.c
reimar
parents: 21507
diff changeset
165 y=avcodec_decode_audio2(sh_audio->context,(int16_t*)buf,&len2,start,x);
11977
efb37725d616 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents: 9547
diff changeset
166 //printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
167 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
168 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
169 if(len2>0){
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
170 if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
171 int src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
172 const char *codec=((AVCodecContext*)sh_audio->context)->codec->name;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
173 if (!strcasecmp(codec, "ac3"))
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
174 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
175 else if (!strcasecmp(codec, "dca"))
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
176 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
177 else if (!strcasecmp(codec, "libfaad")
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
178 || !strcasecmp(codec, "mpeg4aac"))
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
179 src_ch_layout = AF_CHANNEL_LAYOUT_AAC_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
180 else if (!strcasecmp(codec, "liba52"))
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
181 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
182 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
183 src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
184 reorder_channel_nch(buf, src_ch_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
185 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
186 ((AVCodecContext *)sh_audio->context)->channels,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
187 len2 / 2, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 24226
diff changeset
188 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
189 //len=len2;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
190 if(len<0) len=len2; else len+=len2;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
191 buf+=len2;
23456
1582297cc3d2 Use avcodec_decode_audio2 in ad_ffmpeg.c
reimar
parents: 21507
diff changeset
192 maxlen -= len2;
18242
caac2ca98168 4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents: 18150
diff changeset
193 sh_audio->pts_bytes += len2;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
194 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
195 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
196 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
197 return len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
198 }