diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-06 05:37:09 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-06 05:37:14 +0100 |
commit | 28adecf0fa1fa56db17b1f0e7711acb68baf00e7 (patch) | |
tree | a70970ed0c71408e1ff5780b2fabe077009f2daa /libavcodec/kgv1dec.c | |
parent | a3541896c6f443177a4f715cd71d1bff7ba8f380 (diff) | |
parent | 34e7a3d74cce2ba79905b8ed965c97c119364b39 (diff) | |
download | ffmpeg-28adecf0fa1fa56db17b1f0e7711acb68baf00e7.tar.gz |
Merge remote-tracking branch 'cehoyos/master'
* cehoyos/master:
Move the iconv test to the bottom of configure.
Make 32bit zmbv colour-space opaque.
Use uint8_t instead of uint16_t pointer in kega decoder.
kgv1dec: Simplify kega decoding by using memcpy instead of loops
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/kgv1dec.c')
-rw-r--r-- | libavcodec/kgv1dec.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 008843c673..6b81095af9 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -50,7 +50,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf_end = buf + avpkt->size; KgvContext * const c = avctx->priv_data; int offsets[8]; - uint16_t *out, *prev; + uint8_t *out, *prev; int outcnt = 0, maxcnt; int w, h, i, res; @@ -75,9 +75,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, c->cur.reference = 3; if ((res = ff_get_buffer(avctx, &c->cur)) < 0) return res; - out = (uint16_t *) c->cur.data[0]; + out = c->cur.data[0]; if (c->prev.data[0]) { - prev = (uint16_t *) c->prev.data[0]; + prev = c->prev.data[0]; } else { prev = NULL; } @@ -90,11 +90,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += 2; if (!(code & 0x8000)) { - out[outcnt++] = code; // rgb555 pixel coded directly + AV_WN16A(&out[2 * outcnt], code); // rgb555 pixel coded directly + outcnt++; } else { int count; - int inp_off; - uint16_t *inp; if ((code & 0x6000) == 0x6000) { // copy from previous frame @@ -112,7 +111,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, start = (outcnt + offsets[oidx]) % maxcnt; - if (maxcnt - start < count) + if (maxcnt - start < count || maxcnt - outcnt < count) break; if (!prev) { @@ -121,8 +120,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, break; } - inp = prev; - inp_off = start; + memcpy(out + 2 * outcnt, prev + 2 * start, 2 * count); } else { // copy from earlier in this frame int offset = (code & 0x1FFF) + 1; @@ -137,19 +135,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, count = 4 + *buf++; } - if (outcnt < offset) + if (outcnt < offset || maxcnt - outcnt < count) break; - inp = out; - inp_off = outcnt - offset; - } - - if (maxcnt - outcnt < count) - break; - - for (i = inp_off; i < count + inp_off; i++) { - out[outcnt++] = inp[i]; + av_memcpy_backptr(out + 2 * outcnt, 2 * offset, 2 * count); } + outcnt += count; } } |