[FFmpeg-cvslog] avcodec/movtextdec: Simplify finding default font
Andreas Rheinhardt
git at videolan.org
Mon Oct 19 06:37:16 EEST 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Oct 17 13:33:07 2020 +0200| [c33b9fa74b6f167f472bd26e6ffa3cb796084c77] | committer: Andreas Rheinhardt
avcodec/movtextdec: Simplify finding default font
There is no need to walk through the list of fonts twice.
Reviewed-by: Philip Langdale <philipl at overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c33b9fa74b6f167f472bd26e6ffa3cb796084c77
---
libavcodec/movtextdec.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index e46c932c20..974118c4c1 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -145,7 +145,7 @@ static void mov_text_cleanup_ftab(MovTextContext *m)
static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
{
uint8_t *tx3g_ptr = avctx->extradata;
- int i, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL;
+ int i, j = -1, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL;
int8_t v_align, h_align;
unsigned ftab_entries;
StyleBox s_default;
@@ -230,6 +230,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
for (i = 0; i < m->ftab_entries; i++) {
m->ftab[i].fontID = AV_RB16(tx3g_ptr);
+ if (m->ftab[i].fontID == m->d.fontID)
+ j = i;
tx3g_ptr += 2;
font_length = *tx3g_ptr++;
@@ -247,10 +249,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
m->ftab[i].font[font_length] = '\0';
tx3g_ptr = tx3g_ptr + font_length;
}
- for (i = 0; i < m->ftab_entries; i++) {
- if (m->d.fontID == m->ftab[i].fontID)
- m->d.font = m->ftab[i].font;
- }
+ if (j >= 0)
+ m->d.font = m->ftab[j].font;
return 0;
}
More information about the ffmpeg-cvslog
mailing list