101 0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
106 0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
111 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
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) {
260 memcpy(dst, src, size);
263 for (i = 0; i <
bpp; i++)
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) {
296 int w = (bpp & 3) ? size - 3 : size;
310 #define YUV2RGB(NAME, TYPE) \ 311 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \ 314 for (i = 0; i < size - 2; i += 3 + alpha) { \ 315 int g = dst [i + 1]; \ 326 if (s->interlace_type) {
327 return 100 - 100 * s->pass / (
NB_PASSES - 1);
329 return 100 - 100 * s->y / s->cur_h;
363 deloco_rgb16((uint16_t *)ptr, s->
row_size / 2,
423 while (s->
zstream.avail_in > 0) {
425 if (ret != Z_OK && ret != Z_STREAM_END) {
429 if (s->
zstream.avail_out == 0) {
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;
470 ret =
inflate(&zstream, Z_PARTIAL_FLUSH);
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)
498 q = out =
av_malloc(size_in + extra + 1);
501 for (
i = 0;
i < size_in;
i++) {
503 *(q++) = 0xC0 | (in[
i] >> 6);
504 *(q++) = 0x80 | (in[
i] & 0x3F);
518 const uint8_t *data_end = data + length;
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)) {
602 "compression_type=%d filter_type=%d interlace_type=%d\n",
633 size_t byte_depth = s->
bit_depth > 8 ? 2 : 1;
683 "Bit depth %d color type %d",
708 "and color type %d with TRNS",
713 s->
bpp += byte_depth;
739 ff_dlog(avctx,
"row_size=%d crow_size =%d\n",
745 memcpy(p->
data[1], s->
palette, 256 *
sizeof(uint32_t));
771 s->
bpp -= byte_depth;
776 s->
bpp += byte_depth;
791 if ((length % 3) != 0 || length > 256 * 3)
795 for (i = 0; i < n; i++) {
796 r = bytestream2_get_byte(&s->
gb);
797 g = bytestream2_get_byte(&s->
gb);
798 b = bytestream2_get_byte(&s->
gb);
799 s->
palette[
i] = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
828 for (i = 0; i < length; i++) {
829 unsigned v = bytestream2_get_byte(&s->
gb);
838 for (i = 0; i < length / 2; i++) {
840 v = av_mod_uintp2(bytestream2_get_be16(&s->
gb), s->
bit_depth);
864 while ((profile_name[cnt++] = bytestream2_get_byte(&s->
gb)) && cnt < 81);
870 length =
FFMAX(length - cnt, 0);
872 if (bytestream2_get_byte(&s->
gb) != 0) {
877 length =
FFMAX(length - 1, 0);
893 memcpy(sd->
data, data, bp.len);
907 for (j = 0; j < s->
height; j++) {
909 for (k = 7; k >= 1; k--)
910 if ((s->
width&7) >= k)
911 pd[8*i + k - 1] = (pd[
i]>>8-k) & 1;
912 for (i--; i >= 0; i--) {
913 pd[8*i + 7]= pd[
i] & 1;
914 pd[8*i + 6]= (pd[
i]>>1) & 1;
915 pd[8*i + 5]= (pd[
i]>>2) & 1;
916 pd[8*i + 4]= (pd[
i]>>3) & 1;
917 pd[8*i + 3]= (pd[
i]>>4) & 1;
918 pd[8*i + 2]= (pd[
i]>>5) & 1;
919 pd[8*i + 1]= (pd[
i]>>6) & 1;
920 pd[8*i + 0]= pd[
i]>>7;
927 for (j = 0; j < s->
height; j++) {
930 if ((s->
width&3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3;
931 if ((s->
width&3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3;
932 if ((s->
width&3) >= 1) pd[4*i + 0]= pd[i] >> 6;
933 for (i--; i >= 0; i--) {
934 pd[4*i + 3]= pd[
i] & 3;
935 pd[4*i + 2]= (pd[
i]>>2) & 3;
936 pd[4*i + 1]= (pd[
i]>>4) & 3;
937 pd[4*i + 0]= pd[
i]>>6;
940 if ((s->
width&3) >= 3) pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
941 if ((s->
width&3) >= 2) pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
942 if ((s->
width&3) >= 1) pd[4*i + 0]= ( pd[i]>>6 )*0x55;
943 for (i--; i >= 0; i--) {
944 pd[4*i + 3]= ( pd[
i] & 3)*0x55;
945 pd[4*i + 2]= ((pd[
i]>>2) & 3)*0x55;
946 pd[4*i + 1]= ((pd[
i]>>4) & 3)*0x55;
947 pd[4*i + 0]= ( pd[
i]>>6 )*0x55;
955 for (j = 0; j < s->
height; j++) {
958 if (s->
width&1) pd[2*i+0]= pd[
i]>>4;
959 for (i--; i >= 0; i--) {
960 pd[2*i + 1] = pd[
i] & 15;
961 pd[2*i + 0] = pd[
i] >> 4;
964 if (s->
width & 1) pd[2*i + 0]= (pd[
i] >> 4) * 0x11;
965 for (i--; i >= 0; i--) {
966 pd[2*i + 1] = (pd[
i] & 15) * 0x11;
967 pd[2*i + 0] = (pd[
i] >> 4) * 0x11;
978 uint32_t sequence_number;
1000 sequence_number = bytestream2_get_be32(&s->
gb);
1001 cur_w = bytestream2_get_be32(&s->
gb);
1002 cur_h = bytestream2_get_be32(&s->
gb);
1003 x_offset = bytestream2_get_be32(&s->
gb);
1004 y_offset = bytestream2_get_be32(&s->
gb);
1006 dispose_op = bytestream2_get_byte(&s->
gb);
1007 blend_op = bytestream2_get_byte(&s->
gb);
1010 if (sequence_number == 0 &&
1011 (cur_w != s->
width ||
1015 cur_w <= 0 || cur_h <= 0 ||
1016 x_offset < 0 || y_offset < 0 ||
1017 cur_w > s->
width - x_offset|| cur_h > s->
height - y_offset)
1062 for (j = 0; j < s->
height; j++) {
1063 for (i = 0; i < ls; i++)
1064 pd[i] += pd_last[i];
1072 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16) 1114 memcpy(buffer + row_start, p->
data[0] + row_start, s->
bpp * s->
cur_w);
1122 uint8_t foreground_alpha, background_alpha, output_alpha;
1131 foreground_alpha = foreground[3];
1132 background_alpha = background[3];
1136 foreground_alpha = foreground[1];
1137 background_alpha = background[1];
1141 foreground_alpha = s->
palette[foreground[0]] >> 24;
1142 background_alpha = s->
palette[background[0]] >> 24;
1146 if (foreground_alpha == 0)
1149 if (foreground_alpha == 255) {
1150 memcpy(background, foreground, s->
bpp);
1157 background[0] = foreground[0];
1161 output_alpha = foreground_alpha +
FAST_DIV255((255 - foreground_alpha) * background_alpha);
1165 for (b = 0; b < s->
bpp - 1; ++
b) {
1166 if (output_alpha == 0) {
1168 }
else if (background_alpha == 255) {
1169 output[
b] =
FAST_DIV255(foreground_alpha * foreground[b] + (255 - foreground_alpha) * background[b]);
1171 output[
b] = (255 * foreground_alpha * foreground[
b] + (255 - foreground_alpha) * background_alpha * background[b]) / (255 * output_alpha);
1174 output[
b] = output_alpha;
1175 memcpy(background, output, s->
bpp);
1192 uint32_t
tag, length;
1193 int decode_next_dat = 0;
1219 length = bytestream2_get_be32(&s->
gb);
1227 uint32_t crc_cal = ~
av_crc(crc_tab, UINT32_MAX, s->
gb.
buffer, length + 4);
1228 if (crc_sig ^ crc_cal) {
1240 tag = bytestream2_get_le32(&s->
gb);
1248 case MKTAG(
'I',
'H',
'D',
'R'):
1249 case MKTAG(
'p',
'H',
'Y',
's'):
1250 case MKTAG(
't',
'E',
'X',
't'):
1251 case MKTAG(
'I',
'D',
'A',
'T'):
1252 case MKTAG(
't',
'R',
'N',
'S'):
1261 case MKTAG(
'I',
'H',
'D',
'R'):
1265 case MKTAG(
'p',
'H',
'Y',
's'):
1269 case MKTAG(
'f',
'c',
'T',
'L'):
1274 decode_next_dat = 1;
1276 case MKTAG(
'f',
'd',
'A',
'T'):
1279 if (!decode_next_dat || length < 4) {
1283 bytestream2_get_be32(&s->
gb);
1286 case MKTAG(
'I',
'D',
'A',
'T'):
1292 case MKTAG(
'P',
'L',
'T',
'E'):
1296 case MKTAG(
't',
'R',
'N',
'S'):
1300 case MKTAG(
't',
'E',
'X',
't'):
1305 case MKTAG(
'z',
'T',
'X',
't'):
1310 case MKTAG(
's',
'T',
'E',
'R'): {
1311 int mode = bytestream2_get_byte(&s->
gb);
1318 if (mode == 0 || mode == 1) {
1323 "Unknown value in sTER chunk (%d)\n", mode);
1328 case MKTAG(
'i',
'C',
'C',
'P'): {
1333 case MKTAG(
'c',
'H',
'R',
'M'): {
1344 for (i = 0; i < 3; i++) {
1353 case MKTAG(
'g',
'A',
'M',
'A'): {
1356 int num = bytestream2_get_be32(&s->
gb);
1369 case MKTAG(
'I',
'E',
'N',
'D'):
1403 size_t byte_depth = s->
bit_depth > 8 ? 2 : 1;
1404 size_t raw_bpp = s->
bpp - byte_depth;
1409 for (y = 0; y < s->
height; ++
y) {
1412 if (s->
bpp == 2 && byte_depth == 1) {
1416 for (x = s->
width; x > 0; --x) {
1417 *pixel-- = *rowp == tcolor ? 0 : 0xff;
1420 }
else if (s->
bpp == 4 && byte_depth == 1) {
1424 for (x = s->
width; x > 0; --x) {
1425 *pixel-- =
AV_RL24(rowp-2) == tcolor ? 0 : 0xff;
1432 for (x = s->
width; x > 0; --x) {
1434 memmove(pixel, &row[raw_bpp * (x - 1)], raw_bpp);
1437 memset(&pixel[raw_bpp], 0, byte_depth);
1439 memset(&pixel[raw_bpp], 0xff, byte_depth);
1475 #if CONFIG_PNG_DECODER 1477 void *
data,
int *got_frame,
1482 int buf_size = avpkt->
size;
1494 sig = bytestream2_get_be64(&s->
gb);
1509 ret = inflateInit(&s->
zstream);
1537 #if CONFIG_APNG_DECODER 1539 void *
data,
int *got_frame,
1564 if ((ret = inflateInit(&s->
zstream)) != Z_OK) {
1593 #if CONFIG_LSCR_DECODER 1595 void *
data,
int *got_frame,
1601 int ret, nb_blocks,
offset = 0;
1603 if (avpkt->
size < 2)
1611 nb_blocks = bytestream2_get_le16(gb);
1621 for (
int b = 0;
b < nb_blocks;
b++) {
1622 int x,
y, x2, y2,
w,
h, left;
1623 uint32_t csize,
size;
1629 if ((ret = inflateInit(&s->
zstream)) != Z_OK) {
1637 x = bytestream2_get_le16(gb);
1638 y = bytestream2_get_le16(gb);
1639 x2 = bytestream2_get_le16(gb);
1640 y2 = bytestream2_get_le16(gb);
1644 if (w <= 0 || x < 0 || x >= avctx->
width || w + x > avctx->
width ||
1645 h <= 0 || y < 0 || y >= avctx->
height || h + y > avctx->
height) {
1650 size = bytestream2_get_le32(gb);
1653 (w == avctx->
width) &&
1655 (x == 0) && (y == 0);
1658 csize = bytestream2_get_be32(gb);
1659 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
1698 csize = bytestream2_get_be32(gb);
1699 if (bytestream2_get_le32(gb) !=
MKTAG(
'I',
'D',
'A',
'T')) {
1828 #if CONFIG_APNG_DECODER 1837 .
decode = decode_frame_apng,
1845 #if CONFIG_PNG_DECODER 1854 .
decode = decode_frame_png,
1862 #if CONFIG_LSCR_DECODER 1871 .
decode = decode_frame_lscr,
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
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.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
This structure describes decoded (raw) audio or video data.
static void flush(AVCodecContext *avctx)
unsigned int tmp_row_size
8 bits gray, 8 bits alpha
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
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.
static av_cold int init(AVCodecContext *avctx)
#define avpriv_request_sample(...)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, AVDictionary **dict)
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 AV_INPUT_BUFFER_PADDING_SIZE at the end w...
enum PNGImageState pic_state
Views are next to each other.
#define PNG_COLOR_TYPE_RGB
static void error(const char *err)
void(* add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
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
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#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
enum AVDiscard skip_frame
Skip decoding for selected frames.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int percent_missing(PNGDecContext *s)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define PNG_COLOR_TYPE_RGB_ALPHA
8 bits with AV_PIX_FMT_RGB32 palette
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
#define FF_DEBUG_PICT_INFO
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.
Public header for CRC hash function implementation.
static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s)
Structure to hold side data for an AVFrame.
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
AVDictionary * metadata
metadata.
static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f)
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 FF_CODEC_CAP_ALLOCATE_PROGRESS
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int decode_plte_chunk(AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint8_t png_pass_dsp_mask[NB_PASSES]
int flags
Additional information about the frame packing.
16 bits gray, 16 bits alpha (big-endian)
#define AV_BPRINT_SIZE_UNLIMITED
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]
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.
int ff_png_get_nb_channels(int color_type)
#define av_fourcc2str(fourcc)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
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.
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
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.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#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.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
#define AV_EF_EXPLODE
abort decoding on minor error detection
packed RGB 8:8:8, 24bpp, BGRBGR...
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)
the normal 2^n-1 "JPEG" YUV ranges
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)
enum AVStereo3DType type
How views are packed within the video.
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
Libavcodec external API header.
enum PNGHeaderState hdr_state
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
static AVRational av_make_q(int num, int den)
Create an AVRational.
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').
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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.
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)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
#define FF_COMPLIANCE_NORMAL
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
Rational number (pair of numerator and denominator).
#define CONFIG_PNG_DECODER
uint8_t transparent_color_be[6]
#define AV_EF_IGNORE_ERR
ignore errors and continue
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p)
#define YUV2RGB(NAME, TYPE)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static const uint8_t png_pass_mask[NB_PASSES]
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)
void(* add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
common internal api header.
static void handle_small_bpp(PNGDecContext *s, AVFrame *p)
#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...
#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)
#define FF_DEBUG_STARTCODE
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
#define av_malloc_array(a, b)
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.
static void decode_flush(AVCodecContext *avctx)
#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.
mode
Use these values in ebur128_init (or'ed).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
#define UNROLL_FILTER(op)