sd_lavc: respect forced subs only setting for DVD subs

Like the old spudec.c code did. Untested, I (probably) don't have a
sample with subtitles that have this flag set.
This commit is contained in:
wm4 2013-06-29 01:38:21 +02:00
parent ada06703fb
commit 588eef86c2
1 changed files with 9 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include "talloc.h" #include "talloc.h"
#include "core/mp_msg.h" #include "core/mp_msg.h"
#include "core/av_common.h" #include "core/av_common.h"
#include "core/options.h"
#include "demux/stheader.h" #include "demux/stheader.h"
#include "sd.h" #include "sd.h"
#include "dec_sub.h" #include "dec_sub.h"
@ -126,6 +127,7 @@ static void clear(struct sd_lavc_priv *priv)
static void decode(struct sd *sd, struct demux_packet *packet) static void decode(struct sd *sd, struct demux_packet *packet)
{ {
struct MPOpts *opts = sd->opts;
struct sd_lavc_priv *priv = sd->priv; struct sd_lavc_priv *priv = sd->priv;
AVCodecContext *ctx = priv->avctx; AVCodecContext *ctx = priv->avctx;
double pts = packet->pts; double pts = packet->pts;
@ -157,6 +159,9 @@ static void decode(struct sd *sd, struct demux_packet *packet)
if (sub.num_rects > 0) { if (sub.num_rects > 0) {
switch (sub.rects[0]->type) { switch (sub.rects[0]->type) {
case SUBTITLE_BITMAP: case SUBTITLE_BITMAP:
priv->count = 0;
priv->pts = pts;
priv->endpts = endpts;
priv->inbitmaps = talloc_array(priv, struct sub_bitmap, priv->inbitmaps = talloc_array(priv, struct sub_bitmap,
sub.num_rects); sub.num_rects);
priv->imgs = talloc_array(priv, struct osd_bmp_indexed, priv->imgs = talloc_array(priv, struct osd_bmp_indexed,
@ -165,6 +170,9 @@ static void decode(struct sd *sd, struct demux_packet *packet)
struct AVSubtitleRect *r = sub.rects[i]; struct AVSubtitleRect *r = sub.rects[i];
struct sub_bitmap *b = &priv->inbitmaps[i]; struct sub_bitmap *b = &priv->inbitmaps[i];
struct osd_bmp_indexed *img = &priv->imgs[i]; struct osd_bmp_indexed *img = &priv->imgs[i];
if (!(r->flags & AV_SUBTITLE_FLAG_FORCED) &&
opts->forced_subs_only)
continue;
img->bitmap = r->pict.data[0]; img->bitmap = r->pict.data[0];
assert(r->nb_colors > 0); assert(r->nb_colors > 0);
assert(r->nb_colors * 4 <= sizeof(img->palette)); assert(r->nb_colors * 4 <= sizeof(img->palette));
@ -175,10 +183,8 @@ static void decode(struct sd *sd, struct demux_packet *packet)
b->h = r->h; b->h = r->h;
b->x = r->x; b->x = r->x;
b->y = r->y; b->y = r->y;
priv->count++;
} }
priv->count = sub.num_rects;
priv->pts = pts;
priv->endpts = endpts;
break; break;
default: default:
mp_msg(MSGT_SUBREADER, MSGL_ERR, "sd_lavc: unsupported subtitle " mp_msg(MSGT_SUBREADER, MSGL_ERR, "sd_lavc: unsupported subtitle "