Revision d29f0cd9 libavcodec/vc9.c
libavcodec/vc9.c  

699  699 
#define IMODE_ROWSKIP 5 
700  700 
#define IMODE_COLSKIP 6 
701  701  
702 
static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ 

703 
int x, y; 

704  
705 
for (y=0; y<height; y++){ 

706 
if (!get_bits(&v>gb, 1)) //rowskip 

707 
memset(plane, 0, width); 

708 
else 

709 
for (x=0; x<width; x++) 

710 
plane[x] = get_bits(&v>gb, 1); 

711 
plane += stride; 

712 
} 

713 
} 

714  
715 
static void decode_colskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ 

716 
int x, y; 

717  
718 
for (x=0; x<width; x++){ 

719 
if (!get_bits(&v>gb, 1)) //colskip 

720 
for (y=0; y<height; y++) 

721 
plane[y*stride] = 0; 

722 
else 

723 
for (y=0; y<height; y++) 

724 
plane[y*stride] = get_bits(&v>gb, 1); 

725 
plane ++; 

726 
} 

727 
} 

728  
702  729 
//FIXME optimize 
730 
//FIXME is this supposed to set elements to 0/FF or 0/1? 

703  731 
static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context *v) 
704  732 
{ 
705 
int imode, x, y, code;


733 
int imode, x, y, i, code, use_vertical_tile;


706  734 
uint8_t invert, *planep = plane; 
735 
int stride= width; 

707  736  
708  737 
invert = get_bits(&v>gb, 1); 
709  738 
imode = get_vlc2(&v>gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); 
...  ...  
717  746 
{ 
718  747 
for (x=0; x<width; x++) 
719  748 
planep[x] = (get_bits(&v>gb, 1)); //1=0xFF 
720 
planep += width;


749 
planep += stride;


721  750 
} 
751 
invert=0; //spec says ignore invert if raw 

722  752 
break; 
723  753 
case IMODE_DIFF2: 
724  754 
case IMODE_NORM2: 
725  755 
if ((height*width) & 1) *(++planep) = get_bits(&v>gb, 1); 
726 
code = get_vlc2(&v>gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); 

727 
*(++planep) = code&1; //lsb => left 

728 
*(++planep) = code&2; //msb => right  this is a bitplane, so only !0 matters 

756 
for(i=0; i<(height*width)>>1; i++){ 

757 
code = get_vlc2(&v>gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); 

758 
*(++planep) = code&1; //lsb => left 

759 
*(++planep) = code&2; //msb => right  this is a bitplane, so only !0 matters 

760 
//FIXME width>stride 

761 
} 

729  762 
break; 
730  763 
case IMODE_DIFF6: 
731  764 
case IMODE_NORM6: 
765 
use_vertical_tile= height%3==0 && width%3!=0; 

766 
if(use_vertical_tile){ 

767 
}else{ 

768 
} 

769 


732  770 
av_log(v>avctx, AV_LOG_ERROR, "Imode using Norm6 isn't supported\n"); 
733  771 
return 1; 
734  772 
break; 
735  773 
case IMODE_ROWSKIP: 
736 
for (y=0; y<height; y++) 

737 
{ 

738 
if (get_bits(&v>gb, 1)) //rowskip 

739 
memset(planep, 0, width); 

740 
else for (x=0; x<width; x++) planep[x] = get_bits(&v>gb, 1); 

741 
planep += width; 

742 
} 

774 
decode_rowskip(plane, width, height, stride, v); 

743  775 
break; 
744  776 
case IMODE_COLSKIP: //Teh ugly 
745 
for (x=0; x<width; x++) 

746 
{ 

747 
planep = plane; 

748 
if (get_bits(&v>gb, 1)) //colskip 

749 
{ 

750 
for (y=0; y<height; y++) 

751 
{ 

752 
planep[x] = 0; 

753 
planep += width; 

754 
} 

755 
} 

756 
else 

757 
{ 

758 
for (y=0; y<height; y++) 

759 
{ 

760 
planep[x] = get_bits(&v>gb, 1); 

761 
planep += width; 

762 
} 

763 
} 

764 
} 

777 
decode_rowskip(plane, width, height, stride, v); 

765  778 
break; 
766  779 
default: break; 
767  780 
} 
768  781  
769  782 
/* Applying diff operator */ 
770 
if (imode == IMODE_DIFF2  imode == IMODE_DIFF2)


783 
if (imode == IMODE_DIFF2  imode == IMODE_DIFF6)


771  784 
{ 
772 
/* And what about j=0 !? */ 

773 
planep = plane + width; 

774 
memset(plane, invert, width); 

775 
for (y=0; y<height; y++) 

785 
planep = plane; 

786 
planep[0] ^= invert; 

787 
for (x=1; x<width; x++) 

788 
planep[x] ^= planep[x1]; 

789 
for (y=1; y<height; y++) 

776  790 
{ 
777 
planep[0] = planep[width]; 

791 
planep += stride; 

792 
planep[0] ^= planep[stride]; 

778  793 
for (x=1; x<width; x++) 
779  794 
{ 
780 
if (planep[x1] != planep[width]) planep[x] = invert;


781 
else planep[x] = planep[x1];


795 
if (planep[x1] != planep[xstride]) planep[x] ^= invert;


796 
else planep[x] ^= planep[x1];


782  797 
} 
783 
planep += width; 

784  798 
} 
785  799 
} 
786  800 
else if (invert) 
787  801 
{ 
788  802 
planep = plane; 
789 
for (x=0; x<width*height; x++) planep[x] = !planep[x]; 

803 
for (x=0; x<width*height; x++) planep[x] = !planep[x]; //FIXME stride


790  804 
} 
791  805 
return 0; 
792  806 
} 
Also available in: Unified diff