diff mbox series

[FFmpeg-devel] avcodec/mjpegdec: fix SOF check in EOI

Message ID 20210428145309.10112-1-jamrial@gmail.com
State Accepted
Commit fb5e2d71127ccae19c3f80ec363bb67d1871cb74
Headers show
Series [FFmpeg-devel] avcodec/mjpegdec: fix SOF check in EOI | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer April 28, 2021, 2:53 p.m. UTC
For frames decoded with skip_frame == AVDISCARD_ALL, a picture is not allocated
and got_picture is never set to 1 even if a SOF and SOS were parsed.
The existing check in EOI only cares if a SOF was parsed, not if a picture
allocated, so change it and add a new check to explicitly ensure a picture was
allocated when skip_frame != AVDISCARD_ALL.

Fixes probing and decoding when skip_frame is AVDISCARD_ALL.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/mjpegdec.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

James Almer April 30, 2021, 8:24 p.m. UTC | #1
On 4/28/2021 11:53 AM, James Almer wrote:
> For frames decoded with skip_frame == AVDISCARD_ALL, a picture is not allocated
> and got_picture is never set to 1 even if a SOF and SOS were parsed.
> The existing check in EOI only cares if a SOF was parsed, not if a picture
> allocated, so change it and add a new check to explicitly ensure a picture was
> allocated when skip_frame != AVDISCARD_ALL.
> 
> Fixes probing and decoding when skip_frame is AVDISCARD_ALL.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/mjpegdec.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index 16aed078f6..c829172200 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -2560,11 +2560,16 @@ eoi_parser:
>                   s->progressive && s->cur_scan && s->got_picture)
>                   mjpeg_idct_scan_progressive_ac(s);
>               s->cur_scan = 0;
> -            if (!s->got_picture) {
> +            if (!s->seen_sof) {
>                   av_log(avctx, AV_LOG_WARNING,
>                          "Found EOI before any SOF, ignoring\n");
>                   break;
>               }
> +            if (!s->got_picture && avctx->skip_frame != AVDISCARD_ALL) {
> +                av_log(avctx, AV_LOG_WARNING,
> +                       "Found EOI before any SOS, ignoring\n");
> +                break;
> +            }
>               if (s->interlaced) {
>                   s->bottom_field ^= 1;
>                   /* if not bottom field, do not output image yet */

Will apply.
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 16aed078f6..c829172200 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2560,11 +2560,16 @@  eoi_parser:
                 s->progressive && s->cur_scan && s->got_picture)
                 mjpeg_idct_scan_progressive_ac(s);
             s->cur_scan = 0;
-            if (!s->got_picture) {
+            if (!s->seen_sof) {
                 av_log(avctx, AV_LOG_WARNING,
                        "Found EOI before any SOF, ignoring\n");
                 break;
             }
+            if (!s->got_picture && avctx->skip_frame != AVDISCARD_ALL) {
+                av_log(avctx, AV_LOG_WARNING,
+                       "Found EOI before any SOS, ignoring\n");
+                break;
+            }
             if (s->interlaced) {
                 s->bottom_field ^= 1;
                 /* if not bottom field, do not output image yet */