From 7ea1d650a950d9211cce944226ca3b66c8d96dbb Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Mon, 29 Aug 2022 11:08:21 +0200 Subject: [PATCH] bestsource: Fixes to fps and colorspace conversion Some of these got lost in the process before. For now, default to 709 if the colorspace is unkown. More detailed colorspace guessing can be added in the future. --- src/video_provider_bestsource.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video_provider_bestsource.cpp b/src/video_provider_bestsource.cpp index 3b5e0834c..a75a8c676 100644 --- a/src/video_provider_bestsource.cpp +++ b/src/video_provider_bestsource.cpp @@ -147,7 +147,7 @@ BSVideoProvider::BSVideoProvider(agi::fs::path const& filename, std::string cons Keyframes.push_back(n); } - TimecodesVector.push_back((int) frame->GetAVFrame()->pts); + TimecodesVector.push_back(frame->Pts * properties.TimeBase.Den / properties.TimeBase.Num); ps->SetProgress(n, properties.NumFrames); } @@ -182,6 +182,14 @@ void BSVideoProvider::GetFrame(int n, VideoFrame &out) { throw VideoDecodeError("Couldn't convert frame!"); } + int range = frame->color_range == AVCOL_RANGE_JPEG; + const int *coefficients = sws_getCoefficients(frame->colorspace == AVCOL_SPC_UNSPECIFIED ? AVCOL_SPC_BT709 : frame->colorspace); + + sws_setColorspaceDetails(context, + coefficients, range, + coefficients, range, + 0, 1 << 16, 1 << 16); + out.data.resize(frame->width * frame->height * 4); uint8_t *data[1] = {&out.data[0]}; int stride[1] = {frame->width * 4};