From c40b40b36f460bd30d60e8df65436b89875326b1 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Wed, 30 Nov 2016 18:11:30 +0200 Subject: [PATCH] x264enc: Add information for mixed mode https://bugzilla.gnome.org/show_bug.cgi?id=775411 --- ext/x264/gstx264enc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c index 0c84b41b..f5d8f9f6 100644 --- a/ext/x264/gstx264enc.c +++ b/ext/x264/gstx264enc.c @@ -1824,6 +1824,9 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder) if (GST_VIDEO_INFO_IS_INTERLACED (info)) { encoder->x264param.b_interlaced = TRUE; + if (GST_VIDEO_INFO_INTERLACE_MODE (info) == GST_VIDEO_INTERLACE_MODE_MIXED) { + encoder->x264param.b_pic_struct = TRUE; + } if (GST_VIDEO_INFO_FIELD_ORDER (info) == GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST) { encoder->x264param.b_tff = TRUE; @@ -2361,6 +2364,24 @@ gst_x264_enc_handle_frame (GstVideoEncoder * video_enc, pic_in.i_pts = frame->pts; pic_in.opaque = GINT_TO_POINTER (frame->system_frame_number); + if (GST_VIDEO_INFO_INTERLACE_MODE (info) == GST_VIDEO_INTERLACE_MODE_MIXED) { + if ((fdata->vframe.flags & GST_VIDEO_FRAME_FLAG_INTERLACED) == 0) { + pic_in.i_pic_struct = PIC_STRUCT_PROGRESSIVE; + } else if ((fdata->vframe.flags & GST_VIDEO_FRAME_FLAG_RFF) != 0) { + if ((fdata->vframe.flags & GST_VIDEO_FRAME_FLAG_TFF) != 0) { + pic_in.i_pic_struct = PIC_STRUCT_TOP_BOTTOM_TOP; + } else { + pic_in.i_pic_struct = PIC_STRUCT_BOTTOM_TOP_BOTTOM; + } + } else { + if ((fdata->vframe.flags & GST_VIDEO_FRAME_FLAG_TFF) != 0) { + pic_in.i_pic_struct = PIC_STRUCT_TOP_BOTTOM; + } else { + pic_in.i_pic_struct = PIC_STRUCT_BOTTOM_TOP; + } + } + } + ret = gst_x264_enc_encode_frame (encoder, &pic_in, frame, &i_nal, TRUE); /* input buffer is released later on */ -- 2.34.1