mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +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) {
|
switch (cip->usage) {
|
||||||
case GST_VAAPI_CONTEXT_USAGE_ENCODE:
|
case GST_VAAPI_CONTEXT_USAGE_ENCODE:
|
||||||
{
|
{
|
||||||
|
const GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
|
||||||
|
|
||||||
/* Rate control */
|
/* Rate control */
|
||||||
attrib->type = VAConfigAttribRateControl;
|
attrib->type = VAConfigAttribRateControl;
|
||||||
if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
|
if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
|
||||||
goto cleanup;
|
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) {
|
if ((value & va_rate_control) != va_rate_control) {
|
||||||
GST_ERROR ("unsupported %s rate control",
|
GST_ERROR ("unsupported %s rate control",
|
||||||
string_of_VARateControl (va_rate_control));
|
string_of_VARateControl (va_rate_control));
|
||||||
|
@ -234,6 +236,23 @@ cleanup:
|
||||||
return success;
|
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
|
static inline void
|
||||||
gst_vaapi_context_init (GstVaapiContext * context,
|
gst_vaapi_context_init (GstVaapiContext * context,
|
||||||
const GstVaapiContextInfo * cip)
|
const GstVaapiContextInfo * cip)
|
||||||
|
@ -323,12 +342,11 @@ gst_vaapi_context_reset (GstVaapiContext * context,
|
||||||
if (cip->usage != new_cip->usage) {
|
if (cip->usage != new_cip->usage) {
|
||||||
cip->usage = new_cip->usage;
|
cip->usage = new_cip->usage;
|
||||||
config_changed = TRUE;
|
config_changed = TRUE;
|
||||||
|
memcpy (&cip->config, &new_cip->config, sizeof (cip->config));
|
||||||
} else if (new_cip->usage == GST_VAAPI_CONTEXT_USAGE_ENCODE) {
|
} else if (new_cip->usage == GST_VAAPI_CONTEXT_USAGE_ENCODE) {
|
||||||
if (cip->rc_mode != new_cip->rc_mode) {
|
if (context_update_config_encoder (context, &new_cip->config.encoder))
|
||||||
cip->rc_mode = new_cip->rc_mode;
|
|
||||||
config_changed = TRUE;
|
config_changed = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (size_changed)
|
if (size_changed)
|
||||||
context_destroy_surfaces (context);
|
context_destroy_surfaces (context);
|
||||||
|
|
|
@ -37,6 +37,7 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_CONTEXT(obj) \
|
#define GST_VAAPI_CONTEXT(obj) \
|
||||||
((GstVaapiContext *) (obj))
|
((GstVaapiContext *) (obj))
|
||||||
|
|
||||||
|
typedef struct _GstVaapiConfigInfoEncoder GstVaapiConfigInfoEncoder;
|
||||||
typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
|
typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
|
||||||
typedef struct _GstVaapiContext GstVaapiContext;
|
typedef struct _GstVaapiContext GstVaapiContext;
|
||||||
typedef struct _GstVaapiContextClass GstVaapiContextClass;
|
typedef struct _GstVaapiContextClass GstVaapiContextClass;
|
||||||
|
@ -55,25 +56,35 @@ typedef enum {
|
||||||
GST_VAAPI_CONTEXT_USAGE_VPP,
|
GST_VAAPI_CONTEXT_USAGE_VPP,
|
||||||
} GstVaapiContextUsage;
|
} GstVaapiContextUsage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiConfigInfoEncoder:
|
||||||
|
* @rc_mode: rate-control mode (#GstVaapiRateControl).
|
||||||
|
*
|
||||||
|
* Extra configuration for encoding.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiConfigInfoEncoder
|
||||||
|
{
|
||||||
|
GstVaapiRateControl rc_mode;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstVaapiContextInfo:
|
* GstVaapiContextInfo:
|
||||||
*
|
*
|
||||||
* Structure holding VA context info like encoded size, decoder
|
* Structure holding VA context info like encoded size, decoder
|
||||||
* profile and entry-point to use, and maximum number of reference
|
* profile and entry-point to use, and maximum number of reference
|
||||||
* frames reported by the bitstream.
|
* 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
|
struct _GstVaapiContextInfo
|
||||||
{
|
{
|
||||||
GstVaapiContextUsage usage;
|
GstVaapiContextUsage usage;
|
||||||
GstVaapiProfile profile;
|
GstVaapiProfile profile;
|
||||||
GstVaapiEntrypoint entrypoint;
|
GstVaapiEntrypoint entrypoint;
|
||||||
GstVaapiRateControl rc_mode;
|
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
guint ref_frames;
|
guint ref_frames;
|
||||||
|
union _GstVaapiConfigInfo {
|
||||||
|
GstVaapiConfigInfoEncoder encoder;
|
||||||
|
} config;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -483,14 +483,17 @@ static void
|
||||||
set_context_info (GstVaapiEncoder * encoder)
|
set_context_info (GstVaapiEncoder * encoder)
|
||||||
{
|
{
|
||||||
GstVaapiContextInfo *const cip = &encoder->context_info;
|
GstVaapiContextInfo *const cip = &encoder->context_info;
|
||||||
|
GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
|
||||||
|
|
||||||
cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE;
|
cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE;
|
||||||
cip->profile = encoder->profile;
|
cip->profile = encoder->profile;
|
||||||
cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
|
cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
|
||||||
cip->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
|
|
||||||
cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
|
cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
|
||||||
cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
|
cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
|
||||||
cip->ref_frames = encoder->num_ref_frames;
|
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 */
|
/* Ensures the underlying VA context for encoding is created */
|
||||||
|
|
Loading…
Reference in a new issue