obs-ffmpeg: Support Rec. 2020, I010/P010 formats
Also remove unused function, ffmpeg_to_obs_video_format.
This commit is contained in:
parent
4ae3956010
commit
4c2aa58dbe
@ -72,7 +72,15 @@ static const char *svt_av1_getname(void *unused)
|
||||
static void av1_video_info(void *data, struct video_scale_info *info)
|
||||
{
|
||||
UNUSED_PARAMETER(data);
|
||||
info->format = VIDEO_FORMAT_I420;
|
||||
|
||||
switch (info->format) {
|
||||
case VIDEO_FORMAT_I010:
|
||||
case VIDEO_FORMAT_P010:
|
||||
info->format = VIDEO_FORMAT_I010;
|
||||
break;
|
||||
default:
|
||||
info->format = VIDEO_FORMAT_I420;
|
||||
}
|
||||
}
|
||||
|
||||
static bool av1_init_codec(struct av1_encoder *enc)
|
||||
@ -190,21 +198,30 @@ static bool av1_update(struct av1_encoder *enc, obs_data_t *settings)
|
||||
|
||||
switch (info.colorspace) {
|
||||
case VIDEO_CS_601:
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE170M;
|
||||
enc->context->color_primaries = AVCOL_PRI_SMPTE170M;
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE170M;
|
||||
enc->context->colorspace = AVCOL_SPC_SMPTE170M;
|
||||
break;
|
||||
case VIDEO_CS_DEFAULT:
|
||||
case VIDEO_CS_709:
|
||||
enc->context->color_trc = AVCOL_TRC_BT709;
|
||||
enc->context->color_primaries = AVCOL_PRI_BT709;
|
||||
enc->context->color_trc = AVCOL_TRC_BT709;
|
||||
enc->context->colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_SRGB:
|
||||
enc->context->color_trc = AVCOL_TRC_IEC61966_2_1;
|
||||
enc->context->color_primaries = AVCOL_PRI_BT709;
|
||||
enc->context->color_trc = AVCOL_TRC_IEC61966_2_1;
|
||||
enc->context->colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_2020_PQ:
|
||||
enc->context->color_primaries = AVCOL_PRI_BT2020;
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE2084;
|
||||
enc->context->colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
case VIDEO_CS_2020_HLG:
|
||||
enc->context->color_primaries = AVCOL_PRI_BT2020;
|
||||
enc->context->color_trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
enc->context->colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
}
|
||||
|
||||
if (keyint_sec)
|
||||
|
@ -41,6 +41,10 @@ obs_to_ffmpeg_video_format(enum video_format format)
|
||||
return AV_PIX_FMT_YUVA422P;
|
||||
case VIDEO_FORMAT_YUVA:
|
||||
return AV_PIX_FMT_YUVA444P;
|
||||
case VIDEO_FORMAT_I010:
|
||||
return AV_PIX_FMT_YUV420P10LE;
|
||||
case VIDEO_FORMAT_P010:
|
||||
return AV_PIX_FMT_P010LE;
|
||||
case VIDEO_FORMAT_NONE:
|
||||
case VIDEO_FORMAT_YVYU:
|
||||
case VIDEO_FORMAT_AYUV:
|
||||
@ -51,42 +55,6 @@ obs_to_ffmpeg_video_format(enum video_format format)
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static inline enum video_format
|
||||
ffmpeg_to_obs_video_format(enum AVPixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case AV_PIX_FMT_YUV444P:
|
||||
return VIDEO_FORMAT_I444;
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
return VIDEO_FORMAT_I420;
|
||||
case AV_PIX_FMT_NV12:
|
||||
return VIDEO_FORMAT_NV12;
|
||||
case AV_PIX_FMT_YUYV422:
|
||||
return VIDEO_FORMAT_YUY2;
|
||||
case AV_PIX_FMT_UYVY422:
|
||||
return VIDEO_FORMAT_UYVY;
|
||||
case AV_PIX_FMT_RGBA:
|
||||
return VIDEO_FORMAT_RGBA;
|
||||
case AV_PIX_FMT_BGRA:
|
||||
return VIDEO_FORMAT_BGRA;
|
||||
case AV_PIX_FMT_GRAY8:
|
||||
return VIDEO_FORMAT_Y800;
|
||||
case AV_PIX_FMT_BGR24:
|
||||
return VIDEO_FORMAT_BGR3;
|
||||
case AV_PIX_FMT_YUV422P:
|
||||
return VIDEO_FORMAT_I422;
|
||||
case AV_PIX_FMT_YUVA420P:
|
||||
return VIDEO_FORMAT_I40A;
|
||||
case AV_PIX_FMT_YUVA422P:
|
||||
return VIDEO_FORMAT_I42A;
|
||||
case AV_PIX_FMT_YUVA444P:
|
||||
return VIDEO_FORMAT_YUVA;
|
||||
case AV_PIX_FMT_NONE:
|
||||
default:
|
||||
return VIDEO_FORMAT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static inline enum audio_format
|
||||
convert_ffmpeg_sample_format(enum AVSampleFormat format)
|
||||
{
|
||||
|
@ -144,6 +144,15 @@ static void add_video_encoder_params(struct ffmpeg_muxer *stream,
|
||||
trc = AVCOL_TRC_IEC61966_2_1;
|
||||
spc = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_2020_PQ:
|
||||
pri = AVCOL_PRI_BT2020;
|
||||
trc = AVCOL_TRC_SMPTE2084;
|
||||
spc = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
case VIDEO_CS_2020_HLG:
|
||||
pri = AVCOL_PRI_BT2020;
|
||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
spc = AVCOL_SPC_BT2020_NCL;
|
||||
}
|
||||
|
||||
const enum AVColorRange range = (info->range == VIDEO_RANGE_FULL)
|
||||
|
@ -258,21 +258,30 @@ static bool nvenc_update(struct nvenc_encoder *enc, obs_data_t *settings,
|
||||
|
||||
switch (info.colorspace) {
|
||||
case VIDEO_CS_601:
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE170M;
|
||||
enc->context->color_primaries = AVCOL_PRI_SMPTE170M;
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE170M;
|
||||
enc->context->colorspace = AVCOL_SPC_SMPTE170M;
|
||||
break;
|
||||
case VIDEO_CS_DEFAULT:
|
||||
case VIDEO_CS_709:
|
||||
enc->context->color_trc = AVCOL_TRC_BT709;
|
||||
enc->context->color_primaries = AVCOL_PRI_BT709;
|
||||
enc->context->color_trc = AVCOL_TRC_BT709;
|
||||
enc->context->colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_SRGB:
|
||||
enc->context->color_trc = AVCOL_TRC_IEC61966_2_1;
|
||||
enc->context->color_primaries = AVCOL_PRI_BT709;
|
||||
enc->context->color_trc = AVCOL_TRC_IEC61966_2_1;
|
||||
enc->context->colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_2020_PQ:
|
||||
enc->context->color_primaries = AVCOL_PRI_BT2020;
|
||||
enc->context->color_trc = AVCOL_TRC_SMPTE2084;
|
||||
enc->context->colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
case VIDEO_CS_2020_HLG:
|
||||
enc->context->color_primaries = AVCOL_PRI_BT2020;
|
||||
enc->context->color_trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
enc->context->colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
}
|
||||
|
||||
if (keyint_sec)
|
||||
|
@ -1119,28 +1119,35 @@ static bool try_connect(struct ffmpeg_output *output)
|
||||
|
||||
config.color_range = voi->range == VIDEO_RANGE_FULL ? AVCOL_RANGE_JPEG
|
||||
: AVCOL_RANGE_MPEG;
|
||||
config.colorspace = format_is_yuv(voi->format) ? AVCOL_SPC_BT709
|
||||
: AVCOL_SPC_RGB;
|
||||
switch (voi->colorspace) {
|
||||
case VIDEO_CS_601:
|
||||
config.color_primaries = AVCOL_PRI_SMPTE170M;
|
||||
config.color_trc = AVCOL_TRC_SMPTE170M;
|
||||
config.colorspace = AVCOL_SPC_SMPTE170M;
|
||||
break;
|
||||
case VIDEO_CS_DEFAULT:
|
||||
case VIDEO_CS_709:
|
||||
config.color_primaries = AVCOL_PRI_BT709;
|
||||
config.color_trc = AVCOL_TRC_BT709;
|
||||
config.colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_SRGB:
|
||||
config.color_primaries = AVCOL_PRI_BT709;
|
||||
config.color_trc = AVCOL_TRC_IEC61966_2_1;
|
||||
config.colorspace = AVCOL_SPC_BT709;
|
||||
break;
|
||||
case VIDEO_CS_2020_PQ:
|
||||
config.color_primaries = AVCOL_PRI_BT2020;
|
||||
config.color_trc = AVCOL_TRC_SMPTE2084;
|
||||
config.colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
case VIDEO_CS_2020_HLG:
|
||||
config.color_primaries = AVCOL_PRI_BT2020;
|
||||
config.color_trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
config.colorspace = AVCOL_SPC_BT2020_NCL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (format_is_yuv(voi->format)) {
|
||||
config.colorspace = (voi->colorspace == VIDEO_CS_601)
|
||||
? AVCOL_SPC_SMPTE170M
|
||||
: AVCOL_SPC_BT709;
|
||||
} else {
|
||||
config.colorspace = AVCOL_SPC_RGB;
|
||||
}
|
||||
|
||||
if (config.format == AV_PIX_FMT_NONE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user