[FFmpeg-cvslog] avformat/jacosubdec: clarify code

Michael Niedermayer git at videolan.org
Sun Apr 14 21:33:22 EEST 2024


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Tue Oct 10 19:52:33 2023 +0200| [24f1cb160831d1cc0a207028b45455dde5e69da8] | committer: Michael Niedermayer

avformat/jacosubdec: clarify code

add comments, rename variables and indent things differently

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit e83e8d443b5b86aabf17d1cfb7fba9abf15e24fd)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=24f1cb160831d1cc0a207028b45455dde5e69da8
---

 libavformat/jacosubdec.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index d112110327..617dcaf1ef 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -135,28 +135,28 @@ shift_and_ret:
 static int get_shift(unsigned timeres, const char *buf)
 {
     int sign = 1;
-    int a = 0, b = 0, c = 0, d = 0;
+    int h = 0, m = 0, s = 0, d = 0;
     int64_t ret;
 #define SSEP "%*1[.:]"
-    int n = sscanf(buf, "%d"SSEP"%d"SSEP"%d"SSEP"%d", &a, &b, &c, &d);
+    int n = sscanf(buf, "%d"SSEP"%d"SSEP"%d"SSEP"%d", &h, &m, &s, &d);
 #undef SSEP
 
-    if (a == INT_MIN)
+    if (h == INT_MIN)
         return 0;
 
-    if (*buf == '-' || a < 0) {
+    if (*buf == '-' || h < 0) {
         sign = -1;
-        a = FFABS(a);
+        h = FFABS(h);
     }
 
     ret = 0;
     switch (n) {
-    case 1:                      a = 0;
-    case 2:        c = b; b = a; a = 0;
-    case 3: d = c; c = b; b = a; a = 0;
+    case 1:        h = 0;                   //clear all in case of a single parameter
+    case 2: s = m; m = h; h = 0;            //shift into second subsecondd
+    case 3: d = s; s = m; m = h; h = 0;     //shift into minute second subsecond
     }
 
-    ret = (int64_t)a*3600 + (int64_t)b*60 + c;
+    ret = (int64_t)h*3600 + (int64_t)m*60 + s;
     if (FFABS(ret) > (INT64_MAX - FFABS(d)) / timeres)
         return 0;
     ret = sign * (ret * timeres + d);



More information about the ffmpeg-cvslog mailing list