[FFmpeg-devel] avformat: rename AVOutputFormat.deinit to AVOutputFormat.close

Submitted by James Almer on Nov. 20, 2017, 8:40 p.m.

Details

Message ID 20171120204019.5756-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Nov. 20, 2017, 8:40 p.m.
This is more in line with other callbacks, like AVCodec.close and
AVInputFormat.read_close

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/avformat.h  |  4 ++--
 libavformat/dashenc.c   |  6 +++---
 libavformat/fifo.c      |  4 ++--
 libavformat/movenc.c    | 18 +++++++++---------
 libavformat/mpegtsenc.c |  4 ++--
 libavformat/mux.c       | 12 ++++++------
 libavformat/nutenc.c    |  4 ++--
 libavformat/oggenc.c    | 12 ++++++------
 libavformat/segment.c   |  6 +++---
 9 files changed, 35 insertions(+), 35 deletions(-)

Comments

Nicolas George Nov. 20, 2017, 8:45 p.m.
James Almer (2017-11-20):
> This is more in line with other callbacks, like AVCodec.close and
> AVInputFormat.read_close

Unless I am mistaken, unlike the "close" callbacks, this one is always
called, including when init fails.

Regards,
James Almer Nov. 20, 2017, 9:11 p.m.
On 11/20/2017 5:45 PM, Nicolas George wrote:
> James Almer (2017-11-20):
>> This is more in line with other callbacks, like AVCodec.close and
>> AVInputFormat.read_close
> 
> Unless I am mistaken, unlike the "close" callbacks, this one is always
> called, including when init fails.
> 
> Regards,

The three behave in different ways. AVCodec.close is called always from
avcodec_close() but from avcodec_open2() only if
FF_CODEC_CAP_INIT_CLEANUP is set, whereas AVInputFormat.read_close is
called always but exclusively from avformat_close_input().

