avcodec/snow: Move decoder parts out of ff_snow_common_init_after_header

They are not common.

Furthermore, this file is pulled in when linking checkasm and
up until now, the calls to ff_get_buffer() and av_codec_is_decoder()
caused all of libavcodec to be pulled in as well. Besides being
bad size-wise this also has the downside that it pulls in
avpriv_(cga|vga16)_font from libavutil which are marked as
being imported from another library when building libavcodec
as a DLL; this breaks checkasm because it links both lavc and lavu
statically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-25 18:57:47 +02:00
parent 418332e01c
commit 00ba78cd6f
2 changed files with 12 additions and 14 deletions

View File

@ -21,7 +21,6 @@
#include "libavutil/log.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "decode.h"
#include "snow_dwt.h"
#include "snow.h"
#include "snowdata.h"
@ -476,27 +475,15 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
int ff_snow_common_init_after_header(AVCodecContext *avctx) {
SnowContext *s = avctx->priv_data;
int plane_index, level, orientation;
int ret, emu_buf_size;
if(!s->scratchbuf) {
if (av_codec_is_decoder(avctx->codec)) {
if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
}
int emu_buf_size;
emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
!FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))
return AVERROR(ENOMEM);
}
if (av_codec_is_decoder(avctx->codec) &&
s->mconly_picture->format != avctx->pix_fmt) {
av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
return AVERROR_INVALIDDATA;
}
for(plane_index=0; plane_index < s->nb_planes; plane_index++){
int w= s->avctx->width;
int h= s->avctx->height;

View File

@ -455,6 +455,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
if ((res = decode_header(s)) < 0)
return res;
if (!s->mconly_picture->data[0]) {
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) {
av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
return AVERROR_INVALIDDATA;
}
if ((res=ff_snow_common_init_after_header(avctx)) < 0)
return res;