diff mbox series

[FFmpeg-devel,6/6] avformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bump

Message ID 20210226171808.2297158-1-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/5] fftools/ffmpeg_filter: Don't use deprecated function | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 26, 2021, 5:18 p.m. UTC
This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5
in conjunction with av_demuxer_open() to allow to pass private
options to demuxers. It worked as follows: av_open_input_stream()
(the predecessor of avformat_open_input()) would not call the
read_header function if this flag is set. Instead the user could set
private options of the demuxer via the format's private class after
avformat_open_input() and then call av_demuxer_open() which called
the format's read_header function.

This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a
and av_demuxer_open() deprecated; instead the AVDictionary based way of
passing private options to the demuxer was choosen. Yet
AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open()
never removed. This commit implements the deprecation of the flag and
schedules av_demuxer_open for removal on the next major bump.
Given that av_demuxer_open() has been deprecated in 2012 and that this
flag is useless without it, the flag will be ignored after the next
major version bump.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 doc/APIchanges         |  4 ++++
 libavformat/avformat.h |  9 ++++++++-
 libavformat/utils.c    | 12 ++++++++++--
 libavformat/version.h  |  8 +++++++-
 4 files changed, 29 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt March 2, 2021, 7:35 a.m. UTC | #1
Andreas Rheinhardt:
> This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5
> in conjunction with av_demuxer_open() to allow to pass private
> options to demuxers. It worked as follows: av_open_input_stream()
> (the predecessor of avformat_open_input()) would not call the
> read_header function if this flag is set. Instead the user could set
> private options of the demuxer via the format's private class after
> avformat_open_input() and then call av_demuxer_open() which called
> the format's read_header function.
> 
> This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a
> and av_demuxer_open() deprecated; instead the AVDictionary based way of
> passing private options to the demuxer was choosen. Yet
> AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open()
> never removed. This commit implements the deprecation of the flag and
> schedules av_demuxer_open for removal on the next major bump.
> Given that av_demuxer_open() has been deprecated in 2012 and that this
> flag is useless without it, the flag will be ignored after the next
> major version bump.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  doc/APIchanges         |  4 ++++
>  libavformat/avformat.h |  9 ++++++++-
>  libavformat/utils.c    | 12 ++++++++++--
>  libavformat/version.h  |  8 +++++++-
>  4 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 33be750af2..baa2b24daf 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,10 @@ libavutil:     2017-10-21
>  
>  API changes, most recent first:
>  
> +2021-02-26 - xxxxxxxxxx - lavf 58.69.100 - avformat.h
> +  Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
> +  as soon as av_demuxer_open() is removed.
> +
>  2021-02-21 - xxxxxxxxxx - lavu 56.66.100 - tx.h
>    Add enum AVTXFlags and AVTXFlags.AV_TX_INPLACE
>  
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 41482328f6..7da2f3d98e 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1379,7 +1379,9 @@ typedef struct AVFormatContext {
>  #define AVFMT_FLAG_MP4A_LATM    0x8000 ///< Deprecated, does nothing.
>  #endif
>  #define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
> -#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
> +#if FF_API_LAVF_PRIV_OPT
> +#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (deprecated, will do nothing once av_demuxer_open() is removed)
> +#endif
>  #if FF_API_LAVF_KEEPSIDE_FLAG
>  #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing.
>  #endif
> @@ -2210,8 +2212,13 @@ int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
>   */
>  int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options);
>  
> +#if FF_API_DEMUXER_OPEN
> +/**
> + * @deprecated Use an AVDictionary to pass options to a demuxer.
> + */
>  attribute_deprecated
>  int av_demuxer_open(AVFormatContext *ic);
> +#endif
>  
>  /**
>   * Read packets of a media file to get stream information. This
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 6e92bd777a..36164e0f0d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -392,6 +392,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  /************************************************************/
>  /* input media file */
>  
> +#if FF_API_DEMUXER_OPEN
>  int av_demuxer_open(AVFormatContext *ic) {
>      int err;
>  
> @@ -411,7 +412,7 @@ int av_demuxer_open(AVFormatContext *ic) {
>  
>      return 0;
>  }
> -
> +#endif
>  /* Open input file and probe the format if necessary. */
>  static int init_input(AVFormatContext *s, const char *filename,
>                        AVDictionary **options)
> @@ -594,8 +595,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      if (s->pb)
>          ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
>  
> -
> +#if FF_API_DEMUXER_OPEN
>      if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
> +#else
> +    if (s->iformat->read_header)
> +#endif
>          if ((ret = s->iformat->read_header(s)) < 0)
>              goto fail;
>  
> @@ -624,7 +628,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      if ((ret = avformat_queue_attached_pictures(s)) < 0)
>          goto close;
>  
> +#if FF_API_DEMUXER_OPEN
>      if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
> +#else
> +    if (s->pb && !s->internal->data_offset)
> +#endif
>          s->internal->data_offset = avio_tell(s->pb);
>  
>      s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
> diff --git a/libavformat/version.h b/libavformat/version.h
> index c11d885b83..7d16c4d6a5 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -32,7 +32,7 @@
>  // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
>  // Also please add any ticket numbers that you believe might be affected here
>  #define LIBAVFORMAT_VERSION_MAJOR  58
> -#define LIBAVFORMAT_VERSION_MINOR  68
> +#define LIBAVFORMAT_VERSION_MINOR  69
>  #define LIBAVFORMAT_VERSION_MICRO 100
>  
>  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
> @@ -106,6 +106,12 @@
>  #ifndef FF_API_AVIOFORMAT
>  #define FF_API_AVIOFORMAT               (LIBAVFORMAT_VERSION_MAJOR < 59)
>  #endif
> +#ifndef FF_API_DEMUXER_OPEN
> +#define FF_API_DEMUXER_OPEN             (LIBAVFORMAT_VERSION_MAJOR < 59)
> +#endif
> +#ifndef FF_API_LAVF_PRIV_OPT
> +#define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
> +#endif
>  
>  
>  #ifndef FF_API_R_FRAME_RATE
> 
Will apply this patch tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 33be750af2..baa2b24daf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@  libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2021-02-26 - xxxxxxxxxx - lavf 58.69.100 - avformat.h
+  Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
+  as soon as av_demuxer_open() is removed.
+
 2021-02-21 - xxxxxxxxxx - lavu 56.66.100 - tx.h
   Add enum AVTXFlags and AVTXFlags.AV_TX_INPLACE
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 41482328f6..7da2f3d98e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1379,7 +1379,9 @@  typedef struct AVFormatContext {
 #define AVFMT_FLAG_MP4A_LATM    0x8000 ///< Deprecated, does nothing.
 #endif
 #define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
-#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
+#if FF_API_LAVF_PRIV_OPT
+#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (deprecated, will do nothing once av_demuxer_open() is removed)
+#endif
 #if FF_API_LAVF_KEEPSIDE_FLAG
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing.
 #endif
@@ -2210,8 +2212,13 @@  int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
  */
 int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options);
 
+#if FF_API_DEMUXER_OPEN
+/**
+ * @deprecated Use an AVDictionary to pass options to a demuxer.
+ */
 attribute_deprecated
 int av_demuxer_open(AVFormatContext *ic);
+#endif
 
 /**
  * Read packets of a media file to get stream information. This
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6e92bd777a..36164e0f0d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -392,6 +392,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
 /************************************************************/
 /* input media file */
 
+#if FF_API_DEMUXER_OPEN
 int av_demuxer_open(AVFormatContext *ic) {
     int err;
 
@@ -411,7 +412,7 @@  int av_demuxer_open(AVFormatContext *ic) {
 
     return 0;
 }
-
+#endif
 /* Open input file and probe the format if necessary. */
 static int init_input(AVFormatContext *s, const char *filename,
                       AVDictionary **options)
@@ -594,8 +595,11 @@  FF_ENABLE_DEPRECATION_WARNINGS
     if (s->pb)
         ff_id3v2_read_dict(s->pb, &s->internal->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
 
-
+#if FF_API_DEMUXER_OPEN
     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
+#else
+    if (s->iformat->read_header)
+#endif
         if ((ret = s->iformat->read_header(s)) < 0)
             goto fail;
 
@@ -624,7 +628,11 @@  FF_ENABLE_DEPRECATION_WARNINGS
     if ((ret = avformat_queue_attached_pictures(s)) < 0)
         goto close;
 
+#if FF_API_DEMUXER_OPEN
     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
+#else
+    if (s->pb && !s->internal->data_offset)
+#endif
         s->internal->data_offset = avio_tell(s->pb);
 
     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
diff --git a/libavformat/version.h b/libavformat/version.h
index c11d885b83..7d16c4d6a5 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@ 
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  68
+#define LIBAVFORMAT_VERSION_MINOR  69
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -106,6 +106,12 @@ 
 #ifndef FF_API_AVIOFORMAT
 #define FF_API_AVIOFORMAT               (LIBAVFORMAT_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_DEMUXER_OPEN
+#define FF_API_DEMUXER_OPEN             (LIBAVFORMAT_VERSION_MAJOR < 59)
+#endif
+#ifndef FF_API_LAVF_PRIV_OPT
+#define FF_API_LAVF_PRIV_OPT            (LIBAVFORMAT_VERSION_MAJOR < 60)
+#endif
 
 
 #ifndef FF_API_R_FRAME_RATE