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
21#include "libavutil/log.h"21#include "libavutil/log.h"
22#include "libavutil/thread.h"22#include "libavutil/thread.h"
23#include "avcodec.h"23#include "avcodec.h"
24#include "decode.h"
25#include "snow_dwt.h"24#include "snow_dwt.h"
26#include "snow.h"25#include "snow.h"
27#include "snowdata.h"26#include "snowdata.h"
@@ -476,27 +475,15 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ · 448 unmodified lines
476int ff_snow_common_init_after_header(AVCodecContext *avctx) {475int ff_snow_common_init_after_header(AVCodecContext *avctx) {
477 SnowContext *s = avctx->priv_data;476 SnowContext *s = avctx->priv_data;
478 int plane_index, level, orientation;477 int plane_index, level, orientation;
479 int ret, emu_buf_size;
480 478
481 if(!s->scratchbuf) {479 if(!s->scratchbuf) {
482 if (av_codec_is_decoder(avctx->codec)) {480 int emu_buf_size;
483 if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
484 AV_GET_BUFFER_FLAG_REF)) < 0)
485 return ret;
486 }
487
488 emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);481 emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
489 if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||482 if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
490 !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))483 !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))
491 return AVERROR(ENOMEM);484 return AVERROR(ENOMEM);
492 }485 }
493 486
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
500 for(plane_index=0; plane_index < s->nb_planes; plane_index++){487 for(plane_index=0; plane_index < s->nb_planes; plane_index++){
501 int w= s->avctx->width;488 int w= s->avctx->width;
502 int h= s->avctx->height;489 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
455 s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P455 s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
456 if ((res = decode_header(s)) < 0)456 if ((res = decode_header(s)) < 0)
457 return res;457 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
458 if ((res=ff_snow_common_init_after_header(avctx)) < 0)469 if ((res=ff_snow_common_init_after_header(avctx)) < 0)
459 return res;470 return res;
460 471

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