@@ -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);
From: Aman Gupta <aman@tmm1.net> --- libavcodec/j2kenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)