diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index dea5d99821..b602eb7105 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -108,7 +108,7 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt,
 
 int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush,
                         int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
-                        int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
+                        int (*compare_ts)(AVFormatContext *, const AVPacket *, const AVPacket *))
 {
     int i, ret;
 
diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h
index 4d77832fa1..f28d5fefcc 100644
--- a/libavformat/audiointerleave.h
+++ b/libavformat/audiointerleave.h
@@ -50,6 +50,6 @@ void ff_audio_interleave_close(AVFormatContext *s);
  */
 int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush,
                         int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
-                        int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *));
+                        int (*compare_ts)(AVFormatContext *, const AVPacket *, const AVPacket *));
 
 #endif /* AVFORMAT_AUDIOINTERLEAVE_H */
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 3507c00b40..ad9ddea887 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -987,10 +987,11 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
-static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cur)
+static int gxf_compare_field_nb(AVFormatContext *s, const AVPacket *next,
+                                                    const AVPacket *cur)
 {
     GXFContext *gxf = s->priv_data;
-    AVPacket *pkt[2] = { cur, next };
+    const AVPacket *pkt[2] = { cur, next };
     int i, field_nb[2];
     GXFStreamContext *sc[2];
 
diff --git a/libavformat/internal.h b/libavformat/internal.h
index cf8c16579c..d6a039c497 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -237,7 +237,7 @@ int ff_hex_to_data(uint8_t *data, const char *p);
  * @return 0, or < 0 on error
  */
 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
-                             int (*compare)(AVFormatContext *, AVPacket *, AVPacket *));
+                             int (*compare)(AVFormatContext *, const AVPacket *, const AVPacket *));
 
 void ff_read_frame_flush(AVFormatContext *s);
 
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 870e716950..2728c62de5 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -917,7 +917,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
 #define CHUNK_START 0x1000
 
 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
-                             int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
+                             int (*compare)(AVFormatContext *, const AVPacket *, const AVPacket *))
 {
     int ret;
     AVPacketList **next_point, *this_pktl;
@@ -991,8 +991,8 @@ next_non_null:
     return 0;
 }
 
-static int interleave_compare_dts(AVFormatContext *s, AVPacket *next,
-                                  AVPacket *pkt)
+static int interleave_compare_dts(AVFormatContext *s, const AVPacket *next,
+                                                      const AVPacket *pkt)
 {
     AVStream *st  = s->streams[pkt->stream_index];
     AVStream *st2 = s->streams[next->stream_index];
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2e54320cf0..8b3d599a6f 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3148,7 +3148,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
     }
 }
 
-static int mxf_compare_timestamps(AVFormatContext *s, AVPacket *next, AVPacket *pkt)
+static int mxf_compare_timestamps(AVFormatContext *s, const AVPacket *next,
+                                                      const AVPacket *pkt)
 {
     MXFStreamContext *sc  = s->streams[pkt ->stream_index]->priv_data;
     MXFStreamContext *sc2 = s->streams[next->stream_index]->priv_data;
