67 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55,
72 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
82 int x,
mask, dsp_mask, j, src_x,
b,
bpp;
89 switch (bits_per_pixel) {
93 memset(dst, 0, (width + 7) >> 3);
95 for (x = 0; x <
width; x++) {
97 if ((dsp_mask << j) & 0x80) {
98 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
99 dst[x >> 3] |= b << (7 - j);
101 if ((mask << j) & 0x80)
106 bpp = bits_per_pixel >> 3;
110 for (x = 0; x <
width; x++) {
112 if ((dsp_mask << j) & 0x80) {
113 *(uint32_t *)d = (s[3] << 24) | (s[0] << 16) | (s[1] << 8) | s[2];
116 if ((mask << j) & 0x80)
120 for (x = 0; x <
width; x++) {
122 if ((dsp_mask << j) & 0x80) {
126 if ((mask << j) & 0x80)
138 for (i = 0; i < w; i++) {
139 int a,
b, c, p, pa, pb, pc;
152 if (pa <= pb && pa <= pc)
162 #define UNROLL1(bpp, op) \ 171 for (; i < size; i += bpp) { \ 172 dst[i + 0] = r = op(r, src[i + 0], last[i + 0]); \ 175 dst[i + 1] = g = op(g, src[i + 1], last[i + 1]); \ 178 dst[i + 2] = b = op(b, src[i + 2], last[i + 2]); \ 181 dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \ 185 #define UNROLL_FILTER(op) \ 188 } else if (bpp == 2) { \ 190 } else if (bpp == 3) { \ 192 } else if (bpp == 4) { \ 195 for (; i < size; i += bpp) { \ 197 for (j = 0; j < bpp; j++) \ 198 dst[i + j] = op(dst[i + j - bpp], src[i + j], last[i + j]); \ 206 int i, p,
r,
g,
b,
a;
208 switch (filter_type) {
210 memcpy(dst, src, size);
213 for (i = 0; i <
bpp; i++)
218 int s = *(
int *)(src + i);
219 p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
220 *(
int *)(dst + i) = p;
223 #define OP_SUB(x, s, l) x + s 231 for (i = 0; i <
bpp; i++) {
235 #define OP_AVG(x, s, l) (((x + l) >> 1) + s) & 0xff 239 for (i = 0; i <
bpp; i++) {
243 if (bpp > 2 && size > 4) {
246 int w = bpp == 4 ? size : size - 3;
260 unsigned int r,
g,
b,
a;
262 for (j = 0; j <
width; j++) {
271 *(uint32_t *) dst = (a << 24) | (r << 16) | (g << 8) |
b;
289 for (i = 0; i <
size; i += 3) {
383 while (s->
zstream.avail_in > 0) {
384 ret = inflate(&s->
zstream, Z_PARTIAL_FLUSH);
385 if (ret != Z_OK && ret != Z_STREAM_END) {
388 if (s->
zstream.avail_out == 0) {
395 if (ret == Z_STREAM_END && s->
zstream.avail_in > 0) {
397 "%d undecompressed bytes left in buffer\n", s->
zstream.avail_in);
405 void *
data,
int *got_frame,
410 int buf_size = avpkt->
size;
413 uint32_t
tag, length;
429 ret = inflateInit(&s->
zstream);
435 length = bytestream2_get_be32(&s->
gb);
436 if (length > 0x7fffffff)
438 tag = bytestream2_get_le32(&s->
gb);
439 av_dlog(avctx,
"png: tag=%c%c%c%c length=%u\n",
442 ((tag >> 16) & 0xff),
443 ((tag >> 24) & 0xff), length);
445 case MKTAG(
'I',
'H',
'D',
'R'):
448 s->
width = bytestream2_get_be32(&s->
gb);
449 s->
height = bytestream2_get_be32(&s->
gb);
461 av_dlog(avctx,
"width=%d height=%d depth=%d color_type=%d " 462 "compression_type=%d filter_type=%d interlace_type=%d\n",
466 case MKTAG(
'I',
'D',
'A',
'T'):
528 av_dlog(avctx,
"row_size=%d crow_size =%d\n",
534 memcpy(p->
data[1], s->
palette, 256 *
sizeof(uint32_t));
560 case MKTAG(
'P',
'L',
'T',
'E'):
564 if ((length % 3) != 0 || length > 256 * 3)
568 for (i = 0; i < n; i++) {
569 r = bytestream2_get_byte(&s->
gb);
570 g = bytestream2_get_byte(&s->
gb);
571 b = bytestream2_get_byte(&s->
gb);
572 s->
palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
580 case MKTAG(
't',
'R',
'N',
'S'):
589 for (i = 0; i < length; i++) {
590 v = bytestream2_get_byte(&s->
gb);
596 case MKTAG(
'I',
'E',
'N',
'D'):
616 for (j = 0; j < s->
height; j++) {
617 for (i = 0; i < s->
width * s->
bpp; i++)
#define PNG_FILTER_VALUE_AVG
static void png_handle_row(PNGDecContext *s)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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)
#define PNG_COLOR_TYPE_RGB
void(* add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define PNG_FILTER_VALUE_PAETH
av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (%s)\, 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)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
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
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int interlaced_frame
The content of the picture is interlaced.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint8_t png_pass_dsp_mask[NB_PASSES]
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
16bit gray, 16bit alpha (big-endian)
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int ff_png_get_nb_channels(int color_type)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int flags
A combination of AV_PKT_FLAG values.
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
const uint8_t ff_mngsig[8]
#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.
av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
the normal 2^n-1 "JPEG" YUV ranges
static av_always_inline int bytestream2_tell(GetByteContext *g)
static av_cold int png_dec_init(AVCodecContext *avctx)
Libavcodec external API header.
#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
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
const uint8_t ff_png_pass_mask[NB_PASSES]
const uint8_t ff_png_pass_ymask[NB_PASSES]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
#define PNG_FILTER_VALUE_NONE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
static const uint8_t png_pass_dsp_ymask[NB_PASSES]
const uint8_t ff_pngsig[8]
void ff_png_zfree(void *opaque, void *ptr)
static av_cold int init(AVCodecParserContext *s)
static void convert_to_rgb32(uint8_t *dst, const uint8_t *src, int width, int loco)
static av_always_inline void convert_to_rgb32_loco(uint8_t *dst, const uint8_t *src, int width, int loco)
static int png_decode_idat(PNGDecContext *s, int length)
int key_frame
1 -> keyframe, 0-> not
int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
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)
#define MKTAG(a, b, c, d)
void * ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define UNROLL_FILTER(op)
static void deloco_rgb24(uint8_t *dst, int size)