From 3cc61f98b1f061cde714a22dab0d211de740aea6 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 22 Feb 2018 12:32:20 -0900 Subject: [PATCH] msdk: enc: Support force-key-unit events https://bugzilla.gnome.org/show_bug.cgi?id=791479 --- sys/msdk/gstmsdkenc.c | 11 ++++++++++- sys/msdk/gstmsdkenc.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c index 9ff1db5a61..413660ce62 100644 --- a/sys/msdk/gstmsdkenc.c +++ b/sys/msdk/gstmsdkenc.c @@ -727,7 +727,15 @@ gst_msdkenc_encode_frame (GstMsdkEnc * thiz, mfxFrameSurface1 * surface, task = gst_msdkenc_get_free_task (thiz); for (;;) { - status = MFXVideoENCODE_EncodeFrameAsync (session, NULL, surface, + /* Force key-frame if needed */ + if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (input_frame)) + thiz->enc_cntrl.FrameType = + MFX_FRAMETYPE_I | MFX_FRAMETYPE_IDR | MFX_FRAMETYPE_REF; + else + thiz->enc_cntrl.FrameType = MFX_FRAMETYPE_UNKNOWN; + + status = + MFXVideoENCODE_EncodeFrameAsync (session, &thiz->enc_cntrl, surface, &task->output_bitstream, &task->sync_point); if (status != MFX_WRN_DEVICE_BUSY) break; @@ -1384,6 +1392,7 @@ gst_msdkenc_init (GstMsdkEnc * thiz) thiz->enable_extopt3 = FALSE; memset (&thiz->option2, 0, sizeof (thiz->option2)); memset (&thiz->option3, 0, sizeof (thiz->option3)); + memset (&thiz->enc_cntrl, 0, sizeof (thiz->enc_cntrl)); } /* gst_msdkenc_set_common_property: diff --git a/sys/msdk/gstmsdkenc.h b/sys/msdk/gstmsdkenc.h index 02590d3e4c..db333bd0d7 100644 --- a/sys/msdk/gstmsdkenc.h +++ b/sys/msdk/gstmsdkenc.h @@ -120,6 +120,9 @@ struct _GstMsdkEnc mfxExtCodingOption3 option3; gboolean enable_extopt3; + /* parameters for per-frame based encoding control */ + mfxEncodeCtrl enc_cntrl; + GstBufferPool *msdk_pool; GstBufferPool *msdk_converted_pool; GstVideoInfo aligned_info;