mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
[mpp_enc]: Add color range support
1. Change interface for adding color range to MppPrepCfg. 2. Add option in MppEncCfg. 3. Add H.264 / H.265 sps support on full / limit range. IMPORTANT: the binary backward compatibility is broken since this commit. Change-Id: Ib68f29bab5c6d364fe8b612bd4dff2ecd5bc59cd Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -56,6 +56,17 @@ typedef enum {
|
|||||||
MPP_FRAME_RANGE_NB, ///< Not part of ABI
|
MPP_FRAME_RANGE_NB, ///< Not part of ABI
|
||||||
} MppFrameColorRange;
|
} MppFrameColorRange;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MPP_FRAME_VIDEO_FMT_COMPONEMT = 0,
|
||||||
|
MPP_FRAME_VIDEO_FMT_PAL = 1,
|
||||||
|
MPP_FRAME_VIDEO_FMT_NTSC = 2,
|
||||||
|
MPP_FRAME_VIDEO_FMT_SECAM = 3,
|
||||||
|
MPP_FRAME_VIDEO_FMT_MAC = 4,
|
||||||
|
MPP_FRAME_VIDEO_FMT_UNSPECIFIED = 5,
|
||||||
|
MPP_FRAME_VIDEO_FMT_RESERVED0 = 6,
|
||||||
|
MPP_FRAME_VIDEO_FMT_RESERVED1 = 7,
|
||||||
|
} MppFrameVideoFormat;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Chromaticity coordinates of the source primaries.
|
* Chromaticity coordinates of the source primaries.
|
||||||
*/
|
*/
|
||||||
|
@@ -349,6 +349,7 @@ typedef struct MppEncPrepCfg_t {
|
|||||||
*/
|
*/
|
||||||
MppFrameFormat format;
|
MppFrameFormat format;
|
||||||
MppFrameColorSpace color;
|
MppFrameColorSpace color;
|
||||||
|
MppFrameColorRange range;
|
||||||
|
|
||||||
MppEncRotationCfg rotation;
|
MppEncRotationCfg rotation;
|
||||||
|
|
||||||
|
@@ -170,6 +170,7 @@ static const char *cfg_func_names[] = {
|
|||||||
ENTRY(prep, ver_stride, S32, RK_S32, MPP_ENC_PREP_CFG_CHANGE_INPUT, prep, ver_stride) \
|
ENTRY(prep, ver_stride, S32, RK_S32, MPP_ENC_PREP_CFG_CHANGE_INPUT, prep, ver_stride) \
|
||||||
ENTRY(prep, format, S32, MppFrameFormat, MPP_ENC_PREP_CFG_CHANGE_FORMAT, prep, format) \
|
ENTRY(prep, format, S32, MppFrameFormat, MPP_ENC_PREP_CFG_CHANGE_FORMAT, prep, format) \
|
||||||
ENTRY(prep, color, S32, MppFrameColorSpace,MPP_ENC_PREP_CFG_CHANGE_FORMAT, prep, color) \
|
ENTRY(prep, color, S32, MppFrameColorSpace,MPP_ENC_PREP_CFG_CHANGE_FORMAT, prep, color) \
|
||||||
|
ENTRY(prep, range, S32, MppFrameColorRange,MPP_ENC_PREP_CFG_CHANGE_FORMAT, prep, range) \
|
||||||
ENTRY(prep, rotation, S32, MppEncRotationCfg, MPP_ENC_PREP_CFG_CHANGE_ROTATION, prep, rotation) \
|
ENTRY(prep, rotation, S32, MppEncRotationCfg, MPP_ENC_PREP_CFG_CHANGE_ROTATION, prep, rotation) \
|
||||||
ENTRY(prep, mirroring, S32, RK_S32, MPP_ENC_PREP_CFG_CHANGE_MIRRORING, prep, mirroring) \
|
ENTRY(prep, mirroring, S32, RK_S32, MPP_ENC_PREP_CFG_CHANGE_MIRRORING, prep, mirroring) \
|
||||||
/* codec coding config */ \
|
/* codec coding config */ \
|
||||||
|
@@ -202,8 +202,11 @@ static MPP_RET h264e_proc_prep_cfg(MppEncPrepCfg *dst, MppEncPrepCfg *src)
|
|||||||
if (change) {
|
if (change) {
|
||||||
MppEncPrepCfg bak = *dst;
|
MppEncPrepCfg bak = *dst;
|
||||||
|
|
||||||
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT)
|
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT) {
|
||||||
dst->format = src->format;
|
dst->format = src->format;
|
||||||
|
dst->color = src->color;
|
||||||
|
dst->range = src->range;
|
||||||
|
}
|
||||||
|
|
||||||
if (change & MPP_ENC_PREP_CFG_CHANGE_ROTATION)
|
if (change & MPP_ENC_PREP_CFG_CHANGE_ROTATION)
|
||||||
dst->rotation = src->rotation;
|
dst->rotation = src->rotation;
|
||||||
|
@@ -164,6 +164,11 @@ MPP_RET h264e_sps_update(SynH264eSps *sps, MppEncCfgSet *cfg, MppDeviceId dev)
|
|||||||
vui->time_scale = rc->fps_out_num * 2;
|
vui->time_scale = rc->fps_out_num * 2;
|
||||||
vui->num_units_in_tick = rc->fps_out_denorm;
|
vui->num_units_in_tick = rc->fps_out_denorm;
|
||||||
vui->fixed_frame_rate = !rc->fps_out_flex;
|
vui->fixed_frame_rate = !rc->fps_out_flex;
|
||||||
|
vui->vidformat = MPP_FRAME_VIDEO_FMT_UNSPECIFIED;
|
||||||
|
if (prep->range == MPP_FRAME_RANGE_JPEG) {
|
||||||
|
vui->signal_type_present = 1;
|
||||||
|
vui->fullrange = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -211,8 +211,11 @@ MPP_RET h265e_set_sps(H265eCtx *ctx, H265eSps *sps, H265eVps *vps)
|
|||||||
sps->vui.m_overscanInfoPresentFlag = 0;
|
sps->vui.m_overscanInfoPresentFlag = 0;
|
||||||
sps->vui.m_overscanAppropriateFlag = 0;
|
sps->vui.m_overscanAppropriateFlag = 0;
|
||||||
sps->vui.m_videoSignalTypePresentFlag = 0;
|
sps->vui.m_videoSignalTypePresentFlag = 0;
|
||||||
sps->vui.m_videoFormat = 5;
|
sps->vui.m_videoFormat = MPP_FRAME_VIDEO_FMT_UNSPECIFIED;
|
||||||
sps->vui.m_videoFullRangeFlag = 0;
|
if (prep->range == MPP_FRAME_RANGE_JPEG) {
|
||||||
|
sps->vui.m_videoFullRangeFlag = 1;
|
||||||
|
sps->vui.m_videoSignalTypePresentFlag = 1;
|
||||||
|
}
|
||||||
sps->vui.m_colourDescriptionPresentFlag = 0;
|
sps->vui.m_colourDescriptionPresentFlag = 0;
|
||||||
sps->vui.m_colourPrimaries = 2;
|
sps->vui.m_colourPrimaries = 2;
|
||||||
sps->vui.m_transferCharacteristics = 2;
|
sps->vui.m_transferCharacteristics = 2;
|
||||||
@@ -237,10 +240,6 @@ MPP_RET h265e_set_sps(H265eCtx *ctx, H265eSps *sps, H265eVps *vps)
|
|||||||
sps->vui.m_aspectRatioInfoPresentFlag = !!vui->vui_aspect_ratio;
|
sps->vui.m_aspectRatioInfoPresentFlag = !!vui->vui_aspect_ratio;
|
||||||
sps->vui.m_aspectRatioIdc = vui->vui_aspect_ratio;
|
sps->vui.m_aspectRatioIdc = vui->vui_aspect_ratio;
|
||||||
}
|
}
|
||||||
if (vui->full_range) {
|
|
||||||
sps->vui.m_videoFullRangeFlag = 1;
|
|
||||||
sps->vui.m_videoSignalTypePresentFlag = 1;
|
|
||||||
}
|
|
||||||
sps->vui.m_timingInfo.m_timingInfoPresentFlag = 1;
|
sps->vui.m_timingInfo.m_timingInfoPresentFlag = 1;
|
||||||
sps->vui.m_timingInfo.m_numUnitsInTick = i_timebase_num;
|
sps->vui.m_timingInfo.m_numUnitsInTick = i_timebase_num;
|
||||||
sps->vui.m_timingInfo.m_timeScale = i_timebase_den;
|
sps->vui.m_timingInfo.m_timeScale = i_timebase_den;
|
||||||
|
@@ -734,8 +734,11 @@ void mpp_enc_update_prep_cfg(MppEncPrepCfg *dst, MppEncPrepCfg *src)
|
|||||||
|
|
||||||
if (change) {
|
if (change) {
|
||||||
|
|
||||||
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT)
|
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT) {
|
||||||
dst->format = src->format;
|
dst->format = src->format;
|
||||||
|
dst->color = src->color;
|
||||||
|
dst->range = src->range;
|
||||||
|
}
|
||||||
|
|
||||||
if (change & MPP_ENC_PREP_CFG_CHANGE_ROTATION)
|
if (change & MPP_ENC_PREP_CFG_CHANGE_ROTATION)
|
||||||
dst->rotation = src->rotation;
|
dst->rotation = src->rotation;
|
||||||
|
Reference in New Issue
Block a user