macroblock.c
资源名称:chapter15.rar [点击查看]
上传用户:hjq518
上传日期:2021-12-09
资源大小:5084k
文件大小:173k
源码类别:
Audio
开发平台:
Visual C++
- int level = 1;
- int cbp = currMB->cbp;
- SyntaxElement currSE;
- Slice *currSlice = img->currentSlice;
- DataPartition *dP;
- int *partMap = assignSE2partition[currSlice->dp_mode];
- int boff_x, boff_y;
- int qp_per, qp_rem;
- int uv = pl - 1;
- int64 cbp_mask = (int64) 51 << (4 * b8 - 2 * (b8 & 0x01)); // corresponds to 110011, as if all four 4x4 blocks contain coeff, shifted to block position
- int64 *cur_cbp;
- Boolean lossless_qpprime = (Boolean) ((img->qp + img->bitdepth_luma_qp_scale)==0 && img->lossless_qpprime_flag==1);
- int (*InvLevelScale8x8)[8] = NULL;
- // select scan type
- const byte (*pos_scan8x8) = ((img->structure == FRAME) && (!currMB->mb_field)) ? SNGL_SCAN8x8[0] : FIELD_SCAN8x8[0];
- if (cbp & (1<<b8)) // are there any coefficients in the current block
- {
- if (pl)
- {
- qp_per = qp_per_matrix[ currMB->qp_scaled[pl] ];
- qp_rem = qp_rem_matrix[ currMB->qp_scaled[pl] ];
- cur_cbp = &currMB->cbp_blk;
- }
- else
- {
- qp_per = qp_per_matrix[ currMB->qp_scaled[pl] ];
- qp_rem = qp_rem_matrix[ currMB->qp_scaled[pl] ];
- cur_cbp = &currMB->cbp_blk_CbCr[uv];
- }
- InvLevelScale8x8 = IS_INTRA(currMB)? InvLevelScale8x8_Intra[pl][qp_rem] : InvLevelScale8x8_Inter[pl][qp_rem];
- img->is_intra_block = IS_INTRA(currMB);
- // === set offset in current macroblock ===
- boff_x = (b8&0x01) << 3;
- boff_y = (b8 >> 1) << 3;
- tcoeffs = &img->mb_rres[pl][boff_y];
- img->subblock_x = boff_x >> 2; // position for coeff_count ctx
- img->subblock_y = boff_y >> 2; // position for coeff_count ctx
- if (pl==PLANE_Y || IS_INDEPENDENT(img))
- currSE.context = LUMA_8x8;
- else if (pl==PLANE_U)
- currSE.context = CB_8x8;
- else
- currSE.context = CR_8x8;
- currSE.reading = readRunLevel_CABAC;
- if(!lossless_qpprime)
- {
- // Read DC
- currSE.type = ((img->is_intra_block == 1) ? SE_LUM_DC_INTRA : SE_LUM_DC_INTER ); // Intra or Inter?
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- #if TRACE
- if (pl==PLANE_Y)
- sprintf(currSE.tracestring, "Luma8x8 DC sng ");
- else if (pl==PLANE_U)
- sprintf(currSE.tracestring, "Cb 8x8 DC sng ");
- else
- sprintf(currSE.tracestring, "Cr 8x8 DC sng ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //============ decode =============
- if (level != 0) /* leave if len=1 */
- {
- *cur_cbp |= cbp_mask;
- pos_scan8x8 += 2 * (currSE.value2);
- i = *pos_scan8x8++;
- j = *pos_scan8x8++;
- tcoeffs[j][boff_x + i] = rshift_rnd_sf((level * InvLevelScale8x8[j][i]) << qp_per, 6); // dequantization
- // AC coefficients
- currSE.type = ((img->is_intra_block == 1) ? SE_LUM_AC_INTRA : SE_LUM_AC_INTER);
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- for(k = 1;(k < 65) && (level != 0);k++)
- {
- #if TRACE
- if (pl==PLANE_Y)
- sprintf(currSE.tracestring, "Luma8x8 sng ");
- else if (pl==PLANE_U)
- sprintf(currSE.tracestring, "Cb 8x8 sng ");
- else
- sprintf(currSE.tracestring, "Cr 8x8 sng ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //============ decode =============
- if (level != 0) /* leave if len=1 */
- {
- pos_scan8x8 += 2 * (currSE.value2);
- i = *pos_scan8x8++;
- j = *pos_scan8x8++;
- tcoeffs[ j][boff_x + i] = rshift_rnd_sf((level * InvLevelScale8x8[j][i]) << qp_per, 6); // dequantization
- }
- }
- }
- }
- else
- {
- for(k=0; (k < 65) && (level != 0);k++)
- {
- //============ read =============
- /*
- * make distinction between INTRA and INTER coded
- * luminance coefficients
- */
- currSE.type = ((img->is_intra_block == 1)
- ? (k==0 ? SE_LUM_DC_INTRA : SE_LUM_AC_INTRA)
- : (k==0 ? SE_LUM_DC_INTER : SE_LUM_AC_INTER));
- #if TRACE
- if (pl==PLANE_Y)
- sprintf(currSE.tracestring, "Luma8x8 sng ");
- else if (pl==PLANE_U)
- sprintf(currSE.tracestring, "Cb 8x8 sng ");
- else
- sprintf(currSE.tracestring, "Cr 8x8 sng ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //============ decode =============
- if (level != 0) /* leave if len=1 */
- {
- pos_scan8x8 += 2 * (currSE.value2);
- i = *pos_scan8x8++;
- j = *pos_scan8x8++;
- *cur_cbp |= cbp_mask;
- tcoeffs[j][boff_x + i] = level;
- }
- }
- }
- }
- }
- /*!
- ************************************************************************
- * brief
- * Data partitioning: Check if neighboring macroblock is needed for
- * CAVLC context decoding, and disable current MB if data partition
- * is missing.
- ************************************************************************
- */
- static void check_dp_neighbors (Macroblock *currMB)
- {
- PixelPos up, left;
- getNeighbour(currMB, -1, 0, img->mb_size[1], &left);
- getNeighbour(currMB, 0, -1, img->mb_size[1], &up);
- if (IS_INTER (currMB) || (IS_INTRA (currMB) && !(active_pps->constrained_intra_pred_flag)) )
- {
- if (left.available)
- {
- currMB->dpl_flag |= img->mb_data[left.mb_addr].dpl_flag;
- }
- if (up.available)
- {
- currMB->dpl_flag |= img->mb_data[up.mb_addr].dpl_flag;
- }
- }
- }
- /*!
- ************************************************************************
- * brief
- * Get coded block pattern and coefficients (run/level)
- * from the NAL
- ************************************************************************
- */
- static void readCBPandCoeffsFromNAL(ImageParameters *img, Macroblock *currMB)
- {
- int i,j,k;
- int level;
- int mb_nr = img->current_mb_nr;
- int ii,jj;
- int cbp;
- SyntaxElement currSE;
- Slice *currSlice = img->currentSlice;
- DataPartition *dP = NULL;
- int *partMap = assignSE2partition[currSlice->dp_mode];
- int coef_ctr, i0, j0, b8;
- int ll;
- int block_x,block_y;
- int start_scan;
- int levarr[16], runarr[16], numcoeff;
- int qp_per = qp_per_matrix[ (img->qp + img->bitdepth_luma_qp_scale) ];
- int qp_rem = qp_rem_matrix[ (img->qp + img->bitdepth_luma_qp_scale) ];
- int smb = ((img->type==SP_SLICE) && IS_INTER (currMB)) || (img->type == SI_SLICE && currMB->mb_type == SI4MB);
- int uv;
- int qp_per_uv[2];
- int qp_rem_uv[2];
- int intra = IS_INTRA (currMB);
- int temp[4];
- int b4;
- int yuv = dec_picture->chroma_format_idc - 1;
- int m6[4];
- int need_transform_size_flag;
- Boolean lossless_qpprime = (Boolean) ((img->qp + img->bitdepth_luma_qp_scale)==0 && img->lossless_qpprime_flag==1);
- int (*InvLevelScale4x4)[4] = NULL;
- int (*InvLevelScale8x8)[8] = NULL;
- // select scan type
- const byte (*pos_scan8x8)[2] = ((img->structure == FRAME) && (!currMB->mb_field)) ? SNGL_SCAN8x8 : FIELD_SCAN8x8;
- const byte (*pos_scan4x4)[2] = ((img->structure == FRAME) && (!currMB->mb_field)) ? SNGL_SCAN : FIELD_SCAN;
- const byte *pos_scan_4x4 = ((img->structure == FRAME) && (!currMB->mb_field)) ? SNGL_SCAN[0] : FIELD_SCAN[0];
- if(img->type==SP_SLICE && currMB->mb_type!=I16MB )
- smb=1;
- // QPI
- //init constants for every chroma qp offset
- if (dec_picture->chroma_format_idc != YUV400)
- {
- for (i=0; i<2; i++)
- {
- qp_per_uv[i] = qp_per_matrix[ currMB->qp_scaled[i + 1] ];
- qp_rem_uv[i] = qp_rem_matrix[ currMB->qp_scaled[i + 1] ];
- }
- }
- // read CBP if not new intra mode
- if (!IS_NEWINTRA (currMB))
- {
- //===== C B P =====
- //---------------------
- currSE.type = (IS_OLDINTRA (currMB) || currMB->mb_type == SI4MB || currMB->mb_type == I8MB)
- ? SE_CBP_INTRA
- : SE_CBP_INTER;
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- {
- currSE.mapping = (IS_OLDINTRA (currMB) || currMB->mb_type == SI4MB || currMB->mb_type == I8MB)
- ? linfo_cbp_intra
- : linfo_cbp_inter;
- }
- else
- {
- currSE.reading = readCBP_CABAC;
- }
- TRACE_STRING("coded_block_pattern");
- dP->readSyntaxElement(&currSE, img, dP);
- currMB->cbp = cbp = currSE.value1;
- //============= Transform size flag for INTER MBs =============
- //-------------------------------------------------------------
- need_transform_size_flag = (((currMB->mb_type >= 1 && currMB->mb_type <= 3)||
- (IS_DIRECT(currMB) && active_sps->direct_8x8_inference_flag) ||
- (currMB->NoMbPartLessThan8x8Flag))
- && currMB->mb_type != I8MB && currMB->mb_type != I4MB
- && (currMB->cbp&15)
- && img->Transform8x8Mode);
- if (need_transform_size_flag)
- {
- currSE.type = SE_HEADER;
- dP = &(currSlice->partArr[partMap[SE_HEADER]]);
- currSE.reading = readMB_transform_size_flag_CABAC;
- TRACE_STRING("transform_size_8x8_flag");
- // read UVLC transform_size_8x8_flag
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- {
- currSE.len = 1;
- readSyntaxElement_FLC(&currSE, dP->bitstream);
- }
- else
- {
- dP->readSyntaxElement(&currSE,img,dP);
- }
- currMB->luma_transform_size_8x8_flag = currSE.value1;
- }
- //===== DQUANT =====
- //----------------------
- // Delta quant only if nonzero coeffs
- if (cbp !=0)
- {
- read_delta_quant(&currSE, dP, currSlice, img, currMB, partMap, (IS_INTER (currMB)) ? SE_DELTA_QUANT_INTER : SE_DELTA_QUANT_INTRA);
- if (currSlice->dp_mode)
- {
- if (IS_INTER (currMB) && currSlice->dpC_NotPresent )
- currMB->dpl_flag = 1;
- if( intra && currSlice->dpB_NotPresent )
- {
- currMB->ei_flag = 1;
- currMB->dpl_flag = 1;
- }
- // check for prediction from neighbours
- check_dp_neighbors (currMB);
- if (currMB->dpl_flag)
- {
- cbp = 0;
- currMB->cbp = cbp;
- }
- }
- }
- }
- else
- {
- cbp = currMB->cbp;
- }
- memset(&img->cof[0][0][0], 0, MB_PIXELS * sizeof(int)); // reset luma coeffs
- memset(&img->fcf[0][0][0], 0, MB_PIXELS * sizeof(int)); // reset luma coeffs
- if (IS_NEWINTRA (currMB)) // read DC coeffs for new intra modes
- {
- read_delta_quant(&currSE, dP, currSlice, img, currMB, partMap, SE_DELTA_QUANT_INTRA);
- for (j=0;j<BLOCK_SIZE;j++)
- memset(&img->ipredmode[img->block_y+j][img->block_x], DC_PRED, BLOCK_SIZE * sizeof(byte));
- if (currSlice->dp_mode)
- {
- if (currSlice->dpB_NotPresent)
- {
- currMB->ei_flag = 1;
- currMB->dpl_flag = 1;
- }
- check_dp_neighbors (currMB);
- if (currMB->dpl_flag)
- {
- currMB->cbp = cbp = 0;
- }
- }
- if (!currMB->dpl_flag)
- {
- pos_scan_4x4 = pos_scan4x4[0];
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- readCoeff4x4_CAVLC(currMB, img, LUMA_INTRA16x16DC, 0, 0, levarr, runarr, &numcoeff);
- for(k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0) // leave if len=1
- {
- pos_scan_4x4 += 2 * runarr[k];
- i0 = ((*pos_scan_4x4++) << 2);
- j0 = ((*pos_scan_4x4++) << 2);
- img->cof[0][j0][i0] = levarr[k];// add new intra DC coeff
- img->fcf[0][j0][i0] = levarr[k];// add new intra DC coeff
- }
- }
- }
- else
- {
- currSE.type = SE_LUM_DC_INTRA;
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- currSE.context = LUMA_16DC;
- currSE.type = SE_LUM_DC_INTRA;
- img->is_intra_block = 1;
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- {
- currSE.mapping = linfo_levrun_inter;
- }
- else
- {
- currSE.reading = readRunLevel_CABAC;
- }
- level = 1; // just to get inside the loop
- for(k=0;(k<17) && (level!=0);k++)
- {
- #if TRACE
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "DC luma 16x16 ");
- #endif
- dP->readSyntaxElement(&currSE, img, dP);
- level = currSE.value1;
- if (level != 0) // leave if len=1
- {
- pos_scan_4x4 += (2 * currSE.value2);
- i0 = ((*pos_scan_4x4++) << 2);
- j0 = ((*pos_scan_4x4++) << 2);
- img->cof[0][j0][i0] = level;// add new intra DC coeff
- img->fcf[0][j0][i0] = level;// add new intra DC coeff
- }
- }
- }
- if(!lossless_qpprime)
- itrans_2(img, currMB, PLANE_Y);// transform new intra DC
- }
- }
- update_qp(img, currMB, img->qp);
- qp_per = qp_per_matrix[ currMB->qp_scaled[img->colour_plane_id] ];
- qp_rem = qp_rem_matrix[ currMB->qp_scaled[img->colour_plane_id] ];
- //init quant parameters for chroma
- if (dec_picture->chroma_format_idc != YUV400)
- {
- for(i=0; i < 2; i++)
- {
- qp_per_uv[i] = qp_per_matrix[ currMB->qp_scaled[i + 1] ];
- qp_rem_uv[i] = qp_rem_matrix[ currMB->qp_scaled[i + 1] ];
- }
- }
- InvLevelScale4x4 = intra? InvLevelScale4x4_Intra[img->colour_plane_id][qp_rem] : InvLevelScale4x4_Inter[img->colour_plane_id][qp_rem];
- InvLevelScale8x8 = intra? InvLevelScale8x8_Intra[img->colour_plane_id][qp_rem] : InvLevelScale8x8_Inter[img->colour_plane_id][qp_rem];
- // luma coefficients
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- start_scan = IS_NEWINTRA(currMB) ? 1 : 0;
- if (!lossless_qpprime)
- {
- if (!currMB->luma_transform_size_8x8_flag) // 4x4 transform
- {
- if (cbp)
- {
- int cur_context = IS_NEWINTRA(currMB) ? LUMA_INTRA16x16AC : LUMA;
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = (block_y + (block_x >> 1));
- if (cbp & (1 << b8)) // test if the block contains any coefficients
- {
- for (j=block_y; j < block_y + 2; j++)
- {
- for (i=block_x; i < block_x + 2; i++)
- {
- readCoeff4x4_CAVLC(currMB, img, cur_context, i, j, levarr, runarr, &numcoeff);
- pos_scan_4x4 = pos_scan4x4[start_scan];
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- pos_scan_4x4 += (runarr[k] << 1);
- i0 = *pos_scan_4x4++;
- j0 = *pos_scan_4x4++;
- // inverse quant for 4x4 transform only
- currMB->cbp_blk |= (int64) 1 << ((j<<2) + i);
- img->cof[0][(j<<2) + j0][(i<<2) + i0]= rshift_rnd_sf((levarr[k] * InvLevelScale4x4[j0][i0])<<qp_per, 4);
- img->fcf[0][(j<<2) + j0][(i<<2) + i0]= levarr[k];
- }
- }
- }
- }
- }
- else
- {
- for (j=block_y; j < block_y + 2; j++)
- {
- memset(&img->nz_coeff[mb_nr][0][j][block_x], 0, 2 * sizeof(int));
- }
- }
- }
- }
- }
- else
- {
- memset(&img->nz_coeff[mb_nr][0][0][0], 0, BLOCK_SIZE * BLOCK_SIZE * sizeof(int));
- }
- }
- else // 8x8 transform
- {
- if (cbp)
- {
- int cur_context = IS_NEWINTRA(currMB) ? LUMA_INTRA16x16AC : LUMA;
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = 2*(block_y>>1) + (block_x>>1);
- if (cbp & (1<<b8)) /* are there any coeff in current block at all */
- {
- for (j=block_y; j < block_y+2; j++)
- {
- for (i=block_x; i < block_x+2; i++)
- {
- readCoeff4x4_CAVLC(currMB, img, cur_context, i, j, levarr, runarr, &numcoeff);
- coef_ctr = start_scan - 1;
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- // do same as CABAC for deblocking: any coeff in the 8x8 marks all the 4x4s
- //as containing coefficients
- currMB->cbp_blk |= 51 << ((block_y<<2) + block_x);
- b4 = (coef_ctr << 2) + 2*(j - block_y)+(i - block_x);
- i0 = pos_scan8x8[b4][0];
- j0 = pos_scan8x8[b4][1];
- img->mb_rres[0][block_y*4 +j0][block_x*4 +i0] = rshift_rnd_sf((levarr[k] * InvLevelScale8x8[j0][i0])<<qp_per, 6); // dequantization
- }
- }//else (!currMB->luma_transform_size_8x8_flag)
- }
- }
- }
- else
- {
- for (j=block_y; j < block_y+2; j++)
- {
- memset(&img->nz_coeff[mb_nr][0][j][block_x], 0, 2 * sizeof(int));
- }
- }
- }
- }
- }
- else
- {
- memset(&img->nz_coeff[mb_nr][0][0][0], 0, BLOCK_SIZE * BLOCK_SIZE * sizeof(int));
- }
- }
- }
- else // if (!lossless_qpprime)
- {
- int cur_context = IS_NEWINTRA(currMB) ? LUMA_INTRA16x16AC : LUMA;
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = 2*(block_y>>1) + (block_x>>1);
- for (j=block_y; j < block_y+2; j++)
- {
- for (i=block_x; i < block_x+2; i++)
- {
- if (cbp & (1<<b8)) /* are there any coeff in current block at all */
- {
- readCoeff4x4_CAVLC(currMB, img, cur_context, i, j, levarr, runarr, &numcoeff);
- coef_ctr = start_scan - 1;
- if (!currMB->luma_transform_size_8x8_flag) // inverse quant for 4x4 transform
- {
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- currMB->cbp_blk |= (int64) 1 << ((j<<2) + i);
- img->cof[0][(j<<2) + j0][(i<<2) + i0]= levarr[k];
- img->fcf[0][(j<<2) + j0][(i<<2) + i0]= levarr[k];
- }
- }
- }
- else // inverse quant for 8x8 transform
- {
- int iz, jz;
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- // do same as CABAC for deblocking: any coeff in the 8x8 marks all the 4x4s
- //as containing coefficients
- currMB->cbp_blk |= 51 << ((block_y<<2) + block_x);
- b4 = 2*(j-block_y)+(i-block_x);
- iz=pos_scan8x8[coef_ctr*4+b4][0];
- jz=pos_scan8x8[coef_ctr*4+b4][1];
- img->mb_rres[0][block_y*4 +jz][block_x*4 +iz] = levarr[k];
- }
- }
- }//else (!currMB->luma_transform_size_8x8_flag)
- }
- else
- {
- img->nz_coeff[mb_nr][0][j][i] = 0;
- }
- }
- }
- }
- }
- }
- } // VLC
- else
- {
- //======= Other Modes & CABAC ========
- //------------------------------------
- if(currMB->luma_transform_size_8x8_flag)
- {
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (b8 = block_y; b8 < block_y + 2; b8 += 1)
- {
- readLumaCoeff8x8_CABAC(img, currMB, PLANE_Y, b8); //======= 8x8 trannsform size & CABAC ========
- }
- }
- }
- else
- {
- if(!lossless_qpprime)
- {
- if (cbp)
- {
- start_scan = IS_NEWINTRA (currMB)? 1 : 0;
- img->is_intra_block = intra;
- currSE.context = (IS_NEWINTRA(currMB) ? LUMA_16AC : LUMA_4x4);
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = 2*(block_y>>1) + (block_x>>1);
- if (cbp & (1<<b8)) // are there any coeff in current block at all
- {
- for (j = (block_y<<2); j < (block_y<<2) + 8; j += 4)
- {
- img->subblock_y = (j>>2); // position for coeff_count ctx
- for (i = block_x; i < block_x + 2; i++)
- {
- img->subblock_x = i; // position for coeff_count ctx
- pos_scan_4x4 = pos_scan4x4[start_scan];
- level = 1;
- for(k=start_scan;(k<17) && (level!=0);k++)
- {
- /*
- * make distinction between INTRA and INTER coded
- * luminance coefficients
- */
- currSE.type = (img->is_intra_block
- ? (k==0 ? SE_LUM_DC_INTRA : SE_LUM_AC_INTRA)
- : (k==0 ? SE_LUM_DC_INTER : SE_LUM_AC_INTER));
- #if TRACE
- sprintf(currSE.tracestring, "Luma sng ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_inter;
- else
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0) /* leave if len=1 */
- {
- pos_scan_4x4 += 2 * currSE.value2;
- i0 = *pos_scan_4x4++;
- j0 = *pos_scan_4x4++;
- currMB->cbp_blk |= (int64)1 << (j + i) ;
- img->cof[0][j + j0][(i<<2) + i0]= rshift_rnd_sf((level * InvLevelScale4x4[j0][i0]) << qp_per, 4);
- img->fcf[0][j + j0][(i<<2) + i0]= level;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- else
- {
- start_scan = IS_NEWINTRA (currMB)? 1 : 0;
- img->is_intra_block = intra;
- currSE.context = (IS_NEWINTRA(currMB) ? LUMA_16AC : LUMA_4x4);
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = 2*(block_y>>1) + (block_x>>1);
- for (j = block_y; j < block_y + 2; j++)
- {
- img->subblock_y = j; // position for coeff_count ctx
- for (i = block_x; i < block_x + 2; i++)
- {
- img->subblock_x = i; // position for coeff_count ctx
- if (cbp & (1<<b8)) // are there any coeff in current block at all
- {
- coef_ctr = start_scan - 1;
- level = 1;
- for(k=start_scan;(k<17) && (level!=0);k++)
- {
- /*
- * make distinction between INTRA and INTER coded
- * luminance coefficients
- */
- currSE.type = (img->is_intra_block
- ? (k==0 ? SE_LUM_DC_INTRA : SE_LUM_AC_INTRA)
- : (k==0 ? SE_LUM_DC_INTER : SE_LUM_AC_INTER));
- #if TRACE
- sprintf(currSE.tracestring, "Luma sng ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_inter;
- else
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0) /* leave if len=1 */
- {
- coef_ctr += currSE.value2+1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- currMB->cbp_blk |= (int64)1 << ((j<<2) + i) ;
- img->cof[0][(j<<2) + j0][(i<<2) + i0] = level;
- img->fcf[0][(j<<2) + j0][(i<<2) + i0] = level;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if ( active_sps->chroma_format_idc==YUV444 && !IS_INDEPENDENT(img) )
- {
- for (uv = 0; uv < 2; uv++ )
- {
- memset(&img->cof[uv + 1][0][0], 0, MB_PIXELS * sizeof(int));
- memset(&img->fcf[uv + 1][0][0], 0, MB_PIXELS * sizeof(int));
- /*----------------------16x16DC Luma_Add----------------------*/
- if (IS_NEWINTRA (currMB)) // read DC coeffs for new intra modes
- {
- for (i=0;i<BLOCK_SIZE;i++)
- for (j=0;j<BLOCK_SIZE;j++)
- img->ipredmode[img->block_y+j][img->block_x+i]=DC_PRED;
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- if (uv == 0)
- readCoeff4x4_CAVLC(currMB, img, CB_INTRA16x16DC, 0, 0, levarr, runarr, &numcoeff);
- else
- readCoeff4x4_CAVLC(currMB, img, CR_INTRA16x16DC, 0, 0, levarr, runarr, &numcoeff);
- coef_ctr=-1;
- level = 1; // just to get inside the loop
- for(k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0) // leave if len=1
- {
- coef_ctr += runarr[k] + 1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- img->cof[uv + 1][j0<<2][i0<<2] = levarr[k];// add new intra DC coeff
- img->fcf[uv + 1][j0<<2][i0<<2] = levarr[k];// add new intra DC coeff
- } //if leavarr[k]
- } //k loop
- } //UVLC
- else // else UVLC
- {
- currSE.type = SE_LUM_DC_INTRA;
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (uv==0)
- currSE.context = CB_16DC;
- else
- currSE.context = CR_16DC;
- if( IS_INDEPENDENT(img) )
- currSE.context = LUMA_16DC;
- currSE.type = SE_LUM_DC_INTRA;
- img->is_intra_block = 1;
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- {
- currSE.mapping = linfo_levrun_inter;
- }
- else
- {
- currSE.reading = readRunLevel_CABAC;
- }
- coef_ctr = -1;
- level = 1; // just to get inside the loop
- for(k=0;(k<17) && (level!=0);k++)
- {
- #if TRACE
- if (uv == 0)
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "DC Cb 16x16 ");
- else
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "DC Cr 16x16 ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //run = currSE.value2;
- //len = currSE.len;
- if (level != 0) // leave if len=1
- {
- coef_ctr += currSE.value2 + 1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- img->cof[uv + 1][j0<<2][i0<<2] = level;
- img->fcf[uv + 1][j0<<2][i0<<2] = level;
- }
- } //k loop
- } // else UVLC
- if(!lossless_qpprime)
- {
- itrans_2(img, currMB, (ColorPlane) (uv + 1)); // transform new intra DC
- }
- } //IS_NEWINTRA
- update_qp(img, currMB, img->qp);
- qp_per = qp_per_matrix[ (img->qp + img->bitdepth_luma_qp_scale) ];
- qp_rem = qp_rem_matrix[ (img->qp + img->bitdepth_luma_qp_scale) ];
- //init constants for every chroma qp offset
- qp_per_uv[uv] = qp_per_matrix[ (currMB->qpc[uv] + img->bitdepth_chroma_qp_scale) ];
- qp_rem_uv[uv] = qp_rem_matrix[ (currMB->qpc[uv] + img->bitdepth_chroma_qp_scale) ];
- InvLevelScale4x4 = intra? InvLevelScale4x4_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale4x4_Inter[uv + 1][qp_rem_uv[uv]];
- InvLevelScale8x8 = intra? InvLevelScale8x8_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale8x8_Inter[uv + 1][qp_rem_uv[uv]];
- // luma_add coefficients
- for (block_y=0; block_y < 4; block_y += 2) /* all modes */
- {
- for (block_x=0; block_x < 4; block_x += 2)
- {
- b8 = 2*(block_y>>1) + (block_x>>1);
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- for (j=block_y; j < block_y+2; j++)
- {
- for (i=block_x; i < block_x+2; i++)
- {
- ii = block_x >> 1;
- jj = block_y >> 1;
- b8 = 2 * jj + ii;
- if (cbp & (1<<b8)) /* are there any coeff in current block at all */
- {
- if (uv==0)
- readCoeff4x4_CAVLC(currMB, img, (IS_NEWINTRA(currMB) ? CB_INTRA16x16AC : CB), i, j, levarr, runarr, &numcoeff);
- else
- readCoeff4x4_CAVLC(currMB, img, (IS_NEWINTRA(currMB) ? CR_INTRA16x16AC : CR), i, j, levarr, runarr, &numcoeff);
- start_scan = IS_NEWINTRA(currMB) ? 1 : 0;
- coef_ctr = start_scan - 1;
- if(!lossless_qpprime)
- {
- if (!currMB->luma_transform_size_8x8_flag) // 4x4 transform
- {
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- i0 = pos_scan4x4[coef_ctr][0];
- j0 = pos_scan4x4[coef_ctr][1];
- // inverse quant for 4x4 transform only
- currMB->cbp_blk_CbCr[uv] |= (int64) 1 << ((j<<2) + i);
- img->cof[uv + 1][(j << 2) + j0][(i << 2) + i0] = rshift_rnd_sf((levarr[k] * InvLevelScale4x4[j0][i0])<<qp_per_uv[uv],4);
- img->fcf[uv + 1][(j << 2) + j0][(i << 2) + i0] = levarr[k];
- } //levarr[k] != 0
- }//k loop
- } //4x4
- else //8x8
- {
- int iz, jz;
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- // do same as CABAC for deblocking: any coeff in the 8x8 marks all the 4x4s
- //as containing coefficients
- currMB->cbp_blk_CbCr[uv] |= 51 << ((block_y<<2) + block_x);
- b4 = 2*(j - block_y)+(i - block_x);
- iz = pos_scan8x8[(coef_ctr << 2) + b4][0];
- jz = pos_scan8x8[(coef_ctr << 2) + b4][1];
- img->mb_rres[uv+1][block_y*4 +jz][block_x*4 +iz] = rshift_rnd_sf((levarr[k]*InvLevelScale8x8[jz][iz])<<qp_per_uv[uv], 6); // dequantization 444_TEMP_NOTE
- } //if levarr
- }//8x8
- }//k loop
- } // !lossless
- else //lossless
- {
- if (!currMB->luma_transform_size_8x8_flag) // inverse quant for 4x4 transform
- {
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- currMB->cbp_blk_CbCr[uv] |= (int64) 1 << ((j<<2) + i);
- img->cof[uv + 1][(j << 2) + j0][(i << 2) + i0] = levarr[k];
- img->fcf[uv + 1][(j << 2) + j0][(i << 2) + i0] = levarr[k];
- } //levarr[k]
- } //k loop
- } //4x4
- else //8x8
- {
- int iz, jz;
- for (k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- coef_ctr += runarr[k]+1;
- // do same as CABAC for deblocking: any coeff in the 8x8 marks all the 4x4s
- //as containing coefficients
- currMB->cbp_blk_CbCr[uv] |= 51 << ((block_y<<2) + block_x);
- b4 = 2*(j-block_y)+(i-block_x);
- iz=pos_scan8x8[coef_ctr*4+b4][0];
- jz=pos_scan8x8[coef_ctr*4+b4][1];
- img->mb_rres[uv+1][block_y*4 +jz][block_x*4 +iz] = levarr[k];
- } //levarr[k]
- } //k loop
- } //8x8
- }// loseless
- } //if (cbp & (1<<b8))
- else //!(cbp & (1<<b8))
- {
- img->nz_coeff[mb_nr][uv + 1][j][i] = 0;
- } //!(cbp & (1<<b8))
- } //i=block_x
- } //j=block_y
- } //UVCL
- else // CABAC
- {
- if(currMB->luma_transform_size_8x8_flag)
- {
- readLumaCoeff8x8_CABAC(img, currMB, (ColorPlane) (PLANE_U + uv), b8); //======= 8x8 trannsform size & CABAC ========
- }
- else //4x4
- {
- //======= Other Modes & CABAC ========
- //------------------------------------
- for (j=block_y; j < block_y+2; j++)
- {
- for (i=block_x; i < block_x+2; i++)
- {
- start_scan = IS_NEWINTRA (currMB)? 1 : 0;
- img->subblock_x = i; // position for coeff_count ctx
- img->subblock_y = j; // position for coeff_count ctx
- if (cbp & (1<<b8)) // are there any coeff in current block at all
- {
- coef_ctr = start_scan - 1;
- level = 1;
- img->is_intra_block = intra;
- if(!lossless_qpprime)
- {
- for(k=start_scan;(k<17) && (level!=0);k++)
- {
- /*
- * make distinction between INTRA and INTER coded
- * luminance coefficients
- */
- if (uv == 0)
- currSE.context = (IS_NEWINTRA(currMB) ? CB_16AC: CB_4x4);
- else
- currSE.context = (IS_NEWINTRA(currMB) ? CR_16AC: CR_4x4);
- if( IS_INDEPENDENT(img) )
- currSE.context = (IS_NEWINTRA(currMB) ? LUMA_16AC: LUMA_4x4);
- currSE.type = (img->is_intra_block
- ? (k==0 ? SE_LUM_DC_INTRA : SE_LUM_AC_INTRA)
- : (k==0 ? SE_LUM_DC_INTER : SE_LUM_AC_INTER));
- #if TRACE
- if (uv == 0)
- sprintf(currSE.tracestring, "Cb sng ");
- else
- sprintf(currSE.tracestring, "Cr sng ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_inter;
- else
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //run = currSE.value2;
- //len = currSE.len;
- if (level != 0) /* leave if len=1 */
- {
- coef_ctr += currSE.value2+1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- currMB->cbp_blk_CbCr[uv] |= (int64)1 << ((j<<2) + i) ;
- img->cof[uv + 1][(j << 2) + j0][(i << 2) + i0] = rshift_rnd_sf((level * InvLevelScale4x4[j0][i0]) << qp_per_uv[uv], 4); //444_TEMP_NOTE
- img->fcf[uv + 1][(j << 2) + j0][(i << 2) + i0] = level;
- }//level != 0
- } //k loop
- }//!lossless
- else //(lossless_qpprime)
- {
- for(k=start_scan;(k<17) && (level!=0);k++)
- {
- /*
- * make distinction between INTRA and INTER coded
- * luminance coefficients
- */
- if (uv == 0)
- currSE.context = (IS_NEWINTRA(currMB) ? CB_16AC: CB_4x4);
- else
- currSE.context = (IS_NEWINTRA(currMB) ? CR_16AC: CR_4x4);
- if( IS_INDEPENDENT(img) )
- currSE.context = (IS_NEWINTRA(currMB) ? LUMA_16AC: LUMA_4x4);
- currSE.type = (img->is_intra_block
- ? (k==0 ? SE_LUM_DC_INTRA : SE_LUM_AC_INTRA)
- : (k==0 ? SE_LUM_DC_INTER : SE_LUM_AC_INTER));
- #if TRACE
- if (uv == 0)
- sprintf(currSE.tracestring, "Cb sng ");
- else
- sprintf(currSE.tracestring, "Cr sng ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_inter;
- else
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- //run = currSE.value2;
- //len = currSE.len;
- if (level != 0) /* leave if len=1 */
- {
- coef_ctr += currSE.value2 + 1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- currMB->cbp_blk_CbCr[uv] |= (int64)1 << ((j<<2) + i);
- img->cof[uv + 1][(j << 2) + j0][(i << 2) + i0] = level;
- img->fcf[uv + 1][(j << 2) + j0][(i << 2) + i0] = level;
- } //level != 0
- }//k loop
- } //lossless
- } //(cbp & (1<<b8))
- } //i=block_x
- }//j=block_y
- } //4x4
- } //CABAC
- } //block_x
- } //block_y
- } //uv loop
- } //444
- else if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
- {
- memset(&img->cof[1][0][0], 0, MB_PIXELS * sizeof(int));
- memset(&img->cof[2][0][0], 0, MB_PIXELS * sizeof(int));
- memset(&img->fcf[1][0][0], 0, MB_PIXELS * sizeof(int));
- memset(&img->fcf[2][0][0], 0, MB_PIXELS * sizeof(int));
- //========================== CHROMA DC ============================
- //-----------------------------------------------------------------
- // chroma DC coeff
- if(cbp>15)
- {
- if (dec_picture->chroma_format_idc == YUV420)
- {
- for (ll=0;ll<3;ll+=2)
- {
- uv = ll>>1;
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- InvLevelScale4x4 = intra ? InvLevelScale4x4_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale4x4_Inter[uv + 1][qp_rem_uv[uv]];
- //===================== CHROMA DC YUV420 ======================
- memset(&img->cofu[0], 0, 4 *sizeof(int));
- readCoeff4x4_CAVLC(currMB, img, CHROMA_DC, 0, 0, levarr, runarr, &numcoeff);
- coef_ctr=-1;
- for(k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- currMB->cbp_blk |= 0xf0000 << (ll<<1) ;
- coef_ctr += runarr[k] + 1;
- img->cofu[coef_ctr]=levarr[k];
- }
- }
- }
- else
- {
- InvLevelScale4x4 = intra ? InvLevelScale4x4_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale4x4_Inter[uv + 1][qp_rem_uv[uv]];
- //===================== CHROMA DC YUV420 ======================
- memset(&img->cofu[0], 0, 4 *sizeof(int));
- coef_ctr=-1;
- level=1;
- img->is_intra_block = intra;
- img->is_v_block = ll;
- currSE.context = CHROMA_DC;
- currSE.type = (intra ? SE_CHR_DC_INTRA : SE_CHR_DC_INTER);
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_c2x2;
- else
- currSE.reading = readRunLevel_CABAC;
- for(k = 0; (k < (img->num_cdc_coeff + 1))&&(level!=0);k++)
- {
- #if TRACE
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "2x2 DC Chroma ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0)
- {
- currMB->cbp_blk |= 0xf0000 << (ll<<1) ;
- coef_ctr += currSE.value2 + 1;
- // Bug: img->cofu has only 4 entries, hence coef_ctr MUST be <4 (which is
- // caught by the assert(). If it is bigger than 4, it starts patching the
- // img->predmode pointer, which leads to bugs later on.
- //
- // This assert() should be left in the code, because it captures a very likely
- // bug early when testing in error prone environments (or when testing NAL
- // functionality).
- assert (coef_ctr < img->num_cdc_coeff);
- img->cofu[coef_ctr]=level;
- }
- }
- }
- if (smb || lossless_qpprime) // check to see if MB type is SPred or SIntra4x4
- {
- img->cof[uv + 1][0][0] = img->cofu[0];
- img->cof[uv + 1][4][0] = img->cofu[1];
- img->cof[uv + 1][0][4] = img->cofu[2];
- img->cof[uv + 1][4][4] = img->cofu[3];
- img->fcf[uv + 1][0][0] = img->cofu[0];
- img->fcf[uv + 1][4][0] = img->cofu[1];
- img->fcf[uv + 1][0][4] = img->cofu[2];
- img->fcf[uv + 1][4][4] = img->cofu[3];
- }
- else
- {
- ihadamard2x2(img->cofu, temp);
- img->fcf[uv + 1][0][0] = temp[0];
- img->fcf[uv + 1][0][4] = temp[1];
- img->fcf[uv + 1][4][0] = temp[2];
- img->fcf[uv + 1][4][4] = temp[3];
- for (i=0;i<img->num_cdc_coeff;i++)
- {
- temp[i]= (((temp[i] * InvLevelScale4x4[0][0])<<qp_per_uv[uv])>>5);
- }
- img->cof[uv + 1][0][0] = temp[0];
- img->cof[uv + 1][0][4] = temp[1];
- img->cof[uv + 1][4][0] = temp[2];
- img->cof[uv + 1][4][4] = temp[3];
- }
- }
- }
- else if (dec_picture->chroma_format_idc == YUV422)
- {
- for (ll=0;ll<3;ll+=2)
- {
- int (*InvLevelScale4x4)[4] = NULL;
- uv = ll>>1;
- {
- int (*imgcof)[16] = img->cof[uv + 1];
- int m3[2][4] = {{0,0,0,0},{0,0,0,0}};
- int m4[2][4] = {{0,0,0,0},{0,0,0,0}};
- int qp_per_uv_dc = qp_per_matrix[ (currMB->qpc[uv] + 3 + img->bitdepth_chroma_qp_scale) ]; //for YUV422 only
- int qp_rem_uv_dc = qp_rem_matrix[ (currMB->qpc[uv] + 3 + img->bitdepth_chroma_qp_scale) ]; //for YUV422 only
- if (intra)
- InvLevelScale4x4 = InvLevelScale4x4_Intra[uv + 1][qp_rem_uv_dc];
- else
- InvLevelScale4x4 = InvLevelScale4x4_Inter[uv + 1][qp_rem_uv_dc];
- //===================== CHROMA DC YUV422 ======================
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- readCoeff4x4_CAVLC(currMB, img, CHROMA_DC, 0, 0, levarr, runarr, &numcoeff);
- coef_ctr=-1;
- level=1;
- for(k = 0; k < numcoeff; k++)
- {
- if (levarr[k] != 0)
- {
- currMB->cbp_blk |= ((int64)0xff0000) << (ll<<2);
- coef_ctr += runarr[k]+1;
- i0 = SCAN_YUV422[coef_ctr][0];
- j0 = SCAN_YUV422[coef_ctr][1];
- m3[i0][j0]=levarr[k];
- }
- }
- }
- else
- {
- coef_ctr=-1;
- level=1;
- for(k=0;(k<9)&&(level!=0);k++)
- {
- currSE.context = CHROMA_DC_2x4;
- currSE.type = (IS_INTRA(currMB) ? SE_CHR_DC_INTRA : SE_CHR_DC_INTER);
- img->is_intra_block = IS_INTRA(currMB);
- img->is_v_block = ll;
- #if TRACE
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "2x4 DC Chroma ");
- #endif
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (active_pps->entropy_coding_mode_flag == UVLC || dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_c2x2;
- else
- currSE.reading = readRunLevel_CABAC;
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0)
- {
- currMB->cbp_blk |= ((int64)0xff0000) << (ll<<2) ;
- coef_ctr += currSE.value2 + 1;
- assert (coef_ctr < img->num_cdc_coeff);
- i0=SCAN_YUV422[coef_ctr][0];
- j0=SCAN_YUV422[coef_ctr][1];
- m3[i0][j0]=level;
- }
- }
- }
- // inverse CHROMA DC YUV422 transform
- // horizontal
- if(!lossless_qpprime)
- {
- m4[0][0] = m3[0][0] + m3[1][0];
- m4[0][1] = m3[0][1] + m3[1][1];
- m4[0][2] = m3[0][2] + m3[1][2];
- m4[0][3] = m3[0][3] + m3[1][3];
- m4[1][0] = m3[0][0] - m3[1][0];
- m4[1][1] = m3[0][1] - m3[1][1];
- m4[1][2] = m3[0][2] - m3[1][2];
- m4[1][3] = m3[0][3] - m3[1][3];
- for (i = 0; i < 2; i++)
- {
- m6[0] = m4[i][0] + m4[i][2];
- m6[1] = m4[i][0] - m4[i][2];
- m6[2] = m4[i][1] - m4[i][3];
- m6[3] = m4[i][1] + m4[i][3];
- imgcof[ 0][i<<2] = m6[0] + m6[3];
- imgcof[ 4][i<<2] = m6[1] + m6[2];
- imgcof[ 8][i<<2] = m6[1] - m6[2];
- imgcof[12][i<<2] = m6[0] - m6[3];
- }//for (i=0;i<2;i++)
- }
- else
- {
- for(j=0;j<4;j++)
- {
- for(i=0;i<2;i++)
- {
- img->cof[uv + 1][j<<2][i<<2] = m3[i][j];
- img->fcf[uv + 1][j<<2][i<<2] = m3[i][j];
- }
- }
- }
- for(j = 0;j < img->mb_cr_size_y; j += BLOCK_SIZE)
- {
- for(i=0;i < img->mb_cr_size_x;i+=BLOCK_SIZE)
- {
- imgcof[j][i] = rshift_rnd_sf((imgcof[j][i] * InvLevelScale4x4[0][0]) << qp_per_uv_dc, 6);
- }
- }
- }
- }//for (ll=0;ll<3;ll+=2)
- }//else if (dec_picture->chroma_format_idc == YUV422)
- }
- //========================== CHROMA AC ============================
- //-----------------------------------------------------------------
- // chroma AC coeff, all zero fram start_scan
- if (cbp<=31)
- {
- if (active_pps->entropy_coding_mode_flag == UVLC)
- memset(&img->nz_coeff [mb_nr ][1][0][0], 0, 2 * BLOCK_SIZE * BLOCK_SIZE * sizeof(int));
- }
- else
- {
- if (active_pps->entropy_coding_mode_flag == UVLC)
- {
- if(!lossless_qpprime)
- {
- for (b8=0; b8 < img->num_blk8x8_uv; b8++)
- {
- img->is_v_block = uv = (b8 > ((img->num_uv_blocks) - 1 ));
- InvLevelScale4x4 = intra ? InvLevelScale4x4_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale4x4_Inter[uv + 1][qp_rem_uv[uv]];
- for (b4=0; b4 < 4; b4++)
- {
- i = cofuv_blk_x[yuv][b8][b4];
- j = cofuv_blk_y[yuv][b8][b4];
- readCoeff4x4_CAVLC(currMB, img, CHROMA_AC, i + 2*uv, j + 4, levarr, runarr, &numcoeff);
- coef_ctr = 0;
- for(k = 0; k < numcoeff;k++)
- {
- if (levarr[k] != 0)
- {
- currMB->cbp_blk |= ((int64)1) << cbp_blk_chroma[b8][b4];
- coef_ctr += runarr[k] + 1;
- i0=pos_scan4x4[coef_ctr][0];
- j0=pos_scan4x4[coef_ctr][1];
- img->cof[uv + 1][(j<<2) + j0][(i<<2) + i0] = rshift_rnd_sf((levarr[k] * InvLevelScale4x4[j0][i0])<<qp_per_uv[uv], 4);
- img->fcf[uv + 1][(j<<2) + j0][(i<<2) + i0] = levarr[k];
- }
- }
- }
- }
- }
- else
- {
- for (b8=0; b8 < img->num_blk8x8_uv; b8++)
- {
- img->is_v_block = uv = (b8 > ((img->num_uv_blocks) - 1 ));
- for (b4=0; b4 < 4; b4++)
- {
- i = cofuv_blk_x[yuv][b8][b4];
- j = cofuv_blk_y[yuv][b8][b4];
- readCoeff4x4_CAVLC(currMB, img, CHROMA_AC, i, j, levarr, runarr, &numcoeff);
- coef_ctr=0;
- level=1;
- for(k = 0; k < numcoeff;k++)
- {
- if (levarr[k] != 0)
- {
- currMB->cbp_blk |= ((int64) 1) << cbp_blk_chroma[b8][b4];
- coef_ctr += runarr[k] + 1;
- i0 = pos_scan4x4[coef_ctr][0];
- j0 = pos_scan4x4[coef_ctr][1];
- img->cof[uv + 1][(j<<2) + j0][(i<<2) + i0] = levarr[k];
- img->fcf[uv + 1][(j<<2) + j0][(i<<2) + i0] = levarr[k];
- }
- }
- }
- }
- }
- }
- else
- {
- img->is_intra_block = IS_INTRA(currMB);
- currSE.context = CHROMA_AC;
- currSE.type = (img->is_intra_block ? SE_CHR_AC_INTRA : SE_CHR_AC_INTER);
- dP = &(currSlice->partArr[partMap[currSE.type]]);
- if (dP->bitstream->ei_flag)
- currSE.mapping = linfo_levrun_inter;
- else
- currSE.reading = readRunLevel_CABAC;
- if(!lossless_qpprime)
- {
- for (b8=0; b8 < img->num_blk8x8_uv; b8++)
- {
- img->is_v_block = uv = (b8 > ((img->num_uv_blocks) - 1 ));
- InvLevelScale4x4 = intra ? InvLevelScale4x4_Intra[uv + 1][qp_rem_uv[uv]] : InvLevelScale4x4_Inter[uv + 1][qp_rem_uv[uv]];
- for (b4 = 0; b4 < 4; b4++)
- {
- i = cofuv_blk_x[yuv][b8][b4];
- j = cofuv_blk_y[yuv][b8][b4];
- img->subblock_y = subblk_offset_y[yuv][b8][b4]>>2;
- img->subblock_x = subblk_offset_x[yuv][b8][b4]>>2;
- pos_scan_4x4 = pos_scan4x4[1];
- level=1;
- for(k = 0; (k < 16) && (level != 0);k++)
- {
- #if TRACE
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "AC Chroma ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0)
- {
- currMB->cbp_blk |= ((int64)1) << cbp_blk_chroma[b8][b4];
- pos_scan_4x4 += (currSE.value2 << 1);
- i0 = *pos_scan_4x4++;
- j0 = *pos_scan_4x4++;
- img->cof[uv + 1][(j<<2) + j0][(i<<2) + i0] = rshift_rnd_sf((level * InvLevelScale4x4[j0][i0])<<qp_per_uv[uv], 4);
- img->fcf[uv + 1][(j<<2) + j0][(i<<2) + i0] = level;
- }
- } //for(k=0;(k<16)&&(level!=0);k++)
- }
- }
- }
- else
- {
- for (b8=0; b8 < img->num_blk8x8_uv; b8++)
- {
- img->is_v_block = uv = (b8 > ((img->num_uv_blocks) - 1 ));
- for (b4=0; b4 < 4; b4++)
- {
- i = cofuv_blk_x[yuv][b8][b4];
- j = cofuv_blk_y[yuv][b8][b4];
- pos_scan_4x4 = pos_scan4x4[1];
- level=1;
- img->subblock_y = subblk_offset_y[yuv][b8][b4]>>2;
- img->subblock_x = subblk_offset_x[yuv][b8][b4]>>2;
- for(k=0;(k<16)&&(level!=0);k++)
- {
- #if TRACE
- snprintf(currSE.tracestring, TRACESTRING_SIZE, "AC Chroma ");
- #endif
- dP->readSyntaxElement(&currSE,img,dP);
- level = currSE.value1;
- if (level != 0)
- {
- currMB->cbp_blk |= ((int64)1) << cbp_blk_chroma[b8][b4];
- pos_scan_4x4 += (currSE.value2 << 1);
- i0 = *pos_scan_4x4++;
- j0 = *pos_scan_4x4++;
- img->cof[uv + 1][(j<<2) + j0][(i<<2) + i0] = level;
- img->fcf[uv + 1][(j<<2) + j0][(i<<2) + i0] = level;
- }
- }
- }
- }
- } //for (b4=0; b4 < 4; b4++)
- } //for (b8=0; b8 < img->num_blk8x8_uv; b8++)
- } //if (dec_picture->chroma_format_idc != YUV400)
- }
- }
- /*!
- ************************************************************************
- * brief
- * Copy IPCM coefficients to decoded picture buffer and set parameters for this MB
- * (for IPCM CABAC and IPCM CAVLC 28/11/2003)
- *
- * author
- * Dong Wang <Dong.Wang@bristol.ac.uk>
- ************************************************************************
- */
- void decode_ipcm_mb(ImageParameters *img, Macroblock *currMB)
- {
- int i, j, k;
- int mb_nr = img->current_mb_nr;
- //Copy coefficients to decoded picture buffer
- //IPCM coefficients are stored in img->cof which is set in function readIPCMcoeffsFromNAL()
- for(i = 0; i < MB_BLOCK_SIZE; i++)
- {
- for(j = 0;j < MB_BLOCK_SIZE ; j++)
- {
- dec_picture->imgY[img->pix_y+i][img->pix_x+j] = (imgpel) img->cof[0][i][j];
- }
- }
- if ((dec_picture->chroma_format_idc != YUV400) && !IS_INDEPENDENT(img))
- {
- for (k = 0; k < 2; k++)
- {
- for(i = 0; i < img->mb_cr_size_y; i++)
- {
- for(j = 0;j < img->mb_cr_size_x; j++)
- {
- dec_picture->imgUV[k][img->pix_c_y+i][img->pix_c_x+j] = (imgpel) img->cof[k + 1][i][j];
- }
- }
- }
- }
- // for deblocking filter
- update_qp(img, currMB, 0);
- // for CAVLC: Set the nz_coeff to 16.
- // These parameters are to be used in CAVLC decoding of neighbour blocks
- for (k = 0; k < 3; k++)
- {
- for (j = 0; j < BLOCK_SIZE; j++)
- {
- for(i = 0; i < BLOCK_SIZE; i++)
- {
- img->nz_coeff[mb_nr][k][j][i] = 16;
- }
- }
- }
- // for CABAC decoding of MB skip flag
- currMB->skip_flag = 0;
- //for deblocking filter CABAC
- currMB->cbp_blk = 0xFFFF;
- //For CABAC decoding of Dquant
- last_dquant = 0;
- }
- /*!
- ************************************************************************
- * brief
- * decode one macroblock
- ************************************************************************
- */
- int decode_one_macroblock(ImageParameters *img, Macroblock *currMB, StorablePicture *dec_picture)
- {
- int i=0,j=0,k,l,ii=0,jj=0, j4=0,i4=0, j6;
- int refList;
- int uv, hv;
- int ioff,joff;
- int block8x8; // needed for ABT
- int j_pos, i_pos;
- static const byte decode_block_scan[16] = {0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15};
- int mb_nr = img->current_mb_nr;
- short ref_idx;
- int mv_mode, pred_dir; // = currMB->ref_frame;
- int block_size_x, block_size_y;
- int mv_scale;
- static imgpel **curComp;
- static imgpel (*mpr) [16];
- static imgpel *cur_line;
- static int *cur_m7;
- int smb = ((img->type==SP_SLICE) && IS_INTER (currMB)) || (img->type == SI_SLICE && currMB->mb_type == SI4MB);
- int list_offset;
- char l0_rFrame = -1, l1_rFrame = -1;
- short pmvl0[2]={0,0}, pmvl1[2]={0,0};
- int direct_pdir=-1;
- int curr_mb_field = ((img->MbaffFrameFlag)&&(currMB->mb_field));
- static MotionParams *colocated;
- int need_4x4_transform = (!currMB->luma_transform_size_8x8_flag);
- int yuv = dec_picture->chroma_format_idc - 1;
- //For residual DPCM
- Boolean lossless_qpprime = (Boolean) (((img->qp + img->bitdepth_luma_qp_scale) == 0) && (img->lossless_qpprime_flag == 1));
- ipmode_DPCM = NO_INTRA_PMODE;
- if (img->structure != FRAME || (img->MbaffFrameFlag && currMB->mb_field))
- img->max_mb_vmv_r = img->max_vmv_r >> 1;
- else
- img->max_mb_vmv_r = img->max_vmv_r;
- if(currMB->mb_type == IPCM)
- {
- //copy readed data into imgY and set parameters
- decode_ipcm_mb(img, currMB);
- return 0;
- }
- if (img->type==SP_SLICE && currMB->mb_type!=I16MB)
- smb = 1;// modif ES added
- //////////////////////////
- // find out the correct list offsets
- if (curr_mb_field)
- {
- if(mb_nr&0x01)
- {
- list_offset = 4; // top field mb
- colocated = &Co_located->bottom;
- }
- else
- {
- list_offset = 2; // bottom field mb
- colocated = &Co_located->top;
- }
- }
- else
- {
- list_offset = 0; // no mb aff or frame mb
- colocated = &Co_located->frame;
- }
- if (!img->MbaffFrameFlag)
- {
- for (l = LIST_0 + list_offset; l <= (LIST_1 + list_offset); l++)
- {
- for(k = 0; k < listXsize[l]; k++)
- {
- listX[l][k]->chroma_vector_adjustment= 0;
- if(img->structure == TOP_FIELD && img->structure != listX[l][k]->structure)
- listX[l][k]->chroma_vector_adjustment = -2;
- if(img->structure == BOTTOM_FIELD && img->structure != listX[l][k]->structure)
- listX[l][k]->chroma_vector_adjustment = 2;
- }
- }
- }
- else
- {
- if (curr_mb_field)
- {
- for (l = LIST_0 + list_offset; l <= (LIST_1 + list_offset); l++)
- {
- for(k = 0; k < listXsize[l]; k++)
- {
- listX[l][k]->chroma_vector_adjustment= 0;
- if(mb_nr % 2 == 0 && listX[l][k]->structure == BOTTOM_FIELD)
- listX[l][k]->chroma_vector_adjustment = -2;
- if(mb_nr % 2 == 1 && listX[l][k]->structure == TOP_FIELD)
- listX[l][k]->chroma_vector_adjustment = 2;
- }
- }
- }
- else
- {
- for (l = LIST_0 + list_offset; l <= (LIST_1 + list_offset); l++)
- {
- for(k = 0; k < listXsize[l]; k++)
- {
- listX[l][k]->chroma_vector_adjustment= 0;
- }
- }
- }
- }
- // luma decoding **************************************************
- // get prediction for INTRA_MB_16x16
- if (IS_NEWINTRA (currMB))
- {
- intrapred_luma_16x16(img, currMB, PLANE_Y, currMB->i16mode);
- ipmode_DPCM = currMB->i16mode; //For residual DPCM
- // =============== 4x4 itrans ================
- // -------------------------------------------
- iMBtrans4x4(PLANE_Y, img, smb);
- // chroma decoding *******************************************************
- if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
- {
- intra_cr_decoding(currMB, yuv, img, smb);
- }
- }
- else if (currMB->mb_type == I4MB)
- {
- itrans_4x4 = (!lossless_qpprime) ? itrans4x4 : Inv_Residual_trans_4x4;
- for (block8x8 = 0; block8x8 < 4; block8x8++)
- {
- for (k = block8x8 * 4; k < block8x8 * 4 + 4; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- ioff = (i << 2);
- joff = (j << 2);
- i4 = img->block_x + i;
- j4 = img->block_y + j;
- j_pos = j4 * BLOCK_SIZE;
- i_pos = i4 * BLOCK_SIZE;
- // PREDICTION
- //===== INTRA PREDICTION =====
- if (intrapred(img, currMB, PLANE_Y, ioff,joff,i4,j4) == SEARCH_SYNC) /* make 4x4 prediction block mpr from given prediction img->mb_mode */
- return SEARCH_SYNC; /* bit error */
- // =============== 4x4 itrans ================
- // -------------------------------------------
- itrans_4x4 (img, (ColorPlane) LumaComp, ioff, joff); // use DCT transform and make 4x4 block m7 from prediction block mpr
- for(jj=0;jj<BLOCK_SIZE;jj++)
- {
- cur_m7 = &img->mb_rres[0][jj + joff][ioff];
- cur_line = &dec_picture->imgY[j_pos + jj][i_pos];
- for(ii=0;ii<BLOCK_SIZE;ii++)
- {
- *(cur_line++) = (imgpel) (*cur_m7++); // construct picture from 4x4 blocks
- }
- }
- }
- }
- // chroma decoding *******************************************************
- if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
- {
- intra_cr_decoding(currMB, yuv, img, smb);
- }
- }
- else if (currMB->mb_type == I8MB)
- {
- itrans_8x8 = (!lossless_qpprime) ? itrans8x8 : Inv_Residual_trans_8x8;
- for (block8x8 = 0; block8x8 < 4; block8x8++)
- {
- //=========== 8x8 BLOCK TYPE ============
- ioff = 8 * (block8x8 & 0x01);
- joff = 8 * (block8x8 >> 1);
- //PREDICTION
- intrapred8x8(img, currMB, PLANE_Y, block8x8);
- itrans_8x8(img, currMB, PLANE_Y, ioff,joff); // use DCT transform and make 8x8 block m7 from prediction block mpr
- for(jj = joff; jj < joff + 8;jj++)
- {
- cur_m7 = &img->mb_rres[0][jj][ioff];
- cur_line = &dec_picture->imgY[img->pix_y + jj][img->pix_x + ioff];
- for(ii = 0; ii < 8; ii++)
- {
- *(cur_line++) = (imgpel) *(cur_m7++); // construct picture from 8x8 blocks
- }
- }
- }
- // chroma decoding *******************************************************
- if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
- {
- intra_cr_decoding(currMB, yuv, img, smb);
- }
- }
- else if ((img->type == P_SLICE) && (currMB->mb_type == PSKIP))
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = MB_BLOCK_SIZE;
- i = 0;
- j = 0;
- pred_dir = LIST_0;
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- mpr = img->mb_pred[LumaComp];
- curComp = &dec_picture->imgY[img->pix_y];
- for(j = 0; j < img->mb_size[0][1]; j++)
- {
- memcpy(&(curComp[j][img->pix_x]), &(mpr[j][0]), img->mb_size[0][0] * sizeof(imgpel));
- }
- if ((dec_picture->chroma_format_idc != YUV400) && (dec_picture->chroma_format_idc != YUV444))
- {
- for(uv=0;uv<2;uv++)
- {
- curComp = &dec_picture->imgUV[uv][img->pix_c_y];
- mpr = img->mb_pred[uv + 1];
- for(jj = 0; jj < img->mb_size[1][1]; jj++)
- memcpy(&(curComp[jj][img->pix_c_x]), &(mpr[jj][0]), img->mb_size[1][0] * sizeof(imgpel));
- }
- }
- }
- else if (currMB->mb_type == P16x16)
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = MB_BLOCK_SIZE;
- i = 0;
- j = 0;
- pred_dir = currMB->b8pdir[0];
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- iTransform(img, currMB, PLANE_Y, need_4x4_transform, smb);
- }
- else if (currMB->mb_type == P16x8)
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = 8;
- for (block8x8 = 0; block8x8 < 4; block8x8 += 2)
- {
- i = 0;
- j = block8x8;
- pred_dir = currMB->b8pdir[block8x8];
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- iTransform(img, currMB, PLANE_Y, need_4x4_transform, smb);
- }
- else if (currMB->mb_type == P8x16)
- {
- block_size_x = 8;
- block_size_y = 16;
- for (block8x8 = 0; block8x8 < 2; block8x8 ++)
- {
- i = block8x8<<1;
- j = 0;
- pred_dir = currMB->b8pdir[block8x8];
- assert (pred_dir<=2);
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- iTransform(img, currMB, PLANE_Y, need_4x4_transform, smb);
- }
- else
- {
- // prepare direct modes
- if (img->type==B_SLICE && img->direct_spatial_mv_pred_flag && (IS_DIRECT (currMB) ||
- (IS_P8x8(currMB) && !(currMB->b8mode[0] && currMB->b8mode[1] && currMB->b8mode[2] && currMB->b8mode[3]))))
- prepare_direct_params(currMB, dec_picture, img, pmvl0, pmvl1, &l0_rFrame, &l1_rFrame);
- for (block8x8=0; block8x8<4; block8x8++)
- {
- mv_mode = currMB->b8mode[block8x8];
- pred_dir = currMB->b8pdir[block8x8];
- //if ( mv_mode == SMB8x8 || mv_mode == SMB8x4 || mv_mode == SMB4x8 || mv_mode == SMB4x4 )
- if ( mv_mode != 0 )
- {
- int k_start = (block8x8 << 2);
- int k_inc = (mv_mode == SMB8x4) ? 2 : 1;
- int k_end = (mv_mode == SMB8x8) ? k_start + 1 : ((mv_mode == SMB4x4) ? k_start + 4 : k_start + k_inc + 1);
- block_size_x = ( mv_mode == SMB8x4 || mv_mode == SMB8x8 ) ? SMB_BLOCK_SIZE : BLOCK_SIZE;
- block_size_y = ( mv_mode == SMB4x8 || mv_mode == SMB8x8 ) ? SMB_BLOCK_SIZE : BLOCK_SIZE;
- for (k = k_start; k < k_end; k += k_inc)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- }
- else
- {
- int k_start = (block8x8 << 2);
- int k_end = k_start;
- if (active_sps->direct_8x8_inference_flag)
- {
- block_size_x = SMB_BLOCK_SIZE;
- block_size_y = SMB_BLOCK_SIZE;
- k_end ++;
- }
- else
- {
- block_size_x = BLOCK_SIZE;
- block_size_y = BLOCK_SIZE;
- k_end += BLOCK_MULTIPLE;
- }
- // Prepare mvs (needed for deblocking and mv prediction
- if (img->direct_spatial_mv_pred_flag)
- {
- for (k = k_start; k < k_start + BLOCK_MULTIPLE; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- ioff = (i << 2);
- i4 = img->block_x + i;
- joff = (j << 2);
- j4 = img->block_y + j;
- assert (pred_dir<=2);
- j6 = img->block_y_aff + j;
- //===== DIRECT PREDICTION =====
- if (l0_rFrame >=0)
- {
- if (!l0_rFrame && ((!colocated->moving_block[j6][i4]) && (!listX[LIST_1 + list_offset][0]->is_long_term)))
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_0][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- }
- else
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0] = pmvl0[0];
- dec_picture->motion.mv [LIST_0][j4][i4][1] = pmvl0[1];
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = l0_rFrame;
- }
- }
- else
- {
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = -1;
- dec_picture->motion.mv [LIST_0][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_0][j4][i4][1] = 0;
- }
- if (l1_rFrame >=0)
- {
- if (l1_rFrame==0 && ((!colocated->moving_block[j6][i4]) && (!listX[LIST_1 + list_offset][0]->is_long_term)))
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_1][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = l1_rFrame;
- }
- else
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = pmvl1[0];
- dec_picture->motion.mv [LIST_1][j4][i4][1] = pmvl1[1];
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = l1_rFrame;
- }
- }
- else
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_1][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = -1;
- }
- if (l0_rFrame < 0 && l1_rFrame < 0)
- {
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- if (dec_picture->motion.ref_idx[LIST_1][j4][i4]==-1)
- {
- direct_pdir = 0;
- ref_idx = (dec_picture->motion.ref_idx[LIST_0][j4][i4] != -1) ? dec_picture->motion.ref_idx[LIST_0][j4][i4] : 0;
- }
- else if (dec_picture->motion.ref_idx[LIST_0][j4][i4]==-1)
- {
- direct_pdir = 1;
- ref_idx = (dec_picture->motion.ref_idx[LIST_1][j4][i4] != -1) ? dec_picture->motion.ref_idx[LIST_1][j4][i4] : 0;
- }
- else
- direct_pdir = 2;
- pred_dir = direct_pdir;
- dec_picture->motion.ref_pic_id[LIST_0][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_0 + list_offset][(short)dec_picture->motion.ref_idx[LIST_0][j4][i4]];
- dec_picture->motion.ref_pic_id[LIST_1][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_1 + list_offset][(short)dec_picture->motion.ref_idx[LIST_1][j4][i4]];
- }
- }
- else
- {
- for (k = k_start; k < k_start + BLOCK_MULTIPLE; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- ioff = (i << 2);
- i4 = img->block_x + i;
- joff = (j << 2);
- j4 = img->block_y + j;
- assert (pred_dir<=2);
- j6 = img->block_y_aff + j;
- refList = (colocated->ref_idx[LIST_0][j6][i4]== -1 ? LIST_1 : LIST_0);
- ref_idx = colocated->ref_idx[refList][j6][i4];
- if(ref_idx==-1) // co-located is intra mode
- {
- memset( &dec_picture->motion.mv [LIST_0][j4][i4][0], 0, 2* sizeof(short));
- memset( &dec_picture->motion.mv [LIST_1][j4][i4][0], 0, 2* sizeof(short));
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- else // co-located skip or inter mode
- {
- int mapped_idx=0;
- int iref;
- for (iref=0;iref<imin(img->num_ref_idx_l0_active,listXsize[LIST_0 + list_offset]);iref++)
- {
- if(img->structure==0 && curr_mb_field==0)
- {
- // If the current MB is a frame MB and the colocated is from a field picture,
- // then the colocated->ref_pic_id may have been generated from the wrong value of
- // frame_poc if it references it's complementary field, so test both POC values
- if(listX[0][iref]->top_poc*2 == colocated->ref_pic_id[refList][j6][i4] || listX[0][iref]->bottom_poc*2 == colocated->ref_pic_id[refList][j6][i4])
- {
- mapped_idx=iref;
- break;
- }
- else //! invalid index. Default to zero even though this case should not happen
- mapped_idx=INVALIDINDEX;
- continue;
- }
- if (dec_picture->ref_pic_num[img->current_slice_nr][LIST_0 + list_offset][iref]==colocated->ref_pic_id[refList][j6][i4])
- {
- mapped_idx=iref;
- break;
- }
- else //! invalid index. Default to zero even though this case should not happen
- {
- mapped_idx=INVALIDINDEX;
- }
- }
- if (INVALIDINDEX == mapped_idx)
- {
- error("temporal direct errorncolocated block has ref that is unavailable",-1111);
- }
- mv_scale = img->mvscale[LIST_0 + list_offset][mapped_idx];
- //! In such case, an array is needed for each different reference.
- if (mv_scale == 9999 || listX[LIST_0+list_offset][mapped_idx]->is_long_term)
- {
- memcpy(&dec_picture->motion.mv [LIST_0][j4][i4][0], &colocated->mv[refList][j6][i4][0], 2 * sizeof(short));
- memset(&dec_picture->motion.mv [LIST_1][j4][i4][0], 0, 2 * sizeof(short));
- }
- else
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0]=(mv_scale * colocated->mv[refList][j6][i4][0] + 128 ) >> 8;
- dec_picture->motion.mv [LIST_0][j4][i4][1]=(mv_scale * colocated->mv[refList][j6][i4][1] + 128 ) >> 8;
- dec_picture->motion.mv [LIST_1][j4][i4][0]=dec_picture->motion.mv[LIST_0][j4][i4][0] - colocated->mv[refList][j6][i4][0] ;
- dec_picture->motion.mv [LIST_1][j4][i4][1]=dec_picture->motion.mv[LIST_0][j4][i4][1] - colocated->mv[refList][j6][i4][1] ;
- }
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = (char) mapped_idx; //listX[1][0]->ref_idx[refList][j4][i4];
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- // store reference picture ID determined by direct mode
- dec_picture->motion.ref_pic_id[LIST_0][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_0 + list_offset][(short)dec_picture->motion.ref_idx[LIST_0][j4][i4]];
- dec_picture->motion.ref_pic_id[LIST_1][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_1 + list_offset][(short)dec_picture->motion.ref_idx[LIST_1][j4][i4]];
- }
- }
- for (k = k_start; k < k_end; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- perform_mc(PLANE_Y, dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- }
- }
- iTransform(img, currMB, PLANE_Y, need_4x4_transform, smb);
- }
- if ((active_sps->chroma_format_idc==YUV444)&&(!IS_INDEPENDENT(img)))
- {
- for (uv = 0; uv < 2; uv++ )
- {
- if (IS_NEWINTRA (currMB))
- {
- // =============== 4x4 itrans ================
- // -------------------------------------------
- if (uv==0)
- {
- intrapred_luma_16x16(img, currMB, PLANE_U, currMB->i16mode);
- iMBtrans4x4(PLANE_U, img, smb);
- }
- else
- {
- intrapred_luma_16x16(img, currMB, PLANE_V, currMB->i16mode);
- iMBtrans4x4(PLANE_V, img, smb);
- }
- }
- else if (currMB->mb_type == I4MB)
- {
- itrans_4x4 = (!lossless_qpprime) ? itrans4x4 : Inv_Residual_trans_4x4;
- for (block8x8 = 0; block8x8 < 4; block8x8++)
- {
- for (k = block8x8 * 4; k < block8x8 * 4 + 4; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- ioff = (i << 2);
- joff = (j << 2);
- i4 = img->block_x + i;
- j4 = img->block_y + j;
- j_pos = j4 * BLOCK_SIZE;
- i_pos = i4 * BLOCK_SIZE;
- // PREDICTION
- //===== INTRA PREDICTION =====
- if (intrapred(img, currMB, (ColorPlane) (uv + 1), ioff, joff, i4,j4)==SEARCH_SYNC) /* make 4x4 prediction block mpr from given prediction img->mb_mode */
- return SEARCH_SYNC; /* bit error */
- // =============== 4x4 itrans ================
- // -------------------------------------------
- itrans_4x4 (img, (ColorPlane) (uv + 1), ioff, joff);
- for(jj=0;jj<BLOCK_SIZE;jj++)
- {
- for(ii=0;ii<BLOCK_SIZE;ii++)
- {
- dec_picture->imgUV[uv][j_pos + jj][i_pos + ii] = (imgpel) img->mb_rres[uv+1][jj + joff][ii + ioff]; // construct picture from 4x4 blocks
- }
- }
- }
- }
- } //I4MB
- else if (currMB->mb_type == I8MB)
- {
- itrans_8x8 = (!lossless_qpprime) ? itrans8x8 : Inv_Residual_trans_8x8;
- for (block8x8 = 0; block8x8 < 4; block8x8++)
- {
- //=========== 8x8 BLOCK TYPE ============
- ioff = 8 * (block8x8 & 0x01);
- joff = 8 * (block8x8 >> 1);
- //PREDICTION
- intrapred8x8(img, currMB, (ColorPlane) (uv + 1), block8x8);
- //For residual DPCM
- itrans_8x8(img, currMB, (ColorPlane) (uv + 1), ioff, joff); // use DCT transform and make 8x8 block m7 from prediction block mpr
- for(jj = joff; jj < joff + 8;jj++)
- {
- for(ii = ioff; ii < ioff + 8;ii++)
- {
- dec_picture->imgUV[uv][img->pix_y + jj][img->pix_x + ii] = (imgpel) img->mb_rres[uv+1][jj][ii]; // construct picture from 4x4 blocks
- }
- }
- }
- } //I8MB
- else if ((img->type == P_SLICE) && (currMB->mb_type == PSKIP))
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = MB_BLOCK_SIZE;
- i = 0;
- j = 0;
- pred_dir = LIST_0;
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- mpr = img->mb_pred[uv+1];
- curComp = dec_picture->imgUV[uv];
- for(j = 0; j < img->mb_size[0][1]; j++)
- {
- memcpy(&(curComp[img->pix_y + j][img->pix_x]), &(mpr[j][0]), img->mb_size[0][0] * sizeof(imgpel));
- }
- } //PSKIP
- else if (currMB->mb_type == P16x16)
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = MB_BLOCK_SIZE;
- i = 0;
- j = 0;
- pred_dir = currMB->b8pdir[0];
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- iTransform(img, currMB, (ColorPlane) (uv + 1), need_4x4_transform, smb);
- } //P16x16
- else if (currMB->mb_type == P16x8)
- {
- block_size_x = MB_BLOCK_SIZE;
- block_size_y = 8;
- for (block8x8 = 0; block8x8 < 4; block8x8 += 2)
- {
- i = 0;
- j = block8x8;
- pred_dir = currMB->b8pdir[block8x8];
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- iTransform(img, currMB, (ColorPlane) (uv + 1), need_4x4_transform, smb);
- } //P16x8
- else if (currMB->mb_type == P8x16)
- {
- block_size_x = 8;
- block_size_y = 16;
- for (block8x8 = 0; block8x8 < 2; block8x8 ++)
- {
- i = block8x8<<1;
- j = 0;
- pred_dir = currMB->b8pdir[block8x8];
- assert (pred_dir<=2);
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- iTransform(img, currMB, (ColorPlane) (uv + 1), need_4x4_transform, smb);
- } //P8x16
- else
- {
- // prepare direct modes
- if (img->type==B_SLICE && img->direct_spatial_mv_pred_flag && (IS_DIRECT (currMB) ||
- (IS_P8x8(currMB) && !(currMB->b8mode[0] && currMB->b8mode[1] && currMB->b8mode[2] && currMB->b8mode[3]))))
- prepare_direct_params(currMB, dec_picture, img, pmvl0, pmvl1, &l0_rFrame, &l1_rFrame);
- for (block8x8=0; block8x8<4; block8x8++)
- {
- mv_mode = currMB->b8mode[block8x8];
- pred_dir = currMB->b8pdir[block8x8];
- //if ( mv_mode == SMB8x8 || mv_mode == SMB8x4 || mv_mode == SMB4x8 || mv_mode == SMB4x4 )
- if ( mv_mode != 0 )
- {
- int k_start = (block8x8 << 2);
- int k_inc = (mv_mode == SMB8x4) ? 2 : 1;
- int k_end = (mv_mode == SMB8x8) ? k_start + 1 : ((mv_mode == SMB4x4) ? k_start + 4 : k_start + k_inc + 1);
- block_size_x = ( mv_mode == SMB8x4 || mv_mode == SMB8x8 ) ? SMB_BLOCK_SIZE : BLOCK_SIZE;
- block_size_y = ( mv_mode == SMB4x8 || mv_mode == SMB8x8 ) ? SMB_BLOCK_SIZE : BLOCK_SIZE;
- for (k = k_start; k < k_end; k += k_inc)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- }
- else
- {
- int k_start = (block8x8 << 2);
- int k_end = k_start;
- if (active_sps->direct_8x8_inference_flag)
- {
- block_size_x = SMB_BLOCK_SIZE;
- block_size_y = SMB_BLOCK_SIZE;
- k_end ++;
- }
- else
- {
- block_size_x = BLOCK_SIZE;
- block_size_y = BLOCK_SIZE;
- k_end += BLOCK_MULTIPLE;
- }
- // Prepare mvs (needed for deblocking and mv prediction
- for (k = k_start; k < k_start + BLOCK_MULTIPLE; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- ioff = (i << 2);
- i4 = img->block_x + i;
- joff = (j << 2);
- j4 = img->block_y + j;
- assert (pred_dir<=2);
- if (img->direct_spatial_mv_pred_flag)
- {
- j6 = img->block_y_aff + j;
- //===== DIRECT PREDICTION =====
- if (l0_rFrame >=0)
- {
- if (!l0_rFrame && ((!colocated->moving_block[j6][i4]) && (!listX[LIST_1 + list_offset][0]->is_long_term)))
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_0][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- }
- else
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0] = pmvl0[0];
- dec_picture->motion.mv [LIST_0][j4][i4][1] = pmvl0[1];
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = l0_rFrame;
- }
- }
- else
- {
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = -1;
- dec_picture->motion.mv [LIST_0][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_0][j4][i4][1] = 0;
- }
- if (l1_rFrame >=0)
- {
- if (l1_rFrame==0 && ((!colocated->moving_block[j6][i4]) && (!listX[LIST_1 + list_offset][0]->is_long_term)))
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_1][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = l1_rFrame;
- }
- else
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = pmvl1[0];
- dec_picture->motion.mv [LIST_1][j4][i4][1] = pmvl1[1];
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = l1_rFrame;
- }
- }
- else
- {
- dec_picture->motion.mv [LIST_1][j4][i4][0] = 0;
- dec_picture->motion.mv [LIST_1][j4][i4][1] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = -1;
- }
- if (l0_rFrame < 0 && l1_rFrame < 0)
- {
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- if (dec_picture->motion.ref_idx[LIST_1][j4][i4]==-1)
- {
- direct_pdir = 0;
- ref_idx = (dec_picture->motion.ref_idx[LIST_0][j4][i4] != -1) ? dec_picture->motion.ref_idx[LIST_0][j4][i4] : 0;
- }
- else if (dec_picture->motion.ref_idx[LIST_0][j4][i4]==-1)
- {
- direct_pdir = 1;
- ref_idx = (dec_picture->motion.ref_idx[LIST_1][j4][i4] != -1) ? dec_picture->motion.ref_idx[LIST_1][j4][i4] : 0;
- }
- else
- direct_pdir = 2;
- pred_dir = direct_pdir;
- }
- else
- {
- j6= img->block_y_aff + j;
- refList = (colocated->ref_idx[LIST_0][j6][i4]== -1 ? LIST_1 : LIST_0);
- ref_idx = colocated->ref_idx[refList][j6][i4];
- if(ref_idx==-1) // co-located is intra mode
- {
- for(hv=0; hv<2; hv++)
- {
- dec_picture->motion.mv [LIST_0][j4][i4][hv]=0;
- dec_picture->motion.mv [LIST_1][j4][i4][hv]=0;
- }
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = 0;
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- else // co-located skip or inter mode
- {
- int mapped_idx=0;
- int iref;
- {
- for (iref=0;iref<imin(img->num_ref_idx_l0_active,listXsize[LIST_0 + list_offset]);iref++)
- {
- if(img->structure==0 && curr_mb_field==0)
- {
- // If the current MB is a frame MB and the colocated is from a field picture,
- // then the colocated->ref_pic_id may have been generated from the wrong value of
- // frame_poc if it references it's complementary field, so test both POC values
- if(listX[0][iref]->top_poc*2 == colocated->ref_pic_id[refList][j6][i4] || listX[0][iref]->bottom_poc*2 == colocated->ref_pic_id[refList][j6][i4])
- {
- mapped_idx=iref;
- break;
- }
- else //! invalid index. Default to zero even though this case should not happen
- mapped_idx=INVALIDINDEX;
- continue;
- }
- if (dec_picture->ref_pic_num[img->current_slice_nr][LIST_0 + list_offset][iref]==colocated->ref_pic_id[refList][j6][i4])
- {
- mapped_idx=iref;
- break;
- }
- else //! invalid index. Default to zero even though this case should not happen
- {
- mapped_idx=INVALIDINDEX;
- }
- }
- if (INVALIDINDEX == mapped_idx)
- {
- error("temporal direct errorncolocated block has ref that is unavailable",-1111);
- }
- }
- mv_scale = img->mvscale[LIST_0 + list_offset][mapped_idx];
- //! In such case, an array is needed for each different reference.
- if (mv_scale == 9999 || listX[LIST_0+list_offset][mapped_idx]->is_long_term)
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0]=colocated->mv[refList][j6][i4][0];
- dec_picture->motion.mv [LIST_0][j4][i4][1]=colocated->mv[refList][j6][i4][1];
- dec_picture->motion.mv [LIST_1][j4][i4][0]=0;
- dec_picture->motion.mv [LIST_1][j4][i4][1]=0;
- }
- else
- {
- dec_picture->motion.mv [LIST_0][j4][i4][0] = (short) ((mv_scale * colocated->mv[refList][j6][i4][0] + 128 ) >> 8);
- dec_picture->motion.mv [LIST_0][j4][i4][1] = (short) ((mv_scale * colocated->mv[refList][j6][i4][1] + 128 ) >> 8);
- dec_picture->motion.mv [LIST_1][j4][i4][0] = (short) (dec_picture->motion.mv[LIST_0][j4][i4][0] - colocated->mv[refList][j6][i4][0]);
- dec_picture->motion.mv [LIST_1][j4][i4][1] = (short) (dec_picture->motion.mv[LIST_0][j4][i4][1] - colocated->mv[refList][j6][i4][1]);
- }
- dec_picture->motion.ref_idx[LIST_0][j4][i4] = (char) mapped_idx; //listX[1][0]->ref_idx[refList][j4][i4];
- dec_picture->motion.ref_idx[LIST_1][j4][i4] = 0;
- }
- }
- // store reference picture ID determined by direct mode
- dec_picture->motion.ref_pic_id[LIST_0][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_0 + list_offset][(short)dec_picture->motion.ref_idx[LIST_0][j4][i4]];
- dec_picture->motion.ref_pic_id[LIST_1][j4][i4] = dec_picture->ref_pic_num[img->current_slice_nr][LIST_1 + list_offset][(short)dec_picture->motion.ref_idx[LIST_1][j4][i4]];
- }
- for (k = k_start; k < k_end; k ++)
- {
- i = (decode_block_scan[k] & 3);
- j = ((decode_block_scan[k] >> 2) & 3);
- perform_mc((ColorPlane) (uv + 1), dec_picture, img, pred_dir, i, j, list_offset, block_size_x, block_size_y, curr_mb_field);
- }
- }
- }
- iTransform(img, currMB, (ColorPlane) (uv + 1), need_4x4_transform, smb);
- }
- }
- }
- return 0;
- }
- /*!
- ************************************************************************
- * brief
- * change target plane
- * for 4:4:4 Independent mode
- ************************************************************************
- */
- void change_plane_JV( int nplane )
- {
- img->colour_plane_id = nplane;
- img->mb_data = img->mb_data_JV[nplane];
- dec_picture = dec_picture_JV[nplane];
- Co_located = Co_located_JV[nplane];
- }
- /*!
- ************************************************************************
- * brief
- * make frame picture from each plane data
- * for 4:4:4 Independent mode
- ************************************************************************
- */
- void make_frame_picture_JV()
- {
- int uv, line;
- int nsize;
- int nplane;
- dec_picture = dec_picture_JV[0];
- // Copy Storable Params
- for( nplane=0; nplane<MAX_PLANE; nplane++ )
- {
- copy_storable_param_JV( &dec_picture->JVmotion[nplane], &dec_picture_JV[nplane]->motion );
- }
- // This could be done with pointers and seems not necessary
- for( uv=0; uv<2; uv++ )
- {
- for( line=0; line<img->height; line++ )
- {
- nsize = sizeof(imgpel) * img->width;
- memcpy( dec_picture->imgUV[uv][line], dec_picture_JV[uv+1]->imgY[line], nsize );
- }
- free_storable_picture(dec_picture_JV[uv+1]);
- }
- }