diff mbox series

[FFmpeg-devel,04/15] avcodec/rangecoder: Move ff_rac_check_termination to tests/rangecoder.c

Message ID 20210219075022.2445161-4-andreas.rheinhardt@gmail.com
State Accepted
Commit bce9c5e276be3da2cc44f6ff04673c7f1e8bfb2f
Headers show
Series [FFmpeg-devel,01/15] avformat/asf: Move ff_asf_audio_conceal_none to its only user
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 19, 2021, 7:50 a.m. UTC
It is only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/rangecoder.c       | 19 -------------------
 libavcodec/rangecoder.h       |  9 ---------
 libavcodec/tests/rangecoder.c | 28 +++++++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 29 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
index a6a3f082ef..fa7d5526d1 100644
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -121,22 +121,3 @@  int ff_rac_terminate(RangeCoder *c, int version)
 
     return c->bytestream - c->bytestream_start;
 }
-
-int ff_rac_check_termination(RangeCoder *c, int version)
-{
-    if (version == 1) {
-        RangeCoder tmp = *c;
-        get_rac(c, (uint8_t[]) { 129 });
-
-        if (c->bytestream == tmp.bytestream && c->bytestream > c->bytestream_start)
-            tmp.low -= *--tmp.bytestream;
-        tmp.bytestream_end = tmp.bytestream;
-
-        if (get_rac(&tmp, (uint8_t[]) { 129 }))
-            return AVERROR_INVALIDDATA;
-    } else {
-        if (c->bytestream_end != c->bytestream)
-            return AVERROR_INVALIDDATA;
-    }
-    return 0;
-}
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 4d4ca4d526..4495f6df1a 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -57,15 +57,6 @@  void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size);
  */
 int ff_rac_terminate(RangeCoder *c, int version);
 
-/**
- * Check if at the current position there is a valid looking termination
- * @param version version 0 requires the decoder to know the data size in bytes
- *                version 1 needs about 1 bit more space but does not need to
- *                          carry the size from encoder to decoder
- * @returns negative AVERROR code on error or non negative.
- */
-int ff_rac_check_termination(RangeCoder *c, int version);
-
 void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
 
 static inline void renorm_encoder(RangeCoder *c)
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c
index d6cf9ec380..ca96e13c99 100644
--- a/libavcodec/tests/rangecoder.c
+++ b/libavcodec/tests/rangecoder.c
@@ -26,6 +26,32 @@ 
 
 #define SIZE 1240
 
+/**
+ * Check if at the current position there is a valid looking termination
+ * @param version version 0 requires the decoder to know the data size in bytes
+ *                version 1 needs about 1 bit more space but does not need to
+ *                          carry the size from encoder to decoder
+ * @returns negative AVERROR code on error or non negative.
+ */
+static int rac_check_termination(RangeCoder *c, int version)
+{
+    if (version == 1) {
+        RangeCoder tmp = *c;
+        get_rac(c, (uint8_t[]) { 129 });
+
+        if (c->bytestream == tmp.bytestream && c->bytestream > c->bytestream_start)
+            tmp.low -= *--tmp.bytestream;
+        tmp.bytestream_end = tmp.bytestream;
+
+        if (get_rac(&tmp, (uint8_t[]) { 129 }))
+            return AVERROR_INVALIDDATA;
+    } else {
+        if (c->bytestream_end != c->bytestream)
+            return AVERROR_INVALIDDATA;
+    }
+    return 0;
+}
+
 int main(void)
 {
     RangeCoder c;
@@ -61,7 +87,7 @@  int main(void)
                     return 1;
                 }
 
-            if (ff_rac_check_termination(&c, version) < 0) {
+            if (rac_check_termination(&c, version) < 0) {
                 av_log(NULL, AV_LOG_ERROR, "rac failure at termination pass %d version %d\n", p, version);
                 return 1;
             }