[FFmpeg-devel] [PATCH 3/5] mpegts: add channel specific languages into metadata

Måns Rullgård mans
Tue Feb 15 00:11:45 CET 2011


Anssi Hannula <anssi.hannula at iki.fi> writes:

> ---
>  libavformat/mpegts.c |   27 +++++++++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 8b67db4..fafd9f9 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -949,6 +949,32 @@ 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 */
> +        if (desc_len >= 8 && desc_len % 4 == 0) {
> +            /* channel-specific language tags */
> +            int ch;
> +            int tag_count = FFMIN(desc_len / 4, 10);
> +            char *combined_lang = av_malloc(tag_count * 4);
> +            if (!combined_lang)
> +                break;
> +            for (ch = 0; ch < tag_count; ch++) {
> +                char *language_key = av_strdup("channelX/language");

What does channel refer to here?

> +                if (!language_key)
> +                    break;
> +                language_key[7] = '0' + ch;
> +                language[0] = combined_lang[ch * 4 + 0] = get8(pp, desc_end);
> +                language[1] = combined_lang[ch * 4 + 1] = get8(pp, desc_end);
> +                language[2] = combined_lang[ch * 4 + 2] = get8(pp, desc_end);
> +                language[3] = 0;
> +                combined_lang[ch * 4 + 3] = '+';
> +                av_metadata_set2(&st->metadata, language_key, language,
> +                                 AV_METADATA_DONT_STRDUP_KEY);
> +                if (get8(pp, desc_end))
> +                    av_log_ask_for_sample(fc, "Multiple languages and non-zero audio_type.");
> +            }
> +            combined_lang[tag_count * 4 - 1] = 0;
> +            av_metadata_set2(&st->metadata, "language", combined_lang,
> +                             AV_METADATA_DONT_STRDUP_VAL);

I don't understand the idea behind this.  The descriptor applies to one
program element (AVStream).  If it contains several language codes, this
simply means the stream contains multiple languages.  The MPEG spec
doesn't specify any further interpretation.  Does DVB use this to
indicate multiple mono streams coded as one elementary stream?  I don't
have those specs at hand.

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



More information about the ffmpeg-devel mailing list