diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-25 18:21:55 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-28 00:17:47 +0200 |
commit | 418332e01ce99d43f218504e4e4e1b4ea89c9a49 (patch) | |
tree | 53db7aa3c53bdfecde26b54e2d9c2154386c53c7 /libavcodec/snow.c | |
parent | 0228e27dedc66c98e5b25dee0f95e664a185bbf1 (diff) | |
download | ffmpeg-418332e01ce99d43f218504e4e4e1b4ea89c9a49.tar.gz |
avcodec/snow: Split ff_snow_get_buffer()
The part of said function that is common to both encoder and decoder
is negligible since c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a
and more than offset by the costs of "Am I an encoder?" checks.
So move allocating the frames to the encoder and decoder directly.
Also rename ff_snow_frame_start() to ff_snow_frames_prepare(),
because a frame without a buffer has not been properly started.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/snow.c')
-rw-r--r-- | libavcodec/snow.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 5eb3ee1e9e..09f2d60f47 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -22,7 +22,6 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "decode.h" -#include "encode.h" #include "snow_dwt.h" #include "snow.h" #include "snowdata.h" @@ -61,36 +60,6 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_ } } -int ff_snow_get_buffer(SnowContext *s, AVFrame *frame) -{ - int ret, i; - int edges_needed = av_codec_is_encoder(s->avctx->codec); - - frame->width = s->avctx->width ; - frame->height = s->avctx->height; - if (edges_needed) { - frame->width += 2 * EDGE_WIDTH; - frame->height += 2 * EDGE_WIDTH; - - ret = ff_encode_alloc_frame(s->avctx, frame); - } else - ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF); - if (ret < 0) - return ret; - if (edges_needed) { - for (i = 0; frame->data[i]; i++) { - int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) * - frame->linesize[i] + - (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0)); - frame->data[i] += offset; - } - frame->width = s->avctx->width; - frame->height = s->avctx->height; - } - - return 0; -} - void ff_snow_reset_contexts(SnowContext *s){ //FIXME better initial contexts int plane_index, level, orientation; @@ -589,20 +558,21 @@ void ff_snow_release_buffer(AVCodecContext *avctx) } } -int ff_snow_frame_start(SnowContext *s){ +int ff_snow_frames_prepare(SnowContext *s) +{ AVFrame *tmp; - int i, ret; ff_snow_release_buffer(s->avctx); tmp= s->last_picture[s->max_ref_frames-1]; - for(i=s->max_ref_frames-1; i>0; i--) + for (int i = s->max_ref_frames - 1; i > 0; i--) s->last_picture[i] = s->last_picture[i-1]; s->last_picture[0] = s->current_picture; s->current_picture = tmp; if(s->keyframe){ s->ref_frames= 0; + s->current_picture->flags |= AV_FRAME_FLAG_KEY; }else{ int i; for(i=0; i<s->max_ref_frames && s->last_picture[i]->data[0]; i++) @@ -613,14 +583,8 @@ int ff_snow_frame_start(SnowContext *s){ av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n"); return AVERROR_INVALIDDATA; } - } - if ((ret = ff_snow_get_buffer(s, s->current_picture)) < 0) - return ret; - - if (s->keyframe) - s->current_picture->flags |= AV_FRAME_FLAG_KEY; - else s->current_picture->flags &= ~AV_FRAME_FLAG_KEY; + } return 0; } |