diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-05-31 03:32:36 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-31 05:10:07 +0400 |
commit | 45c0e338fc307616e7348c2504d333529f34fcdb (patch) | |
tree | 953723e550ef7969e7c32b58898d3a731c806802 /libavcodec | |
parent | f471b5fa300eed4f19b77383454b2ada573ec7f5 (diff) |
j2kdec: merge picture handling from jpeg2000
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/j2kdec.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c index b8b3921d42..4511094bb2 100644 --- a/libavcodec/j2kdec.c +++ b/libavcodec/j2kdec.c @@ -62,7 +62,6 @@ typedef struct Jpeg2000Tile { typedef struct Jpeg2000DecoderContext { AVClass *class; AVCodecContext *avctx; - AVFrame *picture; GetByteContext g; int width, height; @@ -162,7 +161,6 @@ static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node, static int get_siz(Jpeg2000DecoderContext *s) { int i, ret; - ThreadFrame frame = { .f = s->picture }; if (bytestream2_get_bytes_left(&s->g) < 36) return AVERROR(EINVAL); @@ -255,13 +253,6 @@ static int get_siz(Jpeg2000DecoderContext *s) break; } - - if ((ret = ff_thread_get_buffer(s->avctx, &frame, 0)) < 0) - return ret; - - s->picture->pict_type = AV_PICTURE_TYPE_I; - s->picture->key_frame = 1; - return 0; } @@ -1237,11 +1228,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { Jpeg2000DecoderContext *s = avctx->priv_data; + ThreadFrame frame = { .f = data }; AVFrame *picture = data; int tileno, ret; - s->picture = picture; - s->avctx = avctx; bytestream2_init(&s->g, avpkt->data, avpkt->size); s->curtileno = -1; @@ -1276,11 +1266,19 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, if (ret = jpeg2000_read_main_headers(s)) goto err_out; + /* get picture buffer */ + if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) { + av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed.\n"); + goto err_out; + } + picture->pict_type = AV_PICTURE_TYPE_I; + picture->key_frame = 1; + if (ret = jpeg2000_read_bitstream_packets(s)) goto err_out; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) - if (ret = jpeg2000_decode_tile(s, s->tile + tileno, s->picture)) + if (ret = jpeg2000_decode_tile(s, s->tile + tileno, picture)) goto err_out; jpeg2000_dec_cleanup(s); |