diff mbox series

[FFmpeg-devel,2/8] avutil/timecode: cosmetics on av_timecode_get_smpte

Message ID 20200905182217.28037-2-cus@passwd.hu
State Accepted
Commit d0596e0bb0ea6536aa13090e0f920d8e532c975b
Headers show
Series [FFmpeg-devel,1/8] avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Marton Balint Sept. 5, 2020, 6:22 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavutil/timecode.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Lance Wang Sept. 6, 2020, 1:36 p.m. UTC | #1
On Sat, Sep 05, 2020 at 08:22:11PM +0200, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavutil/timecode.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/libavutil/timecode.c b/libavutil/timecode.c
> index cb916970ef..c0956adadb 100644
> --- a/libavutil/timecode.c
> +++ b/libavutil/timecode.c
> @@ -71,31 +71,28 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
>  uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff)
>  {
>      uint32_t tc = 0;
> -    uint32_t frames;
>  
>      /* For SMPTE 12-M timecodes, frame count is a special case if > 30 FPS.
>         See SMPTE ST 12-1:2014 Sec 12.1 for more info. */
>      if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
> -        frames = ff / 2;
>          if (ff % 2 == 1) {
>              if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
>                  tc |= (1 << 7);
>              else
>                  tc |= (1 << 23);
>          }
> -    } else {
> -        frames = ff;
> +        ff /= 2;
>      }
>  
>      tc |= drop << 30;
> -    tc |= (frames / 10) << 28;
> -    tc |= (frames % 10) << 24;
> +    tc |= (ff / 10) << 28;
> +    tc |= (ff % 10) << 24;
>      tc |= (ss / 10) << 20;
>      tc |= (ss % 10) << 16;
>      tc |= (mm / 10) << 12;
>      tc |= (mm % 10) << 8;
>      tc |= (hh / 10) << 4;
> -    tc |= (hh  % 10);
> +    tc |= (hh % 10);

lgtm

>  
>      return tc;
>  }
> -- 
> 2.26.2
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index cb916970ef..c0956adadb 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -71,31 +71,28 @@  uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
 uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff)
 {
     uint32_t tc = 0;
-    uint32_t frames;
 
     /* For SMPTE 12-M timecodes, frame count is a special case if > 30 FPS.
        See SMPTE ST 12-1:2014 Sec 12.1 for more info. */
     if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
-        frames = ff / 2;
         if (ff % 2 == 1) {
             if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
                 tc |= (1 << 7);
             else
                 tc |= (1 << 23);
         }
-    } else {
-        frames = ff;
+        ff /= 2;
     }
 
     tc |= drop << 30;
-    tc |= (frames / 10) << 28;
-    tc |= (frames % 10) << 24;
+    tc |= (ff / 10) << 28;
+    tc |= (ff % 10) << 24;
     tc |= (ss / 10) << 20;
     tc |= (ss % 10) << 16;
     tc |= (mm / 10) << 12;
     tc |= (mm % 10) << 8;
     tc |= (hh / 10) << 4;
-    tc |= (hh  % 10);
+    tc |= (hh % 10);
 
     return tc;
 }