1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit 'c6303f8d70c25dd6c6e6486c78bf99c9924e2b6b'

* commit 'c6303f8d70c25dd6c6e6486c78bf99c9924e2b6b':
  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: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-12-24 15:42:52 +01:00
commit 9dbedf331e
4 changed files with 84 additions and 94 deletions

View File

@ -25,7 +25,8 @@
#include "internal.h"
#include "msrledec.h"
static av_cold int bmp_decode_init(AVCodecContext *avctx){
static av_cold int bmp_decode_init(AVCodecContext *avctx)
{
BMPContext *s = avctx->priv_data;
avcodec_get_frame_defaults(&s->picture);
@ -112,7 +113,8 @@ static int bmp_decode_frame(AVCodecContext *avctx,
return -1;
}
if(bytestream_get_le16(&buf) != 1){ /* planes */
/* planes */
if (bytestream_get_le16(&buf) != 1) {
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
@ -124,7 +126,8 @@ static int bmp_decode_frame(AVCodecContext *avctx,
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){
if (comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 &&
comp != BMP_RLE8) {
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
@ -256,7 +259,8 @@ static int bmp_decode_frame(AVCodecContext *avctx,
}
}
buf = buf0 + 14 + ihsize; //palette location
if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry
// OS/2 bitmap, 3 bytes per palette entry
if ((hsize-ihsize-14) < (colors << 2)) {
for (i = 0; i < colors; i++)
((uint32_t*)p->data[1])[i] = (0xFFU<<24) | bytestream_get_le24(&buf);
} else {

View File

@ -237,6 +237,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
for (i = 0; i < 256; i++) {
palette[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
newpic->palette_has_changed = 1;
} else {
if (oldpic->data[1])
memcpy(newpic->data[1], oldpic->data[1], 256 * 4);

View File

@ -36,7 +36,6 @@ typedef struct YopDecContext {
int num_pal_colors;
int first_color[2];
int frame_data_length;
int row_pos;
uint8_t *low_nibble;
uint8_t *srcptr;
@ -177,27 +176,12 @@ static uint8_t yop_get_next_nibble(YopDecContext *s)
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,
AVPacket *avpkt)
{
YopDecContext *s = avctx->priv_data;
int tag, firstcolor, is_odd_frame;
int ret, i;
int ret, i, x, y;
uint32_t *palette;
if (s->frame.data[0])
@ -214,12 +198,9 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return ret;
}
s->frame.linesize[0] = avctx->width;
s->dstbuf = s->frame.data[0];
s->dstptr = s->frame.data[0];
s->srcptr = avpkt->data + 4;
s->row_pos = 0;
s->low_nibble = NULL;
is_odd_frame = avpkt->data[0];
@ -240,9 +221,12 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->frame.palette_has_changed = 1;
while (s->dstptr - s->dstbuf <
avctx->width * avctx->height &&
s->srcptr - avpkt->data < avpkt->size) {
for (y = 0; y < avctx->height; y += 2) {
for (x = 0; x < avctx->width; x += 2) {
if (s->srcptr - avpkt->data >= avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "Packet too small.\n");
return AVERROR_INVALIDDATA;
}
tag = yop_get_next_nibble(s);
@ -256,7 +240,9 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return ret;
}
}
yop_next_macroblock(s);
s->dstptr += 2;
}
s->dstptr += 2*s->frame.linesize[0] - x;
}
*got_frame = 1;

View File

@ -5,4 +5,3 @@
0, 3, 3, 1, 302760, 0xe0fc92da
0, 4, 4, 1, 302760, 0xd7699bb4
0, 5, 5, 1, 302760, 0x26e93266
0, 6, 6, 1, 302760, 0x4cddb216