[FFmpeg-cvslog] r25493 - in trunk: doc/APIchanges libavformat/asfdec.c libavformat/asfenc.c libavformat/avformat.h libavformat/avidec.c libavformat/avienc.c libavformat/flacdec.c libavformat/flacenc.c libavformat/...

aurel subversion
Fri Oct 15 21:04:26 CEST 2010


Author: aurel
Date: Fri Oct 15 21:04:25 2010
New Revision: 25493

Log:
Export metadata in the generic format. Deprecate old conversion API.
patch by Anton Khirnov  anton _at_ khirnov _dot_ net

Modified:
   trunk/doc/APIchanges
   trunk/libavformat/asfdec.c
   trunk/libavformat/asfenc.c
   trunk/libavformat/avformat.h
   trunk/libavformat/avidec.c
   trunk/libavformat/avienc.c
   trunk/libavformat/flacdec.c
   trunk/libavformat/flacenc.c
   trunk/libavformat/id3v2.c
   trunk/libavformat/matroskadec.c
   trunk/libavformat/matroskaenc.c
   trunk/libavformat/metadata.c
   trunk/libavformat/metadata.h
   trunk/libavformat/mp3.c
   trunk/libavformat/nutdec.c
   trunk/libavformat/nutenc.c
   trunk/libavformat/oggdec.c
   trunk/libavformat/oggenc.c
   trunk/libavformat/oggparsevorbis.c
   trunk/libavformat/oma.c
   trunk/libavformat/vorbiscomment.c

Modified: trunk/doc/APIchanges
==============================================================================
--- trunk/doc/APIchanges	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/doc/APIchanges	Fri Oct 15 21:04:25 2010	(r25493)
@@ -13,6 +13,11 @@ libavutil:   2009-03-08
 
 API changes, most recent first:
 
+2010-10-15 - r25493 - lavf 52.83.0 - metadata API
+  Change demuxers to export metadata in generic format and
+  muxers to accept generic format. Deprecate the public
+  conversion API.
+
 2010-10-10 - r25441 - lavfi 1.49.0 - AVFilterLink.time_base
   Add time_base field to AVFilterLink.
 

Modified: trunk/libavformat/asfdec.c
==============================================================================
--- trunk/libavformat/asfdec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/asfdec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -659,6 +659,8 @@ static int asf_read_header(AVFormatConte
         }
     }
 
+    metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv);
+
     return 0;
 }
 
@@ -1235,5 +1237,4 @@ AVInputFormat asf_demuxer = {
     asf_read_close,
     asf_read_seek,
     asf_read_pts,
-    .metadata_conv = ff_asf_metadata_conv,
 };

Modified: trunk/libavformat/asfenc.c
==============================================================================
--- trunk/libavformat/asfenc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/asfenc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -279,6 +279,8 @@ static int asf_write_header1(AVFormatCon
     int bit_rate;
     int64_t duration;
 
+    metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
+
     tags[0] = av_metadata_get(s->metadata, "title"    , NULL, 0);
     tags[1] = av_metadata_get(s->metadata, "author"   , NULL, 0);
     tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
@@ -870,7 +872,6 @@ AVOutputFormat asf_muxer = {
     asf_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0},
-    .metadata_conv = ff_asf_metadata_conv,
 };
 #endif
 
@@ -892,6 +893,5 @@ AVOutputFormat asf_stream_muxer = {
     asf_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0},
-    .metadata_conv = ff_asf_metadata_conv,
 };
 #endif //CONFIG_ASF_STREAM_MUXER

Modified: trunk/libavformat/avformat.h
==============================================================================
--- trunk/libavformat/avformat.h	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/avformat.h	Fri Oct 15 21:04:25 2010	(r25493)
@@ -22,7 +22,7 @@
 #define AVFORMAT_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 82
+#define LIBAVFORMAT_VERSION_MINOR 83
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -137,10 +137,9 @@ struct AVFormatContext;
  *       sorting will have '-sort' appended. E.g. artist="The Beatles",
  *       artist-sort="Beatles, The".
  *
- * 4. Tag names are normally exported exactly as stored in the container to
- *    allow lossless remuxing to the same format. For container-independent
- *    handling of metadata, av_metadata_conv() can convert it to ffmpeg generic
- *    format. Follows a list of generic tag names:
+ * 4. Demuxers attempt to export metadata in a generic format, however tags
+ *    with no generic equivalents are left as they are stored in the container.
+ *    Follows a list of generic tag names:
  *
  * album        -- name of the set this work belongs to
  * album_artist -- main creator of the set/album, if different from artist.
