Mercurial > mplayer.hg
annotate libmpcodecs/ad_ffmpeg.c @ 26903:5ed6787022c4
Merge vidix/dhahelperwin/Makefile into top-level Makefile.
author | diego |
---|---|
date | Fri, 30 May 2008 20:09:31 +0000 |
parents | b6280829f7f8 |
children | d3a0f537dbe8 |
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 | 26 |
26069
1318e956c092
FFmpeg now uses different (unified) #include paths.
diego
parents:
25962
diff
changeset
|
27 #include "libavcodec/avcodec.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
|
28 |
25962 | 29 extern int avcodec_initialized; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
30 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
31 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
|
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 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
|
34 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
|
35 } |
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 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
|
38 { |
5447 | 39 int x; |
5480 | 40 AVCodecContext *lavc_context; |
41 AVCodec *lavc_codec; | |
5447 | 42 |
43 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n"); | |
25962 | 44 if(!avcodec_initialized){ |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
45 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
|
46 avcodec_register_all(); |
25962 | 47 avcodec_initialized=1; |
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 } |
5447 | 49 |
5480 | 50 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); |
51 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
|
52 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
|
53 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
|
54 } |
5447 | 55 |
7940 | 56 lavc_context = avcodec_alloc_context(); |
5480 | 57 sh_audio->context=lavc_context; |
7940 | 58 |
24226
352d7d9422b5
Set sample_rate and bit_rate from sh_audio as fallback in case sh_audio->wf
reimar
parents:
24108
diff
changeset
|
59 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
|
60 lavc_context->bit_rate = sh_audio->i_bps * 8; |
8590 | 61 if(sh_audio->wf){ |
62 lavc_context->channels = sh_audio->wf->nChannels; | |
63 lavc_context->sample_rate = sh_audio->wf->nSamplesPerSec; | |
64 lavc_context->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8; | |
65 lavc_context->block_align = sh_audio->wf->nBlockAlign; | |
14922 | 66 lavc_context->bits_per_sample = sh_audio->wf->wBitsPerSample; |
8590 | 67 } |
24108 | 68 lavc_context->request_channels = audio_output_channels; |
9547 | 69 lavc_context->codec_tag = sh_audio->format; //FOURCC |
8590 | 70 lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi |
7940 | 71 |
72 /* alloc extra data */ | |
8590 | 73 if (sh_audio->wf && sh_audio->wf->cbSize > 0) { |
17226
255b14c0bc36
malloc padding to avoid access beyond allocated memory
henry
parents:
16165
diff
changeset
|
74 lavc_context->extradata = av_mallocz(sh_audio->wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE); |
7940 | 75 lavc_context->extradata_size = sh_audio->wf->cbSize; |
76 memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX), | |
77 lavc_context->extradata_size); | |
78 } | |
79 | |
14633 | 80 // for QDM2 |
81 if (sh_audio->codecdata_len && sh_audio->codecdata && !lavc_context->extradata) | |
82 { | |
83 lavc_context->extradata = av_malloc(sh_audio->codecdata_len); | |
84 lavc_context->extradata_size = sh_audio->codecdata_len; | |
85 memcpy(lavc_context->extradata, (char *)sh_audio->codecdata, | |
86 lavc_context->extradata_size); | |
87 } | |
88 | |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
89 /* open it */ |
5480 | 90 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
|
91 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
|
92 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
|
93 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
94 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n"); |
8101 | 95 |
96 // printf("\nFOURCC: 0x%X\n",sh_audio->format); | |
97 if(sh_audio->format==0x3343414D){ | |
98 // MACE 3:1 | |
99 sh_audio->ds->ss_div = 2*3; // 1 samples/packet | |
8108 | 100 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet |
8101 | 101 } else |
102 if(sh_audio->format==0x3643414D){ | |
103 // MACE 6:1 | |
104 sh_audio->ds->ss_div = 2*6; // 1 samples/packet | |
8108 | 105 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet |
8101 | 106 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
107 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
108 // 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
|
109 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
|
110 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
|
111 |
5480 | 112 sh_audio->channels=lavc_context->channels; |
113 sh_audio->samplerate=lavc_context->sample_rate; | |
114 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
|
115 if(sh_audio->wf){ |
18150
710d4bc5f8c9
Using channel count, samplerate and input bps values from the container
diego
parents:
17995
diff
changeset
|
116 // 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
|
117 // 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
|
118 if (sh_audio->wf->nSamplesPerSec) |
17995
92c4247cc902
Trust the demuxer instead of the decoder for samplerate detection.
diego
parents:
17523
diff
changeset
|
119 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
|
120 if (sh_audio->wf->nAvgBytesPerSec) |
17995
92c4247cc902
Trust the demuxer instead of the decoder for samplerate detection.
diego
parents:
17523
diff
changeset
|
121 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
92c4247cc902
Trust the demuxer instead of the decoder for samplerate detection.
diego
parents:
17523
diff
changeset
|
122 } |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
12142
diff
changeset
|
123 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
|
124 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
|
125 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
126 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
127 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
|
128 { |
7940 | 129 AVCodecContext *lavc_context = sh->context; |
130 | |
131 if (avcodec_close(lavc_context) < 0) | |
5447 | 132 mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec); |
14431
0c10f923746e
change malloc and free to av_ variants where needed.
reimar
parents:
13427
diff
changeset
|
133 av_freep(&lavc_context->extradata); |
0c10f923746e
change malloc and free to av_ variants where needed.
reimar
parents:
13427
diff
changeset
|
134 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
|
135 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
136 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
137 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
|
138 { |
11977
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
9547
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 } |
efb37725d616
flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
michael
parents:
9547
diff
changeset
|
145 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
|
146 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
147 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
148 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
|
149 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
150 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
|
151 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
|
152 while(len<minlen){ |
23456 | 153 int len2=maxlen; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18150
diff
changeset
|
154 double pts; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18150
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 sh_audio->pts = pts; |
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18150
diff
changeset
|
159 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
|
160 } |
23456 | 161 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
|
162 //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
|
163 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
|
164 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
|
165 if(len2>0){ |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
166 if (((AVCodecContext *)sh_audio->context)->channels >= 5) { |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
167 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
|
168 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
|
169 if (!strcasecmp(codec, "ac3")) |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
170 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
|
171 else if (!strcasecmp(codec, "dca")) |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
172 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
|
173 else if (!strcasecmp(codec, "libfaad") |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
174 || !strcasecmp(codec, "mpeg4aac")) |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
175 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
|
176 else if (!strcasecmp(codec, "liba52")) |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
177 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT; |
26132
b6280829f7f8
Fix ffvorbis decoder's output channel order with channel reordering function.
ulion
parents:
26069
diff
changeset
|
178 else if (!strcasecmp(codec, "vorbis")) |
b6280829f7f8
Fix ffvorbis decoder's output channel order with channel reordering function.
ulion
parents:
26069
diff
changeset
|
179 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_VORBIS_DEFAULT; |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
180 else |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
181 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
|
182 reorder_channel_nch(buf, src_ch_layout, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
183 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
184 ((AVCodecContext *)sh_audio->context)->channels, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
185 len2 / 2, 2); |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
24226
diff
changeset
|
186 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
187 //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
|
188 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
|
189 buf+=len2; |
23456 | 190 maxlen -= len2; |
18242
caac2ca98168
4 - Implement a better way to calculate current audio pts and use it for
rtognimp
parents:
18150
diff
changeset
|
191 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
|
192 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
193 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
|
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 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
|
196 } |