mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
context: move rate-control mode to encoder specific config.
Move usage-specific config out of the common GstVaapiContextInfo. Create a specialized config for encoding and move rate-control mode to there.
This commit is contained in:
parent
0eb4070977
commit
14ad694fdc
3 changed files with 41 additions and 9 deletions
|
@ -189,12 +189,14 @@ context_create (GstVaapiContext * context)
|
|||
switch (cip->usage) {
|
||||
case GST_VAAPI_CONTEXT_USAGE_ENCODE:
|
||||
{
|
||||
const GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
|
||||
|
||||
/* Rate control */
|
||||
attrib->type = VAConfigAttribRateControl;
|
||||
if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
|
||||
goto cleanup;
|
||||
|
||||
va_rate_control = from_GstVaapiRateControl (cip->rc_mode);
|
||||
va_rate_control = from_GstVaapiRateControl (config->rc_mode);
|
||||
if ((value & va_rate_control) != va_rate_control) {
|
||||
GST_ERROR ("unsupported %s rate control",
|
||||
string_of_VARateControl (va_rate_control));
|
||||
|
@ -234,6 +236,23 @@ cleanup:
|
|||
return success;
|
||||
}
|
||||
|
||||
/** Updates config for encoding. Returns %TRUE if config changed */
|
||||
static gboolean
|
||||
context_update_config_encoder (GstVaapiContext * context,
|
||||
const GstVaapiConfigInfoEncoder * new_config)
|
||||
{
|
||||
GstVaapiConfigInfoEncoder *const config = &context->info.config.encoder;
|
||||
gboolean config_changed = FALSE;
|
||||
|
||||
g_assert (context->info.usage == GST_VAAPI_CONTEXT_USAGE_ENCODE);
|
||||
|
||||
if (config->rc_mode != new_config->rc_mode) {
|
||||
config->rc_mode = new_config->rc_mode;
|
||||
config_changed = TRUE;
|
||||
}
|
||||
return config_changed;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_vaapi_context_init (GstVaapiContext * context,
|
||||
const GstVaapiContextInfo * cip)
|
||||
|
@ -323,12 +342,11 @@ gst_vaapi_context_reset (GstVaapiContext * context,
|
|||
if (cip->usage != new_cip->usage) {
|
||||
cip->usage = new_cip->usage;
|
||||
config_changed = TRUE;
|
||||
memcpy (&cip->config, &new_cip->config, sizeof (cip->config));
|
||||
} else if (new_cip->usage == GST_VAAPI_CONTEXT_USAGE_ENCODE) {
|
||||
if (cip->rc_mode != new_cip->rc_mode) {
|
||||
cip->rc_mode = new_cip->rc_mode;
|
||||
if (context_update_config_encoder (context, &new_cip->config.encoder))
|
||||
config_changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (size_changed)
|
||||
context_destroy_surfaces (context);
|
||||
|
|
|
@ -37,6 +37,7 @@ G_BEGIN_DECLS
|
|||
#define GST_VAAPI_CONTEXT(obj) \
|
||||
((GstVaapiContext *) (obj))
|
||||
|
||||
typedef struct _GstVaapiConfigInfoEncoder GstVaapiConfigInfoEncoder;
|
||||
typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
|
||||
typedef struct _GstVaapiContext GstVaapiContext;
|
||||
typedef struct _GstVaapiContextClass GstVaapiContextClass;
|
||||
|
@ -55,25 +56,35 @@ typedef enum {
|
|||
GST_VAAPI_CONTEXT_USAGE_VPP,
|
||||
} GstVaapiContextUsage;
|
||||
|
||||
/**
|
||||
* GstVaapiConfigInfoEncoder:
|
||||
* @rc_mode: rate-control mode (#GstVaapiRateControl).
|
||||
*
|
||||
* Extra configuration for encoding.
|
||||
*/
|
||||
struct _GstVaapiConfigInfoEncoder
|
||||
{
|
||||
GstVaapiRateControl rc_mode;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVaapiContextInfo:
|
||||
*
|
||||
* Structure holding VA context info like encoded size, decoder
|
||||
* profile and entry-point to use, and maximum number of reference
|
||||
* frames reported by the bitstream.
|
||||
*
|
||||
* Note: @rc_mode is only valid for VA context used for encoding,
|
||||
* i.e. if @entrypoint is set to @GST_VAAPI_ENTRYPOINT_SLICE_ENCODE.
|
||||
*/
|
||||
struct _GstVaapiContextInfo
|
||||
{
|
||||
GstVaapiContextUsage usage;
|
||||
GstVaapiProfile profile;
|
||||
GstVaapiEntrypoint entrypoint;
|
||||
GstVaapiRateControl rc_mode;
|
||||
guint width;
|
||||
guint height;
|
||||
guint ref_frames;
|
||||
union _GstVaapiConfigInfo {
|
||||
GstVaapiConfigInfoEncoder encoder;
|
||||
} config;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -483,14 +483,17 @@ static void
|
|||
set_context_info (GstVaapiEncoder * encoder)
|
||||
{
|
||||
GstVaapiContextInfo *const cip = &encoder->context_info;
|
||||
GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
|
||||
|
||||
cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE;
|
||||
cip->profile = encoder->profile;
|
||||
cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
|
||||
cip->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
|
||||
cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
|
||||
cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
|
||||
cip->ref_frames = encoder->num_ref_frames;
|
||||
|
||||
memset (config, 0, sizeof (*config));
|
||||
config->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
|
||||
}
|
||||
|
||||
/* Ensures the underlying VA context for encoding is created */
|
||||
|
|
Loading…
Reference in a new issue