avcodec/snowdec: fix mconly

Fixes non repeatable checksums

This also avoids allocating the mc only buffer when its not used

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2026-02-19 03:19:34 +01:00
parent fb3012269e
commit 09ab2d18ed
2 changed files with 6 additions and 4 deletions

View File

@@ -540,7 +540,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
int plane_index, level, orientation;
if(!s->scratchbuf) {
if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE))
if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->current_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE))
return AVERROR(ENOMEM);
}

View File

@@ -605,14 +605,16 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
if ((res = decode_header(s)) < 0)
return res;
if (!s->mconly_picture->data[0]) {
if (avctx->debug & 2048) {
av_frame_unref(s->mconly_picture);
res = ff_get_buffer(avctx, s->mconly_picture, AV_GET_BUFFER_FLAG_REF);
if (res < 0)
return res;
}
if (s->mconly_picture->format != avctx->pix_fmt) {
if (s->current_picture->data[0] && s->current_picture->format != avctx->pix_fmt) {
av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
return AVERROR_INVALIDDATA;
return AVERROR_PATCHWELCOME;
}
if ((res=ff_snow_common_init_after_header(avctx)) < 0)