📄 recon.c
字号:
//*********************************************
//File name: recon.c
//Author: Anna
//Date:
//*********************************************
#define INTER4V 2
#define DEC_MBC 45
#define DEC_MBR 36
#define abs(a) ((a)>0 ? (a) : -(a))
#define sign(a) ((a) < 0 ? -1 : 1)
extern int MV[2][6][DEC_MBR+1][DEC_MBC+2];
extern int coded_picture_width;
extern int rounding_type;
extern unsigned char //*edged_ref[3],
// *edged_for[3],
*frame_ref[3],
*frame_for[3];
// *display_frame[3];
extern int roundtab[16];
extern void CopyBlock(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockHor(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockVer(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockHorVer(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockVerRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyBlockHorVerRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
/**/
extern void CopyMBlock(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockHor(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockVer(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockHorVer(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockVerRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
extern void CopyMBlockHorVerRound(unsigned char * Src, unsigned char * Dst, int Stride,int xint,int yint,int orgx,int orgy);
void recon_comp (unsigned char *src, unsigned char *dst,
int lx, int w, int h, int x,
int y, int dx, int dy, int chroma)
{
int xint, xh, yint, yh;
unsigned char *s, *d;
xint = dx >> 1;
xh = dx & 1;
yint = dy >> 1;
yh = dy & 1;
/* origins */
// s = src + lx * (y + yint) + x + xint;
// d = dst + lx * y + x;
{
int mc_driver = ((w!=8)<<3) | (rounding_type<<2) | (yh<<1) | (xh);
switch (mc_driver)
{
// block
// no round
case 0: case 4:
// CopyBlock(s,d,lx);
CopyBlock(src,dst,lx,xint,yint,x,y);
break;
case 1:
// CopyBlockHor(s, d, lx);
CopyBlockHor(src, dst, lx,xint,yint,x,y);
break;
case 2:
// CopyBlockVer(s, d, lx);
CopyBlockVer(src,dst,lx,xint,yint,x,y);
break;
case 3:
// CopyBlockHorVer(s, d, lx);
CopyBlockHorVer(src,dst,lx,xint,yint,x,y);
break;
// round
case 5:
// CopyBlockHorRound(s, d, lx);
CopyBlockHorRound(src,dst,lx,xint,yint,x,y);
break;
case 6:
// CopyBlockVerRound(s, d, lx);
CopyBlockVerRound(src,dst,lx,xint,yint,x,y);
break;
case 7:
// CopyBlockHorVerRound(s, d, lx);
CopyBlockHorVerRound(src,dst,lx,xint,yint,x,y);
break;
// macroblock
// no round
case 8: case 12:
// CopyMBlock(s, d, lx);
CopyMBlock(src,dst,lx,xint,yint,x,y);
break;
case 9:
// CopyMBlockHor(s, d, lx);
CopyMBlockHor(src,dst,lx,xint,yint,x,y);
break;
case 10:
// CopyMBlockVer(s, d, lx);
CopyMBlockVer(src,dst,lx,xint,yint,x,y);
break;
case 11:
// CopyMBlockHorVer(s, d, lx);
CopyMBlockHorVer(src,dst,lx,xint,yint,x,y);
break;
// round
case 13:
// CopyMBlockHorRound(s, d, lx);
CopyMBlockHorRound(src,dst,lx,xint,yint,x,y);
break;
case 14:
// CopyMBlockVerRound(s, d, lx);
CopyMBlockVerRound(src,dst,lx,xint,yint,x,y);
break;
case 15:
// CopyMBlockHorVerRound(s, d, lx);
CopyMBlockHorVerRound(src,dst,lx,xint,yint,x,y);
break;
}
}
}
/***/
void reconstruct (int bx, int by, int mode)
{
int w, h, lx, dx, dy, xp, yp, comp, sum;
int x, y, px, py;
unsigned char * src[3];
// start_timer();
x = bx + 1;
y = by + 1;
lx = coded_picture_width;
src[0] = frame_for[0];
src[1] = frame_for[1];
src[2] = frame_for[2];
w = 8;
h = 8;
// Luma
px = bx << 4;
py = by << 4;
if (mode == INTER4V)
{
for (comp = 0; comp < 4; comp++)
{
dx = MV[0][comp][y][x];
dy = MV[1][comp][y][x];
xp = px + ((comp & 1) << 3);
yp = py + ((comp & 2) << 2);
recon_comp (src[0], frame_ref[0], lx, w, h, xp, yp, dx, dy, 0);
}
} else
{
dx = MV[0][0][y][x];
dy = MV[1][0][y][x];
// if((px+dx)<0 || (px+dx)>mp4_state->hdr.width-1-16) dx=0;
// if((py+dy)<0 || (py+dy)>mp4_state->hdr.height-1-16) dy=0;
recon_comp (src[0], frame_ref[0], lx, w << 1, h << 1, px, py, dx, dy, 0);
}
// Chr
px = bx << 3;
py = by << 3;
if (mode == INTER4V)
{
sum = MV[0][0][y][x] + MV[0][1][y][x] +
MV[0][2][y][x] + MV[0][3][y][x];
if (sum == 0)
dx = 0;
else
dx = sign (sum) * (roundtab[abs (sum) % 16] + (abs (sum) / 16) * 2);
sum = MV[1][0][y][x] + MV[1][1][y][x] +
MV[1][2][y][x] + MV[1][3][y][x];
if (sum == 0)
dy = 0;
else
dy = sign (sum) * (roundtab[abs (sum) % 16] + (abs (sum) / 16) * 2);
} else
{
dx = MV[0][0][y][x];
dy = MV[1][0][y][x];
/* chroma rounding */
dx = (dx % 4 == 0 ? dx >> 1 : (dx >> 1) | 1);
dy = (dy % 4 == 0 ? dy >> 1 : (dy >> 1) | 1);
}
lx >>= 1;
recon_comp (src[1], frame_ref[1], lx, w, h, px, py, dx, dy, 1);
recon_comp (src[2], frame_ref[2], lx, w, h, px, py, dx, dy, 2);
//stop_recon_timer();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -