mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs/media-io: Restore color range conversion
FFmpeg needs color range during context init to handle conversions. sws_setColorspaceDetails after the fact is too late.
This commit is contained in:
parent
743117f080
commit
3dd0f895f8
@ -297,11 +297,7 @@ static size_t video_get_input_idx(const video_t *video,
|
|||||||
|
|
||||||
static bool match_range(enum video_range_type a, enum video_range_type b)
|
static bool match_range(enum video_range_type a, enum video_range_type b)
|
||||||
{
|
{
|
||||||
//return (a == VIDEO_RANGE_FULL) == (b == VIDEO_RANGE_FULL);
|
return (a == VIDEO_RANGE_FULL) == (b == VIDEO_RANGE_FULL);
|
||||||
/* TODO: Restore test when full NV12 to limited NV12 works */
|
|
||||||
UNUSED_PARAMETER(a);
|
|
||||||
UNUSED_PARAMETER(b);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum video_colorspace collapse_space(enum video_colorspace cs)
|
static enum video_colorspace collapse_space(enum video_colorspace cs)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "video-scaler.h"
|
#include "video-scaler.h"
|
||||||
|
|
||||||
#include <libavutil/imgutils.h>
|
#include <libavutil/imgutils.h>
|
||||||
|
#include <libavutil/opt.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
|
|
||||||
struct video_scaler {
|
struct video_scaler {
|
||||||
@ -188,16 +189,27 @@ int video_scaler_create(video_scaler_t **scaler_out,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
scaler->swscale = sws_getCachedContext(NULL, src->width, src->height,
|
scaler->swscale = sws_alloc_context();
|
||||||
format_src, dst->width,
|
|
||||||
dst->height, format_dst,
|
|
||||||
scale_type, NULL, NULL, NULL);
|
|
||||||
if (!scaler->swscale) {
|
if (!scaler->swscale) {
|
||||||
blog(LOG_ERROR, "video_scaler_create: Could not create "
|
blog(LOG_ERROR, "video_scaler_create: Could not create "
|
||||||
"swscale");
|
"swscale");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_opt_set_int(scaler->swscale, "sws_flags", scale_type, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "srcw", src->width, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "srch", src->height, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "dstw", dst->width, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "dsth", dst->height, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "src_format", format_src, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "dst_format", format_dst, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "src_range", range_src, 0);
|
||||||
|
av_opt_set_int(scaler->swscale, "dst_range", range_dst, 0);
|
||||||
|
if (sws_init_context(scaler->swscale, NULL, NULL) < 0) {
|
||||||
|
blog(LOG_ERROR, "video_scaler_create: sws_init_context failed");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
ret = sws_setColorspaceDetails(scaler->swscale, coeff_src, range_src,
|
ret = sws_setColorspaceDetails(scaler->swscale, coeff_src, range_src,
|
||||||
coeff_dst, range_dst, 0, FIXED_1_0,
|
coeff_dst, range_dst, 0, FIXED_1_0,
|
||||||
FIXED_1_0);
|
FIXED_1_0);
|
||||||
|
Loading…
Reference in New Issue
Block a user