@@ -177,7 +176,9 @@ typedef struct {
 }AVMetadataTag;
 
 typedef struct AVMetadata AVMetadata;
+#if FF_API_OLD_METADATA
 typedef struct AVMetadataConv AVMetadataConv;
+#endif
 
 /**
  * Get a metadata element with matching key.
@@ -216,16 +217,13 @@ attribute_deprecated int av_metadata_set
  */
 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
 
+#if FF_API_OLD_METADATA
 /**
- * Convert all the metadata sets from ctx according to the source and
- * destination conversion tables. If one of the tables is NULL, then
- * tags are converted to/from ffmpeg generic tag names.
- *
- * @param d_conv destination tags format conversion table
- * @param s_conv source tags format conversion table
+ * This function is provided for compatibility reason and currently does nothing.
  */
-void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
-                                                   const AVMetadataConv *s_conv);
+attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
+                                                                        const AVMetadataConv *s_conv);
+#endif
 
 /**
  * Free all the memory allocated for an AVMetadata struct.
@@ -349,7 +347,9 @@ typedef struct AVOutputFormat {
 
     enum CodecID subtitle_codec; /**< default subtitle codec */
 
+#if FF_API_OLD_METADATA
     const AVMetadataConv *metadata_conv;
+#endif
 
     /* private fields */
     struct AVOutputFormat *next;
@@ -465,7 +465,9 @@ typedef struct AVInputFormat {
      */
     int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
 
+#if FF_API_OLD_METADATA
     const AVMetadataConv *metadata_conv;
+#endif
 
     /* private fields */
     struct AVInputFormat *next;

Modified: trunk/libavformat/avidec.c
==============================================================================
--- trunk/libavformat/avidec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/avidec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -693,6 +693,8 @@ static int avi_read_header(AVFormatConte
         clean_index(s);
     }
 
+    ff_metadata_conv_ctx(s, NULL, ff_avi_metadata_conv);
+
     return 0;
 }
 
@@ -1332,5 +1334,4 @@ AVInputFormat avi_demuxer = {
     avi_read_packet,
     avi_read_close,
     avi_read_seek,
-    .metadata_conv = ff_avi_metadata_conv,
 };

Modified: trunk/libavformat/avienc.c
==============================================================================
--- trunk/libavformat/avienc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/avienc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -290,12 +290,7 @@ static int avi_write_header(AVFormatCont
             return -1;
         }
         ff_end_tag(pb, strf);
-        if ((t = av_metadata_get(s->streams[i]->metadata, "strn", NULL, 0))) {
-            avi_write_info_tag(s->pb, t->key, t->value);
-            t = NULL;
-        }
-        //FIXME a limitation of metadata conversion system
-        else if ((t = av_metadata_get(s->streams[i]->metadata, "INAM", NULL, 0))) {
+        if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
             avi_write_info_tag(s->pb, "strn", t->value);
             t = NULL;
         }
