]> git.sesse.net Git - ffmpeg/commitdiff
mpegvideo: Move ff_*_rl functions to a separate file
authorAnton Khirnov <anton@khirnov.net>
Fri, 22 May 2015 18:50:11 +0000 (19:50 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 28 May 2015 14:38:43 +0000 (15:38 +0100)
libavcodec/Makefile
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/rl.c [new file with mode: 0644]

index e4ca55108535018556cae16c3f913a7595a04fc7..0107460154e4031a1b75328829207d4cbc079894 100644 (file)
@@ -75,7 +75,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP)            += mpegaudiodsp.o                \
                                           mpegaudiodsp_data.o           \
                                           mpegaudiodsp_fixed.o          \
                                           mpegaudiodsp_float.o
-OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o mpegvideodsp.o    \
+OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o mpegvideodsp.o rl.o \
                                           mpegvideo_motion.o mpegutils.o
 OBJS-$(CONFIG_MPEGVIDEOENC)            += mpegvideo_enc.o mpeg12data.o  \
                                           motion_est.o ratecontrol.o    \
index 10ace8dfdba39bc15a03eec6498efd590dbc4888..4294eb61792efaabb6043582222c592fe3515f77 100644 (file)
@@ -1521,98 +1521,6 @@ void ff_mpv_common_end(MpegEncContext *s)
     s->linesize = s->uvlinesize = 0;
 }
 
