OSDN Git Service

rl: Add a function for freeing dynamically allocated tables.
authorAnton Khirnov <anton@khirnov.net>
Fri, 22 May 2015 18:50:13 +0000 (19:50 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 28 May 2015 14:38:43 +0000 (15:38 +0100)
Such tables are not used anywhere currently, but that should change.

libavcodec/rl.c
libavcodec/rl.h

index 942b7a6..c0ec8ec 100644 (file)
 #include <stdint.h>
 
 #include "libavutil/attributes.h"
+#include "libavutil/mem.h"
 
 #include "rl.h"
 
+void ff_rl_free(RLTable *rl)
+{
+    int i;
+
+    for (i = 0; i < 2; i++) {
+        av_freep(&rl->max_run[i]);
+        av_freep(&rl->max_level[i]);
+        av_freep(&rl->index_run[i]);
+    }
+}
+
 av_cold void ff_rl_init(RLTable *rl,
                         uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
 {
index d03d436..8244968 100644 (file)
@@ -56,6 +56,11 @@ typedef struct RLTable {
 void ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
 void ff_rl_init_vlc(RLTable *rl);
 
+/**
+ * Free the contents of a dynamically allocated table.
+ */
+void ff_rl_free(RLTable *rl);
+
 #define INIT_VLC_RL(rl, static_size)\
 {\
     int q;\