www.pudn.com > rm52c.rar > b_frame.c


/* 
*********************************************************************** 
* COPYRIGHT AND WARRANTY INFORMATION 
* 
* Copyright 2003, Advanced Audio Video Coding Standard, Part II 
* 
* DISCLAIMER OF WARRANTY 
* 
* These software programs are available to the users without any 
* license fee or royalty on an "as is" basis. The AVS disclaims 
* any and all warranties, whether express, implied, or statutory, 
* including any implied warranties of merchantability or of fitness 
* for a particular purpose. In no event shall the contributors or  
* the AVS be liable for any incidental, punitive, or consequential 
* damages of any kind whatsoever arising from the use of this program. 
* 
* This disclaimer of warranty extends to the user of this program 
* and user's customers, employees, agents, transferees, successors, 
* and assigns. 
* 
* The AVS does not represent or warrant that the program furnished 
* hereunder are free of infringement of any third-party patents. 
* Commercial implementations of AVS, including shareware, may be 
* subject to royalty fees to patent holders. Information regarding 
* the AVS patent policy is available from the AVS Web site at 
* http://www.avs.org.cn 
* 
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY. 
************************************************************************ 
*/ 
 
/* 
************************************************************************************* 
* File name: b_frame.c 
* Function: B picture decoding 
* 
************************************************************************************* 
*/ 
 
 
#include  
#include  
#include  
 
#include "global.h" 
#include "b_frame.h" 
 
/* 
************************************************************************* 
* Function:Copy decoded P frame to temporary image array 
* Input: 
* Output: 
* Return:  
* Attention: 
************************************************************************* 
*/ 
void copy_Pframe(struct img_par *img) 
{ 
  int i,j; 
	 
  /* 
	* the mmin, mmax macros are taken out, because it makes no sense due to limited range of data type 
	*/ 
   
  for(i=0;iheight;i++) 
    for(j=0;jwidth;j++) 
    { 
      imgY_prev[i][j] = imgY[i][j]; 
    } 
		 
	for(i=0;iheight_cr;i++) 
		for(j=0;jwidth_cr;j++) 
		{ 
			imgUV_prev[0][i][j] = imgUV[0][i][j]; 
		} 
 
	for(i=0;iheight_cr;i++) 
		for(j=0;jwidth_cr;j++) 
		{ 
			imgUV_prev[1][i][j] = imgUV[1][i][j]; 
		} 
} 
 
/* 
************************************************************************* 
* Function:init macroblock B frames 
* Input: 
* Output: 
* Return:  
* Attention: 
************************************************************************* 
*/ 
 
void init_macroblock_Bframe(struct img_par *img) 
{ 
  int i,j,k; 
  Macroblock *currMB = &mb_data[img->current_mb_nr];//GB current_mb_nr]; 
	 
  // reset vectors and pred. modes 
  for (i=0;i<2;i++) 
  { 
    for(j=0;j<2;j++) 
    { 
      img->dfMV [img->block_x+i+4][img->block_y+j][0]=img->dfMV[img->block_x+i+4][img->block_y+j][1]=0; 
      img->dbMV [img->block_x+i+4][img->block_y+j][0]=img->dbMV[img->block_x+i+4][img->block_y+j][1]=0; 
			 
      img->fw_mv[img->block_x+i+4][img->block_y+j][0]=img->fw_mv[img->block_x+i+4][img->block_y+j][1]=0; 
      img->bw_mv[img->block_x+i+4][img->block_y+j][0]=img->bw_mv[img->block_x+i+4][img->block_y+j][1]=0; 
    } 
  } 
	 
  for (i=0;i<2;i++) 
  { 
    for(j=0;j<2;j++) 
    { 
      img->ipredmode[img->block_x+i+1][img->block_y+j+1] = DC_PRED; 
    } 
  } 
   
  // Set the reference frame information for motion vector prediction 
  if (IS_INTRA (currMB) || IS_DIRECT (currMB)) 
  { 
    for (j=0; j<2; j++) 
      for (i=0; i<2; i++) 
      { 
        img->fw_refFrArr[img->block_y+j][img->block_x+i] = -1; 
        img->bw_refFrArr[img->block_y+j][img->block_x+i] = -1; 
      } 
  } 
  else 
  { 
    for(j=0;j<2;j++) 
      for(i=0;i<2;i++) 
      { 
        k=2*j+i; 
				 
        img->fw_refFrArr[img->block_y+j][img->block_x+i] = ((currMB->b8pdir[k]==0||currMB->b8pdir[k]==2)&&currMB->b8mode[k]!=0?0:-1); 
        img->bw_refFrArr[img->block_y+j][img->block_x+i] = ((currMB->b8pdir[k]==1||currMB->b8pdir[k]==2)&&currMB->b8mode[k]!=0?0:-1); 
      } 
  } 
}