From cc32aa436e21be055c4cb1e3149fb316e3c4e7df Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 Jan 2015 18:05:20 +0100 Subject: [PATCH] sd_lavc: apply fallback to video resolution only for vobsubs Commit 87c13de6 added a fallback to video resolution if the subtitle resolution is unknown. Apparently this fixed some broken files with vobsubs. This broke some DVB subtitles. Apparently .ts captures with 1920x1080 video resolution and 720x576 subtitles do exist. The sample at hand had some streams with 720x576 resolution and no sub resolution set, and some streams with 1920x1080 resolution and sub resolution set (both against the same 1920x1080 video). My conclusion is that 720x576 is the only reasonable fallback for DVB (but I can't be sure). The fallback is removed for PGS too. I don't know about the PGS case; it seems the sub resolution must always be set, so it shouldn't matter. Fixes #1425. --- sub/sd_lavc.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 0a969efc41..653be085c5 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -69,9 +69,18 @@ static bool supports_format(const char *format) } } -static void guess_resolution(enum AVCodecID type, int *w, int *h) +static void get_resolution(struct sd *sd, int wh[2]) { - if (type == AV_CODEC_ID_DVD_SUBTITLE) { + struct sd_lavc_priv *priv = sd->priv; + enum AVCodecID codec = priv->avctx->codec_id; + int *w = &wh[0], *h = &wh[1]; + *w = priv->avctx->width; + *h = priv->avctx->height; + if (codec == AV_CODEC_ID_DVD_SUBTITLE) { + if (*w <= 0 || *h <= 0) { + *w = priv->video_params.w; + *h = priv->video_params.h; + } /* XXX Although the video frame is some size, the SPU frame is always maximum size i.e. 720 wide and 576 or 480 high */ // For HD files in MKV the VobSub resolution can be higher though, @@ -89,18 +98,6 @@ static void guess_resolution(enum AVCodecID type, int *w, int *h) } } -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]); -} - static void set_mp4_vobsub_idx(AVCodecContext *avctx, char *src, int w, int h) { char pal_s[128];