コード例 #1
0
ファイル: quant_h263.c プロジェクト: JERUKA9/ffdshow-tryouts
uint32_t
quant_h263_intra_c(int16_t * coeff,
				   const int16_t * data,
				   const uint32_t quant,
				   const uint32_t dcscalar,
				   const uint16_t * mpeg_quant_matrices)
{
	const uint32_t mult = multipliers[quant];
	const uint16_t quant_m_2 = quant << 1;
	int i;

	coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar);

	for (i = 1; i < 64; i++) {
		int16_t acLevel = data[i];

		if (acLevel < 0) {
			acLevel = -acLevel;
			if (acLevel < quant_m_2) {
				coeff[i] = 0;
				continue;
			}
			acLevel = (acLevel * mult) >> SCALEBITS;
			coeff[i] = -acLevel;
		} else {
			if (acLevel < quant_m_2) {
コード例 #2
0
ファイル: mbprediction.c プロジェクト: headhsu2568/codejam
static int __inline
rescale(int predict_quant,
		int current_quant,
		int coeff)
{
	return (coeff != 0) ? DIV_DIV((coeff) * (predict_quant),
								  (current_quant)) : 0;
}
コード例 #3
0
ファイル: quant_h263_altivec.c プロジェクト: roozbeh/openCU
uint32_t
quant_h263_intra_altivec_c(int16_t *coeff,
                                    int16_t *data,
                                    const uint32_t quant,
                                    const uint32_t dcscalar,
                                    const uint16_t *mpeg_quant_matrices)
{
    vector unsigned char zerovec;
    vector unsigned short mult;
    vector unsigned short quant_m_2;
    vector signed short acLevel;
    
    register vector unsigned int even;
    register vector unsigned int odd;
    
    vector bool short zero_mask;
    vector bool short m2_mask;
    
    register int16_t *origin_coeff = coeff;
    register int16_t *origin_data = data;

#ifdef DEBUG
    if(((unsigned)coeff) & 15)
        fprintf(stderr, "quant_h263_intra_altivec_c:incorrect align, coeff: %lx\n", (long)coeff);
#endif
    
    zerovec = vec_splat_u8(0);
    
    *((unsigned short*)&mult) = (unsigned short)multipliers[quant];
    mult = vec_splat(mult, 0);
    
    *((unsigned short*)&quant_m_2) = (unsigned short)quant;
    quant_m_2 = vec_splat(quant_m_2, 0);
    quant_m_2 = vec_sl(quant_m_2, vec_splat_u16(1));
    
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    QUANT_H263_INTRA_ALTIVEC();
    
    // noch erstes setzen
    origin_coeff[0] = DIV_DIV(origin_data[0], (int32_t)dcscalar);
    
    return 0;
}
コード例 #4
0
ファイル: mbprediction.c プロジェクト: headhsu2568/codejam
void
predict_acdc(MACROBLOCK * pMBs,
			 uint32_t x,
			 uint32_t y,
			 uint32_t mb_width,
			 uint32_t block,
			 int16_t qcoeff[64],
			 uint32_t current_quant,
			 int32_t iDcScaler,
			 int16_t predictors[8],
			const int bound)

{
	const int mbpos = (y * mb_width) + x;
	int16_t *left, *top, *diag, *current;

	int32_t left_quant = current_quant;
	int32_t top_quant = current_quant;

	const int16_t *pLeft = default_acdc_values;
	const int16_t *pTop = default_acdc_values;
	const int16_t *pDiag = default_acdc_values;

	uint32_t index = x + y * mb_width;	/* current macroblock */
	int *acpred_direction = &pMBs[index].acpred_directions[block];
	uint32_t i;

	left = top = diag = current = 0;

	/* grab left,top and diag macroblocks */

	/* left macroblock  */

	if (x && mbpos >= bound + 1  &&
		(pMBs[index - 1].mode == MODE_INTRA ||
		 pMBs[index - 1].mode == MODE_INTRA_Q)) {

		left = pMBs[index - 1].pred_values[0];
		left_quant = pMBs[index - 1].quant;
	}
	/* top macroblock */

	if (mbpos >= bound + (int)mb_width &&
		(pMBs[index - mb_width].mode == MODE_INTRA ||
		 pMBs[index - mb_width].mode == MODE_INTRA_Q)) {

		top = pMBs[index - mb_width].pred_values[0];
		top_quant = pMBs[index - mb_width].quant;
	}
	/* diag macroblock  */

	if (x && mbpos >= bound + (int)mb_width + 1 &&
		(pMBs[index - 1 - mb_width].mode == MODE_INTRA ||
		 pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q)) {

		diag = pMBs[index - 1 - mb_width].pred_values[0];
	}

	current = pMBs[index].pred_values[0];

	/* now grab pLeft, pTop, pDiag _blocks_  */

	switch (block) {

	case 0:
		if (left)
			pLeft = left + MBPRED_SIZE;

		if (top)
			pTop = top + (MBPRED_SIZE << 1);

		if (diag)
			pDiag = diag + 3 * MBPRED_SIZE;

		break;

	case 1:
		pLeft = current;
		left_quant = current_quant;

		if (top) {
			pTop = top + 3 * MBPRED_SIZE;
			pDiag = top + (MBPRED_SIZE << 1);
		}
		break;

	case 2:
		if (left) {
			pLeft = left + 3 * MBPRED_SIZE;
			pDiag = left + MBPRED_SIZE;
		}

		pTop = current;
		top_quant = current_quant;

		break;

	case 3:
		pLeft = current + (MBPRED_SIZE << 1);
		left_quant = current_quant;

		pTop = current + MBPRED_SIZE;
		top_quant = current_quant;

		pDiag = current;

		break;

	case 4:
		if (left)
			pLeft = left + (MBPRED_SIZE << 2);
		if (top)
			pTop = top + (MBPRED_SIZE << 2);
		if (diag)
			pDiag = diag + (MBPRED_SIZE << 2);
		break;

	case 5:
		if (left)
			pLeft = left + 5 * MBPRED_SIZE;
		if (top)
			pTop = top + 5 * MBPRED_SIZE;
		if (diag)
			pDiag = diag + 5 * MBPRED_SIZE;
		break;
	}

	/*  determine ac prediction direction & ac/dc predictor */
	/*  place rescaled ac/dc predictions into predictors[] for later use */

	if (ABS(pLeft[0] - pDiag[0]) < ABS(pDiag[0] - pTop[0])) {
		*acpred_direction = 1;	/* vertical */
		predictors[0] = (int16_t)(DIV_DIV(pTop[0], iDcScaler));
		for (i = 1; i < 8; i++) {
			predictors[i] = rescale(top_quant, current_quant, pTop[i]);
		}
	} else {
		*acpred_direction = 2;	/* horizontal */
		predictors[0] = (int16_t)(DIV_DIV(pLeft[0], iDcScaler));
		for (i = 1; i < 8; i++) {
			predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]);
		}
	}
}
コード例 #5
0
void __inline
predict_acdc_part2(MACROBLOCK * pMBs,
			 uint32_t x,
			 uint32_t y,
			 uint32_t mb_width,
			 uint32_t block,
			 int16_t qcoeff[64],
			 uint32_t current_quant,
			 int32_t iDcScaler,
			 int16_t predictors[8],
		   //const int bound,
	     int16_t *direct[],
	     int32_t left_quant,
		   int32_t top_quant, int acpredflag)
{
  //const int mbpos = (y * mb_width) + x;
	int16_t *left, *top, *diag, *current;

	//int32_t left_quant = current_quant;
	//int32_t top_quant = current_quant;

	const int16_t *pLeft = default_acdc_values;
	const int16_t *pTop = default_acdc_values;
	const int16_t *pDiag = default_acdc_values;

	uint32_t index = x + y * mb_width;	/* current macroblock */
	int *acpred_direction = &pMBs[index].acpred_directions[block];
	uint32_t i;

	*acpred_direction = 0;
	//left = top = diag = current = NULL;
	left = direct[0];
	top  = direct[1];
	diag = direct[2];
	current = direct[3];
	/* now grab pLeft, pTop, pDiag _blocks_ */

	switch (block) {

	case 0:
		if (left)
			pLeft = left + MBPRED_SIZE;

		if (top)
			pTop = top + (MBPRED_SIZE << 1);

		if (diag)
			pDiag = diag + 3 * MBPRED_SIZE;

		break;

	case 1:
		pLeft = current;
		left_quant = current_quant;

		if (top) {
			pTop = top + 3 * MBPRED_SIZE;
			pDiag = top + (MBPRED_SIZE << 1);
		}
		break;

	case 2:
		if (left) {
			pLeft = left + 3 * MBPRED_SIZE;
			pDiag = left + MBPRED_SIZE;
		}

		pTop = current;
		top_quant = current_quant;

		break;

	case 3:
		pLeft = current + (MBPRED_SIZE << 1);
		left_quant = current_quant;

		pTop = current + MBPRED_SIZE;
		top_quant = current_quant;

		pDiag = current;

		break;

	case 4:
		if (left)
			pLeft = left + (MBPRED_SIZE << 2);
		if (top)
			pTop = top + (MBPRED_SIZE << 2);
		if (diag)
			pDiag = diag + (MBPRED_SIZE << 2);
		break;

	case 5:
		if (left)
			pLeft = left + 5 * MBPRED_SIZE;
		if (top)
			pTop = top + 5 * MBPRED_SIZE;
		if (diag)
			pDiag = diag + 5 * MBPRED_SIZE;
		break;
	}

	/* determine ac prediction direction & ac/dc predictor place rescaled ac/dc
	 * predictions into predictors[] for later use */
	if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) {
		
		predictors[0] = DIV_DIV(pTop[0], iDcScaler);
		if(acpredflag)
		  {
		    *acpred_direction = 1;	/* vertical */
		    for (i = 1; i < 8; i++) {
		      predictors[i] = rescale(top_quant, current_quant, pTop[i]);
		    }
		  }
		    
	} else {
	
		predictors[0] = DIV_DIV(pLeft[0], iDcScaler);
		if(acpredflag)
		  {
		    *acpred_direction = 2;	/* horizontal */
		    for (i = 1; i < 8; i++) {
		      predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]);
		    }
		  }
	}
}
コード例 #6
0
ファイル: mbprediction.c プロジェクト: amon0424/mong_mpeg4
void
predict_acdc(MACROBLOCK * pMBs,
             uint32 x, uint32 y, uint32 mb_width,
             uint32 block,
             int16 qcoeff[64],
             uint32 current_quant,
             int32 iDcScaler, int16 predictors[8], xint * slice)
{
    int16  *left, *top, *diag, *current;

    int32   left_quant = current_quant;
    int32   top_quant = current_quant;

    const int16 *pLeft = default_acdc_values;
    const int16 *pTop = default_acdc_values;
    const int16 *pDiag = default_acdc_values;

    xint    index = x + y * mb_width;   // current macroblock
    xint    slice_idx = index + y + mb_width + 2;
    xint   *acpred_direction = &pMBs[index].acpred_directions[block];
    xint    i;

    left = top = diag = current = 0;

    // grab left,top and diag macroblocks

    // left macroblock
    if ((slice[slice_idx - 1] == slice[slice_idx]) &&
        (pMBs[index - 1].mode == MODE_INTRA
         || pMBs[index - 1].mode == MODE_INTRA_Q))
    {
        left = pMBs[index - 1].pred_values[0];
        left_quant = pMBs[index - 1].quant;
        //DEBUGI("LEFT", *(left+MBPRED_SIZE));
    }

    // top macroblock
    if ((slice[slice_idx - mb_width - 1] == slice[slice_idx])
        && (pMBs[index - mb_width].mode == MODE_INTRA
            || pMBs[index - mb_width].mode == MODE_INTRA_Q))
    {
        top = pMBs[index - mb_width].pred_values[0];
        top_quant = pMBs[index - mb_width].quant;
    }

    // diag macroblock
    if ((slice[slice_idx - 2 - mb_width] == slice[slice_idx]) &&
        (pMBs[index - 1 - mb_width].mode == MODE_INTRA ||
         pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q))
    {
        diag = pMBs[index - 1 - mb_width].pred_values[0];
    }

    current = pMBs[index].pred_values[0];

    // now grab pLeft, pTop, pDiag _blocks_

    switch (block)
    {
    case 0:
        if (left)
            pLeft = left + MBPRED_SIZE;
        if (top)
            pTop = top + (MBPRED_SIZE << 1);
        if (diag)
            pDiag = diag + 3 * MBPRED_SIZE;
        break;

    case 1:
        pLeft = current;
        left_quant = current_quant;
        if (top)
        {
            pTop = top + 3 * MBPRED_SIZE;
            pDiag = top + (MBPRED_SIZE << 1);
        }
        break;

    case 2:
        if (left)
        {
            pLeft = left + 3 * MBPRED_SIZE;
            pDiag = left + MBPRED_SIZE;
        }
        pTop = current;
        top_quant = current_quant;
        break;

    case 3:
        pLeft = current + (MBPRED_SIZE << 1);
        left_quant = current_quant;
        pTop = current + MBPRED_SIZE;
        top_quant = current_quant;
        pDiag = current;
        break;

    case 4:
        if (left)
            pLeft = left + (MBPRED_SIZE << 2);
        if (top)
            pTop = top + (MBPRED_SIZE << 2);
        if (diag)
            pDiag = diag + (MBPRED_SIZE << 2);
        break;

    case 5:
        if (left)
            pLeft = left + 5 * MBPRED_SIZE;
        if (top)
            pTop = top + 5 * MBPRED_SIZE;
        if (diag)
            pDiag = diag + 5 * MBPRED_SIZE;
        break;
    }

    //      determine ac prediction direction & ac/dc predictor
    //      place rescaled ac/dc predictions into predictors[] for later use

    if (ABS(pLeft[0] - pDiag[0]) < ABS(pDiag[0] - pTop[0]))
    {
        *acpred_direction = 1;  // vertical
        predictors[0] = DIV_DIV(pTop[0], (int16) iDcScaler);
        for (i = 1; i < 8; i++)
        {
            predictors[i] = rescale(top_quant, current_quant, pTop[i]);
        }
    }
    else
    {
        *acpred_direction = 2;  // horizontal
        predictors[0] = DIV_DIV(pLeft[0], (int16) iDcScaler);
        for (i = 1; i < 8; i++)
        {
            predictors[i] =
                rescale(left_quant, current_quant, pLeft[i + 7]);
        }
    }
}