diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-03-22 20:58:56 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-03-22 20:59:58 +0100 |
commit | 6716e6892baf0036f58d02011b8aac8c766970a4 (patch) | |
tree | f2c95e6ee685cbbfbb8238e2c0884fc7995f4ee3 /libavcodec/pngenc.c | |
parent | b1a0d694ea973c4de91fbb1fb46858cff6f6e91b (diff) | |
parent | e9c0b12c2e6dd81d047669178719f68f18741f9c (diff) | |
download | ffmpeg-6716e6892baf0036f58d02011b8aac8c766970a4.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
FATE: Add ZeroCodec test
oggparseogm: fix order of arguments of avpriv_set_pts_info().
pngenc: better upper bound for encoded frame size.
aiffdec: set block_duration to 1 for PCM codecs that are supported in AIFF-C
aiffdec: factor out handling of integer PCM for AIFF-C and plain AIFF
aiffdec: use av_get_audio_frame_duration() to set block_duration for AIFF-C
aiffdec: do not set bit rate if block duration is unknown
wmall: output packet only if we have decoded some samples
Conflicts:
libavcodec/pngenc.c
tests/fate/lossless-video.mak
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngenc.c')
-rw-r--r-- | libavcodec/pngenc.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 0fd29ecb89..5b2c2e436c 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -219,7 +219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, PNGEncContext *s = avctx->priv_data; AVFrame * const p= &s->picture; int bit_depth, color_type, y, len, row_size, ret, is_progressive; - int bits_per_pixel, pass_row_size, max_packet_size; + int bits_per_pixel, pass_row_size, enc_row_size, max_packet_size; int compression_level; uint8_t *ptr, *top; uint8_t *crow_base = NULL, *crow_buf, *crow; @@ -230,15 +230,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, p->pict_type= AV_PICTURE_TYPE_I; p->key_frame= 1; - max_packet_size = avctx->width * avctx->height * 9 + FF_MIN_BUFFER_SIZE; - if ((ret = ff_alloc_packet2(avctx, pkt, max_packet_size)) < 0) { - return ret; - } - - s->bytestream_start = - s->bytestream = pkt->data; - s->bytestream_end = pkt->data + pkt->size; - is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT); switch(avctx->pix_fmt) { case PIX_FMT_RGBA64BE: @@ -293,6 +284,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY); if (ret != Z_OK) return -1; + + enc_row_size = deflateBound(&s->zstream, row_size); + max_packet_size = avctx->height * (enc_row_size + + ((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) * 12) + + FF_MIN_BUFFER_SIZE; + if ((ret = ff_alloc_packet2(avctx, pkt, max_packet_size)) < 0) { + return ret; + } + + s->bytestream_start = + s->bytestream = pkt->data; + s->bytestream_end = pkt->data + pkt->size; + crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED)); if (!crow_base) goto fail; |