Go to the documentation of this file.
101 0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
106 0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
111 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
118 int bits_per_pixel,
int pass,
121 int x,
mask, dsp_mask, j, src_x,
b, bpp;
128 switch (bits_per_pixel) {
131 for (x = 0; x <
width; x++) {
133 if ((dsp_mask << j) & 0x80) {
134 b = (
src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
135 dst[x >> 3] &= 0xFF7F>>j;
136 dst[x >> 3] |=
b << (7 - j);
138 if ((
mask << j) & 0x80)
144 for (x = 0; x <
width; x++) {
145 int j2 = 2 * (x & 3);
147 if ((dsp_mask << j) & 0x80) {
148 b = (
src[src_x >> 2] >> (6 - 2*(src_x & 3))) & 3;
149 dst[x >> 2] &= 0xFF3F>>j2;
150 dst[x >> 2] |=
b << (6 - j2);
152 if ((
mask << j) & 0x80)
158 for (x = 0; x <
width; x++) {
161 if ((dsp_mask << j) & 0x80) {
162 b = (
src[src_x >> 1] >> (4 - 4*(src_x & 1))) & 15;
163 dst[x >> 1] &= 0xFF0F>>j2;
164 dst[x >> 1] |=
b << (4 - j2);
166 if ((
mask << j) & 0x80)
171 bpp = bits_per_pixel >> 3;
174 for (x = 0; x <
width; x++) {
176 if ((dsp_mask << j) & 0x80) {
180 if ((
mask << j) & 0x80)
191 for (
i = 0;
i <
w;
i++) {
192 int a,
b,
c, p, pa, pb, pc;
205 if (pa <= pb && pa <= pc)
215 #define UNROLL1(bpp, op) \
224 for (; i <= size - bpp; i += bpp) { \
225 dst[i + 0] = r = op(r, src[i + 0], last[i + 0]); \
228 dst[i + 1] = g = op(g, src[i + 1], last[i + 1]); \
231 dst[i + 2] = b = op(b, src[i + 2], last[i + 2]); \
234 dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \
238 #define UNROLL_FILTER(op) \
241 } else if (bpp == 2) { \
243 } else if (bpp == 3) { \
245 } else if (bpp == 4) { \
248 for (; i < size; i++) { \
249 dst[i] = op(dst[i - bpp], src[i], last[i]); \
256 int i, p,
r,
g,
b,
a;
258 switch (filter_type) {
263 for (
i = 0;
i < bpp;
i++)
267 for (;
i <
size;
i += bpp) {
268 unsigned s = *(
int *)(
src +
i);
269 p = ((
s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((
s ^ p) & 0x80808080);
270 *(
int *)(dst +
i) = p;
273 #define OP_SUB(x, s, l) ((x) + (s))
281 for (
i = 0;
i < bpp;
i++) {
285 #define OP_AVG(x, s, l) (((((x) + (l)) >> 1) + (s)) & 0xff)
289 for (
i = 0;
i < bpp;
i++) {
293 if (bpp > 2 &&
size > 4) {
310 #define YUV2RGB(NAME, TYPE) \
311 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
314 for (i = 0; i < size; i += 3 + alpha) { \
315 int g = dst [i + 1]; \
326 if (
s->interlace_type) {
329 return 100 - 100 *
s->y /
s->cur_h;
339 if (!
s->interlace_type) {
340 ptr =
s->image_buf +
s->image_linesize * (
s->y +
s->y_offset) +
s->x_offset *
s->bpp;
342 last_row =
s->last_row;
344 last_row = ptr -
s->image_linesize;
347 last_row,
s->row_size,
s->bpp);
350 if (
s->bit_depth == 16) {
351 deloco_rgb16((uint16_t *)(ptr -
s->image_linesize),
s->row_size / 2,
354 deloco_rgb8(ptr -
s->image_linesize,
s->row_size,
359 if (
s->y ==
s->cur_h) {
362 if (
s->bit_depth == 16) {
363 deloco_rgb16((uint16_t *)ptr,
s->row_size / 2,
366 deloco_rgb8(ptr,
s->row_size,
374 ptr =
s->image_buf +
s->image_linesize * (
s->y +
s->y_offset) +
s->x_offset *
s->bpp;
381 s->last_row,
s->pass_row_size,
s->bpp);
383 FFSWAP(
unsigned int,
s->last_row_size,
s->tmp_row_size);
388 s->color_type,
s->last_row);
391 if (
s->y ==
s->cur_h) {
392 memset(
s->last_row, 0,
s->row_size);
403 s->crow_size =
s->pass_row_size + 1;
404 if (
s->pass_row_size != 0)
419 s->zstream.next_in =
s->gb.buffer;
423 while (
s->zstream.avail_in > 0) {
425 if (
ret != Z_OK &&
ret != Z_STREAM_END) {
429 if (
s->zstream.avail_out == 0) {
433 s->zstream.avail_out =
s->crow_size;
434 s->zstream.next_out =
s->crow_buf;
436 if (
ret == Z_STREAM_END &&
s->zstream.avail_in > 0) {
438 "%d undecompressed bytes left in buffer\n",
s->zstream.avail_in);
455 zstream.opaque =
NULL;
456 if (inflateInit(&zstream) != Z_OK)
458 zstream.next_in =
data;
459 zstream.avail_in = data_end -
data;
462 while (zstream.avail_in > 0) {
468 zstream.next_out = buf;
469 zstream.avail_out = buf_size - 1;
471 if (
ret != Z_OK &&
ret != Z_STREAM_END) {
475 bp->len += zstream.next_out - buf;
476 if (
ret == Z_STREAM_END)
479 inflateEnd(&zstream);
480 bp->str[bp->len] = 0;
484 inflateEnd(&zstream);
494 for (
i = 0;
i < size_in;
i++)
495 extra +=
in[
i] >= 0x80;
496 if (size_in == SIZE_MAX || extra > SIZE_MAX - size_in - 1)
501 for (
i = 0;
i < size_in;
i++) {
503 *(q++) = 0xC0 | (
in[
i] >> 6);
504 *(q++) = 0x80 | (
in[
i] & 0x3F);
520 const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword);
527 data = keyword_end + 1;
530 if (
data == data_end)
543 text_len = data_end - text;
550 if (!(kw_utf8 && txt_utf8)) {
577 s->width =
s->cur_w = bytestream2_get_be32(&
s->gb);
578 s->height =
s->cur_h = bytestream2_get_be32(&
s->gb);
580 s->cur_w =
s->cur_h =
s->width =
s->height = 0;
584 s->bit_depth = bytestream2_get_byte(&
s->gb);
585 if (
s->bit_depth != 1 &&
s->bit_depth != 2 &&
s->bit_depth != 4 &&
586 s->bit_depth != 8 &&
s->bit_depth != 16) {
590 s->color_type = bytestream2_get_byte(&
s->gb);
591 s->compression_type = bytestream2_get_byte(&
s->gb);
592 if (
s->compression_type) {
596 s->filter_type = bytestream2_get_byte(&
s->gb);
597 s->interlace_type = bytestream2_get_byte(&
s->gb);
602 "compression_type=%d filter_type=%d interlace_type=%d\n",
603 s->width,
s->height,
s->bit_depth,
s->color_type,
604 s->compression_type,
s->filter_type,
s->interlace_type);
608 s->cur_w =
s->cur_h =
s->width =
s->height = 0;
633 size_t byte_depth =
s->bit_depth > 8 ? 2 : 1;
646 s->bits_per_pixel =
s->bit_depth *
s->channels;
647 s->bpp = (
s->bits_per_pixel + 7) >> 3;
648 s->row_size = (
s->cur_w *
s->bits_per_pixel + 7) >> 3;
650 if ((
s->bit_depth == 2 ||
s->bit_depth == 4 ||
s->bit_depth == 8) &&
653 }
else if ((
s->bit_depth == 2 ||
s->bit_depth == 4 ||
s->bit_depth == 8) &&
656 }
else if ((
s->bit_depth == 2 ||
s->bit_depth == 4 ||
s->bit_depth == 8) &&
659 }
else if (
s->bit_depth == 16 &&
662 }
else if (
s->bit_depth == 16 &&
665 }
else if (
s->bit_depth == 16 &&
668 }
else if ((
s->bits_per_pixel == 1 ||
s->bits_per_pixel == 2 ||
s->bits_per_pixel == 4 ||
s->bits_per_pixel == 8) &&
673 }
else if (
s->bit_depth == 8 &&
676 }
else if (
s->bit_depth == 16 &&
681 "Bit depth %d color type %d",
682 s->bit_depth,
s->color_type);
706 "and color type %d with TRNS",
707 s->bit_depth,
s->color_type);
711 s->bpp += byte_depth;
728 if (!
s->interlace_type) {
729 s->crow_size =
s->row_size + 1;
735 s->crow_size =
s->pass_row_size + 1;
737 ff_dlog(avctx,
"row_size=%d crow_size =%d\n",
738 s->row_size,
s->crow_size);
739 s->image_buf = p->
data[0];
743 memcpy(p->
data[1],
s->palette, 256 *
sizeof(uint32_t));
748 if (
s->interlace_type ||
760 s->crow_buf =
s->buffer + 15;
761 s->zstream.avail_out =
s->crow_size;
762 s->zstream.next_out =
s->crow_buf;
769 s->bpp -= byte_depth;
774 s->bpp += byte_depth;
789 if ((length % 3) != 0 || length > 256 * 3)
793 for (
i = 0;
i < n;
i++) {
794 r = bytestream2_get_byte(&
s->gb);
795 g = bytestream2_get_byte(&
s->gb);
796 b = bytestream2_get_byte(&
s->gb);
797 s->palette[
i] = (0xFF
U << 24) | (
r << 16) | (
g << 8) |
b;
800 s->palette[
i] = (0xFFU << 24);
823 if (length > 256 || !(
s->hdr_state &
PNG_PLTE))
826 for (
i = 0;
i < length;
i++) {
827 unsigned v = bytestream2_get_byte(&
s->gb);
828 s->palette[
i] = (
s->palette[
i] & 0x00ffffff) | (v << 24);
836 for (
i = 0;
i < length / 2;
i++) {
838 v = av_mod_uintp2(bytestream2_get_be16(&
s->gb),
s->bit_depth);
840 if (
s->bit_depth > 8)
841 AV_WB16(&
s->transparent_color_be[2 *
i], v);
843 s->transparent_color_be[
i] = v;
862 while ((profile_name[cnt++] = bytestream2_get_byte(&
s->gb)) && cnt < 81);
868 length =
FFMAX(length - cnt, 0);
870 if (bytestream2_get_byte(&
s->gb) != 0) {
875 length =
FFMAX(length - 1, 0);
905 for (j = 0; j <
s->height; j++) {
907 for (k = 7; k >= 1; k--)
908 if ((
s->width&7) >= k)
909 pd[8*
i + k - 1] = (pd[
i]>>8-k) & 1;
910 for (
i--;
i >= 0;
i--) {
911 pd[8*
i + 7]= pd[
i] & 1;
912 pd[8*
i + 6]= (pd[
i]>>1) & 1;
913 pd[8*
i + 5]= (pd[
i]>>2) & 1;
914 pd[8*
i + 4]= (pd[
i]>>3) & 1;
915 pd[8*
i + 3]= (pd[
i]>>4) & 1;
916 pd[8*
i + 2]= (pd[
i]>>5) & 1;
917 pd[8*
i + 1]= (pd[
i]>>6) & 1;
918 pd[8*
i + 0]= pd[
i]>>7;
920 pd +=
s->image_linesize;
922 }
else if (
s->bits_per_pixel == 2) {
925 for (j = 0; j <
s->height; j++) {
928 if ((
s->width&3) >= 3) pd[4*
i + 2]= (pd[
i] >> 2) & 3;
929 if ((
s->width&3) >= 2) pd[4*
i + 1]= (pd[
i] >> 4) & 3;
930 if ((
s->width&3) >= 1) pd[4*
i + 0]= pd[
i] >> 6;
931 for (
i--;
i >= 0;
i--) {
932 pd[4*
i + 3]= pd[
i] & 3;
933 pd[4*
i + 2]= (pd[
i]>>2) & 3;
934 pd[4*
i + 1]= (pd[
i]>>4) & 3;
935 pd[4*
i + 0]= pd[
i]>>6;
938 if ((
s->width&3) >= 3) pd[4*
i + 2]= ((pd[
i]>>2) & 3)*0x55;
939 if ((
s->width&3) >= 2) pd[4*
i + 1]= ((pd[
i]>>4) & 3)*0x55;
940 if ((
s->width&3) >= 1) pd[4*
i + 0]= ( pd[
i]>>6 )*0x55;
941 for (
i--;
i >= 0;
i--) {
942 pd[4*
i + 3]= ( pd[
i] & 3)*0x55;
943 pd[4*
i + 2]= ((pd[
i]>>2) & 3)*0x55;
944 pd[4*
i + 1]= ((pd[
i]>>4) & 3)*0x55;
945 pd[4*
i + 0]= ( pd[
i]>>6 )*0x55;
948 pd +=
s->image_linesize;
950 }
else if (
s->bits_per_pixel == 4) {
953 for (j = 0; j <
s->height; j++) {
956 if (
s->width&1) pd[2*
i+0]= pd[
i]>>4;
957 for (
i--;
i >= 0;
i--) {
958 pd[2*
i + 1] = pd[
i] & 15;
959 pd[2*
i + 0] = pd[
i] >> 4;
962 if (
s->width & 1) pd[2*
i + 0]= (pd[
i] >> 4) * 0x11;
963 for (
i--;
i >= 0;
i--) {
964 pd[2*
i + 1] = (pd[
i] & 15) * 0x11;
965 pd[2*
i + 0] = (pd[
i] >> 4) * 0x11;
968 pd +=
s->image_linesize;
976 uint32_t sequence_number;
977 int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
992 s->last_w =
s->cur_w;
993 s->last_h =
s->cur_h;
994 s->last_x_offset =
s->x_offset;
995 s->last_y_offset =
s->y_offset;
996 s->last_dispose_op =
s->dispose_op;
998 sequence_number = bytestream2_get_be32(&
s->gb);
999 cur_w = bytestream2_get_be32(&
s->gb);
1000 cur_h = bytestream2_get_be32(&
s->gb);
1001 x_offset = bytestream2_get_be32(&
s->gb);
1002 y_offset = bytestream2_get_be32(&
s->gb);
1004 dispose_op = bytestream2_get_byte(&
s->gb);
1005 blend_op = bytestream2_get_byte(&
s->gb);
1008 if (sequence_number == 0 &&
1009 (cur_w !=
s->width ||
1010 cur_h !=
s->height ||
1013 cur_w <= 0 || cur_h <= 0 ||
1014 x_offset < 0 || y_offset < 0 ||
1015 cur_w >
s->width - x_offset|| cur_h >
s->height - y_offset)
1023 if ((sequence_number == 0 || !
s->previous_picture.f->data[0]) &&
1044 s->x_offset = x_offset;
1045 s->y_offset = y_offset;
1046 s->dispose_op = dispose_op;
1047 s->blend_op = blend_op;
1056 uint8_t *pd_last =
s->last_picture.f->data[0];
1060 for (j = 0; j <
s->height; j++) {
1061 for (
i = 0;
i < ls;
i++)
1062 pd[
i] += pd_last[
i];
1063 pd +=
s->image_linesize;
1064 pd_last +=
s->image_linesize;
1070 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
1095 memcpy(
buffer,
s->last_picture.f->data[0],
s->image_linesize *
s->height);
1098 for (y =
s->last_y_offset; y < s->last_y_offset +
s->last_h; ++y)
1099 memset(
buffer +
s->image_linesize * y +
s->bpp *
s->last_x_offset, 0,
s->bpp *
s->last_w);
1101 memcpy(
s->previous_picture.f->data[0],
buffer,
s->image_linesize *
s->height);
1105 memcpy(
buffer,
s->previous_picture.f->data[0],
s->image_linesize *
s->height);
1110 for (y =
s->y_offset; y < s->y_offset +
s->cur_h; ++y) {
1111 size_t row_start =
s->image_linesize * y +
s->bpp *
s->x_offset;
1112 memcpy(
buffer + row_start, p->
data[0] + row_start,
s->bpp *
s->cur_w);
1115 for (y =
s->y_offset; y < s->y_offset +
s->cur_h; ++y) {
1116 uint8_t *foreground = p->
data[0] +
s->image_linesize * y +
s->bpp *
s->x_offset;
1117 uint8_t *background =
buffer +
s->image_linesize * y +
s->bpp *
s->x_offset;
1118 for (x =
s->x_offset; x < s->x_offset +
s->cur_w; ++x, foreground +=
s->bpp, background +=
s->bpp) {
1120 uint8_t foreground_alpha, background_alpha, output_alpha;
1129 foreground_alpha = foreground[3];
1130 background_alpha = background[3];
1134 foreground_alpha = foreground[1];
1135 background_alpha = background[1];
1139 foreground_alpha =
s->palette[foreground[0]] >> 24;
1140 background_alpha =
s->palette[background[0]] >> 24;
1144 if (foreground_alpha == 0)
1147 if (foreground_alpha == 255) {
1148 memcpy(background, foreground,
s->bpp);
1155 background[0] = foreground[0];
1159 output_alpha = foreground_alpha +
FAST_DIV255((255 - foreground_alpha) * background_alpha);
1163 for (
b = 0;
b <
s->bpp - 1; ++
b) {
1164 if (output_alpha == 0) {
1166 }
else if (background_alpha == 255) {
1167 output[
b] =
FAST_DIV255(foreground_alpha * foreground[
b] + (255 - foreground_alpha) * background[
b]);
1169 output[
b] = (255 * foreground_alpha * foreground[
b] + (255 - foreground_alpha) * background_alpha * background[
b]) / (255 * output_alpha);
1173 memcpy(background,
output,
s->bpp);
1179 memcpy(p->
data[0],
buffer,
s->image_linesize *
s->height);
1190 uint32_t
tag, length;
1191 int decode_next_dat = 0;
1217 length = bytestream2_get_be32(&
s->gb);
1224 uint32_t crc_sig =
AV_RB32(
s->gb.buffer + length + 4);
1225 uint32_t crc_cal = ~
av_crc(crc_tab, UINT32_MAX,
s->gb.buffer, length + 4);
1226 if (crc_sig ^ crc_cal) {
1238 tag = bytestream2_get_le32(&
s->gb);
1246 case MKTAG(
'I',
'H',
'D',
'R'):
1247 case MKTAG(
'p',
'H',
'Y',
's'):
1248 case MKTAG(
't',
'E',
'X',
't'):
1249 case MKTAG(
'I',
'D',
'A',
'T'):
1250 case MKTAG(
't',
'R',
'N',
'S'):
1259 case MKTAG(
'I',
'H',
'D',
'R'):
1263 case MKTAG(
'p',
'H',
'Y',
's'):
1267 case MKTAG(
'f',
'c',
'T',
'L'):
1272 decode_next_dat = 1;
1274 case MKTAG(
'f',
'd',
'A',
'T'):
1277 if (!decode_next_dat || length < 4) {
1281 bytestream2_get_be32(&
s->gb);
1284 case MKTAG(
'I',
'D',
'A',
'T'):
1290 case MKTAG(
'P',
'L',
'T',
'E'):
1294 case MKTAG(
't',
'R',
'N',
'S'):
1298 case MKTAG(
't',
'E',
'X',
't'):
1303 case MKTAG(
'z',
'T',
'X',
't'):
1308 case MKTAG(
's',
'T',
'E',
'R'): {
1309 int mode = bytestream2_get_byte(&
s->gb);
1321 "Unknown value in sTER chunk (%d)\n",
mode);
1326 case MKTAG(
'i',
'C',
'C',
'P'): {
1331 case MKTAG(
'c',
'H',
'R',
'M'): {
1342 for (
i = 0;
i < 3;
i++) {
1351 case MKTAG(
'g',
'A',
'M',
'A'): {
1354 int num = bytestream2_get_be32(&
s->gb);
1367 case MKTAG(
'I',
'E',
'N',
'D'):
1393 if (
s->bits_per_pixel <= 4)
1398 size_t byte_depth =
s->bit_depth > 8 ? 2 : 1;
1399 size_t raw_bpp =
s->bpp - byte_depth;
1404 for (y = 0; y <
s->height; ++y) {
1405 uint8_t *row = &
s->image_buf[
s->image_linesize * y];
1407 if (
s->bpp == 2 && byte_depth == 1) {
1409 uint8_t *rowp = &row[1 *
s->width - 1];
1410 int tcolor =
s->transparent_color_be[0];
1411 for (x =
s->width; x > 0; --x) {
1412 *
pixel-- = *rowp == tcolor ? 0 : 0xff;
1415 }
else if (
s->bpp == 4 && byte_depth == 1) {
1417 uint8_t *rowp = &row[3 *
s->width - 1];
1418 int tcolor =
AV_RL24(
s->transparent_color_be);
1419 for (x =
s->width; x > 0; --x) {
1427 for (x =
s->width; x > 0; --x) {
1429 memmove(
pixel, &row[raw_bpp * (x - 1)], raw_bpp);
1431 if (!memcmp(
pixel,
s->transparent_color_be, raw_bpp)) {
1432 memset(&
pixel[raw_bpp], 0, byte_depth);
1434 memset(&
pixel[raw_bpp], 0xff, byte_depth);
1442 if (
s->last_picture.f->data[0]) {
1444 &&
s->last_picture.f->width == p->
width
1445 &&
s->last_picture.f->height== p->
height
1446 &&
s->last_picture.f->format== p->
format
1450 else if (CONFIG_APNG_DECODER &&
1451 s->previous_picture.f->width == p->
width &&
1452 s->previous_picture.f->height== p->
height &&
1453 s->previous_picture.f->format== p->
format &&
1470 #if CONFIG_PNG_DECODER
1472 void *
data,
int *got_frame,
1477 int buf_size = avpkt->
size;
1489 sig = bytestream2_get_be64(&
s->gb);
1496 s->y =
s->has_trns = 0;
1503 s->zstream.opaque =
NULL;
1504 ret = inflateInit(&
s->zstream);
1526 inflateEnd(&
s->zstream);
1532 #if CONFIG_APNG_DECODER
1534 void *
data,
int *got_frame,
1559 if ((
ret = inflateInit(&
s->zstream)) != Z_OK) {
1583 inflateEnd(&
s->zstream);
1588 #if CONFIG_LSCR_DECODER
1590 void *
data,
int *got_frame,
1598 if (avpkt->
size < 2)
1606 nb_blocks = bytestream2_get_le16(gb);
1610 if (
s->last_picture.f->data[0]) {
1616 for (
int b = 0;
b < nb_blocks;
b++) {
1617 int x, y, x2, y2,
w,
h,
left;
1618 uint32_t csize,
size;
1622 s->zstream.opaque =
NULL;
1624 if ((
ret = inflateInit(&
s->zstream)) != Z_OK) {
1632 x = bytestream2_get_le16(gb);
1633 y = bytestream2_get_le16(gb);
1634 x2 = bytestream2_get_le16(gb);
1635 y2 = bytestream2_get_le16(gb);
1636 s->width =
s->cur_w =
w = x2-x;
1637 s->height =
s->cur_h =
h = y2-y;
1639 if (
w <= 0 || x < 0 || x >= avctx->
width ||
w + x > avctx->
width ||
1640 h <= 0 || y < 0 || y >= avctx->
height ||
h + y > avctx->
height) {
1645 size = bytestream2_get_le32(gb);
1647 frame->key_frame = (nb_blocks == 1) &&
1650 (x == 0) && (y == 0);
1653 csize = bytestream2_get_be32(gb);
1654 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
1663 s->row_size =
w * 3;
1677 s->crow_size =
w * 3 + 1;
1678 s->crow_buf =
s->buffer + 15;
1679 s->zstream.avail_out =
s->crow_size;
1680 s->zstream.next_out =
s->crow_buf;
1681 s->image_buf =
frame->data[0] + (avctx->
height - y - 1) *
frame->linesize[0] + x * 3;
1682 s->image_linesize =-
frame->linesize[0];
1693 csize = bytestream2_get_be32(gb);
1694 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
1701 inflateEnd(&
s->zstream);
1712 inflateEnd(&
s->zstream);
1791 if (!
s->previous_picture.f || !
s->last_picture.f || !
s->picture.f) {
1816 s->last_row_size = 0;
1818 s->tmp_row_size = 0;
1823 #if CONFIG_APNG_DECODER
1832 .
decode = decode_frame_apng,
1840 #if CONFIG_PNG_DECODER
1849 .
decode = decode_frame_png,
1857 #if CONFIG_LSCR_DECODER
1866 .
decode = decode_frame_lscr,
static void error(const char *err)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
static av_cold int init(AVCodecContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define FFSWAP(type, a, b)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
unsigned int last_row_size
#define MKTAG(a, b, c, d)
int ff_png_get_nb_channels(int color_type)
@ APNG_DISPOSE_OP_BACKGROUND
void(* add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
This structure describes decoded (raw) audio or video data.
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
static int decode_zbuf(AVBPrint *bp, const uint8_t *data, const uint8_t *data_end)
static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
static uint8_t * iso88591_to_utf8(const uint8_t *in, size_t size_in)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
ThreadFrame previous_picture
unsigned int tmp_row_size
void ff_png_zfree(void *opaque, void *ptr)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before ff_thread_await_progress() has been called on them. reget_buffer() and buffer age optimizations no longer work. *The contents of buffers must not be written to after ff_thread_report_progress() has been called on them. This includes draw_edges(). Porting codecs to frame threading
#define FF_DEBUG_PICT_INFO
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void decode_flush(AVCodecContext *avctx)
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define PNG_FILTER_TYPE_LOCO
int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
enum AVDiscard skip_frame
Skip decoding for selected frames.
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *last, int size, int bpp)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames. The frames must then be freed with ff_thread_release_buffer(). Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
static av_cold int png_dec_end(AVCodecContext *avctx)
enum PNGImageState pic_state
int key_frame
1 -> keyframe, 0-> not
static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
static const uint8_t png_pass_dsp_ymask[NB_PASSES]
#define PNG_COLOR_TYPE_RGB_ALPHA
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int skip_tag(AVIOContext *in, int32_t tag_name)
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
#define YUV2RGB(NAME, TYPE)
static const uint16_t mask[17]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
static void png_handle_row(PNGDecContext *s)
#define PNG_COLOR_TYPE_RGB
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum PNGHeaderState hdr_state
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int percent_missing(PNGDecContext *s)
@ APNG_DISPOSE_OP_PREVIOUS
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
Additional information about the frame packing.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
@ AVDISCARD_ALL
discard all
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
static void flush(AVCodecContext *avctx)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_cold int png_dec_init(AVCodecContext *avctx)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Rational number (pair of numerator and denominator).
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
#define PNG_COLOR_TYPE_GRAY
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
#define AV_EF_EXPLODE
abort decoding on minor error detection
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
const uint8_t ff_png_pass_ymask[NB_PASSES]
static const uint8_t png_pass_mask[NB_PASSES]
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline int bytestream2_tell(GetByteContext *g)
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
static void handle_small_bpp(PNGDecContext *s, AVFrame *p)
#define PNG_FILTER_VALUE_NONE
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
enum AVPictureType pict_type
Picture type of the frame.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length, AVFrame *p)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_EF_IGNORE_ERR
ignore errors and continue
void av_bprint_get_buffer(AVBPrint *buf, unsigned size, unsigned char **mem, unsigned *actual_size)
Allocate bytes in the buffer for external use.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void handle_p_frame_png(PNGDecContext *s, AVFrame *p)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static void png_put_interlaced_row(uint8_t *dst, int width, int bits_per_pixel, int pass, int color_type, const uint8_t *src)
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
#define PNG_FILTER_VALUE_AVG
static AVRational av_make_q(int num, int den)
Create an AVRational.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define PNG_FILTER_VALUE_PAETH
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
#define PNG_FILTER_VALUE_UP
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AVERROR_EXTERNAL
Generic error in an external library.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int flags
A combination of AV_PKT_FLAG values.
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
#define FF_COMPLIANCE_NORMAL
static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, AVDictionary **dict)
av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f)
int interlaced_frame
The content of the picture is interlaced.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
void(* add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
#define PNG_FILTER_VALUE_SUB
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int png_decode_idat(PNGDecContext *s, int length)
#define av_malloc_array(a, b)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define FF_DEBUG_STARTCODE
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
const char * name
Name of the codec implementation.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
enum AVStereo3DType type
How views are packed within the video.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call ff_thread_finish_setup() afterwards. If some code can 't be moved
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
static int decode_plte_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define UNROLL_FILTER(op)
uint8_t transparent_color_be[6]
AVDictionary * metadata
metadata.
void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call.
static const uint8_t png_pass_dsp_mask[NB_PASSES]
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
@ AV_PICTURE_TYPE_P
Predicted.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
#define avpriv_request_sample(...)
Structure to hold side data for an AVFrame.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, AVPacket *avpkt)
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
#define PNG_COLOR_TYPE_PALETTE
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
#define av_fourcc2str(fourcc)