/**
This function is used to decode the macroblock information in a B slice.
*/
int MbPredBCabacSvc ( CABACContext *c, unsigned char *state, SLICE *Slice, RESIDU *CurrResidu, DATA *macroblock, 
					  short mv_cache_l0[][2], short ref_cache_l0[] , short mv_cache_l1[][2], short ref_cache_l1[])
{

	int index = 14 * CurrResidu -> Mode;

	//Get MotionPred flag
	if(GetCabacSVCPMotionPred(c, state, Slice, macroblock, macroblock -> MotionPredL0, CurrResidu -> InCropWindow, Pred_L1, 0)){
		//Error detected
		return 1;
	}
	
	//Get MotionPred flag
	if(GetCabacSVCPMotionPred(c, state, Slice, macroblock, macroblock -> MotionPredL1, CurrResidu -> InCropWindow, Pred_L0, 1)){
		//Error detected
		return 1;
	}
	

	if(GetCabacBRefList(c, state, macroblock -> RefIdxL0, ref_cache_l0, macroblock -> MotionPredL0, CurrResidu -> Mode, 
		Slice -> num_RefIdxL0_active_minus1, macroblock -> MbPartPredMode, Pred_L1, index)){
			return 1;
	}

	if(GetCabacBRefList(c, state, macroblock -> RefIdxL1, ref_cache_l1, macroblock -> MotionPredL1, CurrResidu -> Mode, 
		Slice -> num_RefIdxL1_active_minus1, macroblock -> MbPartPredMode, Pred_L0, index)){
			return 1;
	}

	if (CurrResidu -> Mode == 3){
		// Pred_L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadCabacMotionVector(c, state, mv_cache_l0, &macroblock -> MvdL0[0][0], 3, 12);
		}

		// Pred_L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadCabacMotionVector(c, state, mv_cache_l1, &macroblock -> MvdL1[0][0], 3, 12);
		}
	}else if (CurrResidu -> Mode == 1){
		//Recovery of of the motion vector for the frame P
		// mode == 1: 8x16
	
		//L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadCabacMotionVector(c, state, mv_cache_l0, &macroblock -> MvdL0[0][0], 1, 12);
		}	

		if ( macroblock -> MbPartPredMode [1] != Pred_L1 ) {
			ReadCabacMotionVector(c, state, mv_cache_l0, &macroblock -> MvdL0[4][0], 1, 14);
		}


		//L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadCabacMotionVector(c, state, mv_cache_l1, &macroblock -> MvdL1[0][0], 1, 12);
		}

		if ( macroblock -> MbPartPredMode [1] != Pred_L0 ) {
			ReadCabacMotionVector(c, state, mv_cache_l1, &macroblock -> MvdL1[4][0], 1, 14);
		}
	}else{
		//L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadCabacMotionVector(c, state, mv_cache_l0, &macroblock -> MvdL0[0][0], 2, 12);
		}

		if ( macroblock -> MbPartPredMode [1] != Pred_L1 ) {
			ReadCabacMotionVector(c, state, mv_cache_l0, &macroblock -> MvdL0[4][0], 2, 28);		
		}

		//L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadCabacMotionVector(c, state, mv_cache_l1, &macroblock -> MvdL1[0][0], 2, 12);
		}
		if ( macroblock -> MbPartPredMode [1] != Pred_L0 ) {
			ReadCabacMotionVector(c, state, mv_cache_l1, &macroblock -> MvdL1[4][0], 2, 28);		
		}
	}

	return 0;
}
Exemple #2
0
/**
Motion vector and reference list decoding process when cabac entropy for a B16x16 macroblock
*/
char mb_pred_cabac ( CABACContext *c, unsigned char *state, SLICE *slice, RESIDU *CurrResidu, DATA *macroblock, 
					short mv_cache_l0[][2], short mv_cache_l1[][2], short *ref_cache_l0, short *ref_cache_l1, 
					short mvl0_cache[][2], short mvl1_cache[][2], short *refl0_cache, short *refl1_cache)
{

	int index = 14 * CurrResidu -> Mode;
	char RefIdxL0[2] = {0, 0};
	char RefIdxL1[2] = {0, 0};

	//Reference index for L0
	if(GetCabacBRefList(c, state, RefIdxL0, ref_cache_l0, RefIdxL0, CurrResidu -> Mode, slice -> num_RefIdxL0_active_minus1, 
		macroblock -> MbPartPredMode, Pred_L1, index)){
			refl0_cache [12] = refl0_cache [14] = refl0_cache [28] = refl0_cache [30] = 0;
			refl1_cache [12] = refl1_cache [14] = refl1_cache [28] = refl1_cache [30] = 0;
			return 1;
	}

	//Reference index for L0
	if(GetCabacBRefList(c, state, RefIdxL1, ref_cache_l1, RefIdxL1, CurrResidu -> Mode, slice -> num_RefIdxL1_active_minus1, 
		macroblock -> MbPartPredMode, Pred_L0, index)){
			refl1_cache [12] = refl1_cache [14] = refl1_cache [28] = refl1_cache [30] = 0;
			return 1;
	}


	if (CurrResidu -> Mode == 3){
		// Pred_L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadAndComputeCabac16x16MotionVector(c, state, RefIdxL0, refl0_cache, mv_cache_l0, mvl0_cache);
		}else {
			refl0_cache[14] = refl0_cache[30] = -1;
		}

		// Pred_L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadAndComputeCabac16x16MotionVector(c, state, RefIdxL1, refl1_cache, mv_cache_l1, mvl1_cache);
		}else {
			refl1_cache[14] = refl1_cache[30] = -1;
		}
	}else if (CurrResidu -> Mode == 1){
		//Recovery of of the motion vector for the frame P
		// mode == 1: 8x16
	
		//L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadAndComputeCabac8x16MotionVector(c, state, RefIdxL0, refl0_cache, mv_cache_l0, mvl0_cache, 12);
		}	

		if ( macroblock -> MbPartPredMode [1] != Pred_L1 ) {
			ReadAndComputeCabac8x16MotionVector(c, state, &RefIdxL0[1], refl0_cache, mv_cache_l0, mvl0_cache, 14);
		}else{
			refl0_cache[14] = refl0_cache[30] = -1;
		}


		//L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadAndComputeCabac8x16MotionVector(c, state, RefIdxL1, refl1_cache, mv_cache_l1, mvl1_cache, 12);
		}

		if ( macroblock -> MbPartPredMode [1] != Pred_L0 ) {
			ReadAndComputeCabac8x16MotionVector(c, state, &RefIdxL1[1], refl1_cache, mv_cache_l1, mvl1_cache, 14);
		}else{
			refl1_cache[14] = refl1_cache[30] = -1;
		}
	}else{
		//L0 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L1 ) {
			ReadAndComputeCabac16x8MotionVector(c, state, RefIdxL0, refl0_cache, mv_cache_l0, mvl0_cache, 12);
		}else{
			refl0_cache[14] = -1;
		}

		if ( macroblock -> MbPartPredMode [1] != Pred_L1 ) {
			ReadAndComputeCabac16x8MotionVector(c, state, &RefIdxL0[1], refl0_cache, mv_cache_l0, mvl0_cache, 28);		
		}else{
			refl0_cache[30] = -1;
		}

		//L1 prediction
		if ( macroblock -> MbPartPredMode [0] != Pred_L0 ) {
			ReadAndComputeCabac16x8MotionVector(c, state, RefIdxL1, refl1_cache, mv_cache_l1, mvl1_cache, 12);
		}else{
			refl1_cache[14] = -1;
		}
		if ( macroblock -> MbPartPredMode [1] != Pred_L0 ) {
			ReadAndComputeCabac16x8MotionVector(c, state, &RefIdxL1[1], refl1_cache, mv_cache_l1, mvl1_cache, 28);		
		}else{
			refl1_cache[30] = -1;
		}
	}
	return 0;
}