Libav
Data Structures | Macros | Functions | Variables
pngdec.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/imgutils.h"
#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "png.h"
#include "pngdsp.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
 

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 av_always_inline void convert_to_rgb32_loco (uint8_t *dst, const uint8_t *src, int width, int loco)
 
static void convert_to_rgb32 (uint8_t *dst, const uint8_t *src, int width, int loco)
 
static void deloco_rgb24 (uint8_t *dst, int size)
 
static void png_handle_row (PNGDecContext *s)
 
static int png_decode_idat (PNGDecContext *s, int length)
 
static int decode_frame (AVCodecContext *avctx, void *data, int *got_frame, 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_dsp_ymask [NB_PASSES]
 
static const uint8_t png_pass_dsp_mask [NB_PASSES]
 
AVCodec ff_png_decoder
 

Macro Definition Documentation

◆ UNROLL1

#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; 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]); \
} \
}
int size
#define b
Definition: input.c:52
#define r
Definition: input.c:51
#define src
Definition: vp8dsp.c:254
g
Definition: yuv2rgb.c:546
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:76

Definition at line 166 of file pngdec.c.

◆ UNROLL_FILTER

#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) \
} else { \
for (; i < size; i += bpp) { \
int j; \
for (j = 0; j < bpp; j++) \
dst[i + j] = op(dst[i + j - bpp], src[i + j], last[i + j]); \
} \
}
int size
#define src
Definition: vp8dsp.c:254
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:76

Definition at line 189 of file pngdec.c.

Referenced by png_filter_row().

◆ OP_SUB

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

Referenced by png_filter_row().

◆ OP_AVG

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

Referenced by png_filter_row().

Function Documentation

◆ png_put_interlaced_row()

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 82 of file pngdec.c.

Referenced by png_handle_row().

◆ ff_add_png_paeth_prediction()

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

Definition at line 138 of file pngdec.c.

Referenced by ff_pngdsp_init(), and png_filter_row().

◆ 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 207 of file pngdec.c.

Referenced by png_handle_row().

◆ convert_to_rgb32_loco()

static av_always_inline void convert_to_rgb32_loco ( uint8_t dst,
const uint8_t src,
int  width,
int  loco 
)
static

Definition at line 259 of file pngdec.c.

Referenced by convert_to_rgb32().

◆ convert_to_rgb32()

static void convert_to_rgb32 ( uint8_t dst,
const uint8_t src,
int  width,
int  loco 
)
static

Definition at line 281 of file pngdec.c.

Referenced by png_handle_row().

◆ deloco_rgb24()

static void deloco_rgb24 ( uint8_t dst,
int  size 
)
static

Definition at line 290 of file pngdec.c.

Referenced by png_handle_row().

◆ png_handle_row()

static void png_handle_row ( PNGDecContext s)
static

Definition at line 301 of file pngdec.c.

Referenced by png_decode_idat().

◆ png_decode_idat()

static int png_decode_idat ( PNGDecContext s,
int  length 
)
static

Definition at line 379 of file pngdec.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame,
AVPacket avpkt 
)
static

Definition at line 408 of file pngdec.c.

◆ png_dec_init()

static av_cold int png_dec_init ( AVCodecContext avctx)
static

Definition at line 677 of file pngdec.c.

◆ png_dec_end()

static av_cold int png_dec_end ( AVCodecContext avctx)
static

Definition at line 692 of file pngdec.c.

Variable Documentation

◆ png_pass_dsp_ymask

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

Definition at line 70 of file pngdec.c.

Referenced by png_handle_row().

◆ png_pass_dsp_mask

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

Definition at line 75 of file pngdec.c.

Referenced by png_put_interlaced_row().

◆ ff_png_decoder

AVCodec ff_png_decoder
Initial value:
= {
.name = "png",
.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
.priv_data_size = sizeof(PNGDecContext),
.close = png_dec_end,
.capabilities = AV_CODEC_CAP_DR1 ,
}
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: avconv.c:1288
static av_cold int png_dec_init(AVCodecContext *avctx)
Definition: pngdec.c:677
static av_cold int png_dec_end(AVCodecContext *avctx)
Definition: pngdec.c:692
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: pngdec.c:408
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:838

Definition at line 701 of file pngdec.c.