📄 io2.c
字号:
/*BFUNC
HalfSubFCompensate_en() does a subtractive motion compensation on a
filtered version of the input block with the motion vector divided by
a factor of two.
EFUNC*/
//
//void HalfSubFCompensate_en(matrix)
// int *matrix;
//void HalfSubFCompensate_en(int *matrix)
//{
// BEGIN("HalfSubFCompensate_en");
// int i,j;
// unsigned char *memloc;
// int temp[64];
// int *ptr;
//
// memloc = (((Iob2->vpos * BlockH2eight2) + (MVDV2/2))*Iob2->width)
// + (Iob2->hpos * BlockWidth2) + (MVDH2/2)
// + Iob2->mem->data;
// LoadFilterMatrix2(memloc,temp);
// for(ptr=temp,i=0;i<BlockH2eight2;i++)
// {
// for(j=0;j<BlockWidth2;j++)
// {
// *(matrix) = *(matrix) - *(ptr++);
// matrix++;
// }
// }
//}
/*BFUNC
HalfAddFCompensate2() does an additive motion compensation on a
filtered version of the input block with the motion vector divided by
two.
EFUNC*/
//void HalfAddFCompensate2(matrix)
// int *matrix;
void HalfAddFCompensate2(int *matrix)
{
BEGIN("HalfAddFCompensate2");
int i,j;
unsigned char *memloc;
int temp[64];
int *ptr;
memloc = (((Iob2->vpos * BlockH2eight2) + (MVDV2/2))*Iob2->width)
+ (Iob2->hpos * BlockWidth2) + (MVDH2/2)
+ Iob2->mem->data;
LoadFilterMatrix2(memloc,temp);
for(ptr=temp,i=0;i<BlockH2eight2;i++)
{
for(j=0;j<BlockWidth2;j++)
{
*(matrix) = *(matrix) + *(ptr++);
matrix++;
}
}
}
/*BFUNC
ClearIob() clears the all the CFrame2 Iob2 memory structures by
resetting it to all zeroes.
EFUNC*/
//void ClearIob()
//{
// BEGIN("ClearIob");
// int i;
//
// for(i=0;i<CFrame2->NumberComponents;i++)
// {
// ClearMem2(CFrame2->Iob2[i]->mem);
// }
//}
/*BFUNC
CopyIob2FS2() copies all of the CFrame2 Iob2's to a given frame store.
EFUNC*/
//void CopyIob2FS2(fs)
// FSTORE *fs;
void CopyIob2FS2(FSTORE *fs)
{
BEGIN("CopyIob2FS2");
int i;
for(i=0;i<CFrame2->NumberComponents;i++)
{
CopyMem2(CFrame2->Iob2[i]->mem,fs->fs[i]->mem);
}
}
/*BFUNC
ClearFS2() clears the entire frame store passed into it.
EFUNC*/
void ClearFS2(FSTORE *fs)
{
BEGIN("ClearFS2");
int i;
for(i=0;i<fs->NumberComponents;i++)
{
ClearMem2(fs->fs[i]->mem);
}
}
/*BFUNC
ParityFS() calculates the parity of all the contents of the designated
frame store by exclusive-oring it on individual bit-planes and
returning the aggregate byte.
EFUNC*/
//int ParityFS(fs)
// FSTORE *fs;
//int ParityFS(FSTORE *fs)
//{
// BEGIN("ParityFS");
// int i,parity;
//
// for(parity=0,i=0;i<fs->NumberComponents;i++)
// {
// parity ^= ParityMem(fs->fs[i]->mem);
// }
// return(parity);
//}
/*BFUNC
InitFS2() initializes a frame store that is passed into it. It creates
the IO structures and the memory structures.
EFUNC*/
void InitFS2(FSTORE *fs)
{
BEGIN("InitFS2");
int i;
for(i=0;i<fs->NumberComponents;i++)
{
if (!(fs->fs[i]=MakeStructure(IOBUF)))
{
WHEREAMI();
printf("Cannot create IO structure.\n");
exit(ERROR_MEMORY);
}
fs->fs[i]->flag = 0;
fs->fs[i]->hpos = 0;
fs->fs[i]->vpos = 0;
fs->fs[i]->hor = CFrame2->hf[i];
fs->fs[i]->ver = CFrame2->vf[i];
fs->fs[i]->width = CFrame2->Width[i];
fs->fs[i]->height = CFrame2->Height[i];
fs->fs[i]->mem = MakeMem2(CFrame2->Width[i],CFrame2->Height[i]);
}
}
/*BFUNC
ReadIob_en() loads the memory images from the filenames designated in the
CFrame2 structure.
EFUNC*/
//void ReadIob_en()
//{
// BEGIN("ReadIob_en");
// int i;
//
// for(i=0;i<CFrame2->NumberComponents;i++)
// {
// //CFrame2->Iob2[i]->mem = LoadMem(CFrame2->ComponentFileName[i],
// // CFrame2->Width[i],
// // CFrame2->Height[i],
// // CFrame2->Iob2[i]->mem);
// //begin
// if(! CFrame2->Iob2[i]->mem)
// CFrame2->Iob2[i]->mem = MakeMem2(CFrame2->Width[i], CFrame2->Height[i]);
//
// memcpy(CFrame2->Iob2[i]->mem->data, CFrame2->yuv2[i], CFrame2->Width[i]*CFrame2->Height[i] );
// //free(CFrame2->Iob2[i]->mem->data);
// //CFrame2->Iob2[i]->mem->data = CFrame2->yuv2[i];
// //end
// }
//}
/*BFUNC
InstallIob2() installs a particular CFrame2 Iob2 as the target Iob2.
EFUNC*/
//void InstallIob2(index)
// int index;
void InstallIob2(int index)
{
BEGIN("InstallIob2");
Iob2 = CFrame2->Iob2[index];
}
/*BFUNC
InstallFS2() installs a index Iob2 in the designated frame store to be
the target Iob2.
EFUNC*/
void InstallFS2(int index,FSTORE *fs)
{
BEGIN("InstallFS2");
Iob2 = fs->fs[index];
}
/*BFUNC
WriteIob2() writes all the CFrame2 Iob2's out to the filenames designated
in CFrame2.
EFUNC*/
void WriteIob2()
{
BEGIN("WriteIob2");
int i;
for(i=0;i<CFrame2->NumberComponents;i++)
{
//SaveMem(CFrame2->ComponentFileName[i],CFrame2->Iob2[i]->mem);
//begin 该语句可以取代SaveMem函数
memcpy(CFrame2->yuv2[i], CFrame2->Iob2[i]->mem->data, CFrame2->Iob2[i]->mem->height * CFrame2->Iob2[i]->mem->width);
//end
}
}
/*BFUNC
MoveTo2() moves the installed Iob2 to a given location designated by the
Gob, MDU, and horizontal and vertical offsets.
EFUNC*/
//void MoveTo2(g,m,h,v)
// int g;
// int m;
// int h;
// int v;
void MoveTo2(int g,int m,int h,int v)
{
BEGIN("MoveTo2");
/* printf("moveto: IOB: %x IOB->hor: %d %d %d %d %d\n",
Iob2,Iob2->hor,g,m,h,v); fflush(stdout); rm, */
switch (ImageType2)
{
case IT_QCIF:
Iob2->hpos = (m % 11)*Iob2->hor + h;
Iob2->vpos = ((g * 3) + (m / 11))*Iob2->ver + v;
break;
case IT_CIF:
case IT_NTSC:
Iob2->hpos = (((g & 1) * 11) + (m % 11))*Iob2->hor + h;
Iob2->vpos = (((g >> 1) * 3) + (m / 11))*Iob2->ver + v;
break;
default:
WHEREAMI();
printf("Unknown image type: %d.\n",ImageType2);
break;
}
}
/*BFUNC
Bpos_en() returns the designated MDU number inside of the frame of the
installed Iob2 given by the input gob, mdu, horizontal and vertical
offset. It returns 0 on error.
EFUNC*/
//int Bpos_en(g,m,h,v)
// int g;
// int m;
// int h;
// int v;
//int Bpos_en(int g,int m,int h,int v)
//{
// BEGIN("Bpos_en");
//
// switch (ImageType2)
// {
// case IT_QCIF:
// return(((m % 11)*Iob2->hor + h) +
// ((((g * 3) + (m / 11))*Iob2->ver + v)* Iob2->width/BlockWidth2));
// break;
// case IT_CIF:
// case IT_NTSC:
// return(((((g & 1) * 11) + (m % 11))*Iob2->hor + h) +
// (((((g >> 1) * 3) + (m / 11))*Iob2->ver + v)* Iob2->width/BlockWidth2));
// break;
// default:
// WHEREAMI();
// printf("Unknown image type: %d.\n",ImageType2);
// break;
// }
// return(0);
//}
/*BFUNC
ReadBlock_en() reads a block from the currently installed Iob2 into a
designated matrix.
EFUNC*/
//void ReadBlock_en(store)
// int *store;
//void ReadBlock_en(int *store)
//{
// BEGIN("ReadBlock_en");
// int i,j;
// unsigned char *loc;
//
// loc = Iob2->vpos*Iob2->width*BlockH2eight2 + Iob2->hpos*BlockWidth2+Iob2->mem->data;
// for(i=0;i<BlockH2eight2;i++)
// {
// for(j=0;j<BlockWidth2;j++)
// {
// *(store++) = *(loc++);
// }
// loc += Iob2->width - BlockWidth2;
// }
// if ((++Iob2->hpos % Iob2->hor)==0)
// {
// if ((++Iob2->vpos % Iob2->ver) == 0)
// {
// if (Iob2->hpos < ((Iob2->width - 1)/(BlockWidth2*Iob2->hor))*Iob2->hor + 1)
// {
// Iob2->vpos -= Iob2->ver;
// }
// else {Iob2->hpos = 0;}
// }
// else {Iob2->hpos -= Iob2->hor;}
// }
//}
/*BFUNC
WriteBlock2() writes a input matrix as a block into the currently
designated IOB structure.
EFUNC*/
//void WriteBlock2(store)
// int *store;
void WriteBlock2(int *store)
{
int i,j;
unsigned char *loc;
loc = Iob2->vpos * Iob2->width * BlockH2eight2 + Iob2->hpos * BlockWidth2 + Iob2->mem->data;
for(i=0;i<BlockH2eight2;i++)
{
for(j=0; j<BlockWidth2; j++)
{
*(loc++) = *(store++);
}
loc += Iob2->width - BlockWidth2;
}
if ( ( ++Iob2->hpos % Iob2->hor )==0 )
{
if ((++Iob2->vpos % Iob2->ver) == 0)
{
if (Iob2->hpos < ((Iob2->width - 1)/(BlockWidth2*Iob2->hor))*Iob2->hor + 1)
{
Iob2->vpos -= Iob2->ver;
}
else
{
Iob2->hpos = 0;
}
}
else
{
Iob2->hpos -= Iob2->hor;
}
}
}
/*BFUNC
PrintIob() prints out the current Iob2 structure to the standard output2
device.
EFUNC*/
//
//void PrintIob()
//{
// printf("IOB: %x\n",Iob2);
// if (Iob2)
// {
// printf("hor: %d ver: %d width: %d height: %d\n",
// Iob2->hor,Iob2->ver,Iob2->width,Iob2->height);
// printf("flag: %d Memory2 Structure: %x\n",Iob2->flag,Iob2->mem);
// }
//}
/*END*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -