[FFmpeg-cvslog] lavc/h264: move some shared code from h264dec to h264_parse

Anton Khirnov git at videolan.org
Wed Jan 26 16:44:29 EET 2022


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jan 24 18:00:08 2022 +0100| [d552f2535be0dd47330412e8e11e1923ca99f92f] | committer: Andreas Rheinhardt

lavc/h264: move some shared code from h264dec to h264_parse

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

 libavcodec/h264_parse.h  | 32 ++++++++++++++++++++++++++++++++
 libavcodec/h264dec.h     | 26 --------------------------
 tests/checkasm/h264dsp.c |  1 +
 3 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/libavcodec/h264_parse.h b/libavcodec/h264_parse.h
index 05732326d3..52b224f4c5 100644
--- a/libavcodec/h264_parse.h
+++ b/libavcodec/h264_parse.h
@@ -24,9 +24,32 @@
 #ifndef AVCODEC_H264_PARSE_H
 #define AVCODEC_H264_PARSE_H
 
+#include "config.h"
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+
 #include "get_bits.h"
 #include "h264_ps.h"
 
+// This table must be here because scan8[constant] must be known at compiletime
+static const uint8_t scan8[16 * 3 + 3] = {
+    4 +  1 * 8, 5 +  1 * 8, 4 +  2 * 8, 5 +  2 * 8,
+    6 +  1 * 8, 7 +  1 * 8, 6 +  2 * 8, 7 +  2 * 8,
+    4 +  3 * 8, 5 +  3 * 8, 4 +  4 * 8, 5 +  4 * 8,
+    6 +  3 * 8, 7 +  3 * 8, 6 +  4 * 8, 7 +  4 * 8,
+    4 +  6 * 8, 5 +  6 * 8, 4 +  7 * 8, 5 +  7 * 8,
+    6 +  6 * 8, 7 +  6 * 8, 6 +  7 * 8, 7 +  7 * 8,
+    4 +  8 * 8, 5 +  8 * 8, 4 +  9 * 8, 5 +  9 * 8,
+    6 +  8 * 8, 7 +  8 * 8, 6 +  9 * 8, 7 +  9 * 8,
+    4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8,
+    6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8,
+    4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8,
+    6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8,
+    0 +  0 * 8, 0 +  5 * 8, 0 + 10 * 8
+};
+
 /**
  * Memory management control operation opcode.
  */
@@ -103,4 +126,13 @@ int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
  */
 int ff_h264_get_profile(const SPS *sps);
 
+static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
+{
+#if HAVE_BIGENDIAN
+    return (b & 0xFFFF) + (a << 16);
+#else
+    return (a & 0xFFFF) + (b << 16);
+#endif
+}
+
 #endif /* AVCODEC_H264_PARSE_H */
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 7553dd808c..5266420fa1 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -642,32 +642,6 @@ void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int
 #define LUMA_DC_BLOCK_INDEX   48
 #define CHROMA_DC_BLOCK_INDEX 49
 
-// This table must be here because scan8[constant] must be known at compiletime
-static const uint8_t scan8[16 * 3 + 3] = {
-    4 +  1 * 8, 5 +  1 * 8, 4 +  2 * 8, 5 +  2 * 8,
-    6 +  1 * 8, 7 +  1 * 8, 6 +  2 * 8, 7 +  2 * 8,
-    4 +  3 * 8, 5 +  3 * 8, 4 +  4 * 8, 5 +  4 * 8,
-    6 +  3 * 8, 7 +  3 * 8, 6 +  4 * 8, 7 +  4 * 8,
-    4 +  6 * 8, 5 +  6 * 8, 4 +  7 * 8, 5 +  7 * 8,
-    6 +  6 * 8, 7 +  6 * 8, 6 +  7 * 8, 7 +  7 * 8,
-    4 +  8 * 8, 5 +  8 * 8, 4 +  9 * 8, 5 +  9 * 8,
-    6 +  8 * 8, 7 +  8 * 8, 6 +  9 * 8, 7 +  9 * 8,
-    4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8,
-    6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8,
-    4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8,
-    6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8,
-    0 +  0 * 8, 0 +  5 * 8, 0 + 10 * 8
-};
-
-static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
-{
-#if HAVE_BIGENDIAN
-    return (b & 0xFFFF) + (a << 16);
-#else
-    return (a & 0xFFFF) + (b << 16);
-#endif
-}
-
 /**
  * Get the chroma qp.
  */
diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 7392452957..3c95f9d74d 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -23,6 +23,7 @@
 #include "libavcodec/avcodec.h"
 #include "libavcodec/h264dsp.h"
 #include "libavcodec/h264data.h"
+#include "libavcodec/h264_parse.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"



More information about the ffmpeg-cvslog mailing list