diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-17 03:31:32 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-17 03:31:32 +0100 |
commit | 92cbd775687204f9750a09c69f97702719036aab (patch) | |
tree | 16a375879e56045652edd2dd8f604bb7fb2fb4d0 /libavcodec/flashsv.c | |
parent | 9ad477d9098b5281cede0bd8525ca90b0e52436d (diff) | |
parent | d48c20630214a4effcc920e93a5044bee4e2002e (diff) | |
download | ffmpeg-92cbd775687204f9750a09c69f97702719036aab.tar.gz |
Merge commit 'd48c20630214a4effcc920e93a5044bee4e2002e'
* commit 'd48c20630214a4effcc920e93a5044bee4e2002e':
qtrleenc: use the AVFrame API properly.
ulti: use the AVFrame API properly.
vc1: use the AVFrame API properly.
flashsv: use the AVFrame API properly.
Conflicts:
libavcodec/flashsv.c
libavcodec/qtrleenc.c
libavcodec/ulti.c
libavcodec/vc1dec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flashsv.c')
-rw-r--r-- | libavcodec/flashsv.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 6527dac3ed..6af7d9bbbe 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -50,7 +50,7 @@ typedef struct BlockInfo { typedef struct FlashSVContext { AVCodecContext *avctx; - AVFrame frame; + AVFrame *frame; int image_width, image_height; int block_width, block_height; uint8_t *tmpblock; @@ -99,6 +99,19 @@ static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy, return sptr - orig_src; } +static av_cold int flashsv_decode_end(AVCodecContext *avctx) +{ + FlashSVContext *s = avctx->priv_data; + inflateEnd(&s->zstream); + /* release the frame if needed */ + av_frame_free(&s->frame); + + /* free the tmpblock */ + av_freep(&s->tmpblock); + + return 0; +} + static av_cold int flashsv_decode_init(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; @@ -114,7 +127,12 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) return 1; } avctx->pix_fmt = AV_PIX_FMT_BGR24; - avcodec_get_frame_defaults(&s->frame); + + s->frame = av_frame_alloc(); + if (!s->frame) { + flashsv_decode_end(avctx); + return AVERROR(ENOMEM); + } return 0; } @@ -206,18 +224,18 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, /* Flash Screen Video stores the image upside down, so copy * lines to destination in reverse order. */ for (k = 1; k <= s->diff_height; k++) { - memcpy(s->frame.data[0] + x_pos * 3 + - (s->image_height - y_pos - k) * s->frame.linesize[0], + memcpy(s->frame->data[0] + x_pos * 3 + + (s->image_height - y_pos - k) * s->frame->linesize[0], line, width * 3); /* advance source pointer to next line */ line += width * 3; } } else { /* hybrid 15-bit/palette mode */ - decode_hybrid(s->tmpblock, s->frame.data[0], + decode_hybrid(s->tmpblock, s->frame->data[0], s->image_height - (y_pos + 1 + s->diff_height), x_pos, s->diff_height, width, - s->frame.linesize[0], s->pal); + s->frame->linesize[0], s->pal); } skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */ return 0; @@ -344,7 +362,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); - if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) + if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; /* loop over all block columns */ @@ -369,7 +387,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->diff_height = cur_blk_height; if (8 * size > get_bits_left(&gb)) { - av_frame_unref(&s->frame); + av_frame_unref(s->frame); return AVERROR_INVALIDDATA; } @@ -429,11 +447,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, if (has_diff) { int k; - int off = (s->image_height - y_pos - 1) * s->frame.linesize[0]; + int off = (s->image_height - y_pos - 1) * s->frame->linesize[0]; for (k = 0; k < cur_blk_height; k++) { - int x = off - k * s->frame.linesize[0] + x_pos * 3; - memcpy(s->frame.data[0] + x, s->keyframe + x, + int x = off - k * s->frame->linesize[0] + x_pos * 3; + memcpy(s->frame->data[0] + x, s->keyframe + x, cur_blk_width * 3); } } @@ -451,17 +469,17 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, } if (s->is_keyframe && s->ver == 2) { if (!s->keyframe) { - s->keyframe = av_malloc(s->frame.linesize[0] * avctx->height); + s->keyframe = av_malloc(s->frame->linesize[0] * avctx->height); if (!s->keyframe) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n"); return AVERROR(ENOMEM); } } - memcpy(s->keyframe, s->frame.data[0], - s->frame.linesize[0] * avctx->height); + memcpy(s->keyframe, s->frame->data[0], + s->frame->linesize[0] * avctx->height); } - if ((ret = av_frame_ref(data, &s->frame)) < 0) + if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; @@ -474,19 +492,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, return buf_size; } -static av_cold int flashsv_decode_end(AVCodecContext *avctx) -{ - FlashSVContext *s = avctx->priv_data; - inflateEnd(&s->zstream); - /* release the frame if needed */ - av_frame_unref(&s->frame); - - /* free the tmpblock */ - av_freep(&s->tmpblock); - - return 0; -} - #if CONFIG_FLASHSV_DECODER AVCodec ff_flashsv_decoder = { .name = "flashsv", |