resize_utils: return void

Actually no error is handled except of wrong usage (passing NULL in/out
pointers). As the functions are used just from one place, the caller
should take responsibility that this won't happen.
This commit is contained in:
Martin Pulec
2023-11-09 10:59:40 +01:00
parent 9dae59dc5f
commit 84f827d4cb
3 changed files with 27 additions and 27 deletions

View File

@@ -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);
}
}

View File

@@ -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: */

View File

@@ -1,9 +1,11 @@
/*
* FILE: capture_filter/resize_utils.c
* FILE: capture_filter/resize_utils.h
* AUTHORS: Gerard Castillo <gerard.castillo@i2cat.net>
* Marc Palau <marc.palau@i2cat.net>
* Martin Pulec <martin.pulec@cesnet.cz>
*
* 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
}