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

cyril comparon cyril.comparon
Sat Apr 11 22:15:00 CEST 2009


Hi and thank you for your answers. I am new to this game so there may
be pivotal habits I don't have yet.
You're right about the patches that are not relevant when dealing with
language-tags. I should have kept them out this business.
However, I would like to understand the reasons why you think the data
structure holding the language tags should be changed. That would help
me submitting a more relevant implementation.

Happy Easter!
Cyril

2009/4/11 Michael Niedermayer <michaelni at gmx.at>:
> 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
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFJ4ODuYR7HhwQLD6sRAtZqAKCLG2A8SX4SbtZZNb+8VQFdAM/Z+gCgkLSo
> F0J6mwq9vhHGL/aMkFeOPGc=
> =ej/E
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>



More information about the ffmpeg-devel mailing list