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

📄 header.c

📁 JM 11.0 KTA 2.1 Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
      }

      // d_pos
      if(FilterFlag[d_pos])
        for(i= 0; i < FILTER_SIZE; i++)
          DiffQFilterCoef[d_pos][i] = se_v("d_pos", currStream);

      // e_pos
      if(FilterFlag[e_pos])
      {
        if (FilterFlag[d_pos])
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[e_pos][i] = se_v("e_pos", currStream) + DiffQFilterCoef[d_pos][i];
        else
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[e_pos][i] = se_v("e_pos", currStream);
      }

      // f_pos
      if(FilterFlag[f_pos])
      {
        if (FilterFlag[e_pos])
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[f_pos][i] = se_v("f_pos", currStream) + DiffQFilterCoef[e_pos][i];
        else
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[f_pos][i] = se_v("f_pos", currStream);
      }

      // g_pos
      if(FilterFlag[g_pos])
      {
        if (FilterFlag[f_pos])
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[g_pos][i] = se_v("g_pos", currStream) + DiffQFilterCoef[f_pos][i];
        else
          for(i= 0; i < FILTER_SIZE; i++)
            DiffQFilterCoef[g_pos][i] = se_v("g_pos", currStream);
      }

      // h_pos
      if(FilterFlag[h_pos])
      {
        for(i= 0; i < FILTER_SIZE>>1; i++)
          DiffQFilterCoef[h_pos][i] = se_v("h_pos", currStream);
        DiffQFilterCoef[h_pos][3] = DiffQFilterCoef[h_pos][2];
        DiffQFilterCoef[h_pos][4] = DiffQFilterCoef[h_pos][1];                 
        DiffQFilterCoef[h_pos][5] = DiffQFilterCoef[h_pos][0]; 
      }

      // i_pos
      if(FilterFlag[i_pos])
      {
        if(FilterFlag[h_pos])
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[i_pos][i] = se_v("i_pos", currStream) + DiffQFilterCoef[h_pos][i];
        else
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[i_pos][i] = se_v("i_pos", currStream);
        DiffQFilterCoef[i_pos][3] = DiffQFilterCoef[i_pos][2];
        DiffQFilterCoef[i_pos][4] = DiffQFilterCoef[i_pos][1];                 
        DiffQFilterCoef[i_pos][5] = DiffQFilterCoef[i_pos][0]; 
      }

      // j_pos
      if(FilterFlag[j_pos])
      {
        if(FilterFlag[i_pos])
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[j_pos][i] = se_v("j_pos", currStream) + DiffQFilterCoef[i_pos][i];
        else
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[j_pos][i] = se_v("j_pos", currStream);
        DiffQFilterCoef[j_pos][3] = DiffQFilterCoef[j_pos][2];
        DiffQFilterCoef[j_pos][4] = DiffQFilterCoef[j_pos][1];                 
        DiffQFilterCoef[j_pos][5] = DiffQFilterCoef[j_pos][0]; 
      }

      // k_pos
      if(FilterFlag[k_pos])
      {
        if(FilterFlag[j_pos])
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[k_pos][i] = se_v("k_pos", currStream) + DiffQFilterCoef[j_pos][i];
        else
          for(i= 0; i < FILTER_SIZE>>1; i++)
            DiffQFilterCoef[k_pos][i] = se_v("k_pos", currStream);
        DiffQFilterCoef[k_pos][3] = DiffQFilterCoef[k_pos][2];
        DiffQFilterCoef[k_pos][4] = DiffQFilterCoef[k_pos][1];                 
        DiffQFilterCoef[k_pos][5] = DiffQFilterCoef[k_pos][0]; 
      }

      // l_pos
      if(FilterFlag[l_pos])
        for(i= 0; i < FILTER_SIZE; i++)
          DiffQFilterCoef[l_pos][i] = DiffQFilterCoef[d_pos][FILTER_SIZE-i-1];

      // m_pos
      if(FilterFlag[m_pos])
        for(i= 0; i < FILTER_SIZE; i++)
          DiffQFilterCoef[m_pos][i] = DiffQFilterCoef[e_pos][FILTER_SIZE-i-1];

      // n_pos
      if(FilterFlag[n_pos])
        for(i= 0; i < FILTER_SIZE; i++)
          DiffQFilterCoef[n_pos][i] = DiffQFilterCoef[f_pos][FILTER_SIZE-i-1];

      // o_pos
      if(FilterFlag[o_pos])
        for(i= 0; i < FILTER_SIZE; i++)
          DiffQFilterCoef[o_pos][i] = DiffQFilterCoef[g_pos][FILTER_SIZE-i-1];      
    }
