00001
00017 #include "contributors.h"
00018
00019 #include "global.h"
00020 #include "block.h"
00021 #include "image.h"
00022 #include "mb_access.h"
00023 #include "transform.h"
00024 #include "quant.h"
00025 #include "memalloc.h"
00026
00033 void itrans4x4(Macroblock *currMB,
00034 ColorPlane pl,
00035 int ioff,
00036 int joff)
00037 {
00038 int i,j;
00039
00040 Slice *currSlice = currMB->p_Slice;
00041 ImageParameters *p_Img = currMB->p_Img;
00042 int max_imgpel_value = p_Img->max_imgpel_value_comp[pl];
00043
00044 imgpel **mb_pred = currSlice->mb_pred[pl];
00045 imgpel **mb_rec = currSlice->mb_rec[pl];
00046 int **mb_rres = currSlice->mb_rres[pl];
00047
00048 inverse4x4(currSlice->cof[pl],mb_rres,joff,ioff);
00049
00050 for (j = joff; j < joff + BLOCK_SIZE; ++j)
00051 {
00052 for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
00053 {
00054 mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, mb_pred[j][i] + rshift_rnd_sf(mb_rres[j][i], DQ_BITS));
00055 }
00056 }
00057 }
00058
00065 void itrans4x4_ls(Macroblock *currMB,
00066 ColorPlane pl,
00067 int ioff,
00068 int joff)
00069 {
00070 int i,j;
00071
00072 Slice *currSlice = currMB->p_Slice;
00073 ImageParameters *p_Img = currMB->p_Img;
00074 int max_imgpel_value = p_Img->max_imgpel_value_comp[pl];
00075
00076 imgpel **mb_pred = currSlice->mb_pred[pl];
00077 imgpel **mb_rec = currSlice->mb_rec[pl];
00078 int **mb_rres = currSlice->mb_rres [pl];
00079
00080 inverse4x4(currSlice->cof[pl],mb_rres,joff,ioff);
00081
00082 for (j = joff; j < joff + BLOCK_SIZE; ++j)
00083 {
00084 for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
00085 {
00086
00087 mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, mb_pred[j][i] + rshift_rnd_sf(mb_rres[j][i], DQ_BITS));
00088 }
00089 }
00090 }
00091
00099 void Inv_Residual_trans_4x4(Macroblock *currMB,
00100 ColorPlane pl,
00101 int ioff,
00102 int joff)
00103 {
00104 int i,j;
00105 int temp[4][4];
00106 Slice *currSlice = currMB->p_Slice;
00107 ImageParameters *p_Img = currMB->p_Img;
00108 imgpel **mb_pred = currSlice->mb_pred[pl];
00109 imgpel **mb_rec = currSlice->mb_rec[pl];
00110 int **mb_rres = currSlice->mb_rres[pl];
00111 int **cof = currSlice->cof[pl];
00112
00113 if(p_Img->ipmode_DPCM == VERT_PRED)
00114 {
00115 for(i=0; i<4; ++i)
00116 {
00117 temp[0][i] = cof[joff + 0][ioff + i];
00118 temp[1][i] = cof[joff + 1][ioff + i] + temp[0][i];
00119 temp[2][i] = cof[joff + 2][ioff + i] + temp[1][i];
00120 temp[3][i] = cof[joff + 3][ioff + i] + temp[2][i];
00121 }
00122
00123 for(i=0; i<4; ++i)
00124 {
00125 mb_rres[joff ][ioff + i]=temp[0][i];
00126 mb_rres[joff + 1][ioff + i]=temp[1][i];
00127 mb_rres[joff + 2][ioff + i]=temp[2][i];
00128 mb_rres[joff + 3][ioff + i]=temp[3][i];
00129 }
00130 }
00131 else if(p_Img->ipmode_DPCM==HOR_PRED)
00132 {
00133 for(j=0; j<4; ++j)
00134 {
00135 temp[j][0] = cof[joff + j][ioff ];
00136 temp[j][1] = cof[joff + j][ioff + 1] + temp[j][0];
00137 temp[j][2] = cof[joff + j][ioff + 2] + temp[j][1];
00138 temp[j][3] = cof[joff + j][ioff + 3] + temp[j][2];
00139 }
00140
00141 for(j=0; j<4; ++j)
00142 {
00143 mb_rres[joff + j][ioff ]=temp[j][0];
00144 mb_rres[joff + j][ioff + 1]=temp[j][1];
00145 mb_rres[joff + j][ioff + 2]=temp[j][2];
00146 mb_rres[joff + j][ioff + 3]=temp[j][3];
00147 }
00148 }
00149 else
00150 {
00151 for (j = joff; j < joff + BLOCK_SIZE; ++j)
00152 for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
00153 mb_rres[j][i] = cof[j][i];
00154 }
00155
00156 for (j = joff; j < joff + BLOCK_SIZE; ++j)
00157 {
00158 for (i = ioff; i < ioff + BLOCK_SIZE; ++i)
00159 {
00160 mb_rec[j][i] = (imgpel) (mb_rres[j][i] + mb_pred[j][i]);
00161 }
00162 }
00163 }
00164
00174
00175 void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff)
00176 {
00177 Slice *currSlice = currMB->p_Slice;
00178 ImageParameters *p_Img = currMB->p_Img;
00179 int i, j;
00180 int temp[8][8];
00181 imgpel **mb_pred = currSlice->mb_pred[pl];
00182 imgpel **mb_rec = currSlice->mb_rec[pl];
00183 int **mb_rres = currSlice->mb_rres[pl];
00184
00185 if(p_Img->ipmode_DPCM == VERT_PRED)
00186 {
00187 for(i=0; i<8; ++i)
00188 {
00189 temp[0][i] = mb_rres[joff + 0][ioff + i];
00190 temp[1][i] = mb_rres[joff + 1][ioff + i] + temp[0][i];
00191 temp[2][i] = mb_rres[joff + 2][ioff + i] + temp[1][i];
00192 temp[3][i] = mb_rres[joff + 3][ioff + i] + temp[2][i];
00193 temp[4][i] = mb_rres[joff + 4][ioff + i] + temp[3][i];
00194 temp[5][i] = mb_rres[joff + 5][ioff + i] + temp[4][i];
00195 temp[6][i] = mb_rres[joff + 6][ioff + i] + temp[5][i];
00196 temp[7][i] = mb_rres[joff + 7][ioff + i] + temp[6][i];
00197 }
00198 for(i=0; i<8; ++i)
00199 {
00200 mb_rres[joff ][ioff+i]=temp[0][i];
00201 mb_rres[joff+1][ioff+i]=temp[1][i];
00202 mb_rres[joff+2][ioff+i]=temp[2][i];
00203 mb_rres[joff+3][ioff+i]=temp[3][i];
00204 mb_rres[joff+4][ioff+i]=temp[4][i];
00205 mb_rres[joff+5][ioff+i]=temp[5][i];
00206 mb_rres[joff+6][ioff+i]=temp[6][i];
00207 mb_rres[joff+7][ioff+i]=temp[7][i];
00208 }
00209 }
00210 else if(p_Img->ipmode_DPCM == HOR_PRED)
00211 {
00212 for(i=0; i<8; ++i)
00213 {
00214 temp[i][0] = mb_rres[joff + i][ioff + 0];
00215 temp[i][1] = mb_rres[joff + i][ioff + 1] + temp[i][0];
00216 temp[i][2] = mb_rres[joff + i][ioff + 2] + temp[i][1];
00217 temp[i][3] = mb_rres[joff + i][ioff + 3] + temp[i][2];
00218 temp[i][4] = mb_rres[joff + i][ioff + 4] + temp[i][3];
00219 temp[i][5] = mb_rres[joff + i][ioff + 5] + temp[i][4];
00220 temp[i][6] = mb_rres[joff + i][ioff + 6] + temp[i][5];
00221 temp[i][7] = mb_rres[joff + i][ioff + 7] + temp[i][6];
00222 }
00223 for(i=0; i<8; ++i)
00224 {
00225 mb_rres[joff+i][ioff+0]=temp[i][0];
00226 mb_rres[joff+i][ioff+1]=temp[i][1];
00227 mb_rres[joff+i][ioff+2]=temp[i][2];
00228 mb_rres[joff+i][ioff+3]=temp[i][3];
00229 mb_rres[joff+i][ioff+4]=temp[i][4];
00230 mb_rres[joff+i][ioff+5]=temp[i][5];
00231 mb_rres[joff+i][ioff+6]=temp[i][6];
00232 mb_rres[joff+i][ioff+7]=temp[i][7];
00233 }
00234 }
00235
00236 for (j = joff; j < joff + BLOCK_SIZE*2; ++j)
00237 {
00238 for (i = ioff; i < ioff + BLOCK_SIZE*2; ++i)
00239 {
00240 mb_rec [j][i] = (imgpel) (mb_rres[j][i] + mb_pred[j][i]);
00241 }
00242 }
00243 }
00244
00251 void itrans_2(Macroblock *currMB,
00252 ColorPlane pl)
00253 {
00254 Slice *currSlice = currMB->p_Slice;
00255 ImageParameters *p_Img = currMB->p_Img;
00256 int i,j;
00257
00258 int transform_pl = IS_INDEPENDENT(p_Img) ? PLANE_Y : pl;
00259 int **cof = currSlice->cof[transform_pl];
00260 int qp_scaled = currMB->qp_scaled[pl];
00261
00262 int qp_per = p_Img->qp_per_matrix[ qp_scaled ];
00263 int qp_rem = p_Img->qp_rem_matrix[ qp_scaled ];
00264
00265 int invLevelScale = currSlice->InvLevelScale4x4_Intra[pl][qp_rem][0][0];
00266 int **M4;
00267 get_mem2Dint(&M4, BLOCK_SIZE, BLOCK_SIZE);
00268
00269
00270 for (j=0; j < 4;++j)
00271 {
00272 for (i=0; i < 4;++i)
00273 {
00274 M4[j][i]=cof[j<<2][i<<2];
00275 }
00276 }
00277
00278 ihadamard4x4(M4, M4);
00279
00280
00281 for (j=0; j < 4;++j)
00282 {
00283 for (i=0; i < 4;++i)
00284 {
00285 cof[j<<2][i<<2] = rshift_rnd((( M4[j][i] * invLevelScale) << qp_per), 6);
00286 }
00287 }
00288
00289 free_mem2Dint(M4);
00290 }
00291
00292
00293 void itrans_sp(Macroblock *currMB,
00294 ColorPlane pl,
00295 int ioff,
00296 int joff)
00297 {
00298 ImageParameters *p_Img = currMB->p_Img;
00299 Slice *currSlice = currMB->p_Slice;
00300 int i,j;
00301 int ilev, icof;
00302
00303 int qp = (currSlice->slice_type == SI_SLICE) ? currSlice->qs : p_Img->qp;
00304 int qp_per = p_Img->qp_per_matrix[ qp ];
00305 int qp_rem = p_Img->qp_rem_matrix[ qp ];
00306
00307 int qp_per_sp = p_Img->qp_per_matrix[ currSlice->qs ];
00308 int qp_rem_sp = p_Img->qp_rem_matrix[ currSlice->qs ];
00309 int q_bits_sp = Q_BITS + qp_per_sp;
00310
00311 imgpel **mb_pred = currSlice->mb_pred[pl];
00312 imgpel **mb_rec = currSlice->mb_rec[pl];
00313 int **mb_rres = currSlice->mb_rres[pl];
00314 int **cof = currSlice->cof[pl];
00315 int max_imgpel_value = p_Img->max_imgpel_value_comp[pl];
00316
00317 const int (*InvLevelScale4x4) [4] = dequant_coef[qp_rem];
00318 const int (*InvLevelScale4x4SP)[4] = dequant_coef[qp_rem_sp];
00319 int **PBlock;
00320
00321 get_mem2Dint(&PBlock, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00322
00323 for (j=0; j< BLOCK_SIZE; ++j)
00324 for (i=0; i< BLOCK_SIZE; ++i)
00325 PBlock[j][i] = mb_pred[j+joff][i+ioff];
00326
00327 forward4x4(PBlock, PBlock, 0, 0);
00328
00329 if(p_Img->sp_switch || currSlice->slice_type==SI_SLICE)
00330 {
00331 for (j=0;j<BLOCK_SIZE;++j)
00332 {
00333 for (i=0;i<BLOCK_SIZE;++i)
00334 {
00335
00336 icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
00337
00338
00339 ilev = rshift_rnd_sf(iabs(PBlock[j][i]) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
00340 ilev = isignab(ilev, PBlock[j][i]) + icof;
00341 cof[joff + j][ioff + i] = ilev * InvLevelScale4x4SP[j][i] << qp_per_sp;
00342 }
00343 }
00344 }
00345 else
00346 {
00347 for (j=0;j<BLOCK_SIZE;++j)
00348 {
00349 for (i=0;i<BLOCK_SIZE;++i)
00350 {
00351
00352 icof = (cof[joff + j][ioff + i] >> qp_per) / InvLevelScale4x4[j][i];
00353
00354
00355 ilev = PBlock[j][i] + ((icof * InvLevelScale4x4[j][i] * A[j][i] << qp_per) >> 6);
00356 ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
00357
00358 cof[joff + j][ioff + i] = ilev * dequant_coef[qp_rem_sp][j][i] << qp_per_sp;
00359 }
00360 }
00361 }
00362
00363 inverse4x4(cof, mb_rres, joff, ioff);
00364
00365 for (j=joff; j<joff +BLOCK_SIZE;++j)
00366 {
00367 for (i=ioff; i < ioff + BLOCK_SIZE;++i)
00368 {
00369 mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value,rshift_rnd_sf(mb_rres[j][i], DQ_BITS));
00370 }
00371 }
00372
00373 free_mem2Dint(PBlock);
00374 }
00375
00376
00377 void itrans_sp_cr(Macroblock *currMB, int uv)
00378 {
00379 Slice *currSlice = currMB->p_Slice;
00380 ImageParameters *p_Img = currMB->p_Img;
00381 int i,j,ilev, icof, n2,n1;
00382 int mp1[BLOCK_SIZE];
00383 int qp_per,qp_rem;
00384 int qp_per_sp,qp_rem_sp,q_bits_sp;
00385 imgpel **mb_pred = currSlice->mb_pred[uv + 1];
00386 int **cof = currSlice->cof[uv + 1];
00387 int **PBlock;
00388
00389 get_mem2Dint(&PBlock, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00390
00391
00392 qp_per = p_Img->qp_per_matrix[ ((p_Img->qp < 0 ? p_Img->qp : QP_SCALE_CR[p_Img->qp]))];
00393 qp_rem = p_Img->qp_rem_matrix[ ((p_Img->qp < 0 ? p_Img->qp : QP_SCALE_CR[p_Img->qp]))];
00394
00395 qp_per_sp = p_Img->qp_per_matrix[ ((currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
00396 qp_rem_sp = p_Img->qp_rem_matrix[ ((currSlice->qs < 0 ? currSlice->qs : QP_SCALE_CR[currSlice->qs]))];
00397 q_bits_sp = Q_BITS + qp_per_sp;
00398
00399 if (currSlice->slice_type == SI_SLICE)
00400 {
00401 qp_per = qp_per_sp;
00402 qp_rem = qp_rem_sp;
00403 }
00404
00405 for (j=0; j < p_Img->mb_cr_size_y; ++j)
00406 {
00407 for (i=0; i < p_Img->mb_cr_size_x; ++i)
00408 {
00409 PBlock[j][i] = mb_pred[j][i];
00410 mb_pred[j][i] = 0;
00411 }
00412 }
00413
00414 for (n2=0; n2 < p_Img->mb_cr_size_y; n2 += BLOCK_SIZE)
00415 {
00416 for (n1=0; n1 < p_Img->mb_cr_size_x; n1 += BLOCK_SIZE)
00417 {
00418 forward4x4(PBlock, PBlock, n2, n1);
00419 }
00420 }
00421
00422
00423 mp1[0] = (PBlock[0][0] + PBlock[4][0] + PBlock[0][4] + PBlock[4][4]);
00424 mp1[1] = (PBlock[0][0] - PBlock[4][0] + PBlock[0][4] - PBlock[4][4]);
00425 mp1[2] = (PBlock[0][0] + PBlock[4][0] - PBlock[0][4] - PBlock[4][4]);
00426 mp1[3] = (PBlock[0][0] - PBlock[4][0] - PBlock[0][4] + PBlock[4][4]);
00427
00428 if (p_Img->sp_switch || currSlice->slice_type == SI_SLICE)
00429 {
00430 for (n2=0; n2 < 2; ++n2 )
00431 {
00432 for (n1=0; n1 < 2; ++n1 )
00433 {
00434
00435 ilev = rshift_rnd_sf(iabs (mp1[n1+n2*2]) * quant_coef[qp_rem_sp][0][0], q_bits_sp + 1);
00436
00437 ilev = isignab(ilev, mp1[n1+n2*2]) + cof[n2<<2][n1<<2];
00438
00439 mp1[n1+n2*2] =ilev * dequant_coef[qp_rem_sp][0][0] << qp_per_sp;
00440 }
00441 }
00442
00443 for (n2 = 0; n2 < p_Img->mb_cr_size_y; n2 += BLOCK_SIZE)
00444 {
00445 for (n1 = 0; n1 < p_Img->mb_cr_size_x; n1 += BLOCK_SIZE)
00446 {
00447 for (j = 0; j < BLOCK_SIZE; ++j)
00448 {
00449 for (i = 0; i < BLOCK_SIZE; ++i)
00450 {
00451
00452 cof[n2 + j][n1 + i] = (cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
00453
00454
00455 ilev = rshift_rnd_sf(iabs(PBlock[n2 + j][n1 + i]) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
00456
00457 ilev = isignab(ilev,PBlock[n2 + j][n1 + i]) + cof[n2 + j][n1 + i];
00458
00459 cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i] << qp_per_sp;
00460 }
00461 }
00462 }
00463 }
00464 }
00465 else
00466 {
00467 for (n2=0; n2 < 2; ++n2 )
00468 {
00469 for (n1=0; n1 < 2; ++n1 )
00470 {
00471 ilev = mp1[n1+n2*2] + (((cof[n2<<2][n1<<2] * dequant_coef[qp_rem][0][0] * A[0][0]) << qp_per) >> 5);
00472 ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][0][0], q_bits_sp + 1);
00473
00474 mp1[n1+n2*2] = ilev * dequant_coef[qp_rem_sp][0][0] << qp_per_sp;
00475 }
00476 }
00477
00478 for (n2 = 0; n2 < p_Img->mb_cr_size_y; n2 += BLOCK_SIZE)
00479 {
00480 for (n1 = 0; n1 < p_Img->mb_cr_size_x; n1 += BLOCK_SIZE)
00481 {
00482 for (j = 0; j< BLOCK_SIZE; ++j)
00483 {
00484 for (i = 0; i< BLOCK_SIZE; ++i)
00485 {
00486
00487
00488 icof = (cof[n2 + j][n1 + i] >> qp_per) / dequant_coef[qp_rem][j][i];
00489
00490 ilev = PBlock[n2 + j][n1 + i] + ((icof * dequant_coef[qp_rem][j][i] * A[j][i] << qp_per) >> 6);
00491
00492 ilev = isign(ilev) * rshift_rnd_sf(iabs(ilev) * quant_coef[qp_rem_sp][j][i], q_bits_sp);
00493 cof[n2 + j][n1 + i] = ilev * dequant_coef[qp_rem_sp][j][i] << qp_per_sp;
00494
00495 }
00496 }
00497 }
00498 }
00499 }
00500
00501 cof[0][0] = (mp1[0] + mp1[1] + mp1[2] + mp1[3]) >> 1;
00502 cof[0][4] = (mp1[0] + mp1[1] - mp1[2] - mp1[3]) >> 1;
00503 cof[4][0] = (mp1[0] - mp1[1] + mp1[2] - mp1[3]) >> 1;
00504 cof[4][4] = (mp1[0] - mp1[1] - mp1[2] + mp1[3]) >> 1;
00505
00506 free_mem2Dint(PBlock);
00507 }
00508
00509 void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb)
00510 {
00511 Slice *currSlice = currMB->p_Slice;
00512 ImageParameters *p_Img = currMB->p_Img;
00513
00514 StorablePicture *dec_picture = p_Img->dec_picture;
00515 int jj, ii;
00516 int block8x8;
00517 int k;
00518
00519 imgpel **curr_img = pl ? dec_picture->imgUV[pl - 1]: dec_picture->imgY;
00520
00521
00522
00523
00524 currMB->itrans_4x4 = (smb) ? itrans_sp : ((currMB->is_lossless == FALSE) ? itrans4x4 : Inv_Residual_trans_4x4);
00525
00526 for (block8x8=0; block8x8 < MB_BLOCK_SIZE; block8x8 += 4)
00527 {
00528 for (k = block8x8; k < block8x8 + 4; ++k )
00529 {
00530 jj = ((decode_block_scan[k] >> 2) & 3) << BLOCK_SHIFT;
00531 ii = (decode_block_scan[k] & 3) << BLOCK_SHIFT;
00532
00533 currMB->itrans_4x4(currMB, pl, ii, jj);
00534 }
00535 }
00536
00537
00538 copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_rec[pl], currMB->pix_x, 0);
00539 }
00540
00541 void iMBtrans8x8(Macroblock *currMB, ColorPlane pl)
00542 {
00543 Slice *currSlice = currMB->p_Slice;
00544 ImageParameters *p_Img = currMB->p_Img;
00545 StorablePicture *dec_picture = p_Img->dec_picture;
00546 imgpel **curr_img = pl ? dec_picture->imgUV[pl - 1]: dec_picture->imgY;
00547
00548 int block8x8;
00549 int ioff, joff;
00550
00551 for (block8x8=0; block8x8<4; ++block8x8)
00552 {
00553
00554
00555 ioff = 8 * (block8x8 & 0x01);
00556 joff = 8 * (block8x8 >> 1);
00557
00558 itrans8x8(currMB, pl, ioff, joff);
00559 }
00560
00561 copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_rec[pl], currMB->pix_x, 0);
00562 }
00563
00564 void iTransform(Macroblock *currMB, ColorPlane pl, int need_4x4_transform, int smb)
00565 {
00566 Slice *currSlice = currMB->p_Slice;
00567 ImageParameters *p_Img = currMB->p_Img;
00568 StorablePicture *dec_picture = p_Img->dec_picture;
00569 imgpel **curr_img;
00570 int uv = pl-1;
00571
00572 if ((currMB->cbp & 15) != 0 || smb)
00573 {
00574 if(need_4x4_transform)
00575 {
00576 iMBtrans4x4(currMB, pl, smb);
00577 }
00578 else
00579 {
00580 iMBtrans8x8(currMB, pl);
00581 }
00582 }
00583 else
00584 {
00585 curr_img = pl ? dec_picture->imgUV[uv] : dec_picture->imgY;
00586 copy_image_data_16x16(&curr_img[currMB->pix_y], currSlice->mb_pred[pl], currMB->pix_x, 0);
00587 }
00588
00589 if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
00590 {
00591 imgpel **curUV;
00592 int b4, b8;
00593 int ioff, joff;
00594 imgpel **mb_rec;
00595
00596 for(uv=0;uv<2;++uv)
00597 {
00598 currMB->itrans_4x4 = (currMB->is_lossless == FALSE) ? itrans4x4 : itrans4x4_ls;
00599
00600
00601
00602 curUV = &dec_picture->imgUV[uv][currMB->pix_c_y];
00603 mb_rec = currSlice->mb_rec[uv+1];
00604
00605 if (!smb && (currMB->cbp>>4))
00606 {
00607 for (b8 = 0; b8 < (p_Img->num_uv_blocks); ++b8)
00608 {
00609 for(b4 = 0; b4 < 4; ++b4)
00610 {
00611 joff = subblk_offset_y[1][b8][b4];
00612 ioff = subblk_offset_x[1][b8][b4];
00613
00614 currMB->itrans_4x4(currMB, (ColorPlane) (uv + 1), ioff, joff);
00615 }
00616 }
00617
00618 copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Img->mb_size[1][0], p_Img->mb_size[1][1]);
00619 }
00620 else if (smb)
00621 {
00622 itrans_sp_cr(currMB, uv);
00623
00624 for (joff = 0; joff < p_Img->mb_cr_size_y; joff += BLOCK_SIZE)
00625 {
00626 for(ioff = 0; ioff < p_Img->mb_cr_size_x ;ioff += BLOCK_SIZE)
00627 {
00628 currMB->itrans_4x4(currMB, (ColorPlane) (uv + 1), ioff, joff);
00629 }
00630 }
00631
00632 copy_image_data(curUV, mb_rec, currMB->pix_c_x, 0, p_Img->mb_size[1][0], p_Img->mb_size[1][1]);
00633 }
00634 else
00635 {
00636 copy_image_data(curUV, currSlice->mb_pred[uv + 1], currMB->pix_c_x, 0, p_Img->mb_size[1][0], p_Img->mb_size[1][1]);
00637 }
00638 }
00639 }
00640 }
00641
00648 void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00649 {
00650 int j;
00651 for(j=0; j<MB_BLOCK_SIZE; ++j)
00652 {
00653 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], MB_BLOCK_SIZE * sizeof (imgpel));
00654 }
00655 }
00656
00663 void copy_image_data_8x8(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00664 {
00665 int j;
00666 for(j = 0; j < BLOCK_SIZE_8x8; ++j)
00667 {
00668 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], BLOCK_SIZE_8x8 * sizeof (imgpel));
00669 }
00670 }
00671
00672
00679 void copy_image_data_4x4(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00680 {
00681 int j;
00682 for(j = 0; j < BLOCK_SIZE; ++j)
00683 {
00684 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], BLOCK_SIZE * sizeof (imgpel));
00685 }
00686 }
00687
00694 void copy_image_data(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2, int width, int height)
00695 {
00696 int j;
00697 for(j = 0; j < height; ++j)
00698 {
00699 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], width * sizeof (imgpel));
00700 }
00701 }