diff mbox series

[FFmpeg-devel,21/23] lavc/movtextenc: simplify initialization of new style record

Message ID 20200406175218.1299994-22-jstebbins@jetheaddev.com
State Accepted
Commit dbdbcbf384d1e45bceb7e21d73b9e1b671ee48a3
Headers show
Series [FFmpeg-devel,01/23] lavc/movtextdec: fix ass header colors | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork warning Failed to apply patch

Commit Message

John Stebbins April 6, 2020, 5:52 p.m. UTC
---
 libavcodec/movtextenc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Philip Langdale April 8, 2020, 6:41 p.m. UTC | #1
On Mon, 6 Apr 2020 11:52:16 -0600
John Stebbins <jstebbins@jetheaddev.com> wrote:

> ---
>  libavcodec/movtextenc.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index 2e65489c4d..167dffee6a 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -96,8 +96,7 @@ static void mov_text_cleanup(MovTextContext *s)
>          av_freep(&s->style_attributes);
>      }
>      if (s->style_attributes_temp) {
> -        s->style_attributes_temp->style_flag = 0;
> -        s->style_attributes_temp->style_start = 0;
> +        *s->style_attributes_temp = s->d;
>      }
>  }
>  
> @@ -122,7 +121,7 @@ static void encode_styl(MovTextContext *s,
> uint32_t tsmb_type) style_start  =
> AV_RB16(&s->style_attributes[j]->style_start); style_end    =
> AV_RB16(&s->style_attributes[j]->style_end); style_color  =
> AV_RB32(&s->style_attributes[j]->style_color);
> -            style_fontID = AV_RB16(&s->d.style_fontID);
> +            style_fontID =
> AV_RB16(&s->style_attributes[j]->style_fontID); 
>              av_bprint_append_any(&s->buffer, &style_start, 2);
>              av_bprint_append_any(&s->buffer, &style_end, 2);
> @@ -259,14 +258,10 @@ static int mov_text_style_start(MovTextContext
> *s) return 0;
>          }
>  
> -        s->style_attributes_temp->style_flag =
> s->style_attributes[s->count - 1]->style_flag;
> -        s->style_attributes_temp->style_color =
> s->style_attributes[s->count - 1]->style_color;
> -        s->style_attributes_temp->style_fontsize =
> s->style_attributes[s->count - 1]->style_fontsize;
> +        *s->style_attributes_temp = s->d;
>          s->style_attributes_temp->style_start = s->text_pos;
>      } else { // style entry matches defaults, drop entry
> -        s->style_attributes_temp->style_flag = s->d.style_flag;
> -        s->style_attributes_temp->style_color = s->d.style_color;
> -        s->style_attributes_temp->style_fontsize =
> s->d.style_fontsize;
> +        *s->style_attributes_temp = s->d;
>          s->style_attributes_temp->style_start = s->text_pos;
>      }
>      return 1;

LGTM


--phil
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 2e65489c4d..167dffee6a 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -96,8 +96,7 @@  static void mov_text_cleanup(MovTextContext *s)
         av_freep(&s->style_attributes);
     }
     if (s->style_attributes_temp) {
-        s->style_attributes_temp->style_flag = 0;
-        s->style_attributes_temp->style_start = 0;
+        *s->style_attributes_temp = s->d;
     }
 }
 
@@ -122,7 +121,7 @@  static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
             style_start  = AV_RB16(&s->style_attributes[j]->style_start);
             style_end    = AV_RB16(&s->style_attributes[j]->style_end);
             style_color  = AV_RB32(&s->style_attributes[j]->style_color);
-            style_fontID = AV_RB16(&s->d.style_fontID);
+            style_fontID = AV_RB16(&s->style_attributes[j]->style_fontID);
 
             av_bprint_append_any(&s->buffer, &style_start, 2);
             av_bprint_append_any(&s->buffer, &style_end, 2);
@@ -259,14 +258,10 @@  static int mov_text_style_start(MovTextContext *s)
             return 0;
         }
 
-        s->style_attributes_temp->style_flag = s->style_attributes[s->count - 1]->style_flag;
-        s->style_attributes_temp->style_color = s->style_attributes[s->count - 1]->style_color;
-        s->style_attributes_temp->style_fontsize = s->style_attributes[s->count - 1]->style_fontsize;
+        *s->style_attributes_temp = s->d;
         s->style_attributes_temp->style_start = s->text_pos;
     } else { // style entry matches defaults, drop entry
-        s->style_attributes_temp->style_flag = s->d.style_flag;
-        s->style_attributes_temp->style_color = s->d.style_color;
-        s->style_attributes_temp->style_fontsize = s->d.style_fontsize;
+        *s->style_attributes_temp = s->d;
         s->style_attributes_temp->style_start = s->text_pos;
     }
     return 1;