On Mon, Apr 06, 2020 at 09:23:26AM +0530, Gautam Ramakrishnan wrote: > On Mon, Apr 6, 2020 at 1:16 AM Michael Niedermayer > <mich...@niedermayer.cc> wrote: > > > > On Sun, Apr 05, 2020 at 04:13:28PM +0530, gautamr...@gmail.com wrote: > > > From: Gautam Ramakrishnan <gautamr...@gmail.com> > > > > > > This patch adds functional changes to support the > > > PPT marker. This patch fixes bug ticket #4610. > > > --- > > > libavcodec/jpeg2000dec.c | 88 +++++++++++++++++++++++++++++++++++----- > > > 1 file changed, 77 insertions(+), 11 deletions(-) > > > > > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > > > index 732d88e6fc..2af3c61c37 100644 > > > --- a/libavcodec/jpeg2000dec.c > > > +++ b/libavcodec/jpeg2000dec.c > > > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile { > > > Jpeg2000QuantStyle qntsty[4]; > > > Jpeg2000POC poc; > > > Jpeg2000TilePart tile_part[32]; > > > + uint8_t has_ppt; // whether this tile has > > > a ppt marker > > > + uint8_t *packed_headers; // contains packed > > > headers. Used only along with PPT marker > > > + int packed_headers_size; // size in bytes of the > > > packed headers > > > + GetByteContext packed_headers_stream; // byte context > > > corresponding to packed headers > > > uint16_t tp_idx; // Tile-part index > > > int coord[2][2]; // border coordinates {{x0, x1}, > > > {y0, y1}} > > > } Jpeg2000Tile; > > > @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int n) > > > return 0; > > > } > > > > > > +static int get_ppt(Jpeg2000DecoderContext *s, int n) > > > +{ > > > + Jpeg2000Tile *tile; > > > + > > > + 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 > > > > > > > + if (!tile->packed_headers) > > > + tile->packed_headers = av_malloc(n - 3); > > > + else > > > + tile->packed_headers = av_realloc(tile->packed_headers, > > > + tile->packed_headers_size + n > > > - 3); > > > > why is the special case with av_malloc() needed ? > > > The if else is to check whether this is the first time this tile is being > allocated its packed headers. If packed headers does not exist > exist, create it. The else condition is just to add a new packed > header to it.
what is the problem with av_realloc(tile->packed_headers, tile->packed_headers_size + n - 3); when tile->packed_headers is NULL and tile->packed_headers_size is 0 for the first allocation ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".