aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-28 13:08:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-05-28 13:08:50 +0200
commitdff4aa6afd40bcc6c71b5a21d229fb941f9fc1eb (patch)
treee50cc5c08974c011ff14516a14d602605eee065a /libavformat
parent579e2b2874aeaa9cfdeed1fd1408767e33a63029 (diff)
parentefcde917af407a6031ecff68edd51fce7b83d104 (diff)
downloadffmpeg-dff4aa6afd40bcc6c71b5a21d229fb941f9fc1eb.tar.gz
Merge commit 'efcde917af407a6031ecff68edd51fce7b83d104'
* commit 'efcde917af407a6031ecff68edd51fce7b83d104': vorbiscomment: simplify API by using av_dict_count() Conflicts: libavformat/flacenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/flacenc.c6
-rw-r--r--libavformat/oggenc.c5
-rw-r--r--libavformat/vorbiscomment.c8
-rw-r--r--libavformat/vorbiscomment.h7
4 files changed, 10 insertions, 16 deletions
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index f0b7d2956e..ae8e171fb1 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -47,12 +47,12 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
int last_block, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
- unsigned int len, count;
+ unsigned int len;
uint8_t *p, *p0;
ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
- len = ff_vorbiscomment_length(*m, vendor, &count);
+ len = ff_vorbiscomment_length(*m, vendor);
p0 = av_malloc(len+4);
if (!p0)
return AVERROR(ENOMEM);
@@ -60,7 +60,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
bytestream_put_byte(&p, last_block ? 0x84 : 0x04);
bytestream_put_be24(&p, len);
- ff_vorbiscomment_write(&p, m, vendor, count);
+ ff_vorbiscomment_write(&p, m, vendor);
avio_write(pb, p0, len+4);
av_freep(&p0);
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 9f75538daa..bec3917a21 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -277,18 +277,17 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
int size;
uint8_t *p, *p0;
- unsigned int count;
ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
- size = offset + ff_vorbiscomment_length(*m, vendor, &count) + framing_bit;
+ size = offset + ff_vorbiscomment_length(*m, vendor) + framing_bit;
p = av_mallocz(size);
if (!p)
return NULL;
p0 = p;
p += offset;
- ff_vorbiscomment_write(&p, m, vendor, count);
+ ff_vorbiscomment_write(&p, m, vendor);
if (framing_bit)
bytestream_put_byte(&p, 1);
diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c
index f17a0c1d13..cc9b6620ef 100644
--- a/libavformat/vorbiscomment.c
+++ b/libavformat/vorbiscomment.c
@@ -38,28 +38,26 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
{ 0 }
};
-int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
- unsigned *count)
+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string)
{
int len = 8;
len += strlen(vendor_string);
- *count = 0;
if (m) {
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
- (*count)++;
}
}
return len;
}
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
- const char *vendor_string, const unsigned count)
+ const char *vendor_string)
{
bytestream_put_le32(p, strlen(vendor_string));
bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
if (*m) {
+ int count = av_dict_count(*m);
AVDictionaryEntry *tag = NULL;
bytestream_put_le32(p, count);
while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
diff --git a/libavformat/vorbiscomment.h b/libavformat/vorbiscomment.h
index 4e631e3553..f4212d2632 100644
--- a/libavformat/vorbiscomment.h
+++ b/libavformat/vorbiscomment.h
@@ -32,11 +32,9 @@
* @param m The metadata structure to be parsed. For no metadata, set to NULL.
* @param vendor_string The vendor string to be added into the VorbisComment.
* For no string, set to an empty string.
- * @param count Pointer to store the number of tags in m because m->count is "not allowed"
* @return The length in bytes.
*/
-int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
- unsigned *count);
+int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string);
/**
* Write a VorbisComment into a buffer. The buffer, p, must have enough
@@ -47,10 +45,9 @@ int ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
* @param p The buffer in which to write.
* @param m The metadata struct to write.
* @param vendor_string The vendor string to write.
- * @param count The number of tags in m because m->count is "not allowed"
*/
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
- const char *vendor_string, const unsigned count);
+ const char *vendor_string);
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];