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

📄 parset.c

📁 jm61 的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
***********************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2001, International Telecommunications Union, Geneva
*
* DISCLAIMER OF WARRANTY
*
* These software programs are available to the user without any
* license fee or royalty on an "as is" basis. The ITU 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
* contributor or the ITU be liable for any incidental, punitive, or
* consequential damages of any kind whatsoever arising from the
* use of these programs.
*
* This disclaimer of warranty extends to the user of these programs
* and user's customers, employees, agents, transferees, successors,
* and assigns.
*
* The ITU does not represent or warrant that the programs furnished
* hereunder are free of infringement of any third-party patents.
* Commercial implementations of ITU-T Recommendations, including
* shareware, may be subject to royalty fees to patent holders.
* Information regarding the ITU-T patent policy is available from
* the ITU Web site at http://www.itu.int.
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE ITU-T PATENT POLICY.
************************************************************************
*/


/*!
 ************************************************************************
 *  \file
 *     parset.c
 *  \brief
 *     Parameter Sets
 *  \author
 *     Main contributors (see contributors.h for copyright, address and affiliation details)
 *     - Stephan Wenger          <stewe@cs.tu-berlin.de>
 *
 ***********************************************************************
 */

#include <stdlib.h>
#include <assert.h>
#include <string.h>

#include "parsetcommon.h"
#include "parset.h"
#include "nalu.h"
#include "global.h"
#include "memalloc.h"
#include "fmo.h"
#include "vlc.h"

#if TRACE
#define SYMTRACESTRING(s) strncpy(sym->tracestring,s,TRACESTRING_SIZE)
#else
#define SYMTRACESTRING(s) // do nothing
#endif

extern int UsedBits;      // for internal statistics, is adjusted by se_v, ue_v, u_1

seq_parameter_set_rbsp_t SeqParSet[MAXSPS];
pic_parameter_set_rbsp_t PicParSet[MAXPPS];
                          
// fill sps with content of p

int InterpretSPS (DataPartition *p, seq_parameter_set_rbsp_t *sps)
{
  unsigned i;
  Bitstream *s = p->bitstream;

  assert (p != NULL);
  assert (p->bitstream != NULL);
  assert (p->bitstream->streamBuffer != 0);
  assert (sps != NULL);

  UsedBits = 0;

  sps->profile_idc                            = u_v  (8, "SPS: profile_idc"                           , s);
  sps->level_idc                              = u_v  (8, "SPS: level_idc"                             , s);
  sps->more_than_one_slice_group_allowed_flag = u_1  ("SPS: more_than_one_slice_group_allowed_flag"   , s);
  sps->arbitrary_slice_order_allowed_flag     = u_1  ("SPS: arbitrary_slice_order_allowed_flag"       , s);
  sps->redundant_slices_allowed_flag          = u_1  ("SPS: redundant_slices_allowed_flag"            , s);
  sps->seq_parameter_set_id                   = ue_v ("SPS: seq_parameter_set_id"                     , s);
  sps->log2_max_frame_num_minus4              = ue_v ("SPS: log2_max_frame_num_minus4"                , s);
  sps->pic_order_cnt_type                     = ue_v ("SPS: pic_order_count_type"                     , s);
  // POC200301
  if (sps->pic_order_cnt_type == 0)
    sps->log2_max_pic_order_cnt_lsb_minus4 = ue_v ("SPS: log2_max_pic_order_cnt_lsb_minus4"           , s);
  else if (sps->pic_order_cnt_type == 1)
  {
    sps->delta_pic_order_always_zero_flag      = u_1  ("SPS: delta_pic_order_always_zero_flag"       , s);
    sps->offset_for_non_ref_pic                = se_v ("SPS: offset_for_non_ref_pic"                 , s);
    sps->offset_for_top_to_bottom_field        = se_v ("SPS: offset_for_top_to_bottom_field"         , s);
    sps->num_ref_frames_in_pic_order_cnt_cycle = ue_v ("SPS: num_ref_frames_in_pic_order_cnt_cycle"  , s);
    for(i=0; i<sps->num_ref_frames_in_pic_order_cnt_cycle; i++)
      sps->offset_for_ref_frame[i]               = se_v ("SPS: offset_for_ref_frame[i]"              , s);
  }
  sps->num_ref_frames                        = ue_v ("SPS: num_ref_frames"                         , s);
  sps->required_frame_num_update_behaviour_flag = u_1 ("SPS: required_frame_num_update_behaviour_flag", s);
  sps->frame_width_in_mbs_minus1             = ue_v ("SPS: frame_width_in_mbs_minus1"              , s);
  sps->frame_height_in_mbs_minus1            = ue_v ("SPS: frame_height_in_mbs_minus1"             , s);
  sps->frame_mbs_only_flag                   = u_1  ("SPS: frame_mbs_only_flag"                    , s);
  if (!sps->frame_mbs_only_flag)
  {
    sps->mb_adaptive_frame_field_flag          = u_1  ("SPS: mb_adaptive_frame_field_flag"           , s);
  }
  sps->direct_8x8_inference_flag             = u_1  ("SPS: direct_8x8_inference_flag"       , s);
  sps->vui_parameters_present_flag           = u_1  ("SPS: vui_parameters_present_flag"             , s);
  if (sps->vui_parameters_present_flag)
  {
    printf ("VUI sequence parameters present but not supported, ignored, proceeding to next NALU\n");
  }
  sps->Valid = TRUE;
  return UsedBits;
}


