* [FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: fix tilepart processing
@ 2024-06-07 0:25 Osamu Watanabe
2024-06-13 18:45 ` Pierre-Anthony Lemieux
0 siblings, 1 reply; 2+ messages in thread
From: Osamu Watanabe @ 2024-06-07 0:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Osamu Watanabe, Osamu Watanabe, pal
From: Osamu Watanabe <65328111+osamu620@users.noreply.github.com>
Fix http://trac.ffmpeg.org/ticket/10121
Signed-off-by: Osamu Watanabe <owatanab@es.takushoku-u.ac.jp>
---
libavcodec/jpeg2000dec.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index d15502a527..091931b1ff 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1005,6 +1005,7 @@ static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *
{
s->g = tile->tile_part[*tp_index].header_tpg;
if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
+ av_log(s->avctx, AV_LOG_WARNING, "Packet header bytes in PPM marker segment is too short.\n");
if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
s->g = tile->tile_part[++(*tp_index)].tpg;
}
@@ -1014,10 +1015,18 @@ static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *
static inline void select_stream(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
int *tp_index, const Jpeg2000CodingStyle *codsty)
{
+ int32_t is_endof_tp;
+
s->g = tile->tile_part[*tp_index].tpg;
- if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
+ is_endof_tp = bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8;
+ // Following while loop is necessary because a tilepart may include only SOD marker.
+ // Such a tilepart has neither packet header nor compressed data.
+ while (is_endof_tp) {
if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
s->g = tile->tile_part[++(*tp_index)].tpg;
+ is_endof_tp = bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8;
+ } else {
+ is_endof_tp = 0;
}
}
if (codsty->csty & JPEG2000_CSTY_SOP) {
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: fix tilepart processing
2024-06-07 0:25 [FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: fix tilepart processing Osamu Watanabe
@ 2024-06-13 18:45 ` Pierre-Anthony Lemieux
0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Anthony Lemieux @ 2024-06-13 18:45 UTC (permalink / raw)
To: Osamu Watanabe; +Cc: Osamu Watanabe, ffmpeg-devel
LGTM. Will merge over the weekend unless I hear otherwise.
On Thu, Jun 6, 2024 at 5:25 PM Osamu Watanabe
<owatanab@es.takushoku-u.ac.jp> wrote:
>
> From: Osamu Watanabe <65328111+osamu620@users.noreply.github.com>
>
> Fix http://trac.ffmpeg.org/ticket/10121
>
> Signed-off-by: Osamu Watanabe <owatanab@es.takushoku-u.ac.jp>
> ---
> libavcodec/jpeg2000dec.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index d15502a527..091931b1ff 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -1005,6 +1005,7 @@ static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *
> {
> s->g = tile->tile_part[*tp_index].header_tpg;
> if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> + av_log(s->avctx, AV_LOG_WARNING, "Packet header bytes in PPM marker segment is too short.\n");
> if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> s->g = tile->tile_part[++(*tp_index)].tpg;
> }
> @@ -1014,10 +1015,18 @@ static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *
> static inline void select_stream(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile,
> int *tp_index, const Jpeg2000CodingStyle *codsty)
> {
> + int32_t is_endof_tp;
> +
> s->g = tile->tile_part[*tp_index].tpg;
> - if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> + is_endof_tp = bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8;
> + // Following while loop is necessary because a tilepart may include only SOD marker.
> + // Such a tilepart has neither packet header nor compressed data.
> + while (is_endof_tp) {
> if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> s->g = tile->tile_part[++(*tp_index)].tpg;
> + is_endof_tp = bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8;
> + } else {
> + is_endof_tp = 0;
> }
> }
> if (codsty->csty & JPEG2000_CSTY_SOP) {
> --
> 2.34.1
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-13 18:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-07 0:25 [FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: fix tilepart processing Osamu Watanabe
2024-06-13 18:45 ` Pierre-Anthony Lemieux
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git