]> granicus.if.org Git - handbrake/commitdiff
QSV: enc_qsv: write initial PTS-DTS delay. Some muxers (e.g. MP4) expect this value...
authorRodeo <tdskywalker@gmail.com>
Sun, 30 Jun 2013 15:38:59 +0000 (15:38 +0000)
committerRodeo <tdskywalker@gmail.com>
Sun, 30 Jun 2013 15:38:59 +0000 (15:38 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5619 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/enc_qsv.c

index 20cbb82c604f1f09e45c5ead3f7bb40766933b70..9f54f15f070371d1e758577cafe11702f4bd5dbb 100644 (file)
@@ -1049,6 +1049,26 @@ int encqsvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                         buf->s.renderOffset = hb_qsv_pop_next_dts(pv->list_dts);
                     }
                 }
+
+                /*
+                 * In the MP4 container, DT(0) = STTS(0) = 0.
+                 *
+                 * Which gives us:
+                 * CT(0) = CTTS(0) + STTS(0) = CTTS(0) = PTS(0) - DTS(0)
+                 * When DTS(0) < PTS(0), we then have:
+                 * CT(0) > 0 for video, but not audio (breaks A/V sync).
+                 *
+                 * This is typically solved by writing an edit list shifting
+                 * video samples by the initial delay, PTS(0) - DTS(0).
+                 *
+                 * See:
+                 * ISO/IEC 14496-12:2008(E), ISO base media file format
+                 *  - 8.6.1.2 Decoding Time to Sample Box
+                 */
+                if (w->config->h264.init_delay == 0 && buf->s.renderOffset < 0)
+                {
+                    w->config->h264.init_delay = -buf->s.renderOffset;
+                }
             }
 
                 if(pv->qsv_config.gop_ref_dist > 1)