FFmpeg
Loading...
Searching...
No Matches
ps.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "libavcodec/golomb.h"
#include "libavcodec/h2645_vui.h"
#include "data.h"
#include "ps.h"
#include "libavcodec/profiles.h"

Go to the source code of this file.

Macros

#define check_profile_idc(idc)
 
#define CHECK_QP_OFFSET(name)
 

Enumerations

enum  DependencyType { HEVC_DEP_TYPE_SAMPLE = 0 , HEVC_DEP_TYPE_MV = 1 , HEVC_DEP_TYPE_BOTH = 2 }
 

Functions

static int read_window (HEVCWindow *window, GetBitContext *gb, int chroma_format_idc, int w, int h)
 
static void remove_sps (HEVCParamSets *s, int id)
 
static void remove_vps (HEVCParamSets *s, int id)
 
int ff_hevc_decode_short_term_rps (GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
 
static int decode_profile_tier_level (GetBitContext *gb, AVCodecContext *avctx, PTLCommon *ptl)
 
static int parse_ptl (GetBitContext *gb, AVCodecContext *avctx, int profile_present, PTL *ptl, int max_num_sub_layers)
 
static void decode_sublayer_hrd (GetBitContext *gb, unsigned int nb_cpb, HEVCSublayerHdrParams *par, int subpic_params_present)
 
static int decode_hrd (GetBitContext *gb, int common_inf_present, HEVCHdrParams *hdr, int max_sublayers)
 
static void hevc_vps_free (AVRefStructOpaque opaque, void *obj)
 
static int decode_vps_ext (GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps, uint64_t layer1_id_included)
 
int ff_hevc_decode_nal_vps (GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
 
static void decode_vui (GetBitContext *gb, AVCodecContext *avctx, int apply_defdispwin, HEVCSPS *sps)
 
static void set_default_scaling_list_data (ScalingList *sl)
 
static int scaling_list_data (GetBitContext *gb, AVCodecContext *avctx, ScalingList *sl, const HEVCSPS *sps)
 
static int map_pixel_format (AVCodecContext *avctx, HEVCSPS *sps)
 
int ff_hevc_parse_sps (HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, unsigned nuh_layer_id, int apply_defdispwin, const HEVCVPS *const *vps_list, AVCodecContext *avctx)
 Parse the SPS from the bitstream into the provided HEVCSPS struct.
 
static void hevc_sps_free (AVRefStructOpaque opaque, void *obj)
 
static int compare_sps (const HEVCSPS *sps1, const HEVCSPS *sps2)
 
int ff_hevc_decode_nal_sps (GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, unsigned nuh_layer_id, int apply_defdispwin)
 
static void hevc_pps_free (AVRefStructOpaque unused, void *obj)
 
static void colour_mapping_octants (GetBitContext *gb, HEVCPPS *pps, int inp_depth, int idx_y, int idx_cb, int idx_cr, int inp_length)
 
static int colour_mapping_table (GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps)
 
static int pps_multilayer_extension (GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps, const HEVCSPS *sps, const HEVCVPS *vps)
 
static void delta_dlt (GetBitContext *gb, HEVCPPS *pps)
 
static int pps_3d_extension (GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps, const HEVCSPS *sps)
 
static int pps_range_extensions (GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps, const HEVCSPS *sps)
 
static int pps_scc_extension (GetBitContext *gb, AVCodecContext *avctx, HEVCPPS *pps, const HEVCSPS *sps)
 
static int setup_pps (AVCodecContext *avctx, GetBitContext *gb, HEVCPPS *pps, const HEVCSPS *sps)
 
int ff_hevc_decode_nal_pps (GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
 
void ff_hevc_ps_uninit (HEVCParamSets *ps)
 
int ff_hevc_compute_poc2 (unsigned log2_max_poc_lsb, int pocTid0, int poc_lsb, int nal_unit_type)
 Compute POC of the current frame and return it.
 

Variables

static const uint8_t default_scaling_list_intra []
 
static const uint8_t default_scaling_list_inter []
 
static const uint8_t hevc_sub_width_c []
 
static const uint8_t hevc_sub_height_c []
 

Macro Definition Documentation

◆ check_profile_idc

#define check_profile_idc ( idc)
Value:
ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
const H265RawProfileTierLevel * ptl

Referenced by decode_profile_tier_level().

◆ CHECK_QP_OFFSET

#define CHECK_QP_OFFSET ( name)
Value:
(pps->pps_act_ ## name ## _qp_offset <= -12 || \
pps->pps_act_ ## name ## _qp_offset >= 12)
uint64_t pps
Definition dovi_rpuenc.c:36
const char * name
Definition qsvenc.c:142

Referenced by pps_scc_extension().

Enumeration Type Documentation

◆ DependencyType

Enumerator
HEVC_DEP_TYPE_SAMPLE 
HEVC_DEP_TYPE_MV 
HEVC_DEP_TYPE_BOTH 

Definition at line 477 of file ps.c.

Function Documentation

◆ read_window()

static int read_window ( HEVCWindow * window,
GetBitContext * gb,
int chroma_format_idc,
int w,
int h )
static

Definition at line 66 of file ps.c.

Referenced by decode_vps_ext(), decode_vui(), and ff_hevc_parse_sps().

◆ remove_sps()

static void remove_sps ( HEVCParamSets * s,
int id )
static

Definition at line 89 of file ps.c.

Referenced by ff_hevc_decode_nal_sps(), and remove_vps().

◆ remove_vps()

static void remove_vps ( HEVCParamSets * s,
int id )
static

Definition at line 102 of file ps.c.

Referenced by ff_hevc_decode_nal_vps().

◆ ff_hevc_decode_short_term_rps()

int ff_hevc_decode_short_term_rps ( GetBitContext * gb,
AVCodecContext * avctx,
ShortTermRPS * rps,
const HEVCSPS * sps,
int is_slice_header )

Definition at line 113 of file ps.c.

Referenced by ff_hevc_parse_sps(), and hls_slice_header().

◆ decode_profile_tier_level()

static int decode_profile_tier_level ( GetBitContext * gb,
AVCodecContext * avctx,
PTLCommon * ptl )
static

Definition at line 262 of file ps.c.

Referenced by parse_ptl().

◆ parse_ptl()

static int parse_ptl ( GetBitContext * gb,
AVCodecContext * avctx,
int profile_present,
PTL * ptl,
int max_num_sub_layers )
static

Definition at line 337 of file ps.c.

Referenced by decode_vps_ext(), ff_hevc_decode_nal_vps(), and ff_hevc_parse_sps().

◆ decode_sublayer_hrd()

static void decode_sublayer_hrd ( GetBitContext * gb,
unsigned int nb_cpb,
HEVCSublayerHdrParams * par,
int subpic_params_present )
static

Definition at line 383 of file ps.c.

Referenced by decode_hrd().

◆ decode_hrd()

static int decode_hrd ( GetBitContext * gb,
int common_inf_present,
HEVCHdrParams * hdr,
int max_sublayers )
static

Definition at line 401 of file ps.c.

Referenced by decode_vui(), and ff_hevc_decode_nal_vps().

◆ hevc_vps_free()

static void hevc_vps_free ( AVRefStructOpaque opaque,
void * obj )
static

Definition at line 469 of file ps.c.

Referenced by ff_hevc_decode_nal_vps().

◆ decode_vps_ext()

static int decode_vps_ext ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCVPS * vps,
uint64_t layer1_id_included )
static

For stereoscopic MV-HEVC, the following simplifying assumptions are made:

  • vps_max_layers = 2 (one base layer, one multiview layer)
  • vps_num_layer_sets = 2 (one output layer set for each view)
  • NumScalabilityTypes = 1 (only HEVC_SCALABILITY_MULTIVIEW)
  • direct_dependency_flag[1][0] = 1 (second layer depends on first)
  • num_add_olss = 0 (no extra output layer sets)
  • default_output_layer_idc = 0 (1:1 mapping between OLSs and layers)
  • layer_id_included_flag[1] = {1, 1} (consequence of layer dependencies)
  • vps_num_rep_formats_minus1 = 0 (all layers have the same size)

Which results in the following derived variables:

  • ViewOrderIdx = {0, 1}
  • NumViews = 2
  • DependencyFlag[1][0] = 1
  • NumDirectRefLayers = {0, 1}
  • NumRefLayers = {0, 1}
  • NumPredictedLayers = {1, 0}
  • NumIndependentLayers = 1
  • NumLayersInTreePartition = {2}
  • NumLayerSets = 2
  • NumOutputLayerSets = 2
  • OlsIdxToLsIdx = {0, 1}
  • LayerIdxInVps = {0, 1}
  • NumLayersInIdList = {1, 2}
  • NumNecessaryLayers = {1, 2}
  • NecessaryLayerFlag = {{1, 0}, {1, 1}}
  • NumOutputLayersInOutputLayerSet = {1, 2}
  • OutputLayerFlag = {{1, 0}, {1, 1}}

Definition at line 483 of file ps.c.

Referenced by ff_hevc_decode_nal_vps().

◆ ff_hevc_decode_nal_vps()

int ff_hevc_decode_nal_vps ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCParamSets * ps )

Definition at line 786 of file ps.c.

Referenced by decode_nal_unit(), hevc_decode_nal_units(), and parse_nal_units().

◆ decode_vui()

static void decode_vui ( GetBitContext * gb,
AVCodecContext * avctx,
int apply_defdispwin,
HEVCSPS * sps )
static

Definition at line 961 of file ps.c.

Referenced by ff_hevc_parse_sps().

◆ set_default_scaling_list_data()

static void set_default_scaling_list_data ( ScalingList * sl)
static

Definition at line 1083 of file ps.c.

Referenced by ff_hevc_decode_nal_pps(), and ff_hevc_parse_sps().

◆ scaling_list_data()

static int scaling_list_data ( GetBitContext * gb,
AVCodecContext * avctx,
ScalingList * sl,
const HEVCSPS * sps )
static

Definition at line 1113 of file ps.c.

Referenced by ff_hevc_decode_nal_pps(), and ff_hevc_parse_sps().

◆ map_pixel_format()

static int map_pixel_format ( AVCodecContext * avctx,
HEVCSPS * sps )
static

Definition at line 1190 of file ps.c.

Referenced by ff_hevc_parse_sps().

◆ ff_hevc_parse_sps()

int ff_hevc_parse_sps ( HEVCSPS * sps,
GetBitContext * gb,
unsigned int * sps_id,
unsigned nuh_layer_id,
int apply_defdispwin,
const HEVCVPS *const * vps_list,
AVCodecContext * avctx )

Parse the SPS from the bitstream into the provided HEVCSPS struct.

Parameters
sps_idthe SPS id will be written here
apply_defdispwinif set 1, the default display window from the VUI will be applied to the video dimensions
vps_listif non-NULL, this function will validate that the SPS refers to an existing VPS

Definition at line 1239 of file ps.c.

Referenced by ff_hevc_decode_nal_sps(), and generate_fake_vps().

◆ hevc_sps_free()

static void hevc_sps_free ( AVRefStructOpaque opaque,
void * obj )
static

Definition at line 1720 of file ps.c.

Referenced by ff_hevc_decode_nal_sps().

◆ compare_sps()

static int compare_sps ( const HEVCSPS * sps1,
const HEVCSPS * sps2 )
static

Definition at line 1729 of file ps.c.

Referenced by ff_hevc_decode_nal_sps().

◆ ff_hevc_decode_nal_sps()

int ff_hevc_decode_nal_sps ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCParamSets * ps,
unsigned nuh_layer_id,
int apply_defdispwin )

Definition at line 1735 of file ps.c.

Referenced by decode_nal_unit(), hevc_decode_nal_units(), and parse_nal_units().

◆ hevc_pps_free()

static void hevc_pps_free ( AVRefStructOpaque unused,
void * obj )
static

Definition at line 1788 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ colour_mapping_octants()

static void colour_mapping_octants ( GetBitContext * gb,
HEVCPPS * pps,
int inp_depth,
int idx_y,
int idx_cb,
int idx_cr,
int inp_length )
static

Definition at line 1807 of file ps.c.

Referenced by colour_mapping_octants(), and colour_mapping_table().

◆ colour_mapping_table()

static int colour_mapping_table ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCPPS * pps )
static

