[FFmpeg-cvslog] dict: add av_dict_count()

Mans Rullgard git at videolan.org
Sat Aug 11 15:10:55 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Wed Aug  8 17:30:15 2012 +0100| [987170cb9dd036d3372c8feac6074d13d1b84dd2] | committer: Mans Rullgard

dict: add av_dict_count()

This adds a function to retrieve the number of entries in a
dictionary and updates the places directly accessing what should
be an opaque struct to use this new function instead.

Signed-off-by: Mans Rullgard <mans at mansr.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=987170cb9dd036d3372c8feac6074d13d1b84dd2
---

 doc/APIchanges       |    3 +++
 libavformat/asfenc.c |    2 +-
 libavformat/utils.c  |    2 +-
 libavutil/dict.c     |    5 +++++
 libavutil/dict.h     |    8 ++++++++
 libavutil/version.h  |    4 ++--
 6 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 436e994..b723e10 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-08-08 - xxxxxxx - lavu 51.38 - dict.h
+  Add av_dict_count().
+
 2012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h
   Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*.
 
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 7c824a5..bcb741e 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -316,7 +316,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
 
     duration = asf->duration + PREROLL_TIME * 10000;
     has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
-    metadata_count = s->metadata ? s->metadata->count : 0;
+    metadata_count = av_dict_count(s->metadata);
 
     bit_rate = 0;
     for(n=0;n<s->nb_streams;n++) {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 435ffc1..b850abf 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3306,7 +3306,7 @@ static void print_fps(double d, const char *postfix){
 
 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
 {
-    if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){
+    if(m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))){
         AVDictionaryEntry *tag=NULL;
 
         av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
diff --git a/libavutil/dict.c b/libavutil/dict.c
index cb5f7b1..1344613 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -23,6 +23,11 @@
 #include "internal.h"
 #include "mem.h"
 
+int av_dict_count(const AVDictionary *m)
+{
+    return m ? m->count : 0;
+}
+
 AVDictionaryEntry *
 av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
 {
diff --git a/libavutil/dict.h b/libavutil/dict.h
index aa07626..72d1e9d 100644
--- a/libavutil/dict.h
+++ b/libavutil/dict.h
@@ -87,6 +87,14 @@ AVDictionaryEntry *
 av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
 
 /**
+ * Get number of entries in dictionary.
+ *
+ * @param m dictionary
+ * @return  number of entries in dictionary
+ */
+int av_dict_count(const AVDictionary *m);
+
+/**
  * Set the given entry in *pm, overwriting an existing entry.
  *
  * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
diff --git a/libavutil/version.h b/libavutil/version.h
index bd60d3f..de5731a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -37,8 +37,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 37
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR 38
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list