From patchwork Mon Mar 2 04:35:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17990 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 397EC447C8B for ; Mon, 2 Mar 2020 06:36:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D1B068AF81; Mon, 2 Mar 2020 06:36:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 540C86899BB for ; Mon, 2 Mar 2020 06:36:31 +0200 (EET) Received: by mail-wr1-f47.google.com with SMTP id j7so10677040wrp.13 for ; Sun, 01 Mar 2020 20:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w8htMq2PEFGZqhzmgFVIsg781XcCvMe33t4zvNdJ+Vk=; b=LSoW8OTdbn5a0g6fE3+6Dn72pQ/i342ebJrkSrtqSa5SVI1G8OqYeLawGjxh4rPOEU xsOEEGQadrBIL4cFCzbXVNZZ1OOQMXC9psMF6P3S9Zp1HeCltnQnK7QVbR60XwKFmQiF R5yBNQLsC5OhoQdGyN1NgHc3zLFs/cnUUvSD3MwpBV4+sIkVZ5A95Et15ifAKNNpST1f 9gRHlZ6HuZqslZeIOnAbSpwgJ3YVcwVW9VQRjCvhfl9kWZ87294M80FS/426FMZzwIle GZGU/T6eIhushMoVhHt/QWr05Vnzxa7Z3VfpTLzJ1W7pqof54viRHA+x8D7Mk21+0agZ RHhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w8htMq2PEFGZqhzmgFVIsg781XcCvMe33t4zvNdJ+Vk=; b=MbyOvw2wQeb8WKIFX2Z1Ehw5Fc5iNmfP47TCUUPNN3krcdv7VfCkjoxe9+leYOlpw1 NHjypirYihAN7u4bBC2aFJP0imADqWuc3e90zn8NyAeEIQv/O2YiYCbqapWoFJUpgsDz kn1Sd0EPg0ydczWjNxD4OOzJvmOr9jNvA9glEFpWTII+Ed9oOE7M3ZwbtZLjLuBi0C0/ Bor60fnF7Pl5tP97BUkmaRE4K9LAOaMOp2g9ZDj9XsgNzaNOrp0fl/jWN+y9W2ZHLj+i Mxfg76OHKJrVWm01f8qX8uKiQGM79ltdM5rXm5qghDDS16aEBmEukeNjFg38VeriZm9o oVpg== X-Gm-Message-State: APjAAAVFHlk0w5da3yBB7D38mvOFC0JOxH3Y10c0V4qfaKhy4rbKJFCU +gD/s81ubajFrMZYwBvGc0joN3Pd X-Google-Smtp-Source: APXvYqyVK/eNcHfs5NHkdnnLlBo4nMh8xsrSh9iU2pJHi7v7YMNRW7+ebG/PPNbaESrNDzLqMOoOtg== X-Received: by 2002:a5d:4902:: with SMTP id x2mr20860749wrq.301.1583123790267; Sun, 01 Mar 2020 20:36:30 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id g7sm20842429wrm.72.2020.03.01.20.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:36:29 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:35:19 +0100 Message-Id: <20200302043520.14165-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/17] avformat/avformat: Allow const AVOutputFormat where possible X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 9461e4bc made preparations to constify the various AVOutputFormat pointers because the underlying AVOutputFormats should not be changed. To do this, a preprocessor directive (ff_const59) is used that will add const to certain AVOutputFormat * after the next major version bump. This approach has the drawback that it does not allow users to write future-proof code now (if one needs to use av_guess_format(), e.g. because of the mime_type parameter). Yet this is possible: Currently both avformat_alloc_output_context2() and av_guess_codec() have a pointer to AVOutputFormat as function parameter. They can also accept a pointer to const AVOutputFormat without imparing ABI/API compability. Users can then already write future-proof code now by using const. This also makes it possible to already use const now in certain parts of our own code. For the time being, avformat_alloc_output_context2() will have to cast the const away internally until the next major version bump. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 4 ++++ libavformat/avformat.h | 4 ++-- libavformat/fifo.c | 4 ++-- libavformat/format.c | 4 ++-- libavformat/hlsenc.c | 4 ++-- libavformat/mux.c | 4 ++-- libavformat/segment.c | 2 +- libavformat/version.h | 4 ++-- libavformat/webm_chunk.c | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5bfb0a654e..a2d428e4ef 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-03-01 - xxxxxxxxxx - lavf 58.40.100 - avformat.h + avformat_alloc_output_context2() and av_guess_codec() now accept + pointer to const AVOutputFormat. + 2020-02-21 - xxxxxxxxxx - lavc 58.73.101 - avcodec.h Add AV_CODEC_EXPORT_DATA_PRFT. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9b9b634ec3..a260c02072 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2224,7 +2224,7 @@ AVProgram *av_new_program(AVFormatContext *s, int id); * @return >= 0 in case of success, a negative AVERROR code in case of * failure */ -int avformat_alloc_output_context2(AVFormatContext **ctx, ff_const59 AVOutputFormat *oformat, +int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat, const char *format_name, const char *filename); /** @@ -2707,7 +2707,7 @@ ff_const59 AVOutputFormat *av_guess_format(const char *short_name, /** * Guess the codec ID based upon muxer and filename. */ -enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, +enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type); diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 7b37fff6da..3989ca4119 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -441,7 +441,7 @@ static void *fifo_consumer_thread(void *data) return NULL; } -static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oformat, +static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat, const char *filename) { FifoContext *fifo = avf->priv_data; @@ -480,7 +480,7 @@ static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oforma static int fifo_init(AVFormatContext *avf) { FifoContext *fifo = avf->priv_data; - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; int ret = 0; if (fifo->recovery_wait_streamtime && !fifo->drop_pkts_on_overflow) { diff --git a/libavformat/format.c b/libavformat/format.c index c47490c8eb..a926d5be0c 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -84,12 +84,12 @@ ff_const59 AVOutputFormat *av_guess_format(const char *short_name, const char *f return fmt_found; } -enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, +enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type) { if (av_match_name("segment", fmt->name) || av_match_name("ssegment", fmt->name)) { - ff_const59 AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL); + const AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL); if (fmt2) fmt = fmt2; } diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e58da7328f..d685ec0179 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -113,8 +113,8 @@ typedef struct VariantStream { unsigned var_stream_idx; unsigned number; int64_t sequence; - ff_const59 AVOutputFormat *oformat; - ff_const59 AVOutputFormat *vtt_oformat; + const AVOutputFormat *oformat; + const AVOutputFormat *vtt_oformat; AVIOContext *out; int packets_written; int init_range_length; diff --git a/libavformat/mux.c b/libavformat/mux.c index 565a7d7c18..6a973186ff 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -145,7 +145,7 @@ enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st } -int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputFormat *oformat, +int avformat_alloc_output_context2(AVFormatContext **avctx, const AVOutputFormat *oformat, const char *format, const char *filename) { AVFormatContext *s = avformat_alloc_context(); @@ -174,7 +174,7 @@ int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputF } } - s->oformat = oformat; + s->oformat = (ff_const59 AVOutputFormat *)oformat; if (s->oformat->priv_data_size > 0) { s->priv_data = av_mallocz(s->oformat->priv_data_size); if (!s->priv_data) diff --git a/libavformat/segment.c b/libavformat/segment.c index bf9e706c1c..5f7fe76600 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -72,7 +72,7 @@ typedef struct SegmentContext { int segment_idx_wrap; ///< number after which the index wraps int segment_idx_wrap_nb; ///< number of time the index has wraped int segment_count; ///< number of segment files already written - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; AVFormatContext *avf; char *format; ///< format to use for output segment files AVDictionary *format_options; diff --git a/libavformat/version.h b/libavformat/version.h index 4724269b3c..a233b67351 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // 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 39 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 40 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 4e2ce21a79..bc3d346a00 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -53,7 +53,7 @@ typedef struct WebMChunkContext { char *http_method; uint64_t duration_written; int64_t prev_pts; - ff_const59 AVOutputFormat *oformat; + const AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext;