diff --git a/deps/media-playback/media-playback/media.c b/deps/media-playback/media-playback/media.c index a951e1052..11f2f61e9 100644 --- a/deps/media-playback/media-playback/media.c +++ b/deps/media-playback/media-playback/media.c @@ -419,10 +419,9 @@ static void mp_media_next_video(mp_media_t *m, bool preload) frame->format = new_format; frame->full_range = new_range == VIDEO_RANGE_FULL; - success = video_format_get_parameters(new_space, new_range, - frame->color_matrix, - frame->color_range_min, - frame->color_range_max); + success = video_format_get_parameters_for_format( + new_space, new_range, new_format, frame->color_matrix, + frame->color_range_min, frame->color_range_max); frame->format = new_format; m->cur_space = new_space; diff --git a/libobs/obs.c b/libobs/obs.c index 48409db79..72e406e78 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -546,8 +546,9 @@ static inline void set_video_matrix(struct obs_core_video *video, struct vec4 r_row; if (format_is_yuv(ovi->output_format)) { - video_format_get_parameters(ovi->colorspace, ovi->range, - (float *)&mat, NULL, NULL); + video_format_get_parameters_for_format( + ovi->colorspace, ovi->range, ovi->output_format, + (float *)&mat, NULL, NULL); matrix4_inv(&mat, &mat); /* swap R and G */ diff --git a/plugins/aja/aja-source.cpp b/plugins/aja/aja-source.cpp index cdead9233..7cda6de9a 100644 --- a/plugins/aja/aja-source.cpp +++ b/plugins/aja/aja-source.cpp @@ -149,21 +149,25 @@ void AJASource::GenerateTestPattern(NTV2VideoFormat vf, NTV2PixelFormat pf, return; } + const enum video_format obs_vid_fmt = + aja::AJAPixelFormatToOBSVideoFormat(pix_fmt); + struct obs_source_frame2 obsFrame; obsFrame.flip = false; obsFrame.timestamp = os_gettime_ns(); obsFrame.width = fd.GetRasterWidth(); obsFrame.height = fd.GetRasterHeight(); - obsFrame.format = aja::AJAPixelFormatToOBSVideoFormat(pix_fmt); + obsFrame.format = obs_vid_fmt; obsFrame.data[0] = mTestPattern.data(); obsFrame.linesize[0] = fd.GetBytesPerRow(); video_colorspace colorspace = VIDEO_CS_709; if (NTV2_IS_SD_VIDEO_FORMAT(vid_fmt)) colorspace = VIDEO_CS_601; - video_format_get_parameters(colorspace, VIDEO_RANGE_PARTIAL, - obsFrame.color_matrix, - obsFrame.color_range_min, - obsFrame.color_range_max); + video_format_get_parameters_for_format(colorspace, VIDEO_RANGE_PARTIAL, + obs_vid_fmt, + obsFrame.color_matrix, + obsFrame.color_range_min, + obsFrame.color_range_max); obs_source_output_video2(mSource, &obsFrame); blog(LOG_DEBUG, "AJASource::GenerateTestPattern: Black"); } @@ -354,24 +358,27 @@ void AJASource::CaptureThread(AJAThread *thread, void *data) actualVideoFormat = aja::GetLevelAFormatForLevelBFormat( videoFormat); + const enum video_format obs_vid_fmt = + aja::AJAPixelFormatToOBSVideoFormat( + sourceProps.pixelFormat); + NTV2FormatDesc fd(actualVideoFormat, pixelFormat); struct obs_source_frame2 obsFrame; obsFrame.flip = false; obsFrame.timestamp = os_gettime_ns(); obsFrame.width = fd.GetRasterWidth(); obsFrame.height = fd.GetRasterHeight(); - obsFrame.format = aja::AJAPixelFormatToOBSVideoFormat( - sourceProps.pixelFormat); + obsFrame.format = obs_vid_fmt; obsFrame.data[0] = reinterpret_cast( (ULWord *)ajaSource->mVideoBuffer.GetHostPointer()); obsFrame.linesize[0] = fd.GetBytesPerRow(); video_colorspace colorspace = VIDEO_CS_709; if (NTV2_IS_SD_VIDEO_FORMAT(actualVideoFormat)) colorspace = VIDEO_CS_601; - video_format_get_parameters(colorspace, VIDEO_RANGE_PARTIAL, - obsFrame.color_matrix, - obsFrame.color_range_min, - obsFrame.color_range_max); + video_format_get_parameters_for_format( + colorspace, VIDEO_RANGE_PARTIAL, obs_vid_fmt, + obsFrame.color_matrix, obsFrame.color_range_min, + obsFrame.color_range_max); obs_source_output_video2(ajaSource->mSource, &obsFrame); diff --git a/plugins/decklink/decklink-device-instance.cpp b/plugins/decklink/decklink-device-instance.cpp index e7beead57..dbe5ef67c 100644 --- a/plugins/decklink/decklink-device-instance.cpp +++ b/plugins/decklink/decklink-device-instance.cpp @@ -305,7 +305,8 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_) if (mode_ == nullptr) return; - currentFrame.format = ConvertPixelFormat(pixelFormat); + const enum video_format format = ConvertPixelFormat(pixelFormat); + currentFrame.format = format; colorSpace = static_cast(decklink)->GetColorSpace(); if (colorSpace == VIDEO_CS_DEFAULT) { @@ -323,10 +324,9 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_) colorRange = static_cast(decklink)->GetColorRange(); currentFrame.range = colorRange; - video_format_get_parameters(activeColorSpace, colorRange, - currentFrame.color_matrix, - currentFrame.color_range_min, - currentFrame.color_range_max); + video_format_get_parameters_for_format( + activeColorSpace, colorRange, format, currentFrame.color_matrix, + currentFrame.color_range_min, currentFrame.color_range_max); delete convertFrame; diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index adcbb9bae..b3c613749 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -121,12 +121,16 @@ static void v4l2_prep_obs_frame(struct v4l2_data *data, memset(frame, 0, sizeof(struct obs_source_frame)); memset(plane_offsets, 0, sizeof(size_t) * MAX_AV_PLANES); + const enum video_format format = v4l2_to_obs_video_format(data->pixfmt); + frame->width = data->width; frame->height = data->height; - frame->format = v4l2_to_obs_video_format(data->pixfmt); - video_format_get_parameters(VIDEO_CS_DEFAULT, data->color_range, - frame->color_matrix, frame->color_range_min, - frame->color_range_max); + frame->format = format; + video_format_get_parameters_for_format(VIDEO_CS_DEFAULT, + data->color_range, format, + frame->color_matrix, + frame->color_range_min, + frame->color_range_max); switch (data->pixfmt) { case V4L2_PIX_FMT_NV12: diff --git a/plugins/mac-avcapture/av-capture.mm b/plugins/mac-avcapture/av-capture.mm index 3827a77cb..e3513ba21 100644 --- a/plugins/mac-avcapture/av-capture.mm +++ b/plugins/mac-avcapture/av-capture.mm @@ -493,9 +493,9 @@ static inline bool update_colorspace(av_capture *capture, frame->full_range = full_range; - if (!video_format_get_parameters(colorspace, range, frame->color_matrix, - frame->color_range_min, - frame->color_range_max)) { + if (!video_format_get_parameters_for_format( + colorspace, range, frame->format, frame->color_matrix, + frame->color_range_min, frame->color_range_max)) { AVLOG(LOG_ERROR, "Failed to get colorspace parameters for " "colorspace %u range %u", diff --git a/plugins/vlc-video/vlc-video-source.c b/plugins/vlc-video/vlc-video-source.c index bf5d698d8..3ed181e19 100644 --- a/plugins/vlc-video/vlc-video-source.c +++ b/plugins/vlc-video/vlc-video-source.c @@ -420,10 +420,10 @@ static unsigned vlcs_video_format(void **p_data, char *chroma, unsigned *width, c->frame.full_range = new_range; range = c->frame.full_range ? VIDEO_RANGE_FULL : VIDEO_RANGE_PARTIAL; - video_format_get_parameters(VIDEO_CS_DEFAULT, range, - c->frame.color_matrix, - c->frame.color_range_min, - c->frame.color_range_max); + video_format_get_parameters_for_format( + VIDEO_CS_DEFAULT, range, new_format, + c->frame.color_matrix, c->frame.color_range_min, + c->frame.color_range_max); } while (c->frame.data[i]) { diff --git a/plugins/win-dshow/ffmpeg-decode.c b/plugins/win-dshow/ffmpeg-decode.c index 878fe11a0..67cf96ec8 100644 --- a/plugins/win-dshow/ffmpeg-decode.c +++ b/plugins/win-dshow/ffmpeg-decode.c @@ -368,7 +368,9 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode, uint8_t *data, frame->linesize[i] = decode->frame->linesize[i]; } - frame->format = convert_pixel_format(decode->frame->format); + const enum video_format format = + convert_pixel_format(decode->frame->format); + frame->format = format; if (range == VIDEO_RANGE_DEFAULT) { range = (decode->frame->color_range == AVCOL_RANGE_JPEG) @@ -379,8 +381,8 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode, uint8_t *data, const enum video_colorspace cs = convert_color_space( decode->frame->colorspace, decode->frame->color_trc); - const bool success = video_format_get_parameters( - cs, range, frame->color_matrix, frame->color_range_min, + const bool success = video_format_get_parameters_for_format( + cs, range, format, frame->color_matrix, frame->color_range_min, frame->color_range_max); if (!success) { blog(LOG_ERROR, diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 15b95df56..65b7b5d07 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -1140,10 +1140,10 @@ inline bool DShowInput::Activate(obs_data_t *settings) range = GetColorRange(settings); frame.range = range; - bool success = video_format_get_parameters(cs, range, - frame.color_matrix, - frame.color_range_min, - frame.color_range_max); + bool success = video_format_get_parameters_for_format( + cs, range, ConvertVideoFormat(videoConfig.format), + frame.color_matrix, frame.color_range_min, + frame.color_range_max); if (!success) { blog(LOG_ERROR, "Failed to get video format parameters for "