av1enc: Use correct enum type with libaom >= 3

This fixes, among other things, a compiler warning with clang.

Also add static assertions that our own enum values match with the ones
from libaom.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4223>
This commit is contained in:
Sebastian Dröge 2023-03-19 18:26:56 +02:00 committed by GStreamer Marge Bot
parent f3dfe7b125
commit da198e59b2
3 changed files with 37 additions and 1 deletions

View file

@ -568,7 +568,11 @@ gst_av1_enc_init (GstAV1Enc * av1enc)
av1enc->aom_cfg.rc_resize_mode = DEFAULT_RESIZE_MODE;
av1enc->aom_cfg.rc_resize_denominator = DEFAULT_RESIZE_DENOMINATOR;
av1enc->aom_cfg.rc_resize_kf_denominator = DEFAULT_RESIZE_KF_DENOMINATOR;
#ifdef HAVE_LIBAOM_3
av1enc->aom_cfg.rc_superres_mode = (aom_superres_mode) DEFAULT_SUPERRES_MODE;
#else
av1enc->aom_cfg.rc_superres_mode = DEFAULT_SUPERRES_MODE;
#endif
av1enc->aom_cfg.rc_superres_denominator = DEFAULT_SUPERRES_DENOMINATOR;
av1enc->aom_cfg.rc_superres_kf_denominator = DEFAULT_SUPERRES_KF_DENOMINATOR;
av1enc->aom_cfg.rc_superres_qthresh = DEFAULT_SUPERRES_QTHRESH;

View file

@ -82,6 +82,13 @@ typedef enum
GST_AV1_ENC_SUPERRES_QTHRESH = 3,
} GstAV1EncSuperresMode;
#ifdef HAVE_LIBAOM_3
G_STATIC_ASSERT ((guint) GST_AV1_ENC_SUPERRES_NONE == (guint) AOM_SUPERRES_NONE);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_SUPERRES_FIXED == (guint) AOM_SUPERRES_FIXED);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_SUPERRES_RANDOM == (guint) AOM_SUPERRES_RANDOM);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_SUPERRES_QTHRESH == (guint) AOM_SUPERRES_QTHRESH);
#endif
/**
* GstAV1EncEndUsageMode:
* @GST_AV1_ENC_END_USAGE_VBR: Variable Bit Rate Mode
@ -100,6 +107,11 @@ typedef enum
GST_AV1_ENC_END_USAGE_Q = 3,
} GstAV1EncEndUsageMode;
G_STATIC_ASSERT ((guint) GST_AV1_ENC_END_USAGE_VBR == (guint) AOM_VBR);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_END_USAGE_CBR == (guint) AOM_CBR);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_END_USAGE_CQ == (guint) AOM_CQ);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_END_USAGE_Q == (guint) AOM_Q);
/**
* GstAV1EncKFMode:
* @GST_AV1_ENC_KF_DISABLED: Encoder does not place keyframes
@ -116,6 +128,9 @@ typedef enum
GST_AV1_ENC_KF_AUTO = 1,
} GstAV1EncKFMode;
G_STATIC_ASSERT ((guint) GST_AV1_ENC_KF_DISABLED == (guint) AOM_KF_DISABLED);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_KF_AUTO == (guint) AOM_KF_AUTO);
/**
* GstAV1EncEncPass:
* @GST_AV1_ENC_ONE_PASS: Single pass mode
@ -135,6 +150,13 @@ typedef enum
GST_AV1_ENC_THIRD_PASS = 3,
} GstAV1EncEncPass;
#ifdef HAVE_LIBAOM_3_2
G_STATIC_ASSERT ((guint) GST_AV1_ENC_ONE_PASS == (guint) AOM_RC_ONE_PASS);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_FIRST_PASS == (guint) AOM_RC_FIRST_PASS);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_SECOND_PASS == (guint) AOM_RC_SECOND_PASS);
G_STATIC_ASSERT ((guint) GST_AV1_ENC_THIRD_PASS == (guint) AOM_RC_THIRD_PASS);
#endif
/**
* GstAV1EncUsageProfile:
* @GST_AV1_ENC_USAGE_GOOD_QUALITY: Good Quality profile

View file

@ -1,8 +1,18 @@
aom_dep = dependency('aom', required: get_option('aom'))
aom3_dep = dependency('aom', version: '>= 3', required: get_option('aom'))
aom3_2_dep = dependency('aom', version: '>= 3.2', required: get_option('aom'))
if aom_dep.found()
aom_defines = []
if aom3_dep.found()
aom_defines += ['-DHAVE_LIBAOM_3']
endif
if aom3_2_dep.found()
aom_defines += ['-DHAVE_LIBAOM_3_2']
endif
gstaom = library('gstaom',
['gstaom.c', 'gstav1enc.c', 'gstav1dec.c', 'gstav1utils.c'],
c_args : gst_plugins_bad_args,
c_args : gst_plugins_bad_args + aom_defines,
include_directories : [configinc],
dependencies : [gstpbutils_dep, gstvideo_dep, aom_dep],
install : true,