mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-08 00:59:48 +00:00
msdkenc: add need_reconfig virtual method
need_reconfig is added to allow sub class requires a reconfig when the input frame or the MetaData (e.g. GstVideoRegionOfInterestMeta) attached to the input frame is changed.
This commit is contained in:
parent
6e73e762c5
commit
0e2fc39f24
2 changed files with 12 additions and 7 deletions
|
@ -1374,22 +1374,17 @@ static GstFlowReturn
|
|||
gst_msdkenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
|
||||
{
|
||||
GstMsdkEnc *thiz = GST_MSDKENC (encoder);
|
||||
GstMsdkEncClass *klass = GST_MSDKENC_GET_CLASS (thiz);
|
||||
GstVideoInfo *info = &thiz->input_state->info;
|
||||
FrameData *fdata;
|
||||
MsdkSurface *surface;
|
||||
|
||||
if (thiz->reconfig) {
|
||||
mfxInfoMFX *mfx = NULL;
|
||||
|
||||
GST_INFO_OBJECT (encoder, "Adjust encoder bitrate before current frame");
|
||||
if (thiz->reconfig || klass->need_reconfig (thiz, frame)) {
|
||||
gst_msdkenc_flush_frames (thiz, FALSE);
|
||||
gst_msdkenc_close_encoder (thiz);
|
||||
|
||||
// This will reinitialized the encoder but keep same input format.
|
||||
gst_msdkenc_set_format (encoder, NULL);
|
||||
|
||||
mfx = &thiz->param.mfx;
|
||||
GST_INFO_OBJECT (encoder, "New target bitrate: %u", mfx->TargetKbps);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (thiz->context == NULL))
|
||||
|
@ -1682,6 +1677,12 @@ gst_msdkenc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_msdkenc_need_reconfig (GstMsdkEnc * encoder, GstVideoCodecFrame * frame)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_msdkenc_class_init (GstMsdkEncClass * klass)
|
||||
{
|
||||
|
@ -1694,6 +1695,7 @@ gst_msdkenc_class_init (GstMsdkEncClass * klass)
|
|||
gstencoder_class = GST_VIDEO_ENCODER_CLASS (klass);
|
||||
|
||||
klass->need_conversion = gst_msdkenc_need_conversion;
|
||||
klass->need_reconfig = gst_msdkenc_need_reconfig;
|
||||
|
||||
gobject_class->finalize = gst_msdkenc_finalize;
|
||||
|
||||
|
|
|
@ -174,6 +174,9 @@ struct _GstMsdkEncClass
|
|||
*/
|
||||
gboolean (*need_conversion) (GstMsdkEnc * encoder, GstVideoInfo * info,
|
||||
GstVideoFormat * out_format);
|
||||
|
||||
/* Return TRUE if sub class requires a recofnig */
|
||||
gboolean (*need_reconfig) (GstMsdkEnc * encoder, GstVideoCodecFrame * frame);
|
||||
};
|
||||
|
||||
struct _MsdkEncTask
|
||||
|
|
Loading…
Reference in a new issue