[FFmpeg-devel] [PATCH 1/2] mpegts: add all stream languages into metadata

Måns Rullgård mans
Mon Mar 7 20:48:47 CET 2011


"Ronald S. Bultje" <rsbultje at gmail.com> writes:

> Hi,
>
> On Thu, Feb 17, 2011 at 10:26 AM, Anssi Hannula <anssi.hannula at iki.fi> wrote:
>> This is used at least on some older DVB broadcasts for dual-mono audio
>> tracks.
>> ---
>>
>> Here goes the patchset without the channelX/language stuff.
>> I also changed the language separator from '+' from ',', but I'm open
>> to bikeshedding.
>>
>> ?libavformat/mpegts.c | ? 18 ++++++++++++------
>> ?1 files changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index abb6f08..c7e4fe3 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -890,7 +890,8 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>> ?{
>> ? ? const uint8_t *desc_end;
>> ? ? int desc_len, desc_tag;
>> - ? ?char language[4];
>> + ? ?char language[252];
>> + ? ?int i;
>>
>> ? ? desc_tag = get8(pp, desc_list_end);
>> ? ? if (desc_tag < 0)
>> @@ -949,16 +950,21 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>> ? ? ? ? av_metadata_set2(&st->metadata, "language", language, 0);
>> ? ? ? ? break;
>> ? ? case 0x0a: /* ISO 639 language descriptor */
>> - ? ? ? ?language[0] = get8(pp, desc_end);
>> - ? ? ? ?language[1] = get8(pp, desc_end);
>> - ? ? ? ?language[2] = get8(pp, desc_end);
>> - ? ? ? ?language[3] = 0;
>> - ? ? ? ?av_metadata_set2(&st->metadata, "language", language, 0);
>> + ? ? ? ?for (i = 0; i + 4 <= desc_len; i += 4) {
>> + ? ? ? ? ? ?language[i + 0] = get8(pp, desc_end);
>> + ? ? ? ? ? ?language[i + 1] = get8(pp, desc_end);
>> + ? ? ? ? ? ?language[i + 2] = get8(pp, desc_end);
>> + ? ? ? ? ? ?language[i + 3] = ',';
>> ? ? ? ? switch (get8(pp, desc_end)) {
>> ? ? ? ? ? ? case 0x01: st->disposition |= AV_DISPOSITION_CLEAN_EFFECTS; break;
>> ? ? ? ? ? ? case 0x02: st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; break;
>> ? ? ? ? ? ? case 0x03: st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; break;
>> ? ? ? ? }
>> + ? ? ? ?}
>> + ? ? ? ?if (i) {
>> + ? ? ? ? ? ?language[i - 1] = 0;
>> + ? ? ? ? ? ?av_metadata_set2(&st->metadata, "language", language, 0);
>> + ? ? ? ?}
>
> if language[] is 252 bytes, can this overflow? There's no checks for i
> being under 252.

desc_len is an 8-bit field in the stream.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list