[FFmpeg-devel] [PATCH 3/5] png: Clearly separate init, encoding headers and encoding frame

Michael Niedermayer michaelni at gmx.at
Sat Mar 28 22:46:56 CET 2015


On Sat, Mar 28, 2015 at 03:14:23PM +0000, Donny Yang wrote:
> Signed-off-by: Donny Yang <work at kota.moe>
[...]
> -    enc_row_size    = deflateBound(&s->zstream, row_size);
> -    max_packet_size = avctx->height * (int64_t)(enc_row_size +
> -                                       ((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) * 12)
> -                      + FF_MIN_BUFFER_SIZE;
> -    if (max_packet_size > INT_MAX)
> -        return AVERROR(ENOMEM);
> -    if ((ret = ff_alloc_packet2(avctx, pkt, max_packet_size)) < 0)
> -        return ret;
[...]
> +    size_t max_packet_size;
> +
> +    enc_row_size = deflateBound(&s->zstream, (avctx->width * s->bits_per_pixel + 7) >> 3);
> +    max_packet_size =
> +        8 +             // PNGSIG
> +        13 + 12 +       // IHDR
> +        9 + 12 +        // pHYs
> +        1 + 12 +        // sRGB
> +        32 + 12 +       // cHRM
> +        4 + 12 +        // gAMA
> +        256 * 3 + 12 +  // PLTE
> +        256 + 12 +      // tRNS
> +        avctx->height * (
> +            enc_row_size +
> +            12 * ((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) // 12 * ceil(enc_row_size / IOBUF_SIZE)
> +        );
> +
> +    ret = ff_alloc_packet2(avctx, pkt, max_packet_size < FF_MIN_BUFFER_SIZE ? FF_MIN_BUFFER_SIZE : max_packet_size);

changes to how the packet size is calculated should be in a seperate
patch
also all other functional changes should be seperate from a patch
that primarely moves code between init/header and frame encode


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150328/740e9c2d/attachment.asc>


More information about the ffmpeg-devel mailing list