📄 io.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 = (((Iob->vpos * BlockHeight) + (MVDV/2))*Iob->width)
+ (Iob->hpos * BlockWidth) + (MVDH/2)
+ Iob->mem->data;
LoadFilterMatrix_en(memloc,temp);
for(ptr=temp,i=0;i<BlockHeight;i++)
{
for(j=0;j<BlockWidth;j++)
{
*(matrix) = *(matrix) - *(ptr++);
matrix++;
}
}
}
/*BFUNC
HalfAddFCompensate_en() does an additive motion compensation on a
filtered version of the input block with the motion vector divided by
two.
EFUNC*/
//void HalfAddFCompensate_en(matrix)
// int *matrix;
void HalfAddFCompensate_en(int *matrix)
{
BEGIN("HalfAddFCompensate_en");
int i,j;
unsigned char *memloc;
int temp[64];
int *ptr;
memloc = (((Iob->vpos * BlockHeight) + (MVDV/2))*Iob->width)
+ (Iob->hpos * BlockWidth) + (MVDH/2)
+ Iob->mem->data;
LoadFilterMatrix_en(memloc,temp);
for(ptr=temp,i=0;i<BlockHeight;i++)
{
for(j=0;j<BlockWidth;j++)
{
*(matrix) = *(matrix) + *(ptr++);
matrix++;
}
}
}
/*BFUNC
ClearIob() clears the all the CFrame Iob memory structures by
resetting it to all zeroes.
EFUNC*/
//void ClearIob()
//{
// BEGIN("ClearIob");
// int i;
//
// for(i=0;i<CFrame->NumberComponents;i++)
// {
// ClearMem_en(CFrame->Iob[i]->mem);
// }
//}
/*BFUNC
CopyIob2FS() copies all of the CFrame Iob's to a given frame store.
EFUNC*/
//void CopyIob2FS(fs)
// FSTORE *fs;
//void CopyIob2FS(FSTORE *fs)
//{
// BEGIN("CopyIob2FS");
// int i;
//
// for(i=0;i<CFrame->NumberComponents;i++)
// {
// CopyMem(CFrame->Iob[i]->mem,fs->fs[i]->mem);
// }
//}
/*BFUNC
ClearFS_en() clears the entire frame store passed into it.
EFUNC*/
void ClearFS_en(FSTORE *fs)
{
BEGIN("ClearFS_en");
int i;
for(i=0;i<fs->NumberComponents;i++)
{
ClearMem_en(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
InitFS_en() initializes a frame store that is passed into it. It creates
the IO structures and the memory structures.
EFUNC*/
void InitFS_en(FSTORE *fs)
{
BEGIN("InitFS_en");
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 = CFrame->hf[i];
fs->fs[i]->ver = CFrame->vf[i];
fs->fs[i]->width = CFrame->Width[i];
fs->fs[i]->height = CFrame->Height[i];
fs->fs[i]->mem = MakeMem_en(CFrame->Width[i],CFrame->Height[i]);
}
}
/*BFUNC
ReadIob_en() loads the memory images from the filenames designated in the
CFrame structure.
EFUNC*/
void ReadIob_en()
{
BEGIN("ReadIob_en");
int i;
for(i=0;i<CFrame->NumberComponents;i++)
{
//CFrame->Iob[i]->mem = LoadMem(CFrame->ComponentFileName[i],
// CFrame->Width[i],
// CFrame->Height[i],
// CFrame->Iob[i]->mem);
//begin
if(! CFrame->Iob[i]->mem)
CFrame->Iob[i]->mem = MakeMem_en(CFrame->Width[i], CFrame->Height[i]);
memcpy(CFrame->Iob[i]->mem->data, CFrame->yuv[i], CFrame->Width[i]*CFrame->Height[i] );
//free(CFrame->Iob[i]->mem->data);
//CFrame->Iob[i]->mem->data = CFrame->yuv[i];
//end
}
}
/*BFUNC
InstallIob_en() installs a particular CFrame Iob as the target Iob.
EFUNC*/
//void InstallIob_en(index)
// int index;
void InstallIob_en(int index)
{
BEGIN("InstallIob_en");
Iob = CFrame->Iob[index];
}
/*BFUNC
InstallFS_en() installs a index Iob in the designated frame store to be
the target Iob.
EFUNC*/
void InstallFS_en(int index,FSTORE *fs)
{
BEGIN("InstallFS_en");
Iob = fs->fs[index];
}
/*BFUNC
WriteIob() writes all the CFrame Iob's out to the filenames designated
in CFrame.
EFUNC*/
//void WriteIob()
//{
// BEGIN("WriteIob");
// int i;
//
// for(i=0;i<CFrame->NumberComponents;i++)
// {
// //SaveMem(CFrame->ComponentFileName[i],CFrame->Iob[i]->mem);
// //begin 该语句可以取代SaveMem函数
// memcpy(CFrame->yuv[i], CFrame->Iob[i]->mem->data, CFrame->Iob[i]->mem->height * CFrame->Iob[i]->mem->width);
// //end
// }
//}
/*BFUNC
MoveTo_en() moves the installed Iob to a given location designated by the
Gob, MDU, and horizontal and vertical offsets.
EFUNC*/
//void MoveTo_en(g,m,h,v)
// int g;
// int m;
// int h;
// int v;
void MoveTo_en(int g,int m,int h,int v)
{
BEGIN("MoveTo_en");
/* printf("moveto: IOB: %x IOB->hor: %d %d %d %d %d\n",
Iob,Iob->hor,g,m,h,v); fflush(stdout); rm, */
switch (ImageType)
{
case IT_QCIF:
Iob->hpos = (m % 11)*Iob->hor + h;
Iob->vpos = ((g * 3) + (m / 11))*Iob->ver + v;
break;
case IT_CIF:
case IT_NTSC:
Iob->hpos = (((g & 1) * 11) + (m % 11))*Iob->hor + h;
Iob->vpos = (((g >> 1) * 3) + (m / 11))*Iob->ver + v;
break;
default:
WHEREAMI();
printf("Unknown image type: %d.\n",ImageType);
break;
}
}
/*BFUNC
Bpos_en() returns the designated MDU number inside of the frame of the
installed Iob 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 (ImageType)
{
case IT_QCIF:
return(((m % 11)*Iob->hor + h) +
((((g * 3) + (m / 11))*Iob->ver + v)* Iob->width/BlockWidth));
break;
case IT_CIF:
case IT_NTSC:
return(((((g & 1) * 11) + (m % 11))*Iob->hor + h) +
(((((g >> 1) * 3) + (m / 11))*Iob->ver + v)* Iob->width/BlockWidth));
break;
default:
WHEREAMI();
printf("Unknown image type: %d.\n",ImageType);
break;
}
return(0);
}
/*BFUNC
ReadBlock_en() reads a block from the currently installed Iob 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 = Iob->vpos*Iob->width*BlockHeight + Iob->hpos*BlockWidth+Iob->mem->data;
for(i=0;i<BlockHeight;i++)
{
for(j=0;j<BlockWidth;j++)
{
*(store++) = *(loc++);
}
loc += Iob->width - BlockWidth;
}
if ((++Iob->hpos % Iob->hor)==0)
{
if ((++Iob->vpos % Iob->ver) == 0)
{
if (Iob->hpos < ((Iob->width - 1)/(BlockWidth*Iob->hor))*Iob->hor + 1)
{
Iob->vpos -= Iob->ver;
}
else {Iob->hpos = 0;}
}
else {Iob->hpos -= Iob->hor;}
}
}
/*BFUNC
WriteBlock_en() writes a input matrix as a block into the currently
designated IOB structure.
EFUNC*/
//void WriteBlock_en(store)
// int *store;
void WriteBlock_en(int *store)
{
int i,j;
unsigned char *loc;
loc = Iob->vpos * Iob->width * BlockHeight + Iob->hpos * BlockWidth + Iob->mem->data;
for(i=0;i<BlockHeight;i++)
{
for(j=0; j<BlockWidth; j++)
{
*(loc++) = *(store++);
}
loc += Iob->width - BlockWidth;
}
if ( ( ++Iob->hpos % Iob->hor )==0 )
{
if ((++Iob->vpos % Iob->ver) == 0)
{
if (Iob->hpos < ((Iob->width - 1)/(BlockWidth*Iob->hor))*Iob->hor + 1)
{
Iob->vpos -= Iob->ver;
}
else
{
Iob->hpos = 0;
}
}
else
{
Iob->hpos -= Iob->hor;
}
}
}
/*BFUNC
PrintIob() prints out the current Iob structure to the standard output
device.
EFUNC*/
//void PrintIob()
//{
// printf("IOB: %x\n",Iob);
// if (Iob)
// {
// printf("hor: %d ver: %d width: %d height: %d\n",
// Iob->hor,Iob->ver,Iob->width,Iob->height);
// printf("flag: %d Memory Structure: %x\n",Iob->flag,Iob->mem);
// }
//}
/*END*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -