[FFmpeg-devel] [PATCH]Display DVB subtitles if display segment is missing
Carl Eugen Hoyos
cehoyos at ag.or.at
Tue Jan 24 00:36:49 CET 2012
On Monday 23 January 2012 07:20:16 pm Reimar Döffinger wrote:
> On Mon, Jan 23, 2012 at 12:22:48PM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch by Mark Kendall fixes ticket #937.
> > + int gotpage = 0, gotregion = 0, gotclut = 0, gotobject = 0,
> > gotdisplay = 0;
>
> A single got_segment and bit masks for each might be a bit nicer.
Definitely, new patch attached.
Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index e2a804a..e2b4ee6 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1452,6 +1452,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
int page_id;
int segment_length;
int i;
+ int got_segment = 0;
av_dlog(avctx, "DVB sub packet:\n");
@@ -1490,21 +1491,26 @@ static int dvbsub_decode(AVCodecContext *avctx,
switch (segment_type) {
case DVBSUB_PAGE_SEGMENT:
dvbsub_parse_page_segment(avctx, p, segment_length);
+ got_segment |= 1;
break;
case DVBSUB_REGION_SEGMENT:
dvbsub_parse_region_segment(avctx, p, segment_length);
+ got_segment |= 2;
break;
case DVBSUB_CLUT_SEGMENT:
dvbsub_parse_clut_segment(avctx, p, segment_length);
+ got_segment |= 4;
break;
case DVBSUB_OBJECT_SEGMENT:
dvbsub_parse_object_segment(avctx, p, segment_length);
+ got_segment |= 8;
break;
case DVBSUB_DISPLAYDEFINITION_SEGMENT:
dvbsub_parse_display_definition_segment(avctx, p, segment_length);
break;
case DVBSUB_DISPLAY_SEGMENT:
*data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
+ got_segment |= 16;
break;
default:
av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
@@ -1515,6 +1521,10 @@ static int dvbsub_decode(AVCodecContext *avctx,
p += segment_length;
}
+ // Some streams do not send a display segment but if we have all the other
+ // segments then we need no further data.
+ if (got_segment == 15 && sub)
+ *data_size = dvbsub_display_end_segment(avctx, p, 0, sub);
return p - buf;
}
More information about the ffmpeg-devel
mailing list