comparison h264.c @ 7450:30d38a880fde libavcodec

Simplify intra PCM MB handling.
author michael
date Wed, 30 Jul 2008 18:21:51 +0000
parents a202753ce99d
children 5cbf11f56c02
comparison
equal deleted inserted replaced
7449:18fc253b4991 7450:30d38a880fde
2500 uint8_t *top_cr = s->current_picture.data[2] + (mbt_y * 8 * s->uvlinesize) + mb_x * 8; 2500 uint8_t *top_cr = s->current_picture.data[2] + (mbt_y * 8 * s->uvlinesize) + mb_x * 8;
2501 xchg_pair_border(h, top_y, top_cb, top_cr, s->linesize, s->uvlinesize, 1); 2501 xchg_pair_border(h, top_y, top_cb, top_cr, s->linesize, s->uvlinesize, 1);
2502 } 2502 }
2503 2503
2504 if (!simple && IS_INTRA_PCM(mb_type)) { 2504 if (!simple && IS_INTRA_PCM(mb_type)) {
2505 unsigned int x, y; 2505 for (i=0; i<16; i++) {
2506 2506 memcpy(dest_y + i* linesize, h->mb + i*8, 16);
2507 // The pixels are stored in h->mb array in the same order as levels, 2507 }
2508 // copy them in output in the correct order. 2508 for (i=0; i<8; i++) {
2509 for(i=0; i<16; i++) { 2509 memcpy(dest_cb+ i*uvlinesize, h->mb + 128 + i*4, 8);
2510 for (y=0; y<4; y++) { 2510 memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4, 8);
2511 for (x=0; x<4; x++) {
2512 *(dest_y + block_offset[i] + y*linesize + x) = h->mb[i*16+y*4+x];
2513 }
2514 }
2515 }
2516 for(i=16; i<16+4; i++) {
2517 for (y=0; y<4; y++) {
2518 for (x=0; x<4; x++) {
2519 *(dest_cb + block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x];
2520 }
2521 }
2522 }
2523 for(i=20; i<20+4; i++) {
2524 for (y=0; y<4; y++) {
2525 for (x=0; x<4; x++) {
2526 *(dest_cr + block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x];
2527 }
2528 }
2529 } 2511 }
2530 } else { 2512 } else {
2531 if(IS_INTRA(mb_type)){ 2513 if(IS_INTRA(mb_type)){
2532 if(h->deblocking_filter && (simple || !FRAME_MBAFF)) 2514 if(h->deblocking_filter && (simple || !FRAME_MBAFF))
2533 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple); 2515 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple);
4403 mb_type |= MB_TYPE_INTERLACED; 4385 mb_type |= MB_TYPE_INTERLACED;
4404 4386
4405 h->slice_table[ mb_xy ]= h->slice_num; 4387 h->slice_table[ mb_xy ]= h->slice_num;
4406 4388
4407 if(IS_INTRA_PCM(mb_type)){ 4389 if(IS_INTRA_PCM(mb_type)){
4408 unsigned int x, y; 4390 unsigned int x;
4409 4391
4410 // We assume these blocks are very rare so we do not optimize it. 4392 // We assume these blocks are very rare so we do not optimize it.
4411 align_get_bits(&s->gb); 4393 align_get_bits(&s->gb);
4412 4394
4413 // The pixels are stored in the same order as levels in h->mb array. 4395 // The pixels are stored in the same order as levels in h->mb array.
4414 for(y=0; y<16; y++){ 4396 for(x=0; x < (CHROMA ? 384 : 256); x++){
4415 const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); 4397 ((uint8_t*)h->mb)[x]= get_bits(&s->gb, 8);
4416 for(x=0; x<16; x++){
4417 tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4418 h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8);
4419 }
4420 }
4421 if(CHROMA){
4422 for(y=0; y<8; y++){
4423 const int index= 256 + 4*(y&3) + 32*(y>>2);
4424 for(x=0; x<8; x++){
4425 tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4426 h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
4427 }
4428 }
4429 for(y=0; y<8; y++){
4430 const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
4431 for(x=0; x<8; x++){
4432 tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
4433 h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
4434 }
4435 }
4436 } 4398 }
4437 4399
4438 // In deblocking, the quantizer is 0 4400 // In deblocking, the quantizer is 0
4439 s->current_picture.qscale_table[mb_xy]= 0; 4401 s->current_picture.qscale_table[mb_xy]= 0;
4440 // All coeffs are present 4402 // All coeffs are present
5543 5505
5544 h->slice_table[ mb_xy ]= h->slice_num; 5506 h->slice_table[ mb_xy ]= h->slice_num;
5545 5507
5546 if(IS_INTRA_PCM(mb_type)) { 5508 if(IS_INTRA_PCM(mb_type)) {
5547 const uint8_t *ptr; 5509 const uint8_t *ptr;
5548 unsigned int x, y;
5549 5510
5550 // We assume these blocks are very rare so we do not optimize it. 5511 // We assume these blocks are very rare so we do not optimize it.
5551 // FIXME The two following lines get the bitstream position in the cabac 5512 // FIXME The two following lines get the bitstream position in the cabac
5552 // decode, I think it should be done by a function in cabac.h (or cabac.c). 5513 // decode, I think it should be done by a function in cabac.h (or cabac.c).
5553 ptr= h->cabac.bytestream; 5514 ptr= h->cabac.bytestream;
5555 if(CABAC_BITS==16){ 5516 if(CABAC_BITS==16){
5556 if(h->cabac.low&0x1FF) ptr--; 5517 if(h->cabac.low&0x1FF) ptr--;
5557 } 5518 }
5558 5519
5559 // The pixels are stored in the same order as levels in h->mb array. 5520 // The pixels are stored in the same order as levels in h->mb array.
5560 for(y=0; y<16; y++){ 5521 memcpy(h->mb, ptr, 256); ptr+=256;
5561 const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
5562 for(x=0; x<16; x++){
5563 tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *ptr);
5564 h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
5565 }
5566 }
5567 if(CHROMA){ 5522 if(CHROMA){
5568 for(y=0; y<8; y++){ 5523 memcpy(h->mb+128, ptr, 128); ptr+=128;
5569 const int index= 256 + 4*(y&3) + 32*(y>>2);
5570 for(x=0; x<8; x++){
5571 tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *ptr);
5572 h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
5573 }
5574 }
5575 for(y=0; y<8; y++){
5576 const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
5577 for(x=0; x<8; x++){
5578 tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *ptr);
5579 h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
5580 }
5581 }
5582 } 5524 }
5583 5525
5584 ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr); 5526 ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
5585 5527
5586 // All blocks are present 5528 // All blocks are present