func: static int encode_frame(AVCodecContext *avctx, const AVFrame *pict) PNGEncContext * s = avctx -> priv_data ; int y , len , ret ; int row_size , pass_row_size ; uint8_t * ptr , * top , * crow_buf , * crow ; uint8_t * progressive_buf = NULL ; row_size = ( pict -> width * s -> bits_per_pixel + 7 ) >> 3; crow_base = av_malloc ( ( row_size + 32 ) << ( s -> filter_type == PNG_FILTER_VALUE_MIXED ) ); if ( ! crow_base )  crow_buf = crow_base + 15; if ( s -> is_progressive )  progressive_buf = av_malloc ( row_size + 1 ); top_buf = av_malloc ( row_size + 1 ); if ( ! progressive_buf || ! top_buf )  s -> zstream . avail_out = IOBUF_SIZE; s -> zstream . next_out = s -> buf; if ( s -> is_progressive )  int pass ; for (pass = 0; pass < NB_PASSES; pass++) pass_row_size = ff_png_pass_row_size ( pass , s -> bits_per_pixel , pict -> width ); if ( pass_row_size > 0 )  top = NULL; for (y = 0; y < pict->height; y++) if ( ( ff_png_pass_ymask [ pass ] << ( y & 7 ) ) & 0x80 )  crow = png_choose_filter ( s , crow_buf , progressive_buf , top , pass_row_size , s -> bits_per_pixel >> 3 ); top = progressive_buf; static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t uint8_t *src, uint8_t *top, int size, int bpp) int pred = s -> filter_type ; if ( ! top && pred )  pred = PNG_FILTER_VALUE_SUB; if ( pred == PNG_FILTER_VALUE_MIXED )  png_filter_row ( s , dst + 1 , pred , src , top , size , bpp ); static void png_filter_row(PNGEncContext *c, uint8_t *dst, int uint8_t *src, uint8_t *top, int size, int bpp) switch ( filter_type )  memcpy ( dst , src , size ); sub_left_prediction ( c , dst , src , bpp , size ); static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *src, int bpp, int size) memcpy ( dst , src , bpp ); dst += bpp; * dst ++ = * src1 ++ - * src2 ++; c -> hdsp . diff_bytes ( dst , src1 , src2 , size ); 