summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pngenc.c24
-rw-r--r--libavcodec/wmalosslessdec.c4
2 files changed, 16 insertions, 12 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 0fd29ec..5b2c2e4 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;
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 326bfba..2137722 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -1229,7 +1229,7 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
}
*(AVFrame *)data = s->frame;
- *got_frame_ptr = 1;
+ *got_frame_ptr = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
@@ -1243,6 +1243,6 @@ AVCodec ff_wmalossless_decoder = {
.priv_data_size = sizeof(WmallDecodeCtx),
.init = decode_init,
.decode = decode_packet,
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"),
};
OpenPOWER on IntegriCloud