summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha.yang@navercorp.com>2018-09-18 21:43:14 +0900
committerTim-Philipp Müller <tim@centricular.com>2018-09-22 12:42:34 +0100
commit7e639433617c4e3969ed27b600f0508e4d7252b8 (patch)
treee650b61ddc0c979745e8b69eba28ae9a088c4c97
parent6c37b359eefebe634e7fb467173a6cac2407e2cc (diff)
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
-rw-r--r--ext/x264/gstx264enc.c8
-rw-r--r--ext/x264/gstx264enc.h3
2 files changed, 7 insertions, 4 deletions
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index 9e7986ab..70a02777 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 e8291a31..c7de48cf 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