[FFmpeg-devel] [patch] Only decode forced dvd-subtitles

Michael Niedermayer michaelni at gmx.at
Mon Sep 22 21:19:49 CEST 2014


On Fri, Sep 19, 2014 at 07:15:09PM +0200, wm4 wrote:
> On Fri, 19 Sep 2014 07:33:26 -0700
> Nicholas Robbins <nickrobbins-at-yahoo.com at ffmpeg.org> wrote:
> 
> > Ok, not to beat a dead horse, but I think I've gotten this working. I think it might work better in lavc/dvdsubdec.c. AFAICT this works and doesn't produce mangled tracks. Patch at end of email. (Sorry for the inline patch) If this is a good patch, I'll add the appropriate documentation and do a proper commit-patch 
> > 
> > 
> > 
> > diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
> > index 7355c03..874c28b 100644
> > --- a/libavcodec/dvdsubdec.c
> > +++ b/libavcodec/dvdsubdec.c
> > @@ -39,6 +39,7 @@ typedef struct DVDSubContext
> >    uint8_t  alpha[256];
> >    uint8_t *buf;
> >    int      buf_size;
> > +  int      only_dec_forced;
> > #ifdef DEBUG
> >    int sub_id;
> > #endif
> > @@ -548,6 +549,9 @@ static int dvdsub_decode(AVCodecContext *avctx,
> >      if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
> >          goto no_subtitle;
> > 
> > +    if (ctx->only_dec_forced && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
> > +        goto no_subtitle; 
> > +
> > #if defined(DEBUG)
> >      {
> >      char ppm_name[32];
> > @@ -652,6 +656,7 @@ static av_cold int dvdsub_close(AVCodecContext *avctx)
> > #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
> > static const AVOption options[] = {
> >      { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
> > +    { "only_dec_forced", "Only decode forced subtitles", OFFSET(only_dec_forced), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VD},
> >      { NULL }
> > };
> > static const AVClass dvdsub_class = {
> 
> Sorry, but didn't the discussion go towards that ffmpeg.c should filter
> out subtitles flagged as forced?

maybe but our video decoders also have options to skip things like
the loop filter or b frames.
And performance wise droping in the decoder if something is droped
can be more efficient
so i applied this, dont hesitate to flame me, if i missed something


> 
> And in fact, the PGS decoder should be changed to flag forced subs
> correctly.

agree


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140922/2ada2359/attachment.asc>


More information about the ffmpeg-devel mailing list