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

📄 header.c

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

  // j_pos            
  if(FilterFlag[j_pos])
  {
    if (FilterFlag[i_pos])
      for(i= 0; i < FILTER_SIZE>>1; i++)
        len += se_v("SH: j_pos", DiffQFilterCoef[j_pos][i] - DiffQFilterCoef[i_pos][i], bitstream);
    else
      for(i= 0; i < FILTER_SIZE>>1; i++)
        len += se_v("SH: j_pos", DiffQFilterCoef[j_pos][i], bitstream);
  }

  // k_pos             
  if(FilterFlag[k_pos])
  {
    if (FilterFlag[j_pos])
      for(i= 0; i < FILTER_SIZE>>1; i++)
        len += se_v("SH: k_pos", DiffQFilterCoef[k_pos][i] - DiffQFilterCoef[j_pos][i], bitstream);
    else 
      for(i= 0; i < FILTER_SIZE>>1; i++)
        len += se_v("SH: k_pos", DiffQFilterCoef[k_pos][i], bitstream);
  }

  free(bitstream->streamBuffer);
  free(bitstream);
  return len;
}
// separable aif (END)
#endif
/*!
********************************************************************************************
* \brief 
*    writes the ref_pic_list_reordering syntax
*    based on content of according fields in img structure
*
* \return
*    number of bits used 
********************************************************************************************
*/
static int ref_pic_list_reordering(Bitstream *bitstream)
{
  Slice *currSlice = img->currentSlice;

  int i, len=0;

  // RPLR for redundant pictures
  if(input->redundant_pic_flag && redundant_coding)
  {
    currSlice->ref_pic_list_reordering_flag_l0 = 1;
    currSlice->reordering_of_pic_nums_idc_l0[0] = 0;
    currSlice->reordering_of_pic_nums_idc_l0[1] = 3;
    currSlice->abs_diff_pic_num_minus1_l0[0] = redundant_ref_idx - 1;
    currSlice->long_term_pic_idx_l0[0] = 0;
    reorder_ref_pic_list( listX[LIST_0], &listXsize[LIST_0], 
      img->num_ref_idx_l0_active-1, 
      currSlice->reordering_of_pic_nums_idc_l0, 
      currSlice->abs_diff_pic_num_minus1_l0, 
      currSlice->long_term_pic_idx_l0);
  }

  if ((img->type!=I_SLICE) /*&&(img->type!=SI_IMG)*/ )
  {
    len += u_1 ("SH: ref_pic_list_reordering_flag_l0", currSlice->ref_pic_list_reordering_flag_l0, bitstream);
    if (currSlice->ref_pic_list_reordering_flag_l0)
    {
      i=-1;
      do
      {
        i++;
        len += ue_v ("SH: reordering_of_pic_num_idc", currSlice->reordering_of_pic_nums_idc_l0[i], bitstream);
        if (currSlice->reordering_of_pic_nums_idc_l0[i]==0 ||
          currSlice->reordering_of_pic_nums_idc_l0[i]==1)
        {
          len += ue_v ("SH: abs_diff_pic_num_minus1_l0", currSlice->abs_diff_pic_num_minus1_l0[i], bitstream);
        }
        else
        {
          if (currSlice->reordering_of_pic_nums_idc_l0[i]==2)
          {
            len += ue_v ("SH: long_term_pic_idx_l0", currSlice->long_term_pic_idx_l0[i], bitstream);
          }
        }

      } while (currSlice->reordering_of_pic_nums_idc_l0[i] != 3);
    }
  }

  if (img->type==B_SLICE)
  {
    len += u_1 ("SH: ref_pic_list_reordering_flag_l1", currSlice->ref_pic_list_reordering_flag_l1, bitstream);
    if (currSlice->ref_pic_list_reordering_flag_l1)
    {
      i=-1;
      do
      {
        i++;
        len += ue_v ("SH: remapping_of_pic_num_idc", currSlice->reordering_of_pic_nums_idc_l1[i], bitstream);
        if (currSlice->reordering_of_pic_nums_idc_l1[i]==0 ||
          currSlice->reordering_of_pic_nums_idc_l1[i]==1)
        {
          len += ue_v ("SH: abs_diff_pic_num_minus1_l1", currSlice->abs_diff_pic_num_minus1_l1[i], bitstream);
        }
        else
        {
          if (currSlice->reordering_of_pic_nums_idc_l1[i]==2)
          {
            len += ue_v ("SH: long_term_pic_idx_l1", currSlice->long_term_pic_idx_l1[i], bitstream);
          }
        }
      } while (currSlice->reordering_of_pic_nums_idc_l1[i] != 3);
    }
  }

  return len;
}


