FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
pngdec.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/imgutils.h"
#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "apng.h"
#include "png.h"
#include "pngdsp.h"
#include "thread.h"
#include <zlib.h>

Go to the source code of this file.

Data Structures

struct  PNGDecContext
 

Macros

#define UNROLL1(bpp, op)
 
#define UNROLL_FILTER(op)
 
#define OP_SUB(x, s, l)   ((x) + (s))
 
#define OP_AVG(x, s, l)   (((((x) + (l)) >> 1) + (s)) & 0xff)
 
#define YUV2RGB(NAME, TYPE)
 
#define FAST_DIV255(x)   ((((x) + 128) * 257) >> 16)
 

Enumerations

enum  PNGHeaderState { PNG_IHDR = 1 << 0, PNG_PLTE = 1 << 1 }
 
enum  PNGImageState { PNG_IDAT = 1 << 0, PNG_ALLIMAGE = 1 << 1 }
 

Functions

static void png_put_interlaced_row (uint8_t *dst, int width, int bits_per_pixel, int pass, int color_type, const uint8_t *src)
 
void ff_add_png_paeth_prediction (uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
 
static void png_filter_row (PNGDSPContext *dsp, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *last, int size, int bpp)
 
static void png_handle_row (PNGDecContext *s)
 
static int png_decode_idat (PNGDecContext *s, int length)
 
static int decode_zbuf (AVBPrint *bp, const uint8_t *data, const uint8_t *data_end)
 
static uint8_tiso88591_to_utf8 (const uint8_t *in, size_t size_in)
 
static int decode_text_chunk (PNGDecContext *s, uint32_t length, int compressed, AVDictionary **dict)
 
static int decode_ihdr_chunk (AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
 
static int decode_phys_chunk (AVCodecContext *avctx, PNGDecContext *s)
 
static int decode_idat_chunk (AVCodecContext *avctx, PNGDecContext *s, uint32_t length, AVFrame *p)
 
static int decode_plte_chunk (AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
 
static int decode_trns_chunk (AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
 
static int decode_iccp_chunk (PNGDecContext *s, int length, AVFrame *f)
 
static void handle_small_bpp (PNGDecContext *s, AVFrame *p)
 
static int decode_fctl_chunk (AVCodecContext *avctx, PNGDecContext *s, uint32_t length)
 
static void handle_p_frame_png (PNGDecContext *s, AVFrame *p)
 
static int handle_p_frame_apng (AVCodecContext *avctx, PNGDecContext *s, AVFrame *p)
 
static int decode_frame_common (AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, AVPacket *avpkt)
 
static av_cold int png_dec_init (AVCodecContext *avctx)
 
static av_cold int png_dec_end (AVCodecContext *avctx)
 

Variables

static const uint8_t png_pass_mask [NB_PASSES]
 
static const uint8_t png_pass_dsp_ymask [NB_PASSES]
 
static const uint8_t png_pass_dsp_mask [NB_PASSES]
 

Macro Definition Documentation

#define UNROLL1 (   bpp,
  op 
)
Value:
{ \
r = dst[0]; \
if (bpp >= 2) \
g = dst[1]; \
if (bpp >= 3) \
b = dst[2]; \
if (bpp >= 4) \
a = dst[3]; \
for (; i <= size - bpp; i += bpp) { \
dst[i + 0] = r = op(r, src[i + 0], last[i + 0]); \
if (bpp == 1) \
continue; \
dst[i + 1] = g = op(g, src[i + 1], last[i + 1]); \
if (bpp == 2) \
continue; \
dst[i + 2] = b = op(b, src[i + 2], last[i + 2]); \
if (bpp == 3) \
continue; \
dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \
} \
}
const char * g
Definition: vf_curves.c:112
const char * b
Definition: vf_curves.c:113
#define src
Definition: vp8dsp.c:254
ptrdiff_t size
Definition: opengl_enc.c:101
const char * r
Definition: vf_curves.c:111
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:78
if(ret< 0)
Definition: vf_mcdeint.c:279
for(j=16;j >0;--j)

Definition at line 212 of file pngdec.c.

#define UNROLL_FILTER (   op)
Value:
if (bpp == 1) { \
UNROLL1(1, op) \
} else if (bpp == 2) { \
UNROLL1(2, op) \
} else if (bpp == 3) { \
UNROLL1(3, op) \
} else if (bpp == 4) { \
UNROLL1(4, op) \
} \
for (; i < size; i++) { \
dst[i] = op(dst[i - bpp], src[i], last[i]); \
}
#define src
Definition: vp8dsp.c:254
ptrdiff_t size
Definition: opengl_enc.c:101
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:78
#define UNROLL1(bpp, op)
Definition: pngdec.c:212
for(j=16;j >0;--j)

Definition at line 235 of file pngdec.c.

Referenced by png_filter_row().

#define OP_SUB (   x,
  s,
 
)    ((x) + (s))

Referenced by png_filter_row().

#define OP_AVG (   x,
  s,
 
)    (((((x) + (l)) >> 1) + (s)) & 0xff)

Referenced by png_filter_row().

#define YUV2RGB (   NAME,
  TYPE 
)
Value:
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \
int i; \
for (i = 0; i < size; i += 3 + alpha) { \
int g = dst [i + 1]; \
dst[i + 0] += g; \
dst[i + 2] += g; \
} \
}
static float alpha(float a)
const char * g
Definition: vf_curves.c:112
ptrdiff_t size
Definition: opengl_enc.c:101
#define TYPE
Definition: ffv1.h:204
int
for(j=16;j >0;--j)

