History

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.

Andreas Rheinhardt committed 3 years ago

Commit 00ba78c1 parent 418332e2 files · +12 −14Browse files

Unified · Split

2 files
  1. libavcodec/snow.c +1 −14
  2. libavcodec/snowdec.c +11 −0
libavcodec/snow.c+1−14
@@ -21,7 +21,6 @@ · 20 unmodified lines
2121 #include "libavutil/log.h"
2222 #include "libavutil/thread.h"
2323 #include "avcodec.h"
24−#include "decode.h"
2524 #include "snow_dwt.h"
2625 #include "snow.h"
2726 #include "snowdata.h"
@@ -476,27 +475,15 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ · 448 unmodified lines
476475 int ff_snow_common_init_after_header(AVCodecContext *avctx) {
477476 SnowContext *s = avctx->priv_data;
478477 int plane_index, level, orientation;
479− int ret, emu_buf_size;
480478
481479 if(!s->scratchbuf) {
482− if (av_codec_is_decoder(avctx->codec)) {
483− if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
484− AV_GET_BUFFER_FLAG_REF)) < 0)
485− return ret;
486− }
487−
480+ int emu_buf_size;
488481 emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
489482 if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
490483 !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))
491484 return AVERROR(ENOMEM);
492485 }
493486
494− if (av_codec_is_decoder(avctx->codec) &&
495− s->mconly_picture->format != avctx->pix_fmt) {
496− av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
497− return AVERROR_INVALIDDATA;
498− }
499−
500487 for(plane_index=0; plane_index < s->nb_planes; plane_index++){
501488 int w= s->avctx->width;
502489 int h= s->avctx->height;
libavcodec/snowdec.c+11−0
@@ -455,6 +455,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, · 454 unmodified lines
455455 s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
456456 if ((res = decode_header(s)) < 0)
457457 return res;
458+
459+ if (!s->mconly_picture->data[0]) {
460+ res = ff_get_buffer(avctx, s->mconly_picture, AV_GET_BUFFER_FLAG_REF);
461+ if (res < 0)
462+ return res;
463+ }
464+ if (s->mconly_picture->format != avctx->pix_fmt) {
465+ av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
466+ return AVERROR_INVALIDDATA;
467+ }
468+
458469 if ((res=ff_snow_common_init_after_header(avctx)) < 0)
459470 return res;
460471

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t