From patchwork Mon Apr 6 17:52:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stebbins X-Patchwork-Id: 18722 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 EB09F44BD3F for ; Mon, 6 Apr 2020 20:55:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D451468B47A; Mon, 6 Apr 2020 20:55:53 +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 8FB9568B49C for ; Mon, 6 Apr 2020 20:55:52 +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:55:51 -0700 From: John Stebbins To: Date: Mon, 6 Apr 2020 11:52:04 -0600 Message-ID: <20200406175218.1299994-10-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 09/23] lavc/movtextdec: restore active style color after hilite 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" --- libavcodec/movtextdec.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 4d5dcdf5e7..f3a504b47b 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -376,6 +376,7 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, int text_pos = 0; int style_active = 0; int entry = 0; + int color = m->d.color; if (text < text_end && m->box_flags & TWRP_BOX) { if (m->w.wrap_flag == 1) { @@ -404,9 +405,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if (m->s[entry]->style_fontID == m->ftab[i]->fontID) av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font); } - if (m->d.color != m->s[entry]->color) - av_bprintf(buf, "{\\1c&H%X&}", - RGB_TO_BGR(m->s[entry]->color)); + if (m->d.color != m->s[entry]->color) { + color = m->s[entry]->color; + av_bprintf(buf, "{\\1c&H%X&}", RGB_TO_BGR(color)); + } if (m->d.alpha != m->s[entry]->alpha) av_bprintf(buf, "{\\1a&H%02X&}", 255 - m->s[entry]->alpha); } @@ -414,6 +416,7 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if (style_active) { av_bprintf(buf, "{\\r}"); style_active = 0; + color = m->d.color; } entry++; } @@ -435,9 +438,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, } if (text_pos == m->h.hlit_end) { if (m->box_flags & HCLR_BOX) { - av_bprintf(buf, "{\\2c&H000000&}"); + av_bprintf(buf, "{\\2c&H%X&}", RGB_TO_BGR(m->d.color)); } else { - av_bprintf(buf, "{\\1c&HFFFFFF&}{\\2c&H000000&}"); + av_bprintf(buf, "{\\1c&H%X&}{\\2c&H%X&}", + RGB_TO_BGR(color), RGB_TO_BGR(m->d.color)); } } }