summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-05-01 23:15:50 +0200
committerwm4 <wm4@nowhere>2014-05-02 01:09:55 +0200
commit50ebcf1a432c4be5e458111b6915130424e56872 (patch)
treec43867cb9d450b6f6a86090bad4efb305c882c90 /video
parentf4eaceee0fe24a59828ce37f61173b1dd2afd8d4 (diff)
downloadmpv-50ebcf1a432c4be5e458111b6915130424e56872.tar.bz2
mpv-50ebcf1a432c4be5e458111b6915130424e56872.tar.xz
video: handle colorspace and aspect overrides separately
Now the video filter code handles these explicitly, which should increase robustness (or at least find bugs earlier).
Diffstat (limited to 'video')
-rw-r--r--video/decode/dec_video.c4
-rw-r--r--video/filter/vf.c25
-rw-r--r--video/filter/vf.h4
3 files changed, 24 insertions, 9 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 7ade93b577..b59ded7ac3 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -431,12 +431,12 @@ int video_reconfig_filters(struct dec_video *d_video,
MP_VERBOSE(d_video, "VO Config (%dx%d->%dx%d,0x%X)\n",
p.w, p.h, p.d_w, p.d_h, p.imgfmt);
- if (vf_reconfig(d_video->vfilter, &p) < 0) {
+ if (vf_reconfig(d_video->vfilter, params, &p) < 0) {
MP_FATAL(d_video, "Cannot initialize video filters.\n");
return -1;
}
- d_video->vf_input = p;
+ d_video->vf_input = *params;
return 0;
}
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 08391290a3..a812ba8136 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -245,6 +245,9 @@ void vf_print_filter_chain(struct vf_chain *c, int msglevel)
if (!mp_msg_test(c->log, msglevel))
return;
+ mp_msg(c->log, msglevel, " [vd] ");
+ print_fmt(c->log, msglevel, &c->input_params);
+ mp_msg(c->log, msglevel, "\n");
for (vf_instance_t *f = c->first; f; f = f->next) {
mp_msg(c->log, msglevel, " [%s] ", f->info->name);
print_fmt(c->log, msglevel, &f->fmt_out);
@@ -404,7 +407,8 @@ int vf_filter_frame(struct vf_chain *c, struct mp_image *img)
talloc_free(img);
return -1;
}
- vf_fix_img_params(img, &c->input_params);
+ assert(mp_image_params_equals(&img->params, &c->input_params));
+ vf_fix_img_params(img, &c->override_params);
return vf_do_filter(c->first, img);
}
@@ -583,9 +587,11 @@ static int vf_reconfig_wrapper(struct vf_instance *vf,
return r;
}
-int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params)
+// override_params is used to forcibly change the parameters of input images,
+// while params has to match the input images exactly.
+int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params,
+ const struct mp_image_params *override_params)
{
- struct mp_image_params cur = *params;
int r = 0;
vf_chain_forget_frames(c);
for (struct vf_instance *vf = c->first; vf; ) {
@@ -594,7 +600,11 @@ int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params)
vf_remove_filter(c, vf);
vf = next;
}
- c->first->fmt_in = *params;
+ c->input_params = *params;
+ c->first->fmt_in = *override_params;
+ c->override_params = *override_params;
+ struct mp_image_params cur = c->override_params;
+
uint8_t unused[IMGFMT_END - IMGFMT_START];
update_formats(c, c->first, unused);
for (struct vf_instance *vf = c->first; vf; vf = vf->next) {
@@ -603,14 +613,17 @@ int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params)
break;
cur = vf->fmt_out;
}
- c->input_params = r < 0 ? (struct mp_image_params){0} : *params;
- c->output_params = r < 0 ? (struct mp_image_params){0} : cur;
+ c->output_params = cur;
c->initialized = r < 0 ? -1 : 1;
int loglevel = r < 0 ? MSGL_WARN : MSGL_V;
if (r == -2)
MP_ERR(c, "Image formats incompatible.\n");
mp_msg(c->log, loglevel, "Video filter chain:\n");
vf_print_filter_chain(c, loglevel);
+ if (r < 0) {
+ c->input_params = c->override_params = c->output_params =
+ (struct mp_image_params){0};
+ }
return r;
}
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 399e3f1e42..5773d36105 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -103,6 +103,7 @@ struct vf_chain {
struct vf_instance *first, *last;
struct mp_image_params input_params;
+ struct mp_image_params override_params; // input to first filter
struct mp_image_params output_params;
uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START];
@@ -135,7 +136,8 @@ enum vf_ctrl {
struct vf_chain *vf_new(struct mpv_global *global);
void vf_destroy(struct vf_chain *c);
-int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params);
+int vf_reconfig(struct vf_chain *c, const struct mp_image_params *params,
+ const struct mp_image_params *override_params);
int vf_control_any(struct vf_chain *c, int cmd, void *arg);
int vf_control_by_label(struct vf_chain *c, int cmd, void *arg, bstr label);
int vf_filter_frame(struct vf_chain *c, struct mp_image *img);