/*!
************************************************************************
* \brief
*    write the memory management control operations
*
* \return
*    number of bits used 
************************************************************************
*/
static int dec_ref_pic_marking(Bitstream *bitstream)
{
  DecRefPicMarking_t *tmp_drpm;

  int val, len=0;

  if (img->currentPicture->idr_flag)
  {
    len += u_1("SH: no_output_of_prior_pics_flag", img->no_output_of_prior_pics_flag, bitstream);
    len += u_1("SH: long_term_reference_flag", img->long_term_reference_flag, bitstream);
  }
  else
  {
    img->adaptive_ref_pic_buffering_flag = (img->dec_ref_pic_marking_buffer!=NULL);

    len += u_1("SH: adaptive_ref_pic_buffering_flag", img->adaptive_ref_pic_buffering_flag, bitstream);

    if (img->adaptive_ref_pic_buffering_flag)
    {
      tmp_drpm = img->dec_ref_pic_marking_buffer;
      // write Memory Management Control Operation 
      do
      {
        if (tmp_drpm==NULL) error ("Error encoding MMCO commands", 500);

        val = tmp_drpm->memory_management_control_operation;
        len += ue_v("SH: memory_management_control_operation", val, bitstream);

        if ((val==1)||(val==3)) 
        {
          len += 1 + ue_v("SH: difference_of_pic_nums_minus1", tmp_drpm->difference_of_pic_nums_minus1, bitstream);
        }
        if (val==2)
        {
          len+= ue_v("SH: long_term_pic_num", tmp_drpm->long_term_pic_num, bitstream);
        }
        if ((val==3)||(val==6))
        {
          len+= ue_v("SH: long_term_frame_idx", tmp_drpm->long_term_frame_idx, bitstream);
        }
        if (val==4)
        {
          len += ue_v("SH: max_long_term_pic_idx_plus1", tmp_drpm->max_long_term_frame_idx_plus1, bitstream);
        }

        tmp_drpm=tmp_drpm->Next;

      } while (val != 0);

    }
  }
  return len;
}


