信源编码-H.264调试

一、作业要求

1.输出第一帧第二个宏块行的第三个宏块mode
2.输出第二帧同样位置宏块的mode和mv

二、理论储备

1.宏块类型

//  Available MB modes
typedef enum {
  PSKIP        =  0,
  BSKIP_DIRECT =  0,
  P16x16       =  1,
  P16x8        =  2,
  P8x16        =  3,
  SMB8x8       =  4,
  SMB8x4       =  5,
  SMB4x8       =  6,
  SMB4x4       =  7,
  P8x8         =  8,
  I4MB         =  9,
  I16MB        = 10,
  IBLOCK       = 11,
  SI4MB        = 12,
  I8MB         = 13,
  IPCM         = 14,
  MAXMODE      = 15
} MBModeTypes;

2.帧内预测模式

4×4亮度块预测模式

在这里插入图片描述

// 4x4 intra prediction modes 
typedef enum {
  VERT_PRED            = 0,
  HOR_PRED             = 1,
  DC_PRED              = 2,
  DIAG_DOWN_LEFT_PRED  = 3,
  DIAG_DOWN_RIGHT_PRED = 4,
  VERT_RIGHT_PRED      = 5,
  HOR_DOWN_PRED        = 6,
  VERT_LEFT_PRED       = 7,
  HOR_UP_PRED          = 8
} I4x4PredModes;

16×16亮度块预测模式

在这里插入图片描述

// 16x16 intra prediction modes
typedef enum {
  VERT_PRED_16   = 0,
  HOR_PRED_16    = 1,
  DC_PRED_16     = 2,
  PLANE_16       = 3
} I16x16PredModes;

8×8亮度块预测模式

// 8x8 chroma intra prediction modes
typedef enum {
  DC_PRED_8     =  0,
  HOR_PRED_8    =  1,
  VERT_PRED_8   =  2,
  PLANE_8       =  3
} I8x8PredModes;

三、代码调试

1.命令行参数输入:

/d ./bin/decoder.cfg

2.设置打开trace文件:

设置define.h第25行启动trace:

#if defined _DEBUG
# define TRACE           1      //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
#else
# define TRACE           0      //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
#endif

3.注意修改RefFile路径

# Files
##########################################################################################
InputFile             = "test.264"       # H.264/AVC coded bitstream
OutputFile            = "test_dec.yuv"   # Output file, YUV/RGB
RefFile               = "./bin/foreman_part_qcif.yuv"   # Ref sequence (for SNR)
WriteUV               = 1                # Write 4:2:0 chroma components for monochrome streams
FileFormat            = 0                # NAL mode (0=Annex B, 1: RTP packets)
RefOffset             = 0                # SNR computation offset
POCScale              = 2                # Poc Scale (1 or 2)
##########################################################################################

4.添加代码

根据该段代码找出mode和mv

