diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-17 20:13:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-17 20:39:03 +0200 |
commit | 4624656797b667eb6405186682eb04e74dfd90fd (patch) | |
tree | 3de85df7cb083bcbf0a89bc56ed52ad20a5f6f12 /libavcodec | |
parent | e6190045b3a119cc27efe9fbd91eb7881fb6f823 (diff) | |
download | ffmpeg-4624656797b667eb6405186682eb04e74dfd90fd.tar.gz |
avcodec/j2kenc: Properly flush the end of the truncated AC stream
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/j2kenc.c | 10 | ||||
-rw-r--r-- | libavcodec/jpeg2000.h | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 593ceb40e5..68905cc2d3 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -612,7 +612,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 break; } - cblk->passes[passno].rate = 3 + ff_mqc_length(&t1->mqc); + cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len); wmsedec += (int64_t)nmsedec << (2*bpno); cblk->passes[passno].disto = wmsedec; @@ -624,8 +624,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 cblk->npasses = passno; cblk->ninclpasses = passno; - // TODO: optional flush on each pass - cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc); + cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len); } /* tier-2 routines: */ @@ -732,7 +731,10 @@ static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, in if (cblk->ninclpasses){ if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate) return -1; - bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate); + bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate + - cblk->passes[cblk->ninclpasses-1].flushed_len); + bytestream_put_buffer(&s->buf, cblk->passes[cblk->ninclpasses-1].flushed, + cblk->passes[cblk->ninclpasses-1].flushed_len); } } } diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index 1054fe6333..f963cbeb5d 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -159,6 +159,8 @@ typedef struct Jpeg2000QuantStyle { typedef struct Jpeg2000Pass { uint16_t rate; int64_t disto; + uint8_t flushed[4]; + int flushed_len; } Jpeg2000Pass; typedef struct Jpeg2000Cblk { |