mp4_recon.c
资源名称:VC++视频传输.rar [点击查看]
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:3k
源码类别:
VC书籍
开发平台:
Visual C++
- #include "mp4_vars.h"
- #include "basic_prediction.h"
- #include "timer.h"
- /**
- *
- **/
- 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;
- s = src + lx * (y + yint) + x + xint;
- d = dst + lx * y + x;
- {
- int mc_driver = ((w!=8)<<3) | (mp4_state->hdr.rounding_type<<2) | (yh<<1) | (xh);
- switch (mc_driver)
- {
- case 0: case 4:
- CopyBlock(s, d, lx);
- break;
- case 1:
- CopyBlockHor(s, d, lx);
- break;
- case 2:
- CopyBlockVer(s, d, lx);
- break;
- case 3:
- CopyBlockHorVer(s, d, lx);
- break;
- case 5:
- CopyBlockHorRound(s, d, lx);
- break;
- case 6:
- CopyBlockVerRound(s, d, lx);
- break;
- case 7:
- CopyBlockHorVerRound(s, d, lx);
- break;
- case 8: case 12:
- CopyMBlock(s, d, lx);
- break;
- case 9:
- CopyMBlockHor(s, d, lx);
- break;
- case 10:
- CopyMBlockVer(s, d, lx);
- break;
- case 11:
- CopyMBlockHorVer(s, d, lx);
- break;
- case 13:
- CopyMBlockHorRound(s, d, lx);
- break;
- case 14:
- CopyMBlockVerRound(s, d, lx);
- break;
- case 15:
- CopyMBlockHorVerRound(s, d, lx);
- 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 = mp4_state->coded_picture_width;
- src[0] = frame_for[0];
- src[1] = frame_for[1];
- src[2] = frame_for[2];
- w = 8;
- h = 8;
- px = bx << 4;
- py = by << 4;
- if (mode == INTER4V)
- {
- for (comp = 0; comp < 4; comp++)
- {
- dx = mp4_state->MV[0][comp][y][x];
- dy = mp4_state->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 = mp4_state->MV[0][0][y][x];
- dy = mp4_state->MV[1][0][y][x];
- recon_comp (src[0], frame_ref[0], lx, w << 1, h << 1, px, py, dx, dy, 0);
- }
- px = bx << 3;
- py = by << 3;
- if (mode == INTER4V)
- {
- sum = mp4_state->MV[0][0][y][x] + mp4_state->MV[0][1][y][x] +
- mp4_state->MV[0][2][y][x] + mp4_state->MV[0][3][y][x];
- if (sum == 0)
- dx = 0;
- else
- dx = sign (sum) * (mp4_tables->roundtab[abs (sum) % 16] + (abs (sum) / 16) * 2);
- sum = mp4_state->MV[1][0][y][x] + mp4_state->MV[1][1][y][x] +
- mp4_state->MV[1][2][y][x] + mp4_state->MV[1][3][y][x];
- if (sum == 0)
- dy = 0;
- else
- dy = sign (sum) * (mp4_tables->roundtab[abs (sum) % 16] + (abs (sum) / 16) * 2);
- } else
- {
- dx = mp4_state->MV[0][0][y][x];
- dy = mp4_state->MV[1][0][y][x];
- 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();
- }
- /***/