24 #include "libavutil/bprint.h"
25 #include "libavutil/imgutils.h"
74 0x01, 0x01, 0x11, 0x11, 0x55, 0x55, 0xff,
79 0xff, 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
84 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
91 int bits_per_pixel,
int pass,
94 int x,
mask, dsp_mask, j, src_x,
b, bpp;
101 switch (bits_per_pixel) {
104 for (x = 0; x <
width; x++) {
106 if ((dsp_mask << j) & 0x80) {
107 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
108 dst[x >> 3] &= 0xFF7F>>j;
109 dst[x >> 3] |= b << (7 - j);
111 if ((mask << j) & 0x80)
117 for (x = 0; x <
width; x++) {
118 int j2 = 2 * (x & 3);
120 if ((dsp_mask << j) & 0x80) {
121 b = (src[src_x >> 2] >> (6 - 2*(src_x & 3))) & 3;
122 dst[x >> 2] &= 0xFF3F>>j2;
123 dst[x >> 2] |= b << (6 - j2);
125 if ((mask << j) & 0x80)
131 for (x = 0; x <
width; x++) {
134 if ((dsp_mask << j) & 0x80) {
135 b = (src[src_x >> 1] >> (4 - 4*(src_x & 1))) & 15;
136 dst[x >> 1] &= 0xFF0F>>j2;
137 dst[x >> 1] |= b << (4 - j2);
139 if ((mask << j) & 0x80)
144 bpp = bits_per_pixel >> 3;
147 for (x = 0; x <
width; x++) {
149 if ((dsp_mask << j) & 0x80) {
153 if ((mask << j) & 0x80)
163 for (i = 0; i < w; i++) {
164 int a,
b,
c, p, pa, pb, pc;
177 if (pa <= pb && pa <= pc)
187 #define UNROLL1(bpp, op) {\
189 if(bpp >= 2) g = dst[1];\
190 if(bpp >= 3) b = dst[2];\
191 if(bpp >= 4) a = dst[3];\
192 for(; i <= size - bpp; i+=bpp) {\
193 dst[i+0] = r = op(r, src[i+0], last[i+0]);\
194 if(bpp == 1) continue;\
195 dst[i+1] = g = op(g, src[i+1], last[i+1]);\
196 if(bpp == 2) continue;\
197 dst[i+2] = b = op(b, src[i+2], last[i+2]);\
198 if(bpp == 3) continue;\
199 dst[i+3] = a = op(a, src[i+3], last[i+3]);\
203 #define UNROLL_FILTER(op)\
204 if(bpp == 1) UNROLL1(1, op)\
205 else if(bpp == 2) UNROLL1(2, op)\
206 else if(bpp == 3) UNROLL1(3, op)\
207 else if(bpp == 4) UNROLL1(4, op)\
208 for (; i < size; i++) {\
209 dst[i] = op(dst[i-bpp], src[i], last[i]);\
216 int i, p,
r,
g,
b,
a;
218 switch (filter_type) {
220 memcpy(dst, src, size);
223 for (i = 0; i < bpp; i++) {
228 for (; i <
size; i += bpp) {
229 int s = *(
int*)(src + i);
230 p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
231 *(
int*)(dst + i) = p;
234 #define OP_SUB(x,s,l) x+s
242 for (i = 0; i < bpp; i++) {
246 #define OP_AVG(x,s,l) (((x + l) >> 1) + s) & 0xff
250 for (i = 0; i < bpp; i++) {
254 if (bpp > 2 && size > 4) {
256 int w = bpp == 4 ? size : size - 3;
267 #define YUV2RGB(NAME, TYPE) \
268 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
271 for (i = 0; i < size; i += 3 + alpha) { \
287 if (!s->interlace_type) {
288 ptr = s->image_buf + s->image_linesize * s->y;
290 last_row = s->last_row;
292 last_row = ptr - s->image_linesize;
295 last_row, s->row_size, s->bpp);
298 if (s->bit_depth == 16) {
299 deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2,
302 deloco_rgb8(ptr - s->image_linesize, s->row_size,
307 if (s->y == s->height) {
310 if (s->bit_depth == 16) {
311 deloco_rgb16((uint16_t *)ptr, s->row_size / 2,
314 deloco_rgb8(ptr, s->row_size,
322 ptr = s->image_buf + s->image_linesize * s->y;
328 png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
329 s->last_row, s->pass_row_size, s->bpp);
331 FFSWAP(
unsigned int, s->last_row_size, s->tmp_row_size);
336 s->color_type, s->last_row);
339 if (s->y == s->height) {
340 memset(s->last_row, 0, s->row_size);
351 s->crow_size = s->pass_row_size + 1;
352 if (s->pass_row_size != 0)
371 while (s->
zstream.avail_in > 0) {
372 ret = inflate(&s->
zstream, Z_PARTIAL_FLUSH);
373 if (ret != Z_OK && ret != Z_STREAM_END) {
377 if (s->
zstream.avail_out == 0) {
384 if (ret == Z_STREAM_END && s->
zstream.avail_in > 0) {
402 zstream.opaque = NULL;
403 if (inflateInit(&zstream) != Z_OK)
405 zstream.next_in = (
unsigned char *)data;
406 zstream.avail_in = data_end -
data;
409 while (zstream.avail_in > 0) {
415 zstream.next_out =
buf;
416 zstream.avail_out = buf_size;
417 ret = inflate(&zstream, Z_PARTIAL_FLUSH);
418 if (ret != Z_OK && ret != Z_STREAM_END) {
422 bp->len += zstream.next_out -
buf;
423 if (ret == Z_STREAM_END)
426 inflateEnd(&zstream);
427 bp->str[bp->len] = 0;
431 inflateEnd(&zstream);
441 for (i = 0; i < size_in; i++)
442 extra += in[i] >= 0x80;
443 if (size_in == SIZE_MAX || extra > SIZE_MAX - size_in - 1)
445 q = out =
av_malloc(size_in + extra + 1);
448 for (i = 0; i < size_in; i++) {
450 *(q++) = 0xC0 | (in[i] >> 6);
451 *(q++) = 0x80 | (in[i] & 0x3F);
467 const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword);
468 uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL;
474 data = keyword_end + 1;
477 if (data == data_end)
490 text_len = data_end - text;
497 if (!(kw_utf8 && txt_utf8)) {
509 void *
data,
int *got_frame,
514 int buf_size = avpkt->
size;
528 sig = bytestream2_get_be64(&s->
gb);
541 ret = inflateInit(&s->
zstream);
552 length = bytestream2_get_be32(&s->
gb);
557 tag = bytestream2_get_le32(&s->
gb);
562 ((tag >> 16) & 0xff),
563 ((tag >> 24) & 0xff), length);
565 case MKTAG(
'I',
'H',
'D',
'R'):
568 s->
width = bytestream2_get_be32(&s->
gb);
569 s->
height = bytestream2_get_be32(&s->
gb);
584 "compression_type=%d filter_type=%d interlace_type=%d\n",
588 case MKTAG(
'p',
'H',
'Y',
's'):
600 case MKTAG(
'I',
'D',
'A',
'T'):
643 "and color type %d\n",
666 av_dlog(avctx,
"row_size=%d crow_size =%d\n",
672 memcpy(p->
data[1], s->
palette, 256 *
sizeof(uint32_t));
698 case MKTAG(
'P',
'L',
'T',
'E'):
702 if ((length % 3) != 0 || length > 256 * 3)
706 for (i = 0; i <
n; i++) {
707 r = bytestream2_get_byte(&s->
gb);
708 g = bytestream2_get_byte(&s->
gb);
709 b = bytestream2_get_byte(&s->
gb);
710 s->
palette[i] = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
712 for (; i < 256; i++) {
719 case MKTAG(
't',
'R',
'N',
'S'):
728 for (i = 0; i <
length; i++) {
729 v = bytestream2_get_byte(&s->
gb);
735 case MKTAG(
't',
'E',
'X',
't'):
740 case MKTAG(
'z',
'T',
'X',
't'):
745 case MKTAG(
'I',
'E',
'N',
'D'):
765 for (j = 0; j < s->
height; j++) {
767 for (k = 7; k >= 1; k--)
768 if ((s->
width&7) >= k)
769 pd[8*i + k - 1] = (pd[i]>>8-k) & 1;
770 for (i--; i >= 0; i--) {
771 pd[8*i + 7]= pd[i] & 1;
772 pd[8*i + 6]= (pd[i]>>1) & 1;
773 pd[8*i + 5]= (pd[i]>>2) & 1;
774 pd[8*i + 4]= (pd[i]>>3) & 1;
775 pd[8*i + 3]= (pd[i]>>4) & 1;
776 pd[8*i + 2]= (pd[i]>>5) & 1;
777 pd[8*i + 1]= (pd[i]>>6) & 1;
778 pd[8*i + 0]= pd[i]>>7;
786 for (j = 0; j < s->
height; j++) {
789 if ((s->
width&3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3;
790 if ((s->
width&3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3;
791 if ((s->
width&3) >= 1) pd[4*i + 0]= pd[i] >> 6;
792 for (i--; i >= 0; i--) {
793 pd[4*i + 3]= pd[i] & 3;
794 pd[4*i + 2]= (pd[i]>>2) & 3;
795 pd[4*i + 1]= (pd[i]>>4) & 3;
796 pd[4*i + 0]= pd[i]>>6;
799 if ((s->
width&3) >= 3) pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
800 if ((s->
width&3) >= 2) pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
801 if ((s->
width&3) >= 1) pd[4*i + 0]= ( pd[i]>>6 )*0x55;
802 for (i--; i >= 0; i--) {
803 pd[4*i + 3]= ( pd[i] & 3)*0x55;
804 pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55;
805 pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55;
806 pd[4*i + 0]= ( pd[i]>>6 )*0x55;
815 for (j = 0; j < s->
height; j++) {
818 if (s->
width&1) pd[2*i+0]= pd[i]>>4;
819 for (i--; i >= 0; i--) {
820 pd[2*i + 1] = pd[i] & 15;
821 pd[2*i + 0] = pd[i] >> 4;
824 if (s->
width & 1) pd[2*i + 0]= (pd[i] >> 4) * 0x11;
825 for (i--; i >= 0; i--) {
826 pd[2*i + 1] = (pd[i] & 15) * 0x11;
827 pd[2*i + 0] = (pd[i] >> 4) * 0x11;
846 for (j = 0; j < s->
height; j++) {
847 for (i = 0; i < s->
width * s->
bpp; i++) {
#define PNG_FILTER_VALUE_AVG
static void png_handle_row(PNGDecContext *s)
This structure describes decoded (raw) audio or video data.
unsigned int tmp_row_size
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int init(AVCodecContext *avctx)
void av_bprint_get_buffer(AVBPrint *buf, unsigned size, unsigned char **mem, unsigned *actual_size)
Allocate bytes in the buffer for external use.
void(* add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
packed RGB 8:8:8, 24bpp, RGBRGB...
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...
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() and children.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define PNG_FILTER_VALUE_PAETH
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define PNG_COLOR_TYPE_RGB_ALPHA
Multithreading support functions.
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
struct AVCodecInternal * internal
Private context used for internal data.
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
int interlaced_frame
The content of the picture is interlaced.
#define FFSWAP(type, a, b)
unsigned int last_row_size
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
void(* add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
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]
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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
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)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_png_get_nb_channels(int color_type)
void av_dict_free(AVDictionary **m)
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)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define FF_DEBUG_STARTCODE
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Libavcodec external API header.
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.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
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...
Buffer to print data progressively.
enum AVPictureType pict_type
Picture type of the frame.
#define PNG_FILTER_VALUE_SUB
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() and chilren.
#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 * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
static int decode_zbuf(AVBPrint *bp, const uint8_t *data, const uint8_t *data_end)
static uint8_t * iso88591_to_utf8(const uint8_t *in, size_t size_in)
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)
#define PNG_FILTER_VALUE_UP
#define PNG_FILTER_TYPE_LOCO
main external API structure.
static void close(AVCodecParserContext *s)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
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.
#define MKTAG(a, b, c, d)
rational number numerator/denominator
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int allocate_progress
Whether to allocate progress for frame threading.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
#define FF_DEBUG_PICT_INFO
#define YUV2RGB(NAME, TYPE)
static const uint8_t png_pass_mask[NB_PASSES]
static av_cold int png_dec_end(AVCodecContext *avctx)
common internal api header.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define PNG_FILTER_VALUE_NONE
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_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
void av_frame_set_metadata(AVFrame *frame, AVDictionary *val)
void ff_png_zfree(void *opaque, void *ptr)
static int png_decode_idat(PNGDecContext *s, int length)
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
#define AVERROR_INVALIDDATA
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
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 int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
8 bit with PIX_FMT_RGB32 palette
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define UNROLL_FILTER(op)