diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-27 04:45:04 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-27 04:49:09 +0200 |
commit | b96c9513f35a109b6ee06e6e22deea84c5fdab4b (patch) | |
tree | ad12ae34c14c935e73d9a9cbf910bd189fa8a89a /libavcodec/snow.c | |
parent | 134beb9e02222a33fc2534176c64aeeed0549851 (diff) | |
download | ffmpeg-b96c9513f35a109b6ee06e6e22deea84c5fdab4b.tar.gz |
avcodec/snow: factor ff_snow_get_buffer() out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/snow.c')
-rw-r--r-- | libavcodec/snow.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 616d1170af..e1ed29793d 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -66,6 +66,26 @@ 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; + + frame->width = s->avctx->width + 2 * EDGE_WIDTH; + frame->height = s->avctx->height + 2 * EDGE_WIDTH; + if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) + return ret; + 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; @@ -661,18 +681,8 @@ int ff_snow_frame_start(SnowContext *s){ return -1; } } - s->current_picture->width = s->avctx->width + 2 * EDGE_WIDTH; - s->current_picture->height = s->avctx->height + 2 * EDGE_WIDTH; - if ((ret = ff_get_buffer(s->avctx, s->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0) + if ((ret = ff_snow_get_buffer(s, s->current_picture)) < 0) return ret; - for (i = 0; s->current_picture->data[i]; i++) { - int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) * - s->current_picture->linesize[i] + - (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0)); - s->current_picture->data[i] += offset; - } - s->current_picture->width = s->avctx->width; - s->current_picture->height = s->avctx->height; s->current_picture->key_frame= s->keyframe; |