⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 b_frame.c

📁 AVS视频编解码器 能实现视频图像的高效率压缩 能在VC上高速运行
💻 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 <stdlib.h>
#include <math.h>
#include <string.h>

#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;i<img->height;i++)
       		for(j=0;j<img->width;j++)
	   	{
	        	imgY_prev[i][j] = imgY[i][j];
		}
		
	for(i=0;i<img->height_cr;i++)
		for(j=0;j<img->width_cr;j++)
		{
			imgUV_prev[0][i][j] = imgUV[0][i][j];
		}

	for(i=0;i<img->height_cr;i++)
		for(j=0;j<img->width_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;
	img->ipredmode[img->block_x+i+1][img->block_y+j+1] = -1;   //cjw the default value should be -1
    }
  }
  
  // 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);
      }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -