summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxylosper <darklin20@gmail.com>2014-02-14 23:44:13 +0900
committerwm4 <wm4@nowhere>2014-03-11 00:09:52 +0100
commitd85772261858f5d03ee9b6b420de00d6a0139b30 (patch)
tree012a0de6411899d6ab1c49a32e5aadd67f142068
parent6d9d597b10f968906f5964202f1866b379d1ad97 (diff)
downloadmpv-d85772261858f5d03ee9b6b420de00d6a0139b30.tar.bz2
mpv-d85772261858f5d03ee9b6b420de00d6a0139b30.tar.xz
sd_lavc: handle subtitles with no subtitle resolution set
Set subtitle resolution to video resolution when avctx->width and avctx->height are zero. This can happen with broken vobsubs that have no size set in their .idx file (or Matroska extradata). At least with the test file provided in issue #551, using the video resolution as fallback instead of what guess_resolution() does is better. Note that these files clearly are broken. It seems this particular file was created by trying to use ffmpeg to transcode DVB subtitles to vobsub, and ffmpeg "forgot" to set the subtitle resolution in the destination file. On the other hand, ffmpeg DVB and PGS decoders set the resolution on the first subtitle packet (or somewhere close), so it's not really clear what to do here. Closes #551. Signed-off-by: wm4 <wm4@nowhere> Patch by xylosper, rewritten commit message by wm4.
-rw-r--r--sub/sd_lavc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 0252a37207..c46e52cb70 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -91,6 +91,10 @@ static void get_resolution(struct sd *sd, int wh[2])
struct sd_lavc_priv *priv = sd->priv;
wh[0] = priv->avctx->width;
wh[1] = priv->avctx->height;
+ if (wh[0] <= 0 || wh[1] <= 0) {
+ wh[0] = priv->video_params.w;
+ wh[1] = priv->video_params.h;
+ }
guess_resolution(priv->avctx->codec_id, &wh[0], &wh[1]);
}