diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-07-16 19:40:35 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-07-16 19:43:35 +0200 |
commit | 15285d8fc528483aebf4ae7c522ea33c558f503c (patch) | |
tree | 0c6e05a3593224ab22b88d2ab5d979e4f608d8f6 /libavcodec/flashsv.c | |
parent | c31a5b23b4cd566724743685e5ea158b0c818647 (diff) | |
parent | 8342a82680966055af8cbc48e0ad129411df7c44 (diff) | |
download | ffmpeg-15285d8fc528483aebf4ae7c522ea33c558f503c.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
arm: remove disabled function dct_unquantize_h263_inter_iwmmxt()
Remove commented-out call to non-existing function print_pow1().
Do not decode RV30 files if the extradata is too small
flashsv: split flashsv_decode_block() off from flashsv_decode_frame().
ppc: remove disabled code
libspeexdec: Drop const qualifier to silence compiler warning.
libopenjpeg: Drop const qualifier to silence compiler warning.
alac: Remove unused dummy code.
Remove unused structs and tables.
vaapi: do not assert on value read from input bitstream
flashsvenc: replace bitstream description by a link to the specification
flashsvenc: drop unnecessary cast
flashsvenc: improve some variable names and fix corresponding comments
flashsvenc: merge two consecutive if-conditions
flashsvenc: merge variable declarations and initializations
flashsvenc: convert some debug av_log() to av_dlog()
flashsvenc: whitespace cosmetics
flashsvenc: drop some unnecessary parentheses
flashsvenc: fix some comment typos
aacps: skip some memcpy() if src and dst would be equal
...
Conflicts:
libavcodec/vaapi_mpeg2.c
libavformat/aviobuf.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flashsv.c')
-rw-r--r-- | libavcodec/flashsv.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 47a94a40b6..96045e5eac 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -71,6 +71,45 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) } +static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, + GetBitContext *gb, int block_size, + int width, int height, int x_pos, int y_pos) +{ + struct FlashSVContext *s = avctx->priv_data; + uint8_t *line = s->tmpblock; + int k; + int ret = inflateReset(&s->zstream); + if (ret != Z_OK) { + //return -1; + } + s->zstream.next_in = avpkt->data + get_bits_count(gb) / 8; + s->zstream.avail_in = block_size; + s->zstream.next_out = s->tmpblock; + s->zstream.avail_out = s->block_size * 3; + ret = inflate(&s->zstream, Z_FINISH); + if (ret == Z_DATA_ERROR) { + av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); + inflateSync(&s->zstream); + ret = inflate(&s->zstream, Z_FINISH); + } + + if (ret != Z_OK && ret != Z_STREAM_END) { + //return -1; + } + /* Flash Screen Video stores the image upside down, so copy + * lines to destination in reverse order. */ + for (k = 1; k <= height; k++) { + 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; + } + skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */ + return 0; +} + + static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -159,41 +198,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* skip unchanged blocks, which have size 0 */ if (size) { - /* decompress block */ - uint8_t *line = s->tmpblock; - int k; - int ret = inflateReset(&s->zstream); - if (ret != Z_OK) { - av_log(avctx, AV_LOG_ERROR, - "error in decompression (reset) of block %dx%d\n", i, j); - /* return -1; */ - } - s->zstream.next_in = avpkt->data + get_bits_count(&gb) / 8; - s->zstream.avail_in = size; - s->zstream.next_out = s->tmpblock; - s->zstream.avail_out = s->block_size * 3; - ret = inflate(&s->zstream, Z_FINISH); - if (ret == Z_DATA_ERROR) { - av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); - inflateSync(&s->zstream); - ret = inflate(&s->zstream, Z_FINISH); - } - - if (ret != Z_OK && ret != Z_STREAM_END) { + if (flashsv_decode_block(avctx, avpkt, &gb, size, + cur_blk_width, cur_blk_height, + x_pos, y_pos)) av_log(avctx, AV_LOG_ERROR, - "error in decompression of block %dx%d: %d\n", i, j, ret); - /* return -1; */ - } - /* Flash Screen Video stores the image upside down, so copy - * lines to destination in reverse order. */ - for (k = 1; k <= cur_blk_height; k++) { - memcpy(s->frame.data[0] + x_pos * 3 + - (s->image_height - y_pos - k) * s->frame.linesize[0], - line, cur_blk_width * 3); - /* advance source pointer to next line */ - line += cur_blk_width * 3; - } - skip_bits_long(&gb, 8 * size); /* skip the consumed bits */ + "error in decompression of block %dx%d\n", i, j); } } } |