Skip to content

Commit

Permalink
AV1エンコードでフルレンジのフラグを設定するように。 ( #93 )
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Nov 7, 2023
1 parent 56d9e04 commit aa4ba4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions VCECore/rgy_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ RGY_ERR RGYOutputRaw::Init(const TCHAR *strFileName, const VideoInfo *pVideoOutp
av_dict_set_int(&bsfPrm, "matrix_coefficients", pVideoOutputInfo->vui.matrix, 0);
AddMessage(RGY_LOG_DEBUG, _T("set matrix %d by %s filter\n"), pVideoOutputInfo->vui.matrix, bsf_tname.c_str());
}
if (override_always || pVideoOutputInfo->vui.colorrange != RGY_COLORRANGE_UNSPECIFIED /*undef*/) {
if (pVideoOutputInfo->codec == RGY_CODEC_AV1) {
av_dict_set(&bsfPrm, "color_range", pVideoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "pc" : "tv", 0);
AddMessage(RGY_LOG_DEBUG, _T("set color_range %s by %s filter\n"), pVideoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "full" : "limited", bsf_tname.c_str());
} else if (pVideoOutputInfo->codec == RGY_CODEC_H264 || pVideoOutputInfo->codec == RGY_CODEC_HEVC) {
av_dict_set_int(&bsfPrm, "video_full_range_flag", pVideoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? 1 : 0, 0);
AddMessage(RGY_LOG_DEBUG, _T("set color_range %s by %s filter\n"), pVideoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "full" : "limited", bsf_tname.c_str());
}
}
}
if (ENCODER_QSV || ENCODER_VCEENC) {
if (pVideoOutputInfo->vui.chromaloc != 0) {
Expand Down
12 changes: 11 additions & 1 deletion VCECore/rgy_output_avcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ RGY_ERR RGYOutputAvcodec::InitVideo(const VideoInfo *videoOutputInfo, const Avco
|| videoOutputInfo->vui.colorprim != 2
|| videoOutputInfo->vui.transfer != 2
|| videoOutputInfo->vui.matrix != 2
|| videoOutputInfo->vui.chromaloc != 0)))
|| videoOutputInfo->vui.chromaloc != 0)
|| (videoOutputInfo->codec == RGY_CODEC_AV1 && videoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL)))
|| (ENCODER_MPP
&& ((videoOutputInfo->codec == RGY_CODEC_H264 || videoOutputInfo->codec == RGY_CODEC_HEVC) // HEVCの時は常に上書き)
|| (videoOutputInfo->sar[0] * videoOutputInfo->sar[1] > 0
Expand Down Expand Up @@ -1069,6 +1070,15 @@ RGY_ERR RGYOutputAvcodec::InitVideo(const VideoInfo *videoOutputInfo, const Avco
av_dict_set_int(&bsfPrm, "matrix_coefficients", videoOutputInfo->vui.matrix, 0);
AddMessage(RGY_LOG_DEBUG, _T("set matrix %d by %s filter\n"), videoOutputInfo->vui.matrix, bsf_tname.c_str());
}
if (override_always || videoOutputInfo->vui.colorrange != RGY_COLORRANGE_UNSPECIFIED /*undef*/) {
if (videoOutputInfo->codec == RGY_CODEC_AV1) {
av_dict_set(&bsfPrm, "color_range", videoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "pc" : "tv", 0);
AddMessage(RGY_LOG_DEBUG, _T("set color_range %s by %s filter\n"), videoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "full" : "limited", bsf_tname.c_str());
} else if (videoOutputInfo->codec == RGY_CODEC_H264 || videoOutputInfo->codec == RGY_CODEC_HEVC) {
av_dict_set_int(&bsfPrm, "video_full_range_flag", videoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? 1 : 0, 0);
AddMessage(RGY_LOG_DEBUG, _T("set color_range %s by %s filter\n"), videoOutputInfo->vui.colorrange == RGY_COLORRANGE_FULL ? "full" : "limited", bsf_tname.c_str());
}
}
}
if (ENCODER_QSV || ENCODER_VCEENC || ENCODER_MPP) {
if (videoOutputInfo->vui.chromaloc != 0) {
Expand Down

0 comments on commit aa4ba4a

Please sign in to comment.