Definition at line 1844 of file ps.c.

Referenced by pps_multilayer_extension().

◆ pps_multilayer_extension()

static int pps_multilayer_extension ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCPPS * pps,
const HEVCSPS * sps,
const HEVCVPS * vps )
static

Definition at line 1880 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ delta_dlt()

static void delta_dlt ( GetBitContext * gb,
HEVCPPS * pps )
static

Definition at line 1929 of file ps.c.

Referenced by pps_3d_extension().

◆ pps_3d_extension()

static int pps_3d_extension ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCPPS * pps,
const HEVCSPS * sps )
static

Definition at line 1951 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ pps_range_extensions()

static int pps_range_extensions ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCPPS * pps,
const HEVCSPS * sps )
static

Definition at line 1975 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ pps_scc_extension()

static int pps_scc_extension ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCPPS * pps,
const HEVCSPS * sps )
static

Definition at line 2015 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ setup_pps()

static int setup_pps ( AVCodecContext * avctx,
GetBitContext * gb,
HEVCPPS * pps,
const HEVCSPS * sps )
inlinestatic

6.5

Definition at line 2069 of file ps.c.

Referenced by ff_hevc_decode_nal_pps().

◆ ff_hevc_decode_nal_pps()

int ff_hevc_decode_nal_pps ( GetBitContext * gb,
AVCodecContext * avctx,
HEVCParamSets * ps )

