[FFmpeg-devel] Suggestion for a centralized language-tag facility in libavformat

Michael Niedermayer michaelni
Sat Apr 11 20:26:55 CEST 2009


On Fri, Apr 10, 2009 at 07:33:16PM +0200, cyril comparon wrote:
> Hi ffmpeg crew,
> 
> I recently hacked a little on libavformat to implement :
> - some (documented) helper functions grouped into a brand new
> libavformat/avlanguages.h / .c, namely :
>     - const char *avlanguage_ISO6392toISO6391(const char *lang)
>     - const char *avlanguage_ISO6392toHumanReadable(const char *lang)
>     - const char *avlanguage_ISO6391toISO6392(const char *lang)
>     (please note these helpers are centered on the ISO639-2 code
> space, which is libavformat frontend's language representation)
> - extraction of per-stream language tag from ASF files (in asfdec.c)
> using the above helpers
> - storage of per-stream language tag in ASF files (in asfenc.c) using
> the above helpers
> 
> Everyone supporting or writing muxers/demuxers would be welcome to use
> these helpers (and maybe enrich it with new language code spaces if
> needed by a specific container format).
> 
> In case ffmpeg developers would be ready to accept this patch, there
> would be a bit of work in the frontend (e.g. regarding localized
> metadata management) to migrate to this new facility, and in
> container-specific backends (to get rid of private code-space
> converters and add language management where it is lacking).
> 
> Anyone interested can have a look at the enclosed patch file.
> Happy hacking,
> Cyril Comparon
> Resonate-MP4

> Index: libavformat/asf.c

changes to asf* belong to seperate patch(es)


[..]
> -            if (stream_num < 128)
> +            if (stream_num < MAX_STREAMS)
>                  bitrate[stream_num] = leak_rate;
>  
>              for (i=0; i<stream_ct; i++){

whatever it is it does not belong in here


[...]
> Index: libavformat/avformat.h
> ===================================================================
> --- libavformat/avformat.h	(revision 18419)
> +++ libavformat/avformat.h	(working copy)
> @@ -390,7 +390,7 @@
>      int64_t duration;
>  
>  #if LIBAVFORMAT_VERSION_INT < (53<<16)
> -    char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
> +    char language[4]; /** ISO639-2 3-letter language code (empty string if undefined) */
>  #endif
>  
>      /* av_read_frame() support */

> @@ -479,7 +479,7 @@
>      AVMetadata *metadata;
>  } AVChapter;
>  
> -#define MAX_STREAMS 20
> +#define MAX_STREAMS 80
>  
>  /**
>   * Format I/O context.

this too does not belong in here, if you want your code reviewed i suggest
you read the developer guide

[...]

> +/*ISO 639 code names 
> +- first column is 3-char code of language as per ISO/IEC 639-2 (never NULL)
> +- second column is an alternative 3-char code of language as per ISO/IEC 639-2 (may be NULL)
> +- third column is 2-char code of language as per ISO/IEC 639-1, (may be NULL)
> +- fourth column is a readable English name for the language (never NULL)
> +*/
> +static const char *languageCodes[] =
> +{
> +    "tyv", NULL , NULL, "Tuvinian",
> +    "tib", NULL , "bo", "Tibetan",
> +    "ast", NULL , "as", "Assamese",
> +    "guj", NULL , "gu", "Gujarati",
> +    "mlg", NULL , "mg", "Malagasy",
> +    "mkh", NULL , NULL, "Mon-Khmer (Other)",

diego will tell you to sort these, and i agree this must be sorted
it also must be replaced by a struct of char [3], [2], ... instead of
this string pointer mess

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090411/fb18a074/attachment.pgp>



More information about the ffmpeg-devel mailing list