summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatej Knopp <matej.knopp@gmail.com>2014-11-26 22:15:43 +0100
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2015-06-11 10:29:25 -0400
commit43d6ca85a0e802c8a92e8116ee69c897e46c6aee (patch)
treec3744797a477bf705fb911dacd394e3b9a1d6b3d
parent6d0ee6c7820edba169d41119fa8b4eca1b4c3629 (diff)
x264enc: Use gst_video_encoder_set_min_pts
This method replace the manual adjustment of PTS and DTS to avoid negative DTS issues. Using this method will also update the segment so we don't loos sync. https://bugzilla.gnome.org/show_bug.cgi?id=740575
-rw-r--r--ext/x264/gstx264enc.c17
-rw-r--r--ext/x264/gstx264enc.h1
2 files changed, 6 insertions, 12 deletions
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index d619b8e5..7d5e2b42 100644
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
@@ -1164,6 +1164,10 @@ gst_x264_enc_start (GstVideoEncoder * encoder)
x264enc->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
+ /* make sure that we have enough time for first DTS,
+ this is probably overkill for most streams */
+ gst_video_encoder_set_min_pts (encoder, GST_SECOND * 60 * 60 * 1000);
+
return TRUE;
}
@@ -1539,8 +1543,6 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
encoder->x264param.i_frame_packing);
encoder->reconfig = FALSE;
- /* good start, will be corrected if needed */
- encoder->ts_offset = 0;
GST_OBJECT_UNLOCK (encoder);
@@ -2186,15 +2188,8 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
/* we want to know if x264 is messing around with this */
g_assert (frame->pts == pic_out.i_pts);
- /* As upstream often starts with PTS set to zero, in presence of b-frames,
- * x264 will have to use negative DTS. As this is not supported by
- * GStreamer, we shift both DTS and PTS forward to make it positive. It's
- * important to shift both in order to ensure PTS remains >= to DTS. */
- if (pic_out.i_dts < encoder->ts_offset)
- encoder->ts_offset = pic_out.i_dts;
-
- frame->dts = pic_out.i_dts - encoder->ts_offset;
- frame->pts = pic_out.i_pts - encoder->ts_offset;
+ frame->dts = pic_out.i_dts;
+ frame->pts = pic_out.i_pts;
if (pic_out.b_keyframe) {
GST_DEBUG_OBJECT (encoder, "Output keyframe");
diff --git a/ext/x264/gstx264enc.h b/ext/x264/gstx264enc.h
index b7179c85..d1135d92 100644
--- a/ext/x264/gstx264enc.h
+++ b/ext/x264/gstx264enc.h
@@ -51,7 +51,6 @@ struct _GstX264Enc
x264_t *x264enc;
x264_param_t x264param;
gint current_byte_stream;
- gint64 ts_offset;
/* List of frame/buffer mapping structs for
* pending frames */