diff --git a/src/capture_filter/resize.c b/src/capture_filter/resize.c index fcdc81dc4..c89627e07 100644 --- a/src/capture_filter/resize.c +++ b/src/capture_filter/resize.c @@ -222,18 +222,16 @@ static struct video_frame *filter(void *state, struct video_frame *in) } for (unsigned int i = 0; i < frame->tile_count; i++) { - int res; if (s->param.mode == USE_DIMENSIONS) { - res = resize_frame(in->tiles[i].data, in->color_spec, frame->tiles[i].data, in->tiles[i].width, in->tiles[i].height, s->param.target_width, s->param.target_height); + resize_frame(in->tiles[i].data, in->color_spec, + frame->tiles[i].data, in->tiles[i].width, + in->tiles[i].height, s->param.target_width, + s->param.target_height); } else { - res = resize_frame_factor(in->tiles[i].data, in->color_spec, frame->tiles[i].data, in->tiles[i].width, in->tiles[i].height, (double)s->param.num/s->param.denom); - } - - if(res!=0){ - error_msg("\n[RESIZE ERROR] Unable to resize with scale factor configured [%d/%d] in tile number %d\n", s->param.num, s->param.denom, i); - error_msg("\t\t No scale factor applied at all. No frame returns...\n"); - vf_free(frame); - return NULL; + resize_frame_factor(in->tiles[i].data, in->color_spec, + frame->tiles[i].data, in->tiles[i].width, + in->tiles[i].height, + (double) s->param.num / s->param.denom); } } diff --git a/src/capture_filter/resize_utils.cpp b/src/capture_filter/resize_utils.cpp index 1772528ac..78b81d193 100644 --- a/src/capture_filter/resize_utils.cpp +++ b/src/capture_filter/resize_utils.cpp @@ -109,27 +109,25 @@ static Mat ug_to_rgb_mat(codec_t codec, int width, int height, char *indata) { return rgb; } -int resize_frame_factor(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, double scale_factor){ +void +resize_frame_factor(char *indata, codec_t in_color, char *outdata, + unsigned int width, unsigned int height, + double scale_factor) +{ Mat rgb, out(height * scale_factor, width * scale_factor, CV_8UC3, outdata); - if (indata == NULL || outdata == NULL) { - return 1; - } - rgb = ug_to_rgb_mat(in_color, width, height, indata); resize(rgb, out, Size(0,0), scale_factor, scale_factor, INTER_LINEAR); - - return 0; } -int resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, unsigned int target_width, unsigned int target_height) { +void +resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int width, + unsigned int height, unsigned int target_width, + unsigned int target_height) +{ Mat rgb, out = cv::Mat::zeros(target_height, target_width, CV_8UC3); codec_t out_color = RGB; - if (indata == NULL || outdata == NULL) { - return 1; - } - rgb = ug_to_rgb_mat(in_color, width, height, indata); double in_aspect = (double) width / height; @@ -168,8 +166,6 @@ int resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int wid out.data = (uchar *) outdata; resize(rgb, out(r), r.size()); - - return 0; } /* vim: set expandtab sw=4: */ diff --git a/src/capture_filter/resize_utils.h b/src/capture_filter/resize_utils.h index 61085b703..79c0dd473 100644 --- a/src/capture_filter/resize_utils.h +++ b/src/capture_filter/resize_utils.h @@ -1,9 +1,11 @@ /* - * FILE: capture_filter/resize_utils.c + * FILE: capture_filter/resize_utils.h * AUTHORS: Gerard Castillo * Marc Palau + * Martin Pulec * * Copyright (c) 2005-2010 Fundació i2CAT, Internet I Innovació Digital a Catalunya + * Copyright (c) 2015-2023 CESNET, z. s. p. o. * * Redistribution and use in source and binary forms, with or without * modification, is permitted provided that the following conditions @@ -51,8 +53,12 @@ extern "C" { #endif -int resize_frame_factor(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, double scale_factor); -int resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int width, unsigned int height, unsigned int target_width, unsigned int target_height); +void resize_frame_factor(char *indata, codec_t in_color, char *outdata, + unsigned int width, unsigned int height, + double scale_factor); +void resize_frame(char *indata, codec_t in_color, char *outdata, + unsigned int width, unsigned int height, + unsigned int target_width, unsigned int target_height); #ifdef __cplusplus }