diff libmpcodecs/ad_faad.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 934380353fd6
children 82263a36cfa4
line wrap: on
line diff
--- a/libmpcodecs/ad_faad.c	Mon Apr 24 10:36:29 2006 +0000
+++ b/libmpcodecs/ad_faad.c	Mon Apr 24 10:58:40 2006 +0000
@@ -253,8 +253,13 @@
   } else {
    // packetized (.mp4) aac stream:
     unsigned char* bufptr=NULL;
-    int buflen=ds_get_packet(sh->ds, &bufptr);
+    double pts;
+    int buflen=ds_get_packet_pts(sh->ds, &bufptr, &pts);
     if(buflen<=0) break;
+    if (pts != MP_NOPTS_VALUE) {
+	sh->pts = pts;
+	sh->pts_bytes = 0;
+    }
     faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr, buflen);
   }
   //for (j=0;j<faac_finfo.channels;j++) printf("%d:%d\n", j, faac_finfo.channel_position[j]);
@@ -271,6 +276,7 @@
       memcpy(buf+len,faac_sample_buffer, sh->samplesize*faac_finfo.samples);
       last_dec_len = sh->samplesize*faac_finfo.samples;
       len += last_dec_len;
+      sh->pts_bytes += last_dec_len;
     //printf("FAAD: buffer: %d bytes  consumed: %d \n", k, faac_finfo.bytesconsumed);
     }
   }