72 0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
77 0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
82 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
89 int bits_per_pixel,
int pass,
92 int x,
mask, dsp_mask, j, src_x,
b, bpp;
99 switch (bits_per_pixel) {
102 for (x = 0; x <
width; x++) {
104 if ((dsp_mask << j) & 0x80) {
105 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
106 dst[x >> 3] &= 0xFF7F>>j;
107 dst[x >> 3] |= b << (7 - j);
109 if ((mask << j) & 0x80)
115 for (x = 0; x <
width; x++) {
116 int j2 = 2 * (x & 3);
118 if ((dsp_mask << j) & 0x80) {
119 b = (src[src_x >> 2] >> (6 - 2*(src_x & 3))) & 3;
120 dst[x >> 2] &= 0xFF3F>>j2;
121 dst[x >> 2] |= b << (6 - j2);
123 if ((mask << j) & 0x80)
129 for (x = 0; x <
width; x++) {
132 if ((dsp_mask << j) & 0x80) {
133 b = (src[src_x >> 1] >> (4 - 4*(src_x & 1))) & 15;
134 dst[x >> 1] &= 0xFF0F>>j2;
135 dst[x >> 1] |= b << (4 - j2);
137 if ((mask << j) & 0x80)
142 bpp = bits_per_pixel >> 3;
145 for (x = 0; x <
width; x++) {
147 if ((dsp_mask << j) & 0x80) {
151 if ((mask << j) & 0x80)
161 for (i = 0; i < w; i++) {
162 int a,
b,
c, p, pa, pb, pc;
175 if (pa <= pb && pa <= pc)
185 #define UNROLL1(bpp, op) {\
187 if(bpp >= 2) g = dst[1];\
188 if(bpp >= 3) b = dst[2];\
189 if(bpp >= 4) a = dst[3];\
190 for(; i <= size - bpp; i+=bpp) {\
191 dst[i+0] = r = op(r, src[i+0], last[i+0]);\
192 if(bpp == 1) continue;\
193 dst[i+1] = g = op(g, src[i+1], last[i+1]);\
194 if(bpp == 2) continue;\
195 dst[i+2] = b = op(b, src[i+2], last[i+2]);\
196 if(bpp == 3) continue;\
197 dst[i+3] = a = op(a, src[i+3], last[i+3]);\
201 #define UNROLL_FILTER(op)\
202 if(bpp == 1) UNROLL1(1, op)\
203 else if(bpp == 2) UNROLL1(2, op)\
204 else if(bpp == 3) UNROLL1(3, op)\
205 else if(bpp == 4) UNROLL1(4, op)\
206 for (; i < size; i++) {\
207 dst[i] = op(dst[i-bpp], src[i], last[i]);\
214 int i, p,
r,
g,
b,
a;
216 switch (filter_type) {
218 memcpy(dst, src, size);
221 for (i = 0; i < bpp; i++) {
226 for (; i <
size; i += bpp) {
227 int s = *(
int*)(src + i);
228 p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
229 *(
int*)(dst + i) = p;
232 #define OP_SUB(x,s,l) x+s
240 for (i = 0; i < bpp; i++) {
244 #define OP_AVG(x,s,l) (((x + l) >> 1) + s) & 0xff
248 for (i = 0; i < bpp; i++) {
252 if (bpp > 2 && size > 4) {
254 int w = bpp == 4 ? size : size - 3;
265 #define YUV2RGB(NAME, TYPE) \
266 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
269 for (i = 0; i < size; i += 3 + alpha) { \
285 if (!s->interlace_type) {
286 ptr = s->image_buf + s->image_linesize * s->y;
288 last_row = s->last_row;
290 last_row = ptr - s->image_linesize;
293 last_row, s->row_size, s->bpp);
296 if (s->bit_depth == 16) {
297 deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2,
300 deloco_rgb8(ptr - s->image_linesize, s->row_size,
305 if (s->y == s->height) {
308 if (s->bit_depth == 16) {
309 deloco_rgb16((uint16_t *)ptr, s->row_size / 2,
312 deloco_rgb8(ptr, s->row_size,
320 ptr = s->image_buf + s->image_linesize * s->y;
326 png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
327 s->last_row, s->pass_row_size, s->bpp);
333 s->color_type, s->last_row);
336 if (s->y == s->height) {
337 memset(s->last_row, 0, s->row_size);
348 s->crow_size = s->pass_row_size + 1;
349 if (s->pass_row_size != 0)
368 while (s->
zstream.avail_in > 0) {
369 ret = inflate(&s->
zstream, Z_PARTIAL_FLUSH);
370 if (ret != Z_OK && ret != Z_STREAM_END) {
374 if (s->
zstream.avail_out == 0) {
395 zstream.opaque = NULL;
396 if (inflateInit(&zstream) != Z_OK)
398 zstream.next_in = (
unsigned char *)data;
399 zstream.avail_in = data_end -
data;
402 while (zstream.avail_in > 0) {
408 zstream.next_out =
buf;
409 zstream.avail_out = buf_size;
410 ret = inflate(&zstream, Z_PARTIAL_FLUSH);
411 if (ret != Z_OK && ret != Z_STREAM_END) {
415 bp->len += zstream.next_out -
buf;
416 if (ret == Z_STREAM_END)
419 inflateEnd(&zstream);
420 bp->str[bp->len] = 0;
424 inflateEnd(&zstream);
434 for (i = 0; i < size_in; i++)
435 extra += in[i] >= 0x80;
436 if (size_in == SIZE_MAX || extra > SIZE_MAX - size_in - 1)
438 q = out =
av_malloc(size_in + extra + 1);
441 for (i = 0; i < size_in; i++) {
443 *(q++) = 0xC0 | (in[i] >> 6);
444 *(q++) = 0x80 | (in[i] & 0x3F);
460 const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword);
461 uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL;
467 data = keyword_end + 1;
470 if (data == data_end)
483 text_len = data_end - text;
490 if (!(kw_utf8 && txt_utf8)) {
502 void *
data,
int *got_frame,
507 int buf_size = avpkt->
size;
518 sig = bytestream2_get_be64(&s->
gb);
531 ret = inflateInit(&s->
zstream);
542 length = bytestream2_get_be32(&s->
gb);
547 tag = bytestream2_get_le32(&s->
gb);
552 ((tag >> 16) & 0xff),
553 ((tag >> 24) & 0xff), length);
555 case MKTAG(
'I',
'H',
'D',
'R'):
558 s->
width = bytestream2_get_be32(&s->
gb);
559 s->
height = bytestream2_get_be32(&s->
gb);
574 "compression_type=%d filter_type=%d interlace_type=%d\n",
578 case MKTAG(
'p',
'H',
'Y',
's'):
590 case MKTAG(
'I',
'D',
'A',
'T'):
633 "and color type %d\n",
654 av_dlog(avctx,
"row_size=%d crow_size =%d\n",
660 memcpy(p->
data[1], s->
palette, 256 *
sizeof(uint32_t));
686 case MKTAG(
'P',
'L',
'T',
'E'):
690 if ((length % 3) != 0 || length > 256 * 3)
694 for (i = 0; i <
n; i++) {
695 r = bytestream2_get_byte(&s->
gb);
696 g = bytestream2_get_byte(&s->
gb);
697 b = bytestream2_get_byte(&s->
gb);
698 s->
palette[i] = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
700 for (; i < 256; i++) {
707 case MKTAG(
't',
'R',
'N',
'S'):
716 for (i = 0; i <
length; i++) {
717 v = bytestream2_get_byte(&s->
gb);
723 case MKTAG(
't',
'E',
'X',
't'):
728 case MKTAG(
'z',
'T',
'X',
't'):
733 case MKTAG(
'I',
'E',
'N',
'D'):
753 for (j = 0; j < s->
height; j++) {
755 for (k = 7; k >= 1; k--)
756 if ((s->
width&7) >= k)
757 pd[8*i + k - 1] = (pd[i]>>8-k) & 1;
758 for (i--; i >= 0; i--) {
759 pd[8*i + 7]= pd[i] & 1;
760 pd[8*i + 6]= (pd[i]>>1) & 1;
761 pd[8*i + 5]= (pd[i]>>2) & 1;
762 pd[8*i + 4]= (pd[i]>>3) & 1;
763 pd[8*i + 3]= (pd[i]>>4) & 1;
764 pd[8*i + 2]= (pd[i]>>5) & 1;
765 pd[8*i + 1]= (pd[i]>>6) & 1;
766 pd[8*i + 0]= pd[i]>>7;
774 for (j = 0; j < s->
height; j++) {
777 if ((s->
width&3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3;
778 if ((s->
width&3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3;
779 if ((s->
width&3) >= 1) pd[4*i + 0]= pd[i] >> 6;
780 for (i--; i >= 0; i--) {
781 pd[4*i + 3]= pd[i] & 3;
782 pd[4*i + 2]= (pd[i]>>2) & 3;
783 pd[4*i + 1]= (pd[i]>>4) & 3;
784 pd[4*i + 0]= pd[i]>>6;
787 if ((s->
width&3) >= 3) pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
788 if ((s->
width&3) >= 2) pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
789 if ((s->
width&3) >= 1) pd[4*i + 0]= ( pd[i]>>6 )*0x55;
790 for (i--; i >= 0; i--) {
791 pd[4*i + 3]= ( pd[i] & 3)*0x55;
792 pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
793 pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
794 pd[4*i + 0]= ( pd[i]>>6 )*0x55;
803 for (j = 0; j < s->
height; j++) {
806 if (s->
width&1) pd[2*i+0]= pd[i]>>4;
807 for (i--; i >= 0; i--) {
808 pd[2*i + 1] = pd[i] & 15;
809 pd[2*i + 0] = pd[i] >> 4;
812 if (s->
width & 1) pd[2*i + 0]= (pd[i] >> 4) * 0x11;
813 for (i--; i >= 0; i--) {
814 pd[2*i + 1] = (pd[i] & 15) * 0x11;
815 pd[2*i + 0] = (pd[i] >> 4) * 0x11;
833 for (j = 0; j < s->
height; j++) {
834 for (i = 0; i < s->
width * s->
bpp; i++) {