libs: encoder: set context info profile by encoder
authorHe Junyan <junyan.he@hotmail.com>
Mon, 16 Dec 2019 15:19:46 +0000 (23:19 +0800)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sun, 29 Dec 2019 16:58:36 +0000 (17:58 +0100)
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>
gst-libs/gst/vaapi/gstvaapiencoder.c
gst-libs/gst/vaapi/gstvaapiencoder_h264.c
gst-libs/gst/vaapi/gstvaapiencoder_h265.c
gst-libs/gst/vaapi/gstvaapiencoder_jpeg.c
gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
gst-libs/gst/vaapi/gstvaapiencoder_vp8.c
gst-libs/gst/vaapi/gstvaapiencoder_vp9.c

index 3f0e9a7..ccd804d 100644 (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;
 }
index f3dcc3d..abff56a 100644 (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;
index 795075e..0c14422 100644 (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;
index 5691087..4c87a8a 100644 (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;
 }
 
index 0aca23b..58477d7 100644 (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;
 }
 
index b91fa43..ce88cfb 100644 (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;
 }
 
index 07c8154..9315e3d 100644 (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;