diff mbox

[FFmpeg-devel,V1,4/4] lavf/mux: remove unnecessary packet reset

Message ID 1568115568-14548-4-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao Sept. 10, 2019, 11:39 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

remove unnecessary packet reset in av_interleaved_write_frame

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/mux.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt Sept. 10, 2019, 12:04 p.m. UTC | #1
Jun Zhao:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> remove unnecessary packet reset in av_interleaved_write_frame
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/mux.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index 0227c0d..9bac252 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1227,11 +1227,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
>      for (;; ) {
>          AVPacket opkt;
>          int ret = interleave_packet(s, &opkt, pkt, flush);
> -        if (pkt) {
> -            memset(pkt, 0, sizeof(*pkt));
> -            av_init_packet(pkt);
> +        if (pkt)
>              pkt = NULL;
> -        }
> +
>          if (ret <= 0) //FIXME cleanup needed for ret<0 ?
>              return ret;
>  
I made a patchset [1] (that has already been partially pushed) whose
patch 11 deals with the memleak that happens on error in the above
code and also removes the unnecessary packet reset on success.

- Andreas

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248140.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248145.html
Jun Zhao Sept. 11, 2019, 2:22 a.m. UTC | #2
On Tue, Sep 10, 2019 at 8:05 PM Andreas Rheinhardt
<andreas.rheinhardt@gmail.com> wrote:
>
> Jun Zhao:
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > remove unnecessary packet reset in av_interleaved_write_frame
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/mux.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavformat/mux.c b/libavformat/mux.c
> > index 0227c0d..9bac252 100644
> > --- a/libavformat/mux.c
> > +++ b/libavformat/mux.c
> > @@ -1227,11 +1227,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
> >      for (;; ) {
> >          AVPacket opkt;
> >          int ret = interleave_packet(s, &opkt, pkt, flush);
> > -        if (pkt) {
> > -            memset(pkt, 0, sizeof(*pkt));
> > -            av_init_packet(pkt);
> > +        if (pkt)
> >              pkt = NULL;
> > -        }
> > +
> >          if (ret <= 0) //FIXME cleanup needed for ret<0 ?
> >              return ret;
> >
> I made a patchset [1] (that has already been partially pushed) whose
> patch 11 deals with the memleak that happens on error in the above
> code and also removes the unnecessary packet reset on success.
>
> - Andreas
>
> [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248140.html
> [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248145.html
>
I didn't notice that pathset details, please goto the patchset, will
drop the patch, Thanks
diff mbox

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 0227c0d..9bac252 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1227,11 +1227,9 @@  int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
     for (;; ) {
         AVPacket opkt;
         int ret = interleave_packet(s, &opkt, pkt, flush);
-        if (pkt) {
-            memset(pkt, 0, sizeof(*pkt));
-            av_init_packet(pkt);
+        if (pkt)
             pkt = NULL;
-        }
+
         if (ret <= 0) //FIXME cleanup needed for ret<0 ?
             return ret;