History

Move VLC and RL_VLC_ELEM structure definitions to a separate header

Use the newly created vlc.h directly instead of including get_bits when needed. The VLC and RL_VLC_ELEM structures are independent from the bitreader.

Alexandra Hájková committed 10 years ago

Commit ffa190d1 parent b2361327 files · +74 −44Browse files

Unified · Split

7 files
  1. libavcodec/bitstream.c +1 −1
  2. libavcodec/get_bits.h +1 −41
  3. libavcodec/huffman.c +3 −0
  4. libavcodec/huffman.h +1 −1
  5. libavcodec/rl.c +1 −0
  6. libavcodec/rl.h +2 −1
  7. libavcodec/vlc.h +65 −0
libavcodec/bitstream.c+1−1
@@ -31,8 +31,8 @@ · 30 unmodified lines
3131 #include "avcodec.h"
3232 #include "internal.h"
3333 #include "mathops.h"
34−#include "get_bits.h"
3534 #include "put_bits.h"
35+#include "vlc.h"
3636
3737 const uint8_t ff_log2_run[41]={
3838 0, 0, 0, 0, 1, 1, 1, 1,
libavcodec/get_bits.h+1−41
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/intreadwrite.h"
3333 #include "libavutil/log.h"
3434 #include "mathops.h"
35+#include "vlc.h"
3536
3637 /*
3738 * Safe bitstream reading:
@@ -59,20 +60,6 @@ typedef struct GetBitContext { · 21 unmodified lines
5960 #endif
6061 } GetBitContext;
6162
62−#define VLC_TYPE int16_t
63−
64−typedef struct VLC {
65− int bits;
66− VLC_TYPE (*table)[2]; ///< code, bits
67− int table_size, table_allocated;
68−} VLC;
69−
70−typedef struct RL_VLC_ELEM {
71− int16_t level;
72− int8_t len;
73− uint8_t run;
74−} RL_VLC_ELEM;
75−
7663 /* Bitstream reader API docs:
7764 * name
7865 * arbitrary name which is used as prefix for the internal variables
@@ -421,33 +408,6 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) · 342 unmodified lines
421408 return s->buffer + (s->index >> 3);
422409 }
423410
424−#define init_vlc(vlc, nb_bits, nb_codes, \
425− bits, bits_wrap, bits_size, \
426− codes, codes_wrap, codes_size, \
427− flags) \
428− ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
429− bits, bits_wrap, bits_size, \
430− codes, codes_wrap, codes_size, \
431− NULL, 0, 0, flags)
432−
433−int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
434− const void *bits, int bits_wrap, int bits_size,
435− const void *codes, int codes_wrap, int codes_size,
436− const void *symbols, int symbols_wrap, int symbols_size,
437− int flags);
438−void ff_free_vlc(VLC *vlc);
439−
440−#define INIT_VLC_LE 2
441−#define INIT_VLC_USE_NEW_STATIC 4
442−
443−#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
444− do { \
445− static VLC_TYPE table[static_size][2]; \
446− (vlc)->table = table; \
447− (vlc)->table_allocated = static_size; \
448− init_vlc(vlc, bits, a, b, c, d, e, f, g, INIT_VLC_USE_NEW_STATIC); \
449− } while (0)
450−
451411 /**
452412 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
453413 * If the vlc code is invalid and max_depth>1, then the number of bits removed
libavcodec/huffman.c+3−0
@@ -26,8 +26,11 @@ · 25 unmodified lines
2626
2727 #include <stdint.h>
2828
29+#include"libavutil/common.h"
30+
2931 #include "avcodec.h"
3032 #include "huffman.h"
33+#include "vlc.h"
3134
3235 /* symbol for Huffman tree node */
3336 #define HNODE -1
libavcodec/huffman.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #define AVCODEC_HUFFMAN_H
2828
2929 #include "avcodec.h"
30−#include "get_bits.h"
30+#include "vlc.h"
3131
3232 typedef struct Node {
3333 int16_t sym;
libavcodec/rl.c+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 */
1818
1919 #include <stdint.h>
20+#include <string.h>
2021
2122 #include "libavutil/attributes.h"
2223 #include "libavutil/mem.h"
libavcodec/rl.h+2−1
@@ -28,7 +28,8 @@ · 27 unmodified lines
2828 #define AVCODEC_RL_H
2929
3030 #include <stdint.h>
31−#include "get_bits.h"
31+
32+#include "vlc.h"
3233
3334 /* run length table */
3435 #define MAX_RUN 64
libavcodec/vlc.h+65−0
@@ -0,0 +1,65 @@
1+/*
2+ * This file is part of Libav.
3+ *
4+ * Libav is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * Libav is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with Libav; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#ifndef AVCODEC_VLC_H
20+#define AVCODEC_VLC_H
21+
22+#include <stdint.h>
23+
24+#define VLC_TYPE int16_t
25+
26+typedef struct VLC {
27+ int bits;
28+ VLC_TYPE (*table)[2]; ///< code, bits
29+ int table_size, table_allocated;
30+} VLC;
31+
32+typedef struct RL_VLC_ELEM {
33+ int16_t level;
34+ int8_t len;
35+ uint8_t run;
36+} RL_VLC_ELEM;
37+
38+#define init_vlc(vlc, nb_bits, nb_codes, \
39+ bits, bits_wrap, bits_size, \
40+ codes, codes_wrap, codes_size, \
41+ flags) \
42+ ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
43+ bits, bits_wrap, bits_size, \
44+ codes, codes_wrap, codes_size, \
45+ NULL, 0, 0, flags)
46+
47+int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
48+ const void *bits, int bits_wrap, int bits_size,
49+ const void *codes, int codes_wrap, int codes_size,
50+ const void *symbols, int symbols_wrap, int symbols_size,
51+ int flags);
52+void ff_free_vlc(VLC *vlc);
53+
54+#define INIT_VLC_LE 2
55+#define INIT_VLC_USE_NEW_STATIC 4
56+
57+#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
58+ do { \
59+ static VLC_TYPE table[static_size][2]; \
60+ (vlc)->table = table; \
61+ (vlc)->table_allocated = static_size; \
62+ init_vlc(vlc, bits, a, b, c, d, e, f, g, INIT_VLC_USE_NEW_STATIC); \
63+ } while (0)
64+
65+#endif /* AVCODEC_VLC_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t