From patchwork Tue Apr 20 15:36:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27193 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp1582840iob; Tue, 20 Apr 2021 08:37:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEcU2utSR8r1rk55/P4oaVLDSJcXWDjbcTL1KkiJgdvXxd90j6h1wYQXzyh98xs94QY0qe X-Received: by 2002:a17:906:4347:: with SMTP id z7mr27941267ejm.246.1618933039307; Tue, 20 Apr 2021 08:37:19 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kg1si15270463ejc.507.2021.04.20.08.37.18; Tue, 20 Apr 2021 08:37:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=j5gn1hnE; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 964DD680CC5; Tue, 20 Apr 2021 18:37:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075067.outbound.protection.outlook.com [40.92.75.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4155E680135 for ; Tue, 20 Apr 2021 18:37:09 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uw2nDTi0YR59FhpwLrMu+/tJuvwpE/wGYKfNlgGJCToDuQbwBMbxVd92euDJkNf/kRFJB5dQpAZr3RvtQGpfgExo2eAHY+kX1L+BogJ2yB/KzD3enIO4SvHrNBHjzmuFXi4K+/zJ5tuy60hDsbKuqAbGhk/rhYc+iiTej6Kga6W5oRbcb30ZrRkj2qmU0MyebmVMtt1eRnUzwvEaWu7L5FrZPrsUOJJTXZr8YwoYHn9dwgk4vgPvYXCIcXL/eaYXhjp5YpVn5Wb7GHGQXTPSMc97wzLGO5Fz3Opx8/uAroBovv/691sM8jtr9sGEGHiZU8xtpDChjuxowR5RW0B+vg== 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-SenderADCheck; bh=ClYDfqi1uqso3IL4PdGIXOhQBqFUsqvpwRWE9+NnD+s=; b=Ay4WL/vtacH22b5dYSLgd78Q30xO7H2ccCB+Gr6930RWoXAY79Q70pzBASU67Gq+APBfyc0sdU3Laz3NkIIwbmyCSrT+Ap8K4IQ1VzHQwYLaTIyDBvV7SXmbEA2foJJd9QDcdb9EHyheW9Ays2v8R/UZceY9rD11LUNgynIrfWLV7PJua1R1LHSeAGOD83RSgiQB7MNzIr0cp4S4St4hKbw6hAm8xPTKO69PrWu7ANDqXxLbcAfp1g8m8awjjZR4EObBGDB2aEy3AgbjGI+m0BmBksbQI2zDju6zexbtq7E9WQZSYit4odlnzK8ZwVV3gCui/jSE+j26YZ3F+Dz7Rg== 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=ClYDfqi1uqso3IL4PdGIXOhQBqFUsqvpwRWE9+NnD+s=; b=j5gn1hnEH6H92QxAtmbBUaNI7YnnZRM7eqqe1JHrughRV3ybrFPC+iiYGIAf5mpP5cx5PsEOTxK8g8cziGi2saMcRlT4S1T8akS91pKs7DE6bBBeJxtW4k6+3+9V187zP5uuk5fdsPVvbgi6T0ytQiRvtRh7U/a0Suj3bE5RB9/LnvT09G7S+tLl0jXRXs+BYOeyEVwl1S5GUUR1P4AbxPvm+PiURUmNOfM55YsBAeihFZAbV9EJIDDFPHmSPXrQ82Dnnj65pf2iVsi/BHO3jyLDmIhvil2JvPLxr6kehop0/rD10zs8lxSu9PyAeKhc8Jh1JfmVoCP3mTciRb9gqg== Received: from DB3EUR04FT055.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::4b) by DB3EUR04HT094.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16; Tue, 20 Apr 2021 15:37:07 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0c::40) by DB3EUR04FT055.mail.protection.outlook.com (2a01:111:e400:7e0c::64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Tue, 20 Apr 2021 15:37:07 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2883611AD60D772D24D7FA79E28BBD340B52F18C16EED144C4A1AE7F8783B0ED; UpperCasedChecksum:E48AE688D53448D709DB12EF4A03AD80EBDE849042FBF518D0DC33C34F5AF9AD; SizeAsReceived:7522; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4042.024; Tue, 20 Apr 2021 15:37:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Apr 2021 17:36:56 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210419141024.8174-75-jamrial@gmail.com> References: <20210419141024.8174-75-jamrial@gmail.com> X-TMN: [YBxFsWJEQy/uho2SLgkt3ok0MN2yJ/iExWF1ldRgo+A=] X-ClientProxiedBy: ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210420153656.1784298-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.169.173) by ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.20 via Frontend Transport; Tue, 20 Apr 2021 15:37:06 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ed78f6ad-af11-4c50-9163-08d9041227ba X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UJTxaQ6qj3R7H4IZNMmUN14nmwk3xGfT6C8GWz0KO4zbaI/SH4HNMxVquNzqZ3ECFmJPD1UPyJRPATIFLArF3J3KCeA5E1d0eLzpPpBQDgaTw4bHSaH4KMMEj1AQf0gKocMkNzfKGXzLeOE++lIyYmZN/kogey/eRL1FLxclxFAGZSqpoklpBi+100G/Lz4jE1aeeZcG6R7w5VsPhtUqse3hGw1iGsMbFqL0xQC5tnHEZikfxbri6Mxp9CFyZkHgOW+ow9SlV6+UlcJMn9sGwb0VYT0GZaDV6of/wZPmKc4LKBbg4wB9B07xHXnt9JcwR0Bb7KdT2qPebM/TnrjJJ9i7S64vIM9sHNmhwNkhMpi9WIRbPT7qffaP5tmPAQIwAkrGj4ioFaEGTddJlHF+S+PpKhMazADuE4swexeuPDS3FDyXeJKh/oVCkGwymTub+1u+vbGf1zeHGZP53aRg8faa6E0Lb+q7zzL6sF353gZDS3VIwl4+jqJWjvqykIEslnceEcONXdPwUmAY7pXqCv/wwZ5/eb8Ablwjno1VTAd0k1k5k7lnJyxkNhA1E0zPJuEFSHH8ielljPxWeQ8P4hTq144+1BdsVqqGrebD2cZs+NgVTGg+Q3T9dnY+Nqba/cth+pey68kUy3McRbsMTEWMtvJXciJXN82Xq8mDjwEz/j/3hIqif2VzAJjGX3tmE+ixgYggzCt3Q== X-MS-TrafficTypeDiagnostic: DB3EUR04HT094: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /QMuE2Bk7Pjo4QqEdBxtMOVKnL0dMa8xDR0mWCC9BrCFrCBjpUz0bRkHTJN9QUcCzuSHhcMTgAxgBd17sn81RYrymOY2K3rzGmHfsL+FpzATTE0Ov2EX1fXvSfOR7QircVRdjLyoomGR3SECUa1jP7AW8u9vFza0tGjVw+lbPMnUm+CrkIUr38rD7IEd//gnmYPSYzSFB/t9XLNtK4DHc9Nro2WanzQFVCg7GoZGzpMv3jLEYXl++v6m4UbcQGj6gnzr7WY42XJl9TPL6eSEHFcvsQwsKsINcmn9OUqiFofooS/Xmi1yPDxFcMC4sab/nbj9dF0Tgz2REFgAo4WOI4+rAG+YalDtztnhznTnNl/kdV3BNRQz+2HP7QoL4aqIQ9wTeo0GiiBtT7xD1InfhA== X-MS-Exchange-AntiSpam-MessageData: awYnBNOaamjpVTKOTmEyGTZ47H9KkDbfjuKO3X6I7Y1WIw0rfKNCuKW7L+WZKTPbR7WUzkqRbSJasTyGKwTAb7rg9Ys4ZKPNP4FXtOY0dZAfJ63lU0PUNANSwxy7KPwOx+BcBhHar9OHox343k/F3g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed78f6ad-af11-4c50-9163-08d9041227ba X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2021 15:37:07.4225 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB3EUR04FT055.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT094 Subject: [FFmpeg-devel] [PATCH v2 74/90] avcodec/codec, allcodecs: Constify the AVCodec API 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eEWIn7Q6Wrnr Signed-off-by: Andreas Rheinhardt --- Now also updating doc/examples and tests/api as well as libavdevice/dshow.c. doc/APIchanges | 5 +++++ doc/examples/demuxing_decoding.c | 2 +- doc/examples/muxing.c | 10 ++++++---- doc/examples/transcode_aac.c | 4 ++-- doc/examples/transcoding.c | 4 ++-- doc/examples/vaapi_encode.c | 2 +- doc/examples/vaapi_transcode.c | 4 ++-- libavcodec/allcodecs.c | 18 +++++++++--------- libavcodec/codec.h | 8 ++++---- libavdevice/dshow.c | 2 +- tests/api/api-band-test.c | 2 +- tests/api/api-flac-test.c | 10 +++++----- tests/api/api-h264-test.c | 2 +- tests/api/api-seek-test.c | 2 +- tools/target_dec_fuzzer.c | 8 ++++---- 15 files changed, 45 insertions(+), 38 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2522978952..a823a4419c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -17,6 +17,11 @@ API changes, most recent first: 2021-04-17 - xxxxxxxxxx - lavu 56.73.100 - frame.h detection_bbox.h Add AV_FRAME_DATA_DETECTION_BBOXES +2021-04-14 - xxxxxxxxxx - lavc yyyyyyyyy - codec.h + avcodec_find_encoder_by_name(), avcodec_find_encoder(), + avcodec_find_decoder_by_name() and avcodec_find_decoder() + now return a pointer to const AVCodec. + 2021-04-14 - xxxxxxxxxx - lavf yyyyyyyyy - avformat.h Constified AVFormatContext.*_codec. diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c index db5e0cb951..55fdb2555c 100644 --- a/doc/examples/demuxing_decoding.c +++ b/doc/examples/demuxing_decoding.c @@ -149,7 +149,7 @@ static int open_codec_context(int *stream_idx, { int ret, stream_index; AVStream *st; - AVCodec *dec = NULL; + const AVCodec *dec = NULL; AVDictionary *opts = NULL; ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c index 014359e2ca..fe1b9ded21 100644 --- a/doc/examples/muxing.c +++ b/doc/examples/muxing.c @@ -121,7 +121,7 @@ static int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c, /* Add an output stream. */ static void add_stream(OutputStream *ost, AVFormatContext *oc, - AVCodec **codec, + const AVCodec **codec, enum AVCodecID codec_id) { AVCodecContext *c; @@ -242,7 +242,8 @@ static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt, return frame; } -static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) +static void open_audio(AVFormatContext *oc, const AVCodec *codec, + OutputStream *ost, AVDictionary *opt_arg) { AVCodecContext *c; int nb_samples; @@ -405,7 +406,8 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height) return picture; } -static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) +static void open_video(AVFormatContext *oc, const AVCodec *codec, + OutputStream *ost, AVDictionary *opt_arg) { int ret; AVCodecContext *c = ost->enc; @@ -539,7 +541,7 @@ int main(int argc, char **argv) const AVOutputFormat *fmt; const char *filename; AVFormatContext *oc; - AVCodec *audio_codec, *video_codec; + const AVCodec *audio_codec, *video_codec; int ret; int have_video = 0, have_audio = 0; int encode_video = 0, encode_audio = 0; diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index 73786ab59b..711076b5a5 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -60,7 +60,7 @@ static int open_input_file(const char *filename, AVCodecContext **input_codec_context) { AVCodecContext *avctx; - AVCodec *input_codec; + const AVCodec *input_codec; int error; /* Open the input file to read from it. */ @@ -144,7 +144,7 @@ static int open_output_file(const char *filename, AVCodecContext *avctx = NULL; AVIOContext *output_io_context = NULL; AVStream *stream = NULL; - AVCodec *output_codec = NULL; + const AVCodec *output_codec = NULL; int error; /* Open the output file to write to it. */ diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 6ca3089330..3a97426e2c 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -77,7 +77,7 @@ static int open_input_file(const char *filename) for (i = 0; i < ifmt_ctx->nb_streams; i++) { AVStream *stream = ifmt_ctx->streams[i]; - AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id); + const AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id); AVCodecContext *codec_ctx; if (!dec) { av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream #%u\n", i); @@ -122,7 +122,7 @@ static int open_output_file(const char *filename) AVStream *out_stream; AVStream *in_stream; AVCodecContext *dec_ctx, *enc_ctx; - AVCodec *encoder; + const AVCodec *encoder; int ret; unsigned int i; diff --git a/doc/examples/vaapi_encode.c b/doc/examples/vaapi_encode.c index 46bca1b3fe..e232fa579a 100644 --- a/doc/examples/vaapi_encode.c +++ b/doc/examples/vaapi_encode.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) FILE *fin = NULL, *fout = NULL; AVFrame *sw_frame = NULL, *hw_frame = NULL; AVCodecContext *avctx = NULL; - AVCodec *codec = NULL; + const AVCodec *codec = NULL; const char *enc_name = "h264_vaapi"; if (argc < 5) { diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c index 5a1a704a8e..e9b33eede0 100644 --- a/doc/examples/vaapi_transcode.c +++ b/doc/examples/vaapi_transcode.c @@ -142,7 +142,7 @@ end: return ret; } -static int dec_enc(AVPacket *pkt, AVCodec *enc_codec) +static int dec_enc(AVPacket *pkt, const AVCodec *enc_codec) { AVFrame *frame; int ret = 0; @@ -226,9 +226,9 @@ fail: int main(int argc, char **argv) { + const AVCodec *enc_codec; int ret = 0; AVPacket *dec_pkt; - AVCodec *enc_codec; if (argc != 4) { fprintf(stderr, "Usage: %s \n" diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index cf6fe2055b..e60ac5ce78 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -872,7 +872,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) } } -static AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) +static const AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) { const AVCodec *p, *experimental = NULL; void *i = 0; @@ -886,24 +886,24 @@ static AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) { experimental = p; } else - return (AVCodec*)p; + return p; } } - return (AVCodec*)experimental; + return experimental; } -AVCodec *avcodec_find_encoder(enum AVCodecID id) +const AVCodec *avcodec_find_encoder(enum AVCodecID id) { return find_codec(id, av_codec_is_encoder); } -AVCodec *avcodec_find_decoder(enum AVCodecID id) +const AVCodec *avcodec_find_decoder(enum AVCodecID id) { return find_codec(id, av_codec_is_decoder); } -static AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) +static const AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) { void *i = 0; const AVCodec *p; @@ -915,18 +915,18 @@ static AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) if (!x(p)) continue; if (strcmp(name, p->name) == 0) - return (AVCodec*)p; + return p; } return NULL; } -AVCodec *avcodec_find_encoder_by_name(const char *name) +const AVCodec *avcodec_find_encoder_by_name(const char *name) { return find_codec_by_name(name, av_codec_is_encoder); } -AVCodec *avcodec_find_decoder_by_name(const char *name) +const AVCodec *avcodec_find_decoder_by_name(const char *name) { return find_codec_by_name(name, av_codec_is_decoder); } diff --git a/libavcodec/codec.h b/libavcodec/codec.h index c95078491d..c8653e3b31 100644 --- a/libavcodec/codec.h +++ b/libavcodec/codec.h @@ -367,7 +367,7 @@ const AVCodec *av_codec_iterate(void **opaque); * @param id AVCodecID of the requested decoder * @return A decoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_decoder(enum AVCodecID id); +const AVCodec *avcodec_find_decoder(enum AVCodecID id); /** * Find a registered decoder with the specified name. @@ -375,7 +375,7 @@ AVCodec *avcodec_find_decoder(enum AVCodecID id); * @param name name of the requested decoder * @return A decoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_decoder_by_name(const char *name); +const AVCodec *avcodec_find_decoder_by_name(const char *name); /** * Find a registered encoder with a matching codec ID. @@ -383,7 +383,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name); * @param id AVCodecID of the requested encoder * @return An encoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_encoder(enum AVCodecID id); +const AVCodec *avcodec_find_encoder(enum AVCodecID id); /** * Find a registered encoder with the specified name. @@ -391,7 +391,7 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id); * @param name name of the requested encoder * @return An encoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_encoder_by_name(const char *name); +const AVCodec *avcodec_find_encoder_by_name(const char *name); /** * @return a non-zero number if codec is an encoder, zero otherwise */ diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 73a9a48b20..3f1e9f61d2 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -369,7 +369,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, enum AVPixelFormat pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount); if (pix_fmt == AV_PIX_FMT_NONE) { enum AVCodecID codec_id = av_codec_get_id(tags, bih->biCompression); - AVCodec *codec = avcodec_find_decoder(codec_id); + const AVCodec *codec = avcodec_find_decoder(codec_id); if (codec_id == AV_CODEC_ID_NONE || !codec) { av_log(avctx, AV_LOG_INFO, " unknown compression type 0x%X", (int) bih->biCompression); } else { diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c index 717c9441a4..b00e2927a9 100644 --- a/tests/api/api-band-test.c +++ b/tests/api/api-band-test.c @@ -66,7 +66,7 @@ static void draw_horiz_band(AVCodecContext *ctx, const AVFrame *fr, int offset[4 static int video_decode(const char *input_filename) { - AVCodec *codec = NULL; + const AVCodec *codec = NULL; AVCodecContext *ctx= NULL; AVCodecParameters *origin_par = NULL; uint8_t *byte_buffer = NULL; diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index f3bfbc95b5..88b15e8722 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -48,7 +48,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, return 0; } -static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, +static int init_encoder(const AVCodec *enc, AVCodecContext **enc_ctx, int64_t ch_layout, int sample_rate) { AVCodecContext *ctx; @@ -78,7 +78,7 @@ static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, return 0; } -static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, +static int init_decoder(const AVCodec *dec, AVCodecContext **dec_ctx, int64_t ch_layout) { AVCodecContext *ctx; @@ -105,8 +105,8 @@ static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, return 0; } -static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, - AVCodecContext *dec_ctx) +static int run_test(const AVCodec *enc, const AVCodec *dec, + AVCodecContext *enc_ctx, AVCodecContext *dec_ctx) { AVPacket *enc_pkt; AVFrame *in_frame, *out_frame; @@ -244,7 +244,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, int main(void) { - AVCodec *enc = NULL, *dec = NULL; + const AVCodec *enc = NULL, *dec = NULL; AVCodecContext *enc_ctx = NULL, *dec_ctx = NULL; uint64_t channel_layouts[] = {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_STEREO_DOWNMIX}; int sample_rates[] = {8000, 44100, 48000, 192000}; diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c index 6f13e773f9..b9230c65cb 100644 --- a/tests/api/api-h264-test.c +++ b/tests/api/api-h264-test.c @@ -32,7 +32,7 @@ static int video_decode_example(const char *input_filename) { - AVCodec *codec = NULL; + const AVCodec *codec = NULL; AVCodecContext *ctx= NULL; AVCodecParameters *origin_par = NULL; AVFrame *fr = NULL; diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c index bb9f5c89b3..696af9cdfc 100644 --- a/tests/api/api-seek-test.c +++ b/tests/api/api-seek-test.c @@ -184,7 +184,7 @@ static long int read_seek_range(const char *string_with_number) static int seek_test(const char *input_filename, const char *start, const char *end) { - AVCodec *codec = NULL; + const AVCodec *codec = NULL; AVCodecContext *ctx= NULL; AVCodecParameters *origin_par = NULL; AVPacket *pkt = NULL; diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 334c47a2c8..f52eba92b1 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -59,7 +59,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); -extern AVCodec * codec_list[]; +extern const AVCodec * codec_list[]; static void error(const char *err) { @@ -67,10 +67,10 @@ static void error(const char *err) exit(1); } -static AVCodec *c = NULL; -static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) +static const AVCodec *c = NULL; +static const AVCodec *AVCodecInitialize(enum AVCodecID codec_id) { - AVCodec *res; + const AVCodec *res; res = avcodec_find_decoder(codec_id); if (!res)