History

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.

Mans Rullgard committed 14 years ago

Commit 987170c1 parent 05c36e06 files · +20 −4Browse files

Unified · Split

6 files
  1. doc/APIchanges +3 −0
  2. libavformat/asfenc.c +1 −1
  3. libavformat/utils.c +1 −1
  4. libavutil/dict.c +5 −0
  5. libavutil/dict.h +8 −0
  6. libavutil/version.h +2 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2012-08-08 - xxxxxxx - lavu 51.38 - dict.h
17+ Add av_dict_count().
18+
1619 2012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h
1720 Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*.
1821
libavformat/asfenc.c+1−1
@@ -316,7 +316,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data · 315 unmodified lines
316316
317317 duration = asf->duration + PREROLL_TIME * 10000;
318318 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
319− metadata_count = s->metadata ? s->metadata->count : 0;
319+ metadata_count = av_dict_count(s->metadata);
320320
321321 bit_rate = 0;
322322 for(n=0;n<s->nb_streams;n++) {
libavformat/utils.c+1−1
@@ -3306,7 +3306,7 @@ static void print_fps(double d, const char *postfix){ · 3305 unmodified lines
33063306
33073307 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
33083308 {
3309− if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){
3309+ if(m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))){
33103310 AVDictionaryEntry *tag=NULL;
33113311
33123312 av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
libavutil/dict.c+5−0
@@ -23,6 +23,11 @@ · 22 unmodified lines
2323 #include "internal.h"
2424 #include "mem.h"
2525
26+int av_dict_count(const AVDictionary *m)
27+{
28+ return m ? m->count : 0;
29+}
30+
2631 AVDictionaryEntry *
2732 av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
2833 {
libavutil/dict.h+8−0
@@ -86,6 +86,14 @@ typedef struct AVDictionary AVDictionary; · 85 unmodified lines
8686 AVDictionaryEntry *
8787 av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
8888
89+/**
90+ * Get number of entries in dictionary.
91+ *
92+ * @param m dictionary
93+ * @return number of entries in dictionary
94+ */
95+int av_dict_count(const AVDictionary *m);
96+
8997 /**
9098 * Set the given entry in *pm, overwriting an existing entry.
9199 *
libavutil/version.h+2−2
@@ -37,8 +37,8 @@ · 36 unmodified lines
3737 */
3838
3939 #define LIBAVUTIL_VERSION_MAJOR 51
40−#define LIBAVUTIL_VERSION_MINOR 37
41−#define LIBAVUTIL_VERSION_MICRO 1
40+#define LIBAVUTIL_VERSION_MINOR 38
41+#define LIBAVUTIL_VERSION_MICRO 0
4242
4343 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
4444 LIBAVUTIL_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t