mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-19 22:10:34 +00:00
avcodec/jpeg2000dec: Do not hardcode tile part usage
Fixes part of Ticket 4605 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
1b3fbe41c5
commit
e7adb02d3b
@ -758,7 +758,7 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
|
static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index,
|
||||||
Jpeg2000CodingStyle *codsty,
|
Jpeg2000CodingStyle *codsty,
|
||||||
Jpeg2000ResLevel *rlevel, int precno,
|
Jpeg2000ResLevel *rlevel, int precno,
|
||||||
int layno, uint8_t *expn, int numgbits)
|
int layno, uint8_t *expn, int numgbits)
|
||||||
@ -766,6 +766,12 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
|
|||||||
int bandno, cblkno, ret, nb_code_blocks;
|
int bandno, cblkno, ret, nb_code_blocks;
|
||||||
int cwsno;
|
int cwsno;
|
||||||
|
|
||||||
|
if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
|
||||||
|
if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
|
||||||
|
s->g = tile->tile_part[++(*tp_index)].tpg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(ret = get_bits(s, 1))) {
|
if (!(ret = get_bits(s, 1))) {
|
||||||
jpeg2000_flush(s);
|
jpeg2000_flush(s);
|
||||||
return 0;
|
return 0;
|
||||||
@ -895,6 +901,7 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int layno, reslevelno, compno, precno, ok_reslevel;
|
int layno, reslevelno, compno, precno, ok_reslevel;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
int tp_index = 0;
|
||||||
|
|
||||||
s->bit_index = 8;
|
s->bit_index = 8;
|
||||||
switch (tile->codsty[0].prog_order) {
|
switch (tile->codsty[0].prog_order) {
|
||||||
@ -912,7 +919,7 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
|||||||
reslevelno;
|
reslevelno;
|
||||||
ok_reslevel = 1;
|
ok_reslevel = 1;
|
||||||
for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++)
|
for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++)
|
||||||
if ((ret = jpeg2000_decode_packet(s,
|
if ((ret = jpeg2000_decode_packet(s, tile, &tp_index,
|
||||||
codsty, rlevel,
|
codsty, rlevel,
|
||||||
precno, layno,
|
precno, layno,
|
||||||
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
||||||
@ -937,7 +944,7 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
|||||||
reslevelno;
|
reslevelno;
|
||||||
ok_reslevel = 1;
|
ok_reslevel = 1;
|
||||||
for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++)
|
for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++)
|
||||||
if ((ret = jpeg2000_decode_packet(s,
|
if ((ret = jpeg2000_decode_packet(s, tile, &tp_index,
|
||||||
codsty, rlevel,
|
codsty, rlevel,
|
||||||
precno, layno,
|
precno, layno,
|
||||||
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
||||||
@ -954,11 +961,6 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
|||||||
Jpeg2000CodingStyle *codsty = tile->codsty + compno;
|
Jpeg2000CodingStyle *codsty = tile->codsty + compno;
|
||||||
Jpeg2000QuantStyle *qntsty = tile->qntsty + compno;
|
Jpeg2000QuantStyle *qntsty = tile->qntsty + compno;
|
||||||
|
|
||||||
/* Set bit stream buffer address according to tile-part.
|
|
||||||
* For DCinema one tile-part per component, so can be
|
|
||||||
* indexed by component. */
|
|
||||||
s->g = tile->tile_part[compno].tpg;
|
|
||||||
|
|
||||||
/* Position loop (y axis)
|
/* Position loop (y axis)
|
||||||
* TODO: Automate computing of step 256.
|
* TODO: Automate computing of step 256.
|
||||||
* Fixed here, but to be computed before entering here. */
|
* Fixed here, but to be computed before entering here. */
|
||||||
@ -989,7 +991,7 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
|||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
|
|
||||||
for (layno = 0; layno < tile->codsty[0].nlayers; layno++) {
|
for (layno = 0; layno < tile->codsty[0].nlayers; layno++) {
|
||||||
if ((ret = jpeg2000_decode_packet(s, codsty, rlevel,
|
if ((ret = jpeg2000_decode_packet(s, tile, &tp_index, codsty, rlevel,
|
||||||
precno, layno,
|
precno, layno,
|
||||||
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
|
||||||
qntsty->nguardbits)) < 0)
|
qntsty->nguardbits)) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user