summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@hotmail.com>2019-12-16 23:19:46 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-12-29 17:58:36 +0100
commitb50f06309afc11da783b977589ab4a708ac87822 (patch)
treea251e9818ac661c68096724c7a4bd7e2cea297bf
parent4f43d28bebf6803e1bf124c1f1aeef421ac2ffb2 (diff)
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>
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c26
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_h264.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_h265.c1
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c3
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c3
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_vp8.c3
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_vp9.c1
7 files changed, 23 insertions, 16 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 3f0e9a7c..ccd804d2 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -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;
}
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index f3dcc3df..abff56a8 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -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;
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
index 795075e3..0c14422a 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ -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;
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c b/gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c
index 56910877..4c87a8aa 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c
@@ -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;
}
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
index 0aca23ba..58477d7e 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
@@ -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;
}
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c
index b91fa435..ce88cfb6 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c
@@ -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;
}
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c
index 07c8154b..9315e3db 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c
@@ -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;