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
31#include "avcodec.h"31#include "avcodec.h"
32#include "internal.h"32#include "internal.h"
33#include "mathops.h"33#include "mathops.h"
34#include "get_bits.h"
35#include "put_bits.h"34#include "put_bits.h"
35#include "vlc.h"
36 36
37const uint8_t ff_log2_run[41]={37const uint8_t ff_log2_run[41]={
38 0, 0, 0, 0, 1, 1, 1, 1,38 0, 0, 0, 0, 1, 1, 1, 1,
libavcodec/get_bits.h+1−41
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "libavutil/intreadwrite.h"32#include "libavutil/intreadwrite.h"
33#include "libavutil/log.h"33#include "libavutil/log.h"
34#include "mathops.h"34#include "mathops.h"
35#include "vlc.h"
35 36
36/*37/*
37 * Safe bitstream reading:38 * Safe bitstream reading:
@@ -59,20 +60,6 @@ typedef struct GetBitContext { · 21 unmodified lines
59#endif60#endif
60} GetBitContext;61} GetBitContext;
61 62
62#define VLC_TYPE int16_t
63
64typedef struct VLC {
65 int bits;
66 VLC_TYPE (*table)[2]; ///< code, bits
67 int table_size, table_allocated;
68} VLC;
69
70typedef struct RL_VLC_ELEM {
71 int16_t level;
72 int8_t len;
73 uint8_t run;
74} RL_VLC_ELEM;
75
76/* Bitstream reader API docs:63/* Bitstream reader API docs:
77 * name64 * name
78 * arbitrary name which is used as prefix for the internal variables65 * 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
421 return s->buffer + (s->index >> 3);408 return s->buffer + (s->index >> 3);
422}409}
423 410
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
433int 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);
438void 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
451/**411/**
452 * If the vlc code is invalid and max_depth=1, then no bits will be removed.412 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
453 * If the vlc code is invalid and max_depth>1, then the number of bits removed413 * 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
26 26
27#include <stdint.h>27#include <stdint.h>
28 28
29#include"libavutil/common.h"
30
29#include "avcodec.h"31#include "avcodec.h"
30#include "huffman.h"32#include "huffman.h"
33#include "vlc.h"
31 34
32/* symbol for Huffman tree node */35/* symbol for Huffman tree node */
33#define HNODE -136#define HNODE -1
libavcodec/huffman.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
27#define AVCODEC_HUFFMAN_H27#define AVCODEC_HUFFMAN_H
28 28
29#include "avcodec.h"29#include "avcodec.h"
30#include "get_bits.h"30#include "vlc.h"
31 31
32typedef struct Node {32typedef struct Node {
33 int16_t sym;33 int16_t sym;
libavcodec/rl.c+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
17 */17 */
18 18
19#include <stdint.h>19#include <stdint.h>
20#include <string.h>
20 21
21#include "libavutil/attributes.h"22#include "libavutil/attributes.h"
22#include "libavutil/mem.h"23#include "libavutil/mem.h"
libavcodec/rl.h+2−1
@@ -28,7 +28,8 @@ · 27 unmodified lines
28#define AVCODEC_RL_H28#define AVCODEC_RL_H
29 29
30#include <stdint.h>30#include <stdint.h>
31#include "get_bits.h"31
32#include "vlc.h"
32 33
33/* run length table */34/* run length table */
34#define MAX_RUN 6435#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
26typedef struct VLC {
27 int bits;
28 VLC_TYPE (*table)[2]; ///< code, bits
29 int table_size, table_allocated;
30} VLC;
31
32typedef 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
47int 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);
52void 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