Mercurial > libavcodec.hg
changeset 7450:30d38a880fde libavcodec
Simplify intra PCM MB handling.
author | michael |
---|---|
date | Wed, 30 Jul 2008 18:21:51 +0000 |
parents | 18fc253b4991 |
children | 85ab7655ad4d |
files | h264.c |
diffstat | 1 files changed, 11 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/h264.c Tue Jul 29 18:22:31 2008 +0000 +++ b/h264.c Wed Jul 30 18:21:51 2008 +0000 @@ -2502,30 +2502,12 @@ } if (!simple && IS_INTRA_PCM(mb_type)) { - unsigned int x, y; - - // The pixels are stored in h->mb array in the same order as levels, - // copy them in output in the correct order. - for(i=0; i<16; i++) { - for (y=0; y<4; y++) { - for (x=0; x<4; x++) { - *(dest_y + block_offset[i] + y*linesize + x) = h->mb[i*16+y*4+x]; - } - } - } - for(i=16; i<16+4; i++) { - for (y=0; y<4; y++) { - for (x=0; x<4; x++) { - *(dest_cb + block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x]; - } - } - } - for(i=20; i<20+4; i++) { - for (y=0; y<4; y++) { - for (x=0; x<4; x++) { - *(dest_cr + block_offset[i] + y*uvlinesize + x) = h->mb[i*16+y*4+x]; - } - } + for (i=0; i<16; i++) { + memcpy(dest_y + i* linesize, h->mb + i*8, 16); + } + for (i=0; i<8; i++) { + memcpy(dest_cb+ i*uvlinesize, h->mb + 128 + i*4, 8); + memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4, 8); } } else { if(IS_INTRA(mb_type)){ @@ -4405,34 +4387,14 @@ h->slice_table[ mb_xy ]= h->slice_num; if(IS_INTRA_PCM(mb_type)){ - unsigned int x, y; + unsigned int x; // We assume these blocks are very rare so we do not optimize it. align_get_bits(&s->gb); // The pixels are stored in the same order as levels in h->mb array. - for(y=0; y<16; y++){ - const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); - for(x=0; x<16; x++){ - tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); - h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8); - } - } - if(CHROMA){ - for(y=0; y<8; y++){ - const int index= 256 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); - h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); - } - } - for(y=0; y<8; y++){ - const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); - h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); - } - } + for(x=0; x < (CHROMA ? 384 : 256); x++){ + ((uint8_t*)h->mb)[x]= get_bits(&s->gb, 8); } // In deblocking, the quantizer is 0 @@ -5545,7 +5507,6 @@ if(IS_INTRA_PCM(mb_type)) { const uint8_t *ptr; - unsigned int x, y; // We assume these blocks are very rare so we do not optimize it. // FIXME The two following lines get the bitstream position in the cabac @@ -5557,28 +5518,9 @@ } // The pixels are stored in the same order as levels in h->mb array. - for(y=0; y<16; y++){ - const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); - for(x=0; x<16; x++){ - tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *ptr); - h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++; - } - } + memcpy(h->mb, ptr, 256); ptr+=256; if(CHROMA){ - for(y=0; y<8; y++){ - const int index= 256 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *ptr); - h->mb[index + (x&3) + 16*(x>>2)]= *ptr++; - } - } - for(y=0; y<8; y++){ - const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *ptr); - h->mb[index + (x&3) + 16*(x>>2)]= *ptr++; - } - } + memcpy(h->mb+128, ptr, 128); ptr+=128; } ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);