diff mbox series

[FFmpeg-devel,4/7] avcodec/dvbsubdec: Support computing clut only once

Message ID 20210304184839.24847-4-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/7] avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()
Related show

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

Michael Niedermayer March 4, 2021, 6:48 p.m. UTC
This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/dvbsubdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Marton Balint March 4, 2021, 6:59 p.m. UTC | #1
On Thu, 4 Mar 2021, Michael Niedermayer wrote:

> This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/dvbsubdec.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)

PLease update doc/decoders.texi as well.

Thanks,
Marton

>
> diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
> index 9bee33e4a2..6f340460d8 100644
> --- a/libavcodec/dvbsubdec.c
> +++ b/libavcodec/dvbsubdec.c
> @@ -979,7 +979,8 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
>         }
>     }
> 
> -    region->has_computed_clut = 0;
> +    if (ctx->compute_clut != -2)
> +        region->has_computed_clut = 0;
> }
> 
> static int dvbsub_parse_object_segment(AVCodecContext *avctx,
> @@ -1737,7 +1738,7 @@ end:
> #define OFFSET(x) offsetof(DVBSubContext, x)
> static const AVOption options[] = {
>     {"compute_edt", "compute end of time using pts or timeout", OFFSET(compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
> -    {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, DS},
> +    {"compute_clut", "compute clut when not available(-1) or only once (-2) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -2, 1, DS},
>     {"dvb_substream", "", OFFSET(substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
>     {NULL}
> };
> -- 
> 2.17.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".
Michael Niedermayer March 28, 2021, 12:33 p.m. UTC | #2
On Thu, Mar 04, 2021 at 07:59:34PM +0100, Marton Balint wrote:
> 
> 
> On Thu, 4 Mar 2021, Michael Niedermayer wrote:
> 
> > This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavcodec/dvbsubdec.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> PLease update doc/decoders.texi as well.

will apply with that added

[...]
diff mbox series

Patch

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 9bee33e4a2..6f340460d8 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -979,7 +979,8 @@  static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
         }
     }
 
-    region->has_computed_clut = 0;
+    if (ctx->compute_clut != -2)
+        region->has_computed_clut = 0;
 }
 
 static int dvbsub_parse_object_segment(AVCodecContext *avctx,
@@ -1737,7 +1738,7 @@  end:
 #define OFFSET(x) offsetof(DVBSubContext, x)
 static const AVOption options[] = {
     {"compute_edt", "compute end of time using pts or timeout", OFFSET(compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
-    {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, DS},
+    {"compute_clut", "compute clut when not available(-1) or only once (-2) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -2, 1, DS},
     {"dvb_substream", "", OFFSET(substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
     {NULL}
 };