[FFmpeg-cvslog] avformat/jacosubdec: Factorize code in get_shift() a bit

Michael Niedermayer git at videolan.org
Fri Dec 22 01:52:53 EET 2023


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Sat Sep 30 19:34:29 2023 +0200| [37b247bd605149e6ef15c63aed111c0201d51a44] | committer: Michael Niedermayer

avformat/jacosubdec: Factorize code in get_shift() a bit

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

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

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

diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 59544bb507..d4c055f0f7 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -151,16 +151,12 @@ static int get_shift(int timeres, const char *buf)
 
     ret = 0;
     switch (n) {
-    case 4:
-        ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
-        break;
-    case 3:
-        ret = sign * ((         (int64_t)a*60 + b) * timeres + c);
-        break;
-    case 2:
-        ret = sign * ((                (int64_t)a) * timeres + b);
-        break;
+    case 1:                      a = 0;
+    case 2:        c = b; b = a; a = 0;
+    case 3: d = c; c = b; b = a; a = 0;
     }
+
+    ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
     if ((int)ret != ret)
         ret = 0;
 



More information about the ffmpeg-cvslog mailing list