Enumerations | |
| enum | Imode { IMODE_RAW, IMODE_NORM2, IMODE_DIFF2, IMODE_NORM6, IMODE_DIFF6, IMODE_ROWSKIP, IMODE_COLSKIP } |
Functions | |
| static void | decode_rowskip (uint8_t *plane, int width, int height, int stride, GetBitContext *gb) |
| static void | decode_colskip (uint8_t *plane, int width, int height, int stride, GetBitContext *gb) |
| static int | bitplane_decoding (uint8_t *data, int *raw_flag, VC1Context *v) |
| enum Imode |
Definition at line 126 of file vc1.c.
00126 { 00127 IMODE_RAW, 00128 IMODE_NORM2, 00129 IMODE_DIFF2, 00130 IMODE_NORM6, 00131 IMODE_DIFF6, 00132 IMODE_ROWSKIP, 00133 IMODE_COLSKIP 00134 };
| static int bitplane_decoding | ( | uint8_t * | data, | |
| int * | raw_flag, | |||
| VC1Context * | v | |||
| ) | [static] |
Decode a bitplane's bits
| bp | Bitplane where to store the decode bits | |
| v | VC-1 context for bit reading and logging |
Definition at line 183 of file vc1.c.
References av_log(), AV_LOG_DEBUG, MpegEncContext::avctx, decode_colskip(), ff_vc1_imode_vlc, ff_vc1_norm2_vlc, ff_vc1_norm6_vlc, MpegEncContext::gb, get_bits1(), get_vlc2(), height, IMODE_DIFF2, IMODE_DIFF6, IMODE_NORM2, IMODE_NORM6, IMODE_RAW, MpegEncContext::mb_height, MpegEncContext::mb_stride, MpegEncContext::mb_width, offset, VC1Context::s, stride, VLC::table, VC1_IMODE_VLC_BITS, VC1_NORM2_VLC_BITS, VC1_NORM6_VLC_BITS, and width.
Referenced by vc1_parse_frame_header(), and vc1_parse_frame_header_adv().
00184 { 00185 GetBitContext *gb = &v->s.gb; 00186 00187 int imode, x, y, code, offset; 00188 uint8_t invert, *planep = data; 00189 int width, height, stride; 00190 00191 width = v->s.mb_width; 00192 height = v->s.mb_height; 00193 stride = v->s.mb_stride; 00194 invert = get_bits1(gb); 00195 imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); 00196 00197 *raw_flag = 0; 00198 switch (imode) 00199 { 00200 case IMODE_RAW: 00201 //Data is actually read in the MB layer (same for all tests == "raw") 00202 *raw_flag = 1; //invert ignored 00203 return invert; 00204 case IMODE_DIFF2: 00205 case IMODE_NORM2: 00206 if ((height * width) & 1) 00207 { 00208 *planep++ = get_bits1(gb); 00209 offset = 1; 00210 } 00211 else offset = 0; 00212 // decode bitplane as one long line 00213 for (y = offset; y < height * width; y += 2) { 00214 code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); 00215 *planep++ = code & 1; 00216 offset++; 00217 if(offset == width) { 00218 offset = 0; 00219 planep += stride - width; 00220 } 00221 *planep++ = code >> 1; 00222 offset++; 00223 if(offset == width) { 00224 offset = 0; 00225 planep += stride - width; 00226 } 00227 } 00228 break; 00229 case IMODE_DIFF6: 00230 case IMODE_NORM6: 00231 if(!(height % 3) && (width % 3)) { // use 2x3 decoding 00232 for(y = 0; y < height; y+= 3) { 00233 for(x = width & 1; x < width; x += 2) { 00234 code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); 00235 if(code < 0){ 00236 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); 00237 return -1; 00238 } 00239 planep[x + 0] = (code >> 0) & 1; 00240 planep[x + 1] = (code >> 1) & 1; 00241 planep[x + 0 + stride] = (code >> 2) & 1; 00242 planep[x + 1 + stride] = (code >> 3) & 1; 00243 planep[x + 0 + stride * 2] = (code >> 4) & 1; 00244 planep[x + 1 + stride * 2] = (code >> 5) & 1; 00245 } 00246 planep += stride * 3; 00247 } 00248 if(width & 1) decode_colskip(data, 1, height, stride, &v->s.gb); 00249 } else { // 3x2 00250 planep += (height & 1) * stride; 00251 for(y = height & 1; y < height; y += 2) { 00252 for(x = width % 3; x < width; x += 3) { 00253 code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); 00254 if(code < 0){ 00255 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); 00256 return -1; 00257 } 00258 planep[x + 0] = (code >> 0) & 1; 00259 planep[x + 1] = (code >> 1) & 1; 00260 planep[x + 2] = (code >> 2) & 1; 00261 planep[x + 0 + stride] = (code >> 3) & 1; 00262 planep[x + 1 + stride] = (code >> 4) & 1; 00263 planep[x + 2 + stride] = (code >> 5) & 1; 00264 } 00265 planep += stride * 2; 00266 } 00267 x = width % 3; 00268 if(x) decode_colskip(data , x, height , stride, &v->s.gb); 00269 if(height & 1) decode_rowskip(data+x, width - x, 1, stride, &v->s.gb); 00270 } 00271 break; 00272 case IMODE_ROWSKIP: 00273 decode_rowskip(data, width, height, stride, &v->s.gb); 00274 break; 00275 case IMODE_COLSKIP: 00276 decode_colskip(data, width, height, stride, &v->s.gb); 00277 break; 00278 default: break; 00279 } 00280 00281 /* Applying diff operator */ 00282 if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) 00283 { 00284 planep = data; 00285 planep[0] ^= invert; 00286 for (x=1; x<width; x++) 00287 planep[x] ^= planep[x-1]; 00288 for (y=1; y<height; y++) 00289 { 00290 planep += stride; 00291 planep[0] ^= planep[-stride]; 00292 for (x=1; x<width; x++) 00293 { 00294 if (planep[x-1] != planep[x-stride]) planep[x] ^= invert; 00295 else planep[x] ^= planep[x-1]; 00296 } 00297 } 00298 } 00299 else if (invert) 00300 { 00301 planep = data; 00302 for (x=0; x<stride*height; x++) planep[x] = !planep[x]; //FIXME stride 00303 } 00304 return (imode<<1) + invert; 00305 }
| static void decode_colskip | ( | uint8_t * | plane, | |
| int | width, | |||
| int | height, | |||
| int | stride, | |||
| GetBitContext * | gb | |||
| ) | [static] |
Decode columns by checking if they are skipped
| plane | Buffer to store decoded bits | |
| [in] | width | Width of this buffer |
| [in] | height | Height of this buffer |
| [in] | stride | of this buffer |
Definition at line 163 of file vc1.c.
References get_bits1().
Referenced by bitplane_decoding().
00163 { 00164 int x, y; 00165 00166 for (x=0; x<width; x++){ 00167 if (!get_bits1(gb)) //colskip 00168 for (y=0; y<height; y++) 00169 plane[y*stride] = 0; 00170 else 00171 for (y=0; y<height; y++) 00172 plane[y*stride] = get_bits1(gb); 00173 plane ++; 00174 } 00175 }
| static void decode_rowskip | ( | uint8_t * | plane, | |
| int | width, | |||
| int | height, | |||
| int | stride, | |||
| GetBitContext * | gb | |||
| ) | [static] |
Decode rows by checking if they are skipped
| plane | Buffer to store decoded bits | |
| [in] | width | Width of this buffer |
| [in] | height | Height of this buffer |
| [in] | stride | of this buffer |
Definition at line 143 of file vc1.c.
References get_bits1().
00143 { 00144 int x, y; 00145 00146 for (y=0; y<height; y++){ 00147 if (!get_bits1(gb)) //rowskip 00148 memset(plane, 0, width); 00149 else 00150 for (x=0; x<width; x++) 00151 plane[x] = get_bits1(gb); 00152 plane += stride; 00153 } 00154 }
1.5.1