@@ -1640,6 +1640,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
int out_line_size;
int nb_blocks;/* nb scanline or nb tile */
+ uint64_t *table;/* scanline offset table */
+ uint8_t *marker;/* used to recreate invalid scanline offset table */
+
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
if ((ret = decode_header(s, picture)) < 0)
@@ -1731,6 +1734,21 @@ static int decode_frame(AVCodecContext *avctx, void *data,
s->buf_size = avpkt->size;
ptr = picture->data[0];
+ // check offset table
+ if (!s->is_tile && bytestream2_peek_le64(&s->gb) == 0)
+ {
+ table = (uint64_t *)s->gb.buffer;
+ marker = avpkt->data + bytestream2_tell(&s->gb) + nb_blocks * 8;
+
+ av_log(s->avctx, AV_LOG_DEBUG, "recreating invalid scanline offset table\n");
+
+ for (y = 0; y < nb_blocks; y++)
+ {
+ table[y] = marker - s->buf;
+ marker += ((uint32_t *)marker)[1] + 8;
+ }
+ }
+
// Zero out the start if ymin is not 0
for (y = 0; y < s->ymin; y++) {
memset(ptr, 0, out_line_size);