summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/jpeg2000dec.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 80b2e2d627..a7eb809f30 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2080,7 +2080,6 @@ static int jpeg2000_decode_tile(AVCodecContext *avctx, void *td,
Jpeg2000DecoderContext *s = avctx->priv_data;
AVFrame *picture = td;
Jpeg2000Tile *tile = s->tile + jobnr;
- int x;
tile_codeblocks(s, tile);
@@ -2088,17 +2087,6 @@ static int jpeg2000_decode_tile(AVCodecContext *avctx, void *td,
if (tile->codsty[0].mct)
mct_decode(s, tile);
- for (x = 0; x < s->ncomponents; x++) {
- if (s->cdef[x] < 0) {
- for (x = 0; x < s->ncomponents; x++) {
- s->cdef[x] = x + 1;
- }
- if ((s->ncomponents & 1) == 0)
- s->cdef[s->ncomponents-1] = 0;
- break;
- }
- }
-
if (s->precision <= 8) {
write_frame_8(s, tile, picture, 8);
} else {
@@ -2537,6 +2525,17 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
if (ret = jpeg2000_read_bitstream_packets(s))
goto end;
+ for (int x = 0; x < s->ncomponents; x++) {
+ if (s->cdef[x] < 0) {
+ for (x = 0; x < s->ncomponents; x++) {
+ s->cdef[x] = x + 1;
+ }
+ if ((s->ncomponents & 1) == 0)
+ s->cdef[s->ncomponents-1] = 0;
+ break;
+ }
+ }
+
avctx->execute2(avctx, jpeg2000_decode_tile, picture, NULL, s->numXtiles * s->numYtiles);
jpeg2000_dec_cleanup(s);