From 4f43d28bebf6803e1bf124c1f1aeef421ac2ffb2 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 27 Dec 2019 18:49:02 +0100 Subject: libs: context: add invalid entrypoint symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The symbol GST_VAAPI_ENTRYPOINT_INVALID is just a representation of zero, which was already used as an invalid value tacitly. This patch only makes it explicit. Signed-off-by: Víctor Manuel Jáquez Leal --- gst-libs/gst/vaapi/gstvaapicontext.c | 13 ++++++++++--- gst-libs/gst/vaapi/gstvaapiprofile.h | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c index b26bb52f..7c07cce1 100644 --- a/gst-libs/gst/vaapi/gstvaapicontext.c +++ b/gst-libs/gst/vaapi/gstvaapicontext.c @@ -221,7 +221,8 @@ config_create (GstVaapiContext * context) guint value, va_chroma_format, attrib_index; /* Reset profile and entrypoint */ - if (!cip->profile || !cip->entrypoint) + if (cip->profile == GST_VAAPI_PROFILE_UNKNOWN + || cip->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) goto cleanup; context->va_profile = gst_vaapi_profile_get_va_profile (cip->profile); context->va_entrypoint = @@ -409,10 +410,12 @@ gst_vaapi_context_new (GstVaapiDisplay * display, { GstVaapiContext *context; - g_return_val_if_fail (cip->profile, NULL); - g_return_val_if_fail (cip->entrypoint, NULL); g_return_val_if_fail (display, NULL); + if (cip->profile == GST_VAAPI_PROFILE_UNKNOWN + || cip->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) + return NULL; + context = g_slice_new (GstVaapiContext); if (!context) return NULL; @@ -470,6 +473,10 @@ gst_vaapi_context_reset (GstVaapiContext * context, gboolean grow_surfaces = FALSE; GstVaapiChromaType chroma_type; + if (new_cip->profile == GST_VAAPI_PROFILE_UNKNOWN + || new_cip->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) + return FALSE; + chroma_type = new_cip->chroma_type ? new_cip->chroma_type : DEFAULT_CHROMA_TYPE; if (cip->chroma_type != chroma_type) { diff --git a/gst-libs/gst/vaapi/gstvaapiprofile.h b/gst-libs/gst/vaapi/gstvaapiprofile.h index 8f0039c5..72ffd55c 100644 --- a/gst-libs/gst/vaapi/gstvaapiprofile.h +++ b/gst-libs/gst/vaapi/gstvaapiprofile.h @@ -188,6 +188,7 @@ typedef enum { /** * GstVaapiEntrypoint: + * @GST_VAAPI_ENTRYPOINT_INVALID: Invalid entrypoint * @GST_VAAPI_ENTRYPOINT_VLD: Variable Length Decoding * @GST_VAAPI_ENTRYPOINT_IDCT: Inverse Decrete Cosine Transform * @GST_VAAPI_ENTRYPOINT_MOCO: Motion Compensation @@ -200,7 +201,8 @@ typedef enum { * The set of all entrypoints for #GstVaapiEntrypoint */ typedef enum { - GST_VAAPI_ENTRYPOINT_VLD = 1, + GST_VAAPI_ENTRYPOINT_INVALID, + GST_VAAPI_ENTRYPOINT_VLD, GST_VAAPI_ENTRYPOINT_IDCT, GST_VAAPI_ENTRYPOINT_MOCO, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE, -- cgit v1.2.3