From patchwork Mon Jan 10 19:55:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33192 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3046057iog; Mon, 10 Jan 2022 11:55:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC1XOYNJwV80GlD5BPniZW6RE6Tmk36om3mEbK01ev5oz8JrNy2dSngnFAMRStQ8w+zNzF X-Received: by 2002:a17:907:7fab:: with SMTP id qk43mr1019821ejc.624.1641844548471; Mon, 10 Jan 2022 11:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641844548; cv=none; d=google.com; s=arc-20160816; b=Wt3m6/I0pru89nihRjslPn0gWUABz2jZDQdPubi+yanAa64ftuXTIDpD7POQV3e1An Fndi/F93mfbU/vGM62wplWS7/++Zs2Hp3RwIvvPtjqChctfTTR+PQ2P9nVY+Jd5oDLEM pMeZg5MZClUEElA1t/MX08x3jpcYpFyT8j13dR3pQLm9vCApzDjJZOEKomwZFH+px/bv +AOfmdb2RDbc/43gH/DiRrCQPj6xyErMoMQQXYetWcUmkmV8EYYKyRTedhwCCsoaelK0 1AZ1an0cLv1DgK5+S401d3B8sV7ZcdvyCpZrJGxRbj5uU5PvVuaCDAEilHuz0ceWZ5Bs l5Bg== 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=lgxh4rN0ph3MWDgYd2gigCbl7EWqCe7hIxYqS2Dbpeg=; b=Ug4ZtuTk9Rmgc/Z+vAYDhd67xM6klvN8umKbJ9HcFwaXCBltWCL9XK5g4Z9u2fmDPI Gif/Y6HxhAvcSAoMcKiru7THZSyM2b70eS8C9DwbP+GjSRiaJL774xkSa8E84ql0b50Q cctLZ5wYdsbqmiQ8taB7s4A1+tKyLE1VVuouu9Huzm7qa1Qe+1Gkaag+jJDHHc7wyq/u uQbVvp8/PLNy2aQ+1eUNzw8AHuE93ncAAiQR2k/D/UxknjL+jTtmow19/lSAybjI8gOo HCQSXNiqiVl4IfyQw26R//jzR5snB8lNxPzBtVnGuyXWp5fKennrM+/X2ndtbchjRwTL Priw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=eKEVBZg9; 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 qx3si3639729ejb.345.2022.01.10.11.55.47; Mon, 10 Jan 2022 11:55:48 -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=eKEVBZg9; 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 8D00E68A4AC; Mon, 10 Jan 2022 21:55:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F1A3689D48 for ; Mon, 10 Jan 2022 21:55:36 +0200 (EET) Received: by mail-pj1-f53.google.com with SMTP id m13so14846064pji.3 for ; Mon, 10 Jan 2022 11:55:36 -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=WTYbWltxZhq+x3qyAnJFVQpa4ZOs6jWCblR/c4/IPaI=; b=eKEVBZg9k4f23e3CaM0TjWDrMZokI5RWR0SMn5ObirJZ6/Rjz69pWZiHktRPsy2sd9 5pTP9d/jJpW44sqnwt340Kynv7cuCyTVbErk3o9K0/3zDelLLMPwY2bgZqg4/9Twf1Mp 7htsIUnZykzUxw6UwqWVDjnYsXYqx8r1s3aNHDcWyswB/uVZFXlj+R24nI/l7U8h7uvv +yKmErYQ5+Dxe+c7daNqaDoJqWC+FErreLGdQFSB3IFABzBIByzmCXf9pg7Q9qRCu8M9 3aiIIh/VUAPoV0eChJFTQy7YJagdNmq6hKtPMAg6GKnXvHqPmvt0m2rMPUl4yMZm1jdc u6NA== 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=WTYbWltxZhq+x3qyAnJFVQpa4ZOs6jWCblR/c4/IPaI=; b=xrrAvurJHWeWB3eXnYaJnj1yShT4+CS7LF/4/yTlee+1xLz+8yUu2FMWJQ0bKvMKhW L6o7kAgcuT9wrXEIKRx/ca63oJKRnnFQpOhK+lwoWnxnfoRMq80LlfqFoWf1gN9pQska T8pw2gbCrATvQxEVCh2FBxwRJqBYx8s1Zb0kczYN8QHuNQVofv/RGwhfzRZbO2slNIwz HLQD92VG9WSPMqh0+i/4gYrenW2PvwkEMwBJf8KTZ8gm939okQ9TXSQX7i4HXTs1BNd1 BSQe5mkQoNRO1zWmAoVFDmVbkxawTPjPBhsXeAa3QhiZojeh31LF5o0nSA2IxajbJ4Nr KvuA== X-Gm-Message-State: AOAM530eEZB8KDhXf9XLf2Bm9aVqlYJlad16xyvYHdrwhIoOPGPbtfLW Dj4/CvfEWLUEV4A/bD7j3UQIM291ePVAaw== X-Received: by 2002:a17:902:e5c4:b0:149:e3fc:fa58 with SMTP id u4-20020a170902e5c400b00149e3fcfa58mr1037520plf.142.1641844534592; Mon, 10 Jan 2022 11:55:34 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d185sm6271424pgc.58.2022.01.10.11.55.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jan 2022 11:55:34 -0800 (PST) Message-Id: In-Reply-To: References: From: ffmpegagent Date: Mon, 10 Jan 2022 19:55:31 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 0/2] avcodec/dvbsubdec, dvdsubdec: 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: ywrWZSNeMk/W It's annoying and unexpected, but still useful at times (as I've realized just recently). This is a follow-up to the earlier submission here: https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg128080.html There has been a comment from Anton, questioning whether the dump-feature is useful. Meanwhile I came to the conclusion that it can be useful in-fact. It just shouldn't happen automatically when DEBUG is defined. That's what these patches do. I also added fixes for the fopen() call. softworkz (2): avcodec/dvdsubdec,dvbsubdec: don't dump images to disk based on DEBUG define avcodec/dvdsubdec,dvbsubdec: fix writing ppm libavcodec/dvbsubdec.c | 20 +++++++++++++------- libavcodec/dvdsubdec.c | 11 ++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) base-commit: 6c4074e4234edacfb3f37184fd68771df3cb2b7f Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-17%2Fsoftworkz%2Fsubmit_dvb_subs-v2 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-17/softworkz/submit_dvb_subs-v2 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/17 Range-diff vs v1: 1: 6ca8905c3d ! 1: 2f12ac7f1f avcodec/dvbsubdec: don't dump images to disk based on DEBUG define @@ Metadata Author: softworkz ## Commit message ## - avcodec/dvbsubdec: don't dump images to disk based on DEBUG define + avcodec/dvdsubdec,dvbsubdec: don't dump images to disk based on DEBUG define It's been a regular annoyance. Introduce a debug-only parameter for this. @@ libavcodec/dvbsubdec.c: static const AVOption options[] = { {NULL} }; static const AVClass dvbsubdec_class = { + + ## libavcodec/dvdsubdec.c ## +@@ libavcodec/dvdsubdec.c: typedef struct DVDSubContext + uint8_t used_color[256]; + #ifdef DEBUG + int sub_id; ++ int dump_imgs; + #endif + } DVDSubContext; + +@@ libavcodec/dvdsubdec.c: 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 + +@@ libavcodec/dvdsubdec.c: 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 = { 2: 8da6e4ab17 ! 2: 0cd2c77f31 avcodec/dvbsubdec: fix writing ppm @@ Metadata Author: softworkz ## Commit message ## - avcodec/dvbsubdec: fix writing ppm + avcodec/dvdsubdec,dvbsubdec: fix writing ppm fopen needs (b)inary mode @@ libavcodec/dvbsubdec.c: static void png_save(DVBSubContext *ctx, const char *fil if (!f) { perror(fname2); return; + + ## libavcodec/dvdsubdec.c ## +@@ libavcodec/dvdsubdec.c: 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; 3: 9186ff48ec < -: ---------- avcodec/dvdsubdec: don't dump images to disk based on DEBUG define 4: 341474e338 < -: ---------- avcodec/dvdsubdec: fix writing ppm