#ifdef DIRECTIONAL_FILTER
    else if (img->AdaptiveFilterFlag == FILTER_TYPE_1D) // 1D-AIF
    {
      img->ImpType = u_v(1,"implem_type", currStream);
      initFilterCustom(img->AdaptiveFilterFlag);
      readFilterCoefs(img->AdaptiveFilterFlag, currStream);
    }
#endif  // DIRECTIONAL_FILTER
#ifdef E_DAIF
    else if ((img->AdaptiveFilterFlag == FILTER_TYPE_EDAIF)) 
    {
      initFilterCustom(img->AdaptiveFilterFlag);
      readFilterCoefs_EDAIF(img->AdaptiveFilterFlag, currStream);
    }
#endif  // E_DAIF
  }
  else
  {
    img->AdaptiveFilterFlag = -1;
  }
#endif
#ifdef USE_INTRA_MDDT
  img->UseIntraMDDT = u_v(1, "use_intra_MDDT", currStream);
#endif

#ifdef USE_HP_FILTER    
  //img->use_high_precision_flag = u_1("use_high_precision_flag" , currStream);
  img->use_high_precision_flag = u_v(2,"use_high_precision_flag" , currStream);
#endif

  return UsedBits;
}


/*!
************************************************************************
* \brief
*    read the reference picture reordering information
************************************************************************
*/
static void ref_pic_list_reordering()
{
  Slice *currSlice = img->currentSlice;
  int dP_nr = assignSE2partition[currSlice->dp_mode][SE_HEADER];
  DataPartition *partition = &(currSlice->partArr[dP_nr]);
  Bitstream *currStream = partition->bitstream;
  int i, val;

  alloc_ref_pic_list_reordering_buffer(currSlice);

  if (img->type!=I_SLICE && img->type!=SI_SLICE)
  {
    val = currSlice->ref_pic_list_reordering_flag_l0 = u_1 ("SH: ref_pic_list_reordering_flag_l0", currStream);

    if (val)
    {
      i=0;
      do
      {
        val = currSlice->reordering_of_pic_nums_idc_l0[i] = ue_v("SH: reordering_of_pic_nums_idc_l0", currStream);
        if (val==0 || val==1)
        {
          currSlice->abs_diff_pic_num_minus1_l0[i] = ue_v("SH: abs_diff_pic_num_minus1_l0", currStream);
        }
        else
        {
          if (val==2)
          {
            currSlice->long_term_pic_idx_l0[i] = ue_v("SH: long_term_pic_idx_l0", currStream);
          }
        }
        i++;
        // assert (i>img->num_ref_idx_l0_active);
      } while (val != 3);
    }
  }

  if (img->type==B_SLICE)
  {
    val = currSlice->ref_pic_list_reordering_flag_l1 = u_1 ("SH: ref_pic_list_reordering_flag_l1", currStream);

    if (val)
    {
      i=0;
      do
      {
        val = currSlice->reordering_of_pic_nums_idc_l1[i] = ue_v("SH: reordering_of_pic_nums_idc_l1", currStream);
        if (val==0 || val==1)
        {
          currSlice->abs_diff_pic_num_minus1_l1[i] = ue_v("SH: abs_diff_pic_num_minus1_l1", currStream);
        }
        else
        {
          if (val==2)
          {
            currSlice->long_term_pic_idx_l1[i] = ue_v("SH: long_term_pic_idx_l1", currStream);
          }
        }
        i++;
        // assert (i>img->num_ref_idx_l1_active);
      } while (val != 3);
    }
  }

  // set reference index of redundant slices.
  if(img->redundant_pic_cnt)
  {
    redundant_slice_ref_idx = currSlice->abs_diff_pic_num_minus1_l0[0] + 1;
  }
}

