diff mbox

[FFmpeg-devel,03/13] avformat/mux: Use const AVPacket * in compare functions

Message ID 20190813024726.6596-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 114775955241c2cb742a701cc9eb6462d090f560
Headers show

Commit Message

Andreas Rheinhardt Aug. 13, 2019, 2:47 a.m. UTC
There is no reason for these functions to modify the given packets at
all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/audiointerleave.c | 2 +-
 libavformat/audiointerleave.h | 2 +-
 libavformat/gxfenc.c          | 5 +++--
 libavformat/internal.h        | 2 +-
 libavformat/mux.c             | 6 +++---
 libavformat/mxfenc.c          | 3 ++-
 6 files changed, 11 insertions(+), 9 deletions(-)

Comments

Paul B Mahol Aug. 14, 2019, 4:31 p.m. UTC | #1
LGTM

On Tue, Aug 13, 2019 at 4:49 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> There is no reason for these functions to modify the given packets at
> all.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/audiointerleave.c | 2 +-
>  libavformat/audiointerleave.h | 2 +-
>  libavformat/gxfenc.c          | 5 +++--
>  libavformat/internal.h        | 2 +-
>  libavformat/mux.c             | 6 +++---
>  libavformat/mxfenc.c          | 3 ++-
>  6 files changed, 11 insertions(+), 9 deletions(-)
>
> 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;
> --
> 2.21.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Aug. 14, 2019, 11:13 p.m. UTC | #2
On Wed, Aug 14, 2019 at 06:31:23PM +0200, Paul B Mahol wrote:
> LGTM

will apply

thx

[...]
diff mbox

Patch

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;