int InterpretPPS (DataPartition *p, pic_parameter_set_rbsp_t *pps)
{
  unsigned i;
  int NumberBitsPerSliceGroupId;
  Bitstream *s = p->bitstream;
  
  assert (p != NULL);
  assert (p->bitstream != NULL);
  assert (p->bitstream->streamBuffer != 0);
  assert (pps != NULL);

  UsedBits = 0;

  pps->pic_parameter_set_id                  = ue_v ("PPS: pic_parameter_set_id"                   , s);
  pps->seq_parameter_set_id                  = ue_v ("PPS: seq_parameter_set_id"                   , s);
  pps->entropy_coding_mode                   = u_1  ("PPS: entropy_coding_mode"                    , s);

  //! Note: as per JVT-F078 the following bit is unconditional.  If F078 is not accepted, then
  //! one has to fetch the correct SPS to check whether the bit is present (hopefully there is
  //! no consistency problem :-(
  //! The current encoder code handles this in the same way.  When you change this, don't forget
  //! the encoder!  StW, 12/8/02
  pps->pic_order_present_flag                = u_1  ("PPS: pic_order_present_flag"                 , s);

  pps->num_slice_groups_minus1               = ue_v ("PPS: num_slice_groups_minus1"                , s);

  //! InterpretSPS is able to process all different FMO modes, but UseParameterSet() is not (yet
  //! Hence, make sure FMO is not used.

  assert (pps->num_slice_groups_minus1 == 0);

  // FMO stuff begins here
  if (pps->num_slice_groups_minus1 > 0)
  {
    pps->mb_slice_group_map_type               = ue_v ("PPS: mb_slice_group_map_type"                , s);
    if (pps->mb_slice_group_map_type == 0)
      for (i=0; i<pps->num_slice_groups_minus1; i++)
        pps->run_length [i]                        = ue_v ("PPS: run_length [i]"                         , s);
    else if (pps->mb_slice_group_map_type == 2)
      for (i=0; i<pps->num_slice_groups_minus1; i++)
      {
        //! JVT-F078: avoid reference of SPS by using ue(v) instead of u(v)
        pps->top_left_mb [i]                       = ue_v ("PPS: top_left_mb [i]"                        , s);
        pps->bottom_right_mb [i]                   = ue_v ("PPS: bottom_right_mb [i]"                    , s);
      }
    else if (pps->mb_slice_group_map_type == 3 ||
             pps->mb_slice_group_map_type == 4 ||
             pps->mb_slice_group_map_type == 5)
    {
      pps->slice_group_change_direction_flag     = u_1  ("PPS: slice_group_change_direction_flag"      , s);
      pps->slice_group_change_rate_minus1        = ue_v ("PPS: slice_group_change_rate_minus1"         , s);
    }
    else if (pps->mb_slice_group_map_type == 6)
    {
      if (pps->num_slice_groups_minus1 >= 4)
        NumberBitsPerSliceGroupId = 3;
      else if (pps->num_ref_idx_l0_active_minus1 >= 2)
        NumberBitsPerSliceGroupId = 2;
      else if (pps->num_ref_idx_l0_active_minus1 >= 1)
        NumberBitsPerSliceGroupId = 1;
      else
        NumberBitsPerSliceGroupId = 0;
      //! JVT-F078, exlicitly signal number of MBs in the map
      pps->slice_group_id_cnt_minus1              = ue_v ("PPS: slice_group_id_cnt_minus1"               , s);
      for (i=0; i<=pps->slice_group_id_cnt_minus1; i++)
        pps->slice_group_id[i] = u_v (NumberBitsPerSliceGroupId, "slice_group_id[i]", s);
    }
  }
  // End of FMO stuff

  pps->num_ref_idx_l0_active_minus1          = ue_v ("PPS: num_ref_idx_l0_active_minus1"           , s);
  pps->num_ref_idx_l1_active_minus1          = ue_v ("PPS: num_ref_idx_l1_active_minus1"           , s);
  pps->weighted_pred_flag                    = u_1  ("PPS: weighted prediction flag"               , s);
  pps->weighted_bipred_idc                   = u_v  ( 2, "PPS: weighted_bipred_idc"                , s);
  pps->pic_init_qp_minus26                   = se_v ("PPS: pic_init_qp_minus26"                    , s);
  pps->pic_init_qs_minus26                   = se_v ("PPS: pic_init_qs_minus26"                    , s);
  pps->chroma_qp_index_offset                = se_v ("PPS: chroma_qp_index_offset"                 , s);
  pps->deblocking_filter_parameters_present_flag = u_1 ("PPS: deblocking_filter_parameters_present_flag", s);
  pps->constrained_intra_pred_flag           = u_1  ("PPS: constrained_intra_pred_flag"            , s);
  pps->redundant_pic_cnt_present_flag        = u_1  ("PPS: redundant_pic_cnt_present_flag"         , s);
  pps->frame_cropping_flag                   = u_1  ("PPS: frame_cropping_flag"                , s);

⌨️ 快捷键说明

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