/*!
************************************************************************
* \brief
*    read the weighted prediction tables
************************************************************************
*/
static void pred_weight_table()
{
  Slice *currSlice = img->currentSlice;
  int dP_nr = assignSE2partition[currSlice->dp_mode][SE_HEADER];
  DataPartition *partition = &(currSlice->partArr[dP_nr]);
  Bitstream *currStream = partition->bitstream;
  int luma_weight_flag_l0, luma_weight_flag_l1, chroma_weight_flag_l0, chroma_weight_flag_l1;
  int i,j;

  img->luma_log2_weight_denom = ue_v ("SH: luma_log2_weight_denom", currStream);
  img->wp_round_luma = img->luma_log2_weight_denom ? 1<<(img->luma_log2_weight_denom - 1): 0;

  if ( 0 != active_sps->chroma_format_idc)
  {
    img->chroma_log2_weight_denom = ue_v ("SH: chroma_log2_weight_denom", currStream);
    img->wp_round_chroma = img->chroma_log2_weight_denom ? 1<<(img->chroma_log2_weight_denom - 1): 0;
  }

  reset_wp_params(img);

  for (i=0; i<img->num_ref_idx_l0_active; i++)
  {
    luma_weight_flag_l0 = u_1("SH: luma_weight_flag_l0", currStream);

    if (luma_weight_flag_l0)
    {
      img->wp_weight[0][i][0] = se_v ("SH: luma_weight_l0", currStream);
      img->wp_offset[0][i][0] = se_v ("SH: luma_offset_l0", currStream);
#ifdef  BUG_FIX_FOR_FREXT
      img->wp_offset[0][i][0] = img->wp_offset[0][i][0]<<(img->bitdepth_luma-8);
#endif
    }
    else
    {
      img->wp_weight[0][i][0] = 1<<img->luma_log2_weight_denom;
      img->wp_offset[0][i][0] = 0;
    }

    if (active_sps->chroma_format_idc != 0)
    {
      chroma_weight_flag_l0 = u_1 ("SH: chroma_weight_flag_l0", currStream);

      for (j=1; j<3; j++)
      {
        if (chroma_weight_flag_l0)
        {
          img->wp_weight[0][i][j] = se_v("SH: chroma_weight_l0", currStream);
          img->wp_offset[0][i][j] = se_v("SH: chroma_offset_l0", currStream);
#ifdef  BUG_FIX_FOR_FREXT
          img->wp_offset[0][i][j] = img->wp_offset[0][i][j]<<(img->bitdepth_chroma-8);
#endif
        }
        else
        {
          img->wp_weight[0][i][j] = 1<<img->chroma_log2_weight_denom;
          img->wp_offset[0][i][j] = 0;
        }
      }
    }
  }
  if ((img->type == B_SLICE) && active_pps->weighted_bipred_idc == 1)
  {
    for (i=0; i<img->num_ref_idx_l1_active; i++)
    {
      luma_weight_flag_l1 = u_1("SH: luma_weight_flag_l1", currStream);

      if (luma_weight_flag_l1)
      {
        img->wp_weight[1][i][0] = se_v ("SH: luma_weight_l1", currStream);
        img->wp_offset[1][i][0] = se_v ("SH: luma_offset_l1", currStream);
#ifdef  BUG_FIX_FOR_FREXT
        img->wp_offset[1][i][0] = img->wp_offset[1][i][0]<<(img->bitdepth_luma-8);
#endif
      }
      else
      {
        img->wp_weight[1][i][0] = 1<<img->luma_log2_weight_denom;
        img->wp_offset[1][i][0] = 0;
      }

      if (active_sps->chroma_format_idc != 0)
      {
        chroma_weight_flag_l1 = u_1 ("SH: chroma_weight_flag_l1", currStream);

        for (j=1; j<3; j++)
        {
          if (chroma_weight_flag_l1)
          {
            img->wp_weight[1][i][j] = se_v("SH: chroma_weight_l1", currStream);
            img->wp_offset[1][i][j] = se_v("SH: chroma_offset_l1", currStream);
#ifdef  BUG_FIX_FOR_FREXT
            img->wp_offset[1][i][j] = img->wp_offset[1][i][j]<<(img->bitdepth_chroma-8);
#endif
          }
          else
          {
            img->wp_weight[1][i][j] = 1<<img->chroma_log2_weight_denom;
            img->wp_offset[1][i][j] = 0;
          }
        }
      }
    }  
  }
}


