Added support for "video signal type present" information.

The "Video signal type present" information is written to the output
video file when it is created, and later is used by the decoder to
properly decode the compressed video data.  The saved attributes
are:

- format type (PAL, NTSC, etc.)
- color primaries (BT709, SMPTE170M, etc.)
- transfer characteristics (BT709, SMPTE170M, etc.)
- color matrix ((BT709, SMPTE170M, etc.)

These modifications allow the client to specify these attributes
and, if specified, makes sure they are written to the output file.
This commit is contained in:
Gregory J. Wolfe
2016-02-18 11:51:51 -05:00
parent 13586a3dfc
commit f35a0daccf
4 changed files with 162 additions and 1 deletions
+89
View File
@@ -343,6 +343,81 @@ typedef struct {
unsigned int uiSliceSizeConstraint; ///< now only used when uiSliceMode=4
} SSliceArgument;
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
/**
* @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;
// ... end 02/18/2016
/**
* @brief Structure for spatial layer configuration
*/
@@ -357,6 +432,20 @@ typedef struct {
int iDLayerQp; ///< value of level IDC (0 for auto-detection)
SSliceArgument sSliceArgument;
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See also 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
// ... end 02/18/2016
} SSpatialLayerConfig;
/**
+23
View File
@@ -190,6 +190,18 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
param.sSpatialLayers[iLayer].sSliceArgument.uiSliceMbNum[idx] = 0; //default, using one row a slice if uiSliceMode is SM_RASTER_MODE
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See codec_app_def.h for more info. The default values preserve the previous behavior; i.e., no
// additional information will be written to the output file.
param.sSpatialLayers[iLayer].bVideoSignalTypePresent = false; // do not write any of the following information to the header
param.sSpatialLayers[iLayer].uiVideoFormat = VF_UNDEF; // undefined
param.sSpatialLayers[iLayer].bFullRange = false; // analog video data range [16, 235]
param.sSpatialLayers[iLayer].bColorDescriptionPresent = false; // do not write any of the following three items to the header
param.sSpatialLayers[iLayer].uiColorPrimaries = CP_UNDEF; // undefined
param.sSpatialLayers[iLayer].uiTransferCharacteristics = TRC_UNDEF; // undefined
param.sSpatialLayers[iLayer].uiColorMatrix = CM_UNDEF; // undefined
// ... end 02/18/2016
}
}
@@ -408,6 +420,17 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See codec_app_def.h and parameter_sets.h for more info.
pSpatialLayer->bVideoSignalTypePresent = pCodingParam.sSpatialLayers[iIdxSpatial].bVideoSignalTypePresent;
pSpatialLayer->uiVideoFormat = pCodingParam.sSpatialLayers[iIdxSpatial].uiVideoFormat;
pSpatialLayer->bFullRange = pCodingParam.sSpatialLayers[iIdxSpatial].bFullRange;
pSpatialLayer->bColorDescriptionPresent = pCodingParam.sSpatialLayers[iIdxSpatial].bColorDescriptionPresent;
pSpatialLayer->uiColorPrimaries = pCodingParam.sSpatialLayers[iIdxSpatial].uiColorPrimaries;
pSpatialLayer->uiTransferCharacteristics = pCodingParam.sSpatialLayers[iIdxSpatial].uiTransferCharacteristics;
pSpatialLayer->uiColorMatrix = pCodingParam.sSpatialLayers[iIdxSpatial].uiColorMatrix;
// ... end 02/18/2016
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
++ pDlp;
++ pSpatialLayer;
+15
View File
@@ -85,6 +85,21 @@ bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
// bool bSeparateColorPlaneFlag; // =false,: only used in decoder, encoder in general_***; it can be removed when removed general up_sample
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See also codec_app_def.h for definitions of enumerators EVideoFormatSPS, EColorPrimaries, ETransferCharacteristics,
// and EColorMatrix.
bool bVideoSignalTypePresent; // false => do not write any of the following information to the header
uint8_t 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
uint8_t uiColorPrimaries; // EColorPrimaries; 8 bits in header; 0 - 9 => ???, bt709, undef, ???, bt470m, bt470bg,
// smpte170m, smpte240m, film, bt2020
uint8_t 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
uint8_t uiColorMatrix; // EColorMatrix; 8 bits in header (corresponds to FFmpeg "colorspace"); 0 - 10 => GBR, bt709,
// undef, ???, fcc, bt470bg, smpte170m, smpte240m, YCgCo, bt2020nc, bt2020c
// ... end 02/18/2016
} SWelsSPS, *PWelsSPS;
+35 -1
View File
@@ -202,7 +202,29 @@ int32_t WelsWriteVUI (SWelsSPS* pSps, SBitStringAux* pBitStringAux) {
BsWriteOneBit (pLocalBitStringAux, false); //aspect_ratio_info_present_flag
BsWriteOneBit (pLocalBitStringAux, false); //overscan_info_present_flag
BsWriteOneBit (pLocalBitStringAux, false); //video_signal_type_present_flag
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See parameter_sets.h for more info.
BsWriteOneBit (pLocalBitStringAux, pSps->bVideoSignalTypePresent); //video_signal_type_present_flag
if ( pSps->bVideoSignalTypePresent )
{//write video signal type info to header
BsWriteBits (pLocalBitStringAux, 3, pSps->uiVideoFormat);
BsWriteOneBit (pLocalBitStringAux, pSps->bFullRange);
BsWriteOneBit (pLocalBitStringAux, pSps->bColorDescriptionPresent);
if ( pSps->bColorDescriptionPresent )
{//write color description info to header
BsWriteBits (pLocalBitStringAux, 8, pSps->uiColorPrimaries);
BsWriteBits (pLocalBitStringAux, 8, pSps->uiTransferCharacteristics);
BsWriteBits (pLocalBitStringAux, 8, pSps->uiColorMatrix);
}//write color description info to header
}//write video signal type info to header
// ... end 02/18/2016
BsWriteOneBit (pLocalBitStringAux, false); //chroma_loc_info_present_flag
BsWriteOneBit (pLocalBitStringAux, false); //timing_info_present_flag
BsWriteOneBit (pLocalBitStringAux, false); //nal_hrd_parameters_present_flag
@@ -517,6 +539,18 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
pSps->bGapsInFrameNumValueAllowedFlag = true;
pSps->bVuiParamPresentFlag = true;
// 02/18/2016, Greg Wolfe, Kodak Alaris: Added support for "video signal type present" information.
// See codec_app_def.h and parameter_sets.h for more info.
pSps->bVideoSignalTypePresent = pLayerParam->bVideoSignalTypePresent;
pSps->uiVideoFormat = pLayerParam->uiVideoFormat;
pSps->bFullRange = pLayerParam->bFullRange;
pSps->bColorDescriptionPresent = pLayerParam->bColorDescriptionPresent;
pSps->uiColorPrimaries = pLayerParam->uiColorPrimaries;
pSps->uiTransferCharacteristics = pLayerParam->uiTransferCharacteristics;
pSps->uiColorMatrix = pLayerParam->uiColorMatrix;
// ... end 02/18/2016
return 0;
}