Mercurial > mplayer.hg
diff libmpcodecs/ad_ffmpeg.c @ 30088:4977e04f3a18
Add support for parsing audio streams (though should be easy to extend to video)
via libavcodec.
Parsing can be done at the demuxer stage (currently disabled) or at the decoder
(ad_ffmpeg, enabled).
Should allow using the libavcodec AAC, DTS, ... decoders independent of container
format.
| author | reimar |
|---|---|
| date | Sun, 27 Dec 2009 15:28:01 +0000 |
| parents | 731ddb53dc92 |
| children | c6c40936049c |
line wrap: on
line diff
--- a/libmpcodecs/ad_ffmpeg.c Sun Dec 27 14:42:37 2009 +0000 +++ b/libmpcodecs/ad_ffmpeg.c Sun Dec 27 15:28:01 2009 +0000 @@ -167,7 +167,17 @@ int len2=maxlen; double pts; int x=ds_get_packet_pts(sh_audio->ds,&start, &pts); - if(x<=0) break; // error + if(x<=0) { + start = NULL; + x = 0; + ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0); + if (x <= 0) + break; // error + } else { + int in_size = x; + int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0); + sh_audio->ds->buffer_pos -= in_size - consumed; + } av_init_packet(&pkt); pkt.data = start; pkt.size = x; @@ -178,7 +188,8 @@ y=avcodec_decode_audio3(sh_audio->context,(int16_t*)buf,&len2,&pkt); //printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout); if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } - if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) + if(!sh_audio->needs_parsing && y<x) + sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) if(len2>0){ if (((AVCodecContext *)sh_audio->context)->channels >= 5) { int samplesize = av_get_bits_per_sample_format(((AVCodecContext *)