Definition at line 307 of file pngdec.c.

#define FAST_DIV255 (   x)    ((((x) + 128) * 257) >> 16)

Definition at line 1047 of file pngdec.c.

Referenced by handle_p_frame_apng().

Enumeration Type Documentation

Enumerator
PNG_IHDR 
PNG_PLTE 

Definition at line 39 of file pngdec.c.

Enumerator
PNG_IDAT 
PNG_ALLIMAGE 

Definition at line 44 of file pngdec.c.

Function Documentation

static void png_put_interlaced_row ( uint8_t dst,
int  width,
int  bits_per_pixel,
int  pass,
int  color_type,
const uint8_t src 
)
static

Definition at line 114 of file pngdec.c.

Referenced by png_handle_row().

void ff_add_png_paeth_prediction ( uint8_t dst,
uint8_t src,
uint8_t top,
int  w,
int  bpp 
)

Definition at line 184 of file pngdec.c.

Referenced by ff_pngdsp_init(), and png_filter_row().

static void png_filter_row ( PNGDSPContext dsp,
uint8_t dst,
int  filter_type,
uint8_t src,
uint8_t last,
int  size,
int  bpp 
)
static

Definition at line 250 of file pngdec.c.

Referenced by png_handle_row().

static void png_handle_row ( PNGDecContext s)
static

Definition at line 322 of file pngdec.c.

Referenced by png_decode_idat().

static int png_decode_idat ( PNGDecContext s,
int  length 
)
static

Definition at line 403 of file pngdec.c.

Referenced by decode_idat_chunk().

static int decode_zbuf ( AVBPrint *  bp,
const uint8_t data,
const uint8_t data_end 
)
static

Definition at line 433 of file pngdec.c.

Referenced by decode_iccp_chunk(), and decode_text_chunk().

static uint8_t* iso88591_to_utf8 ( const uint8_t in,
size_t  size_in 
)
static

Definition at line 477 of file pngdec.c.

Referenced by decode_text_chunk().

static int decode_text_chunk ( PNGDecContext s,
uint32_t  length,
int  compressed,
AVDictionary **  dict 
)
static

Definition at line 501 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_ihdr_chunk ( AVCodecContext avctx,
PNGDecContext s,
uint32_t  length 
)
static

Definition at line 549 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_phys_chunk ( AVCodecContext avctx,
PNGDecContext s 
)
static

Definition at line 597 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_idat_chunk ( AVCodecContext avctx,
PNGDecContext s,
uint32_t  length,
AVFrame p 
)
static

Definition at line 613 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_plte_chunk ( AVCodecContext avctx,
PNGDecContext s,
uint32_t  length 
)
static

Definition at line 768 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_trns_chunk ( AVCodecContext avctx,
PNGDecContext s,
uint32_t  length 
)
static

Definition at line 791 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_iccp_chunk ( PNGDecContext s,
int  length,
AVFrame f 
)
static

Definition at line 839 of file pngdec.c.

Referenced by decode_frame_common().

static void handle_small_bpp ( PNGDecContext s,
AVFrame p 
)
static

Definition at line 882 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_fctl_chunk ( AVCodecContext avctx,
PNGDecContext s,
uint32_t  length 
)
static

Definition at line 955 of file pngdec.c.

Referenced by decode_frame_common().

static void handle_p_frame_png ( PNGDecContext s,
AVFrame p 
)
static

Definition at line 1029 of file pngdec.c.

Referenced by decode_frame_common().

static int handle_p_frame_apng ( AVCodecContext avctx,
PNGDecContext s,
AVFrame p 
)
static

Definition at line 1049 of file pngdec.c.

Referenced by decode_frame_common().

static int decode_frame_common ( AVCodecContext avctx,
PNGDecContext s,
AVFrame p,
AVPacket avpkt 
)
static

Definition at line 1162 of file pngdec.c.

static av_cold int png_dec_init ( AVCodecContext avctx)
static

Definition at line 1535 of file pngdec.c.

static av_cold int png_dec_end ( AVCodecContext avctx)
static

Definition at line 1560 of file pngdec.c.

Variable Documentation

const uint8_t png_pass_mask[NB_PASSES]
static
Initial value:
= {
0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
}

Definition at line 97 of file pngdec.c.

Referenced by png_put_interlaced_row().

const uint8_t png_pass_dsp_ymask[NB_PASSES]
static
Initial value:
= {
0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
}

Definition at line 102 of file pngdec.c.

Referenced by png_handle_row().

const uint8_t png_pass_dsp_mask[NB_PASSES]
static
Initial value:
= {
0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
}

Definition at line 107 of file pngdec.c.

Referenced by png_put_interlaced_row().