[FFmpeg-devel] [PATCH] jpeg200dec: reset in_tile_headers flag between frames
Pierre-Anthony Lemieux
pal at sandflow.com
Fri Oct 25 19:10:59 EEST 2024
I plan on applying this over the weekend (modulo the typo in the
subject of the patch) unless there are objections -- since JPEG 2000 +
MXF decoding is broken right now.
On Thu, Oct 24, 2024 at 9:12 PM WATANABE Osamu
<owatanab at es.takushoku-u.ac.jp> wrote:
>
> It looks good to me. Thank you for catching this.
> FYI - The patch has been confirmed to pass all the test cases defined in ISO/IEC 15444-4.
>
> > On Oct 25, 2024, at 9:28, Pierre-Anthony Lemieux <pal at sandflow.com> wrote:
> >
> > Fixes https://trac.ffmpeg.org/ticket/11266
> >
> > On Thu, Oct 24, 2024 at 5:23?PM <pal at sandflow.com> wrote:
> >>
> >> From: Pierre-Anthony Lemieux <pal at palemieux.com>
> >>
> >> ---
> >> libavcodec/jpeg2000dec.c | 19 ++++++++++---------
> >> libavcodec/jpeg2000dec.h | 1 -
> >> 2 files changed, 10 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> >> index 2e09b279dc..5b05ff2455 100644
> >> --- a/libavcodec/jpeg2000dec.c
> >> +++ b/libavcodec/jpeg2000dec.c
> >> @@ -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;
> >> }
> >> diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h
> >> index 78eba27ed9..fce3823164 100644
> >> --- a/libavcodec/jpeg2000dec.h
> >> +++ b/libavcodec/jpeg2000dec.h
> >> @@ -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;
> >> --
> >> 2.25.1
> >>
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list