summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options/m_config.c16
-rw-r--r--options/m_property.c10
-rw-r--r--video/filter/vf.c5
-rw-r--r--video/out/vo_vdpau.c6
-rw-r--r--video/vaapi.c19
5 files changed, 24 insertions, 32 deletions
diff --git a/options/m_config.c b/options/m_config.c
index c39f3ab41a..0f112dcefb 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -115,7 +115,6 @@ static int parse_profile(struct m_config *config, const struct m_option *opt,
static int show_profile(struct m_config *config, bstr param)
{
struct m_profile *p;
- int i, j;
if (!param.len)
return M_OPT_MISSING_PARAM;
if (!(p = m_config_get_profile(config, param))) {
@@ -126,25 +125,18 @@ static int show_profile(struct m_config *config, bstr param)
MP_INFO(config, "Profile %s: %s\n", p->name,
p->desc ? p->desc : "");
config->profile_depth++;
- for (i = 0; i < p->num_opts; i++) {
- char spc[config->profile_depth + 1];
- for (j = 0; j < config->profile_depth; j++)
- spc[j] = ' ';
- spc[config->profile_depth] = '\0';
-
- MP_INFO(config, "%s%s=%s\n", spc, p->opts[2 * i], p->opts[2 * i + 1]);
+ for (int i = 0; i < p->num_opts; i++) {
+ MP_INFO(config, "%*s%s=%s\n", config->profile_depth, "",
+ p->opts[2 * i], p->opts[2 * i + 1]);
if (config->profile_depth < MAX_PROFILE_DEPTH
&& !strcmp(p->opts[2*i], "profile")) {
char *e, *list = p->opts[2 * i + 1];
while ((e = strchr(list, ','))) {
int l = e - list;
- char tmp[l+1];
if (!l)
continue;
- memcpy(tmp, list, l);
- tmp[l] = '\0';
- show_profile(config, bstr0(tmp));
+ show_profile(config, (bstr){list, e - list});
list = e + 1;
}
if (list[0] != '\0')
diff --git a/options/m_property.c b/options/m_property.c
index 9af3c91081..9318d5b7d2 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -49,14 +49,12 @@ static struct m_property *m_property_list_find(const struct m_property *list,
static int do_action(const struct m_property *prop_list, const char *name,
int action, void *arg, void *ctx)
{
- const char *sep;
struct m_property *prop;
struct m_property_action_arg ka;
- if ((sep = strchr(name, '/')) && sep[1]) {
- int len = sep - name;
- char base[len + 1];
- memcpy(base, name, len);
- base[len] = 0;
+ const char *sep = strchr(name, '/');
+ if (sep && sep[1]) {
+ char base[128];
+ snprintf(base, sizeof(base), "%.*s", (int)(sep - name), name);
prop = m_property_list_find(prop_list, base);
ka = (struct m_property_action_arg) {
.key = sep + 1,
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 6ad484c7ff..b16c0b3627 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -269,12 +269,15 @@ static vf_instance_t *vf_open_filter(struct vf_chain *c, const char *name,
for (i = 0; args && args[2 * i]; i++)
l += 1 + strlen(args[2 * i]) + 1 + strlen(args[2 * i + 1]);
l += strlen(name);
- char str[l + 1];
+ char *str = malloc(l + 1);
+ if (!str)
+ return NULL;
char *p = str;
p += sprintf(str, "%s", name);
for (i = 0; args && args[2 * i]; i++)
p += sprintf(p, " %s=%s", args[2 * i], args[2 * i + 1]);
MP_INFO(c, "Opening video filter: [%s]\n", str);
+ free(str);
return vf_open(c, name, args);
}
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 73aae1d45c..72a08adac7 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -651,13 +651,15 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
CHECK_VDP_WARNING(vo, "OSD: error when creating surface");
}
if (imgs->scaled) {
- char zeros[sfc->packer->used_width * format_size];
- memset(zeros, 0, sizeof(zeros));
+ char *zeros = calloc(sfc->packer->used_width, format_size);
+ if (!zeros)
+ return;
vdp_st = vdp->bitmap_surface_put_bits_native(sfc->surface,
&(const void *){zeros}, &(uint32_t){0},
&(VdpRect){0, 0, sfc->packer->used_width,
sfc->packer->used_height});
CHECK_VDP_WARNING(vo, "OSD: error uploading OSD bitmap");
+ free(zeros);
}
if (sfc->surface == VDP_INVALID_HANDLE)
diff --git a/video/vaapi.c b/video/vaapi.c
index a8d27d50e4..1b4cdf6000 100644
--- a/video/vaapi.c
+++ b/video/vaapi.c
@@ -95,19 +95,16 @@ struct va_image_formats {
static void va_get_formats(struct mp_vaapi_ctx *ctx)
{
- int num = vaMaxNumImageFormats(ctx->display);
- VAImageFormat entries[num];
- VAStatus status = vaQueryImageFormats(ctx->display, entries, &num);
+ struct va_image_formats *formats = talloc_ptrtype(ctx, formats);
+ formats->num = vaMaxNumImageFormats(ctx->display);
+ formats->entries = talloc_array(formats, VAImageFormat, formats->num);
+ VAStatus status = vaQueryImageFormats(ctx->display, formats->entries,
+ &formats->num);
if (!CHECK_VA_STATUS(ctx, "vaQueryImageFormats()"))
return;
- struct va_image_formats *formats = talloc_ptrtype(ctx, formats);
- formats->entries = talloc_array(formats, VAImageFormat, num);
- formats->num = num;
- MP_VERBOSE(ctx, "%d image formats available:\n", num);
- for (int i = 0; i < num; i++) {
- formats->entries[i] = entries[i];
- MP_VERBOSE(ctx, " %s\n", VA_STR_FOURCC(entries[i].fourcc));
- }
+ MP_VERBOSE(ctx, "%d image formats available:\n", formats->num);
+ for (int i = 0; i < formats->num; i++)
+ MP_VERBOSE(ctx, " %s\n", VA_STR_FOURCC(formats->entries[i].fourcc));
ctx->image_formats = formats;
}