Ejemplo n.º 1
0
void
MBPrediction(FRAMEINFO * frame,
			 uint32_t x,
			 uint32_t y,
			 uint32_t mb_width,
			 int16_t qcoeff[6 * 64],
			 const int bound)
{

	int32_t j;
	int32_t iDcScaler, iQuant;
	int S = 0;
	int16_t predictors[6][8];

	MACROBLOCK *pMB = &frame->mbs[x + y * mb_width];
    iQuant = pMB->quant;

	if ((pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q)) {

		for (j = 0; j < 6; j++) {
			iDcScaler = get_dc_scaler(iQuant, j<4);

			predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],
						 iQuant, iDcScaler, predictors[j], bound);

			if ((frame->vop_flags & XVID_VOP_HQACPRED))
				S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);
			else
				S += calc_acdc_coeff(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);

		}

		if (S<=0) {				/* dont predict */
			for (j = 0; j < 6; j++)
				pMB->acpred_directions[j] = 0;
		}else{
			for (j = 0; j < 6; j++)
				apply_acdc(pMB, j, &qcoeff[j * 64], predictors[j]);
		}

		pMB->cbp = calc_cbp(qcoeff);
	}
}
Ejemplo n.º 2
0
void
MBPrediction(FRAMEINFO * frame,
			 uint32_t x,
			 uint32_t y,
			 uint32_t mb_width,
			 int16_t qcoeff[6 * 64])
{

	int32_t j;
	int32_t iDcScaler, iQuant = frame->quant;
	int32_t S = 0;
	int16_t predictors[6][8];

	MACROBLOCK *pMB = &frame->mbs[x + y * mb_width];

	if ((pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q)) {

		for (j = 0; j < 6; j++) {
			iDcScaler = get_dc_scaler(iQuant, (j < 4) ? 1 : 0);

			predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],
						 iQuant, iDcScaler, predictors[j], 0);

			S += calc_acdc(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);

		}

		if (S < 0)				/* dont predict */
		{
			for (j = 0; j < 6; j++) {
				pMB->acpred_directions[j] = 0;
			}
		} else {
			for (j = 0; j < 6; j++) {
				apply_acdc(pMB, j, &qcoeff[j * 64], predictors[j]);
			}
		}
		pMB->cbp = calc_cbp(qcoeff);
	}

}
Ejemplo n.º 3
0
void
decoder_mbintra(DECODER * dec,
                MACROBLOCK * pMB,
                const uint32 x_pos,
                const uint32 y_pos,
                const uint32 acpred_flag,
                const uint32 cbp,
                Bitstream * bs,
                const uint32 quant, const uint32 intra_dc_threshold)
{
    uint32  stride = dec->edged_width;
    uint32  stride2 = stride / 2;
    uint32  next_block = stride * 8;
    uint32  i,j;
    uint32  iQuant = pMB->quant;
    uint8  *pY_Cur, *pU_Cur, *pV_Cur;

    pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
    pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
    pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);

    memset(block, 0, 6 * 64 * sizeof(int16));
	int16* tmpBlock = NULL;
    for (i = 0; i < 6; i++)
    {
        uint32  iDcScaler = get_dc_scaler(iQuant, (i < 4) ? 1 : 0);
        int16   predictors[8];
        int     start_coeff;

        start_timer();
        predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i,
                     &block[i * 64], iQuant, iDcScaler, predictors,
                     dec->slice);
        if (!acpred_flag)
        {
            pMB->acpred_directions[i] = 0;
        }
        stop_prediction_timer();

        if (quant < intra_dc_threshold)
        {
            int     dc_size;
            int     dc_dif;

            dc_size =
                i < 4 ? get_dc_size_lum(bs) : get_dc_size_chrom(bs);
            dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0;

            if (dc_size > 8)
            {
                BitstreamSkip(bs, 1);   // marker
            }

            block[i * 64] = dc_dif;
            start_coeff = 1;
        }
        else
        {
            start_coeff = 0;
        }

        start_timer();
        if (cbp & (1 << (5 - i)))       // coded
        {
            get_intra_block(bs, &block[i * 64],
                            pMB->acpred_directions[i], start_coeff);
        }
        stop_coding_timer();

        start_timer();
        add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors);
        stop_prediction_timer();

        start_timer();
        dequant_intra(&data[i * 64], &block[i * 64], iQuant, iDcScaler);
        stop_iquant_timer();

        /*start_timer();
		idct(&data[i * 64]);
        stop_idct_timer();*/
		
		if(tmpBlock!=NULL)
		{
			start_timer();
			idct_dual(tmpBlock, &data[i * 64]);
			stop_idct_timer();
			tmpBlock = NULL;
		}
		else
		{
			tmpBlock = &data[i * 64];
		}
    }

    start_timer();
    transfer_16to8copy(pY_Cur, &data[0 * 64], stride);
    transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);
    transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride);
    transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride);
    transfer_16to8copy(pU_Cur, &data[4 * 64], stride2);
    transfer_16to8copy(pV_Cur, &data[5 * 64], stride2);
    stop_transfer_timer();

#if 0
	printf("(%d,%d)\n",x_pos,y_pos);
	printf("pY_Cur = [\n");
	for (j = 0; j < 8; j++)
        for (i = 0; i < 8; i++)
			printf(((i+1)%8)? "%5d " : "%5d\n", pY_Cur[j * stride + i]);
	printf("\n");
	printf("pY_Cur + 8 = [\n");
	for (j = 0; j < 8; j++)
        for (i = 0; i < 8; i++)
			printf(((i+1)%8)? "%5d " : "%5d\n", (pY_Cur+8)[j * stride + i]);
	printf("\n");
	printf("pY_Cur+ next_block = [\n");
	for (j = 0; j < 8; j++)
        for (i = 0; i < 8; i++)
			printf(((i+1)%8)? "%5d " : "%5d\n", (pY_Cur+ next_block)[j * stride + i]);
	printf("\n");
	printf("pY_Cur+ next_block +8= [\n");
	for (j = 0; j < 8; j++)
        for (i = 0; i < 8; i++)
			printf(((i+1)%8)? "%5d " : "%5d\n", (pY_Cur+ next_block+8)[j * stride + i]);
	printf("\n");
#endif
}