]> granicus.if.org Git - handbrake/commitdiff
merge fix for incorrect audio silence insertion to bugfix branch
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 1 May 2012 10:08:03 +0000 (10:08 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 1 May 2012 10:08:03 +0000 (10:08 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/0.9.x@4619 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/deca52.c
libhb/decavcodec.c
libhb/decdca.c
libhb/declpcm.c
libhb/internal.h
libhb/sync.c

index a8d537d524b944bfab3474f976a2482d2de0c1be..8a8afa83106f5b2ebcf0d8a6cf72c6cd9f98e851 100644 (file)
@@ -265,6 +265,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
         buf = hb_buffer_init( size );
         memcpy( buf->data, pv->frame, size );
         buf->start = pts;
+        buf->duration = frame_dur;
         pts += frame_dur;
         buf->stop  = pts;
         pv->next_expected_pts = pts;
@@ -289,6 +290,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
     /* 6 blocks per frame, 256 samples per block, channelsused channels */
     buf        = hb_buffer_init( 6 * 256 * pv->out_discrete_channels * sizeof( float ) );
     buf->start = pts;
+    buf->duration = frame_dur;
     pts += frame_dur;
     buf->stop  = pts;
     pv->next_expected_pts = pts;
index 80c68fd4d346f0536f8c0a1e64d71f3d23b40cf7..f0d3756853a32f1700d80ddf9922797dd4590378 100644 (file)
@@ -1449,7 +1449,8 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat
         {
             int isamp = av_get_bytes_per_sample( context->sample_fmt );
             nsamples = out_size / isamp;
-            double pts_next = pv->pts_next + nsamples * pv->duration;
+            double duration = nsamples * pv->duration;
+            double pts_next = pv->pts_next + duration;
 
             // DTS-HD can be passed through to mkv
             if( audio->config.out.codec & HB_ACODEC_PASS_FLAG )
@@ -1462,6 +1463,7 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat
                 buf = hb_buffer_init( avp.size );
                 memcpy( buf->data, avp.data, avp.size );
                 buf->start = pv->pts_next;
+                buf->duration = duration;
                 buf->stop  = pts_next;
                 hb_list_add( pv->list, buf );
                 pv->pts_next = pts_next;
@@ -1502,6 +1504,7 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat
             hb_buffer_t * buf;
             buf = downmixAudio( audio, pv, buffer, context->channels, nsamples );
             buf->start = pv->pts_next;
+            buf->duration = duration;
             buf->stop = pts_next;
             hb_list_add( pv->list, buf );
 
index 4f5ee3929238034b76fb2025203a3b1ee7b0e31b..ade6e8951b2fb4e798a0bdee26289f77c77ad6b1 100644 (file)
@@ -236,6 +236,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
         buf = hb_buffer_init( pv->size );
         memcpy( buf->data, pv->frame, pv->size );
         buf->start = pts;
+        buf->duration = frame_dur;
         pv->next_pts = pts + frame_dur;
         buf->stop  = pv->next_pts;
         pv->sync = 0;
@@ -250,10 +251,12 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
 
     /* num_blocks blocks per frame, 256 samples per block, channelsused channels */
     int nsamp = num_blocks * 256;
+    frame_dur = (double)nsamp / (double)pv->rate * 90000.;
     buf = hb_buffer_init( nsamp * pv->out_discrete_channels * sizeof( float ) );
 
     buf->start = pts;
-    pv->next_pts = pts + (double)nsamp / (double)pv->rate * 90000.;
+    buf->duration = frame_dur;
+    pv->next_pts = pts + frame_dur;
     buf->stop  = pv->next_pts;
 
     for( i = 0; i < num_blocks; i++ )
index a47e0974ca740807e76ad3623ea11aac17ff5643..c056d416a1d1b6f842f0229ef4234b8338505971 100644 (file)
@@ -219,6 +219,7 @@ static hb_buffer_t *Decode( hb_work_object_t *w )
     out = hb_buffer_init( pv->samples * sizeof( float ) );
 
     out->start  = pv->next_pts;
+    out->duration = pv->duration;
     pv->next_pts += pv->duration;
     out->stop = pv->next_pts;
 
index 00a7b3eb95b391cf6ddf7f20f82a4389898f7130..75635d73cb536e03818a2bb0ba156869783d49e5 100644 (file)
@@ -70,6 +70,7 @@ struct hb_buffer_s
 
     int           id;           // ID of the track that the packet comes from
     int64_t       start;        // Video and subtitle packets: start time of frame/subtitle
+    double        duration;     // Actual duration, may be fractional ticks
     int64_t       stop;         // Video and subtitle packets: stop time of frame/subtitle
     int64_t       pcr;
     uint8_t       discontinuity;
index 97f4c1d1ef9a90465871646dd4b91ba7ff0b590b..dad2623c905a238d96dc631e0d5cf4d790d52f58 100644 (file)
@@ -1236,7 +1236,15 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
                                        hb_sync_audio_t *sync )
 {
     int64_t start = (int64_t)sync->next_start;
-    double duration = buf->stop - buf->start;
+
+    // Can't count of buf->s.stop - buf->s.start for accurate duration
+    // due to integer rounding, so use buf->s.duration when it is set
+    // (which should be always if I didn't miss anything)
+    double duration;
+    if ( buf->duration > 0 )
+        duration = buf->duration;
+    else
+        duration = buf->stop - buf->start;
 
     if ( !( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) )
     {