diff mbox series

[FFmpeg-devel,2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

Message ID AS8P250MB074436E24B71345F40BF15318F519@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 23, 2022, 3:41 p.m. UTC
This could be improved further by not allocating the buffers
that won't be needed lateron in the first place.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/jpeg2000dec.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tomas Härdin Sept. 23, 2022, 6:24 p.m. UTC | #1
fre 2022-09-23 klockan 17:41 +0200 skrev Andreas Rheinhardt:
> This could be improved further by not allocating the buffers
> that won't be needed lateron in the first place.

My parallellization patches do this

> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/jpeg2000dec.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index c3f2a7aa03..63a706fbf5 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -2523,6 +2523,11 @@ static int
> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
>          avctx->sample_aspect_ratio = s->sar;
>      s->sar.num = s->sar.den = 0;
>  
> +    if (avctx->skip_frame >= AVDISCARD_ALL) {
> +        jpeg2000_dec_cleanup(s);
> +        return 0;
> +    }
> +
>      /* get picture buffer */
>      if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
>          goto end;
> @@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = {
>      .p.priv_class     = &jpeg2000_class,
>      .p.max_lowres     = 5,
>      .p.profiles       = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),
> +    .caps_internal    = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,

Looks good

/Tomas
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index c3f2a7aa03..63a706fbf5 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2523,6 +2523,11 @@  static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
         avctx->sample_aspect_ratio = s->sar;
     s->sar.num = s->sar.den = 0;
 
+    if (avctx->skip_frame >= AVDISCARD_ALL) {
+        jpeg2000_dec_cleanup(s);
+        return 0;
+    }
+
     /* get picture buffer */
     if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
         goto end;
@@ -2587,4 +2592,5 @@  const FFCodec ff_jpeg2000_decoder = {
     .p.priv_class     = &jpeg2000_class,
     .p.max_lowres     = 5,
     .p.profiles       = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),
+    .caps_internal    = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 };