From patchwork Mon Apr 6 17:52:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stebbins X-Patchwork-Id: 18718 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 B208144BD3A for ; Mon, 6 Apr 2020 20:54:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CF0268B3FF; Mon, 6 Apr 2020 20:54:32 +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 BFD8368B3CB for ; Mon, 6 Apr 2020 20:54:25 +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:24 -0700 From: John Stebbins To: Date: Mon, 6 Apr 2020 11:52:00 -0600 Message-ID: <20200406175218.1299994-6-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 05/23] lavc/movtextdec: only write fontsize, fontID tags if not default 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index a3e37d013d..6c7d93702e 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -51,8 +51,9 @@ #define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff)) typedef struct { + uint16_t fontID; char *font; - int fontsize; + uint8_t fontsize; int color; int back_color; uint8_t bold; @@ -146,7 +147,6 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) uint8_t *tx3g_ptr = avctx->extradata; int i, box_size, font_length; int8_t v_align, h_align; - int style_fontID; StyleBox s_default; m->count_f = 0; @@ -192,7 +192,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) // StyleRecord tx3g_ptr += 4; // fontID - style_fontID = AV_RB16(tx3g_ptr); + m->d.fontID = AV_RB16(tx3g_ptr); tx3g_ptr += 2; // face-style-flags s_default.style_flag = *tx3g_ptr++; @@ -252,7 +252,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) tx3g_ptr = tx3g_ptr + font_length; } for (i = 0; i < m->ftab_entries; i++) { - if (style_fontID == m->ftab[i]->fontID) + if (m->d.fontID == m->ftab[i]->fontID) m->d.font = m->ftab[i]->font; } return 0; @@ -385,11 +385,13 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, 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) - av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font); - } + if (m->s[entry]->fontsize != m->d.fontsize) + av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize); + if (m->s[entry]->style_fontID != m->d.fontID) + for (i = 0; i < m->ftab_entries; i++) { + if (m->s[entry]->style_fontID == m->ftab[i]->fontID) + av_bprintf(buf, "{\\fn%s}", m->ftab[i]->font); + } } if (text_pos == m->s[entry]->style_end) { if (style_active) {