aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-17 13:33:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-19 04:58:30 +0200
commitc33b9fa74b6f167f472bd26e6ffa3cb796084c77 (patch)
treeee31b140aa8cb54ba4c3415a940be855a756f6c8
parenta42695c07244991ceabf9996d086dda3fcc28fc1 (diff)
downloadffmpeg-c33b9fa74b6f167f472bd26e6ffa3cb796084c77.tar.gz
avcodec/movtextdec: Simplify finding default font
There is no need to walk through the list of fonts twice. Reviewed-by: Philip Langdale <philipl@overt.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/movtextdec.c10
1 files 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;
}