Ejemplo n.º 1
0
/*!
***********************************************************************
* \brief
*    makes and returns 4x4 DC prediction mode
*
* \param currMB
*    current MB structure
* \param pl
*    color plane
* \param ioff
*    pixel offset X within MB
* \param joff
*    pixel offset Y within MB
* \return
*    DECODING_OK   decoding of intra prediction mode was successful            \n
*
***********************************************************************
*/
static int intra4x4_dc_pred_mbaff(Macroblock *currMB, 
	ColorPlane pl,               
	int ioff,
	int joff)
{
	Slice *currSlice = currMB->p_Slice;
	VideoParameters *p_Vid = currMB->p_Vid;  

	int i,j;
	int s0 = 0;  
	imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;

	PixelPos pix_a[4], pix_b;

	int block_available_up;
	int block_available_left;  

	imgpel **mb_pred = currSlice->mb_pred[pl];    

	for (i=0;i<4;++i)
	{
		getAffNeighbour(currMB, ioff - 1, joff + i, p_Vid->mb_size[IS_LUMA], &pix_a[i]);
	}
	getAffNeighbour(currMB, ioff    , joff -1 , p_Vid->mb_size[IS_LUMA], &pix_b);

	if (p_Vid->active_pps->constrained_intra_pred_flag)
	{
		for (i=0, block_available_left=1; i<4;++i)
			block_available_left  &= pix_a[i].available ? currSlice->intra_block[pix_a[i].mb_addr]: 0;
		block_available_up       = pix_b.available ? currSlice->intra_block [pix_b.mb_addr] : 0;
	}
	else
	{
		block_available_left     = pix_a[0].available;
		block_available_up       = pix_b.available;
	}

	// form predictor pels
	if (block_available_up)
	{
		s0 += imgY[pix_b.pos_y][pix_b.pos_x + 0];
		s0 += imgY[pix_b.pos_y][pix_b.pos_x + 1];
		s0 += imgY[pix_b.pos_y][pix_b.pos_x + 2];
		s0 += imgY[pix_b.pos_y][pix_b.pos_x + 3];
	}

	if (block_available_left)
	{
		s0 += imgY[pix_a[0].pos_y][pix_a[0].pos_x];
		s0 += imgY[pix_a[1].pos_y][pix_a[1].pos_x];
		s0 += imgY[pix_a[2].pos_y][pix_a[2].pos_x];
		s0 += imgY[pix_a[3].pos_y][pix_a[3].pos_x];
	}

	if (block_available_up && block_available_left)
	{
		// no edge
		s0 = (s0 + 4)>>3;
	}
Ejemplo n.º 2
0
/*!
 ***********************************************************************
 * \brief
 *    makes and returns 16x16 DC prediction mode
 *
 * \return
 *    DECODING_OK   decoding of intra prediction mode was successful            \n
 *
 ***********************************************************************
 */
static int intra16x16_dc_pred_mbaff(Macroblock *currMB, ColorPlane pl)
{
    Slice *currSlice = currMB->p_Slice;
    VideoParameters *p_Vid = currMB->p_Vid;

    int s0 = 0, s1 = 0, s2 = 0;

    int i,j;

    imgpel **imgY = (pl) ? currSlice->dec_picture->imgUV[pl - 1] : currSlice->dec_picture->imgY;
    imgpel **mb_pred = &(currSlice->mb_pred[pl][0]);

    PixelPos b;          //!< pixel position p(0,-1)
    PixelPos left[17];    //!< pixel positions p(-1, -1..15)

    int up_avail, left_avail;

    s1=s2=0;

    for (i=0; i<17; ++i)
    {
        getAffNeighbour(currMB, -1,  i-1, p_Vid->mb_size[IS_LUMA], &left[i]);
    }
    getAffNeighbour(currMB,    0,   -1, p_Vid->mb_size[IS_LUMA], &b);

    if (!p_Vid->active_pps->constrained_intra_pred_flag)
    {
        up_avail      = b.available;
        left_avail    = left[1].available;
    }
    else
    {
        up_avail      = b.available ? currSlice->intra_block[b.mb_addr] : 0;
        for (i = 1, left_avail = 1; i < 17; ++i)
            left_avail  &= left[i].available ? currSlice->intra_block[left[i].mb_addr]: 0;
    }

    for (i = 0; i < MB_BLOCK_SIZE; ++i)
    {
        if (up_avail)
            s1 += imgY[b.pos_y][b.pos_x+i];    // sum hor pix
        if (left_avail)
            s2 += imgY[left[i + 1].pos_y][left[i + 1].pos_x];    // sum vert pix
    }
    if (up_avail && left_avail)
        s0 = (s1 + s2 + 16)>>5;       // no edge
    else if (!up_avail && left_avail)