[FFmpeg-devel] [PATCH] avcodec: ViewQuest VQC decoder

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Oct 7 13:38:51 EEST 2022


Tomas Härdin:
> tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:
>>
>> +static av_cold int vqc_decode_init(AVCodecContext * avctx)
>> +{
>> +    static AVOnce init_static_once = AV_ONCE_INIT;
>> +    VqcContext *s = avctx->priv_data;
>> +
>> +    s->vectors = av_malloc((avctx->width * avctx->height * 3) / 2);
>> +    if (!s->vectors)
>> +        return AVERROR(ENOMEM);
>> +
>> +    s->coeff = av_malloc(2 * avctx->width * sizeof(int16_t));
>> +    if (!s->coeff)
>> +        return AVERROR(ENOMEM);
>> +
>> +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
>> +    if (!s->tmp1)
>> +        return AVERROR(ENOMEM);
>> +
>> +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> 
> av_malloc_array() perhaps? Not that these are likely to overflow since
> max pixels is usually far away from INT_MAX
> 

Actually, sizeof(int16_t) is guaranteed to be two, so that
sizeof(int16_t) / 2 is always one.

- Andreas



More information about the ffmpeg-devel mailing list