From patchwork Sun Jun 10 23:08:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 9360 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp3453786jad; Sun, 10 Jun 2018 16:08:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSerM2ZkvD198DgxyJNYccOPZhyp27kvk4GOdHQ77ZMySTQdEq9Wlg1HFX9ywNr9cPHF/U X-Received: by 2002:adf:b0da:: with SMTP id j26-v6mr10360090wra.3.1528672133775; Sun, 10 Jun 2018 16:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528672133; cv=none; d=google.com; s=arc-20160816; b=ZYB3t4IkDg9FRo97v5a/e3x8bOaGqm2Qn1Fgzhc8vciCgXRpW3xstLp6PdxDO2BAV/ RxAaW411g6ghaAJQ85Am0l/NlTWKDoseEdo78124sVP8h3RM/S6neknIWCG7QoI32h40 F1C/X2pwJ1SeiggiqCayh0kJ1e0jpGVp5OkytPXwpV7CXEQImBFsXrjQdRgf5p35TEwL KA+DnzpeVyehIZ6Zv/SiGdfrQPdbOI7Sn+++x4WM+UHDqMKo0s9vdAWoJaxEAVWPwTwn kbFy07eoH846n2tv3u39NzemKwFqm9ZjzX6g52RP4W0PHXVNzYXqJgpHXiGspHEBjkqr czAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=v60Rn8z2T0g3SU3j1RwwBrbjcSxpO8Br/IFaxCgQ3c4=; b=CcXOlEAPr512ffHn+j5mMod/+2gwLWIzvLBZje+VJxtsThrxZ/qEA+u6tSusSCoFka tMOXPLIcaT4i6XIrX8YH/qI7B3BdAOtWgbqyyaExswGyzKiXdZaRvzNHgonxvJV9Xa8T R1EkqtkwCyt2JvlD0TaeHilx0FiZDjJOrDMMBxhU6nC81ewqvNkOuyn6zIw4DY7Xf9K8 R1el1/9dLPaVOsW42GmNwF4rEeBMGq62resMPD9NMdqqSH3aeWSfOjg86HedJBAUm/X2 py4MogFwLoYOFc+96giu0Ld5g3bNRrnIkq/a9GAPtgTBHTReut8ZkRyjIw0idnShCMvh 4tEg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 8-v6si5096750wmt.166.2018.06.10.16.08.52; Sun, 10 Jun 2018 16:08:53 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DD80968AA2D; Mon, 11 Jun 2018 02:08:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B40AE68AA17 for ; Mon, 11 Jun 2018 02:07:55 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A7A49E044E; Mon, 11 Jun 2018 01:08:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 37SCSjrz4U_e; Mon, 11 Jun 2018 01:08:43 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2C12AE03C1; Mon, 11 Jun 2018 01:08:43 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Jun 2018 01:08:37 +0200 Message-Id: <20180610230837.28726-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH] avcodec/libzvbi-teletextdec: propagate ERASE_PAGE flag for repeated subtitle page headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This works around a libzvbi bug (a corner case in the teletext spec): https://sourceforge.net/p/zapping/bugs/203/ https://sourceforge.net/p/zapping/patches/20/ Fixes samples/ffmpeg-bugs/trac/ticket2086/RBT_20100801_1835.ts. Signed-off-by: Marton Balint --- libavcodec/libzvbi-teletextdec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c index ccded23e7c..809547545b 100644 --- a/libavcodec/libzvbi-teletextdec.c +++ b/libavcodec/libzvbi-teletextdec.c @@ -74,6 +74,8 @@ typedef struct TeletextContext int readorder; uint8_t subtitle_map[2048]; + int last_pgno; + int last_p5; } TeletextContext; static int chop_spaces_utf8(const unsigned char* t, int len) @@ -372,6 +374,17 @@ static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size) int pgno = ((pmag & 7) << 8) + page; // Check for disabled NEWSFLASH flag and enabled SUBTITLE and SUPRESS_HEADER flags ctx->subtitle_map[pgno] = (!(flags1 & 0x40) && flags1 & 0x80 && flags2 & 0x01); + // Propagate ERASE_PAGE flag for repeated page headers to work around a libzvbi bug + if (ctx->subtitle_map[pgno] && pgno == ctx->last_pgno) { + int last_byte9 = vbi_unham8(ctx->last_p5); + if (last_byte9 >= 0 && last_byte9 & 0x8) { + int byte9 = vbi_unham8(p[5]); + if (byte9 >= 0) + p[5] = vbi_ham8(byte9 | 0x8); + } + } + ctx->last_pgno = pgno; + ctx->last_p5 = p[5]; } } lines++; @@ -494,6 +507,7 @@ static int teletext_init_decoder(AVCodecContext *avctx) ctx->vbi = NULL; ctx->pts = AV_NOPTS_VALUE; + ctx->last_pgno = -1; if (ctx->opacity == -1) ctx->opacity = ctx->transparent_bg ? 0 : 255; @@ -514,6 +528,7 @@ static int teletext_close_decoder(AVCodecContext *avctx) vbi_decoder_delete(ctx->vbi); ctx->vbi = NULL; ctx->pts = AV_NOPTS_VALUE; + ctx->last_pgno = -1; memset(ctx->subtitle_map, 0, sizeof(ctx->subtitle_map)); if (!(avctx->flags2 & AV_CODEC_FLAG2_RO_FLUSH_NOOP)) ctx->readorder = 0;