80 0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
85 0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
90 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
97 int bits_per_pixel,
int pass,
100 int x,
mask, dsp_mask, j, src_x,
b, bpp;
107 switch (bits_per_pixel) {
110 for (x = 0; x <
width; x++) {
112 if ((dsp_mask << j) & 0x80) {
113 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
114 dst[x >> 3] &= 0xFF7F>>j;
115 dst[x >> 3] |= b << (7 - j);
117 if ((mask << j) & 0x80)
123 for (x = 0; x <
width; x++) {
124 int j2 = 2 * (x & 3);
126 if ((dsp_mask << j) & 0x80) {
127 b = (src[src_x >> 2] >> (6 - 2*(src_x & 3))) & 3;
128 dst[x >> 2] &= 0xFF3F>>j2;
129 dst[x >> 2] |= b << (6 - j2);
131 if ((mask << j) & 0x80)
137 for (x = 0; x <
width; x++) {
140 if ((dsp_mask << j) & 0x80) {
141 b = (src[src_x >> 1] >> (4 - 4*(src_x & 1))) & 15;
142 dst[x >> 1] &= 0xFF0F>>j2;
143 dst[x >> 1] |= b << (4 - j2);
145 if ((mask << j) & 0x80)
150 bpp = bits_per_pixel >> 3;
153 for (x = 0; x <
width; x++) {
155 if ((dsp_mask << j) & 0x80) {
159 if ((mask << j) & 0x80)
170 for (i = 0; i < w; i++) {
171 int a,
b,
c, p, pa, pb, pc;
184 if (pa <= pb && pa <= pc)
194 #define UNROLL1(bpp, op) \
203 for (; i <= size - bpp; i += bpp) { \
204 dst[i + 0] = r = op(r, src[i + 0], last[i + 0]); \
207 dst[i + 1] = g = op(g, src[i + 1], last[i + 1]); \
210 dst[i + 2] = b = op(b, src[i + 2], last[i + 2]); \
213 dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \
217 #define UNROLL_FILTER(op) \
220 } else if (bpp == 2) { \
222 } else if (bpp == 3) { \
224 } else if (bpp == 4) { \
227 for (; i < size; i++) { \
228 dst[i] = op(dst[i - bpp], src[i], last[i]); \
235 int i, p,
r,
g,
b,
a;
237 switch (filter_type) {
239 memcpy(dst, src, size);
242 for (i = 0; i < bpp; i++)
246 for (; i <
size; i += bpp) {
247 unsigned s = *(
int *)(src + i);
248 p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
249 *(
int *)(dst + i) = p;
252 #define OP_SUB(x, s, l) ((x) + (s))
260 for (i = 0; i < bpp; i++) {
264 #define OP_AVG(x, s, l) (((((x) + (l)) >> 1) + (s)) & 0xff)
268 for (i = 0; i < bpp; i++) {
272 if (bpp > 2 && size > 4) {
275 int w = (bpp & 3) ? size - 3 : size;
289 #define YUV2RGB(NAME, TYPE) \
290 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
293 for (i = 0; i < size; i += 3 + alpha) { \
294 int g = dst [i + 1]; \
309 if (!s->interlace_type) {
310 ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp;
312 last_row = s->last_row;
314 last_row = ptr - s->image_linesize;
317 last_row, s->row_size, s->bpp);
320 if (s->bit_depth == 16) {
321 deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2,
324 deloco_rgb8(ptr - s->image_linesize, s->row_size,
329 if (s->y == s->cur_h) {
332 if (s->bit_depth == 16) {
333 deloco_rgb16((uint16_t *)ptr, s->row_size / 2,
336 deloco_rgb8(ptr, s->row_size,
344 ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp;
350 png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
351 s->last_row, s->pass_row_size, s->bpp);
353 FFSWAP(
unsigned int, s->last_row_size, s->tmp_row_size);
358 s->color_type, s->last_row);
361 if (s->y == s->cur_h) {
362 memset(s->last_row, 0, s->row_size);
373 s->crow_size = s->pass_row_size + 1;
374 if (s->pass_row_size != 0)
393 while (s->
zstream.avail_in > 0) {
394 ret = inflate(&s->
zstream, Z_PARTIAL_FLUSH);
395 if (ret != Z_OK && ret != Z_STREAM_END) {
399 if (s->
zstream.avail_out == 0) {
406 if (ret == Z_STREAM_END && s->
zstream.avail_in > 0) {
408 "%d undecompressed bytes left in buffer\n", s->
zstream.avail_in);
425 zstream.opaque =
NULL;
426 if (inflateInit(&zstream) != Z_OK)
428 zstream.next_in = (
unsigned char *)data;
429 zstream.avail_in = data_end -
data;
432 while (zstream.avail_in > 0) {
438 zstream.next_out =
buf;
439 zstream.avail_out = buf_size;
440 ret = inflate(&zstream, Z_PARTIAL_FLUSH);
441 if (ret != Z_OK && ret != Z_STREAM_END) {
445 bp->len += zstream.next_out -
buf;
446 if (ret == Z_STREAM_END)
449 inflateEnd(&zstream);
450 bp->str[bp->len] = 0;
454 inflateEnd(&zstream);
464 for (i = 0; i < size_in; i++)
465 extra += in[i] >= 0x80;
466 if (size_in == SIZE_MAX || extra > SIZE_MAX - size_in - 1)
468 q = out =
av_malloc(size_in + extra + 1);
471 for (i = 0; i < size_in; i++) {
473 *(q++) = 0xC0 | (in[i] >> 6);
474 *(q++) = 0x80 | (in[i] & 0x3F);
490 const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword);
497 data = keyword_end + 1;
500 if (data == data_end)
513 text_len = data_end - text;
520 if (!(kw_utf8 && txt_utf8)) {
563 "compression_type=%d filter_type=%d interlace_type=%d\n",
636 "and color type %d\n",
659 av_dlog(avctx,
"row_size=%d crow_size =%d\n",
665 memcpy(p->
data[1], s->
palette, 256 *
sizeof(uint32_t));
699 if ((length % 3) != 0 || length > 256 * 3)
703 for (i = 0; i <
n; i++) {
704 r = bytestream2_get_byte(&s->
gb);
705 g = bytestream2_get_byte(&s->
gb);
706 b = bytestream2_get_byte(&s->
gb);
707 s->
palette[i] = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
727 for (i = 0; i <
length; i++) {
728 v = bytestream2_get_byte(&s->
gb);
741 for (j = 0; j < s->
height; j++) {
743 for (k = 7; k >= 1; k--)
744 if ((s->
width&7) >= k)
745 pd[8*i + k - 1] = (pd[i]>>8-k) & 1;
746 for (i--; i >= 0; i--) {
747 pd[8*i + 7]= pd[i] & 1;
748 pd[8*i + 6]= (pd[i]>>1) & 1;
749 pd[8*i + 5]= (pd[i]>>2) & 1;
750 pd[8*i + 4]= (pd[i]>>3) & 1;
751 pd[8*i + 3]= (pd[i]>>4) & 1;
752 pd[8*i + 2]= (pd[i]>>5) & 1;
753 pd[8*i + 1]= (pd[i]>>6) & 1;
754 pd[8*i + 0]= pd[i]>>7;
761 for (j = 0; j < s->
height; j++) {
764 if ((s->
width&3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3;
765 if ((s->
width&3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3;
766 if ((s->
width&3) >= 1) pd[4*i + 0]= pd[i] >> 6;
767 for (i--; i >= 0; i--) {
768 pd[4*i + 3]= pd[i] & 3;
769 pd[4*i + 2]= (pd[i]>>2) & 3;
770 pd[4*i + 1]= (pd[i]>>4) & 3;
771 pd[4*i + 0]= pd[i]>>6;
774 if ((s->
width&3) >= 3) pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
775 if ((s->
width&3) >= 2) pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
776 if ((s->
width&3) >= 1) pd[4*i + 0]= ( pd[i]>>6 )*0x55;
777 for (i--; i >= 0; i--) {
778 pd[4*i + 3]= ( pd[i] & 3)*0x55;
779 pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
780 pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
781 pd[4*i + 0]= ( pd[i]>>6 )*0x55;
789 for (j = 0; j < s->
height; j++) {
792 if (s->
width&1) pd[2*i+0]= pd[i]>>4;
793 for (i--; i >= 0; i--) {
794 pd[2*i + 1] = pd[i] & 15;
795 pd[2*i + 0] = pd[i] >> 4;
798 if (s->
width & 1) pd[2*i + 0]= (pd[i] >> 4) * 0x11;
799 for (i--; i >= 0; i--) {
800 pd[2*i + 1] = (pd[i] & 15) * 0x11;
801 pd[2*i + 0] = (pd[i] >> 4) * 0x11;
812 uint32_t sequence_number;
813 int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
823 sequence_number = bytestream2_get_be32(&s->
gb);
824 cur_w = bytestream2_get_be32(&s->
gb);
825 cur_h = bytestream2_get_be32(&s->
gb);
826 x_offset = bytestream2_get_be32(&s->
gb);
827 y_offset = bytestream2_get_be32(&s->
gb);
829 dispose_op = bytestream2_get_byte(&s->
gb);
830 blend_op = bytestream2_get_byte(&s->
gb);
833 if (sequence_number == 0 &&
834 (cur_w != s->
width ||
838 cur_w <= 0 || cur_h <= 0 ||
839 x_offset < 0 || y_offset < 0 ||
840 cur_w > s->
width - x_offset|| cur_h > s->
height - y_offset)
844 if (sequence_number == 0) {
872 for (j = 0; j < s->
height; j++) {
873 for (i = 0; i < ls; i++)
882 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
909 memcpy(pd, pd_last, ls);
933 memcpy(pd, pd_last, i);
940 pd[i+ri] = pd_last_region[i+ri];
941 pd[i+gi] = pd_last_region[i+gi];
942 pd[i+bi] = pd_last_region[i+bi];
948 pd[i+ri] =
FAST_DIV255(alpha * pd[i+ri] + (255 - alpha) * pd_last_region[i+ri]);
949 pd[i+gi] =
FAST_DIV255(alpha * pd[i+gi] + (255 - alpha) * pd_last_region[i+gi]);
950 pd[i+bi] =
FAST_DIV255(alpha * pd[i+bi] + (255 - alpha) * pd_last_region[i+bi]);
956 memcpy(pd+i, pd_last+i, ls - i);
964 int end_len = ls - end_offset;
968 memcpy(pd+end_offset, pd_last+end_offset, end_len);
975 memcpy(pd, pd_last, ls);
988 int decode_next_dat = 0;
1009 length = bytestream2_get_be32(&s->
gb);
1015 tag = bytestream2_get_le32(&s->
gb);
1019 ((tag >> 8) & 0xff),
1020 ((tag >> 16) & 0xff),
1021 ((tag >> 24) & 0xff), length);
1023 case MKTAG(
'I',
'H',
'D',
'R'):
1027 case MKTAG(
'p',
'H',
'Y',
's'):
1031 case MKTAG(
'f',
'c',
'T',
'L'):
1036 decode_next_dat = 1;
1038 case MKTAG(
'f',
'd',
'A',
'T'):
1041 if (!decode_next_dat) {
1045 bytestream2_get_be32(&s->
gb);
1048 case MKTAG(
'I',
'D',
'A',
'T'):
1054 case MKTAG(
'P',
'L',
'T',
'E'):
1058 case MKTAG(
't',
'R',
'N',
'S'):
1062 case MKTAG(
't',
'E',
'X',
't'):
1067 case MKTAG(
'z',
'T',
'X',
't'):
1072 case MKTAG(
'I',
'E',
'N',
'D'):
1122 #if CONFIG_PNG_DECODER
1124 void *
data,
int *got_frame,
1129 int buf_size = avpkt->
size;
1141 sig = bytestream2_get_be64(&s->
gb);
1154 ret = inflateInit(&s->
zstream);
1176 #if CONFIG_APNG_DECODER
1178 void *data,
int *got_frame,
1207 if ((ret = inflateInit(&s->
zstream)) != Z_OK) {
1303 #if CONFIG_APNG_DECODER
1312 .
decode = decode_frame_apng,
1319 #if CONFIG_PNG_DECODER
1328 .
decode = decode_frame_png,
static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length, AVFrame *p)
static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
#define PNG_FILTER_VALUE_AVG
static void png_handle_row(PNGDecContext *s)
ThreadFrame previous_picture
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...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
unsigned int tmp_row_size
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_cold int init(AVCodecContext *avctx)
void(* add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, AVDictionary **dict)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional FF_INPUT_BUFFER_PADDING_SIZE at the end w...
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define PNG_COLOR_TYPE_RGB
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
#define PNG_FILTER_VALUE_PAETH
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define PNG_COLOR_TYPE_RGB_ALPHA
8 bit with PIX_FMT_RGB32 palette
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s)
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
void av_frame_set_metadata(AVFrame *frame, AVDictionary *val)
int interlaced_frame
The content of the picture is interlaced.
unsigned int last_row_size
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int decode_plte_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
void(* add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
static double alpha(void *priv, double x, double y)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint8_t png_pass_dsp_mask[NB_PASSES]
16bit gray, 16bit alpha (big-endian)
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, AVPacket *avpkt)
static const uint16_t mask[17]
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void handle_p_frame_png(PNGDecContext *s, AVFrame *p)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define CONFIG_APNG_DECODER
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define FF_COMPLIANCE_NORMAL
int ff_png_get_nb_channels(int color_type)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
Libavcodec external API header.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
A combination of AV_PKT_FLAG values.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
#define FF_DEBUG_STARTCODE
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...
enum AVPictureType pict_type
Picture type of the frame.
#define PNG_FILTER_VALUE_SUB
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#define PNG_COLOR_TYPE_GRAY
static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *last, int size, int bpp)
int width
picture width / height.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
void av_bprint_get_buffer(AVBPrint *buf, unsigned size, unsigned char **mem, unsigned *actual_size)
Allocate bytes in the buffer for external use.
av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
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)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static av_cold int png_dec_init(AVCodecContext *avctx)
static int skip_tag(AVIOContext *in, int32_t tag_name)
#define PNG_FILTER_VALUE_UP
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define PNG_FILTER_TYPE_LOCO
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
const uint8_t ff_png_pass_ymask[NB_PASSES]
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
BYTE int const BYTE int int int height
rational number numerator/denominator
#define CONFIG_PNG_DECODER
int allocate_progress
Whether to allocate progress for frame threading.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_DEBUG_PICT_INFO
static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p)
#define YUV2RGB(NAME, TYPE)
static const uint8_t png_pass_mask[NB_PASSES]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
static av_cold int png_dec_end(AVCodecContext *avctx)
common internal api header.
static void handle_small_bpp(PNGDecContext *s, AVFrame *p)
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define PNG_FILTER_VALUE_NONE
static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
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_ymask[NB_PASSES]
void ff_png_zfree(void *opaque, void *ptr)
static int png_decode_idat(PNGDecContext *s, int length)
struct AVCodecInternal * internal
Private context used for internal data.
int key_frame
1 -> keyframe, 0-> not
int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
static int init_thread_copy(AVCodecContext *avctx)
static void png_put_interlaced_row(uint8_t *dst, int width, int bits_per_pixel, int pass, int color_type, const uint8_t *src)
#define FFSWAP(type, a, b)
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 MKTAG(a, b, c, d)
void * ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
#define AVERROR_EXTERNAL
Generic error in an external library.
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
#define UNROLL_FILTER(op)