From patchwork Mon Sep 19 17:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Theisen X-Patchwork-Id: 38058 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1396308pzh; Mon, 19 Sep 2022 10:56:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/0lEnAdaCTK7Nx8HG02cVVUtCueHlXn72IMZzVLRpiEq8Yk8uhzFQRDprBqKMZyPdhdrF X-Received: by 2002:aa7:dd0a:0:b0:44e:a27b:fec with SMTP id i10-20020aa7dd0a000000b0044ea27b0fecmr16003035edv.168.1663610164658; Mon, 19 Sep 2022 10:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663610164; cv=none; d=google.com; s=arc-20160816; b=FVbdI1Eeqtnw7Tfo3LImXJmRIx/x4CkSKZJANnVImvhaI6YJyEl+JZzC9OEgIC1sEJ gZXa6mDxVh3BlRvLvkvNwPWZ2sWLC23hCKeDXy5uB6e/yoNCIATfl1dbPDeikNeY6lJx k4Hv0DtpRceYzLJ+4HEEKltA/oynxPRi68nU0C0pbsVqUQt/361uepz/8ww15Owk74oF soV/TnV2MI+U6qdxezbyMvKnPwylgEh6SVLSrBikUsug+gHR7XZaXCpMifP6qKTckXrj /5nbet1Z3iQ6TMywgx3CQTSh+t1Br6+z5N6u6c+bkUravqCPfxO/tQKg81wDCQJ15atr iEzQ== 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:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=++CjZoGV66MnFdt5qONGPFsQrD5/keH9OHNYnl6HCyc=; b=pwZvGotZ5ImqEyXbSMHGOn8mmFnbHeqnqfHZVYbdp7T/oferEL9t1YZ5tv8+6315+u LYSyxsSP060tLRtDseaq53X6AB8alQFOXPAB0pxhAzc7XxtPo0+qqcYiebs295avOB2f Ak9AKN/5BZFLTxbT0I5qEPHgXwMRMxem4n6+UXwB8F7fleStTORIzZTfTyzAjbrYtFNj 5dDaEwWKWcaUF9LnfHzEU02X2gI0Lz5P15U9BBLr5NKLNA87tMsGQBUYx7zpVf75mXF5 c90vdgAr2X5loOs+JEOvlcQgEyE925pXOooKuU2+i0dQzKfmxRpPVhPEAtUvCFweg/CU s3Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="I/PnBl/8"; 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 v21-20020aa7cd55000000b004512f3e3e03si8184579edw.146.2022.09.19.10.56.03; Mon, 19 Sep 2022 10:56:04 -0700 (PDT) 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="I/PnBl/8"; 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 A6A6A68BA30; Mon, 19 Sep 2022 20:56:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82D3468B726 for ; Mon, 19 Sep 2022 20:55:54 +0300 (EEST) Received: by mail-qk1-f179.google.com with SMTP id d17so20265045qko.13 for ; Mon, 19 Sep 2022 10:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=YCOU+jK+pRlMnkNQw2oyhVb5OteKtIVEu+1G69b5XwE=; b=I/PnBl/8sWLtJy5GF/9EDnFpVID505t7l1zJpiVklaXSFZyDP56P81KuDP150k7WKY T4xC5n4zkKYsQbwIivW9/LJGtBIaXuy1vMQ3T395qKRV+kb4/q1edhuk3RwUvlYvIwSf mbKBDd9W3BiWffgEP93q6Zxska1DN3pdnKz2wCUTTVetYadIaPUcWSrIVePY70J47J1c SivCbNcs66txTkOMnlYMriaOBeRJnh+4w7nipw5sBIrUzCodpzHLN5FlOBdWA4p0pfbu VLOBi32+X/CIAMWS1QSJww9LzLrhBzrm6ypBWdkqnNTismq+IdQ/MhGmkv6gndIkPBLq K97A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=YCOU+jK+pRlMnkNQw2oyhVb5OteKtIVEu+1G69b5XwE=; b=i36uWGEQBZ0x6BQirHHWdBZb5/ZHMa3EcfWxFXDCbDRX5qrevcvZgK9gcLW6+u5jsE lfo2WQoMtIdhRjVGrFRBRmLxVYGnhkzuZ4QGM1SUAt4ZUpqMrEKpIoGYJ+37lYQbLwlC 81zyY9t8F0GD8uz87tArb9ijiyUF7mqum6n2wHb14awdOWI8DtKzZcYKBALSNi7omLjd YYqvAw358bzSd+QcfN/8ky6JRmtGiSgc4cHNeX4qtQVRVNk+Hi62iFNPWBe2CDcec0vc 3zHXwktwYFq/xOMK7KLG1jvk/BkusZHOSTgwKuTRLzxG8ywm6nmZdBf02cRiVhNr9yeq T6iQ== X-Gm-Message-State: ACrzQf3tesL+dKhRDan01Ff4dcWXy0iM/7dk4HgRe5dc97O5meAcp27n ST34u1Zvk2r5HWHH4ZPsqcNQoYjEq54= X-Received: by 2002:a05:620a:240f:b0:6ce:9ac3:5f92 with SMTP id d15-20020a05620a240f00b006ce9ac35f92mr14119875qkn.707.1663610152334; Mon, 19 Sep 2022 10:55:52 -0700 (PDT) Received: from scott-desktop.. (pool-71-114-80-52.washdc.fios.verizon.net. [71.114.80.52]) by smtp.gmail.com with ESMTPSA id k13-20020a05620a414d00b006c479acd82fsm14279166qko.7.2022.09.19.10.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 10:55:51 -0700 (PDT) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 13:55:34 -0400 Message-Id: <20220919175534.102124-1-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc: add detection of forced subtitles 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: Scott Theisen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ercle8sC213V This is from the following MythTV commits: libavcodec: add support for detecting forced subtitle segments. https://github.com/MythTV/mythtv/commit/5099f1a5777966fba482b623e581c1eef5c8fc09 This adds forced subtitle segment detection to the PGS subtitle decoder and copies the result to AVSubtitle. Subtitles: Flag forced DVD subtitles. https://github.com/MythTV/mythtv/commit/78f71eecdbd53ba92af2ad639b32564c01f24563 --- libavcodec/avcodec.h | 1 + libavcodec/dvdsubdec.c | 4 +++- libavcodec/pgssubdec.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7db5d1b1c5..b9aa9efb2f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2331,6 +2331,7 @@ typedef struct AVSubtitle { unsigned num_rects; AVSubtitleRect **rects; int64_t pts; ///< Same as packet pts, in AV_TIME_BASE + int forced; } AVSubtitle; /** diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index a5da0d7b08..1504706d52 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -418,8 +418,10 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, break; cmd_pos = next_cmd_pos; } - if (sub_header->num_rects > 0) + if (sub_header->num_rects > 0) { + sub_header->forced = is_menu; return is_menu; + } fail: reset_rects(sub_header); return -1; diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 5f76f12615..7c953263bb 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -62,6 +62,7 @@ typedef struct PGSSubPresentation { int id_number; int palette_id; int object_count; + int object_forced; PGSSubObjectRef objects[MAX_OBJECT_REFS]; int64_t pts; } PGSSubPresentation; @@ -466,6 +467,8 @@ static int parse_presentation_segment(AVCodecContext *avctx, object->crop_h = bytestream_get_be16(&buf); } + ctx->presentation.object_forced = (ctx->presentation.objects[i].composition_flag & 0x40) >> 6; + ff_dlog(avctx, "Subtitle Placement x=%d, y=%d\n", object->x, object->y); @@ -505,6 +508,7 @@ static int display_end_segment(AVCodecContext *avctx, AVSubtitle *sub, memset(sub, 0, sizeof(*sub)); sub->pts = pts; ctx->presentation.pts = AV_NOPTS_VALUE; + sub->forced = ctx->presentation.object_forced; sub->start_display_time = 0; // There is no explicit end time for PGS subtitles. The end time // is defined by the start of the next sub which may contain no