-av_cold void ff_init_rl(RLTable *rl,
-                        uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
-{
-    int8_t  max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
-    uint8_t index_run[MAX_RUN + 1];
-    int last, run, level, start, end, i;
-
-    /* If table is static, we can quit if rl->max_level[0] is not NULL */
-    if (static_store && rl->max_level[0])
-        return;
-
-    /* compute max_level[], max_run[] and index_run[] */
-    for (last = 0; last < 2; last++) {
-        if (last == 0) {
-            start = 0;
-            end = rl->last;
-        } else {
-            start = rl->last;
-            end = rl->n;
-        }
-
-        memset(max_level, 0, MAX_RUN + 1);
-        memset(max_run, 0, MAX_LEVEL + 1);
-        memset(index_run, rl->n, MAX_RUN + 1);
-        for (i = start; i < end; i++) {
-            run   = rl->table_run[i];
-            level = rl->table_level[i];
-            if (index_run[run] == rl->n)
-                index_run[run] = i;
-            if (level > max_level[run])
-                max_level[run] = level;
-            if (run > max_run[level])
-                max_run[level] = run;
-        }
-        if (static_store)
-            rl->max_level[last] = static_store[last];
-        else
-            rl->max_level[last] = av_malloc(MAX_RUN + 1);
-        memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
-        if (static_store)
-            rl->max_run[last]   = static_store[last] + MAX_RUN + 1;
-        else
-            rl->max_run[last]   = av_malloc(MAX_LEVEL + 1);
-        memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
-        if (static_store)
-            rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
-        else
-            rl->index_run[last] = av_malloc(MAX_RUN + 1);
-        memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
-    }
-}
-
-av_cold void ff_init_vlc_rl(RLTable *rl)
-{
-    int i, q;
-
-    for (q = 0; q < 32; q++) {
-        int qmul = q * 2;
-        int qadd = (q - 1) | 1;
-
-        if (q == 0) {
-            qmul = 1;
-            qadd = 0;
-        }
-        for (i = 0; i < rl->vlc.table_size; i++) {
-            int code = rl->vlc.table[i][0];
-            int len  = rl->vlc.table[i][1];
-            int level, run;
-
-            if (len == 0) { // illegal code
-                run   = 66;
-                level = MAX_LEVEL;
-            } else if (len < 0) { // more bits needed
-                run   = 0;
-                level = code;
-            } else {
-                if (code == rl->n) { // esc
-                    run   = 66;
-                    level =  0;
-                } else {
-                    run   = rl->table_run[code] + 1;
-                    level = rl->table_level[code] * qmul + qadd;
-                    if (code >= rl->last) run += 192;
-                }
-            }
-            rl->rl_vlc[q][i].len   = len;
-            rl->rl_vlc[q][i].level = level;
-            rl->rl_vlc[q][i].run   = run;
-        }
-    }
-}
-
 static void release_unused_pictures(AVCodecContext *avctx, Picture *picture)
 {
     int i;
index 8ac7851d2c40c3bed51371a6a64db05d89a39b3e..4eff4d9f0b1df51ece71d9b7d204223e397f442c 100644 (file)
@@ -47,7 +47,6 @@
 #include "parser.h"
 #include "mpeg12data.h"
 #include "qpeldsp.h"
-#include "rl.h"
 #include "thread.h"
 #include "videodsp.h"
 
diff --git a/libavcodec/rl.c b/libavcodec/rl.c
new file mode 100644 (file)
index 0000000..516cb09
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+
+#include "rl.h"
+
+av_cold void ff_init_rl(RLTable *rl,
+                        uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
+{
+    int8_t  max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
+    uint8_t index_run[MAX_RUN + 1];
+    int last, run, level, start, end, i;
+
+    /* If table is static, we can quit if rl->max_level[0] is not NULL */
+    if (static_store && rl->max_level[0])
+        return;
+
+    /* compute max_level[], max_run[] and index_run[] */
+    for (last = 0; last < 2; last++) {
+        if (last == 0) {
+            start = 0;
+            end = rl->last;
+        } else {
+            start = rl->last;
+            end = rl->n;
+        }
+
+        memset(max_level, 0, MAX_RUN + 1);
+        memset(max_run, 0, MAX_LEVEL + 1);
+        memset(index_run, rl->n, MAX_RUN + 1);
+        for (i = start; i < end; i++) {
+            run   = rl->table_run[i];
+            level = rl->table_level[i];
+            if (index_run[run] == rl->n)
+                index_run[run] = i;
+            if (level > max_level[run])
+                max_level[run] = level;
+            if (run > max_run[level])
+                max_run[level] = run;
+        }
+        if (static_store)
+            rl->max_level[last] = static_store[last];
+        else
+            rl->max_level[last] = av_malloc(MAX_RUN + 1);
+        memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
+        if (static_store)
+            rl->max_run[last]   = static_store[last] + MAX_RUN + 1;
+        else
+            rl->max_run[last]   = av_malloc(MAX_LEVEL + 1);
+        memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
+        if (static_store)
+            rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
+        else
+            rl->index_run[last] = av_malloc(MAX_RUN + 1);
+        memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
+    }
+}
+
+av_cold void ff_init_vlc_rl(RLTable *rl)
+{
+    int i, q;
+
+    for (q = 0; q < 32; q++) {
+        int qmul = q * 2;
+        int qadd = (q - 1) | 1;
+
+        if (q == 0) {
+            qmul = 1;
+            qadd = 0;
+        }
+        for (i = 0; i < rl->vlc.table_size; i++) {
+            int code = rl->vlc.table[i][0];
+            int len  = rl->vlc.table[i][1];
+            int level, run;
+
+            if (len == 0) { // illegal code
+                run   = 66;
+                level = MAX_LEVEL;
+            } else if (len < 0) { // more bits needed
+                run   = 0;
+                level = code;
+            } else {
+                if (code == rl->n) { // esc
+                    run   = 66;
+                    level =  0;
+                } else {
+                    run   = rl->table_run[code] + 1;
+                    level = rl->table_level[code] * qmul + qadd;
+                    if (code >= rl->last) run += 192;
+                }
+            }
+            rl->rl_vlc[q][i].len   = len;
+            rl->rl_vlc[q][i].level = level;
+            rl->rl_vlc[q][i].run   = run;
+        }
+    }
+}