mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
mpeg2enc: add disable-encode-retries property
MJPEG Tools may reencode pictures in a second pass to stick closer to the target bitrate. This can result in slower than real-time encoding for full HD content in certain situations, as entire GOPs need reencoding when the reference picture is reencoded. See https://sourceforge.net/p/mjpeg/bugs/141/ for background Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1491>
This commit is contained in:
parent
674ad01016
commit
93a54093ec
5 changed files with 54 additions and 2 deletions
|
@ -207739,6 +207739,7 @@
|
||||||
"description": "High-quality MPEG-1/2 video encoder",
|
"description": "High-quality MPEG-1/2 video encoder",
|
||||||
"hierarchy": [
|
"hierarchy": [
|
||||||
"GstMpeg2enc",
|
"GstMpeg2enc",
|
||||||
|
"GstVideoEncoder",
|
||||||
"GstElement",
|
"GstElement",
|
||||||
"GstObject",
|
"GstObject",
|
||||||
"GInitiallyUnowned",
|
"GInitiallyUnowned",
|
||||||
|
@ -207864,6 +207865,18 @@
|
||||||
"type": "gboolean",
|
"type": "gboolean",
|
||||||
"writable": true
|
"writable": true
|
||||||
},
|
},
|
||||||
|
"disable-encode-retries": {
|
||||||
|
"blurb": "Prevent the encoder from reencoding pictures in a second pass. This can vastly improve performance, but potentially affect reaching bitrate targets.",
|
||||||
|
"conditionally-available": false,
|
||||||
|
"construct": false,
|
||||||
|
"construct-only": false,
|
||||||
|
"controllable": false,
|
||||||
|
"default": "false",
|
||||||
|
"mutable": "null",
|
||||||
|
"readable": true,
|
||||||
|
"type": "gboolean",
|
||||||
|
"writable": true
|
||||||
|
},
|
||||||
"dualprime": {
|
"dualprime": {
|
||||||
"blurb": "Dual Prime Motion Estimation Mode for MPEG-2 I/P-frame only streams. Quite some players do not support this.",
|
"blurb": "Dual Prime Motion Estimation Mode for MPEG-2 I/P-frame only streams. Quite some players do not support this.",
|
||||||
"conditionally-available": false,
|
"conditionally-available": false,
|
||||||
|
|
|
@ -40,6 +40,14 @@
|
||||||
#include "gstmpeg2enc.hh"
|
#include "gstmpeg2enc.hh"
|
||||||
#include "gstmpeg2encoder.hh"
|
#include "gstmpeg2encoder.hh"
|
||||||
|
|
||||||
|
class GstOnTheFlyPass2 : public OnTheFlyPass2 {
|
||||||
|
public:
|
||||||
|
GstOnTheFlyPass2 (EncoderParams &encoder, gboolean disable_encode_retries): OnTheFlyPass2(encoder), disable_encode_retries(disable_encode_retries) {}
|
||||||
|
bool ReencodeRequired() const { return disable_encode_retries ? false : OnTheFlyPass2::ReencodeRequired(); }
|
||||||
|
private:
|
||||||
|
gboolean disable_encode_retries;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class init stuff.
|
* Class init stuff.
|
||||||
*/
|
*/
|
||||||
|
@ -52,6 +60,7 @@ MPEG2Encoder (*options)
|
||||||
caps = in_caps;
|
caps = in_caps;
|
||||||
gst_caps_ref (in_caps);
|
gst_caps_ref (in_caps);
|
||||||
init_done = FALSE;
|
init_done = FALSE;
|
||||||
|
disable_encode_retries = options->disable_encode_retries;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstMpeg2Encoder::~GstMpeg2Encoder ()
|
GstMpeg2Encoder::~GstMpeg2Encoder ()
|
||||||
|
@ -89,7 +98,7 @@ gboolean GstMpeg2Encoder::setup ()
|
||||||
/* encoding internals */
|
/* encoding internals */
|
||||||
quantizer = new Quantizer (parms);
|
quantizer = new Quantizer (parms);
|
||||||
pass1ratectl = new OnTheFlyPass1 (parms);
|
pass1ratectl = new OnTheFlyPass1 (parms);
|
||||||
pass2ratectl = new OnTheFlyPass2 (parms);
|
pass2ratectl = new GstOnTheFlyPass2 (parms, disable_encode_retries);
|
||||||
/* sequencer */
|
/* sequencer */
|
||||||
seqencoder = new SeqEncoder (parms, *reader, *quantizer,
|
seqencoder = new SeqEncoder (parms, *reader, *quantizer,
|
||||||
*writer, *pass1ratectl, *pass2ratectl);
|
*writer, *pass1ratectl, *pass2ratectl);
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
GstElement *element;
|
GstElement *element;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
gboolean init_done;
|
gboolean init_done;
|
||||||
|
gboolean disable_encode_retries;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __GST_MPEG2ENCODER_H__ */
|
#endif /* __GST_MPEG2ENCODER_H__ */
|
||||||
|
|
|
@ -70,7 +70,8 @@ enum
|
||||||
ARG_CORRECT_SVCD_HDS,
|
ARG_CORRECT_SVCD_HDS,
|
||||||
ARG_ALTSCAN_MPEG2,
|
ARG_ALTSCAN_MPEG2,
|
||||||
ARG_CONSTRAINTS,
|
ARG_CONSTRAINTS,
|
||||||
ARG_DUALPRIME_MPEG2
|
ARG_DUALPRIME_MPEG2,
|
||||||
|
ARG_DISABLE_ENCODE_RETRIES,
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,6 +303,7 @@ MPEG2EncOptions ()
|
||||||
|
|
||||||
/* set some default(s) not set in base class */
|
/* set some default(s) not set in base class */
|
||||||
bitrate = DEFAULT_BITRATE * 1000;
|
bitrate = DEFAULT_BITRATE * 1000;
|
||||||
|
disable_encode_retries = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -501,6 +503,25 @@ GstMpeg2EncOptions::initProperties (GObjectClass * klass)
|
||||||
"streams. Quite some players do not support this.",
|
"streams. Quite some players do not support this.",
|
||||||
FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mpeg2enc:disable-encode-retries:
|
||||||
|
*
|
||||||
|
* Prevent the encoder from reencoding pictures in a second pass.
|
||||||
|
*
|
||||||
|
* This can vastly improve performance, but potentially affect reaching
|
||||||
|
* bitrate targets.
|
||||||
|
*
|
||||||
|
* See https://sourceforge.net/p/mjpeg/bugs/141/ for some background.
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (klass, ARG_DISABLE_ENCODE_RETRIES,
|
||||||
|
g_param_spec_boolean ("disable-encode-retries", "Disable encode retries",
|
||||||
|
"Prevent the encoder from reencoding pictures in a second pass."
|
||||||
|
" This can vastly improve performance, but potentially affect reaching"
|
||||||
|
" bitrate targets.",
|
||||||
|
FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
|
|
||||||
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_ASPECT, (GstPluginAPIFlags) 0);
|
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_ASPECT, (GstPluginAPIFlags) 0);
|
||||||
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_FORMAT, (GstPluginAPIFlags) 0);
|
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_FORMAT, (GstPluginAPIFlags) 0);
|
||||||
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_FRAMERATE, (GstPluginAPIFlags) 0);
|
gst_type_mark_as_plugin_api (GST_TYPE_MPEG2ENC_FRAMERATE, (GstPluginAPIFlags) 0);
|
||||||
|
@ -633,6 +654,9 @@ GstMpeg2EncOptions::getProperty (guint prop_id, GValue * value)
|
||||||
case ARG_DUALPRIME_MPEG2:
|
case ARG_DUALPRIME_MPEG2:
|
||||||
g_value_set_boolean (value, hack_dualprime);
|
g_value_set_boolean (value, hack_dualprime);
|
||||||
break;
|
break;
|
||||||
|
case ARG_DISABLE_ENCODE_RETRIES:
|
||||||
|
g_value_set_boolean (value, disable_encode_retries);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -769,6 +793,9 @@ GstMpeg2EncOptions::setProperty (guint prop_id, const GValue * value)
|
||||||
case ARG_DUALPRIME_MPEG2:
|
case ARG_DUALPRIME_MPEG2:
|
||||||
hack_dualprime = g_value_get_boolean (value);
|
hack_dualprime = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_DISABLE_ENCODE_RETRIES:
|
||||||
|
disable_encode_retries = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
GValue *value);
|
GValue *value);
|
||||||
void setProperty (guint prop_id,
|
void setProperty (guint prop_id,
|
||||||
const GValue *value);
|
const GValue *value);
|
||||||
|
|
||||||
|
gboolean disable_encode_retries;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __GST_MPEG2ENCOPTIONS_H__ */
|
#endif /* __GST_MPEG2ENCOPTIONS_H__ */
|
||||||
|
|
Loading…
Reference in a new issue