1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/tscc2: Cleanup generically after init failure

Do this by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-09-13 03:34:19 +02:00
parent ef6c52f3c5
commit 657756c353

View File

@ -74,18 +74,14 @@ static av_cold int init_vlcs(TSCC2Context *c)
tscc2_nc_vlc_bits[i], 1, 1, tscc2_nc_vlc_bits[i], 1, 1,
tscc2_nc_vlc_codes[i], 2, 2, tscc2_nc_vlc_codes[i], 2, 2,
tscc2_nc_vlc_syms, 1, 1, INIT_VLC_LE); tscc2_nc_vlc_syms, 1, 1, INIT_VLC_LE);
if (ret) { if (ret)
free_vlcs(c);
return ret; return ret;
}
ret = ff_init_vlc_sparse(c->ac_vlc + i, 9, tscc2_ac_vlc_sizes[i], ret = ff_init_vlc_sparse(c->ac_vlc + i, 9, tscc2_ac_vlc_sizes[i],
tscc2_ac_vlc_bits[i], 1, 1, tscc2_ac_vlc_bits[i], 1, 1,
tscc2_ac_vlc_codes[i], 2, 2, tscc2_ac_vlc_codes[i], 2, 2,
tscc2_ac_vlc_syms[i], 2, 2, INIT_VLC_LE); tscc2_ac_vlc_syms[i], 2, 2, INIT_VLC_LE);
if (ret) { if (ret)
free_vlcs(c);
return ret; return ret;
}
} }
return 0; return 0;
@ -360,15 +356,12 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx)
c->slice_quants = av_malloc(c->mb_width * c->mb_height); c->slice_quants = av_malloc(c->mb_width * c->mb_height);
if (!c->slice_quants) { if (!c->slice_quants) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n"); av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n");
free_vlcs(c);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
c->pic = av_frame_alloc(); c->pic = av_frame_alloc();
if (!c->pic) { if (!c->pic)
tscc2_decode_end(avctx);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
return 0; return 0;
} }
@ -383,4 +376,5 @@ AVCodec ff_tscc2_decoder = {
.close = tscc2_decode_end, .close = tscc2_decode_end,
.decode = tscc2_decode_frame, .decode = tscc2_decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}; };