MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / bitplane_decoding

Function bitplane_decoding

libavcodec/vc1.c:110–232  ·  view source on GitHub ↗

Decode a bitplane's bits * @param data bitplane where to store the decode bits * @param[out] raw_flag pointer to the flag indicating that this bitplane is not coded explicitly * @param v VC-1 context for bit reading and logging * @return Status * @todo FIXME: Optimize */

Source from the content-addressed store, hash-verified

108 * @todo FIXME: Optimize
109 */
110static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
111{
112 GetBitContext *gb = &v->s.gb;
113
114 int imode, x, y, code, offset;
115 uint8_t invert, *planep = data;
116 int width, height, stride;
117
118 width = v->s.mb_width;
119 height = v->s.mb_height;
120 stride = v->s.mb_stride;
121 invert = get_bits1(gb);
122 imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
123
124 *raw_flag = 0;
125 switch (imode)
126 {
127 case IMODE_RAW:
128 //Data is actually read in the MB layer (same for all tests == "raw")
129 *raw_flag = 1; //invert ignored
130 return invert;
131 case IMODE_DIFF2:
132 case IMODE_NORM2:
133 if ((height * width) & 1)
134 {
135 *planep++ = get_bits1(gb);
136 offset = 1;
137 }
138 else offset = 0;
139 // decode bitplane as one long line
140 for (y = offset; y < height * width; y += 2) {
141 code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);
142 *planep++ = code & 1;
143 offset++;
144 if(offset == width) {
145 offset = 0;
146 planep += stride - width;
147 }
148 *planep++ = code >> 1;
149 offset++;
150 if(offset == width) {
151 offset = 0;
152 planep += stride - width;
153 }
154 }
155 break;
156 case IMODE_DIFF6:
157 case IMODE_NORM6:
158 if(!(height % 3) && (width % 3)) { // use 2x3 decoding
159 for(y = 0; y < height; y+= 3) {
160 for(x = width & 1; x < width; x += 2) {
161 code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
162 if(code < 0){
163 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
164 return -1;
165 }
166 planep[x + 0] = (code >> 0) & 1;
167 planep[x + 1] = (code >> 1) & 1;

Callers 2

vc1_parse_frame_headerFunction · 0.85

Calls 5

get_bits1Function · 0.85
get_vlc2Function · 0.85
av_logFunction · 0.85
decode_colskipFunction · 0.85
decode_rowskipFunction · 0.85

Tested by

no test coverage detected