[FFmpeg-devel] [PATCH 3/4] avformat/mux: do not call write_header multiple times if it fails the first time

Michael Niedermayer michael at niedermayer.cc
Sun Jun 12 05:48:49 CEST 2016


On Sat, Jun 11, 2016 at 11:54:31PM +0200, Marton Balint wrote:
> 
> 
> On Sat, 11 Jun 2016, Michael Niedermayer wrote:
> 
> >On Sat, Jun 11, 2016 at 08:33:42PM +0200, Marton Balint wrote:
> >>Signed-off-by: Marton Balint <cus at passwd.hu>
> >>---
> >> libavformat/internal.h | 1 +
> >> libavformat/mux.c      | 5 +++--
> >> 2 files changed, 4 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/libavformat/internal.h b/libavformat/internal.h
> >>index 40ba089..b6c2020 100644
> >>--- a/libavformat/internal.h
> >>+++ b/libavformat/internal.h
> >>@@ -124,6 +124,7 @@ struct AVFormatInternal {
> >>      * Whether or not a header has already been written
> >>      */
> >>     int header_written;
> >>+    int write_header_ret;
> >> };
> >>
> >> struct AVStreamInternal {
> >>diff --git a/libavformat/mux.c b/libavformat/mux.c
> >>index 08ed940..b1b65a1 100644
> >>--- a/libavformat/mux.c
> >>+++ b/libavformat/mux.c
> >>@@ -479,6 +479,7 @@ static int write_header_internal(AVFormatContext *s)
> >>         int ret = s->oformat->write_header(s);
> >>         if (ret >= 0 && s->pb && s->pb->error < 0)
> >>             ret = s->pb->error;
> >>+        s->internal->write_header_ret = ret;
> >
> >would
> >header_written = ret
> >be simpler ?
> 
> I can change it, but I found it a little less readable.

then better to leave it

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160612/f37082fc/attachment.sig>


More information about the ffmpeg-devel mailing list