summaryrefslogtreecommitdiff
path: root/libavcodec/g2meet.c
diff options
context:
space:
mode:
authorMaxim Poliakovski <max_pole@gmx.de>2013-10-22 00:54:51 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2014-02-11 12:46:11 +0100
commitd6d78518018a12fb495baab5663708a830f3aab6 (patch)
tree5f8c465e5ea37600af5631426c7d6e79f3b4cfc8 /libavcodec/g2meet.c
parent77bb0004bbe18f1498cfecdc68db5f10808b6599 (diff)
g2meet: factor out seeking to the chunk end
Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
Diffstat (limited to 'libavcodec/g2meet.c')
-rw-r--r--libavcodec/g2meet.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 9ce56c9cc3..d01abcca24 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -645,7 +645,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
int magic;
int got_header = 0;
uint32_t chunk_size;
- int chunk_type;
+ int chunk_type, chunk_start;
int i;
int ret;
@@ -671,8 +671,9 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
}
while (bytestream2_get_bytes_left(&bc) > 5) {
- chunk_size = bytestream2_get_le32(&bc) - 1;
- chunk_type = bytestream2_get_byte(&bc);
+ chunk_size = bytestream2_get_le32(&bc) - 1;
+ chunk_type = bytestream2_get_byte(&bc);
+ chunk_start = bytestream2_tell(&bc);
if (chunk_size > bytestream2_get_bytes_left(&bc)) {
av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %d type %02X\n",
chunk_size, chunk_type);
@@ -718,8 +719,6 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
c->bpp = bytestream2_get_byte(&bc);
- chunk_size -= 21;
- bytestream2_skip(&bc, chunk_size);
if (g2m_init_buffers(c)) {
ret = AVERROR(ENOMEM);
goto header_fail;
@@ -730,7 +729,6 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
if (!c->tiles_x || !c->tiles_y) {
av_log(avctx, AV_LOG_WARNING,
"No display info - skipping tile\n");
- bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc));
break;
}
if (chunk_size < 2) {
@@ -746,7 +744,6 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
break;
}
- chunk_size -= 2;
ret = 0;
switch (c->compression) {
case COMPR_EPIC_J_B:
@@ -756,13 +753,12 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
case COMPR_KEMPF_J_B:
ret = kempf_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
- chunk_size);
+ chunk_size - 2);
break;
}
if (ret && c->framebuf)
av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
c->tile_x, c->tile_y);
- bytestream2_skip(&bc, chunk_size);
break;
case CURSOR_POS:
if (chunk_size < 5) {
@@ -772,7 +768,6 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
}
c->cursor_x = bytestream2_get_be16(&bc);
c->cursor_y = bytestream2_get_be16(&bc);
- bytestream2_skip(&bc, chunk_size - 4);
break;
case CURSOR_SHAPE:
if (chunk_size < 8) {
@@ -783,17 +778,17 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
bytestream2_init(&tbc, buf + bytestream2_tell(&bc),
chunk_size - 4);
g2m_load_cursor(avctx, c, &tbc);
- bytestream2_skip(&bc, chunk_size);
break;
case CHUNK_CC:
case CHUNK_CD:
- bytestream2_skip(&bc, chunk_size);
break;
default:
av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02X\n",
chunk_type);
- bytestream2_skip(&bc, chunk_size);
}
+
+ /* navigate to next chunk */
+ bytestream2_skip(&bc, chunk_start + chunk_size - bytestream2_tell(&bc));
}
if (got_header)
c->got_header = 1;