diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-18 02:20:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-18 02:20:19 +0100 |
commit | bbb61a1cd5cb2046e480f367a7ae58a32f2ef907 (patch) | |
tree | 0e7cc2b59558e2dc31d6b8752d90f6b5b5c886e5 /libavcodec/cdxl.c | |
parent | f6492476a63938cc66c51bf61c88407b7749f780 (diff) | |
parent | af468015d972c0dec5c8c37b2685ffa5cbe4ae87 (diff) | |
download | ffmpeg-bbb61a1cd5cb2046e480f367a7ae58a32f2ef907.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
als: prevent infinite loop in zero_remaining().
cook: prevent div-by-zero if channels is zero.
pamenc: switch to encode2().
svq1enc: switch to encode2().
dvenc: switch to encode2().
dpxenc: switch to encode2().
pngenc: switch to encode2().
v210enc: switch to encode2().
xwdenc: switch to encode2().
ttadec: use branchless unsigned-to-signed unfolding
avcodec: add a Sun Rasterfile encoder
sunrast: Move common defines to a new header file.
cdxl: fix video decoding for some files
cdxl: fix audio for some samples
apetag: add proper support for binary tags
ttadec: remove dead code
swscale: make access to filter data conditional on filter type.
swscale: update context offsets after removal of AlpMmxFilter.
prores: initialise encoder and decoder parts only when needed
swscale: make monowhite/black RGB-independent.
...
Conflicts:
Changelog
libavcodec/alsdec.c
libavcodec/dpxenc.c
libavcodec/golomb.h
libavcodec/pamenc.c
libavcodec/pngenc.c
libavformat/img2.c
libswscale/output.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/cdxl.c')
-rw-r--r-- | libavcodec/cdxl.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c index 8c9bea9768..a8546348dc 100644 --- a/libavcodec/cdxl.c +++ b/libavcodec/cdxl.c @@ -60,27 +60,29 @@ static void import_palette(CDXLVideoContext *c, uint32_t *new_palette) } } -static void bitplanar2chunky(CDXLVideoContext *c, int width, - int linesize, uint8_t *out) +static void bitplanar2chunky(CDXLVideoContext *c, int linesize, uint8_t *out) { + int skip = FFALIGN(c->avctx->width, 16) - c->avctx->width; GetBitContext gb; int x, y, plane; init_get_bits(&gb, c->video, c->video_size * 8); memset(out, 0, linesize * c->avctx->height); - for (plane = 0; plane < c->bpp; plane++) - for (y = 0; y < c->avctx->height; y++) - for (x = 0; x < width; x++) + for (plane = 0; plane < c->bpp; plane++) { + for (y = 0; y < c->avctx->height; y++) { + for (x = 0; x < c->avctx->width; x++) out[linesize * y + x] |= get_bits1(&gb) << plane; + skip_bits(&gb, skip); + } + } } static void cdxl_decode_rgb(CDXLVideoContext *c) { uint32_t *new_palette = (uint32_t *)c->frame.data[1]; - int padded_width = FFALIGN(c->avctx->width, 16); import_palette(c, new_palette); - bitplanar2chunky(c, padded_width, c->frame.linesize[0], c->frame.data[0]); + bitplanar2chunky(c, c->frame.linesize[0], c->frame.data[0]); } static void cdxl_decode_ham6(CDXLVideoContext *c) @@ -94,7 +96,7 @@ static void cdxl_decode_ham6(CDXLVideoContext *c) out = c->frame.data[0]; import_palette(c, new_palette); - bitplanar2chunky(c, avctx->width, avctx->width, c->new_video); + bitplanar2chunky(c, avctx->width, c->new_video); for (y = 0; y < avctx->height; y++) { r = new_palette[0] & 0xFF0000; @@ -137,7 +139,7 @@ static void cdxl_decode_ham8(CDXLVideoContext *c) out = c->frame.data[0]; import_palette(c, new_palette); - bitplanar2chunky(c, avctx->width, avctx->width, c->new_video); + bitplanar2chunky(c, avctx->width, c->new_video); for (y = 0; y < avctx->height; y++) { r = new_palette[0] & 0xFF0000; @@ -209,16 +211,13 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, if (w != avctx->width || h != avctx->height) avcodec_set_dimensions(avctx, w, h); + if (c->video_size < FFALIGN(avctx->width, 16) * avctx->height * c->bpp / 8) + return AVERROR_INVALIDDATA; if (encoding == 0) { - if (c->video_size < FFALIGN(avctx->width, 16) * - avctx->height * c->bpp / 8) - return AVERROR_INVALIDDATA; avctx->pix_fmt = PIX_FMT_PAL8; } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) { if (c->palette_size != (1 << (c->bpp - 1))) return AVERROR_INVALIDDATA; - if (c->video_size < avctx->width * avctx->height * c->bpp / 8) - return AVERROR_INVALIDDATA; avctx->pix_fmt = PIX_FMT_BGR24; } else { av_log_ask_for_sample(avctx, "unsupported encoding %d and bpp %d\n", |