avcodec: use int instead of enum for AVOption fields

AVOption with AV_OPT_TYPE_INT assumes the field is int (4 bytes),
but enum size is implementation-defined and may be smaller.
This can cause memory corruption when AVOption writes 4 bytes
to a field that is only 1-2 bytes, potentially overwriting
adjacent struct members.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili
2026-01-25 22:07:44 +08:00
parent 00d3417b71
commit 86d2fae59f
4 changed files with 10 additions and 5 deletions

View File

@@ -115,8 +115,10 @@ typedef struct AMFEncoderContext {
// AV1 - specific options
enum AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_ENUM align;
enum AMF_VIDEO_ENCODER_AV1_AQ_MODE_ENUM aq_mode;
/* enum AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_ENUM, use int for AVOption */
int align;
/* enum AMF_VIDEO_ENCODER_AV1_AQ_MODE_ENUM */
int aq_mode;
// Preanalysis - specific options

View File

@@ -35,7 +35,8 @@ typedef struct FilterUnitsContext {
const char *pass_types;
const char *remove_types;
enum AVDiscard discard;
/* enum AVDiscard, use int for AVOption */
int discard;
int discard_flags;
enum {

View File

@@ -62,7 +62,8 @@ typedef struct HapContext {
GetByteContext gbc;
enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
/* enum HapTextureFormat, use int for AVOption */
int opt_tex_fmt; /* Texture type (encoder only) */
int opt_chunk_count; /* User-requested chunk count (encoder only) */
int opt_compressor; /* User-requested compressor (encoder only) */

View File

@@ -48,7 +48,8 @@ typedef struct HYuvEncContext {
AVClass *class;
AVCodecContext *avctx;
PutBitContext pb;
Predictor predictor;
/* Predictor, use int for AVOption */
int predictor;
int interlaced;
int decorrelate;
int bitstream_bpp;