libs: encoder: set context info profile by encoder

Instead of init_context_info() setting the passed profile, it is
assumed that it has to be set by each encoder.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
This commit is contained in:
He Junyan 2019-12-16 23:19:46 +08:00 committed by Víctor Manuel Jáquez Leal
parent 4f43d28beb
commit b50f06309a
7 changed files with 23 additions and 16 deletions

View file

@ -713,21 +713,9 @@ get_default_chroma_type (GstVaapiEncoder * encoder,
}
static void
init_context_info (GstVaapiEncoder * encoder, GstVaapiContextInfo * cip,
GstVaapiProfile profile)
init_context_info (GstVaapiEncoder * encoder, GstVaapiContextInfo * cip)
{
const GstVaapiEncoderClassData *const cdata =
GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data;
cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE;
cip->profile = profile;
if (cdata->codec == GST_VAAPI_CODEC_JPEG) {
cip->entrypoint = GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE;
} else {
if (cip->entrypoint != GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP &&
cip->entrypoint != GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI)
cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
}
cip->chroma_type = get_default_chroma_type (encoder, cip);
cip->width = 0;
cip->height = 0;
@ -744,8 +732,10 @@ set_context_info (GstVaapiEncoder * encoder)
GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder));
guint fei_function = config->fei_function;
init_context_info (encoder, cip, get_profile (encoder));
g_assert (cip->profile != GST_VAAPI_PROFILE_UNKNOWN);
g_assert (cip->entrypoint != GST_VAAPI_ENTRYPOINT_INVALID);
init_context_info (encoder, cip);
cip->chroma_type = gst_vaapi_video_format_get_chroma_type (format);
cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
@ -1483,6 +1473,8 @@ gst_vaapi_encoder_class_init (GstVaapiEncoderClass * klass)
static GstVaapiContext *
create_test_context_config (GstVaapiEncoder * encoder, GstVaapiProfile profile)
{
const GstVaapiEncoderClassData *const cdata =
GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data;
GstVaapiContextInfo cip = { 0, };
GstVaapiContext *ctxt;
@ -1493,7 +1485,11 @@ create_test_context_config (GstVaapiEncoder * encoder, GstVaapiProfile profile)
if (profile == GST_VAAPI_PROFILE_UNKNOWN)
profile = get_profile (encoder);
init_context_info (encoder, &cip, profile);
cip.profile = profile;
cip.entrypoint = (cdata->codec == GST_VAAPI_CODEC_JPEG) ?
GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE : GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
init_context_info (encoder, &cip);
ctxt = gst_vaapi_context_new (encoder->display, &cip);
return ctxt;
}

View file

@ -3346,7 +3346,7 @@ set_context_info (GstVaapiEncoder * base_encoder)
GST_VAAPI_ENCODER_H264_COMPLIANCE_MODE_RESTRICT_CODED_BUFFER_ALLOC)
base_encoder->codedbuf_size /= encoder->min_cr;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = encoder->entrypoint;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;

View file

@ -2540,6 +2540,7 @@ set_context_info (GstVaapiEncoder * base_encoder)
base_encoder->codedbuf_size += GST_ROUND_UP_16 (vip->width) *
GST_ROUND_UP_16 (vip->height) * 3 / 2;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = encoder->entrypoint;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;

View file

@ -197,6 +197,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
base_encoder->codedbuf_size += MAX_APP_HDR_SIZE + MAX_FRAME_HDR_SIZE +
MAX_QUANT_TABLE_SIZE + MAX_HUFFMAN_TABLE_SIZE + MAX_SCAN_HDR_SIZE;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}

View file

@ -689,6 +689,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
base_encoder->codedbuf_size += (GST_ROUND_UP_16 (vip->height) / 16) *
MAX_SLICE_HDR_SIZE;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}

View file

@ -173,6 +173,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
MAX_TOKEN_PROB_UPDATE_SIZE + MAX_MV_PROBE_UPDATE_SIZE +
MAX_REST_OF_FRAME_HDR_SIZE;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}

View file

@ -219,6 +219,7 @@ set_context_info (GstVaapiEncoder * base_encoder)
base_encoder->codedbuf_size = GST_ROUND_UP_16 (vip->width) *
GST_ROUND_UP_16 (vip->height) * 3 / 2;
base_encoder->context_info.profile = base_encoder->profile;
base_encoder->context_info.entrypoint = encoder->entrypoint;
return GST_VAAPI_ENCODER_STATUS_SUCCESS;