[FFmpeg-devel,3/3] avformat: deprecate AVFMT_FLAG_AUTO_BSF

Submitted by James Almer on Nov. 26, 2017, 8:51 p.m.

Details

Message ID 20171126205104.1064-3-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Nov. 26, 2017, 8:51 p.m.
The bitstream filters inserted by this option should not be optional.
They are needed to succesfully mux files in some cases, and to prevent
muxing broken files in others.

This is more in line with AVCodec.bsfs()

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/avformat.h      | 4 +++-
 libavformat/mux.c           | 3 ---
 libavformat/options_table.h | 6 ++++--
 libavformat/version.h       | 3 +++
 4 files changed, 10 insertions(+), 6 deletions(-)

Comments

Clément Bœsch Nov. 26, 2017, 9:16 p.m.
On Sun, Nov 26, 2017 at 05:51:04PM -0300, James Almer wrote:
> The bitstream filters inserted by this option should not be optional.

Will ffmpeg error out if it's built without the required bsf? (or is there
a hard dep in the configure?)
James Almer Nov. 26, 2017, 9:54 p.m.
On 11/26/2017 6:16 PM, Clément Bœsch wrote:
> On Sun, Nov 26, 2017 at 05:51:04PM -0300, James Almer wrote:
>> The bitstream filters inserted by this option should not be optional.
> 
> Will ffmpeg error out if it's built without the required bsf? (or is there
> a hard dep in the configure?)

Mmh, no, as is it will silently keep going.

I'll resend the patch making the muxers select the required bsfs.
Although admittedly there is no way to guarantee they will be available
even with that, since they are in a different library and you could
always dynamically load a different lavc.

Maybe we could emit a warning at runtime if the bsfs is required but not
compiled in?
James Almer Dec. 6, 2017, 7:56 p.m.
On 11/26/2017 5:51 PM, James Almer wrote:
> The bitstream filters inserted by this option should not be optional.
> They are needed to succesfully mux files in some cases, and to prevent
> muxing broken files in others.
> 
> This is more in line with AVCodec.bsfs()
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/avformat.h      | 4 +++-
>  libavformat/mux.c           | 3 ---
>  libavformat/options_table.h | 6 ++++--
>  libavformat/version.h       | 3 +++
>  4 files changed, 10 insertions(+), 6 deletions(-)

Now that VP9 streams can't be wrongly muxed anymore after commit
0c162854c1, this change is not strictly necessary. And since there's no
real way to enforce or guarantee the presence of specific bsfs in
libavcodec as required by libavformat at runtime, maybe it's best to
leave it as an optional feature.
So patch dropped unless people speak in favor of this change.

Patch hide | download patch | download mbox

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4f2798a871..e39e5e4ada 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1449,7 +1449,9 @@  typedef struct AVFormatContext {
 #endif
 #define AVFMT_FLAG_FAST_SEEK   0x80000 ///< Enable fast, but inaccurate seeks for some formats
 #define AVFMT_FLAG_SHORTEST   0x100000 ///< Stop muxing when the shortest stream stops.
-#define AVFMT_FLAG_AUTO_BSF   0x200000 ///< Add bitstream filters as requested by the muxer
+#if FF_API_LAVF_AUTO_BSF_FLAG
+#define AVFMT_FLAG_AUTO_BSF   0x200000 ///< Deprecated, does nothing.
+#endif
 
     /**
      * Maximum size of the data read from input for determining
diff --git a/libavformat/mux.c b/libavformat/mux.c
index ebb9102f11..382c20fc63 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -825,9 +825,6 @@  static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
     AVStream *st = s->streams[pkt->stream_index];
     int i, ret;
 
-    if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
-        return 1;
-
     if (s->oformat->check_bitstream) {
         if (!st->internal->bitstream_checked) {
             if ((ret = s->oformat->check_bitstream(s, pkt)) < 0)
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index b8fa47c6fd..8b1e6f3d18 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -39,7 +39,7 @@  static const AVOption avformat_options[] = {
 {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT64, {.i64 = 5000000 }, 32, INT64_MAX, D},
 {"formatprobesize", "number of bytes to probe file format", OFFSET(format_probesize), AV_OPT_TYPE_INT, {.i64 = PROBE_BUF_MAX}, 0, INT_MAX-1, D},
 {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, E},
-{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVFMT_FLAG_AUTO_BSF }, INT_MIN, INT_MAX, D|E, "fflags"},
+{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, INT_MIN, INT_MAX, D|E, "fflags"},
 {"flush_packets", "reduce the latency by flushing out packets immediately", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, E, "fflags"},
 {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"},
 {"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"},
@@ -57,7 +57,9 @@  static const AVOption avformat_options[] = {
 {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D},
 {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
 {"shortest", "stop muxing with the shortest stream", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_SHORTEST }, 0, 0, E, "fflags" },
-{"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
+#if FF_API_LAVF_AUTO_BSF_FLAG
+{"autobsf", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_AUTO_BSF }, 0, 0, E, "fflags" },
+#endif
 {"analyzeduration", "specify how many microseconds are analyzed to probe the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/version.h b/libavformat/version.h
index feb1461c41..d2427dd875 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -82,6 +82,9 @@ 
 #ifndef FF_API_OLD_AVIO_EOF_0
 #define FF_API_OLD_AVIO_EOF_0           (LIBAVFORMAT_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_LAVF_AUTO_BSF_FLAG
+#define FF_API_LAVF_AUTO_BSF_FLAG       (LIBAVFORMAT_VERSION_MAJOR < 59)
+#endif
 
 
 #ifndef FF_API_R_FRAME_RATE