[Libav-user] MPEG1-2 CEA-608 CC (subtitle) decoding fails for interlaced content

ericdejong_nospam10 at gmx.net ericdejong_nospam10 at gmx.net
Mon Nov 12 14:59:16 EET 2018


I am trying to decode the CEA-608 subtitles from a MPEG transport steam.
Unfortunate only the field 1 cc data appears in the AVFrame as side data.
 
Looking into the matter deeper, it appears the subtitles are decoded but
then discarded by the mpeg decoder.
Why are captions only stored when "first_field == 0"?
Is this by standard or did I stumble upon a bug?
 
Details:
The subtitles are decoded in function mpeg_decode_a53_cc(..) and stored
in the a53_caption pointer. (mpeg12dec.c line 2223)
In the function mpeg_field_start(..) this a53_caption data is added as
sidedata to AV_FRAME (mpeg12dec.c line 1593, line 1628)
 
However, the a53_caption data is only added when s->first_field == 1 ||
s->picture_structure == PICT_FRAME.
As first_field == 0 and s->picture_structure == PICT_TOP_FIELD, the
a53_caption data is ignored. When the next field is decoded
(s->first_field == 1) the previous a53_caption data is discarded and
replaced with the data this field.
 
The application cc_extractor does extract the captions from my transport
stream. When I modify the mpeg12dec.c source to add side data in both
fields I do get the captions in my application.
 
Any help is greatly appreciated.


More information about the Libav-user mailing list