2009年4月17日 星期五

H.264 JM code理解暫存筆記

 

(1).實際從磁碟讀入值的地方
<input.c>
void ReadOneFrame (int FrameNoInFile, int HeaderSize, FrameFormat *source, FrameFormat *output)

int fuck;

for(fuck=0;fuck<framesize_in_bytes;fuck++)  //自己加
   {printf("%d\n",buf[fuck]);system("PAUSE");} //自己加




(2).開啟trace功能
在<defines.h>文件中把
#if defined _DEBUG
#define TRACE           0                   //!< 0:Trace off 1:Trace on
#else
改成
#if defined _DEBUG
#define TRACE           1                   //!< 0:Trace off 1:Trace on
#else


(3).
encode_one_macroblock_(四種模式)

  //===== GET BEST MACROBLOCK MODE =====
  for (ctr16x16=0, index=0; index < max_index; index++)  //強制改成全部都是IPCM!! index=0 改成index=8 (只執行ipcm判斷)
  {
    mode = mb_mode_table[index];
    //printf("GET BEST MACROBLOCK MODE!\n");

    if (img->yuv_format != YUV400)
    {          
      mode = mb_mode_table[index];
      i16mode = 0;
    }
    //--- for INTER16x16 check all prediction directions ---
    if (mode == 1 && bslice)
    {
      update_prediction_for_mode16x16(b8x8info, ctr16x16, &index);
      ctr16x16++;
    }

    // Skip intra modes in inter slices if best mode is inter <P8x8 with cbp equal to 0   
    if (img->P444_joined)
    {
      if (params->SkipIntraInInterSlices && !intra && mode >= I16MB
        && best_mode <=3 && currMB->cbp == 0 && cmp_cbp[1] == 0 && cmp_cbp[2] == 0)
        continue;
    }
    else
    {

      if (params->SkipIntraInInterSlices && !intra && mode >= I4MB && best_mode <=3 && currMB->cbp == 0)
        continue;
    }

    // check if weights are in valid range for biprediction.
    if (bslice && active_pps->weighted_bipred_idc == 1 && mode < P8x8)
    {
      int cur_blk, cur_comp;
      int weight_sum;
      Boolean invalid_mode = FALSE;
      for (cur_blk = 0; cur_blk < 4; cur_blk ++)
      {
        if (b8x8info->best8x8pdir[mode][cur_blk] == 2)
        {
          for (cur_comp = 0; cur_comp < (active_sps->chroma_format_idc == YUV400 ? 1 : 3) ; cur_comp ++)
          {
            best8x8l0ref = (int) b8x8info->best8x8l0ref[mode][cur_blk];
            best8x8l1ref = (int) b8x8info->best8x8l1ref[mode][cur_blk];
            weight_sum = wbp_weight[0][best8x8l0ref][best8x8l1ref][cur_comp] + wbp_weight[1][best8x8l0ref][best8x8l1ref][cur_comp];

            if (weight_sum < -128 ||  weight_sum > 127)
            {
              invalid_mode = TRUE;
              break;
            }
          }
          if (invalid_mode == TRUE)
            break;
        }
      }
      if (invalid_mode == TRUE)
        continue;
    }
    if (enc_mb.valid[mode])
      compute_mode_RD_cost(mode, currMB, &enc_mb, &min_rdcost, &min_dcost, &min_rate, i16mode, bslice, &inter_skip, is_cavlc);

  }// for (ctr16x16=0, index=0; index<max_index; index++)
}// for (currMB->c_ipred_mode=DC_PRED_8; currMB->c_ipred_mode<=max_chroma_pred_mode; currMB->c_ipred_mode++)                    

0 意見:

張貼留言