Skip to content

Commit

Permalink
resize: fixed clang-tidy complains
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPulec committed Jan 11, 2024
1 parent c1b7f95 commit e319e21
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/capture_filter/resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ static struct video_frame *filter(void *state, struct video_frame *in)
s->decoder == vc_memcpy ? in : s->dec_frame;

resize_frame(in_frame->tiles[i].data, in_frame->color_spec,
out_frame->tiles[i].data, in_frame->tiles[i].width,
in_frame->tiles[i].height, &s->param);
out_frame->tiles[i].data, (int) in_frame->tiles[i].width,
(int) in_frame->tiles[i].height, &s->param);
}

VIDEO_FRAME_DISPOSE(in);
Expand Down
40 changes: 20 additions & 20 deletions src/capture_filter/resize_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ static Mat ug_to_rgb_mat(codec_t codec, int width, int height, char *indata) {
Mat yuv;
Mat rgb;
int pix_fmt = CV_8UC2;
int cv_color;
int num = 1, den = 1;
int cv_color = 0;
int num = 1;
int den = 1;

switch (codec) {
case RG48:
Expand Down Expand Up @@ -128,9 +129,9 @@ get_out_cv_data_type(codec_t pixfmt)
}

static void
resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, unsigned int width,
unsigned int height, unsigned int target_width,
unsigned int target_height, int algo)
resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, int width,
int height, int target_width,
int target_height, int algo)
{
const codec_t out_color =
get_bits_per_component(in_color) == 16 ? RG48 : RGB;
Expand All @@ -147,7 +148,7 @@ resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, unsigned
} else if (in_aspect > out_aspect) {
r.x = 0;
r.width = target_width;
r.height = target_width / in_aspect;
r.height = (int) (target_width / in_aspect);
r.y = (target_height - r.height) / 2;
// clear top and bottom margin
size_t linesize = vc_get_linesize(target_width, out_color);
Expand All @@ -158,13 +159,13 @@ resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, unsigned
} else {
r.y = 0;
r.height = target_height;
r.width = target_height * in_aspect;
r.width = (int) (target_height * in_aspect);
r.x = (target_width - r.width) / 2;
// clear left and right margins
size_t linesize = vc_get_linesize(target_width, out_color);
size_t left_margin_size = vc_get_linesize(r.x, out_color);
size_t right_margin_size = vc_get_linesize(target_width - r.x - r.width, out_color);
for (unsigned int i = 0; i < target_height; ++i) {
for (int i = 0; i < target_height; ++i) {
memset(outdata + i * linesize, 0, left_margin_size);
memset(outdata + (i + 1) * linesize - right_margin_size, 0, right_margin_size);
}
Expand All @@ -176,8 +177,8 @@ resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, unsigned
}

void
resize_frame(char *indata, codec_t in_color, char *outdata, unsigned int width,
unsigned int height, struct resize_param *resize_spec)
resize_frame(char *indata, codec_t in_color, char *outdata, int width,
int height, struct resize_param *resize_spec)
{
if (resize_spec->algo == RESIZE_ALGO_DFL) {
resize_spec->algo = DEFAULT_ALGO;
Expand Down Expand Up @@ -220,16 +221,15 @@ resize_algo_from_string(const char *str)
{
if (strcmp(str, "help") == 0) {
color_printf("Available resize algorithms:\n");
for (unsigned i = 0; i < sizeof interp_map / sizeof interp_map[0];
++i) {
color_printf("\t" TBOLD("%s") "%s\n", interp_map[i].name,
interp_map[i].val == DEFAULT_ALGO ? " (default)" : "");
for (auto const &i : interp_map) {
color_printf("\t" TBOLD("%s") "%s\n", i.name,
i.val == DEFAULT_ALGO ? " (default)" : "");
}
return RESIZE_ALGO_HELP_SHOWN;
}
for (unsigned i = 0; i < sizeof interp_map / sizeof interp_map[0]; ++i) {
if (strcmp(interp_map[i].name, str) == 0) {
return interp_map[i].val;
for (auto const &i : interp_map) {
if (strcmp(i.name, str) == 0) {
return i.val;
}
}
return RESIZE_ALGO_UNKN;
Expand All @@ -238,9 +238,9 @@ resize_algo_from_string(const char *str)
static const char *
resize_algo_to_string(int algo)
{
for (unsigned i = 0; i < sizeof interp_map / sizeof interp_map[0]; ++i) {
if (interp_map[i].val == algo) {
return interp_map[i].name;
for (auto const &i : interp_map) {
if (i.val == algo) {
return i.name;
}
}
return "(unknown algo!)";
Expand Down
5 changes: 2 additions & 3 deletions src/capture_filter/resize_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ struct resize_param {
};
int algo;
};
void resize_frame(char *indata, codec_t in_color, char *outdata,
unsigned int width, unsigned int height,
struct resize_param *resize_spec);
void resize_frame(char *indata, codec_t in_color, char *outdata, int width,
int height, struct resize_param *resize_spec);

#ifdef __cplusplus
}
Expand Down

0 comments on commit e319e21

Please sign in to comment.