Definition at line 2201 of file ps.c.

Referenced by decode_nal_unit(), hevc_decode_nal_units(), and parse_nal_units().

◆ ff_hevc_ps_uninit()

void ff_hevc_ps_uninit ( HEVCParamSets * ps)

Definition at line 2473 of file ps.c.

Referenced by hevc_decode_free(), and hevc_parser_close().

◆ ff_hevc_compute_poc2()

int ff_hevc_compute_poc2 ( unsigned log2_max_poc_lsb,
int pocTid0,
int poc_lsb,
int nal_unit_type )

Compute POC of the current frame and return it.

Definition at line 2485 of file ps.c.

Referenced by ff_hevc_compute_poc(), and hevc_filter().

Variable Documentation

◆ default_scaling_list_intra

const uint8_t default_scaling_list_intra[]
static
Initial value:
= {
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
}

Definition at line 36 of file ps.c.

Referenced by set_default_scaling_list_data().

◆ default_scaling_list_inter

const uint8_t default_scaling_list_inter[]
static
Initial value:
= {
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
}

Definition at line 47 of file ps.c.

Referenced by set_default_scaling_list_data().

◆ hevc_sub_width_c

const uint8_t hevc_sub_width_c[]
static
Initial value:
= {
1, 2, 2, 1
}

Definition at line 58 of file ps.c.

Referenced by read_window().

◆ hevc_sub_height_c

const uint8_t hevc_sub_height_c[]
static
Initial value:
= {
1, 2, 1, 1
}

Definition at line 62 of file ps.c.

Referenced by read_window().