diff options
author | Sebastian Vater <cdgs.basty@googlemail.com> | 2010-04-26 22:38:41 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2010-04-26 22:38:41 +0000 |
commit | fe51b5ce504d118757407c0855e957e97ca90f78 (patch) | |
tree | 7e545df3ccd5b973a721dcb34adff5153cd2c869 | |
parent | 473147bed01c0c6c82d85fd79d3e1c1d65542663 (diff) | |
download | ffmpeg-fe51b5ce504d118757407c0855e957e97ca90f78.tar.gz |
Move some branches outside looped code. Should improve the generated asm (and
thus performance) slightly.
Patch by Sebastian Vater <cdgs.basty googlemail com>.
Originally committed as revision 22975 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/iff.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/libavcodec/iff.c b/libavcodec/iff.c index b5ee2e6e47..e628c5e111 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -140,16 +140,23 @@ static int decode_frame_ilbm(AVCodecContext *avctx, return -1; } + if (avctx->pix_fmt == PIX_FMT_PAL8) { for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; - memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4)); + memset(row, 0, avctx->width); for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { - if (avctx->pix_fmt == PIX_FMT_PAL8) { decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane); + buf += s->planesize; + } + } } else { // PIX_FMT_BGR32 + for(y = 0; y < avctx->height; y++ ) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + memset(row, 0, avctx->width << 2); + for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane); - } buf += s->planesize; + } } } @@ -173,10 +180,11 @@ static int decode_frame_byterun1(AVCodecContext *avctx, return -1; } + if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved + if (avctx->pix_fmt == PIX_FMT_PAL8) { for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; - if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved - memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4)); + memset(row, 0, avctx->width); for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { for(x = 0; x < s->planesize && buf < buf_end; ) { int8_t value = *buf++; @@ -193,13 +201,36 @@ static int decode_frame_byterun1(AVCodecContext *avctx, } x += length; } - if (avctx->pix_fmt == PIX_FMT_PAL8) { decodeplane8(row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane); + } + } } else { //PIX_FMT_BGR32 + for(y = 0; y < avctx->height ; y++ ) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + memset(row, 0, avctx->width << 2); + for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { + for(x = 0; x < s->planesize && buf < buf_end; ) { + int8_t value = *buf++; + unsigned length; + if (value >= 0) { + length = value + 1; + memcpy(s->planebuf + x, buf, FFMIN3(length, s->planesize - x, buf_end - buf)); + buf += length; + } else if (value > -128) { + length = -value + 1; + memset(s->planebuf + x, *buf++, FFMIN(length, s->planesize - x)); + } else { // noop + continue; + } + x += length; + } decodeplane32((uint32_t *) row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane); } } + } } else { + for(y = 0; y < avctx->height ; y++ ) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; for(x = 0; x < avctx->width && buf < buf_end; ) { int8_t value = *buf++; unsigned length; |