/src/vlc/contrib/contrib-build/libvpx/vp8/encoder/boolhuff.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license |
5 | | * that can be found in the LICENSE file in the root of the source |
6 | | * tree. An additional intellectual property rights grant can be found |
7 | | * in the file PATENTS. All contributing project authors may |
8 | | * be found in the AUTHORS file in the root of the source tree. |
9 | | */ |
10 | | |
11 | | /**************************************************************************** |
12 | | * |
13 | | * Module Title : boolhuff.h |
14 | | * |
15 | | * Description : Bool Coder header file. |
16 | | * |
17 | | ****************************************************************************/ |
18 | | #ifndef VPX_VP8_ENCODER_BOOLHUFF_H_ |
19 | | #define VPX_VP8_ENCODER_BOOLHUFF_H_ |
20 | | |
21 | | #include "vpx_ports/mem.h" |
22 | | #include "vpx/internal/vpx_codec_internal.h" |
23 | | |
24 | | #ifdef __cplusplus |
25 | | extern "C" { |
26 | | #endif |
27 | | |
28 | | typedef struct { |
29 | | unsigned int lowvalue; |
30 | | unsigned int range; |
31 | | int count; |
32 | | unsigned int pos; |
33 | | unsigned char *buffer; |
34 | | unsigned char *buffer_end; |
35 | | struct vpx_internal_error_info *error; |
36 | | } BOOL_CODER; |
37 | | |
38 | | void vp8_start_encode(BOOL_CODER *bc, unsigned char *source, |
39 | | unsigned char *source_end); |
40 | | |
41 | | void vp8_encode_value(BOOL_CODER *bc, int data, int bits); |
42 | | void vp8_stop_encode(BOOL_CODER *bc); |
43 | | extern const unsigned int vp8_prob_cost[256]; |
44 | | |
45 | | DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); |
46 | | |
47 | | static int validate_buffer(const unsigned char *start, size_t len, |
48 | | const unsigned char *end, |
49 | 0 | struct vpx_internal_error_info *error) { |
50 | 0 | if (start + len > start && start + len < end) { |
51 | 0 | return 1; |
52 | 0 | } else { |
53 | 0 | vpx_internal_error(error, VPX_CODEC_CORRUPT_FRAME, |
54 | 0 | "Truncated packet or corrupt partition "); |
55 | 0 | } |
56 | | |
57 | 0 | return 0; |
58 | 0 | } Unexecuted instantiation: vp8_cx_iface.c:validate_buffer Unexecuted instantiation: ethreading.c:validate_buffer Unexecuted instantiation: onyx_if.c:validate_buffer Unexecuted instantiation: pickinter.c:validate_buffer Unexecuted instantiation: picklpf.c:validate_buffer Unexecuted instantiation: vp8_quantize.c:validate_buffer Unexecuted instantiation: ratectrl.c:validate_buffer Unexecuted instantiation: rdopt.c:validate_buffer Unexecuted instantiation: segmentation.c:validate_buffer Unexecuted instantiation: vp8_skin_detection.c:validate_buffer Unexecuted instantiation: tokenize.c:validate_buffer Unexecuted instantiation: treewriter.c:validate_buffer Unexecuted instantiation: temporal_filter.c:validate_buffer Unexecuted instantiation: bitstream.c:validate_buffer Unexecuted instantiation: boolhuff.c:validate_buffer Unexecuted instantiation: encodeframe.c:validate_buffer Unexecuted instantiation: encodeintra.c:validate_buffer Unexecuted instantiation: encodemb.c:validate_buffer Unexecuted instantiation: encodemv.c:validate_buffer Unexecuted instantiation: firstpass.c:validate_buffer Unexecuted instantiation: mcomp.c:validate_buffer Unexecuted instantiation: modecosts.c:validate_buffer |
59 | 0 | static void vp8_encode_bool(BOOL_CODER *bc, int bit, int probability) { |
60 | 0 | unsigned int split; |
61 | 0 | int count = bc->count; |
62 | 0 | unsigned int range = bc->range; |
63 | 0 | unsigned int lowvalue = bc->lowvalue; |
64 | 0 | int shift; |
65 | |
|
66 | 0 | split = 1 + (((range - 1) * probability) >> 8); |
67 | |
|
68 | 0 | range = split; |
69 | |
|
70 | 0 | if (bit) { |
71 | 0 | lowvalue += split; |
72 | 0 | range = bc->range - split; |
73 | 0 | } |
74 | |
|
75 | 0 | shift = vp8_norm[range]; |
76 | |
|
77 | 0 | range <<= shift; |
78 | 0 | count += shift; |
79 | |
|
80 | 0 | if (count >= 0) { |
81 | 0 | int offset = shift - count; |
82 | |
|
83 | 0 | if ((lowvalue << (offset - 1)) & 0x80000000) { |
84 | 0 | int x = bc->pos - 1; |
85 | |
|
86 | 0 | while (x >= 0 && bc->buffer[x] == 0xff) { |
87 | 0 | bc->buffer[x] = (unsigned char)0; |
88 | 0 | x--; |
89 | 0 | } |
90 | |
|
91 | 0 | bc->buffer[x] += 1; |
92 | 0 | } |
93 | |
|
94 | 0 | validate_buffer(bc->buffer + bc->pos, 1, bc->buffer_end, bc->error); |
95 | 0 | bc->buffer[bc->pos++] = (lowvalue >> (24 - offset) & 0xff); |
96 | |
|
97 | 0 | shift = count; |
98 | 0 | lowvalue = (int)(((uint64_t)lowvalue << offset) & 0xffffff); |
99 | 0 | count -= 8; |
100 | 0 | } |
101 | |
|
102 | 0 | lowvalue <<= shift; |
103 | 0 | bc->count = count; |
104 | 0 | bc->lowvalue = lowvalue; |
105 | 0 | bc->range = range; |
106 | 0 | } Unexecuted instantiation: vp8_cx_iface.c:vp8_encode_bool Unexecuted instantiation: ethreading.c:vp8_encode_bool Unexecuted instantiation: onyx_if.c:vp8_encode_bool Unexecuted instantiation: pickinter.c:vp8_encode_bool Unexecuted instantiation: picklpf.c:vp8_encode_bool Unexecuted instantiation: vp8_quantize.c:vp8_encode_bool Unexecuted instantiation: ratectrl.c:vp8_encode_bool Unexecuted instantiation: rdopt.c:vp8_encode_bool Unexecuted instantiation: segmentation.c:vp8_encode_bool Unexecuted instantiation: vp8_skin_detection.c:vp8_encode_bool Unexecuted instantiation: tokenize.c:vp8_encode_bool Unexecuted instantiation: treewriter.c:vp8_encode_bool Unexecuted instantiation: temporal_filter.c:vp8_encode_bool Unexecuted instantiation: bitstream.c:vp8_encode_bool Unexecuted instantiation: boolhuff.c:vp8_encode_bool Unexecuted instantiation: encodeframe.c:vp8_encode_bool Unexecuted instantiation: encodeintra.c:vp8_encode_bool Unexecuted instantiation: encodemb.c:vp8_encode_bool Unexecuted instantiation: encodemv.c:vp8_encode_bool Unexecuted instantiation: firstpass.c:vp8_encode_bool Unexecuted instantiation: mcomp.c:vp8_encode_bool Unexecuted instantiation: modecosts.c:vp8_encode_bool |
107 | | |
108 | | #ifdef __cplusplus |
109 | | } // extern "C" |
110 | | #endif |
111 | | |
112 | | #endif // VPX_VP8_ENCODER_BOOLHUFF_H_ |