From patchwork Mon Apr 6 17:51:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stebbins X-Patchwork-Id: 18717 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E139D44BD3A for ; Mon, 6 Apr 2020 20:54:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CD55168B393; Mon, 6 Apr 2020 20:54:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.jetheaddev.com (mail.jetheaddev.com [70.164.99.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5F6668B393 for ; Mon, 6 Apr 2020 20:54:17 +0300 (EEST) Received: from creator.alpe-d-promontory.fun (192.168.13.165) by cas.jetheaddev.com (192.168.13.27) with Microsoft SMTP Server (TLS) id 14.3.351.0; Mon, 6 Apr 2020 10:54:16 -0700 From: John Stebbins To: Date: Mon, 6 Apr 2020 11:51:59 -0600 Message-ID: <20200406175218.1299994-5-jstebbins@jetheaddev.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200406175218.1299994-1-jstebbins@jetheaddev.com> References: <20200406175218.1299994-1-jstebbins@jetheaddev.com> MIME-Version: 1.0 X-Originating-IP: [192.168.13.165] Subject: [FFmpeg-devel] [PATCH 04/23] lavc/movtextdec: handle changes to default style flags 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Style flags were only being turned on. If the default was on and style record turned off, style flag remained on. --- libavcodec/movtextdec.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index d6896562c2..a3e37d013d 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -55,9 +55,9 @@ typedef struct { int fontsize; int color; int back_color; - int bold; - int italic; - int underline; + uint8_t bold; + uint8_t italic; + uint8_t underline; int alignment; } MovTextDefault; @@ -70,6 +70,9 @@ typedef struct { uint16_t style_start; uint16_t style_end; uint8_t style_flag; + uint8_t bold; + uint8_t italic; + uint8_t underline; uint8_t fontsize; uint16_t style_fontID; } StyleBox; @@ -313,6 +316,9 @@ static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) m->s_temp->style_fontID = AV_RB16(tsmb); tsmb += 2; m->s_temp->style_flag = AV_RB8(tsmb); + m->s_temp->bold = !!(m->s_temp->style_flag & STYLE_FLAG_BOLD); + m->s_temp->italic = !!(m->s_temp->style_flag & STYLE_FLAG_ITALIC); + m->s_temp->underline = !!(m->s_temp->style_flag & STYLE_FLAG_UNDERLINE); tsmb++; m->s_temp->fontsize = AV_RB8(tsmb); av_dynarray_add(&m->s, &m->count_s, m->s_temp); @@ -373,12 +379,12 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if ((m->box_flags & STYL_BOX) && entry < m->style_entries) { if (text_pos == m->s[entry]->style_start) { style_active = 1; - if (m->s[entry]->style_flag & STYLE_FLAG_BOLD) - av_bprintf(buf, "{\\b1}"); - if (m->s[entry]->style_flag & STYLE_FLAG_ITALIC) - av_bprintf(buf, "{\\i1}"); - if (m->s[entry]->style_flag & STYLE_FLAG_UNDERLINE) - av_bprintf(buf, "{\\u1}"); + if (m->s[entry]->bold ^ m->d.bold) + av_bprintf(buf, "{\\b%d}", m->s[entry]->bold); + if (m->s[entry]->italic ^ m->d.italic) + av_bprintf(buf, "{\\i%d}", m->s[entry]->italic); + if (m->s[entry]->underline ^ m->d.underline) + av_bprintf(buf, "{\\u%d}", m->s[entry]->underline); av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize); for (i = 0; i < m->ftab_entries; i++) { if (m->s[entry]->style_fontID == m->ftab[i]->fontID)