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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162012-08-08 - xxxxxxx - lavu 51.38 - dict.h
17 Add av_dict_count().
18
162012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h192012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h
17 Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*.20 Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*.
18 21
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
316 316
317 duration = asf->duration + PREROLL_TIME * 10000;317 duration = asf->duration + PREROLL_TIME * 10000;
318 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];318 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);
320 320
321 bit_rate = 0;321 bit_rate = 0;
322 for(n=0;n<s->nb_streams;n++) {322 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
3306 3306
3307static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)3307static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
3308{3308{
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))){
3310 AVDictionaryEntry *tag=NULL;3310 AVDictionaryEntry *tag=NULL;
3311 3311
3312 av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);3312 av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
libavutil/dict.c+5−0
@@ -23,6 +23,11 @@ · 22 unmodified lines
23#include "internal.h"23#include "internal.h"
24#include "mem.h"24#include "mem.h"
25 25
26int av_dict_count(const AVDictionary *m)
27{
28 return m ? m->count : 0;
29}
30
26AVDictionaryEntry *31AVDictionaryEntry *
27av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)32av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
28{33{
libavutil/dict.h+8−0
@@ -86,6 +86,14 @@ typedef struct AVDictionary AVDictionary; · 85 unmodified lines
86AVDictionaryEntry *86AVDictionaryEntry *
87av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);87av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
88 88
89/**
90 * Get number of entries in dictionary.
91 *
92 * @param m dictionary
93 * @return number of entries in dictionary
94 */
95int av_dict_count(const AVDictionary *m);
96
89/**97/**
90 * Set the given entry in *pm, overwriting an existing entry.98 * Set the given entry in *pm, overwriting an existing entry.
91 *99 *
libavutil/version.h+2−2
@@ -37,8 +37,8 @@ · 36 unmodified lines
37 */37 */
38 38
39#define LIBAVUTIL_VERSION_MAJOR 5139#define LIBAVUTIL_VERSION_MAJOR 51
40#define LIBAVUTIL_VERSION_MINOR 3740#define LIBAVUTIL_VERSION_MINOR 38
41#define LIBAVUTIL_VERSION_MICRO 141#define LIBAVUTIL_VERSION_MICRO 0
42 42
43#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \43#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
44 LIBAVUTIL_VERSION_MINOR, \44 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