diff mbox series

[FFmpeg-devel,13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket)

Message ID AM7PR03MB666078808FDDAD1E5393C4408F779@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 41457e536c059d265844b1a66c906a9a842f73ab
Headers show
Series [FFmpeg-devel,01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies | expand

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Andreas Rheinhardt Dec. 16, 2021, 1:29 a.m. UTC
This removes the last usage of sizeof(AVPacket) in the generic
muxing code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/mux.c    | 8 +-------
 libavformat/mxfenc.c | 8 ++------
 2 files changed, 3 insertions(+), 13 deletions(-)

Comments

Tomas Härdin Dec. 21, 2021, 1:52 p.m. UTC | #1
tor 2021-12-16 klockan 02:29 +0100 skrev Andreas Rheinhardt:
> This removes the last usage of sizeof(AVPacket) in the generic
> muxing code.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/mux.c    | 8 +-------
>  libavformat/mxfenc.c | 8 ++------
>  2 files changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index b9c4abb9cf..0500f636de 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1014,15 +1014,9 @@ int
> ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
>          AVStream *const st = s->streams[pktl->pkt.stream_index];
>          FFStream *const sti = ffstream(st);
>  
> -        *pkt = pktl->pkt;
> -
> -        si->packet_buffer = pktl->next;
> -        if (!si->packet_buffer)
> -            si->packet_buffer_end = NULL;
> -
>          if (sti->last_in_packet_buffer == pktl)
>              sti->last_in_packet_buffer = NULL;
> -        av_freep(&pktl);
> +        avpriv_packet_list_get(&si->packet_buffer, &si-
> >packet_buffer_end, pkt);
>  
>          return 1;
>      } else {
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 00bbe58149..7635e183d0 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -3125,14 +3125,10 @@ static int
> mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
>              pktl = si->packet_buffer;
>          }
>  
> -        *out = pktl->pkt;
> -        av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n",
> (*out).stream_index, (*out).dts);
> -        si->packet_buffer = pktl->next;
>          if (ffstream(s->streams[pktl->pkt.stream_index])-
> >last_in_packet_buffer == pktl)
>              ffstream(s->streams[pktl->pkt.stream_index])-
> >last_in_packet_buffer = NULL;
> -        if (!si->packet_buffer)
> -            si->packet_buffer_end = NULL;
> -        av_freep(&pktl);
> +        avpriv_packet_list_get(&si->packet_buffer, &si-
> >packet_buffer_end, out);
> +        av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out-
> >stream_index, out->dts);
>          return 1;
>      } else {
>      out:

Looks like this makes the code simpler, which is fine by me

/Tomas
diff mbox series

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index b9c4abb9cf..0500f636de 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1014,15 +1014,9 @@  int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
         AVStream *const st = s->streams[pktl->pkt.stream_index];
         FFStream *const sti = ffstream(st);
 
-        *pkt = pktl->pkt;
-
-        si->packet_buffer = pktl->next;
-        if (!si->packet_buffer)
-            si->packet_buffer_end = NULL;
-
         if (sti->last_in_packet_buffer == pktl)
             sti->last_in_packet_buffer = NULL;
-        av_freep(&pktl);
+        avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, pkt);
 
         return 1;
     } else {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 00bbe58149..7635e183d0 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3125,14 +3125,10 @@  static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
             pktl = si->packet_buffer;
         }
 
-        *out = pktl->pkt;
-        av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts);
-        si->packet_buffer = pktl->next;
         if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl)
             ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL;
-        if (!si->packet_buffer)
-            si->packet_buffer_end = NULL;
-        av_freep(&pktl);
+        avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, out);
+        av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts);
         return 1;
     } else {
     out: