mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 12:55:16 +00:00
video: move formatting of image parameters to separate function
This commit is contained in:
parent
509997ec12
commit
4136531343
@ -230,25 +230,6 @@ static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt)
|
||||
return vf_next_query_format(vf, fmt);
|
||||
}
|
||||
|
||||
static void fmt_cat(char *b, size_t bs, struct mp_image_params *p)
|
||||
{
|
||||
if (p && p->imgfmt) {
|
||||
mp_snprintf_cat(b, bs, "%dx%d", p->w, p->h);
|
||||
if (p->w != p->d_w || p->h != p->d_h)
|
||||
mp_snprintf_cat(b, bs, "->%dx%d", p->d_w, p->d_h);
|
||||
mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
|
||||
mp_snprintf_cat(b, bs, " %s/%s", mp_csp_names[p->colorspace],
|
||||
mp_csp_levels_names[p->colorlevels]);
|
||||
mp_snprintf_cat(b, bs, " CL=%d", (int)p->chroma_location);
|
||||
if (p->outputlevels)
|
||||
mp_snprintf_cat(b, bs, " out=%s", mp_csp_levels_names[p->outputlevels]);
|
||||
if (p->rotate)
|
||||
mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
|
||||
} else {
|
||||
mp_snprintf_cat(b, bs, "???");
|
||||
}
|
||||
}
|
||||
|
||||
void vf_print_filter_chain(struct vf_chain *c, int msglevel,
|
||||
struct vf_instance *vf)
|
||||
{
|
||||
@ -257,13 +238,13 @@ void vf_print_filter_chain(struct vf_chain *c, int msglevel,
|
||||
|
||||
char b[128] = {0};
|
||||
|
||||
fmt_cat(b, sizeof(b), &c->input_params);
|
||||
mp_snprintf_cat(b, sizeof(b), "%s", mp_image_params_to_str(&c->input_params));
|
||||
mp_msg(c->log, msglevel, " [vd] %s\n", b);
|
||||
|
||||
for (vf_instance_t *f = c->first; f; f = f->next) {
|
||||
b[0] = '\0';
|
||||
mp_snprintf_cat(b, sizeof(b), " [%s] ", f->info->name);
|
||||
fmt_cat(b, sizeof(b), &f->fmt_out);
|
||||
mp_snprintf_cat(b, sizeof(b), "%s", mp_image_params_to_str(&f->fmt_out));
|
||||
if (f->autoinserted)
|
||||
mp_snprintf_cat(b, sizeof(b), " [a]");
|
||||
if (f == vf)
|
||||
|
@ -455,6 +455,27 @@ void mp_image_vflip(struct mp_image *img)
|
||||
}
|
||||
}
|
||||
|
||||
char *mp_image_params_to_str_buf(char *b, size_t bs,
|
||||
const struct mp_image_params *p)
|
||||
{
|
||||
if (p && p->imgfmt) {
|
||||
snprintf(b, bs, "%dx%d", p->w, p->h);
|
||||
if (p->w != p->d_w || p->h != p->d_h)
|
||||
mp_snprintf_cat(b, bs, "->%dx%d", p->d_w, p->d_h);
|
||||
mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
|
||||
mp_snprintf_cat(b, bs, " %s/%s", mp_csp_names[p->colorspace],
|
||||
mp_csp_levels_names[p->colorlevels]);
|
||||
mp_snprintf_cat(b, bs, " CL=%d", (int)p->chroma_location);
|
||||
if (p->outputlevels)
|
||||
mp_snprintf_cat(b, bs, " out=%s", mp_csp_levels_names[p->outputlevels]);
|
||||
if (p->rotate)
|
||||
mp_snprintf_cat(b, bs, " rot=%d", p->rotate);
|
||||
} else {
|
||||
snprintf(b, bs, "???");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// Return whether the image parameters are valid.
|
||||
// Some non-essential fields are allowed to be unset (like colorspace flags).
|
||||
bool mp_image_params_valid(const struct mp_image_params *p)
|
||||
|
@ -142,6 +142,10 @@ struct mp_image *mp_image_new_external_ref(struct mp_image *img, void *arg,
|
||||
|
||||
void mp_image_params_guess_csp(struct mp_image_params *params);
|
||||
|
||||
char *mp_image_params_to_str_buf(char *b, size_t bs,
|
||||
const struct mp_image_params *p);
|
||||
#define mp_image_params_to_str(p) mp_image_params_to_str_buf((char[64]){0}, 64, p)
|
||||
|
||||
bool mp_image_params_valid(const struct mp_image_params *p);
|
||||
bool mp_image_params_equal(const struct mp_image_params *p1,
|
||||
const struct mp_image_params *p2);
|
||||
|
Loading…
Reference in New Issue
Block a user