@@ -375,6 +370,7 @@ static int avi_write_header(AVFormatCont
 
     list2 = ff_start_tag(pb, "LIST");
     put_tag(pb, "INFO");
+    metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
     for (i = 0; *ff_avi_tags[i]; i++) {
         if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
             avi_write_info_tag(s->pb, t->key, t->value);
@@ -647,5 +643,4 @@ AVOutputFormat avi_muxer = {
     avi_write_trailer,
     .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
     .flags= AVFMT_VARIABLE_FPS,
-    .metadata_conv = ff_avi_metadata_conv,
 };

Modified: trunk/libavformat/flacdec.c
==============================================================================
--- trunk/libavformat/flacdec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/flacdec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -133,5 +133,4 @@ AVInputFormat flac_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "flac",
     .value = CODEC_ID_FLAC,
-    .metadata_conv = ff_vorbiscomment_metadata_conv,
 };

Modified: trunk/libavformat/flacenc.c
==============================================================================
--- trunk/libavformat/flacenc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/flacenc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -128,5 +128,4 @@ AVOutputFormat flac_muxer = {
     flac_write_packet,
     flac_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
-    .metadata_conv = ff_vorbiscomment_metadata_conv,
 };

Modified: trunk/libavformat/id3v2.c
==============================================================================
--- trunk/libavformat/id3v2.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/id3v2.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -23,6 +23,7 @@
 #include "id3v1.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
+#include "metadata.h"
 
 int ff_id3v2_match(const uint8_t *buf, const char * magic)
 {
@@ -249,6 +250,7 @@ void ff_id3v2_parse(AVFormatContext *s, 
         /* Skip to end of tag */
         url_fseek(s->pb, next, SEEK_SET);
     }
+    metadata_conv(&s->metadata, NULL, ff_id3v2_metadata_conv);
 
     if (len > 0) {
         /* Skip padding */

Modified: trunk/libavformat/matroskadec.c
==============================================================================
--- trunk/libavformat/matroskadec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/matroskadec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -1048,6 +1048,7 @@ static void matroska_convert_tag(AVForma
                 matroska_convert_tag(s, &tags[i].sub, metadata, key);
         }
     }
+    metadata_conv(metadata, NULL, ff_mkv_metadata_conv);
 }
 
 static void matroska_convert_tags(AVFormatContext *s)
@@ -1923,5 +1924,4 @@ AVInputFormat matroska_demuxer = {
     matroska_read_packet,
     matroska_read_close,
     matroska_read_seek,
-    .metadata_conv = ff_mkv_metadata_conv,
 };

Modified: trunk/libavformat/matroskaenc.c
==============================================================================
--- trunk/libavformat/matroskaenc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/matroskaenc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -752,6 +752,8 @@ static int mkv_write_tags(AVFormatContex
     ebml_master tags = {0};
     int i, ret;
 
+    ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
+
     if (av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) {
         ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
         if (ret < 0) return ret;
@@ -1186,7 +1188,6 @@ AVOutputFormat matroska_muxer = {
     .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
     .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
     .subtitle_codec = CODEC_ID_TEXT,
-    .metadata_conv = ff_mkv_metadata_conv,
 };
 #endif
 
@@ -1220,6 +1221,5 @@ AVOutputFormat matroska_audio_muxer = {
     mkv_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
-    .metadata_conv = ff_mkv_metadata_conv,
 };
 #endif

Modified: trunk/libavformat/metadata.c
==============================================================================
--- trunk/libavformat/metadata.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/metadata.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -91,6 +91,12 @@ int av_metadata_set(AVMetadata **pm, con
 {
     return av_metadata_set2(pm, key, value, 0);
 }
+
+void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
+                                            const AVMetadataConv *s_conv)
+{
+    return;
+}
 #endif
 
 void av_metadata_free(AVMetadata **pm)
@@ -140,8 +146,8 @@ void metadata_conv(AVMetadata **pm, cons
     *pm = dst;
 }
 
-void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
-                                            const AVMetadataConv *s_conv)
+void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
+                                                const AVMetadataConv *s_conv)
 {
     int i;
     metadata_conv(&ctx->metadata, d_conv, s_conv);

Modified: trunk/libavformat/metadata.h
==============================================================================
--- trunk/libavformat/metadata.h	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/metadata.h	Fri Oct 15 21:04:25 2010	(r25493)
@@ -39,6 +39,9 @@ struct AVMetadataConv{
     const char *native;
     const char *generic;
 };
+#if !FF_API_OLD_METADATA
+typedef struct AVMetadataConv AVMetadataConv;
+#endif
 
 #if FF_API_OLD_METADATA
 void ff_metadata_demux_compat(AVFormatContext *s);
@@ -47,5 +50,7 @@ void ff_metadata_mux_compat(AVFormatCont
 
 void metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
                                     const AVMetadataConv *s_conv);
+void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
+                                                const AVMetadataConv *s_conv);
 
 #endif /* AVFORMAT_METADATA_H */

Modified: trunk/libavformat/mp3.c
==============================================================================
--- trunk/libavformat/mp3.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/mp3.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -195,7 +195,6 @@ AVInputFormat mp3_demuxer = {
     mp3_read_packet,
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "mp2,mp3,m2a", /* XXX: use probe */
-    .metadata_conv = ff_id3v2_metadata_conv,
 };
 #endif
 
@@ -294,7 +293,6 @@ AVOutputFormat mp2_muxer = {
     NULL,
     mp3_write_packet,
     mp3_write_trailer,
-    .metadata_conv = ff_id3v2_metadata_conv,
 };
 #endif
 
@@ -317,6 +315,7 @@ static int mp3_write_header(struct AVFor
     size_pos = url_ftell(s->pb);
     put_be32(s->pb, 0);
 
+    metadata_conv(&s->metadata, ff_id3v2_metadata_conv, NULL);
     while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
         uint32_t tag = 0;
 
@@ -366,6 +365,5 @@ AVOutputFormat mp3_muxer = {
     mp3_write_packet,
     mp3_write_trailer,
     AVFMT_NOTIMESTAMPS,
-    .metadata_conv = ff_id3v2_metadata_conv,
 };
 #endif

Modified: trunk/libavformat/nutdec.c
==============================================================================
--- trunk/libavformat/nutdec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/nutdec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -656,6 +656,8 @@ static int nut_read_header(AVFormatConte
     }
     assert(nut->next_startcode == SYNCPOINT_STARTCODE);
 
+    ff_metadata_conv_ctx(s, NULL, ff_nut_metadata_conv);
+
     return 0;
 }
 
@@ -931,7 +933,6 @@ AVInputFormat nut_demuxer = {
     nut_read_close,
     read_seek,
     .extensions = "nut",
-    .metadata_conv = ff_nut_metadata_conv,
     .codec_tag = (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
 };
 #endif

Modified: trunk/libavformat/nutenc.c
==============================================================================
--- trunk/libavformat/nutenc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/nutenc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -491,6 +491,8 @@ static int write_headers(AVFormatContext
     ByteIOContext *dyn_bc;
     int i, ret;
 
+    ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL);
+
     ret = url_open_dyn_buf(&dyn_bc);
     if(ret < 0)
         return ret;
@@ -810,5 +812,4 @@ AVOutputFormat nut_muxer = {
     write_trailer,
     .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
     .codec_tag = (const AVCodecTag * const []){ ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
-    .metadata_conv = ff_nut_metadata_conv,
 };

Modified: trunk/libavformat/oggdec.c
==============================================================================
--- trunk/libavformat/oggdec.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/oggdec.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -641,6 +641,5 @@ AVInputFormat ogg_demuxer = {
     ogg_read_seek,
     ogg_read_timestamp,
     .extensions = "ogg",
-    .metadata_conv = ff_vorbiscomment_metadata_conv,
     .flags = AVFMT_GENERIC_INDEX,
 };

Modified: trunk/libavformat/oggenc.c
==============================================================================
--- trunk/libavformat/oggenc.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/oggenc.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -495,5 +495,4 @@ AVOutputFormat ogg_muxer = {
     ogg_write_header,
     ogg_write_packet,
     ogg_write_trailer,
-    .metadata_conv = ff_vorbiscomment_metadata_conv,
 };

Modified: trunk/libavformat/oggparsevorbis.c
==============================================================================
--- trunk/libavformat/oggparsevorbis.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/oggparsevorbis.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -29,6 +29,7 @@
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
 #include "oggdec.h"
+#include "vorbiscomment.c"
 
 static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
 {
@@ -137,6 +138,8 @@ ff_vorbis_comment(AVFormatContext * as, 
         av_log(as, AV_LOG_INFO,
                "truncated comment header, %i comments not found\n", n);
 
+    metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
+
     return 0;
 }
 

Modified: trunk/libavformat/oma.c
==============================================================================
--- trunk/libavformat/oma.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/oma.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -201,6 +201,5 @@ AVInputFormat oma_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "oma,aa3",
     .codec_tag= (const AVCodecTag* const []){codec_oma_tags, 0},
-    .metadata_conv = ff_id3v2_metadata_conv,
 };
 

Modified: trunk/libavformat/vorbiscomment.c
==============================================================================
--- trunk/libavformat/vorbiscomment.c	Fri Oct 15 20:30:43 2010	(r25492)
+++ trunk/libavformat/vorbiscomment.c	Fri Oct 15 21:04:25 2010	(r25493)
@@ -55,6 +55,7 @@ int ff_vorbiscomment_length(AVMetadata *
 int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
                            const char *vendor_string, const unsigned count)
 {
+    metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
     bytestream_put_le32(p, strlen(vendor_string));
     bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
     if (*m) {



More information about the ffmpeg-cvslog mailing list