summaryrefslogtreecommitdiff
path: root/libavcodec/j2kdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/j2kdec.c')
-rw-r--r--libavcodec/j2kdec.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index 53c4f079f8..fef03487d0 100644
--- a/libavcodec/j2kdec.c
+++ b/libavcodec/j2kdec.c
@@ -49,7 +49,7 @@ typedef struct {
typedef struct {
AVCodecContext *avctx;
- AVFrame picture;
+ AVFrame *picture;
GetByteContext g;
int width, height; ///< image width and height
@@ -281,14 +281,12 @@ static int get_siz(J2kDecoderContext *s)
break;
}
- if (s->picture.data[0])
- s->avctx->release_buffer(s->avctx, &s->picture);
- if ((ret = ff_get_buffer(s->avctx, &s->picture)) < 0)
+ if ((ret = ff_get_buffer(s->avctx, s->picture, 0)) < 0)
return ret;
- s->picture.pict_type = AV_PICTURE_TYPE_I;
- s->picture.key_frame = 1;
+ s->picture->pict_type = AV_PICTURE_TYPE_I;
+ s->picture->key_frame = 1;
return 0;
}
@@ -859,7 +857,7 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++){
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
- line = s->picture.data[0] + y * s->picture.linesize[0];
+ line = s->picture->data[0] + y * s->picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){
uint8_t *dst;
@@ -875,13 +873,13 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
*dst = *src[compno]++;
dst += s->ncomponents;
}
- line += s->picture.linesize[0];
+ line += s->picture->linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
- line = s->picture.data[0] + y * s->picture.linesize[0];
+ line = s->picture->data[0] + y * s->picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
@@ -896,7 +894,7 @@ static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
*dst = val;
dst += s->ncomponents;
}
- line += s->picture.linesize[0];
+ line += s->picture->linesize[0];
}
}
}
@@ -1025,6 +1023,8 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame *picture = data;
int tileno, ret;
+ s->picture = picture;
+
bytestream2_init(&s->g, avpkt->data, avpkt->size);
s->curtileno = -1;
@@ -1062,7 +1062,6 @@ static int decode_frame(AVCodecContext *avctx,
cleanup(s);
*got_frame = 1;
- *picture = s->picture;
return bytestream2_tell(&s->g);
@@ -1076,8 +1075,6 @@ static av_cold int j2kdec_init(AVCodecContext *avctx)
J2kDecoderContext *s = avctx->priv_data;
s->avctx = avctx;
- avcodec_get_frame_defaults((AVFrame*)&s->picture);
- avctx->coded_frame = (AVFrame*)&s->picture;
ff_j2k_init_tier1_luts();
@@ -1088,9 +1085,6 @@ static av_cold int decode_end(AVCodecContext *avctx)
{
J2kDecoderContext *s = avctx->priv_data;
- if (s->picture.data[0])
- avctx->release_buffer(avctx, &s->picture);
-
return 0;
}