Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thirdparties/common/include/wels/codec_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class ISVCEncoder {
* @param bIDR true: force encoder to encode frame as IDR frame;false, return 1 and nothing to do
* @return 0 - success; otherwise - failed;
*/
virtual int EXTAPI ForceIntraFrame (bool bIDR) = 0;
virtual int EXTAPI ForceIntraFrame (bool bIDR,int iLayerId = -1) = 0;

/**
* @brief Set option for encoder, detail option type, please refer to enumurate ENCODER_OPTION.
Expand Down
249 changes: 186 additions & 63 deletions thirdparties/common/include/wels/codec_app_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,23 @@ typedef enum {
* @brief Option types introduced in decoder application
*/
typedef enum {
DECODER_OPTION_DATAFORMAT = 0, ///< color format, now supports 23 only (I420)
DECODER_OPTION_END_OF_STREAM, ///< end of stream flag
DECODER_OPTION_END_OF_STREAM = 1, ///< end of stream flag
DECODER_OPTION_VCL_NAL, ///< feedback whether or not have VCL NAL in current AU for application layer
DECODER_OPTION_TEMPORAL_ID, ///< feedback temporal id for application layer
DECODER_OPTION_FRAME_NUM, ///< feedback current decoded frame number
DECODER_OPTION_IDR_PIC_ID, ///< feedback current frame belong to which IDR period
DECODER_OPTION_LTR_MARKING_FLAG, ///< feedback wether current frame mark a LTR
DECODER_OPTION_LTR_MARKED_FRAME_NUM, ///< feedback frame num marked by current Frame
DECODER_OPTION_ERROR_CON_IDC, ///< not finished yet, indicate decoder error concealment status, in progress
DECODER_OPTION_ERROR_CON_IDC, ///< indicate decoder error concealment method
DECODER_OPTION_TRACE_LEVEL,
DECODER_OPTION_TRACE_CALLBACK, ///< a void (*)(void* context, int level, const char* message) function which receives log messages
DECODER_OPTION_TRACE_CALLBACK_CONTEXT,///< context info of trace callbac

DECODER_OPTION_GET_STATISTICS
DECODER_OPTION_GET_STATISTICS, ///< feedback decoder statistics
DECODER_OPTION_GET_SAR_INFO, ///< feedback decoder Sample Aspect Ratio info in Vui
DECODER_OPTION_PROFILE, ///< get current AU profile info, only is used in GetOption
DECODER_OPTION_LEVEL, ///< get current AU level info,only is used in GetOption
DECODER_OPTION_STATISTICS_LOG_INTERVAL,///< set log output interval

} DECODER_OPTION;

Expand Down Expand Up @@ -235,6 +238,7 @@ typedef struct {
unsigned int uiIDRPicId; ///< distinguish request from different IDR
int iLastCorrectFrameNum;
int iCurrentFrameNum; ///< specify current decoder frame_num.
int iLayerId; //specify the layer for recovery request
} SLTRRecoverRequest;

/**
Expand All @@ -244,6 +248,7 @@ typedef struct {
unsigned int uiFeedbackType; ///< mark failed or successful
unsigned int uiIDRPicId; ///< distinguish request from different IDR
int iLTRFrameNum; ///< specify current decoder frame_num
int iLayerId; //specify the layer for LTR marking feedback
} SLTRMarkingFeedback;

/**
Expand All @@ -254,29 +259,6 @@ typedef struct {
int iLTRRefNum; ///< TODO: not supported to set it arbitrary yet
} SLTRConfig;

/**
* @brief Structure for slice argument
*/
typedef struct {
unsigned int
uiSliceMbNum[MAX_SLICES_NUM_TMP]; ///< only used when uiSliceMode=2;here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
unsigned int uiSliceNum; ///< only used when uiSliceMode=1
unsigned int uiSliceSizeConstraint; ///< only used when uiSliceMode=4
} SSliceArgument; ///< not all the elements in this argument will be used, how it will be used depends on uiSliceMode; please refer to SliceModeEnum

/**
* @brief Enumerate the type of slice mode
*/
typedef enum {
SM_SINGLE_SLICE = 0, ///< | SliceNum==1
SM_FIXEDSLCNUM_SLICE = 1, ///< | according to SliceNum | enabled dynamic slicing for multi-thread
SM_RASTER_SLICE = 2, ///< | according to SlicesAssign | need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
SM_ROWMB_SLICE = 3, ///< | according to PictureMBHeight | typical of single row of mbs each slice + slice size constraint which including re-encoding
SM_DYN_SLICE = 4, ///< | according to SliceSize | dynamic slicing (have no idea about slice_nums until encoding current frame)
SM_AUTO_SLICE = 5, ///< | according to thread number
SM_RESERVED = 6
} SliceModeEnum;

/**
* @brief Enumerate the type of rate control mode
*/
Expand Down Expand Up @@ -311,24 +293,24 @@ typedef enum {
* @brief Enumerate the type of level id
*/
typedef enum {
LEVEL_UNKNOWN,
LEVEL_1_0,
LEVEL_1_B,
LEVEL_1_1,
LEVEL_1_2,
LEVEL_1_3,
LEVEL_2_0,
LEVEL_2_1,
LEVEL_2_2,
LEVEL_3_0,
LEVEL_3_1,
LEVEL_3_2,
LEVEL_4_0,
LEVEL_4_1,
LEVEL_4_2,
LEVEL_5_0,
LEVEL_5_1,
LEVEL_5_2
LEVEL_UNKNOWN = 0,
LEVEL_1_0 = 10,
LEVEL_1_B = 9,
LEVEL_1_1 = 11,
LEVEL_1_2 = 12,
LEVEL_1_3 = 13,
LEVEL_2_0 = 20,
LEVEL_2_1 = 21,
LEVEL_2_2 = 22,
LEVEL_3_0 = 30,
LEVEL_3_1 = 31,
LEVEL_3_2 = 32,
LEVEL_4_0 = 40,
LEVEL_4_1 = 41,
LEVEL_4_2 = 42,
LEVEL_5_0 = 50,
LEVEL_5_1 = 51,
LEVEL_5_2 = 52
} ELevelIdc;

/**
Expand All @@ -347,12 +329,121 @@ enum {
};

/**
* @brief Structure for slice configuration
*/
* @brief Enumerate the type of slice mode
*/
typedef enum {
SM_SINGLE_SLICE = 0, ///< | SliceNum==1
SM_FIXEDSLCNUM_SLICE = 1, ///< | according to SliceNum | enabled dynamic slicing for multi-thread
SM_RASTER_SLICE = 2, ///< | according to SlicesAssign | need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
SM_SIZELIMITED_SLICE = 3, ///< | according to SliceSize | slicing according to size, the slicing will be dynamic(have no idea about slice_nums until encoding current frame)
SM_RESERVED = 4
} SliceModeEnum;

/**
* @brief Structure for slice argument
*/
typedef struct {
SliceModeEnum uiSliceMode; ///< by default, uiSliceMode will be SM_SINGLE_SLICE
SSliceArgument sSliceArgument;
} SSliceConfig;
unsigned int uiSliceNum; ///< only used when uiSliceMode=1, when uiSliceNum=0 means auto design it with cpu core number
unsigned int uiSliceMbNum[MAX_SLICES_NUM_TMP]; ///< only used when uiSliceMode=2; when =0 means setting one MB row a slice
unsigned int uiSliceSizeConstraint; ///< now only used when uiSliceMode=4
} SSliceArgument;

/**
* @brief Enumerate the type of video format
*/
typedef enum {
VF_COMPONENT,
VF_PAL,
VF_NTSC,
VF_SECAM,
VF_MAC,
VF_UNDEF,
VF_NUM_ENUM
} EVideoFormatSPS; // EVideoFormat is already defined/used elsewhere!

/**
* @brief Enumerate the type of color primaries
*/
typedef enum {
CP_RESERVED0,
CP_BT709,
CP_UNDEF,
CP_RESERVED3,
CP_BT470M,
CP_BT470BG,
CP_SMPTE170M,
CP_SMPTE240M,
CP_FILM,
CP_BT2020,
CP_NUM_ENUM
} EColorPrimaries;

/**
* @brief Enumerate the type of transfer characteristics
*/
typedef enum {
TRC_RESERVED0,
TRC_BT709,
TRC_UNDEF,
TRC_RESERVED3,
TRC_BT470M,
TRC_BT470BG,
TRC_SMPTE170M,
TRC_SMPTE240M,
TRC_LINEAR,
TRC_LOG100,
TRC_LOG316,
TRC_IEC61966_2_4,
TRC_BT1361E,
TRC_IEC61966_2_1,
TRC_BT2020_10,
TRC_BT2020_12,
TRC_NUM_ENUM
} ETransferCharacteristics;

/**
* @brief Enumerate the type of color matrix
*/
typedef enum {
CM_GBR,
CM_BT709,
CM_UNDEF,
CM_RESERVED3,
CM_FCC,
CM_BT470BG,
CM_SMPTE170M,
CM_SMPTE240M,
CM_YCGCO,
CM_BT2020NC,
CM_BT2020C,
CM_NUM_ENUM
} EColorMatrix;


/**
* @brief Enumerate the type of sample aspect ratio
*/
typedef enum {
ASP_UNSPECIFIED = 0,
ASP_1x1 = 1,
ASP_12x11 = 2,
ASP_10x11 = 3,
ASP_16x11 = 4,
ASP_40x33 = 5,
ASP_24x11 = 6,
ASP_20x11 = 7,
ASP_32x11 = 8,
ASP_80x33 = 9,
ASP_18x11 = 10,
ASP_15x11 = 11,
ASP_64x33 = 12,
ASP_160x99 = 13,

ASP_EXT_SAR = 255
} ESampleAspectRatio;


/**
* @brief Structure for spatial layer configuration
*/
Expand All @@ -366,7 +457,25 @@ typedef struct {
ELevelIdc uiLevelIdc; ///< value of profile IDC (0 for auto-detection)
int iDLayerQp; ///< value of level IDC (0 for auto-detection)

SSliceConfig sSliceCfg; ///< slice configuration for a layer
SSliceArgument sSliceArgument;

// Note: members bVideoSignalTypePresent through uiColorMatrix below are also defined in SWelsSPS in parameter_sets.h.
bool bVideoSignalTypePresent; // false => do not write any of the following information to the header
unsigned char uiVideoFormat; // EVideoFormatSPS; 3 bits in header; 0-5 => component, kpal, ntsc, secam, mac, undef
bool bFullRange; // false => analog video data range [16, 235]; true => full data range [0,255]
bool bColorDescriptionPresent; // false => do not write any of the following three items to the header
unsigned char uiColorPrimaries; // EColorPrimaries; 8 bits in header; 0 - 9 => ???, bt709, undef, ???, bt470m, bt470bg,
// smpte170m, smpte240m, film, bt2020
unsigned char uiTransferCharacteristics; // ETransferCharacteristics; 8 bits in header; 0 - 15 => ???, bt709, undef, ???, bt470m, bt470bg, smpte170m,
// smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12
unsigned char uiColorMatrix; // EColorMatrix; 8 bits in header (corresponds to FFmpeg "colorspace"); 0 - 10 => GBR, bt709,
// undef, ???, fcc, bt470bg, smpte170m, smpte240m, YCgCo, bt2020nc, bt2020c

bool bAspectRatioPresent; ///< aspect ratio present in VUI
ESampleAspectRatio eAspectRatio; ///< aspect ratio idc
unsigned short sAspectRatioExtWidth; ///< use if aspect ratio idc == 255
unsigned short sAspectRatioExtHeight; ///< use if aspect ratio idc == 255

} SSpatialLayerConfig;

/**
Expand Down Expand Up @@ -438,7 +547,7 @@ typedef struct TagEncParamExt {
eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL
bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI
bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC -- coming soon
bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC
int iPaddingFlag; ///< 0:disable padding;1:padding
int iEntropyCodingModeFlag; ///< 0:CAVLC 1:CABAC.

Expand All @@ -456,6 +565,7 @@ typedef struct TagEncParamExt {
/* multi-thread settings*/
unsigned short
iMultipleThreadIdc; ///< 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; lager than 1: count number of threads;
bool bUseLoadBalancing; ///< only used when uiSliceMode=1 or 3, will change slicing of a picture during the run-time of multi-thread encoding, so the result of each run may be different

/* Deblocking loop filter */
int iLoopFilterDisableIdc; ///< 0: on, 1: off, 2: on except for slice boundaries
Expand Down Expand Up @@ -485,7 +595,6 @@ typedef struct {
typedef struct TagSVCDecodingParam {
char* pFileNameRestructed; ///< file name of reconstructed frame used for PSNR calculation based debug

EVideoFormatType eOutputColorFormat; ///< color space format to be outputed, EVideoFormatType specified in codec_def.h
unsigned int uiCpuLoad; ///< CPU load
unsigned char uiTargetDqLayer; ///< setting target dq layer id

Expand All @@ -502,9 +611,14 @@ typedef struct {
unsigned char uiTemporalId;
unsigned char uiSpatialId;
unsigned char uiQualityId;

EVideoFrameType eFrameType;
unsigned char uiLayerType;

/**
* The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be
* predicted from any picture on any higher layer.
*/
int iSubSeqId; ///< refer to D.2.11 Sub-sequence information SEI message semantics
int iNalCount; ///< count number of NAL coded already
int* pNalLengthInByte; ///< length of NAL size in byte from 0 to iNalCount-1
unsigned char* pBsBuf; ///< buffer of bitstream contained
Expand All @@ -514,14 +628,6 @@ typedef struct {
* @brief Frame bit stream info
*/
typedef struct {
int iTemporalId; ///< temporal ID

/**
* The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be
* predicted from any picture on any higher layer.
*/
int iSubSeqId; ///< refer to D.2.11 Sub-sequence information SEI message semantics

int iLayerNum;
SLayerBSInfo sLayerInfo[MAX_LAYER_NUM_OF_FRAME];

Expand Down Expand Up @@ -600,11 +706,11 @@ typedef struct TagDecoderCapability {
} SDecoderCapability;

/**
* @brief to do
* @brief Structure for parse only output
*/
typedef struct TagParserBsInfo {
int iNalNum; ///< total NAL number in current AU
int iNalLenInByte [MAX_NAL_UNITS_IN_LAYER]; ///< each nal length
int *pNalLenInByte; ///< each nal length
unsigned char* pDstBuff; ///< outputted dst buffer for parsed bitstream
int iSpsWidthInPixel; ///< required SPS width info
int iSpsHeightInPixel; ///< required SPS height info
Expand Down Expand Up @@ -666,6 +772,23 @@ typedef struct TagVideoDecoderStatistics {
int iSpsNoExistNalNum; ///< number of Sps NoExist Nal
int iSubSpsNoExistNalNum; ///< number of SubSps NoExist Nal
int iPpsNoExistNalNum; ///< number of Pps NoExist Nal

unsigned int uiProfile; ///< Profile idc in syntax
unsigned int uiLevel; ///< level idc according to Annex A-1

int iCurrentActiveSpsId; ///< current active SPS id
int iCurrentActivePpsId; ///< current active PPS id

unsigned int iStatisticsLogInterval; ///< frame interval of statistics log
} SDecoderStatistics; // in building, coming soon

/**
* @brief Structure for sample aspect ratio (SAR) info in VUI
*/
typedef struct TagVuiSarInfo {
unsigned int uiSarWidth; ///< SAR width
unsigned int uiSarHeight; ///< SAR height
bool bOverscanAppropriateFlag; ///< SAR overscan flag
} SVuiSarInfo, *PVuiSarInfo;

#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
15 changes: 15 additions & 0 deletions thirdparties/common/include/wels/codec_ver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//The current file is auto-generated by script: generate_codec_ver.sh
#ifndef CODEC_VER_H
#define CODEC_VER_H

#include "codec_app_def.h"

static const OpenH264Version g_stCodecVersion = {1, 6, 0, 0};
static const char* const g_strCodecVer = "OpenH264 version:1.6.0.0";

#define OPENH264_MAJOR (1)
#define OPENH264_MINOR (6)
#define OPENH264_REVISION (0)
#define OPENH264_RESERVED (0)

#endif // CODEC_VER_H
Loading