diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-31 19:18:13 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-31 19:18:13 +0000 |
commit | 49a20ffabc08170f795681c8642d65d0ab087932 (patch) | |
tree | da0eaa732b0aad9d4bdb98e1ea4be3c580c3c3da /libavcodec/interplayvideo.c | |
parent | bcbd9a149e85d21270f28e4fef1239f28885c57d (diff) | |
download | ffmpeg-49a20ffabc08170f795681c8642d65d0ab087932.tar.gz |
One more simplification for ipvideo_decode_block_opcode_0xA
Originally committed as revision 18282 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/interplayvideo.c')
-rw-r--r-- | libavcodec/interplayvideo.c | 71 |
1 files changed, 22 insertions, 49 deletions
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 40f7cd7922..a9bf7cd271 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -399,23 +399,17 @@ static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s) { int x, y; - unsigned char P[8]; - unsigned char B[16]; + unsigned char P[4]; int flags = 0; - int split; /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on * either top and bottom or left and right halves */ - CHECK_STREAM_PTR(4); - - memcpy(P, s->stream_ptr, 4); - s->stream_ptr += 4; + CHECK_STREAM_PTR(24); - if (P[0] <= P[1]) { + if (s->stream_ptr[0] <= s->stream_ptr[1]) { - /* 4-color encoding for each quadrant; need 28 more bytes */ - CHECK_STREAM_PTR(28); - s->stream_ptr -= 4; + /* 4-color encoding for each quadrant; need 32 bytes */ + CHECK_STREAM_PTR(32); for (y = 0; y < 16; y++) { // new values for each 4x4 block @@ -435,50 +429,29 @@ static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s) } } else { + // vertical split? + int vert = s->stream_ptr[12] <= s->stream_ptr[13]; + uint64_t flags = 0; /* 4-color encoding for either left and right or top and bottom - * halves; need 20 more bytes */ - CHECK_STREAM_PTR(20); - - memcpy(B, s->stream_ptr, 8); - s->stream_ptr += 8; - memcpy(P + 4, s->stream_ptr, 4); - s->stream_ptr += 4; - memcpy(B + 8, s->stream_ptr, 8); - s->stream_ptr += 8; - - if (P[4] <= P[5]) { - - /* block is divided into left and right halves */ - for (y = 0; y < 8; y++) { - - flags = (B[y + 8] << 8) | B[y]; - split = 0; - - for (x = 0; x < 8; x++, flags >>= 2) { - if (x == 4) - split = 4; - *s->pixel_ptr++ = P[split + (flags & 0x03)]; - } + * halves */ - s->pixel_ptr += s->line_inc; + for (y = 0; y < 16; y++) { + // load values for each half + if (!(y & 7)) { + memcpy(P, s->stream_ptr, 4); + s->stream_ptr += 4; + flags = bytestream_get_le64(&s->stream_ptr); } - } else { - - /* block is divided into top and bottom halves */ - split = 0; - for (y = 0; y < 8; y++) { - - flags = (B[y * 2 + 1] << 8) | B[y * 2]; - if (y == 4) - split = 4; - - for (x = 0; x < 8; x++, flags >>= 2) - *s->pixel_ptr++ = P[split + (flags & 0x03)]; + for (x = 0; x < 4; x++, flags >>= 2) + *s->pixel_ptr++ = P[flags & 0x03]; - s->pixel_ptr += s->line_inc; - } + if (vert) { + s->pixel_ptr += s->stride - 4; + // switch to right half + if (y == 7) s->pixel_ptr -= 8 * s->stride - 4; + } else if (y & 1) s->pixel_ptr += s->line_inc; } } |