From d85772261858f5d03ee9b6b420de00d6a0139b30 Mon Sep 17 00:00:00 2001 From: xylosper Date: Fri, 14 Feb 2014 23:44:13 +0900 Subject: [PATCH] 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 Patch by xylosper, rewritten commit message by wm4. --- sub/sd_lavc.c | 4 ++++ 1 file changed, 4 insertions(+) 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]); }