DSPContext dsp;
}HYuvContext;
- static const unsigned char classic_shift_luma[] = {
+ #define classic_shift_luma_table_size 42
+ static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8,
16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70,
- 69,68, 0
+ 69,68, 0,
+ 0,0,0,0,0,0,0,0,
};
- static const unsigned char classic_shift_chroma[] = {
+ #define classic_shift_chroma_table_size 59
+ static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183,
56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119,
- 214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0
+ 214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0,
+ 0,0,0,0,0,0,0,0,
};
static const unsigned char classic_add_luma[256] = {
avctx->coded_frame= s->current_picture;
p = s->current_picture;
- s->bytestream_start=
- s->bytestream= buf;
- s->bytestream_end= buf + buf_size;
-
/* check signature */
- if (memcmp(s->bytestream, ff_pngsig, 8) != 0 &&
- memcmp(s->bytestream, ff_mngsig, 8) != 0) {
+ if (buf_size < 8 ||
+ memcmp(buf, ff_pngsig, 8) != 0 &&
- memcmp(buf, ff_mngsig, 8) != 0)
++ memcmp(buf, ff_mngsig, 8) != 0) {
+ av_log(avctx, AV_LOG_ERROR, "Missing png signature\n");
return -1;
- s->bytestream+= 8;
+ }
+
+ bytestream2_init(&s->gb, buf + 8, buf_size - 8);
s->y=
s->state=0;
// memset(s, 0, sizeof(PNGDecContext));
if (ret != Z_OK)
return -1;
for(;;) {
- int tag32;
- if (s->bytestream >= s->bytestream_end)
+ if (bytestream2_get_bytes_left(&s->gb) <= 0)
goto fail;
- length = bytestream_get_be32(&s->bytestream);
- if (length > 0x7fffffff || length > s->bytestream_end - s->bytestream)
++
+ length = bytestream2_get_be32(&s->gb);
- if (length > 0x7fffffff)
++ if (length > 0x7fffffff || length > bytestream2_get_bytes_left(&s->gb))
goto fail;
- tag32 = bytestream_get_be32(&s->bytestream);
- tag = av_bswap32(tag32);
+ tag = bytestream2_get_le32(&s->gb);
- av_dlog(avctx, "png: tag=%c%c%c%c length=%u\n",
+ if (avctx->debug & FF_DEBUG_STARTCODE)
+ av_log(avctx, AV_LOG_DEBUG, "png: tag=%c%c%c%c length=%u\n",
(tag & 0xff),
((tag >> 8) & 0xff),
((tag >> 16) & 0xff),
s->width= s->height= 0;
goto fail;
}
- s->bit_depth = *s->bytestream++;
- s->color_type = *s->bytestream++;
- s->compression_type = *s->bytestream++;
- s->filter_type = *s->bytestream++;
- s->interlace_type = *s->bytestream++;
- s->bytestream += 4; /* crc */
+ s->bit_depth = bytestream2_get_byte(&s->gb);
+ s->color_type = bytestream2_get_byte(&s->gb);
+ s->compression_type = bytestream2_get_byte(&s->gb);
+ s->filter_type = bytestream2_get_byte(&s->gb);
+ s->interlace_type = bytestream2_get_byte(&s->gb);
+ bytestream2_skip(&s->gb, 4); /* crc */
s->state |= PNG_IHDR;
- av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
+ if (avctx->debug & FF_DEBUG_PICT_INFO)
+ av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
break;