📄 getpic.c
字号:
BMVx = sign (xvec) * (roundtab[abs (xvec) % 16] + (abs (xvec) / 16) * 2); BMVy = sign (yvec) * (roundtab[abs (yvec) % 16] + (abs (yvec) / 16) * 2); } } else { if (comp < 4) { /* luma */ mvx = MV[0][0][y][x]; mvy = MV[1][0][y][x]; BMVx = (bdx == 0 ? (trb - trd) * mvx / trd : trb * mvx / trd + bdx - mvx); BMVy = (bdy == 0 ? (trb - trd) * mvy / trd : trb * mvy / trd + bdy - mvy); } else { /* chroma */ mvx = MV[0][0][y][x]; mvy = MV[1][0][y][x]; xvec = (bdx == 0 ? (trb - trd) * mvx / trd : trb * mvx / trd + bdx - mvx); yvec = (bdy == 0 ? (trb - trd) * mvy / trd : trb * mvy / trd + bdy - mvy); xvec *= 4; yvec *= 4; /* chroma rounding (table 16/H.263) */ BMVx = sign (xvec) * (roundtab[abs (xvec) % 16] + (abs (xvec) / 16) * 2); BMVy = sign (yvec) * (roundtab[abs (yvec) % 16] + (abs (yvec) / 16) * 2); } } cc = (comp < 4) ? 0 : (comp & 1) + 1; /* color component index */ if (cc == 0) { /* luminance */ find_bidir_limits (BMVx, &xa, &xb, comp & 1); find_bidir_limits (BMVy, &ya, &yb, (comp & 2) >> 1); bfr = bframe[0] + coded_picture_width * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3); ffr = current_frame[0] + coded_picture_width * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3); ii = coded_picture_width; } else { /* chrominance */ /* scale coordinates and vectors */ bx >>= 1; by >>= 1; find_bidir_chroma_limits (BMVx, &xa, &xb); find_bidir_chroma_limits (BMVy, &ya, &yb); bfr = bframe[cc] + chrom_width * (by + ((comp & 2) << 2)) + bx + (comp & 8); ffr = current_frame[cc] + chrom_width * (by + ((comp & 2) << 2)) + bx + (comp & 8); ii = chrom_width; } xint = BMVx >> 1; xhalf = BMVx - 2 * xint; yint = BMVy >> 1; yhalf = BMVy - 2 * yint; ffr += xint + (yint + ya) * ii; bfr += ya * ii; if (!xhalf && !yhalf) { for (j = ya; j < yb; j++) { for (i = xa; i < xb; i++) { pel = ffr[i]; bfr[i] = ((unsigned int) (pel + bfr[i])) >> 1; } bfr += ii; ffr += ii; } } else if (xhalf && !yhalf) { for (j = ya; j < yb; j++) { for (i = xa; i < xb; i++) { pel = ((unsigned int) (ffr[i] + ffr[i + 1] + 1)) >> 1; bfr[i] = ((unsigned int) (pel + bfr[i])) >> 1; } bfr += ii; ffr += ii; } } else if (!xhalf && yhalf) { for (j = ya; j < yb; j++) { for (i = xa; i < xb; i++) { pel = ((unsigned int) (ffr[i] + ffr[ii + i] + 1)) >> 1; bfr[i] = ((unsigned int) (pel + bfr[i])) >> 1; } bfr += ii; ffr += ii; } } else { /* if (xhalf && yhalf) */ for (j = ya; j < yb; j++) { for (i = xa; i < xb; i++) { pel = ((unsigned int) (ffr[i] + ffr[i + 1] + ffr[ii + i] + ffr[ii + i + 1] + 2)) >> 2; bfr[i] = ((unsigned int) (pel + bfr[i])) >> 1; } bfr += ii; ffr += ii; } } return;}int motion_decode (int vec, int pmv){ if (vec > 31) vec -= 64; vec += pmv; if (!long_vectors) { if (vec > 31) vec -= 64; if (vec < -32) vec += 64; } else { if (pmv < -31 && vec < -63) vec += 64; if (pmv > 32 && vec > 63) vec -= 64; } return vec;}int find_pmv (int x, int y, int block, int comp){ int p1, p2, p3; int xin1, xin2, xin3; int yin1, yin2, yin3; int vec1, vec2, vec3; int l8, o8, or8; x++; y++; l8 = (modemap[y][x - 1] == MODE_INTER4V ? 1 : 0); l8 = (modemap[y][x - 1] == MODE_INTER4V_Q ? 1 : l8); o8 = (modemap[y - 1][x] == MODE_INTER4V ? 1 : 0); o8 = (modemap[y - 1][x] == MODE_INTER4V_Q ? 1 : o8); or8 = (modemap[y - 1][x + 1] == MODE_INTER4V ? 1 : 0); or8 = (modemap[y - 1][x + 1] == MODE_INTER4V_Q ? 1 : or8); switch (block) { case 0: vec1 = (l8 ? 2 : 0); yin1 = y; xin1 = x - 1; vec2 = (o8 ? 3 : 0); yin2 = y - 1; xin2 = x; vec3 = (or8 ? 3 : 0); yin3 = y - 1; xin3 = x + 1; break; case 1: vec1 = (l8 ? 2 : 0); yin1 = y; xin1 = x - 1; vec2 = (o8 ? 3 : 0); yin2 = y - 1; xin2 = x; vec3 = (or8 ? 3 : 0); yin3 = y - 1; xin3 = x + 1; break; case 2: vec1 = 1; yin1 = y; xin1 = x; vec2 = (o8 ? 4 : 0); yin2 = y - 1; xin2 = x; vec3 = (or8 ? 3 : 0); yin3 = y - 1; xin3 = x + 1; break; case 3: vec1 = (l8 ? 4 : 0); yin1 = y; xin1 = x - 1; vec2 = 1; yin2 = y; xin2 = x; vec3 = 2; yin3 = y; xin3 = x; break; case 4: vec1 = 3; yin1 = y; xin1 = x; vec2 = 1; yin2 = y; xin2 = x; vec3 = 2; yin3 = y; xin3 = x; break; case 5: vec1 = 5; yin1 = y; xin1 = x - 1; vec2 = 5; yin2 = y - 1; xin2 = x; vec3 = 5; yin3 = y - 1; xin3 = x + 1; break; default: fprintf (stderr, "Illegal block number in find_pmv (getpic.c)\n"); exit (1); break; } p1 = MV[comp][vec1][yin1][xin1]; p2 = MV[comp][vec2][yin2][xin2]; p3 = MV[comp][vec3][yin3][xin3]; if (newgob && (block == 0 || block == 1 || block == 2)) p2 = NO_VEC; if (p2 == NO_VEC) { p2 = p3 = p1; } return p1 + p2 + p3 - mmax (p1, mmax (p2, p3)) - mmin (p1, mmin (p2, p3));}void find_bidir_limits (int vec, int *start, int *stop, int nhv){ /* limits taken from C loop in section G5 in H.263 */ *start = mmax (0, (-vec + 1) / 2 - nhv * 8); *stop = mmin (7, 15 - (vec + 1) / 2 - nhv * 8); (*stop)++; /* I use < and not <= in the loop */}void find_bidir_chroma_limits (int vec, int *start, int *stop){ /* limits taken from C loop in section G5 in H.263 */ *start = mmax (0, (-vec + 1) / 2); *stop = mmin (7, 7 - (vec + 1) / 2); (*stop)++; /* I use < and not <= in the loop */ return;}void make_edge_image (unsigned char *src, unsigned char *dst, int width, int height, int edge){ int i, j; unsigned char *p1, *p2, *p3, *p4; unsigned char *o1, *o2, *o3, *o4; /* center image */ p1 = dst; o1 = src; for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { *(p1 + i) = *(o1 + i); } p1 += width + (edge << 1); o1 += width; } /* left and right edges */ p1 = dst - 1; o1 = src; for (j = 0; j < height; j++) { for (i = 0; i < edge; i++) { *(p1 - i) = *o1; *(p1 + width + i + 1) = *(o1 + width - 1); } p1 += width + (edge << 1); o1 += width; } /* top and bottom edges */ p1 = dst; p2 = dst + (width + (edge << 1)) * (height - 1); o1 = src; o2 = src + width * (height - 1); for (j = 0; j < edge; j++) { p1 = p1 - (width + (edge << 1)); p2 = p2 + (width + (edge << 1)); for (i = 0; i < width; i++) { *(p1 + i) = *(o1 + i); *(p2 + i) = *(o2 + i); } } /* corners */ p1 = dst - (width + (edge << 1)) - 1; p2 = p1 + width + 1; p3 = dst + (width + (edge << 1)) * (height) - 1; p4 = p3 + width + 1; o1 = src; o2 = o1 + width - 1; o3 = src + width * (height - 1); o4 = o3 + width - 1; for (j = 0; j < edge; j++) { for (i = 0; i < edge; i++) { *(p1 - i) = *o1; *(p2 + i) = *o2; *(p3 - i) = *o3; *(p4 + i) = *o4; } p1 = p1 - (width + (edge << 1)); p2 = p2 - (width + (edge << 1)); p3 = p3 + width + (edge << 1); p4 = p4 + width + (edge << 1); }}/********************************************************************** * * Name: Intra_AC_DC_Decode * Description: Intra Prediction in Advanced Intra Coding * * Input: store_qcoeff, Intra_AC_DC, position of MB, store_QP * * Side effects: change qcoeff to predicted qcoeff * * Return: * * Date:970717 Guy Cote <guyc@ee.ubc.ca> * ***********************************************************************/void Intra_AC_DC_Decode (short *store_qcoeff, int INTRA_AC_DC, int MBA, int xpos, int ypos, int comp, int newgob){ int A[8], B[8]; int i, j, tempDC; short *Rec_C; short *rcoeff; Rec_C = ld->block[comp]; if (xpos == 0 && ypos == 0) { /* top left corner */ (comp == 2 || comp == 3) ? fill_A (A, store_qcoeff, xpos, ypos, comp - 2) : fill_null (A); (comp == 1 || comp == 3) ? fill_B (B, store_qcoeff, xpos, ypos, comp - 1) : fill_null (B); } else { /* left border of picture */ if (xpos == 0) { /* left edge of the picture */ (comp == 2 || comp == 3) ? fill_A (A, store_qcoeff, xpos, ypos, comp - 2) : ((comp == 0 || comp == 1) && !(newgob)) ? fill_A (A, store_qcoeff, xpos, ypos - 1, comp + 2) : ((comp == 4 || comp == 5) && !(newgob)) ? fill_A (A, store_qcoeff, xpos, ypos - 1, comp) : fill_null (A); (comp == 1 || comp == 3) ? fill_B (B, store_qcoeff, xpos, ypos, comp - 1) : fill_null (B); } else { if (ypos == 0) { /* top border of picture */ (comp == 2 || comp == 3) ? fill_A (A, store_qcoeff, xpos, ypos, comp - 2) : fill_null (A); (comp == 4 || comp == 5) ? fill_B (B, store_qcoeff, xpos - 1, ypos, comp) : (comp == 1 || comp == 3) ? fill_B (B, store_qcoeff, xpos, ypos, comp - 1) : fill_B (B, store_qcoeff, xpos - 1, ypos, comp + 1); } else { /* anywhere else in the picture, do not * cross GOB boundary */ (comp == 2 || comp == 3) ? fill_A (A, store_qcoeff, xpos, ypos, comp - 2) : ((comp == 0 || comp == 1) && !(newgob)) ? fill_A (A, store_qcoeff, xpos, ypos - 1, comp + 2) : ((comp == 4 || comp == 5) && !(newgob)) ? fill_A (A, store_qcoeff, xpos, ypos - 1, comp) : fill_null (A); (comp == 4 || comp == 5) ? fill_B (B, store_qcoeff, xpos - 1, ypos, comp) : (comp == 1 || comp == 3) ? fill_B (B, store_qcoeff, xpos, ypos, comp - 1) : fill_B (B, store_qcoeff, xpos - 1, ypos, comp + 1); } } } /* replace the qcoeff with the predicted values pcoeff */ switch (INTRA_AC_DC) { case INTRA_MODE_DC: tempDC = Rec_C[0] + ((A[0] == 1024 && B[0] == 1024) ? 1024 : (A[0] == 1024) ? B[0] : (B[0] == 1024) ? A[0] : (A[0] + B[0]) / 2); for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) Rec_C[i * 8 + j] = clipAC (Rec_C[i * 8 + j]); Rec_C[0] = oddifyclipDC (tempDC); break; case INTRA_MODE_VERT_AC: tempDC = Rec_C[0] + A[0]; for (i = 1; i < 8; i++) { rcoeff = &Rec_C[i]; *rcoeff = clipAC (Rec_C[i] + A[i]); } for (i = 1; i < 8; i++) for (j = 0; j < 8; j++) Rec_C[i * 8 + j] = clipAC (Rec_C[i * 8 + j]); Rec_C[0] = oddifyclipDC (tempDC); break; case INTRA_MODE_HORI_AC: tempDC = Rec_C[0] + B[0]; for (i = 1; i < 8; i++) Rec_C[i * 8] = clipAC (Rec_C[i * 8] + B[i]); for (i = 0; i < 8; i++) for (j = 1; j < 8; j++) Rec_C[i * 8 + j] = clipAC (Rec_C[i * 8 + j]); Rec_C[0] = oddifyclipDC (tempDC); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -