+static uint16_t language_code (const char *str)
+{
+ return ((((str[0]-0x60) & 0x1F)<<10) + (((str[1]-0x60) & 0x1F)<<5) + ((str[2]-0x60) & 0x1F));
+}
+
+static int mov_write_uuidusmt_tag (ByteIOContext *pb, AVFormatContext *s)
+{
+ size_t len, size;
+ offset_t pos, curpos;
+
+ size = 0;
+ if (s->title[0]) {
+ pos = url_ftell(pb);
+ put_be32(pb, 0); /* size placeholder*/
+ put_tag(pb, "uuid");
+ put_tag(pb, "USMT");
+ put_be32(pb, 0x21d24fce ); /* 96 bit UUID */
+ put_be32(pb, 0xbb88695c );
+ put_be32(pb, 0xfac9c740 );
+ size += 24;
+
+ put_be32(pb, 0); /* size placeholder*/
+ put_tag(pb, "MTDT");
+ put_be16(pb, 4);
+ size += 10;
+
+ // ?
+ put_be16(pb, 0x0C); /* size */
+ put_be32(pb, 0x0B); /* type */
+ put_be16(pb, language_code("und")); /* language */
+ put_be16(pb, 0x0); /* ? */
+ put_be16(pb, 0x021C); /* data */
+ size += 12;
+
+ // Encoder
+ len = utf8len(LIBAVCODEC_IDENT)+1;
+ if(len<=0)
+ goto not_utf8;
+ put_be16(pb, len*2+10); /* size */
+ put_be32(pb, 0x04); /* type */
+ put_be16(pb, language_code("eng")); /* language */
+ put_be16(pb, 0x01); /* ? */
+ ascii_to_wc(pb, LIBAVCODEC_IDENT);
+ size += len*2+10;
+
+ // Title
+ len = utf8len(s->title)+1;
+ if(len<=0)
+ goto not_utf8;
+ put_be16(pb, len*2+10); /* size */
+ put_be32(pb, 0x01); /* type */
+ put_be16(pb, language_code("eng")); /* language */
+ put_be16(pb, 0x01); /* ? */
+ ascii_to_wc (pb, s->title);
+ size += len*2+10;
+
+ // Date
+// snprintf(dt,32,"%04d/%02d/%02d %02d:%02d:%02d",t_st->tm_year+1900,t_st->tm_mon+1,t_st->tm_mday,t_st->tm_hour,t_st->tm_min,t_st->tm_sec);
+ len = utf8len("2006/04/01 11:11:11")+1;
+ if(len<=0)
+ goto not_utf8;
+ put_be16(pb, len*2+10); /* size */
+ put_be32(pb, 0x03); /* type */
+ put_be16(pb, language_code("und")); /* language */
+ put_be16(pb, 0x01); /* ? */
+ ascii_to_wc (pb, "2006/04/01 11:11:11");
+ size += len*2+10;
+
+ // size
+ curpos = url_ftell(pb);
+ url_fseek(pb, pos, SEEK_SET);
+ put_be32(pb, size);
+ url_fseek(pb, pos+24, SEEK_SET);
+ put_be32(pb, size-24);
+ url_fseek(pb, curpos, SEEK_SET);