avformat/avformat: Deprecate AVFMT_ALLOW_FLUSH

It is of no value to the user, because every muxer can always
be flushed with a NULL packet. As its documentation shows
("If not set, the muxer will not receive a NULL packet in
the write_packet function") it is actually an internal flag
that has been publically exposed because there was no internal
flags field for output formats for a long time. But now there is
and so use it by replacing the public flag with a private one.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-26 00:40:29 +02:00
parent 0d596776c6
commit dd48e49d54
15 changed files with 135 additions and 5 deletions

View File

@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
2023-10-03 - xxxxxxxxxx - lavf 60.14.100 - avformat.h
Deprecate AVFMT_ALLOW_FLUSH without replacement. Users can always
flush any muxer by sending a NULL packet.
2023-09-28 - xxxxxxxxxx - lavu 58.27.100 - pixfmt.h
Add AV_PIX_FMT_GBRAP14BE, AV_PIX_FMT_GBRAP14LE pixel formats.

View File

@ -802,6 +802,11 @@ const FFOutputFormat ff_pulse_muxer = {
.get_output_timestamp = pulse_get_output_timestamp,
.get_device_list = pulse_get_device_list,
.control_message = pulse_control_message,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_NOFILE,
#endif
.p.priv_class = &pulse_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};

View File

@ -486,7 +486,9 @@ typedef struct AVProbeData {
#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */
#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */
#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */
#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
#if FF_API_ALLOW_FLUSH
#define AVFMT_ALLOW_FLUSH 0x10000 /**< @deprecated: Just send a NULL packet if you want to flush a muxer. */
#endif
#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly
increasing timestamps, but they must
still be monotonic */
@ -522,7 +524,7 @@ typedef struct AVOutputFormat {
/**
* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
* AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
* AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
* AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS,
* AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
*/
int flags;

View File

@ -715,11 +715,16 @@ const FFOutputFormat ff_fifo_muxer = {
.p.name = "fifo",
.p.long_name = NULL_IF_CONFIG_SMALL("FIFO queue pseudo-muxer"),
.p.priv_class = &fifo_muxer_class,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_NOFILE | AVFMT_TS_NEGATIVE,
#endif
.priv_data_size = sizeof(FifoContext),
.init = fifo_init,
.write_header = fifo_write_header,
.write_packet = fifo_write_packet,
.write_trailer = fifo_write_trailer,
.deinit = fifo_deinit,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};

View File

@ -147,6 +147,11 @@ const FFOutputFormat ff_fifo_test_muxer = {
.write_trailer = failing_write_trailer,
.deinit = failing_deinit,
.p.priv_class = &failing_muxer_class,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_NOFILE,
#endif
.flags_internal = FF_FMT_ALLOW_FLUSH,
};

View File

@ -3184,8 +3184,13 @@ const FFOutputFormat ff_hls_muxer = {
.p.audio_codec = AV_CODEC_ID_AAC,
.p.video_codec = AV_CODEC_ID_H264,
.p.subtitle_codec = AV_CODEC_ID_WEBVTT,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_NODIMENSIONS,
#else
.p.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NODIMENSIONS,
#endif
.p.priv_class = &hls_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
.priv_data_size = sizeof(HLSContext),
.init = hls_init,
.write_header = hls_write_header,

View File

@ -3539,7 +3539,11 @@ const FFOutputFormat ff_matroska_muxer = {
.write_packet = mkv_write_flush_packet,
.write_trailer = mkv_write_trailer,
.p.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
#if FF_API_ALLOW_FLUSH
AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
#else
AVFMT_TS_NONSTRICT,
#endif
.p.codec_tag = (const AVCodecTag* const []){
ff_codec_bmp_tags, ff_codec_wav_tags,
additional_audio_tags, additional_subtitle_tags, 0
@ -3548,6 +3552,7 @@ const FFOutputFormat ff_matroska_muxer = {
.query_codec = mkv_query_codec,
.check_bitstream = mkv_check_bitstream,
.p.priv_class = &matroska_webm_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -3578,8 +3583,13 @@ const FFOutputFormat ff_webm_muxer = {
.query_codec = webm_query_codec,
.check_bitstream = mkv_check_bitstream,
.p.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
#if FF_API_ALLOW_FLUSH
AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
#else
AVFMT_TS_NONSTRICT,
#endif
.p.priv_class = &matroska_webm_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -3599,11 +3609,16 @@ const FFOutputFormat ff_matroska_audio_muxer = {
.write_packet = mkv_write_flush_packet,
.write_trailer = mkv_write_trailer,
.check_bitstream = mkv_check_bitstream,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT |
AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT,
#endif
.p.codec_tag = (const AVCodecTag* const []){
ff_codec_wav_tags, additional_audio_tags, 0
},
.p.priv_class = &matroska_webm_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif

View File

@ -7932,12 +7932,17 @@ const FFOutputFormat ff_mov_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = (const AVCodecTag* const []){
ff_codec_movvideo_tags, ff_codec_movaudio_tags, ff_codec_movsubtitle_tags, 0
},
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_TGP_MUXER
@ -7953,10 +7958,15 @@ const FFOutputFormat ff_tgp_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = codec_3gp_tags_list,
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_MP4_MUXER
@ -7974,10 +7984,15 @@ const FFOutputFormat ff_mp4_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = mp4_codec_tags_list,
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_PSP_MUXER
@ -7994,10 +8009,15 @@ const FFOutputFormat ff_psp_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = mp4_codec_tags_list,
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_TG2_MUXER
@ -8013,10 +8033,15 @@ const FFOutputFormat ff_tg2_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = codec_3gp_tags_list,
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_IPOD_MUXER
@ -8033,10 +8058,15 @@ const FFOutputFormat ff_ipod_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 },
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_ISMV_MUXER
@ -8053,11 +8083,16 @@ const FFOutputFormat ff_ismv_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
#endif
.p.codec_tag = (const AVCodecTag* const []){
codec_mp4_tags, codec_ism_tags, 0 },
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_F4V_MUXER
@ -8074,10 +8109,15 @@ const FFOutputFormat ff_f4v_muxer = {
.write_packet = mov_write_packet,
.write_trailer = mov_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_GLOBALHEADER,
#endif
.p.codec_tag = (const AVCodecTag* const []){ codec_f4v_tags, 0 },
.check_bitstream = mov_check_bitstream,
.p.priv_class = &mov_isobmff_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
#if CONFIG_AVIF_MUXER
@ -8093,8 +8133,13 @@ const FFOutputFormat ff_avif_muxer = {
.write_packet = mov_write_packet,
.write_trailer = avif_write_trailer,
.deinit = mov_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_GLOBALHEADER,
#endif
.p.codec_tag = codec_avif_tags_list,
.p.priv_class = &mov_avif_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif

View File

@ -2361,6 +2361,11 @@ const FFOutputFormat ff_mpegts_muxer = {
.write_trailer = mpegts_write_end,
.deinit = mpegts_deinit,
.check_bitstream = mpegts_check_bitstream,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS,
#else
.p.flags = AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS,
#endif
.flags_internal = FF_FMT_ALLOW_FLUSH,
.p.priv_class = &mpegts_muxer_class,
};

View File

@ -1206,7 +1206,13 @@ int av_write_frame(AVFormatContext *s, AVPacket *in)
int ret;
if (!in) {
#if FF_API_ALLOW_FLUSH || LIBAVFORMAT_VERSION_MAJOR >= 61
// Hint: The pulse audio output device has this set,
// so we can't switch the check to FF_FMT_ALLOW_FLUSH immediately.
if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
#else
if (ffofmt(s->oformat)->flags_internal & FF_FMT_ALLOW_FLUSH) {
#endif
ret = ffofmt(s->oformat)->write_packet(s, NULL);
flush_if_needed(s);
if (ret >= 0 && s->pb && s->pb->error < 0)

View File

@ -27,6 +27,8 @@
struct AVDeviceInfoList;
#define FF_FMT_ALLOW_FLUSH (1 << 1)
typedef struct FFOutputFormat {
/**
* The public AVOutputFormat. See avformat.h for it.
@ -38,13 +40,13 @@ typedef struct FFOutputFormat {
int priv_data_size;
/**
* Internal flags. See FF_FMT_FLAG_* in internal.h.
* Internal flags. See FF_FMT_* in internal.h and mux.h.
*/
int flags_internal;
int (*write_header)(AVFormatContext *);
/**
* Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
* Write a packet. If FF_FMT_ALLOW_FLUSH is set in flags_internal,
* pkt can be NULL in order to flush data buffered in the muxer.
* When flushing, return 0 if there still is more data to flush,
* or 1 if everything was flushed and there is no more buffered

View File

@ -771,8 +771,13 @@ const FFOutputFormat ff_ogg_muxer = {
.write_packet = ogg_write_packet,
.write_trailer = ogg_write_trailer,
.deinit = ogg_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT,
#endif
.p.priv_class = &ogg_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -789,8 +794,13 @@ const FFOutputFormat ff_oga_muxer = {
.write_packet = ogg_write_packet,
.write_trailer = ogg_write_trailer,
.deinit = ogg_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_TS_NEGATIVE,
#endif
.p.priv_class = &ogg_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -810,8 +820,13 @@ const FFOutputFormat ff_ogv_muxer = {
.write_packet = ogg_write_packet,
.write_trailer = ogg_write_trailer,
.deinit = ogg_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT,
#endif
.p.priv_class = &ogg_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -828,8 +843,13 @@ const FFOutputFormat ff_spx_muxer = {
.write_packet = ogg_write_packet,
.write_trailer = ogg_write_trailer,
.deinit = ogg_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_TS_NEGATIVE,
#endif
.p.priv_class = &ogg_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif
@ -846,7 +866,12 @@ const FFOutputFormat ff_opus_muxer = {
.write_packet = ogg_write_packet,
.write_trailer = ogg_write_trailer,
.deinit = ogg_free,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
#else
.p.flags = AVFMT_TS_NEGATIVE,
#endif
.p.priv_class = &ogg_muxer_class,
.flags_internal = FF_FMT_ALLOW_FLUSH,
};
#endif

View File

@ -614,5 +614,10 @@ const FFOutputFormat ff_tee_muxer = {
.write_trailer = tee_write_trailer,
.write_packet = tee_write_packet,
.p.priv_class = &tee_muxer_class,
#if FF_API_ALLOW_FLUSH
.p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
#else
.p.flags = AVFMT_NOFILE | AVFMT_TS_NEGATIVE,
#endif
.flags_internal = FF_FMT_ALLOW_FLUSH,
};

View File

@ -31,7 +31,7 @@
#include "version_major.h"
#define LIBAVFORMAT_VERSION_MINOR 13
#define LIBAVFORMAT_VERSION_MINOR 14
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \

View File

@ -47,6 +47,7 @@
#define FF_API_AVFORMAT_IO_CLOSE (LIBAVFORMAT_VERSION_MAJOR < 61)
#define FF_API_AVIO_WRITE_NONCONST (LIBAVFORMAT_VERSION_MAJOR < 61)
#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 61)
#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 61)
#define FF_API_R_FRAME_RATE 1