diff mbox series

[FFmpeg-devel,02/15] avformat/jacosubdec: Factorize code in get_shift() a bit

Message ID 20230930223046.22896-2-michael@niedermayer.cc
State Accepted
Commit 6490b9aed63c06f20bbc46e0bc801e612d07e81e
Headers show
Series [FFmpeg-devel,01/15] avformat/concatdec: Check in/outpoint for overflow | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Sept. 30, 2023, 10:30 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/jacosubdec.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 61b1316dc9b..42c201f93af 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -143,16 +143,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;