diff mbox series

[FFmpeg-devel,1/5] avcodec/cfhd, cfhddata: Simplify check for escape

Message ID AS8P250MB07443029028BA4485D8478F18F7D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 6b1a7fc8bd473aa4e644a64335eb93044647f96d
Headers show
Series [FFmpeg-devel,1/5] avcodec/cfhd, cfhddata: Simplify check for escape | 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

Andreas Rheinhardt Sept. 3, 2022, 8:30 p.m. UTC
cfhd.c checked for level being equal to a certain codebook-
dependent constant and to run being two. The first check is
actually redundant, as all codebooks contain only one (real)
entry with run == 2 (as is usual with VLCs, this one real entry
has several corresponding entries in the table). But given
that no entry has a run of zero (except incomplete entries
which just signal that one needs to do another round of parsing),
one can actually use that as sentinel. This patch does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
One could now deduplicate reading the RL VLCs; or one could
branch based upon whether (codebook == 0) || (codebook == 1) or not
as this is the actual check in dequant_and_decompand().

 libavcodec/cfhd.c     | 4 ++--
 libavcodec/cfhddata.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 7afbbac59e..90b3d0a850 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -819,7 +819,7 @@  static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic,
                                    VLC_BITS, 3, 1);
 
                         /* escape */
-                        if (level == 64 && run == 2)
+                        if (!run)
                             break;
 
                         count += run;
@@ -850,7 +850,7 @@  static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic,
                                    VLC_BITS, 3, 1);
 
                         /* escape */
-                        if (level == 255 && run == 2)
+                        if (!run)
                             break;
 
                         count += run;
diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c
index 67bd8e66db..212dccadb9 100644
--- a/libavcodec/cfhddata.c
+++ b/libavcodec/cfhddata.c
@@ -72,7 +72,7 @@  static const uint16_t table_9_vlc_run[NB_VLC_TABLE_9] = {
     1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,
-    1,    2,
+    1,    0,
 };
 
 static const uint8_t table_9_vlc_level[NB_VLC_TABLE_9] = {
@@ -226,7 +226,7 @@  static const uint16_t table_18_vlc_run[NB_VLC_TABLE_18] = {
      1,    1,    1,    1,    1,    1,    1,    1,
      1,    1,    1,    1,    1,    1,    1,    1,
      1,    1,    1,    1,    1,    1,    1,    1,
-     1,    1,    1,    1,    1,    1,    1,    2,
+     1,    1,    1,    1,    1,    1,    1,    0,
 };
 
 static const uint8_t table_18_vlc_level[NB_VLC_TABLE_18] = {