[FFmpeg-devel] Suggestion for a centralized language-tag facility in libavformat
Michael Niedermayer
michaelni
Wed Apr 22 19:53:57 CEST 2009
On Wed, Apr 22, 2009 at 05:16:13PM +0200, cyril comparon wrote:
> >> Sure thing. I wrote it using Qt4. Please find it attached
> >> (iso639tool.cpp, iso639tool.pro, iso639tool.readme).
> > there seem to be only 2 patches attached
>
> Oops, forgot to attach them. Here they are.
>
> >
> > I also found no hint in the spec that would restrict what key can be, and
> > IMHO it can be anything including NULL
> >
>
> I got rid of the temporary key object and I changed the comparison
> function to interpret its lhs arg directly as a const char* ; it seems
> to work properly with my tests but I am not sure this will work with
> all stdlib implementations...
>
> >> + ? ? ? ? ? ?stream_language_index = asf->streams[i].stream_language_index;
> >> + ? ? ? ? ? ?rfc1766 = asf->stream_languages[stream_language_index];
> >
> > this still reads outside the array
>
> I think I got messed up with my different patch versions...
>
> Thanks for your time
> Cyril
> Changelog | 1
> libavformat/avlanguage.c | 764 +++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/avlanguage.h | 39 ++
> 3 files changed, 804 insertions(+)
patch ok
[...]
> @@ -442,6 +444,58 @@
> end_header(pb, hpos);
> }
>
> + /* stream extension headers */
> + for(n=0; n<s->nb_streams; n++) {
> + enum Flags {
> + reliable_flag = 1,
> + seekable_flag = 2,
> + no_cleanpoints_flag = 4,
> + resend_live_cleanpoints_flag = 8
> + } flags = 0;
> + hpos = put_header(pb, &ff_asf_ext_stream_header);
> + put_le64(pb, 0); // starttime (optional so zero to ignore it)
> + put_le64(pb, 0); // endtime (optional so zero to ignore it)
> + AVStream *st = s->streams[n];
Mixing declarations and statements breaks gcc 2.95
> + put_le32(pb, st->codec->bit_rate); // leak-datarate
> + put_le32(pb, BUFFER_SIZE_IN_MS); // bucket-datasize
> + put_le32(pb, 0); // init-bucket-fullness
> + put_le32(pb, st->codec->bit_rate); // alt-leak-datarate
> + put_le32(pb, BUFFER_SIZE_IN_MS); // alt-bucket-datasize in milliseconds
> + put_le32(pb, 0); // alt-init-bucket-fullness
> + put_le32(pb, 0); // max-object-size (zero means unknown)
> + if (asf->nb_index_count > 0)
> + flags |= seekable_flag; // key-frames are present so the stream is seekable
> + else
> + flags |= no_cleanpoints_flag; // no key-frames
> + put_le32(pb, flags); // flags (reliable,seekable,no_cleanpoints,resend_live_cleanpoints, rest of bits reserved)
> + put_le16(pb, asf->streams[n].num); // stream-num
> + put_le16(pb, n); // stream-language-id-index
> + put_le64(pb, 0); // avg frametime in 100ns units (zero means unknown)
> + put_le16(pb, 0); // stream-name-count
> + put_le16(pb, 0); // payload-extension-system-count
> + end_header(pb, hpos);
> + }
> +
> + /* language list */
> + hpos = put_header(pb, &ff_asf_language_guid);
> + for(nbStreamsWithSupportedLang=0, n=0; n<s->nb_streams; n++) {
> + AVMetadataTag *lang_tag = av_metadata_get(s->streams[n]->metadata, "language", NULL, 0);
> + if (lang_tag && av_convertLangTo(lang_tag->value, AV_LANG_ISO639_1))
> + nbStreamsWithSupportedLang++;
> + }
> + put_le16(pb, nbStreamsWithSupportedLang);
> + for(n=0; n<s->nb_streams; n++) {
> + AVMetadataTag *lang_tag = av_metadata_get(s->streams[n]->metadata, "language", NULL, 0);
> + if (lang_tag) {
> + const char *language = av_convertLangTo(lang_tag->value, AV_LANG_ISO639_1);
> + if (language) {
> + put_byte(pb, 2*(1+strlen(language)));
> + put_str16_nolen(pb, language);
> + }
> + }
> + }
This still does not look like it would work where any of these if() false once
[...]
--
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/20090422/63fa1c9f/attachment.pgp>
More information about the ffmpeg-devel
mailing list