From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C5E664706F for ; Mon, 25 Sep 2023 23:53:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 414D468C9EA; Tue, 26 Sep 2023 02:53:38 +0300 (EEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2038.outbound.protection.outlook.com [40.92.50.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9816F68C734 for ; Tue, 26 Sep 2023 02:53:31 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aKW7QR8pktnKghFas8HqZaZT+Dd4eGPir5WWJQERMBa/PS8QADyVD4rSeUF0fg1vG27mRbjtCHpIB3fc5N+c1EAy6Abi99kRQ6UyDXNH19MkmBokaxpFlVW0vGOepXQIpy/omdwCJfmciooUCt2AnJ2MGYITcCUlbq01bhzzZl/Gw7JvLcnwRpUBaP/W8amlaOqslhT1qri0oJGjGDLYH5vSmwBwOOhMlEq++ECQaYEHdfBK/FLcU44f6glOg5hOW2iEAEQPlqa9s5Wno/5KVtxYHyMM1AtzPGpqBfHsA4ZWyRAvamTiEpFnVEsT1ow4LF73l6uwCdI3xRbplzx7CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gLWuVZjO5ZRWEyQ16L9WnPEzXeSsPC7QVPwfNG/ZTfg=; b=QDzZQKywPq35gU21qT8iJ8zvRNkUpsL0lTb/sQrVN2EPocFEmx5WCWAmlUf4Y3eK1fU5DpTURHVueQ+6X18czedAIKOHYU0PzhnjdzpXUl/a71vyEko7OGKBN4SO8dCeFNj7KYn8Q7ksUgo1CBpcymEqL6mbl+TW4IsavRN94kfsJj5Vzk4FXIZ9oMkiDGJt52NJEiUIJ6D/Auqc47of+wpslAI7nHd0JLHf1oPbgpD4kgHle/rWXeS5LCIVUJJxtCQuVntXllD5p3pXnd3nFmfgTIFmWIAJ0Y5+/+oeUE8inn57GIfHMyUgkOiz+9uWebd1fRGz/eGKRO37AcMTXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gLWuVZjO5ZRWEyQ16L9WnPEzXeSsPC7QVPwfNG/ZTfg=; b=WW/u+0BJctLlyuvkxQC02vYddK/+ueUEQ7VKX4wSogVT48qm/9CEgi9owjITk4sZsBB7a3TWN4o3THqnb35hDZQO2x2O4BFBQ25AfhEydCgmrQX0B9XO32cFYyl9P24KC2koB3YzUbKKTBw1fSlQtTcOU0ZF+BqIlBNV6NxgU5daqHkEb6t8uKvyUCd6ppTH3HIWgP5l2jBLx3tGZqm8NX71K9Z9gqaRJRykNKGyoh4hA/NY5McxIj0n7W6kR9n8N+DfqO6dVd7z0NQcRHodIxh18u6TSFeCwMecGJQJ0KfhLUvq1fpdyRALRsi1XufZxOP94FzVoqSZs+R4Ysr+Eg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0146.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:273::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Mon, 25 Sep 2023 23:53:29 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6792.026; Mon, 25 Sep 2023 23:53:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Sep 2023 01:54:30 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [qNwfRiw+S0n+24vib3jxIJJU4FQeVRb+] X-ClientProxiedBy: ZR2P278CA0018.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:46::16) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20230925235432.2668309-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0146:EE_ X-MS-Office365-Filtering-Correlation-Id: eb8f815d-9b86-4ab6-7492-08dbbe229bb0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lKnd00SndXXqtCNPeDTvLTK0M3z6UgyXldOP7n5rECy3i8pnA02iMaujMn7hUQDc82p0jFSw84hl7gLFhRSiD7eGybdzsNa/TzewruxDgB6n3ztxErOfEm7nAvC0Q0ezkVJSVJPK9wR8zffag0nwXWQV8PvzmwNW7TsGqvcgMRbEXSHamTgrQPC2Vrp0EL8FRYEqN70XiPvURohWV4C8WPG3v6XObKv0SaOMA8qpruayxRHIDZT1IKWiqwH171uVfHDPujDH5IHF0jU78SWjGmMGY00cjA8XII59VNOHp2dAAbRypHdrjCJdFfMGs/IK8wka/24gVFzmGKsWSfp2IykcAsNCSrkX3bJNPFzVu3II4J+AwL5THDs3wsGPl0vHt8IPNbHkT3ykjmVlZMc3D6uik9ryEIy334dVD2mH7EkQ72NkfgZh0aqNFwFOEmX0KSOzAYZfYBWg217+klU5xmaQDpJDHR5aoyQa26QHDQm27GnXYZCMRAKk9a9KT163KYNlG+tayKr6sv3BMteiap2gnOAyHbT3D15GVuZvI9YdtbrtkkFxregrvuIhMqz7tHpHHOmq/h1xRkdu7MTqUhRlr+57Mzjqsn8Xn+XFvaE5HTItrfh3NwOdEkEH697+ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HH5r4fd278w4L6Jd2WUhpLIUWA6fGAX4vO9ALsSIqEn0oFUURvph4e402++P?= =?us-ascii?Q?PObl3LzlH5odU8AjClaJZEi4t4MI7fkjPTGzeqL94iCkSHnRldIpNXxpJ1BB?= =?us-ascii?Q?bBRuHaqsjOUaryyhKlyJgBbu6jZVr+9rlhdSDxOVyMWID8k/WLTG0x6DgfVs?= =?us-ascii?Q?4rnGpPRUxuVy+HHfszrCGzWgw+/OB/P+An+/TcK2SfxTDmzWDqXqzp/GxcU9?= =?us-ascii?Q?d+IvZXrLUaVy1UBvkmXgUT5+/ycqV6PtZULLFB69LOxmuaDOMPUr4GUh7G+S?= =?us-ascii?Q?ozWiyRCTt63uPFHOMxa/8ObrtykfwCkZ4RtFQl1IGnMhxBkN14YiUHb/8xct?= =?us-ascii?Q?OcGzWNazW1nPol/4sKS+ih6oIaJ+pLkN+IaQ9DSswAO9zvX+W3eWU/0jmP8S?= =?us-ascii?Q?QMS54UUdbwtdjQCrnFZ68PVV8LW+QPmHY8yU6+3wTkJFE46ykyIOYNmxc0JT?= =?us-ascii?Q?FnVQb3FZnxITKv/laJewKpBLcfaGN+0khxH1M5No2XV5lMy7Kw9ahJjaVJq9?= =?us-ascii?Q?jn4XpHCuoClcld/zlNRfoQRajMsYIKoK2/z9eT+Tza23oz2zCHh/ItVrt+rg?= =?us-ascii?Q?3NyL8Eb4/PnuKiFhbIZQISXxWiW8THVDmqtqs16d0HVWJ8jzZHZzfQpvozZ/?= =?us-ascii?Q?9Ih2RPA1A2X+c8F7t2E4l/akgNjN4hKrhXEtVgnRg7YiI4vuWI6q7XJXy98B?= =?us-ascii?Q?5Ge6/YqjpHJgGaO0bUZmrdjQIAiuOaObdqOQXob45eBm3jbI8DQrsxDCWT98?= =?us-ascii?Q?uRadAyuOqSUzoU4IsLAu24sYUnISAG89O1oWKIwvKA5+2YH2TFHzXyb5U0hX?= =?us-ascii?Q?q0DxO/L9QDlYk5hriXEIiLTUDyvZ6m9G8huCCBgKZUqMfFcz8wMKUNKXKlva?= =?us-ascii?Q?LDhVjrdBx//fIS1s29FVXIE88ZwDULxN2PJ3uiu8wnZnLSR9o/HQdcSdb1Vc?= =?us-ascii?Q?F4pzQ6H/EvHF0eu3OdySEt+4WrOYIEgjIWwf3QN3pZ+/w2ePi4t6OWVDMseq?= =?us-ascii?Q?ehm5au7LVxNFBk0hYPyx7V6ZpoRYwcmx8s4/n6nkqwgz/yQ9frQbl5twwBlR?= =?us-ascii?Q?+ggcJrXhmRqqQ5oun2Y8H2cTpC6/w+y8Ta31CeygVgJ61EOpdfrK/vfLxyOv?= =?us-ascii?Q?b621Q+tRGPgS+8asdMuUgQAqXE8qPmhVJZAgRvyepRc8eXIBpKGEMNVH7Lrc?= =?us-ascii?Q?O/L07xD1AlieclSuElMU81gig1b6dq0fM+z7q+XZvVlNHk0fmA1Gph5i4tfa?= =?us-ascii?Q?9hBxAOSQjOltVyuAg5kv?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb8f815d-9b86-4ab6-7492-08dbbe229bb0 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2023 23:53:29.1457 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2P250MB0146 Subject: [FFmpeg-devel] [PATCH v2 1/3] avformat/avformat: Deprecate AVFMT_ALLOW_FLUSH X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: James Almer , Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 4 ++++ libavdevice/pulse_audio_enc.c | 5 ++++ libavformat/avformat.h | 6 +++-- libavformat/fifo.c | 5 ++++ libavformat/fifo_test.c | 5 ++++ libavformat/hlsenc.c | 5 ++++ libavformat/matroskaenc.c | 15 ++++++++++++ libavformat/movenc.c | 45 +++++++++++++++++++++++++++++++++++ libavformat/mpegtsenc.c | 5 ++++ libavformat/mux.c | 6 +++++ libavformat/mux.h | 6 +++-- libavformat/oggenc.c | 25 +++++++++++++++++++ libavformat/tee.c | 5 ++++ libavformat/version_major.h | 1 + 14 files changed, 134 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f333ff5b24..ca7ffbb97e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-09-26 - xxxxxxxxxx - lavf 60.xx.100 - avformat.h + Deprecate AVFMT_ALLOW_FLUSH without replacement. Users can always + flush any muxer by sending a NULL packet. + 2023-09-19 - xxxxxxxxxx - lavu 58.25.100 - avutil.h Make AV_TIME_BASE_Q compatible with C++. diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index 9e594c6424..5acbf798ef 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -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, }; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 43175ba332..a8e245000f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -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; diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 9a3a23729c..8fb4975a5c 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -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, }; diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c index 0f12d88b0f..3861c4aee4 100644 --- a/libavformat/fifo_test.c +++ b/libavformat/fifo_test.c @@ -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, }; diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 08f3746ce7..999fc0de75 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -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, diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index ba54f5f98e..c1a4425eb7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -3512,7 +3512,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 @@ -3521,6 +3525,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 @@ -3551,8 +3556,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 @@ -3572,11 +3582,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 diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7e96e7435f..a394ff8ddf 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -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 diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 46ed16985f..84edd418f0 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -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, }; diff --git a/libavformat/mux.c b/libavformat/mux.c index d3779202f0..5a1d6e41cb 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -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) diff --git a/libavformat/mux.h b/libavformat/mux.h index 9de5c2852a..b9ec75641d 100644 --- a/libavformat/mux.h +++ b/libavformat/mux.h @@ -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 diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index c669aea25a..69a66f586d 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -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 diff --git a/libavformat/tee.c b/libavformat/tee.c index cb555f52fd..cfa8346bc9 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -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, }; diff --git a/libavformat/version_major.h b/libavformat/version_major.h index d1d6f95b15..ca9dccc94d 100644 --- a/libavformat/version_major.h +++ b/libavformat/version_major.h @@ -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 -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".