From: Aman Gupta <a...@tmm1.net> --- libavcodec/j2kenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 2135ece540..1eb091af3b 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -995,7 +995,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, Jpeg2000EncoderContext *s = avctx->priv_data; uint8_t *chunkstart, *jp2cstart, *jp2hstart; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) + if (pict->height != s->height || pict->width != s->width) { + s->height = pict->height; + s->width = pict->width; + cleanup(s); + if ((ret=init_tiles(s)) < 0) + return ret; + } + + if ((ret = ff_alloc_packet2(avctx, pkt, s->width*s->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; // init: @@ -1031,8 +1039,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, chunkstart = s->buf; bytestream_put_be32(&s->buf, 0); bytestream_put_buffer(&s->buf, "ihdr", 4); - bytestream_put_be32(&s->buf, avctx->height); - bytestream_put_be32(&s->buf, avctx->width); + bytestream_put_be32(&s->buf, s->height); + bytestream_put_be32(&s->buf, s->width); bytestream_put_be16(&s->buf, s->ncomponents); bytestream_put_byte(&s->buf, s->cbps[0]); bytestream_put_byte(&s->buf, 7); -- 2.14.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel