mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
avcodec/j2kenc: fix edge case when packet ends on 0xFF
ISO/IEC 15444-1:2002 (E), Annex B.10.1 "Bit-stuffing routine": > The last byte in the packet header shall not be an 0xFF value (thus the > single zero bit stuffed after a byte with 0xFF must be included even if > the 0xFF would otherwise have been the last byte). This matches the behavior seen in the jpeg2000 decoder (jpeg2000_flush), and the behavior of openjpeg. Sponsored-by: nxtedition AB Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
@@ -176,6 +176,8 @@ static void j2k_flush(Jpeg2000EncoderContext *s)
|
||||
{
|
||||
if (s->bit_index){
|
||||
s->bit_index = 0;
|
||||
if (*s->buf == 0xff)
|
||||
*(++s->buf) = 0;
|
||||
s->buf++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user