[FFmpeg-devel] [PATCH 3/7] avformat/vorbiscomment: Replace AVDictionary ** by const AVDictionary *

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Apr 28 11:36:41 EEST 2020


ff_vorbiscomment_write() used an AVDictionary ** parameter for a
dictionary whose contents ought to be written; yet this can be replaced
by AVDictionary * since commit 042ca05f0fdc5f4d56a3e9b94bc9cd67bca9a4bc;
and this in turn can be replaced by const AVDictionary * to indicate
that the dictionary isn't modified; the latter also applies to
ff_vorbiscomment_length().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/flacenc.c       |  2 +-
 libavformat/matroskaenc.c   |  2 +-
 libavformat/oggenc.c        |  2 +-
 libavformat/vorbiscomment.c | 10 +++++-----
 libavformat/vorbiscomment.h |  4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index a043274df6..0e88e18355 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -76,7 +76,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, NULL, 0);
+    ff_vorbiscomment_write(&p, *m, vendor, NULL, 0);
 
     avio_write(pb, p0, len+4);
     av_freep(&p0);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 018108b96b..58bcdb904f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -643,7 +643,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb,
         AV_WB24(data + 1, len);
 
         p = data + 4;
-        ff_vorbiscomment_write(&p, &dict, vendor, NULL, 0);
+        ff_vorbiscomment_write(&p, dict, vendor, NULL, 0);
 
         avio_write(pb, data, len + 4);
 
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index fbd14fedf9..cc9a899a4c 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -308,7 +308,7 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact,
     p0 = p;
 
     p += offset;
-    ff_vorbiscomment_write(&p, m, vendor, chapters, nb_chapters);
+    ff_vorbiscomment_write(&p, *m, vendor, chapters, nb_chapters);
     if (framing_bit)
         bytestream_put_byte(&p, 1);
 
diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c
index fb5c655a23..edaeae2772 100644
--- a/libavformat/vorbiscomment.c
+++ b/libavformat/vorbiscomment.c
@@ -38,7 +38,7 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
     { 0 }
 };
 
-int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
+int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string,
                                 AVChapter **chapters, unsigned int nb_chapters)
 {
     int64_t len = 8;
@@ -62,7 +62,7 @@ int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
     return len;
 }
 
-int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
+int ff_vorbiscomment_write(uint8_t **p, const AVDictionary *m,
                            const char *vendor_string,
                            AVChapter **chapters, unsigned int nb_chapters)
 {
@@ -74,11 +74,11 @@ int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
             cm_count += av_dict_count(chapters[i]->metadata) + 1;
         }
     }
-    if (*m) {
-        int count = av_dict_count(*m) + cm_count;
+    if (m) {
+        int count = av_dict_count(m) + cm_count;
         AVDictionaryEntry *tag = NULL;
         bytestream_put_le32(p, count);
-        while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
+        while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
             int64_t len1 = strlen(tag->key);
             int64_t len2 = strlen(tag->value);
             if (len1+1+len2 > UINT32_MAX)
diff --git a/libavformat/vorbiscomment.h b/libavformat/vorbiscomment.h
index 4ff3dd6c27..af9bd75cd7 100644
--- a/libavformat/vorbiscomment.h
+++ b/libavformat/vorbiscomment.h
@@ -34,7 +34,7 @@
  * For no string, set to an empty string.
  * @return The length in bytes.
  */
-int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
+int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string,
                                 AVChapter **chapters, unsigned int nb_chapters);
 
 /**
@@ -49,7 +49,7 @@ int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string,
  * @param chapters The chapters to write.
  * @param nb_chapters The number of chapters to write.
  */
-int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
+int ff_vorbiscomment_write(uint8_t **p, const AVDictionary *m,
                            const char *vendor_string,
                            AVChapter **chapters, unsigned int nb_chapters);
 
-- 
2.20.1



More information about the ffmpeg-devel mailing list