[FFmpeg-devel] [PATCH 3/3] avutil/dict: constify av_dict_get return

Marvin Scholz epirat07 at gmail.com
Mon May 1 14:44:56 EEST 2023


---
 doc/examples/qsv_transcode.c       |  2 +-
 libavcodec/libaomenc.c             |  2 +-
 libavcodec/libkvazaar.c            |  2 +-
 libavcodec/libsvtav1.c             |  2 +-
 libavcodec/libvpxenc.c             |  2 +-
 libavcodec/libx264.c               |  2 +-
 libavcodec/libx265.c               |  2 +-
 libavcodec/mjpegdec.c              |  2 +-
 libavcodec/qsvenc.c                |  2 +-
 libavfilter/avfilter.c             |  2 +-
 libavfilter/f_bench.c              |  2 +-
 libavfilter/f_drawgraph.c          |  2 +-
 libavfilter/f_select.c             |  4 +--
 libavfilter/vf_cover_rect.c        |  2 +-
 libavfilter/vf_drawtext.c          |  2 +-
 libavformat/aiffenc.c              |  2 +-
 libavformat/argo_asf.c             |  2 +-
 libavformat/asfenc.c               |  6 ++--
 libavformat/au.c                   |  2 +-
 libavformat/avformat.h             |  2 +-
 libavformat/avidec.c               |  2 +-
 libavformat/avienc.c               |  2 +-
 libavformat/avio.c                 |  4 +--
 libavformat/dashenc.c              |  6 ++--
 libavformat/dvenc.c                |  2 +-
 libavformat/flacdec.c              |  2 +-
 libavformat/flacenc.c              |  6 ++--
 libavformat/flvdec.c               |  2 +-
 libavformat/gxfenc.c               |  2 +-
 libavformat/http.c                 |  8 +++---
 libavformat/id3v2.c                |  6 ++--
 libavformat/id3v2enc.c             |  2 +-
 libavformat/imfdec.c               |  2 +-
 libavformat/matroskadec.c          |  2 +-
 libavformat/mov.c                  |  6 ++--
 libavformat/movenc.c               | 46 +++++++++++++++---------------
 libavformat/mp3enc.c               |  6 ++--
 libavformat/mpegtsenc.c            |  6 ++--
 libavformat/mux.c                  |  2 +-
 libavformat/mux_utils.c            |  2 +-
 libavformat/mxfenc.c               | 14 ++++-----
 libavformat/riffenc.c              |  2 +-
 libavformat/rmenc.c                |  2 +-
 libavformat/sapenc.c               |  2 +-
 libavformat/sdp.c                  |  2 +-
 libavformat/segment.c              |  4 +--
 libavformat/soxenc.c               |  2 +-
 libavformat/tee.c                  |  2 +-
 libavformat/ttmlenc.c              |  4 +--
 libavformat/wavenc.c               |  4 +--
 libavformat/webmdashenc.c          | 30 +++++++++----------
 libavutil/dict.c                   |  9 +++++-
 libavutil/dict.h                   |  5 ++++
 libavutil/hwcontext_cuda.c         |  2 +-
 libavutil/hwcontext_qsv.c          |  2 +-
 libavutil/hwcontext_vulkan.c       |  8 +++---
 libavutil/version.h                |  1 +
 tests/api/api-threadmessage-test.c |  2 +-
 58 files changed, 136 insertions(+), 123 deletions(-)

diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c
index 48128b200c..cc4c203d94 100644
--- a/doc/examples/qsv_transcode.c
+++ b/doc/examples/qsv_transcode.c
@@ -87,7 +87,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx)
     frame_number++;
     if (current_setting_number < setting_number &&
         frame_number == dynamic_setting[current_setting_number].frame_number) {
-        AVDictionaryEntry *e = NULL;
+        const AVDictionaryEntry *e = NULL;
         ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, &opts);
         if (ret < 0) {
             fprintf(stderr, "The dynamic parameter is wrong\n");
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 0b88102c77..8a32f31677 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -999,7 +999,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
     {
-        AVDictionaryEntry *en = NULL;
+        const AVDictionaryEntry *en = NULL;
 
         while ((en = av_dict_get(ctx->aom_params, "", en, AV_DICT_IGNORE_SUFFIX))) {
             int ret = aom_codec_set_option(&ctx->encoder, en->key, en->value);
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 168486f4ec..f9f3ce8e52 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -103,7 +103,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
     if (ctx->kvz_params) {
         AVDictionary *dict = NULL;
         if (!av_dict_parse_string(&dict, ctx->kvz_params, "=", ",", 0)) {
-            AVDictionaryEntry *entry = NULL;
+            const AVDictionaryEntry *entry = NULL;
             while ((entry = av_dict_get(dict, "", entry, AV_DICT_IGNORE_SUFFIX))) {
                 if (!api->config_parse(cfg, entry->key, entry->value)) {
                     av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 9174e2753c..e959c1cab0 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -151,7 +151,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
 {
     SvtContext *svt_enc = avctx->priv_data;
     const AVPixFmtDescriptor *desc;
-    AVDictionaryEntry *en = NULL;
+    const AVDictionaryEntry *en = NULL;
 
     // Update param from options
 #if FF_API_SVTAV1_OPTS
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index a20e949842..29fdc3f9d4 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1734,7 +1734,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
         if (frame->pict_type == AV_PICTURE_TYPE_I)
             flags |= VPX_EFLAG_FORCE_KF;
         if (frame->metadata) {
-            AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);
+            const AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0);
             if (en) {
                 flags |= strtoul(en->value, NULL, 10);
             }
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index cfdd422236..2eec1c0913 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1082,7 +1082,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
 #endif
 
     {
-        AVDictionaryEntry *en = NULL;
+        const AVDictionaryEntry *en = NULL;
         while (en = av_dict_get(x4->x264_params, "", en, AV_DICT_IGNORE_SUFFIX)) {
            if ((ret = x264_param_parse(&x4->params, en->key, en->value)) < 0) {
                av_log(avctx, AV_LOG_WARNING,
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 420d0953af..ddba5c6dbc 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -421,7 +421,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
     }
 
     {
-        AVDictionaryEntry *en = NULL;
+        const AVDictionaryEntry *en = NULL;
         while ((en = av_dict_get(ctx->x265_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
             int parse_ret = ctx->api->param_parse(ctx->params, en->key, en->value);
 
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 01537d4774..04c3cf0430 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2359,7 +2359,7 @@ int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, AVFrame *frame,
     int i, index;
     int ret = 0;
     int is16bit;
-    AVDictionaryEntry *e = NULL;
+    const AVDictionaryEntry *e = NULL;
 
     s->force_pal8 = 0;
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c975302b4f..cf411ca520 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -2046,7 +2046,7 @@ static int set_roi_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame,
 static void set_skip_frame_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame,
                                mfxEncodeCtrl *enc_ctrl)
 {
-    AVDictionaryEntry* skip_frame_dict = NULL;
+    const AVDictionaryEntry* skip_frame_dict = NULL;
     if (!frame->metadata)
         return;
     skip_frame_dict = av_dict_get(frame->metadata, "qsv_skip_frame", NULL, 0);
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 8d5702a0c8..60224c93ef 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -897,7 +897,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
 int avfilter_init_str(AVFilterContext *filter, const char *args)
 {
     AVDictionary *options = NULL;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
     int ret = 0;
 
     if (args && *args) {
diff --git a/libavfilter/f_bench.c b/libavfilter/f_bench.c
index 9b55194dbc..ca1adf4ae6 100644
--- a/libavfilter/f_bench.c
+++ b/libavfilter/f_bench.c
@@ -71,7 +71,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     if (s->action == ACTION_START) {
         av_dict_set_int(&in->metadata, START_TIME_KEY, t, 0);
     } else if (s->action == ACTION_STOP) {
-        AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, NULL, 0);
+        const AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, NULL, 0);
         if (e) {
             const int64_t start = strtoll(e->value, NULL, 0);
             const int64_t diff = t - start;
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index d29a7fb60a..69d8ba9993 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -165,7 +165,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     DrawGraphContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
     AVDictionary *metadata;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
     AVFrame *out = s->out;
     AVFrame *clone = NULL;
     int64_t in_pts, out_pts, in_duration;
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index d76c248fc5..b01526371a 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -308,8 +308,8 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
 static double get_concatdec_select(AVFrame *frame, int64_t pts)
 {
     AVDictionary *metadata = frame->metadata;
-    AVDictionaryEntry *start_time_entry = av_dict_get(metadata, "lavf.concatdec.start_time", NULL, 0);
-    AVDictionaryEntry *duration_entry = av_dict_get(metadata, "lavf.concatdec.duration", NULL, 0);
+    const AVDictionaryEntry *start_time_entry = av_dict_get(metadata, "lavf.concatdec.start_time", NULL, 0);
+    const AVDictionaryEntry *duration_entry = av_dict_get(metadata, "lavf.concatdec.duration", NULL, 0);
     if (start_time_entry) {
         int64_t start_time = strtoll(start_time_entry->value, NULL, 10);
         if (pts >= start_time) {
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 642747a351..b219ae2948 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -125,7 +125,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     AVFilterContext *ctx = inlink->dst;
     CoverContext *cover = ctx->priv;
-    AVDictionaryEntry *ex, *ey, *ew, *eh;
+    const AVDictionaryEntry *ex, *ey, *ew, *eh;
     int ret, x = -1, y = -1, w = -1, h = -1;
     char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL;
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 71ab851462..d2973f2d96 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1047,7 +1047,7 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp,
                          char *fct, unsigned argc, char **argv, int tag)
 {
     DrawTextContext *s = ctx->priv;
-    AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
+    const AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
 
     if (e && e->value)
         av_bprintf(bp, "%s", e->value);
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 11a5b18d57..b2ca6c9ce7 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -83,7 +83,7 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
 
 static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
 {
-    AVDictionaryEntry *tag;
+    const AVDictionaryEntry *tag;
     AVIOContext *pb = s->pb;
 
     if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 5f38b68b6a..f83f9b2e2a 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -360,7 +360,7 @@ static int argo_asf_write_header(AVFormatContext *s)
         .num_chunks    = 1,
         .chunk_offset  = ASF_FILE_HEADER_SIZE
     };
-    AVDictionaryEntry *t;
+    const AVDictionaryEntry *t;
     const char *name, *end;
     size_t len;
 
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 244c7e7a27..8810d64980 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -331,7 +331,7 @@ static void asf_write_markers(AVFormatContext *s, AVIOContext *dyn_buf)
 
     for (unsigned i = 0; i < s->nb_chapters; i++) {
         AVChapter *c = s->chapters[i];
-        AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
+        const AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
         int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
         uint64_t offset;
         int32_t send_time = get_send_time(asf, pres_time, &offset);
@@ -361,7 +361,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
 {
     ASFContext *asf = s->priv_data;
     AVIOContext *pb = s->pb, *dyn_buf;
-    AVDictionaryEntry *tags[5];
+    const AVDictionaryEntry *tags[5];
     int header_size, extra_size, extra_size2, wav_extra_size;
     int has_title, has_aspect_ratio = 0;
     int metadata_count;
@@ -392,7 +392,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
     for (unsigned n = 0; n < s->nb_streams; n++) {
         AVStream *const st = s->streams[n];
         AVCodecParameters *const par = st->codecpar;
-        AVDictionaryEntry *entry;
+        const AVDictionaryEntry *entry;
 
         avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
 
diff --git a/libavformat/au.c b/libavformat/au.c
index 3bf2150258..68b665aeb7 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -261,7 +261,7 @@ static int au_get_annotations(AVFormatContext *s, AVBPrint *annotations)
     };
     int cnt = 0;
     AVDictionary *m = s->metadata;
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
 
     for (int i = 0; i < FF_ARRAY_ELEMS(keys); i++) {
         t = av_dict_get(m, keys[i], NULL, 0);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1916aa2dc5..95f52a639c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -146,7 +146,7 @@
  * consumed). The calling program can handle such unrecognized options as it
  * wishes, e.g.
  * @code
- * AVDictionaryEntry *e;
+ * const AVDictionaryEntry *e;
  * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
  *     fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
  *     abort();
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 7a3fad6392..0cf9174013 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -507,7 +507,7 @@ static int avi_read_header(AVFormatContext *s)
     uint64_t list_end   = 0;
     int64_t pos;
     int ret;
-    AVDictionaryEntry *dict_entry;
+    const AVDictionaryEntry *dict_entry;
 
     avi->stream_index = -1;
 
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index a61e5c3109..b62258f693 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -266,7 +266,7 @@ static int avi_write_header(AVFormatContext *s)
     AVCodecParameters *video_par;
     AVStream *video_st = NULL;
     int64_t list1, list2, strh, strf;
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
     int padding;
 
     if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
diff --git a/libavformat/avio.c b/libavformat/avio.c
index ab1c19a58d..0082977f2d 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -167,7 +167,7 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
 {
     int err;
     AVDictionary *tmp_opts = NULL;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
 
     if (!options)
         options = &tmp_opts;
@@ -309,7 +309,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
                          URLContext *parent)
 {
     AVDictionary *tmp_opts = NULL;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
     int ret = ffurl_alloc(puc, filename, flags, int_cb);
     if (ret < 0)
         return ret;
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 17fe5f430c..283747c63d 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -800,7 +800,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind
 {
     DASHContext *c = s->priv_data;
     AdaptationSet *as = &c->as[as_index];
-    AVDictionaryEntry *lang, *role;
+    const AVDictionaryEntry *lang, *role;
     int i;
 
     avio_printf(out, "\t\t<AdaptationSet id=\"%d\" contentType=\"%s\" startWithSAP=\"1\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
@@ -1144,7 +1144,7 @@ static int write_manifest(AVFormatContext *s, int final)
     const char *proto = avio_find_protocol_name(s->url);
     int use_rename = proto && !strcmp(proto, "file");
     static unsigned int warned_non_file = 0;
-    AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
+    const AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
     AVDictionary *opts = NULL;
 
     if (!use_rename && !warned_non_file++)
@@ -1372,7 +1372,7 @@ static int write_manifest(AVFormatContext *s, int final)
 
 static int dict_copy_entry(AVDictionary **dst, const AVDictionary *src, const char *key)
 {
-    AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0);
+    const AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0);
     if (entry)
         av_dict_set(dst, key, entry->value, AV_DICT_DONT_OVERWRITE);
     return 0;
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 29d2dc47ac..246d190961 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -390,7 +390,7 @@ static int dv_write_header(AVFormatContext *s)
 {
     AVRational rate;
     DVMuxContext *dvc = s->priv_data;
-    AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
+    const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
 
     if (!dv_init_mux(s)) {
         av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n"
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index b58ec03963..773fddc4fd 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -176,7 +176,7 @@ static int flac_read_header(AVFormatContext *s)
             }
             /* process supported blocks other than STREAMINFO */
             if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
-                AVDictionaryEntry *chmask;
+                const AVDictionaryEntry *chmask;
 
                 ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
                 if (ret < 0) {
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index a8beec7750..fab7b34fa8 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -85,7 +85,7 @@ static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
     AVIOContext *pb = s->pb;
     const AVPixFmtDescriptor *pixdesc;
     const CodecMime *mime = ff_id3v2_mime_tags;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
     const char *mimetype = NULL, *desc = "";
     const AVStream *st = s->streams[pkt->stream_index];
     int i, mimelen, desclen, type = 0, blocklen;
@@ -243,8 +243,8 @@ static int flac_init(struct AVFormatContext *s)
     if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE &&
         !(par->ch_layout.u.mask & ~0x3ffffULL) &&
         !ff_flac_is_native_layout(par->ch_layout.u.mask)) {
-        AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
-                                                NULL, 0);
+        const AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
+                                                      NULL, 0);
 
         if (chmask) {
             av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK is "
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..abb282da56 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1268,7 +1268,7 @@ retry_duration:
         }
         if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
             st->codecpar->codec_id == AV_CODEC_ID_H264)) {
-            AVDictionaryEntry *t;
+            const AVDictionaryEntry *t;
 
             if (st->codecpar->extradata) {
                 if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0)
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 7495924722..93bfed8246 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -688,7 +688,7 @@ static int gxf_write_header(AVFormatContext *s)
     uint8_t tracks[255] = {0};
     int i, media_info = 0;
     int ret;
-    AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
+    const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
 
     if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
         av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome\n");
diff --git a/libavformat/http.c b/libavformat/http.c
index 0817aafb5b..c18a4d7e58 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -309,7 +309,7 @@ static int http_should_reconnect(HTTPContext *s, int err)
 
 static char *redirect_cache_get(HTTPContext *s)
 {
-    AVDictionaryEntry *re;
+    const AVDictionaryEntry *re;
     int64_t expiry;
     char *delim;
 
@@ -960,7 +960,7 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
 static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
 {
     AVDictionary *new_params = NULL;
-    AVDictionaryEntry *e, *cookie_entry;
+    const AVDictionaryEntry *e, *cookie_entry;
     char *eql, *name;
 
     // ensure the cookie is parsable
@@ -978,7 +978,7 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
     if ((e = av_dict_get(new_params, "expires", NULL, 0)) && e->value) {
         struct tm new_tm = {0};
         if (!parse_set_cookie_expiry_time(e->value, &new_tm)) {
-            AVDictionaryEntry *e2;
+            const AVDictionaryEntry *e2;
 
             // if the cookie has already expired ignore it
             if (av_timegm(&new_tm) < av_gettime() / 1000000) {
@@ -1256,7 +1256,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
     *cookies = NULL;
     while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) {
         AVDictionary *cookie_params = NULL;
-        AVDictionaryEntry *cookie_entry, *e;
+        const AVDictionaryEntry *cookie_entry, *e;
 
         next = NULL;
         // store the cookie in a dict in case it is updated in the response
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index cb31864045..8d201cb63a 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -536,9 +536,9 @@ static int is_number(const char *str)
     return !*str;
 }
 
-static AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag)
+static const AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag)
 {
-    AVDictionaryEntry *t;
+    const AVDictionaryEntry *t;
     if ((t = av_dict_get(m, tag, NULL, AV_DICT_MATCH_CASE)) &&
         strlen(t->value) == 4 && is_number(t->value))
         return t;
@@ -547,7 +547,7 @@ static AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag)
 
 static void merge_date(AVDictionary **m)
 {
-    AVDictionaryEntry *t;
+    const AVDictionaryEntry *t;
     char date[17] = { 0 };      // YYYY-MM-DD hh:mm
 
     if (!(t = get_date_tag(*m, "TYER")) &&
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index ac907c2758..6d646e3f29 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -352,7 +352,7 @@ int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
 int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
 {
     AVStream *st = s->streams[pkt->stream_index];
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
 
     AVIOContext *dyn_buf;
     uint8_t     *buf;
diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 7d04d0d853..a7c39ee4f3 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -631,7 +631,7 @@ static int imf_read_header(AVFormatContext *s)
     IMFContext *c = s->priv_data;
     char *asset_map_path;
     char *tmp_str;
-    AVDictionaryEntry* tcr;
+    const AVDictionaryEntry* tcr;
     char tc_buf[AV_TIMECODE_STR_SIZE];
     int ret = 0;
 
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 49950956b6..9af4900814 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2083,7 +2083,7 @@ static int matroska_parse_flac(AVFormatContext *s,
         /* check for the channel mask */
         if (block_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
             AVDictionary *dict = NULL;
-            AVDictionaryEntry *chmask;
+            const AVDictionaryEntry *chmask;
 
             ff_vorbis_comment(s, &dict, p, block_size, 0);
             chmask = av_dict_get(dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 057fd872b1..40f4749ea8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2340,7 +2340,7 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
     int bits_per_sample, flags;
     uint16_t version = avio_rb16(pb);
     uint32_t id = 0;
-    AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE);
+    const AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE);
     int channel_count;
 
     avio_rb16(pb); /* revision level */
@@ -8462,7 +8462,7 @@ static void export_orphan_timecode(AVFormatContext *s)
 
         if (st->codecpar->codec_tag  == MKTAG('t','m','c','d') &&
             !tmcd_is_referenced(s, i + 1)) {
-            AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
+            const AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
             if (tcr) {
                 av_dict_set(&s->metadata, "timecode", tcr->value, 0);
                 break;
@@ -8625,7 +8625,7 @@ static int mov_read_header(AVFormatContext *s)
         AVStream *st = s->streams[i];
         MOVStreamContext *sc = st->priv_data;
         if (sc->timecode_track > 0) {
-            AVDictionaryEntry *tcr;
+            const AVDictionaryEntry *tcr;
             int tmcd_st_id = -1;
 
             for (j = 0; j < s->nb_streams; j++)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c370922c7d..f5f3299cf1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2194,7 +2194,7 @@ static int mov_write_mdcv_tag(AVIOContext *pb, MOVTrack *track)
 
 static void find_compressor(char * compressor_name, int len, MOVTrack *track)
 {
-    AVDictionaryEntry *encoder;
+    const AVDictionaryEntry *encoder;
     int xdcam_res =  (track->par->width == 1280 && track->par->height == 720)
                   || (track->par->width == 1440 && track->par->height == 1080)
                   || (track->par->width == 1920 && track->par->height == 1080);
@@ -2490,7 +2490,7 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
 #if 1
     int frame_duration;
     int nb_frames;
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
 
     if (!track->st->avg_frame_rate.num || !track->st->avg_frame_rate.den) {
         av_log(NULL, AV_LOG_ERROR, "avg_frame_rate not set for tmcd track.\n");
@@ -2988,7 +2988,7 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
             // hdlr.name is used by some players to identify the content title
             // of the track. So if an alternate handler description is
             // specified, use it.
-            AVDictionaryEntry *t;
+            const AVDictionaryEntry *t;
             t = av_dict_get(track->st->metadata, "handler_name", NULL, 0);
             if (t && utf8len(t->value))
                 descr = t->value;
@@ -3639,7 +3639,7 @@ static int mov_write_track_metadata(AVIOContext *pb, AVStream *st,
                                     const char *tag, const char *str)
 {
     int64_t pos = avio_tell(pb);
-    AVDictionaryEntry *t = av_dict_get(st->metadata, str, NULL, 0);
+    const AVDictionaryEntry *t = av_dict_get(st->metadata, str, NULL, 0);
     if (!t || !utf8len(t->value))
         return 0;
 
@@ -3952,11 +3952,11 @@ static int mov_write_string_tag(AVIOContext *pb, const char *name,
     return size;
 }
 
-static AVDictionaryEntry *get_metadata_lang(AVFormatContext *s,
+static const AVDictionaryEntry *get_metadata_lang(AVFormatContext *s,
                                             const char *tag, int *lang)
 {
     int l, len, len2;
-    AVDictionaryEntry *t, *t2 = NULL;
+    const AVDictionaryEntry *t, *t2 = NULL;
     char tag2[16];
 
     *lang = 0;
@@ -3982,7 +3982,7 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
                                      int long_style)
 {
     int lang;
-    AVDictionaryEntry *t = get_metadata_lang(s, tag, &lang);
+    const AVDictionaryEntry *t = get_metadata_lang(s, tag, &lang);
     if (!t)
         return 0;
     return mov_write_string_tag(pb, name, t->value, lang, long_style);
@@ -3991,7 +3991,7 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
 /* iTunes bpm number */
 static int mov_write_tmpo_tag(AVIOContext *pb, AVFormatContext *s)
 {
-    AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0);
+    const AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0);
     int size = 0, tmpo = t ? atoi(t->value) : 0;
     if (tmpo) {
         size = 26;
@@ -4013,7 +4013,7 @@ static int mov_write_loci_tag(AVFormatContext *s, AVIOContext *pb)
     int64_t pos = avio_tell(pb);
     double latitude, longitude, altitude;
     int32_t latitude_fix, longitude_fix, altitude_fix;
-    AVDictionaryEntry *t = get_metadata_lang(s, "location", &lang);
+    const AVDictionaryEntry *t = get_metadata_lang(s, "location", &lang);
     const char *ptr, *place = "";
     char *end;
     static const char *astronomical_body = "earth";
@@ -4061,9 +4061,9 @@ static int mov_write_loci_tag(AVFormatContext *s, AVIOContext *pb)
 static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
                               AVFormatContext *s, int disc)
 {
-    AVDictionaryEntry *t = av_dict_get(s->metadata,
-                                       disc ? "disc" : "track",
-                                       NULL, 0);
+    const AVDictionaryEntry *t = av_dict_get(s->metadata,
+                                             disc ? "disc" : "track",
+                                             NULL, 0);
     int size = 0, track = t ? atoi(t->value) : 0;
     if (track) {
         int tracks = 0;
@@ -4089,7 +4089,7 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
                                    const char *name, const char *tag,
                                    int len)
 {
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
     uint8_t num;
     int size = 24 + len;
 
@@ -4281,7 +4281,7 @@ static int mov_write_raw_metadata_tag(AVFormatContext *s, AVIOContext *pb,
                                       const char *name, const char *key)
 {
     int len;
-    AVDictionaryEntry *t;
+    const AVDictionaryEntry *t;
 
     if (!(t = av_dict_get(s->metadata, key, NULL, 0)))
         return 0;
@@ -4319,7 +4319,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
                                   const char *tag, const char *str)
 {
     int64_t pos = avio_tell(pb);
-    AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0);
+    const AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0);
     if (!t || !utf8len(t->value))
         return 0;
     avio_wb32(pb, 0);   /* size */
@@ -4350,7 +4350,7 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
 
     for (i = 0; i < nb_chapters; i++) {
         AVChapter *c = s->chapters[i];
-        AVDictionaryEntry *t;
+        const AVDictionaryEntry *t;
         avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
 
         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
@@ -4436,7 +4436,7 @@ static void mov_write_psp_udta_tag(AVIOContext *pb,
 
 static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
 {
-    AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
+    const AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
     int64_t pos, pos2;
 
     if (title) {
@@ -4673,7 +4673,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
         char track_name_buf[32] = { 0 };
 
         AVStream *st = track->st;
-        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
+        const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
 
         if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && !is_cover_image(st)) {
             type = "video";
@@ -6673,7 +6673,7 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
 
     for (i = 0; i < s->nb_chapters; i++) {
         AVChapter *c = s->chapters[i];
-        AVDictionaryEntry *t;
+        const AVDictionaryEntry *t;
 
         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,mov->movie_timescale});
         pkt->pts = pkt->dts = av_rescale_q(c->start, c->time_base, (AVRational){1,mov->movie_timescale});
@@ -7068,13 +7068,13 @@ static int mov_init(AVFormatContext *s)
 
     if (   mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4)
         || mov->write_tmcd == 1) {
-        AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode",
-                                                    NULL, 0);
+        const AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode",
+                                                          NULL, 0);
 
         /* +1 tmcd track for each video stream with a timecode */
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
-            AVDictionaryEntry *t = global_tcr;
+            const AVDictionaryEntry *t = global_tcr;
             if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
                 (t || (t=av_dict_get(st->metadata, "timecode", NULL, 0)))) {
                 AVTimecode tc;
@@ -7130,7 +7130,7 @@ static int mov_init(AVFormatContext *s)
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st= s->streams[i];
         MOVTrack *track= &mov->tracks[i];
-        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
+        const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
 
         track->st  = st;
         track->par = st->codecpar;
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 5e81f72a59..41ade128ed 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -41,7 +41,7 @@
 static int id3v1_set_string(AVFormatContext *s, const char *key,
                             uint8_t *buf, int buf_size)
 {
-    AVDictionaryEntry *tag;
+    const AVDictionaryEntry *tag;
     if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
         av_strlcpy(buf, tag->value, buf_size);
     return !!tag;
@@ -50,7 +50,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key,
 // refer to: http://id3.org/ID3v1
 static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
 {
-    AVDictionaryEntry *tag;
+    const AVDictionaryEntry *tag;
     int i, count = 0;
 
     memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */
@@ -145,7 +145,7 @@ static int mp3_write_xing(AVFormatContext *s)
 {
     MP3Context       *mp3 = s->priv_data;
     AVCodecParameters *par = s->streams[mp3->audio_stream_idx]->codecpar;
-    AVDictionaryEntry *enc = av_dict_get(s->streams[mp3->audio_stream_idx]->metadata, "encoder", NULL, 0);
+    const AVDictionaryEntry *enc = av_dict_get(s->streams[mp3->audio_stream_idx]->metadata, "encoder", NULL, 0);
     AVIOContext *dyn_ctx;
     int32_t        header;
     MPADecodeHeader  mpah;
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 700fc549df..6f1062b2d9 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -529,7 +529,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
         MpegTSWriteStream *ts_st = st->priv_data;
-        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
+        const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
         const char default_language[] = "und";
         const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language;
         enum AVCodecID codec_id = st->codecpar->codec_id;
@@ -986,7 +986,7 @@ static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
 {
     MpegTSWrite *ts = s->priv_data;
     MpegTSService *service;
-    AVDictionaryEntry *title, *provider;
+    const AVDictionaryEntry *title, *provider;
     char default_service_name[32];
     const char *service_name;
     const char *provider_name;
@@ -1088,7 +1088,7 @@ static void select_pcr_streams(AVFormatContext *s)
 static int mpegts_init(AVFormatContext *s)
 {
     MpegTSWrite *ts = s->priv_data;
-    AVDictionaryEntry *provider;
+    const AVDictionaryEntry *provider;
     const char *provider_name;
     int i, j;
     int ret;
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 415bd3948f..cfb1269ff5 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -185,7 +185,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
     FFFormatContext *const si = ffformatcontext(s);
     AVDictionary *tmp = NULL;
     const FFOutputFormat *of = ffofmt(s->oformat);
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
     int ret = 0;
 
     if (options)
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index 3e63b8039a..af1ce420e7 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -125,7 +125,7 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op
 
 int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
 {
-    AVDictionaryEntry *entry;
+    const AVDictionaryEntry *entry;
     int64_t parsed_timestamp;
     int ret;
     if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8252ed68f..e9eb801aa5 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -799,9 +799,9 @@ static void mxf_write_identification(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
     AVIOContext *pb = s->pb;
-    AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0);
-    AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0);
-    AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0);
+    const AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0);
+    const AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0);
+    const AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0);
     const char *company = com_entry ? com_entry->value : "FFmpeg";
     const char *product = product_entry ? product_entry->value : !IS_OPATOM(s) ? "OP1a Muxer" : "OPAtom Muxer";
     const char *platform = s->flags & AVFMT_FLAG_BITEXACT ? "Lavf" : PLATFORM_IDENT;
@@ -1649,7 +1649,7 @@ static int mxf_write_tagged_value(AVFormatContext *s, const char* name, const ch
 static int mxf_write_user_comments(AVFormatContext *s, const AVDictionary *m)
 {
     MXFContext *mxf = s->priv_data;
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
     int count = 0;
 
     while ((t = av_dict_get(m, "comment_", t, AV_DICT_IGNORE_SUFFIX))) {
@@ -1789,7 +1789,7 @@ static int mxf_write_essence_container_data(AVFormatContext *s)
 static int mxf_write_header_metadata_sets(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
-    AVDictionaryEntry *entry = NULL;
+    const AVDictionaryEntry *entry = NULL;
     AVStream *st = NULL;
     int i;
     MXFPackage packages[3] = {{0}};
@@ -2652,7 +2652,7 @@ static void mxf_gen_umid(AVFormatContext *s)
 static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational tbc)
 {
     MXFContext *mxf = s->priv_data;
-    AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
+    const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
 
     if (!ff_mxf_get_content_package_rate(tbc)) {
         if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
@@ -2854,7 +2854,7 @@ static int mxf_init(AVFormatContext *s)
             if (ret < 0)
                 return ret;
         } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
-            AVDictionaryEntry *e = av_dict_get(st->metadata, "data_type", NULL, 0);
+            const AVDictionaryEntry *e = av_dict_get(st->metadata, "data_type", NULL, 0);
             if (e && !strcmp(e->value, "vbi_vanc_smpte_436M")) {
                 sc->index = INDEX_S436M;
             } else {
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 179b0f12cb..d5c9eb8c2e 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -336,7 +336,7 @@ void ff_riff_write_info(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     int i;
     int64_t list_pos;
-    AVDictionaryEntry *t = NULL;
+    const AVDictionaryEntry *t = NULL;
 
     ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL);
 
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 0d001224cb..a1f9d9ee15 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -77,7 +77,7 @@ static int rv10_write_header(AVFormatContext *ctx,
     int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
     int bit_rate, v, duration, flags;
     int data_offset;
-    AVDictionaryEntry *tag;
+    const AVDictionaryEntry *tag;
 
     ffio_wfourcc(s, ".RMF");
     avio_wb32(s,18); /* header size */
diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c
index 28839b837f..714ff1e148 100644
--- a/libavformat/sapenc.c
+++ b/libavformat/sapenc.c
@@ -77,7 +77,7 @@ static int sap_write_header(AVFormatContext *s)
     struct sockaddr_storage localaddr;
     socklen_t addrlen = sizeof(localaddr);
     int udp_fd;
-    AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0);
+    const AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0);
 
     if (!ff_network_init())
         return AVERROR(EIO);
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 6888936290..61e57894a0 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -837,7 +837,7 @@ int ff_sdp_write_media(char *buff, int size, const AVStream *st, int idx,
 
 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
 {
-    AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0);
+    const AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0);
     struct sdp_session_level s = { 0 };
     int i, j, port, ttl, is_multicast, index = 0;
     char dst[32], dst_type[5];
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 2a82f39f31..1fb52c7f16 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -355,7 +355,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
     int ret = 0;
     AVTimecode tc;
     AVRational rate;
-    AVDictionaryEntry *tcr;
+    const AVDictionaryEntry *tcr;
     char buf[AV_TIMECODE_STR_SIZE];
     int i;
     int err;
@@ -441,7 +441,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
                 char st_buf[AV_TIMECODE_STR_SIZE];
                 AVTimecode st_tc;
                 AVRational st_rate = s->streams[i]->avg_frame_rate;
-                AVDictionaryEntry *st_tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0);
+                const AVDictionaryEntry *st_tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0);
                 if (st_tcr) {
                     if ((av_timecode_init_from_string(&st_tc, st_rate, st_tcr->value, s) < 0)) {
                         av_log(s, AV_LOG_WARNING, "Could not increment stream %d timecode, error occurred during timecode creation.\n", i);
diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c
index 062b4a3fae..b10168c91f 100644
--- a/libavformat/soxenc.c
+++ b/libavformat/soxenc.c
@@ -47,7 +47,7 @@ static int sox_write_header(AVFormatContext *s)
     SoXContext *sox = s->priv_data;
     AVIOContext *pb = s->pb;
     AVCodecParameters *par = s->streams[0]->codecpar;
-    AVDictionaryEntry *comment;
+    const AVDictionaryEntry *comment;
     size_t comment_len = 0, comment_size;
 
     comment = av_dict_get(s->metadata, "comment", NULL, 0);
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 70f3f2eb29..2aa2934677 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
     int i, ret;
     AVDictionary *options = NULL, *bsf_options = NULL;
     char *entry_val = NULL;
-    AVDictionaryEntry *entry;
+    const AVDictionaryEntry *entry;
     char *filename;
     char *format = NULL, *select = NULL, *on_fail = NULL;
     char *use_fifo = NULL, *fifo_options_str = NULL;
diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c
index 212994be50..41020c2537 100644
--- a/libavformat/ttmlenc.c
+++ b/libavformat/ttmlenc.c
@@ -136,8 +136,8 @@ static int ttml_write_header(AVFormatContext *ctx)
         AVStream    *st = ctx->streams[0];
         AVIOContext *pb = ctx->pb;
 
-        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,
-                                              0);
+        const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,
+                                                    0);
         const char *printed_lang = (lang && lang->value) ? lang->value : "";
 
         ttml_ctx->input_type = ff_is_ttml_stream_paragraph_based(st->codecpar) ?
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index c12c090934..345f21293c 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -91,7 +91,7 @@ typedef struct WAVMuxContext {
 #if CONFIG_WAV_MUXER
 static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, int maxlen)
 {
-    AVDictionaryEntry *tag;
+    const AVDictionaryEntry *tag;
     size_t len = 0;
 
     if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
@@ -105,7 +105,7 @@ static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, in
 
 static void bwf_write_bext_chunk(AVFormatContext *s)
 {
-    AVDictionaryEntry *tmp_tag;
+    const AVDictionaryEntry *tmp_tag;
     uint64_t time_reference = 0;
     int64_t bext = ff_start_tag(s->pb, "bext");
 
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 0d6c4a2072..e085227ddd 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -71,7 +71,7 @@ static double get_duration(AVFormatContext *s)
     int i = 0;
     double max = 0.0;
     for (i = 0; i < s->nb_streams; i++) {
-        AVDictionaryEntry *duration = av_dict_get(s->streams[i]->metadata,
+        const AVDictionaryEntry *duration = av_dict_get(s->streams[i]->metadata,
                                                   DURATION, NULL, 0);
         if (!duration || atof(duration->value) < 0) continue;
         if (atof(duration->value) > max) max = atof(duration->value);
@@ -130,11 +130,11 @@ static void write_footer(AVFormatContext *s)
 static int subsegment_alignment(AVFormatContext *s, const AdaptationSet *as)
 {
     int i;
-    AVDictionaryEntry *gold = av_dict_get(s->streams[as->streams[0]]->metadata,
+    const AVDictionaryEntry *gold = av_dict_get(s->streams[as->streams[0]]->metadata,
                                           CUE_TIMESTAMPS, NULL, 0);
     if (!gold) return 0;
     for (i = 1; i < as->nb_streams; i++) {
-        AVDictionaryEntry *ts = av_dict_get(s->streams[as->streams[i]]->metadata,
+        const AVDictionaryEntry *ts = av_dict_get(s->streams[as->streams[i]]->metadata,
                                             CUE_TIMESTAMPS, NULL, 0);
         if (!ts || !av_strstart(ts->value, gold->value, NULL)) return 0;
     }
@@ -145,13 +145,13 @@ static int bitstream_switching(AVFormatContext *s, const AdaptationSet *as)
 {
     int i;
     const AVStream *gold_st = s->streams[as->streams[0]];
-    AVDictionaryEntry *gold_track_num = av_dict_get(gold_st->metadata,
+    const AVDictionaryEntry *gold_track_num = av_dict_get(gold_st->metadata,
                                                     TRACK_NUMBER, NULL, 0);
     AVCodecParameters *gold_par = gold_st->codecpar;
     if (!gold_track_num) return 0;
     for (i = 1; i < as->nb_streams; i++) {
         const AVStream *st = s->streams[as->streams[i]];
-        AVDictionaryEntry *track_num = av_dict_get(st->metadata,
+        const AVDictionaryEntry *track_num = av_dict_get(st->metadata,
                                                    TRACK_NUMBER, NULL, 0);
         AVCodecParameters *par = st->codecpar;
         if (!track_num ||
@@ -177,7 +177,7 @@ static int write_representation(AVFormatContext *s, AVStream *st, char *id,
     WebMDashMuxContext *w = s->priv_data;
     AVIOContext *pb = s->pb;
     const AVCodecParameters *par = st->codecpar;
-    AVDictionaryEntry *bandwidth = av_dict_get(st->metadata, BANDWIDTH, NULL, 0);
+    const AVDictionaryEntry *bandwidth = av_dict_get(st->metadata, BANDWIDTH, NULL, 0);
     const char *bandwidth_str;
     avio_printf(pb, "<Representation id=\"%s\"", id);
     if (bandwidth) {
@@ -205,10 +205,10 @@ static int write_representation(AVFormatContext *s, AVStream *st, char *id,
         avio_printf(pb, " startsWithSAP=\"1\"");
         avio_printf(pb, ">");
     } else {
-        AVDictionaryEntry *irange = av_dict_get(st->metadata, INITIALIZATION_RANGE, NULL, 0);
-        AVDictionaryEntry *cues_start = av_dict_get(st->metadata, CUES_START, NULL, 0);
-        AVDictionaryEntry *cues_end = av_dict_get(st->metadata, CUES_END, NULL, 0);
-        AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0);
+        const AVDictionaryEntry *irange = av_dict_get(st->metadata, INITIALIZATION_RANGE, NULL, 0);
+        const AVDictionaryEntry *cues_start = av_dict_get(st->metadata, CUES_START, NULL, 0);
+        const AVDictionaryEntry *cues_end = av_dict_get(st->metadata, CUES_END, NULL, 0);
+        const AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0);
         if (!irange || !cues_start || !cues_end || !filename)
             return AVERROR(EINVAL);
 
@@ -307,7 +307,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
     AdaptationSet *as = &w->as[as_index];
     const AVStream *st = s->streams[as->streams[0]];
     AVCodecParameters *par = st->codecpar;
-    AVDictionaryEntry *lang;
+    const AVDictionaryEntry *lang;
     AVIOContext *pb = s->pb;
     int i;
     static const char boolean[2][6] = { "false", "true" };
@@ -347,15 +347,15 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
                 boolean[w->is_live || subsegment_alignment(s, as)]);
 
     for (i = 0; i < as->nb_streams; i++) {
-        AVDictionaryEntry *kf = av_dict_get(s->streams[as->streams[i]]->metadata,
-                                            CLUSTER_KEYFRAME, NULL, 0);
+        const AVDictionaryEntry *kf = av_dict_get(s->streams[as->streams[i]]->metadata,
+                                                  CLUSTER_KEYFRAME, NULL, 0);
         if (!w->is_live && (!kf || !strncmp(kf->value, "0", 1))) subsegmentStartsWithSAP = 0;
     }
     avio_printf(pb, " subsegmentStartsWithSAP=\"%d\"", subsegmentStartsWithSAP);
     avio_printf(pb, ">\n");
 
     if (w->is_live) {
-        AVDictionaryEntry *filename =
+        const AVDictionaryEntry *filename =
             av_dict_get(st->metadata, FILENAME, NULL, 0);
         char *underscore_pos, *period_pos;
         int ret;
@@ -383,7 +383,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
         AVStream *st = s->streams[as->streams[i]];
         int ret;
         if (w->is_live) {
-            AVDictionaryEntry *filename =
+            const AVDictionaryEntry *filename =
                 av_dict_get(st->metadata, FILENAME, NULL, 0);
             if (!filename)
                 return AVERROR(EINVAL);
diff --git a/libavutil/dict.c b/libavutil/dict.c
index ac41771994..ca5026905c 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -57,6 +57,9 @@ const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m,
     return &m->elems[i];
 }
 
+#if !FF_API_AV_DICT_GET_NOT_CONST
+const
+#endif
 AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
                                const AVDictionaryEntry *prev, int flags)
 {
@@ -78,7 +81,11 @@ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
             continue;
         if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
             continue;
+        #if FF_API_AV_DICT_GET_NOT_CONST
         return (AVDictionaryEntry *)entry;
+        #else
+        return entry;
+        #endif
     }
     return NULL;
 }
@@ -100,7 +107,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
         goto err_out;
     }
     if (!(flags & AV_DICT_MULTIKEY)) {
-        tag = av_dict_get(m, key, NULL, flags);
+        tag = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
     }
     if (flags & AV_DICT_DONT_STRDUP_KEY)
         copy_key = (void *)key;
diff --git a/libavutil/dict.h b/libavutil/dict.h
index b2ab55a026..984c12311b 100644
--- a/libavutil/dict.h
+++ b/libavutil/dict.h
@@ -32,6 +32,8 @@
 
 #include <stdint.h>
 
+#include "version.h"
+
 /**
  * @addtogroup lavu_dict AVDictionary
  * @ingroup lavu_data
@@ -107,6 +109,9 @@ typedef struct AVDictionary AVDictionary;
  *
  * @return      Found entry or NULL in case no matching entry was found in the dictionary
  */
+#if !FF_API_AV_DICT_GET_NOT_CONST
+const
+#endif
 AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
                                const AVDictionaryEntry *prev, int flags);
 
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 5ae7711c94..ed698aa6f7 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -379,7 +379,7 @@ static int cuda_context_init(AVHWDeviceContext *device_ctx, int flags) {
 static int cuda_flags_from_opts(AVHWDeviceContext *device_ctx,
                                 AVDictionary *opts, int *flags)
 {
-    AVDictionaryEntry *primary_ctx_opt = av_dict_get(opts, "primary_ctx", NULL, 0);
+    const AVDictionaryEntry *primary_ctx_opt = av_dict_get(opts, "primary_ctx", NULL, 0);
 
     if (primary_ctx_opt && strtol(primary_ctx_opt->value, NULL, 10)) {
         av_log(device_ctx, AV_LOG_VERBOSE, "Using CUDA primary device context\n");
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 6780428875..a00bec89ec 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -2106,7 +2106,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
     enum AVHWDeviceType child_device_type;
     AVHWDeviceContext *child_device;
     AVDictionary *child_device_opts;
-    AVDictionaryEntry *e;
+    const AVDictionaryEntry *e;
 
     mfxIMPL impl;
     int ret;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index ffd4f5dec4..f3429fc39f 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -438,7 +438,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts,
     int optional_exts_num;
     uint32_t sup_ext_count;
     char *user_exts_str = NULL;
-    AVDictionaryEntry *user_exts;
+    const AVDictionaryEntry *user_exts;
     VkExtensionProperties *sup_ext;
     const VulkanOptExtension *optional_exts;
 
@@ -566,14 +566,14 @@ static int check_validation_layers(AVHWDeviceContext *ctx, AVDictionary *opts,
     uint32_t sup_layer_count;
     VkLayerProperties *sup_layers;
 
-    AVDictionaryEntry *user_layers;
+    const AVDictionaryEntry *user_layers;
     char *user_layers_str = NULL;
     char *save, *token;
 
     const char **enabled_layers = NULL;
     uint32_t enabled_layers_count = 0;
 
-    AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
+    const AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
     int debug = debug_opt && strtol(debug_opt->value, NULL, 10);
 
     /* If `debug=0`, enable no layers at all. */
@@ -1313,7 +1313,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
 {
     int err = 0;
     VkResult ret;
-    AVDictionaryEntry *opt_d;
+    const AVDictionaryEntry *opt_d;
     VulkanDevicePriv *p = ctx->internal->priv;
     FFVulkanFunctions *vk = &p->vkfn;
     AVVulkanDeviceContext *hwctx = ctx->hwctx;
diff --git a/libavutil/version.h b/libavutil/version.h
index b8d1ef06a8..31c0403466 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -115,6 +115,7 @@
 #define FF_API_FRAME_PICTURE_NUMBER     (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_HDR_VIVID_THREE_SPLINE   (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_FRAME_PKT                (LIBAVUTIL_VERSION_MAJOR < 59)
+#define FF_API_AV_DICT_GET_NOT_CONST    (LIBAVUTIL_VERSION_MAJOR < 59)
 
 /**
  * @}
diff --git a/tests/api/api-threadmessage-test.c b/tests/api/api-threadmessage-test.c
index c96b473c43..c37c081249 100644
--- a/tests/api/api-threadmessage-test.c
+++ b/tests/api/api-threadmessage-test.c
@@ -137,7 +137,7 @@ static void *receiver_thread(void *arg)
         } else {
             struct message msg;
             AVDictionary *meta;
-            AVDictionaryEntry *e;
+            const AVDictionaryEntry *e;
 
             ret = av_thread_message_queue_recv(rd->queue, &msg, 0);
             if (ret < 0)
-- 
2.37.0 (Apple Git-136)



More information about the ffmpeg-devel mailing list