📄 seg.cpp
字号:
Height[1] = Height[2] = (Height[0]+1)>>1;
nLevels[0] = wvtDecompLev ;
nLevels[1] = nLevels[2] = nLevels[0]-1;
for (col=0; col<colors; col++) {
inimage[col] = (UChar *)MyImage[col].data;
inmask[col] = (UChar *)MyImage[col].mask;
if(col==0) {
Shape = usemask? ((STO_const_alpha) ? STO_const_alpha_value : MASK_VAL):RECTANGULAR;
ret = GetMaskBox(inmask[col], &outmask[col],
Width[col], Height[col], Nx[col],Ny[col],
&width[col], &height[col], &origin_x[col], &origin_y[col],
Shape,
nLevels[col]);
if (ret!=DWT_OK)
errorHandler("DWT Error code = %d\n", ret);
if (usemask) free(inmask[col]);
}
else {
width[col] = width[0]/Nx[0];
height[col] = height[0]/Ny[0];
origin_x[col] = origin_x[0]/Nx[0];
origin_y[col] = origin_y[0]/Ny[0];
}
ret=GetBox(inimage[col],
(Void **)&outimage[col],
Width[col], Height[col],
width[col], height[col], origin_x[col], origin_y[col], 0);
if (ret!=DWT_OK)
errorHandler("DWT Error code = %d\n", ret);
if(col==0) {
if(usemask) { /* do shape quantization */
QuantizeShape(outmask[0], width[0], height[0], alphaTH);
}
}
else {
/* obtain new quantized mask for other color components */
SubsampleMask(outmask[0], &(outmask[col]), width[0],
height[0], Filter);
}
free(inimage[col]);
MyImage[col].data = outimage[col];
MyImage[col].mask = outmask[col];
/* zero out outnode pixels */
for(i=0;i<width[col]*height[col];i++)
if(outmask[col][i]!=DWT_IN) outimage[col][i]=0;
}
mzte_codec.m_iWidth = width[0];
mzte_codec.m_iHeight = height[0];
mzte_codec.m_iOriginX = origin_x[0];
mzte_codec.m_iOriginY = origin_y[0];
mzte_codec.m_iRealWidth = Width[0];
mzte_codec.m_iRealHeight = Height[0];
}
Void CVTCEncoder::get_virtual_image_V1(PICTURE *MyImage, Int wvtDecompLev,
Int usemask, Int colors, Int alphaTH,
Int change_CR_disable, FILTER *Filter)
{
Int Nx[3], Ny[3];
Int Width[3], Height[3];
Int nLevels[3];
Int col,i;
/* for 4:2:0 YUV image only */
Nx[0] = Ny[0]=2;
for(col=1; col<colors; col++) Nx[col]=Ny[col]=1;
Width[0] = MyImage[0].width;
Width[1] = Width[2] = (Width[0]+1)>>1;
Height[0] = MyImage[0].height;
Height[1] = Height[2] = (Height[0]+1)>>1;
nLevels[0] = wvtDecompLev ;
nLevels[1] = nLevels[2] = nLevels[0]-1;
for (col=0; col<colors; col++) {
MyImage[col].mask = (UChar *)malloc(sizeof(UChar)*Width[col]*Height[col]);
for(i=0;i<Width[col]*Height[col];i++) {
MyImage[col].mask[i] = DWT_IN;
}
}
mzte_codec.m_iWidth = Width[0];
mzte_codec.m_iHeight = Height[0];
mzte_codec.m_iOriginX = Width[0];
mzte_codec.m_iOriginY = Height[0];
mzte_codec.m_iRealWidth = Width[0];
mzte_codec.m_iRealHeight = Height[0];
}
Void CVTCDecoder::get_virtual_mask(PICTURE *MyImage, Int wvtDecompLev,
Int w, Int h, Int usemask, Int colors,
Int *target_levels, Int startCodeEnable,
FILTER **filters)
{
Int width[3], height[3];
Int Width[3], Height[3];
Int nLevels[3];
UChar *outmask[3], *tempmask;
Int ret,col;
Int Nx[3], Ny[3];
// Int origin_x[3], origin_y[3];
/* for 4:2:0 YUV image only */
Nx[0] = Ny[0]=2;
for(col=1; col<3; col++) Nx[col]=Ny[col]=1;
nLevels[0] = wvtDecompLev;
nLevels[1] = nLevels[2] = nLevels[0]-1;
Width[0]= w;
Width[1]=Width[2]= (w+1)>>1;
Height[0]= h;
Height[1]=Height[2] = (h+1)>>1;
for (col=0; col<colors; col++) {
if(col==0) { /* get decoded shape of Y */
outmask[col] = MyImage[col].mask =(UChar *)malloc(sizeof(UChar)*Width[col]*Height[col]);
if(outmask[col]==NULL)
errorHandler("Couldn't allocate memory to image\n");
if (usemask) {
/* ShapeDeCoding(outmask[0], Width[0], Height[0]); */
ShapeDeCoding(outmask[0], Width[0], Height[0],
wvtDecompLev, target_levels,
&STO_const_alpha,
&STO_const_alpha_value,
startCodeEnable,
1, /* always get fullsize*/
filters);
}
else {
memset(outmask[0], (UChar) 1, Width[0]*Height[0]);
*target_levels = 0;
}
if((Width[0] &((1<<wvtDecompLev)-1))!=0 || (Height[0] &((1<<wvtDecompLev)-1))!=0 ) {
ret=ExtendMaskBox(outmask[0], &tempmask, Width[0], Height[0], Nx[0], Ny[0], &width[0], &height[0], nLevels[0]);
if (ret!=DWT_OK)
errorHandler("ExtendMaskBox: DWT Error code = %d\n", ret);
free(outmask[0]);
outmask[0]=tempmask;
}
else {
width[0] = Width[0];
height[0] = Height[0];
}
}
else { /* subsample shape for U,V*/
SubsampleMask(outmask[0], &(outmask[col]), width[0],
height[0], filters[0]);
}
MyImage[col].mask = outmask[col];
}
if(!usemask) {
mzte_codec.m_iWidth = width[0];
mzte_codec.m_iHeight = height[0];
mzte_codec.m_iOriginX = 0;
mzte_codec.m_iOriginY = 0;
mzte_codec.m_iRealWidth = Width[0];
mzte_codec.m_iRealHeight = Height[0];
}
else {
mzte_codec.m_iWidth = width[0];
mzte_codec.m_iHeight = height[0];
}
}
Void CVTCDecoder::get_virtual_mask_V1(PICTURE *MyImage, Int wvtDecompLev,
Int w, Int h, Int usemask, Int colors, FILTER **filters)
{
// Int width[3], height[3];
Int Width[3], Height[3];
Int nLevels[3];
Int col,i;
Int Nx[3], Ny[3];
/* for 4:2:0 YUV image only */
Nx[0] = Ny[0]=2;
for(col=1; col<3; col++) Nx[col]=Ny[col]=1;
nLevels[0] = wvtDecompLev;
nLevels[1] = nLevels[2] = nLevels[0]-1;
Width[0]= w;
Width[1]=Width[2]= (w+1)>>1;
Height[0]= h;
Height[1]=Height[2] = (h+1)>>1;
if (!usemask) {
for (col=0; col<mzte_codec.m_iColors; col++) {
MyImage[col].mask
=(UChar *)malloc(sizeof(UChar)*Width[col]*Height[col]);
if (MyImage[col].mask==NULL)
errorHandler("Couldn't allocate memory to image\n");
for (i=0; i<Width[col]*Height[col]; i++)
MyImage[col].mask[i] = DWT_IN;
}
mzte_codec.m_iWidth = Width[0];
mzte_codec.m_iHeight = Height[0];
mzte_codec.m_iOriginX = 0;
mzte_codec.m_iOriginY = 0;
mzte_codec.m_iRealWidth = Width[0];
mzte_codec.m_iRealHeight = Height[0];
}
// else {
// mzte_codec.m_iWidth = width[0];
// mzte_codec.m_iHeight = height[0];
// }
}
Void CVTCDecoder::get_virtual_mask_TILE(PICTURE *MyImage, Int wvtDecompLev,
Int w, Int h, Int usemask, Int colors,
Int *target_shape_layer, Int StartCodeEnable,
FILTER **filters)
{
// Int width[3], height[3];
Int Width[3], Height[3];
Int nLevels[3];
Int col,i;
Int Nx[3], Ny[3];
/* for 4:2:0 YUV image only */
Nx[0] = Ny[0]=2;
for(col=1; col<3; col++) Nx[col]=Ny[col]=1;
nLevels[0] = wvtDecompLev;
nLevels[1] = nLevels[2] = nLevels[0]-1;
Width[0]= w;
Width[1]=Width[2]= (w+1)>>1;
Height[0]= h;
Height[1]=Height[2] = (h+1)>>1;
if (!usemask) {
for (col=0; col<mzte_codec.m_iColors; col++) {
MyImage[col].mask
=(UChar *)malloc(sizeof(UChar)*Width[col]*Height[col]);
if (MyImage[col].mask==NULL)
errorHandler("Couldn't allocate memory to image\n");
for (i=0; i<Width[col]*Height[col]; i++)
MyImage[col].mask[i] = DWT_IN;
}
mzte_codec.m_iWidth = Width[0];
mzte_codec.m_iHeight = Height[0];
mzte_codec.m_iOriginX = 0;
mzte_codec.m_iOriginY = 0;
mzte_codec.m_iRealWidth = Width[0];
mzte_codec.m_iRealHeight = Height[0];
}
}
Int CVTCEncoder::
QuantizeShape(UChar *inmask, Int width, Int height, Int alphaTH)
{
/* quantize the mask according to a 4x4 block alphaTH, should always favour zeros
since it will reduce the coefficients to be coded*/
return(0);
}
Void CVTCEncoder::
PutBitstoStream_Still(Int bits,UInt code)
{
while(bits>16) {
emit_bits((UShort)(code>>(bits-16)), 16);
bits-=16;
}
emit_bits((UShort)code, bits);
return;
}
Int CVTCEncoder::
ByteAlignmentEnc_Still()
{
flush_bits();
return(0);
}
//end; added by SL 030399
// begin: added by Sharp (99/5/10)
// FPDAM begin : modified by Sharp
Void CVTCEncoder::cut_tile_image(PICTURE *DstImage, PICTURE *SrcImage, Int iTile, Int colors, Int tile_width, Int tile_height, FILTER *Filter)
// FPDAM end : modified by Sharp
{
Int SrcWidth[3], DstWidth[3], SrcHeight[3], DstHeight[3];
Int RealWidth[3], RealHeight[3];
Int Width, Height;
Int iTileX, iTileY, iTileW, iTileH;
UChar *SrcPtr, *DstPtr, *DstMask;
/* FPDAM begin: added by Sharp */
UChar *SrcMask, *OutMask;
/* FPDAM end: added by Sharp */
Int iW, iH, i;
iTileW = SrcImage[0].width / tile_width + ((SrcImage[0].width%tile_width)==0?0:1);
iTileH = SrcImage[0].height / tile_height + ((SrcImage[0].height%tile_height)==0?0:1);
iTileX = iTile % iTileW;
iTileY = iTile / iTileW;
/* printf("iTileW=%d\niTileX=%d\niTileY=%d\n", iTileW, iTileX, iTileY);*/
#ifdef _FPDAM_DBG_
fprintf(stderr,"\n..............iTile=%d iTileW=%d iTileH=%d iTileX=%d iTileY=%d\n",
iTile, iTileW, iTileH, iTileX, iTileY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -