jpeg2000dec: fix tile-part header state reset

Fixes https://trac.ffmpeg.org/ticket/11266
This commit is contained in:
Pierre-Anthony Lemieux 2024-10-24 16:28:38 -07:00
parent 562524587e
commit 839f6d38a0
No known key found for this signature in database
GPG Key ID: 698FA1F0F8D4EED4
2 changed files with 10 additions and 10 deletions

View File

@ -2402,6 +2402,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
Jpeg2000QuantStyle *qntsty = s->qntsty;
Jpeg2000POC *poc = &s->poc;
uint8_t *properties = s->properties;
uint8_t in_tile_headers = 0;
for (;;) {
int len, ret = 0;
@ -2484,7 +2485,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_cap(s, codsty);
break;
case JPEG2000_COC:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"COC marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2492,7 +2493,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_coc(s, codsty, properties);
break;
case JPEG2000_COD:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"COD marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2500,7 +2501,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_cod(s, codsty, properties);
break;
case JPEG2000_RGN:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"RGN marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2512,7 +2513,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
}
break;
case JPEG2000_QCC:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"QCC marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2520,7 +2521,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_qcc(s, len, qntsty, properties);
break;
case JPEG2000_QCD:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"QCD marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2528,7 +2529,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_qcd(s, len, qntsty, properties);
break;
case JPEG2000_POC:
if (s->in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
if (in_tile_headers == 1 && s->isHT && (!s->Ccap15_b11)) {
av_log(s->avctx, AV_LOG_ERROR,
"POC marker found in a tile header but the codestream belongs to the HOMOGENEOUS set\n");
return AVERROR_INVALIDDATA;
@ -2536,8 +2537,8 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret = get_poc(s, len, poc);
break;
case JPEG2000_SOT:
if (!s->in_tile_headers) {
s->in_tile_headers = 1;
if (!in_tile_headers) {
in_tile_headers = 1;
if (s->has_ppm) {
bytestream2_init(&s->packed_headers_stream, s->packed_headers, s->packed_headers_size);
}
@ -2569,7 +2570,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
break;
case JPEG2000_PPM:
// Packed headers, main header
if (s->in_tile_headers) {
if (in_tile_headers) {
av_log(s->avctx, AV_LOG_ERROR, "PPM Marker can only be in Main header\n");
return AVERROR_INVALIDDATA;
}

View File

@ -86,7 +86,6 @@ typedef struct Jpeg2000DecoderContext {
uint8_t *packed_headers; // contains packed headers. Used only along with PPM marker
int packed_headers_size;
GetByteContext packed_headers_stream;
uint8_t in_tile_headers;
int cdx[4], cdy[4];
int precision;