/*!
************************************************************************
* \brief
*    write prediction weight table
*
* \return
*    number of bits used 
************************************************************************
*/
static int pred_weight_table(Bitstream *bitstream)
{
  int len = 0;
  int i,j;

  len += ue_v("SH: luma_log_weight_denom", luma_log_weight_denom, bitstream);

  if ( 0 != active_sps->chroma_format_idc)
  {
    len += ue_v("SH: chroma_log_weight_denom", chroma_log_weight_denom, bitstream);
  }

  for (i=0; i< img->num_ref_idx_l0_active; i++)
  {
    if ( (wp_weight[0][i][0] != 1<<luma_log_weight_denom) || (wp_offset[0][i][0] != 0) )
    {
      len += u_1 ("SH: luma_weight_flag_l0", 1, bitstream);

      len += se_v ("SH: luma_weight_l0", wp_weight[0][i][0], bitstream);

#ifdef  BUG_FIX_FOR_FREXT
      len += se_v ("SH: luma_offset_l0", (wp_offset[0][i][0]>>(img->bitdepth_luma-8)), bitstream);
#else
      len += se_v ("SH: luma_offset_l0", wp_offset[0][i][0], bitstream);
#endif
    }
    else
    {
      len += u_1 ("SH: luma_weight_flag_l0", 0, bitstream);
    }

    if (active_sps->chroma_format_idc!=0)
    {
      if ( (wp_weight[0][i][1] != 1<<chroma_log_weight_denom) || (wp_offset[0][i][1] != 0) || 
        (wp_weight[0][i][2] != 1<<chroma_log_weight_denom) || (wp_offset[0][i][2] != 0)  )
      {
        len += u_1 ("chroma_weight_flag_l0", 1, bitstream);
        for (j=1; j<3; j++)
        {
          len += se_v ("chroma_weight_l0", wp_weight[0][i][j] ,bitstream);

#ifdef  BUG_FIX_FOR_FREXT
          len += se_v ("chroma_offset_l0", (wp_offset[0][i][j]>>(img->bitdepth_chroma-8)) ,bitstream);
#else
          len += se_v ("chroma_offset_l0", wp_offset[0][i][j] ,bitstream);
#endif
        }
      }
      else
      {
        len += u_1 ("chroma_weight_flag_l0", 0, bitstream);
      }
    }
  }

  if (img->type == B_SLICE)
  {
    for (i=0; i< img->num_ref_idx_l1_active; i++)
    {
      if ( (wp_weight[1][i][0] != 1<<luma_log_weight_denom) || (wp_offset[1][i][0] != 0) )
      {
        len += u_1 ("SH: luma_weight_flag_l1", 1, bitstream);

        len += se_v ("SH: luma_weight_l1", wp_weight[1][i][0], bitstream);

#ifdef  BUG_FIX_FOR_FREXT
        len += se_v ("SH: luma_offset_l1", (wp_offset[1][i][0]>>(img->bitdepth_luma-8)), bitstream);
#else
        len += se_v ("SH: luma_offset_l1", wp_offset[1][i][0], bitstream);
#endif
      }
      else
      {
        len += u_1 ("SH: luma_weight_flag_l1", 0, bitstream);
      }

      if (active_sps->chroma_format_idc!=0)
      {
        if ( (wp_weight[1][i][1] != 1<<chroma_log_weight_denom) || (wp_offset[1][i][1] != 0) || 
          (wp_weight[1][i][2] != 1<<chroma_log_weight_denom) || (wp_offset[1][i][2] != 0) )
        {
          len += u_1 ("chroma_weight_flag_l1", 1, bitstream);
          for (j=1; j<3; j++)
          {
            len += se_v ("chroma_weight_l1", wp_weight[1][i][j] ,bitstream);

#ifdef  BUG_FIX_FOR_FREXT
            len += se_v ("chroma_offset_l1", (wp_offset[1][i][j]>>(img->bitdepth_chroma-8)) ,bitstream);
#else
            len += se_v ("chroma_offset_l1", wp_offset[1][i][j] ,bitstream);
#endif
          }
        }
        else
        {
          len += u_1 ("chroma_weight_flag_l1", 0, bitstream);
        }
      }
    }
  }
  return len;
}


/*!
************************************************************************
* \brief
*    Selects picture type and codes it to symbol
*
* \return
*    symbol value for picture type
************************************************************************
*/
int get_picture_type()
{
  // set this value to zero for transmission without signaling 
  // that the whole picture has the same slice type
  int same_slicetype_for_whole_frame = 5;

  switch (img->type)
  {
  case I_SLICE:
    return 2 + same_slicetype_for_whole_frame;
    break;
  case P_SLICE:
    return 0 + same_slicetype_for_whole_frame;
    break;
  case B_SLICE:
    return 1 + same_slicetype_for_whole_frame;
    break;
  case SP_SLICE:
    return 3 + same_slicetype_for_whole_frame;
    break;
  default:
    error("Picture Type not supported!",1);
    break;
  }

  return 0;
}



/*!
*****************************************************************************
*
* \brief 
*    int Partition_BC_Header () write the Partition type B, C header
*
* \return
*    Number of bits used by the partition header
*
* \par Parameters
*    PartNo: Partition Number to which the header should be written
*
* \par Side effects
*    Partition header as per VCEG-N72r2 is written into the appropriate 
*    partition bit buffer
*
* \par Limitations/Shortcomings/Tweaks
*    The current code does not support the change of picture parameters within
*    one coded sequence, hence there is only one parameter set necessary.  This
*    is hard coded to zero.
*
* \date
*    October 24, 2001
*
* \author
*    Stephan Wenger   stewe@cs.tu-berlin.de
*****************************************************************************/
int Partition_BC_Header(int PartNo)
{
  DataPartition *partition = &((img->currentSlice)->partArr[PartNo]);
  SyntaxElement symbol, *sym = &symbol;

  int len = 0;

⌨️ 快捷键说明

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