From: Seungha Yang Date: Tue, 18 Sep 2018 12:43:14 +0000 (+0900) Subject: x264enc: Avoid format decision per frame X-Git-Tag: 1.19.3~505^2~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e639433617c4e3969ed27b600f0508e4d7252b8;p=platform%2Fupstream%2Fgstreamer.git x264enc: Avoid format decision per frame Avoid switch/case per frame for format decision and detect the format only if where it could be changed. Note that, whenever encoder->input_state is changed, gst_x264_enc_init_encoder() is called. https://bugzilla.gnome.org/show_bug.cgi?id=797164 --- diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c index 9e7986a..70a0277 100644 --- a/ext/x264/gstx264enc.c +++ b/ext/x264/gstx264enc.c @@ -1582,7 +1582,8 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder) encoder->x264param.i_bitdepth = GST_VIDEO_INFO_COMP_DEPTH (info, 0); #endif encoder->x264param.i_csp = - gst_x264_enc_gst_to_x264_video_format (info->finfo->format, NULL); + gst_x264_enc_gst_to_x264_video_format (info->finfo->format, + &encoder->x264_nplanes); if (info->fps_d == 0 || info->fps_n == 0) { /* No FPS so must use VFR * This raises latency apparently see http://mewiki.project357.com/wiki/X264_Encoding_Suggestions */ @@ -2378,7 +2379,7 @@ gst_x264_enc_handle_frame (GstVideoEncoder * video_enc, x264_picture_t pic_in; gint i_nal, i; FrameData *fdata; - gint nplanes = 0; + gint nplanes = encoder->x264_nplanes; if (G_UNLIKELY (encoder->x264enc == NULL)) goto not_inited; @@ -2393,8 +2394,7 @@ gst_x264_enc_handle_frame (GstVideoEncoder * video_enc, if (!fdata) goto invalid_frame; - pic_in.img.i_csp = - gst_x264_enc_gst_to_x264_video_format (info->finfo->format, &nplanes); + pic_in.img.i_csp = encoder->x264param.i_csp; pic_in.img.i_plane = nplanes; for (i = 0; i < nplanes; i++) { pic_in.img.plane[i] = GST_VIDEO_FRAME_COMP_DATA (&fdata->vframe, i); diff --git a/ext/x264/gstx264enc.h b/ext/x264/gstx264enc.h index e8291a3..c7de48c 100644 --- a/ext/x264/gstx264enc.h +++ b/ext/x264/gstx264enc.h @@ -123,6 +123,9 @@ struct _GstX264Enc const gchar *peer_profile; gboolean peer_intra_profile; gint peer_level_idc; + + /* cached values to set x264_picture_t */ + gint x264_nplanes; }; struct _GstX264EncClass