/*!
************************************************************************
* \brief
*    read the memory control operations
************************************************************************
*/
void dec_ref_pic_marking(Bitstream *currStream)
{
  int val;

  DecRefPicMarking_t *tmp_drpm,*tmp_drpm2;

  // free old buffer content
  while (img->dec_ref_pic_marking_buffer)
  { 
    tmp_drpm=img->dec_ref_pic_marking_buffer;

    img->dec_ref_pic_marking_buffer=tmp_drpm->Next;
    free (tmp_drpm);
  } 

  if (img->idr_flag)
  {
    img->no_output_of_prior_pics_flag = u_1("SH: no_output_of_prior_pics_flag", currStream);
    img->long_term_reference_flag = u_1("SH: long_term_reference_flag", currStream);
  }
  else
  {
    img->adaptive_ref_pic_buffering_flag = u_1("SH: adaptive_ref_pic_buffering_flag", currStream);
    if (img->adaptive_ref_pic_buffering_flag)
    {
      // read Memory Management Control Operation 
      do
      {
        tmp_drpm=(DecRefPicMarking_t*)calloc (1,sizeof (DecRefPicMarking_t));
        tmp_drpm->Next=NULL;

        val = tmp_drpm->memory_management_control_operation = ue_v("SH: memory_management_control_operation", currStream);

        if ((val==1)||(val==3)) 
        {
          tmp_drpm->difference_of_pic_nums_minus1 = ue_v("SH: difference_of_pic_nums_minus1", currStream);
        }
        if (val==2)
        {
          tmp_drpm->long_term_pic_num = ue_v("SH: long_term_pic_num", currStream);
        }

        if ((val==3)||(val==6))
        {
          tmp_drpm->long_term_frame_idx = ue_v("SH: long_term_frame_idx", currStream);
        }
        if (val==4)
        {
          tmp_drpm->max_long_term_frame_idx_plus1 = ue_v("SH: max_long_term_pic_idx_plus1", currStream);
        }

        // add command
        if (img->dec_ref_pic_marking_buffer==NULL) 
        {
          img->dec_ref_pic_marking_buffer=tmp_drpm;
        }
        else
        {
          tmp_drpm2=img->dec_ref_pic_marking_buffer;
          while (tmp_drpm2->Next!=NULL) tmp_drpm2=tmp_drpm2->Next;
          tmp_drpm2->Next=tmp_drpm;
        }

      }while (val != 0);

    }
  }
}

/*!
************************************************************************
* \brief
*    To calculate the poc values
*        based upon JVT-F100d2
*  POC200301: Until Jan 2003, this function will calculate the correct POC
*    values, but the management of POCs in buffered pictures may need more work.
* \return
*    none
************************************************************************
*/
void decode_poc(struct img_par *img)
{
  int i;
  // for POC mode 0:
  unsigned int MaxPicOrderCntLsb = (1<<(active_sps->log2_max_pic_order_cnt_lsb_minus4+4));

  switch ( active_sps->pic_order_cnt_type )
  {
  case 0: // POC MODE 0
    // 1st
    if(img->idr_flag)
    {
      img->PrevPicOrderCntMsb = 0;
      img->PrevPicOrderCntLsb = 0;
    }
    else
    {
      if (img->last_has_mmco_5) 
      {
        if (img->last_pic_bottom_field)
        {
          img->PrevPicOrderCntMsb = 0;
          img->PrevPicOrderCntLsb = 0;
        }
        else
        {
          img->PrevPicOrderCntMsb = 0;
          img->PrevPicOrderCntLsb = img->toppoc;
        }

⌨️ 快捷键说明

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