[FFmpeg-devel] [PATCHv2 1/6] avcodec/vp3dsp: move vp3 init loop filter function to vp3dsp

Peter Ross pross at xvid.org
Mon Jan 14 22:47:26 EET 2019


This is also used by the VP6 decoder.
---
 libavcodec/vp3.c    | 22 +---------------------
 libavcodec/vp3dsp.c | 32 ++++++++++++++++++++++++++++++++
 libavcodec/vp3dsp.h |  2 ++
 3 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index a5d8c2ed0b..b248c90413 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -416,27 +416,7 @@ static void init_dequantizer(Vp3DecodeContext *s, int qpi)
  */
 static void init_loop_filter(Vp3DecodeContext *s)
 {
-    int *bounding_values = s->bounding_values_array + 127;
-    int filter_limit;
-    int x;
-    int value;
-
-    filter_limit = s->filter_limit_values[s->qps[0]];
-    av_assert0(filter_limit < 128U);
-
-    /* set up the bounding values */
-    memset(s->bounding_values_array, 0, 256 * sizeof(int));
-    for (x = 0; x < filter_limit; x++) {
-        bounding_values[-x] = -x;
-        bounding_values[x] = x;
-    }
-    for (x = value = filter_limit; x < 128 && value; x++, value--) {
-        bounding_values[ x] =  value;
-        bounding_values[-x] = -value;
-    }
-    if (value)
-        bounding_values[128] = value;
-    bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
+    ff_vp3dsp_set_bounding_values(s->bounding_values_array, s->filter_limit_values[s->qps[0]]);
 }
 
 /*
diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c
index cdf7d6490e..4e08ee0b8f 100644
--- a/libavcodec/vp3dsp.c
+++ b/libavcodec/vp3dsp.c
@@ -27,6 +27,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/avassert.h"
 
 #include "avcodec.h"
 #include "rnd_avg.h"
@@ -296,3 +297,34 @@ av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags)
     if (ARCH_MIPS)
         ff_vp3dsp_init_mips(c, flags);
 }
+
+/*
+ * This function initializes the loop filter boundary limits if the frame's
+ * quality index is different from the previous frame's.
+ *
+ * where sizeof(bounding_values_array) is 256 * sizeof(int)
+ *
+ * The filter_limit_values may not be larger than 127.
+ */
+void ff_vp3dsp_set_bounding_values(int * bounding_values_array, int filter_limit)
+{
+    int *bounding_values = bounding_values_array + 127;
+    int x;
+    int value;
+
+    av_assert0(filter_limit < 128U);
+
+    /* set up the bounding values */
+    memset(bounding_values_array, 0, 256 * sizeof(int));
+    for (x = 0; x < filter_limit; x++) {
+        bounding_values[-x] = -x;
+        bounding_values[x] = x;
+    }
+    for (x = value = filter_limit; x < 128 && value; x++, value--) {
+        bounding_values[ x] =  value;
+        bounding_values[-x] = -value;
+    }
+    if (value)
+        bounding_values[128] = value;
+    bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
+}
diff --git a/libavcodec/vp3dsp.h b/libavcodec/vp3dsp.h
index f5f042dc0c..f55a7f834f 100644
--- a/libavcodec/vp3dsp.h
+++ b/libavcodec/vp3dsp.h
@@ -51,4 +51,6 @@ void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags);
 void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags);
 void ff_vp3dsp_init_mips(VP3DSPContext *c, int flags);
 
+void ff_vp3dsp_set_bounding_values(int * bound_values_array, int filter_limit);
+
 #endif /* AVCODEC_VP3DSP_H */
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190115/07935f29/attachment.sig>


More information about the ffmpeg-devel mailing list