Commit 9dbedf33 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'c6303f8d'

* commit 'c6303f8d':
  yop: simplify/sanitize the decoding loop
  c93: set palette_has_changed.
  bmp: cosmetics, reformat
  hlsenc: Don't duplicate a string constant

Conflicts:
	libavcodec/bmp.c
	tests/ref/fate/yop
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents ba8e909c c6303f8d
This diff is collapsed.
...@@ -237,6 +237,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -237,6 +237,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
palette[i] = 0xFFU << 24 | bytestream2_get_be24(&gb); palette[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
} }
newpic->palette_has_changed = 1;
} else { } else {
if (oldpic->data[1]) if (oldpic->data[1])
memcpy(newpic->data[1], oldpic->data[1], 256 * 4); memcpy(newpic->data[1], oldpic->data[1], 256 * 4);
......
...@@ -36,7 +36,6 @@ typedef struct YopDecContext { ...@@ -36,7 +36,6 @@ typedef struct YopDecContext {
int num_pal_colors; int num_pal_colors;
int first_color[2]; int first_color[2];
int frame_data_length; int frame_data_length;
int row_pos;
uint8_t *low_nibble; uint8_t *low_nibble;
uint8_t *srcptr; uint8_t *srcptr;
...@@ -177,27 +176,12 @@ static uint8_t yop_get_next_nibble(YopDecContext *s) ...@@ -177,27 +176,12 @@ static uint8_t yop_get_next_nibble(YopDecContext *s)
return ret; return ret;
} }
/**
* Take s->dstptr to the next macroblock in sequence.
*/
static void yop_next_macroblock(YopDecContext *s)
{
// If we are advancing to the next row of macroblocks
if (s->row_pos == s->frame.linesize[0] - 2) {
s->dstptr += s->frame.linesize[0];
s->row_pos = 0;
}else {
s->row_pos += 2;
}
s->dstptr += 2;
}
static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt) AVPacket *avpkt)
{ {
YopDecContext *s = avctx->priv_data; YopDecContext *s = avctx->priv_data;
int tag, firstcolor, is_odd_frame; int tag, firstcolor, is_odd_frame;
int ret, i; int ret, i, x, y;
uint32_t *palette; uint32_t *palette;
if (s->frame.data[0]) if (s->frame.data[0])
...@@ -214,12 +198,9 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -214,12 +198,9 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return ret; return ret;
} }
s->frame.linesize[0] = avctx->width;
s->dstbuf = s->frame.data[0]; s->dstbuf = s->frame.data[0];
s->dstptr = s->frame.data[0]; s->dstptr = s->frame.data[0];
s->srcptr = avpkt->data + 4; s->srcptr = avpkt->data + 4;
s->row_pos = 0;
s->low_nibble = NULL; s->low_nibble = NULL;
is_odd_frame = avpkt->data[0]; is_odd_frame = avpkt->data[0];
...@@ -240,23 +221,28 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -240,23 +221,28 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->frame.palette_has_changed = 1; s->frame.palette_has_changed = 1;
while (s->dstptr - s->dstbuf < for (y = 0; y < avctx->height; y += 2) {
avctx->width * avctx->height && for (x = 0; x < avctx->width; x += 2) {
s->srcptr - avpkt->data < avpkt->size) { if (s->srcptr - avpkt->data >= avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "Packet too small.\n");
tag = yop_get_next_nibble(s); return AVERROR_INVALIDDATA;
}
if (tag != 0xf) {
yop_paint_block(s, tag);
}else {
tag = yop_get_next_nibble(s); tag = yop_get_next_nibble(s);
ret = yop_copy_previous_block(s, tag);
if (ret < 0) { if (tag != 0xf) {
avctx->release_buffer(avctx, &s->frame); yop_paint_block(s, tag);
return ret; } else {
tag = yop_get_next_nibble(s);
ret = yop_copy_previous_block(s, tag);
if (ret < 0) {
avctx->release_buffer(avctx, &s->frame);
return ret;
}
} }
s->dstptr += 2;
} }
yop_next_macroblock(s); s->dstptr += 2*s->frame.linesize[0] - x;
} }
*got_frame = 1; *got_frame = 1;
......
...@@ -5,4 +5,3 @@ ...@@ -5,4 +5,3 @@
0, 3, 3, 1, 302760, 0xe0fc92da 0, 3, 3, 1, 302760, 0xe0fc92da
0, 4, 4, 1, 302760, 0xd7699bb4 0, 4, 4, 1, 302760, 0xd7699bb4
0, 5, 5, 1, 302760, 0x26e93266 0, 5, 5, 1, 302760, 0x26e93266
0, 6, 6, 1, 302760, 0x4cddb216
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment