summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-30 23:01:46 +0200
committerwm4 <wm4@nowhere>2015-08-30 23:04:17 +0200
commit82f0d373fbecc18cd2ddc748f0b330160845f2cd (patch)
treea519cd102de6508c039ded4e2499caac67560f24 /video/decode
parent061b947c843dd240a29b54e76d0ad002f6821b56 (diff)
downloadmpv-82f0d373fbecc18cd2ddc748f0b330160845f2cd.tar.bz2
mpv-82f0d373fbecc18cd2ddc748f0b330160845f2cd.tar.xz
video: make container vs. bitstream aspect ratio configurable
Utterly idiotic bullshit. Fixes #2259.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/dec_video.c45
-rw-r--r--video/decode/vd_lavc.c10
2 files changed, 38 insertions, 17 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 09da72579d..34b437aa52 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -386,24 +386,45 @@ int video_reconfig_filters(struct dec_video *d_video,
struct mp_image_params p = *params;
struct sh_video *sh = d_video->header->video;
- float decoder_aspect = p.d_w / (float)p.d_h;
+ // While mp_image_params normally always have to have d_w/d_h set, the
+ // decoder signals unknown bitstream aspect ratio with both set to 0.
+ float dec_aspect = p.d_w > 0 && p.d_h > 0 ? p.d_w / (float)p.d_h : 0;
if (d_video->initial_decoder_aspect == 0)
- d_video->initial_decoder_aspect = decoder_aspect;
+ d_video->initial_decoder_aspect = dec_aspect;
+
+ bool use_container = true;
+ switch (opts->aspect_method) {
+ case 0:
+ // We normally prefer the container aspect, unless the decoder aspect
+ // changes at least once.
+ if (dec_aspect > 0 && d_video->initial_decoder_aspect != dec_aspect) {
+ MP_VERBOSE(d_video, "Using bitstream aspect ratio.\n");
+ // Even if the aspect switches back, don't use container aspect again.
+ d_video->initial_decoder_aspect = -1;
+ use_container = false;
+ }
+ break;
+ case 1:
+ use_container = false;
+ break;
+ }
- // We normally prefer the container aspect, unless the decoder aspect
- // changes at least once.
- if (d_video->initial_decoder_aspect == decoder_aspect) {
- if (sh->aspect > 0)
- vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, sh->aspect);
- } else {
- MP_VERBOSE(d_video, "Using bitstream aspect ratio.\n");
- // Even if the aspect switches back, don't use container aspect again.
- d_video->initial_decoder_aspect = -1;
+ if (use_container && sh->aspect > 0) {
+ MP_VERBOSE(d_video, "Using container aspect ratio.\n");
+ vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, sh->aspect);
}
float force_aspect = opts->movie_aspect;
- if (force_aspect >= 0.0)
+ if (force_aspect >= 0.0) {
+ MP_VERBOSE(d_video, "Forcing user-set aspect ratio.\n");
vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, force_aspect);
+ }
+
+ // Assume square pixels if no aspect ratio is set at all.
+ if (p.d_w <= 0 || p.d_h <= 0) {
+ p.d_w = p.w;
+ p.d_h = p.h;
+ }
// Detect colorspace from resolution.
mp_image_params_guess_csp(&p);
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index bc038255b7..3ba797bd0c 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -476,15 +476,12 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
av_get_pix_fmt_name(pix_fmt));
}
- int d_w, d_h;
- vf_set_dar(&d_w, &d_h, width, height, aspect);
-
*out_params = (struct mp_image_params) {
.imgfmt = ctx->best_csp,
.w = width,
.h = height,
- .d_w = d_w,
- .d_h = d_h,
+ .d_w = 0,
+ .d_h = 0,
.colorspace = avcol_spc_to_mp_csp(ctx->avctx->colorspace),
.colorlevels = avcol_range_to_mp_csp_levels(ctx->avctx->color_range),
.primaries = avcol_pri_to_mp_csp_prim(ctx->avctx->color_primaries),
@@ -495,6 +492,9 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
.stereo_in = vd->header->video->stereo_mode,
};
+ if (aspect > 0)
+ vf_set_dar(&out_params->d_w, &out_params->d_h, width, height, aspect);
+
if (opts->video_rotate < 0) {
out_params->rotate = 0;
} else {