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.
This commit is contained in:
wm4 2015-01-06 18:05:20 +01:00 committed by Diogo Franco (Kovensky)
parent 57f149e26a
commit cc32aa436e
1 changed files with 11 additions and 14 deletions

View File

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