diff --git a/src/capture_filter/resize.c b/src/capture_filter/resize.c index f9232bac1..30ef4b095 100644 --- a/src/capture_filter/resize.c +++ b/src/capture_filter/resize.c @@ -201,15 +201,13 @@ reconfigure_if_needed(struct state_resize *s, const struct video_frame *in) } struct video_desc dec_desc = video_desc_from_frame(in); s->out_desc = video_desc_from_frame(in); - const codec_t supp_rgb_in_codecs[] = { SUPPORTED_RGB_IN_INIT, + const codec_t supp_in_codecs[] = { RESIZE_SUPPORTED_PIXFMT_INIT, VIDEO_CODEC_NONE }; - if (codec_is_in_set(in->color_spec, supp_rgb_in_codecs)) { - s->out_desc.color_spec = RGB; + if (codec_is_in_set(in->color_spec, supp_in_codecs)) { + dec_desc.color_spec = in->color_spec; s->decoder = vc_memcpy; } else { - const codec_t out_cand[] = { SUPPORTED_RGB_IN_INIT, RG48, - VIDEO_CODEC_NONE }; - s->decoder = get_best_decoder_from(in->color_spec, out_cand, + s->decoder = get_best_decoder_from(in->color_spec, supp_in_codecs, &dec_desc.color_spec); if (s->decoder == NULL) { MSG(ERROR, @@ -217,8 +215,9 @@ reconfigure_if_needed(struct state_resize *s, const struct video_frame *in) get_codec_name(in->color_spec)); return false; } - s->out_desc.color_spec = dec_desc.color_spec == RG48 ? RG48 : RGB; } + s->out_desc.color_spec = + get_bits_per_component(dec_desc.color_spec) == DEPTH8 ? RGB : RG48; MSG(INFO, "Decoding through %s to output pixfmt %s.\n", get_codec_name(dec_desc.color_spec), get_codec_name(s->out_desc.color_spec)); diff --git a/src/capture_filter/resize_utils.cpp b/src/capture_filter/resize_utils.cpp index 29133eb57..5615f038b 100644 --- a/src/capture_filter/resize_utils.cpp +++ b/src/capture_filter/resize_utils.cpp @@ -114,7 +114,7 @@ static Mat ug_to_rgb_mat(codec_t codec, int width, int height, char *indata) { static int get_out_cv_data_type(codec_t pixfmt) { - return pixfmt == RG48 ? CV_16UC3 : CV_8UC3; + return get_bits_per_component(pixfmt) == DEPTH16 ? CV_16UC3 : CV_8UC3; } void @@ -133,7 +133,8 @@ resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, unsigned int target_width, unsigned int target_height) { - const codec_t out_color = in_color == RG48 ? RG48 : RGB; + const codec_t out_color = + get_bits_per_component(in_color) == 16 ? RG48 : RGB; Mat rgb = ug_to_rgb_mat(in_color, (int) width, (int) height, indata); double in_aspect = (double) width / height; diff --git a/src/capture_filter/resize_utils.h b/src/capture_filter/resize_utils.h index 88446216e..f73cf54be 100644 --- a/src/capture_filter/resize_utils.h +++ b/src/capture_filter/resize_utils.h @@ -53,7 +53,7 @@ extern "C" { #endif -#define SUPPORTED_RGB_IN_INIT RGB, RGBA, I420, UYVY, YUYV +#define RESIZE_SUPPORTED_PIXFMT_INIT RGB, RGBA, I420, UYVY, YUYV, RG48 void resize_frame_factor(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, diff --git a/src/types.h b/src/types.h index 2129e7ecb..85867aaf3 100644 --- a/src/types.h +++ b/src/types.h @@ -118,6 +118,13 @@ enum hw_accel_type { HWACCEL_COUNT }; +enum depth { + DEPTH8 = 8, + DEPTH10 = 10, + DEPTH12 = 12, + DEPTH16 = 16, +}; + enum subsampling { SUBS_420 = 4200, SUBS_422 = 4220,