comparison libmpcodecs/ad_ffmpeg.c @ 18242:caac2ca98168

4 - Implement a better way to calculate current audio pts and use it for audio decoded with ad_libvorbis, ad_ffmpeg and ad_faad. Patch by Uoti Urpala
author rtognimp
date Mon, 24 Apr 2006 10:58:40 +0000
parents 710d4bc5f8c9
children 5d9f47834495
comparison
equal deleted inserted replaced
18241:b19dada1aeeb 18242:caac2ca98168
147 { 147 {
148 unsigned char *start=NULL; 148 unsigned char *start=NULL;
149 int y,len=-1; 149 int y,len=-1;
150 while(len<minlen){ 150 while(len<minlen){
151 int len2=0; 151 int len2=0;
152 int x=ds_get_packet(sh_audio->ds,&start); 152 double pts;
153 int x=ds_get_packet_pts(sh_audio->ds,&start, &pts);
153 if(x<=0) break; // error 154 if(x<=0) break; // error
155 if (pts != MP_NOPTS_VALUE) {
156 sh_audio->pts = pts;
157 sh_audio->pts_bytes = 0;
158 }
154 y=avcodec_decode_audio(sh_audio->context,(int16_t*)buf,&len2,start,x); 159 y=avcodec_decode_audio(sh_audio->context,(int16_t*)buf,&len2,start,x);
155 //printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout); 160 //printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
156 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } 161 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
157 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) 162 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
158 if(len2>0){ 163 if(len2>0){
159 //len=len2;break; 164 //len=len2;break;
160 if(len<0) len=len2; else len+=len2; 165 if(len<0) len=len2; else len+=len2;
161 buf+=len2; 166 buf+=len2;
167 sh_audio->pts_bytes += len2;
162 } 168 }
163 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2); 169 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2);
164 } 170 }
165 return len; 171 return len;
166 } 172 }