From patchwork Mon Jan 10 19:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33193 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3046176iog; Mon, 10 Jan 2022 11:55:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWKTUclBeEyoe7FsmoCvZ7nw6tpf4sfCnYz7riIIEn+pbLHl3JsKXcit+E+JJYam3pXPII X-Received: by 2002:a17:907:160f:: with SMTP id hb15mr990089ejc.166.1641844558094; Mon, 10 Jan 2022 11:55:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641844558; cv=none; d=google.com; s=arc-20160816; b=NrUmZO4bk9p3bMgY3+K/Ijx951bW8cCHSOlI2XWErCZ6qIIX6gnoARZi5cR9xQDrOC d3oMil+5WdT4DO0CeJYrrHIoP56Gtr5W51NhssygTkHYznwqwpIVgyfqdBAY8/cegVHh oCCZ9yAoaWiE4TKH4Y2B5d0r1fAj2YPlgvWhsp4ycaBwNhGRfJ4kmUx+jNiI8Y/bF+Qh O7Ls8ohVlAAGkFcJGYb6FhJXJuKXCmwtdeGITfGEu8Fh6EIng6LpoCK6VtTWSni+3OQu p6posaS+DdLWLN3vaMfiuZBJsHR2fPkgwqlUwM/W8u33u2I0TuMUN2Gbp4YBC+YLTbmM 1m+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:mime-version:fcc:date:from:references :in-reply-to:message-id:dkim-signature:delivered-to; bh=aD6CHgBqPMILHNjfEg0u0fD+qluL5ukUa8wjH4m5ck4=; b=0trD8s15XWtAq4uYitw+Sm99QYIy7m7G8tsaUFE2/1fFP4r5s6zH1IgNkD9/joREK0 8JNW8zqhDTy/TUsom8dzl2s2XpAp3rma5PsbiX6zzoRTeu6fIeS/SHzIFNL8BYoRIsJZ 06KZFptxklax7K4uPu/A1TiqcMYkHCB+c0NaxRooS17V0m2l4Gl8w4oJnsGhVktwbP88 r51heLb0nBZyDOtfZgMBS2fUoCuvF0QKf3o00N42b5E1hvC2VkjUnPuiybPSsi9N1MBe 8UXA4bf742GqLwf9ubJfyJu6Jk3qNPBCdECkjbUwvRh8cIwkrEC+slEUc3QlZZeETM5N jH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=fF7m6wIF; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c13si1949575ede.207.2022.01.10.11.55.57; Mon, 10 Jan 2022 11:55:58 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=fF7m6wIF; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A961768AD93; Mon, 10 Jan 2022 21:55:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27A76689D48 for ; Mon, 10 Jan 2022 21:55:37 +0200 (EET) Received: by mail-pl1-f173.google.com with SMTP id w7so13570124plp.13 for ; Mon, 10 Jan 2022 11:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=nV2/UTmCMMEcjrkCg6rnvByLxFRpm6sMohKb9ZnO7TI=; b=fF7m6wIFFKDvzlF3jH7fIGB/h+r4EaNd1x2bvuv6M5OHVLUl2HHg9zJcBDvCf3xFoj ZSkIUeqiI8MDD0SPGuUfVDBbUqCllDMYvr62GRp/PQ7RacBUlfzBIzPy2oAGDRCkZBsB iMFtGIQUcjOSR8OFSxiqJkTK3ifSBS2tYHk2CZquanRb64x5M16EgUPIVgJeQzYrvi6G uuJQUrxLRn6x3gslOTx8c6C8E+dAeFAXTqyDnnbFhV2GCMnrD+WhXfvg081AZselONd+ cVYxi2AqoxG4QEPpN6fiVHHkULcZQeO9j//1R4OM6+ndzzNNhika1leAEv4H5sOaN9dP W9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=nV2/UTmCMMEcjrkCg6rnvByLxFRpm6sMohKb9ZnO7TI=; b=WXmwqZUM5GHg49FCVgHwY15BKLwzl4gvx2gx71mV1nYbpB9FZm1Tm+MU4Xmx0ZLvmv KmWitQbxLMtRLQQT+sReCtTJ/9q3XR9Wi6jFjv+emL1KVoQL3nDWt+t4G8McwmW/aXSP XzvrZkeGGTnVrI3QodQgaleWzVMeUKjGEzUsJM8OgXjsgF7Fz9aSUacynTxKsk6smFhL IWg5RL1OE1vfK8Wq6z5U8DftDajO5J0OEtFLWnhl8p/g5L6G8XIXoWjOg/55qpS8Y1QU wSFrVdtg0wUcLtDDDANRUQ323KqJ06V1xl4qoYzHO+ROd6c23fpIrtiyAp4xnI0e2x3I d2KQ== X-Gm-Message-State: AOAM533UUUtkTwpni2FIR1Q1JWNvRd+CdynnyRXbBUYOZ2pUiCa/Oni7 V1QPMWuVQH/ds5VpGILyrIBh96lSV88vIA== X-Received: by 2002:a17:90a:ae17:: with SMTP id t23mr8362100pjq.116.1641844535666; Mon, 10 Jan 2022 11:55:35 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id n5sm4646391pfo.39.2022.01.10.11.55.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jan 2022 11:55:35 -0800 (PST) Message-Id: <2f12ac7f1fafe9a6032ec67c3441adfbdcbd2d30.1641844533.git.ffmpegagent@gmail.com> In-Reply-To: References: From: ffmpegagent Date: Mon, 10 Jan 2022 19:55:32 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec/dvdsubdec, dvbsubdec: don't dump images to disk based on DEBUG define X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: softworkz , Hendrik Leppkes , Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: S/SqHXhd9xKm From: softworkz It's been a regular annoyance. Introduce a debug-only parameter for this. Signed-off-by: softworkz --- libavcodec/dvbsubdec.c | 16 +++++++++++----- libavcodec/dvdsubdec.c | 9 +++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index bc741a1de6..8db9963fda 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; @@ -1534,11 +1537,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++; @@ -1730,6 +1733,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 = { diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 52259f0730..c0f796068e 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -44,6 +44,7 @@ typedef struct DVDSubContext uint8_t used_color[256]; #ifdef DEBUG int sub_id; + int dump_imgs; #endif } DVDSubContext; @@ -597,8 +598,9 @@ static int dvdsub_decode(AVCodecContext *avctx, ff_dlog(NULL, "start=%d ms end =%d ms\n", sub->start_display_time, sub->end_display_time); - ppm_save(ppm_name, sub->rects[0]->data[0], - sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->data[1]); + if (ctx->dump_imgs) + ppm_save(ppm_name, sub->rects[0]->data[0], + sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->data[1]); } #endif @@ -745,6 +747,9 @@ static const AVOption options[] = { { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, { "ifo_palette", "obtain the global palette from .IFO file", OFFSET(ifo_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, { "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SD}, +#ifdef DEBUG + { "dump_imgs", "Dump subtitle images to disk", OFFSET(dump_imgs), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SD}, +#endif { NULL } }; static const AVClass dvdsub_class = { From patchwork Mon Jan 10 19:55:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33194 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3046284iog; Mon, 10 Jan 2022 11:56:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvSSZW+bfXvGD7odEjB9XwJNvdkVhwvNQNcKa7z/IH6hi7gHsYXMJVwsZ0yFx9M3v6VRXQ X-Received: by 2002:a17:906:7115:: with SMTP id x21mr1011852ejj.599.1641844567542; Mon, 10 Jan 2022 11:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641844567; cv=none; d=google.com; s=arc-20160816; b=LlVqCHk/mPqClpT4ghC0IKH9UKWT7G4grLpPTIO9wOpDGTpko08cieX+1t0bDIDBVl 4Rt73b4TfaHvuQZdIvGnTzMg4rvco5xqKeFQ7Tu//KHT0qCGLDKOH0+3VXbM96CmMKaf +iSGF/iObrLmmd5qmd4R/JioUNDHK2ybiJkQRfTFKecasRB4LVD8Qp5iY1v4PZUphlap DxGjSNZIer8kTv7QB4ravLPnGUPVn7oRxMjdXtIJzUJtRCGO4kFQDQGvzQWge/CByXza p+WKa5rYS91MZlYFu1iWCYOwwRGTAUpPvgD2wCGm+Uwq2ctYXTxJxO2L56DeZWNR47A2 WgNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:mime-version:fcc:date:from:references :in-reply-to:message-id:dkim-signature:delivered-to; bh=yOv7KHDXODgFwaLu4muW09U+WSpX+o+6v/zuUbYnCJ8=; b=0sOcutjIuxTAbCF0REBZfKN/Ij72GYsJjpX+lKdi8c+n/6kOOgcRr5q9WJrqkfrw2Q fqf48jbQ609xuBz2S2F5IGmrbQIgGiHg3EZ5NZ90ttUeb+qJW/cg+I/PUJTut5QD+ibF nec/SV+8YjWjmEJXOQ9ZljXPf/xyvq2mWdkYO59yRuABh0u5uSDEpEdDWJnwjK9fETHH UzUa4MEfSA46qzeFETWjDEap10r9LC7U48+Q+A0HpAzWw7tJLjyURu39MVNEUGlCwAwr KW8L08rzcVceXMEXZWHE+SjsnClnBozoJNVuaJuWE/Ivk76Wvxm5ER9e5hjBsgY3Iz93 vqtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YY7N5N7L; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a21si3611224ejx.44.2022.01.10.11.56.07; Mon, 10 Jan 2022 11:56:07 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YY7N5N7L; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E855268A199; Mon, 10 Jan 2022 21:55:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2677168A4AC for ; Mon, 10 Jan 2022 21:55:38 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id e19so6903189plc.10 for ; Mon, 10 Jan 2022 11:55:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7xkaYNSy82XCLoxSPH61lzIRB/kyudK8OCRMEYwKVK8=; b=YY7N5N7LRQeLFMTVlWpDLf3DH9VGu/q7EBoJ9aWJnTJjfhI3Tf2Q+L6hGCBm3z+EmR Obi4TdHco5zTFX2E8dYGrf8kHSCacenUhZgK5XnB0L9X5m2ElD+kqTNWN/fxx5rUR1Ab y38wPQs4pD6KYv0ftxlclzuF/RTHdZ2RYJl/oyneJTGzkrDm/pN8ugrxolmoVv6wrMLg 4lfwCfI+m4Qh1movxP/oUGgoEJRHKcxG33XHzHP47SD2LAOxTbqI34NFQpVsweiIhiIZ Q7NZc9my1nJrs51CN+vWE2V3JxSa6Aw7WACmgZuBrB9yHfw731/oahOI/4JjaaVfUqb0 VC/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7xkaYNSy82XCLoxSPH61lzIRB/kyudK8OCRMEYwKVK8=; b=YVVwGVrRaJ+KW7nJpD3PAa5EhcsQAZWhleZLbMIS+MAqawblBIXX/rYKr4c8e3/hxd 5KyK1YPWi+rojul002xRF1/nl7UWf8icCra/H2Jm5lGpXfflRUCgu4GvJZvu5e8NzHDR BoO6OicSK1kXhpzYjHjjT16WRuY2cQfqa80K+OfHZxE284EsZDmLGEg5HDODFQ2ACCKR tx4+/+REREfzUQly0duB5D+oaatAuPCSNrmjKhD+SJgybXGedhz8gRZNbVY0oIa+8vuR GOLWc2BuNBFNVOeE2s/IFcuioH+czqg4Lv2BJGVTR9kL6MVCJjMqJMnwhyP8SDazjR9K mLCg== X-Gm-Message-State: AOAM532SNljlygJnQnQ8NSjAYuEDQXmZlsftTp53fnMlUJa3B3PL61eu G9qKTf4pSIrPl5SH39GOpROYNHdghFbCxQ== X-Received: by 2002:a05:6a00:1944:b0:438:d002:6e35 with SMTP id s4-20020a056a00194400b00438d0026e35mr1148690pfk.20.1641844536452; Mon, 10 Jan 2022 11:55:36 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id h5sm8038294pfi.46.2022.01.10.11.55.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jan 2022 11:55:36 -0800 (PST) Message-Id: <0cd2c77f31faac220dd92a147b98c881f6c9a8e1.1641844533.git.ffmpegagent@gmail.com> In-Reply-To: References: From: ffmpegagent Date: Mon, 10 Jan 2022 19:55:33 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 2/2] avcodec/dvdsubdec, dvbsubdec: fix writing ppm X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: softworkz , Hendrik Leppkes , Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kBc64Av/M273 From: softworkz fopen needs (b)inary mode Signed-off-by: softworkz --- libavcodec/dvbsubdec.c | 4 ++-- libavcodec/dvdsubdec.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 8db9963fda..f65bf960a4 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1394,7 +1394,7 @@ static void png_save(DVBSubContext *ctx, const char *filename, uint32_t *bitmap, snprintf(fname, sizeof(fname), "%s.ppm", filename); - f = fopen(fname, "w"); + f = fopen(fname, "wb"); if (!f) { perror(fname); return; @@ -1416,7 +1416,7 @@ static void png_save(DVBSubContext *ctx, const char *filename, uint32_t *bitmap, snprintf(fname2, sizeof(fname2), "%s-a.pgm", filename); - f = fopen(fname2, "w"); + f = fopen(fname2, "wb"); if (!f) { perror(fname2); return; diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index c0f796068e..f3d1a4e2fc 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -509,7 +509,7 @@ static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h, int back[3] = {0, 255, 0}; /* green background */ FILE *f; - f = fopen(filename, "w"); + f = fopen(filename, "wb"); if (!f) { perror(filename); return;