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>
This commit is contained in:
Andreas Rheinhardt 2020-10-17 13:33:07 +02:00
parent a42695c072
commit c33b9fa74b
1 changed files with 5 additions and 5 deletions

View File

@ -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;
}