aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2025-08-05 23:18:47 +0200
committermichaelni <michael@niedermayer.cc>2025-08-07 14:47:56 +0000
commit104d6846c1be0cb757dc95d5801a416f4d7c687d (patch)
tree0a6af57521b689b8c9402c9c1b63b5194069f069
parentf45da79b2c336c5f8f3e563d72b8a22fecdcde0c (diff)
downloadffmpeg-104d6846c1be0cb757dc95d5801a416f4d7c687d.tar.gz
avcodec/jpeg2000dec: move cdef default check into get_siz()
This way cdef is at its final value earlier Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/jpeg2000dec.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9a4afd37d0..aab48532ef 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -271,6 +271,17 @@ static int get_siz(Jpeg2000DecoderContext *s)
return AVERROR_INVALIDDATA;
}
+ for (i = 0; i < s->ncomponents; i++) {
+ if (s->cdef[i] < 0) {
+ for (i = 0; i < s->ncomponents; i++) {
+ s->cdef[i] = i + 1;
+ }
+ if ((s->ncomponents & 1) == 0)
+ s->cdef[s->ncomponents-1] = 0;
+ }
+ }
+ // after here we no longer have to consider negative cdef
+
for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i
uint8_t x = bytestream2_get_byteu(&s->g);
s->cbps[i] = (x & 0x7f) + 1;
@@ -2885,17 +2896,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
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;
- }
- }
-
for (int x = 0; x < s->ncomponents && s->codsty[x].transform == FF_DWT53;)
if (++x == s->ncomponents)
picture->flags |= AV_FRAME_FLAG_LOSSLESS;