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.
This commit is contained in:
xylosper 2014-02-14 23:44:13 +09:00 committed by wm4
parent 6d9d597b10
commit d857722618
1 changed files with 4 additions and 0 deletions

View File

@ -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]);
}