//! Macroblock
typedef struct macroblock_enc
{
  struct slice       *p_Slice;                    //!< pointer to the current slice
  struct video_par   *p_Vid;                      //!< pointer to VideoParameters
  InputParameters    *p_Inp;
  int                 mbAddrX;                    //!< current MB address
  short               mb_type;                    //!< current MB mode type
  short               slice_nr;                   //!< current MB slice id
  short               mb_x;                       //!< current MB horizontal
  short               mb_y;                       //!< current MB vertical
  short               block_x;                    //!< current block horizontal
  short               block_y;                    //!< current block vertical

  short               pix_x;                      //!< current pixel horizontal
  short               pix_y;                      //!< current pixel vertical
  short               pix_c_x;                    //!< current pixel chroma horizontal
  short               pix_c_y;                    //!< current pixel chroma vertical

  short               opix_y;                     //!< current original picture pixel vertical
  short               opix_c_y;                   //!< current original picture pixel chroma vertical

  short               subblock_x;                 //!< current subblock horizontal
  short               subblock_y;                 //!< current subblock vertical

  short               list_offset;
  Boolean             prev_recode_mb;
  int                 DeblockCall;

  int                 mbAddrA, mbAddrB, mbAddrC, mbAddrD;
  byte                mbAvailA, mbAvailB, mbAvailC, mbAvailD;

  short               qp;                         //!< QP luma  
  short               qpc[2];                     //!< QP chroma
  short               qp_scaled[MAX_PLANE];       //!< QP scaled for all comps.
  short               qpsp;
  int                 cbp;
  short               prev_qp;
  short               prev_dqp;
  int                 prev_cbp;
  int                 cr_cbp[3];        // 444. Should be added in an external structure
  int                 c_nzCbCr[3];

  short               i16offset;  

  BitCounter          bits;

  short               ar_mode; //!< mb type to store adaptive rounding parameters
  // ***************************************************
  short               mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2];          //!< indices correspond to [list][block_y][block_x][x,y]
  char                c_ipred_mode;      //!< chroma intra prediction mode
  // ***************************************************
  char                i16mode;

  Info8x8             b8x8[4];    
  //imgpel              intra4x4_pred[16][17]; //!< 4x4 Intra prediction samples
  imgpel              **intra4x4_pred; //[3][17]; //!< 4x4 Intra prediction samples
  imgpel              **intra4x4_pred_buf[2]; //[3][17]; //!< 4x4 Intra prediction samples
  imgpel              **intra8x8_pred; //[3][25]; //!< 8x8 Intra prediction samples
  imgpel              **intra8x8_pred_buf[2]; //[3][25]; //!< 8x8 Intra prediction samples
  imgpel              **intra16x16_pred; //[3][33]; //!< 8x8 Intra prediction samples
  imgpel              **intra16x16_pred_buf[2]; //[3][33]; //!< 8x8 Intra prediction samples

  char                IntraChromaPredModeFlag;
  byte                mb_field;
  byte                is_field_mode;
  byte                luma_transform_size_8x8_flag;
  byte                temp_transform_size_8x8_flag;
  byte                NoMbPartLessThan8x8Flag;
  byte                valid_8x8;
  byte                valid_4x4;
  byte                write_mb;
  byte                is_intra_block;

  char                DFDisableIdc;
  char                DFAlphaC0Offset;
  char                DFBetaOffset;

  int                 skip_flag;

  char                intra_pred_modes   [MB_BLOCK_PARTITIONS];
  char                intra_pred_modes8x8[MB_BLOCK_PARTITIONS];           //!< four 8x8 blocks in a macroblock
...

添加代码:

if TRACE
  // trace: write macroblock header
  if (p_Enc->p_trace)
  {
      if (p_Vid->frame_no == 0 && currMB->mb_x == 2 && currMB->mb_y == 1)
      {
          printf("\n***********  Pic: %i (I/P) MB_x: %i MB_y: %i *********** \n", p_Vid->frame_no, currMB->mb_x, currMB->mb_y);
          printf("MB type:%i\n", currMB->mb_type);
          printf("MB mode:%i\n", currMB->c_ipred_mode);
          printf("********************************************\n");
      }
      if (p_Vid->frame_no == 1 && currMB->mb_x == 2 && currMB->mb_y == 1)
      {
          printf("\n***********  Pic: %i (I/P) MB_x: %i MB_y: %i *********** \n", p_Vid->frame_no, currMB->mb_x, currMB->mb_y);
          printf("MB type:%i\n", currMB->mb_type);
          printf("MB mode:%i\n", currMB->c_ipred_mode);
          printf("MB MV_x:%i\n", currMB->mvd[0][0][0][0]);
          printf("MB MV_y:%i\n", currMB->mvd[0][0][0][1]);
          printf("********************************************\n");
      }
    fprintf(p_Enc->p_trace, "\n*********** Pic: %i (I/P) MB: %i Slice: %i **********\n\n", p_Vid->frame_no, currMB->mbAddrX, currSlice->slice_nr);
  }
#endif

输出结果:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值