+ bytestream2_get_byte(&s->g); //Zppm is skipped and not used
+ new = av_realloc(s->packed_headers,
+ s->packed_headers_size + n - 3);
+ if (new) {
+ s->packed_headers = new;
+ } else
+ return AVERROR(ENOMEM);
+ s->has_ppm = 1;
+ memset(&s->packed_headers_stream, 0, sizeof(s->packed_headers_stream));
+ bytestream_get_buffer(&s->g.buffer, s->packed_headers + s->packed_headers_size,
+ n - 3);
+ s->packed_headers_size += n - 3;
+
+ return 0;
+}
+
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+ Jpeg2000Tile *tile;
+ void *new;
+
+ if (n < 3) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid length for PPT data.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (s->curtileno < 0)
+ return AVERROR_INVALIDDATA;
+
+ tile = &s->tile[s->curtileno];
+ if (tile->tp_idx != 0) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "PPT marker can occur only on first tile part of a tile.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ tile->has_ppt = 1; // this tile has a ppt marker
+ bytestream2_get_byte(&s->g); // Zppt is skipped and not used
+ new = av_realloc(tile->packed_headers,
+ tile->packed_headers_size + n - 3);
+ if (new) {
+ tile->packed_headers = new;
+ } else
+ return AVERROR(ENOMEM);
+ memset(&tile->packed_headers_stream, 0, sizeof(tile->packed_headers_stream));
+ memcpy(tile->packed_headers + tile->packed_headers_size,
+ s->g.buffer, n - 3);
+ tile->packed_headers_size += n - 3;
+ bytestream2_skip(&s->g, n - 3);