Patch hide | download patch | download mbox

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 322210fae0..811c2ab9da 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -603,7 +603,7 @@  typedef struct AVOutputFormat {
      *
      * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
      *
-     * Any allocations made here must be freed in deinit().
+     * Any allocations made here must be freed in close().
      */
     int (*init)(struct AVFormatContext *);
     /**
@@ -614,7 +614,7 @@  typedef struct AVOutputFormat {
      *
      * This is called if init() fails as well.
      */
-    void (*deinit)(struct AVFormatContext *);
+    void (*close)(struct AVFormatContext *);
     /**
      * Set up any necessary bitstream filtering and extract any extra data needed
      * for the global header.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index ddad3351fd..fb67d47091 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -225,7 +225,7 @@  static int flush_init_segment(AVFormatContext *s, OutputStream *os)
     return 0;
 }
 
-static void dash_free(AVFormatContext *s)
+static void dash_close(AVFormatContext *s)
 {
     DASHContext *c = s->priv_data;
     int i, j;
@@ -836,7 +836,7 @@  static int dash_write_header(AVFormatContext *s)
     for (i = 0; i < s->nb_streams; i++) {
         OutputStream *os = &c->streams[i];
         if ((ret = avformat_write_header(os->ctx, NULL)) < 0) {
-            dash_free(s);
+            dash_close(s);
             return ret;
         }
     }
@@ -1211,7 +1211,7 @@  AVOutputFormat ff_dash_muxer = {
     .write_header   = dash_write_header,
     .write_packet   = dash_write_packet,
     .write_trailer  = dash_write_trailer,
-    .deinit         = dash_free,
+    .close          = dash_close,
     .check_bitstream = dash_check_bitstream,
     .priv_class     = &dash_class,
 };
diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index c881f31e94..21bda9f36d 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -600,7 +600,7 @@  static int fifo_write_trailer(AVFormatContext *avf)
     return ret;
 }
 
-static void fifo_deinit(AVFormatContext *avf)
+static void fifo_close(AVFormatContext *avf)
 {
     FifoContext *fifo = avf->priv_data;
 
@@ -661,7 +661,7 @@  AVOutputFormat ff_fifo_muxer = {
     .write_header   = fifo_write_header,
     .write_packet   = fifo_write_packet,
     .write_trailer  = fifo_write_trailer,
-    .deinit         = fifo_deinit,
+    .close          = fifo_close,
     .priv_class     = &fifo_muxer_class,
     .flags          = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
 };
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0d924ad758..00104edd63 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5715,7 +5715,7 @@  static void enable_tracks(AVFormatContext *s)
     }
 }
 
-static void mov_free(AVFormatContext *s)
+static void mov_close(AVFormatContext *s)
 {
     MOVMuxContext *mov = s->priv_data;
     int i;
@@ -6614,7 +6614,7 @@  AVOutputFormat ff_mov_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){
         ff_codec_movvideo_tags, ff_codec_movaudio_tags, 0
@@ -6636,7 +6636,7 @@  AVOutputFormat ff_tgp_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){ codec_3gp_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
@@ -6658,7 +6658,7 @@  AVOutputFormat ff_mp4_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
@@ -6679,7 +6679,7 @@  AVOutputFormat ff_psp_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
@@ -6699,7 +6699,7 @@  AVOutputFormat ff_tg2_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){ codec_3gp_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
@@ -6720,7 +6720,7 @@  AVOutputFormat ff_ipod_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){ codec_ipod_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
@@ -6741,7 +6741,7 @@  AVOutputFormat ff_ismv_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
     .codec_tag         = (const AVCodecTag* const []){
         codec_mp4_tags, codec_ism_tags, 0 },
@@ -6763,7 +6763,7 @@  AVOutputFormat ff_f4v_muxer = {
     .write_header      = mov_write_header,
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
-    .deinit            = mov_free,
+    .close             = mov_close,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH,
     .codec_tag         = (const AVCodecTag* const []){ codec_f4v_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fdfa544ee2..baf0099b9e 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1819,7 +1819,7 @@  static int mpegts_write_end(AVFormatContext *s)
     return 0;
 }
 
-static void mpegts_deinit(AVFormatContext *s)
+static void mpegts_close(AVFormatContext *s)
 {
     MpegTSWrite *ts = s->priv_data;
     MpegTSService *service;
@@ -1981,7 +1981,7 @@  AVOutputFormat ff_mpegts_muxer = {
     .init           = mpegts_init,
     .write_packet   = mpegts_write_packet,
     .write_trailer  = mpegts_write_end,
-    .deinit         = mpegts_deinit,
+    .close          = mpegts_close,
     .check_bitstream = mpegts_check_bitstream,
     .flags          = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS,
     .priv_class     = &mpegts_muxer_class,
diff --git a/libavformat/mux.c b/libavformat/mux.c
index b1244c67f3..bbd558d98b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -397,8 +397,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
 
     if (s->oformat->init) {
         if ((ret = s->oformat->init(s)) < 0) {
-            if (s->oformat->deinit)
-                s->oformat->deinit(s);
+            if (s->oformat->close)
+                s->oformat->close(s);
             return ret;
         }
         return ret == 0;
@@ -537,8 +537,8 @@  int avformat_write_header(AVFormatContext *s, AVDictionary **options)
     return streams_already_initialized;
 
 fail:
-    if (s->oformat->deinit)
-        s->oformat->deinit(s);
+    if (s->oformat->close)
+        s->oformat->close(s);
     return ret;
 }
 
@@ -1299,8 +1299,8 @@  fail:
         }
     }
 
-    if (s->oformat->deinit)
-        s->oformat->deinit(s);
+    if (s->oformat->close)
+        s->oformat->close(s);
 
     s->internal->header_written =
     s->internal->initialized =
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index a92ff55c01..35a9ad9b52 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -1180,7 +1180,7 @@  static int nut_write_trailer(AVFormatContext *s)
     return 0;
 }
 
-static void nut_write_deinit(AVFormatContext *s)
+static void nut_write_close(AVFormatContext *s)
 {
     NUTContext *nut = s->priv_data;
     int i;
@@ -1225,7 +1225,7 @@  AVOutputFormat ff_nut_muxer = {
     .write_header   = nut_write_header,
     .write_packet   = nut_write_packet,
     .write_trailer  = nut_write_trailer,
-    .deinit         = nut_write_deinit,
+    .close          = nut_write_close,
     .flags          = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
     .codec_tag      = ff_nut_codec_tags,
     .priv_class     = &class,
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 10c4eda062..89546b6fd5 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -736,7 +736,7 @@  static int ogg_write_trailer(AVFormatContext *s)
     return 0;
 }
 
-static void ogg_free(AVFormatContext *s)
+static void ogg_close(AVFormatContext *s)
 {
     int i;
 
@@ -781,7 +781,7 @@  AVOutputFormat ff_ogg_muxer = {
     .write_header      = ogg_write_header,
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
-    .deinit            = ogg_free,
+    .close             = ogg_close,
     .flags             = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
     .priv_class        = &ogg_muxer_class,
 };
@@ -800,7 +800,7 @@  AVOutputFormat ff_oga_muxer = {
     .write_header      = ogg_write_header,
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
-    .deinit            = ogg_free,
+    .close             = ogg_close,
     .flags             = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
     .priv_class        = &oga_muxer_class,
 };
@@ -822,7 +822,7 @@  AVOutputFormat ff_ogv_muxer = {
     .write_header      = ogg_write_header,
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
-    .deinit            = ogg_free,
+    .close             = ogg_close,
     .flags             = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
     .priv_class        = &ogv_muxer_class,
 };
@@ -841,7 +841,7 @@  AVOutputFormat ff_spx_muxer = {
     .write_header      = ogg_write_header,
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
-    .deinit            = ogg_free,
+    .close             = ogg_close,
     .flags             = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
     .priv_class        = &spx_muxer_class,
 };
@@ -860,7 +860,7 @@  AVOutputFormat ff_opus_muxer = {
     .write_header      = ogg_write_header,
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
-    .deinit            = ogg_free,
+    .close             = ogg_close,
     .flags             = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
     .priv_class        = &opus_muxer_class,
 };
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 81d3f1d940..07786de824 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -629,7 +629,7 @@  static int select_reference_stream(AVFormatContext *s)
     return 0;
 }
 
-static void seg_free(AVFormatContext *s)
+static void seg_close(AVFormatContext *s)
 {
     SegmentContext *seg = s->priv_data;
     ff_format_io_close(seg->avf, &seg->list_pb);
@@ -1074,7 +1074,7 @@  AVOutputFormat ff_segment_muxer = {
     .write_header   = seg_write_header,
     .write_packet   = seg_write_packet,
     .write_trailer  = seg_write_trailer,
-    .deinit         = seg_free,
+    .close          = seg_close,
     .check_bitstream = seg_check_bitstream,
     .priv_class     = &seg_class,
 };
@@ -1095,7 +1095,7 @@  AVOutputFormat ff_stream_segment_muxer = {
     .write_header   = seg_write_header,
     .write_packet   = seg_write_packet,
     .write_trailer  = seg_write_trailer,
-    .deinit         = seg_free,
+    .close          = seg_close,
     .check_bitstream = seg_check_bitstream,
     .priv_class     = &sseg_class,
 };