various: use MP_ARRAY_SIZE macro

This commit is contained in:
sfan5 committed 2025-05-31 09:59:54 +02:00
1 parent 1d1535ff91
commit cf00b07536
5 files changed
+14 -14

No files matched your search

+4 -4
View File
@@ -538,7 +538,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys,
{ .cmd = DTV_TUNE },
};
struct dtv_properties cmdseq = {
.num = sizeof(p) / sizeof(p[0]),
.num = MP_ARRAY_SIZE(p),
.props = p
};
if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) {
@@ -566,7 +566,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys,
{ .cmd = DTV_TUNE },
};
struct dtv_properties cmdseq = {
.num = sizeof(p) / sizeof(p[0]),
.num = MP_ARRAY_SIZE(p),
.props = p
};
if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) {
@@ -587,7 +587,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys,
{ .cmd = DTV_TUNE },
};
struct dtv_properties cmdseq = {
.num = sizeof(p) / sizeof(p[0]),
.num = MP_ARRAY_SIZE(p),
.props = p
};
if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) {
@@ -606,7 +606,7 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys,
{ .cmd = DTV_TUNE },
};
struct dtv_properties cmdseq = {
.num = sizeof(p) / sizeof(p[0]),
.num = MP_ARRAY_SIZE(p),
.props = p
};
if (dvbv5_tune(priv, fd_frontend, delsys, &cmdseq) != 0) {
+1 -1
View File
@@ -107,7 +107,7 @@ static void print_cdtext(stream_t *s, int track)
cdtext_t *text = cdio_get_cdtext(p->cd->p_cdio);
int header = 0;
if (text) {
for (int i = 0; i < sizeof(cdtext_name) / sizeof(cdtext_name[0]); i++) {
for (int i = 0; i < MP_ARRAY_SIZE(cdtext_name); i++) {
const char *name = cdtext_name[i];
const char *value = cdtext_get_const(text, i, track);
if (name && value) {
+1 -1
View File
@@ -370,7 +370,7 @@ static int open_f(stream_t *stream)
MP_ERR(stream, "No URL\n");
goto out;
}
for (int i = 0; i < sizeof(prefix) / sizeof(prefix[0]); i++)
for (int i = 0; i < MP_ARRAY_SIZE(prefix); i++)
if (!strncmp(filename, prefix[i], strlen(prefix[i])))
filename += strlen(prefix[i]);
if (!strncmp(filename, "rtsp:", 5) || !strncmp(filename, "rtsps:", 6)) {
+2 -2
View File
@@ -1100,9 +1100,9 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
// NONE is a bit random, but the intention is: don't modify colors.
if (trackcsp == YCBCR_NONE)
return;
if (trackcsp < sizeof(ass_csp) / sizeof(ass_csp[0]))
if (trackcsp < MP_ARRAY_SIZE(ass_csp))
csp = ass_csp[trackcsp];
if (trackcsp < sizeof(ass_levels) / sizeof(ass_levels[0]))
if (trackcsp < MP_ARRAY_SIZE(ass_levels))
levels = ass_levels[trackcsp];
if (trackcsp == YCBCR_DEFAULT) {
csp = PL_COLOR_SYSTEM_BT_601;
+6 -6
View File
@@ -256,7 +256,7 @@ static bool is_good_renderer(SDL_RendererInfo *ri,
int i, j;
for (i = 0; i < ri->num_texture_formats; ++i)
for (j = 0; j < sizeof(formats) / sizeof(formats[0]); ++j)
for (j = 0; j < MP_ARRAY_SIZE(formats); ++j)
if (ri->texture_formats[i] == formats[j].sdl)
if (formats[j].is_rgba) {
if (osd_format)
@@ -468,7 +468,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
Uint32 texfmt = SDL_PIXELFORMAT_UNKNOWN;
int i, j;
for (i = 0; i < vc->renderer_info.num_texture_formats; ++i)
for (j = 0; j < sizeof(formats) / sizeof(formats[0]); ++j)
for (j = 0; j < MP_ARRAY_SIZE(formats); ++j)
if (vc->renderer_info.texture_formats[i] == formats[j].sdl)
if (params->imgfmt == formats[j].mpv)
texfmt = formats[j].sdl;
@@ -589,7 +589,7 @@ static void wait_events(struct vo *vo, int64_t until_time_ns)
// The default config does not use Ctrl, so this is fine...
int keycode = 0;
int i;
for (i = 0; i < sizeof(keys) / sizeof(keys[0]); ++i)
for (i = 0; i < MP_ARRAY_SIZE(keys); ++i)
if (keys[i].sdl == ev.key.keysym.sym) {
keycode = keys[i].mpv;
break;
@@ -612,7 +612,7 @@ static void wait_events(struct vo *vo, int64_t until_time_ns)
break;
case SDL_MOUSEBUTTONDOWN: {
int i;
for (i = 0; i < sizeof(mousebtns) / sizeof(mousebtns[0]); ++i)
for (i = 0; i < MP_ARRAY_SIZE(mousebtns); ++i)
if (mousebtns[i].sdl == ev.button.button) {
mp_input_put_key(vo->input_ctx, mousebtns[i].mpv | MP_KEY_STATE_DOWN);
break;
@@ -621,7 +621,7 @@ static void wait_events(struct vo *vo, int64_t until_time_ns)
}
case SDL_MOUSEBUTTONUP: {
int i;
for (i = 0; i < sizeof(mousebtns) / sizeof(mousebtns[0]); ++i)
for (i = 0; i < MP_ARRAY_SIZE(mousebtns); ++i)
if (mousebtns[i].sdl == ev.button.button) {
mp_input_put_key(vo->input_ctx, mousebtns[i].mpv | MP_KEY_STATE_UP);
break;
@@ -872,7 +872,7 @@ static int query_format(struct vo *vo, int format)
struct priv *vc = vo->priv;
int i, j;
for (i = 0; i < vc->renderer_info.num_texture_formats; ++i)
for (j = 0; j < sizeof(formats) / sizeof(formats[0]); ++j)
for (j = 0; j < MP_ARRAY_SIZE(formats); ++j)
if (vc->renderer_info.texture_formats[i] == formats[j].sdl)
if (format == formats[j].mpv)
return 1;