/*! *********************************************************************** * \brief * Inverse 8x8 transformation *********************************************************************** */ void itrans8x8(Macroblock *currMB, //!< current macroblock ColorPlane pl, //!< used color plane int ioff, //!< index to 4x4 block int joff) //!< index to 4x4 block { ImageParameters *p_Img = currMB->p_Img; Slice *currSlice = currMB->p_Slice; int i,j; imgpel **mpr = currSlice->mb_pred[pl]; imgpel **mb_rec = currSlice->mb_rec[pl]; int **m7 = currSlice->mb_rres[pl]; int max_imgpel_value = p_Img->max_imgpel_value_comp[pl]; if (currMB->is_lossless == TRUE) { for( j = joff; j < joff + 8; j++) { for( i = ioff; i < ioff + 8; i++) mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, (m7[j][i] + (long)mpr[j][i])); } } else { inverse8x8(m7, m7, joff, ioff); for( j = joff; j < joff + 8; j++) { for( i = ioff; i < ioff + 8; i++) //mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, rshift_rnd_sf((m7[j][i] + ((long)mpr[j][i] << DQ_BITS_8)), DQ_BITS_8)); mb_rec[j][i] = (imgpel) iClip1(max_imgpel_value, mpr[j][i] + rshift_rnd_sf(m7[j][i], DQ_BITS_8)); } } }
/*! ************************************************************************ * \brief * The routine performs transform,quantization,inverse transform, adds the diff. * to the prediction and writes the result to the decoded luma frame. Includes the * RD constrained quantization also. Used for CAVLC. * * \par Input: * b8: Block position inside a macro block (0,1,2,3). * * \par Output: * nonzero: 0 if no levels are nonzero. 1 if there are nonzero levels. * coeff_cost: Counter for nonzero coefficients, used to discard expensive levels. ************************************************************************ */ int residual_transform_quant_luma_8x8_cavlc(Macroblock *currMB, ColorPlane pl, int b8, int *coeff_cost, int intra) { VideoParameters *p_Vid = currMB->p_Vid; int nonzero = FALSE; int block_x = 8*(b8 & 0x01); int block_y = 8*(b8 >> 1); int pl_off = b8+ (pl<<2); imgpel **img_enc = p_Vid->enc_picture->p_curr_img; Slice *currSlice = currMB->p_Slice; imgpel **mb_pred = currSlice->mb_pred[pl]; int **mb_ores = currSlice->mb_ores[pl]; int **mb_rres = currSlice->mb_rres[pl]; int max_imgpel_value = p_Vid->max_imgpel_value; int qp = currMB->qp_scaled[pl]; //if (check_zero(&mb_ores[block_y], block_x) != 0) { // Variable p_Quant and some of its parameters could be all set outside // to speed up the code (e.g. field mode, coeff_cost, etc). QuantParameters *p_Quant = p_Vid->p_Quant; QuantMethods quant_methods; quant_methods.block_x = block_x; quant_methods.block_y = block_y; quant_methods.qp = qp; quant_methods.q_params = p_Quant->q_params_8x8[pl][intra][qp]; quant_methods.fadjust = p_Vid->AdaptiveRounding ? (&p_Vid->ARCofAdj8x8[pl][currMB->ar_mode][block_y]) : NULL; quant_methods.coeff_cost = coeff_cost; // quant_methods.pos_scan = currMB->is_field_mode ? FIELD_SCAN8x8 : SNGL_SCAN8x8; quant_methods.pos_scan = currMB->is_field_mode ? FIELD_SCAN8x8_CAVLC : SNGL_SCAN8x8_CAVLC; quant_methods.c_cost = COEFF_COST8x8[currSlice->disthres]; // Forward 8x8 transform forward8x8(mb_ores, mb_rres, block_y, block_x); // Quantization process nonzero = currSlice->quant_8x8cavlc(currMB, &mb_rres[block_y], &quant_methods, currSlice->cofAC[pl_off]); } if (nonzero) { // Inverse 8x8 transform inverse8x8(&mb_rres[block_y], &mb_rres[block_y], block_x); // generate final block sample_reconstruct (&img_enc[currMB->pix_y + block_y], &mb_pred[block_y], &mb_rres[block_y], block_x, currMB->pix_x + block_x, BLOCK_SIZE_8x8, BLOCK_SIZE_8x8, max_imgpel_value, DQ_BITS_8); } else // if (nonzero) => No transformed residual. Just use prediction. { copy_image_data_8x8(&img_enc[currMB->pix_y + block_y], &mb_pred[block_y], currMB->pix_x + block_x, block_x); } // Decoded block moved to frame memory return nonzero; }
/*! *********************************************************************** * \brief * Inverse 8x8 transformation *********************************************************************** */ void itrans8x8(Macroblock *currMB, //!< current macroblock ColorPlane pl, //!< used color plane int ioff, //!< index to 4x4 block int joff) //!< index to 4x4 block { Slice *currSlice = currMB->p_Slice; int **m7 = currSlice->mb_rres[pl]; if (currMB->is_lossless == TRUE) { recon8x8_lossless(&m7[joff], &currSlice->mb_rec[pl][joff], &currSlice->mb_pred[pl][joff], currMB->p_Vid->max_pel_value_comp[pl], ioff); } else { inverse8x8(m7, m7, joff, ioff); recon8x8 (&m7[joff], &currSlice->mb_rec[pl][joff], &currSlice->mb_pred[pl][joff], currMB->p_Vid->max_pel_value_comp[pl], ioff); } }