diff mbox series

[FFmpeg-devel,2/2] avcodec/dvbsub: Don't dump images to disk based on DEBUG define

Message ID DM8P223MB03655732F0260C4368798325BA669@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/dvdsub: Don't dump images to disk based on DEBUG define | expand

Checks

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

Commit Message

Soft Works Nov. 29, 2021, 8:17 p.m. UTC
It's been a regular annoyance.
Introduce a debug-only parameter for this.

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 libavcodec/dvbsubdec.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index d192f3251d..e629b315c7 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -137,6 +137,9 @@  typedef struct DVBSubContext {
 
     DVBSubRegionDisplay *display_list;
     DVBSubDisplayDefinition *display_definition;
+#ifdef DEBUG
+  int dump_imgs;
+#endif
 } DVBSubContext;
 
 
@@ -1538,11 +1541,11 @@  static int save_display_set(DVBSubContext *ctx)
 
         }
 
-        snprintf(filename, sizeof(filename), "dvbs.%d", fileno_index);
-
-        png_save(ctx, filename, pbuf, width, height);
-
-        av_freep(&pbuf);
+        if (ctx->dump_imgs) {
+            snprintf(filename, sizeof(filename), "dvbs.%d", fileno_index);
+            png_save(ctx, filename, pbuf, width, height);
+            av_freep(&pbuf);
+        }
     }
 
     fileno_index++;
@@ -1736,6 +1739,9 @@  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 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},
+#ifdef DEBUG
+    { "dump_imgs", "Dump subtitle images to disk", OFFSET(dump_imgs), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
+#endif
     {NULL}
 };
 static const AVClass dvbsubdec_class = {