From patchwork Tue Jul 26 22:08:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37003 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp234659pzb; Wed, 27 Jul 2022 02:36:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tE4TN3DdNURt4m4FW9+1UOvsNOXe1qeN/GjdY8R5tn4ZaoBsyEdoK3dDlpd0mhMphEnjXx X-Received: by 2002:a05:6402:d05:b0:435:b2a6:94eb with SMTP id eb5-20020a0564020d0500b00435b2a694ebmr21824466edb.87.1658914616884; Wed, 27 Jul 2022 02:36:56 -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 q5-20020a170906b28500b007263a6115adsi9857326ejz.893.2022.07.27.02.36.56; Wed, 27 Jul 2022 02:36:56 -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=VPUeSLU3; 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 DB91668B71A; Wed, 27 Jul 2022 12:33:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2098.outbound.protection.outlook.com [40.92.91.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED15F68B894 for ; Wed, 27 Jul 2022 12:33:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7k/ZludYWWO4tJUf0+T0Io5pjCMP83M2ZPaf8h0j5wjLd958o6NkxPnQEZVhxQ3XaaM048ebAh3Rn7eI6t2sJ/g7+oH5J5kKEjXOF9y2aF2uaEN4SZfWDdExssoW0sOtlCGsr9VN0xUe6pb6uvr+NXD2Ct5NbYACAq1HwG+9/o+Rt753fb8y3lLutT8bOwSfiTD7ohN/lKPQUa3deh6QU3L/ehT5F9VShC3iUhBh9OYssPRDi7YHFn30/DZN7kVKC1AOfT3RvaS2GjFUkECE4Ka1Nd+p2R+jTQTQA9aiCNwNHUA2fvmxqXs1XVpR8yEe+9SEkYnVRJyNkLCQqv3Cw== 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=By2ZyjMtHbTl0YkgRAF62NlZdRdZnD7erQ4pQwYYAhQ=; b=gm0qwoQrA/qy5kT6yTZKwGMZXKXm8JvfsChbZMbGelVxXbbB10pXJb1T/Db4YqNSzzB4AT9JCrVEI70uaTrVVW3CWUvLVFicsoKLrYy0fpoMD7lbinKsRuP4ddgdGmI/oAzW8jIIAVr22Sz+vSax7n1LEuJf0txzNGl3CApeCucOdTiOsNN6/VXriImJCx/VkQYICRBV7u2Lz+7KgkrOUO9eF2L9gSBZ7CnIY9gIGq+fChkSCrLAmCQnLhpvo/bONsK6p0EgBNdhiunkHNXe1poFbYbsDADGcS2vcgOKlX5IBHHsAjrLMEjItBB3YP56gR+Ri/Ql+QkuBKZN1Kw37w== 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=By2ZyjMtHbTl0YkgRAF62NlZdRdZnD7erQ4pQwYYAhQ=; b=VPUeSLU3rI1NNP4uBJ/aWD5nhCUXKJZlbqtn/Fh5g5j6yzJNcyClXeSIPwA2gf50voead8THSAjEiW4pr4Cmcl1IvpPi0Vm1gCZ8inJoSV88lsKORB/0Su9zaFPvRd2704m+XGjIat988RzKVqrSKhqWWOBjdVZyIA2qbZ6OPM01L89p+w/mQA2buoIHcQUgjGvw/RylQg4bswnL94kVd3vHCOQQIXQ7woSOn7ec/CMFA3X+3T2JhvmsEYLJ/yWACA59xW89N4x88kuDDlRnLaEaTydGtvw7OV+wFcKUCR8nbUC0sPfK9NAPivbi0ebDEnnDztvuwSMPSeI0G8Mpdg== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by HE1PR0102MB2716.eurprd01.prod.exchangelabs.com (2603:10a6:7:1f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Tue, 26 Jul 2022 22:09:57 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5458.025; Tue, 26 Jul 2022 22:09:57 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Jul 2022 00:08:13 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [p8w9SvTHjxmjgrk8t5Y1aSQdqUjNHHSM] X-ClientProxiedBy: FR3P281CA0157.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::13) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220726220814.695563-37-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1a88d19-debf-4f53-1cc3-08da6f53937d X-MS-Exchange-SLBlob-MailProps: apgo5D0uMOEwyGGkKDsLmRMJnSr7T/RuSmue0b16pYkGQFW2A12uqE57gx/rvNg5VTNZ7ibt6kUsqFylBKSDDi3ElWC5JwSoXdBsUl3l0pMD1T6HIqHv9xn2H2X4fwQ+QqGE+U5EbKuxm7JZm2o75fXGNY9YJQ5LY0lz3QS+uqKZ81e3koEoPYqlfqYUI3oacIuZuBfvyZmtv6xcO4ULBExiXVhGy39O4ketKLkruEzJjwT39dc1WBlOxQmR6k9HG0CQVWeqsFktHF097PLkYXZ5htCxGwu47TYyev4Pqf4QFy2NOWcoP9MacBj3IyDidwBdU2QzrGYMcXFf2WpHJDi8Jm4G2OzTOIyTcGLZLh28KT8KAjS0TjpVF+SzlLFXiBRm8tLmp3hGV0giF5K7dJAkBE/FAFvXmIF3kDtKn+mfgYraO0K/Yse9SDk7eALou20YHN8dQTyogJQK+X+g3/7E4peLbmtY81sf+COYVkN0RCOWzqw+Rl7L5UwrJtYXhZOxP/4dBVELLveOEXi4d3T+avJO3lLcaT1CMWXJOLg57DNzfVGKw2i5Yw3qpYGCFylDgQmn6PMI4KMGTDulsYi2rlsPbVZtkadn5IzAfXCELUCsNhp6GAXBG9GbJouM2d9dHefKOB7PmMQ+mBNSCpheNjWqKtiLbXAjSReAgbsbRWY2y0mNsvRFc+FZemzcyCkQ5qGzj8WkfeiQ74jsNpTtqeunBR9GPMhJ3/eWEnMd5xPP3M9rZF6FefJ9l6ldgc7H6spPpMCwKM/vNuLpdQ2SxKdK/0LprVGx352bDzFErr2RaGZJKmmIsdSOYXO6F42ecjccvhNP7NdFqzLIQdqhwnBwVexSili9goeLbyUa6+qi8ExO2O9m+n1icVaJ5+QUcT4FECwO0MJt8svwoBw2aS3KIzrLGcKS5d7ZEIIHxEFBGs+nvNz2ZPuza7KJS5JDD75MU8Sdi4ILYXw1gMC2MoiKiPrR0fW+W39KYQjA6eEEc1/zYg== X-MS-TrafficTypeDiagnostic: HE1PR0102MB2716:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RY1es4SjOWcfhRWzjm633M0qSOPU2TVI/0IyCp0v8okSP+iyCX+oBpW34ne0Q2xgk1eq0WbgkzKdhWmT0dni7Q8b6EKAbNzLJ0+2/L9rTvnUjuoY6YIzTxKgjke63wyrFFtpw5i0HqEDaz7Ebj16RKQahcpEuX9hmkHchgI9I+p25FDlPBetVmLDGaYFR2RQqrJx/gtw2XYP2h20/9Xa6NT1LYx8R0mXaVelP0kz3Sfic4fcR1CLJg89p8jcfWgTtCN0ggXCGihOTPyKgNK6Q1NzHuYHcayMis+3MKdu1JSYVnyq+89rqXk9t4BD2SKvLBwIG0vgKXq9w1DZAi7gHM4/CGuLY254Oy24Rd7SLdxtobb4txgyfQCTOh0h4zXoslU2WFQbrSV8w1vy/a3ZyaqE1+kykjbHVBbVIdhwlzXbkmE8GbRva4sRldlBq4MCGQaQpRtc5JEhNPmuH+U5zDz9sZgzwrJegYwPxexlTSqRAMsTYcz8dQlVUO3YmiAOimQ4r0ZUgbt2itjU3qFcHDzTkdlD/dn31+i89+6W2YeWdiNcOLLBmaGdskN/dcaq2JXA6UXsYy99lhciQDvbuwEMRukjVHLGkkiNsSUg5BkNI4KDWOmLmmLGHYqZt1qkHpKEywzUAFjw5j54oWvEbw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IAM4hOD7B+UFB15UUdVnDunENXGT9CrekgvysoX7sRWfLlhAw1bWKiqHdKfPUGzCeVoqlGXZX9HmlKqw37r/l0Vo5Ik0HBioXO4MNl2N2aI8ztWerZx40BzBxeZtr0FUXSFsyuTm8Rj3gDqw5CSLRWeMZNcp1VCUvP606mRSRpN23BLiqsETNPvc2a1qkuR/BIBjRrjyv4k5irC7x1US777clMoFuvDURG4xQ/SFNrLKGE6+nzltPfwSw0ZbchkO8QqpcuSlUUsKjxJznV6hcvRky/KQhqkGxKqbNoXJ0w81qGQJohX+TyA4KUuGt+77G1r4x7i856J71Hv5xyxeKrwoFEcBsmPkNmDowvTCK3Oc0woeWyo+bmq32HjnybSJQMdF2Ln/nsYyoPHGE8WbAZhLR8tkWLZMi5mieO46nn3K/ogwb8rncb2vbl53AqQQtU1pcRnuVhaU4EOxa8M6l1d5QbSSu7AKh40t+s1+uoyYx3k0D4yyXdIDevDSU5Ge1QD+Q7lbgC4In1qLR/otC8l1LlK2mjz3kqQOpc/5gGH0lr51IhjsJk9Zms1fzZxr67cVN0+vk4jpnUk3AS+zelUQuOwcHWlzxrJ6t3wADiDWytgxdGJYRxqJLMXek7XgcMrOa6l7Isze6dNMbdLzgBxh2GXg/co9xPR3ZBcwc23VQOkSvx3i4N/oZw4XJhJVARlXU5E05sBkmejr4yBtBNGaOzGPrlgSfpMdNPSEfz3jN9w+e6RgehbM8NvGMOkrKq7A07a6jMloSzHFHILk1Y6eirdQ9dxhmgSbiO+RUnyDkmeLxUx2oebahH5hQNxHFPzfB0asU5erwxkSA++SbhWxCIZC0p0gJJOxfpFCPogzOt/Rm7T8lj37Dd1Ssnq/N1PwSLRac1aKHawl+KlshRikw1eBr/8JJQMqqAqox9BkvSSTq215xA6ctINeML7c3+w+jsdn7RLTuv1hpzaE+oCX/PUVVx7TLUoP9g4LQ2afakR7FBtCkimlUrDS6Iqot97VotJVzYtkNE9VDLb+zSoT32lLO83RfGLMZgNGt49c8uW8htKkCzYqFI3dJI5jO93QotGMJ94c8xDJAIWI1+ICUBvvelF1AmeriHRrnmLjIsDi5Sr3r087KjP4Za5bsU7WbeqrDNJs5qOfHjAEx6QqrcGgA5cFrReU6uq2M64rbJJudJFyaVIRsQLrYCnf9o8biBr+xPDIB6/rbFqAp5dRrGXQKWuomvhxtK85HJNsS/4JWHjpPlquDZkQBOfuumuEiQ+XpwyaJylSeBiDLhoXI3/WjdgrcPvl8vfeFmE= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1a88d19-debf-4f53-1cc3-08da6f53937d X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2022 22:09:57.7671 (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: HE1PR0102MB2716 Subject: [FFmpeg-devel] [PATCH 38/39] avcodec: Constify frame->data pointers for encoders where possible 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: gPrCtkRsEPCD Signed-off-by: Andreas Rheinhardt --- libavcodec/a64multienc.c | 2 +- libavcodec/adpcmenc.c | 4 ++-- libavcodec/asvenc.c | 6 +++--- libavcodec/avuienc.c | 2 +- libavcodec/bmpenc.c | 3 ++- libavcodec/cfhdenc.c | 15 ++++++++------- libavcodec/cinepakenc.c | 2 +- libavcodec/cljrenc.c | 6 +++--- libavcodec/cngenc.c | 2 +- libavcodec/dfpwmenc.c | 2 +- libavcodec/dnxhdenc.c | 6 +++--- libavcodec/dnxhdenc.h | 2 +- libavcodec/dvenc.c | 11 +++++------ libavcodec/exrenc.c | 6 +++--- libavcodec/ffv1enc.c | 2 +- libavcodec/fitsenc.c | 4 ++-- libavcodec/flashsvenc.c | 5 ++--- libavcodec/huffyuvenc.c | 18 +++++++++--------- libavcodec/j2kenc.c | 12 ++++++------ libavcodec/libopusenc.c | 12 ++++++------ libavcodec/ljpegenc.c | 6 +++--- libavcodec/magicyuvenc.c | 3 ++- libavcodec/mlpenc.c | 4 ++-- libavcodec/mpeg4videoenc.c | 4 ++-- libavcodec/mpegvideo_enc.c | 24 ++++++++++++------------ libavcodec/msvideo1enc.c | 4 ++-- libavcodec/pamenc.c | 3 ++- libavcodec/pngenc.c | 16 ++++++++-------- libavcodec/pnmenc.c | 18 ++++++++---------- libavcodec/proresenc_anatoliy.c | 22 +++++++++++----------- libavcodec/qoienc.c | 3 ++- libavcodec/r210enc.c | 8 ++++---- libavcodec/rpzaenc.c | 29 +++++++++++++++-------------- libavcodec/sgienc.c | 6 +++--- libavcodec/snow.h | 2 +- libavcodec/snowenc.c | 14 +++++++------- libavcodec/svq1enc.c | 4 ++-- libavcodec/targaenc.c | 2 +- libavcodec/tiffenc.c | 4 ++-- libavcodec/utvideoenc.c | 4 ++-- libavcodec/v308enc.c | 2 +- libavcodec/v408enc.c | 2 +- libavcodec/v410enc.c | 2 +- libavcodec/vbnenc.c | 2 +- libavcodec/vc2enc.c | 2 +- libavcodec/wmaenc.c | 2 +- libavcodec/xbmenc.c | 3 ++- libavcodec/xwdenc.c | 3 ++- libavcodec/y41penc.c | 2 +- libavcodec/yuv4enc.c | 2 +- libavcodec/zmbvenc.c | 11 ++++++----- 51 files changed, 170 insertions(+), 165 deletions(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index ba774bf59f..043ffabd7c 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -76,7 +76,7 @@ static void to_meta_with_crop(AVCodecContext *avctx, int luma = 0; int height = FFMIN(avctx->height, C64YRES); int width = FFMIN(avctx->width , C64XRES); - uint8_t *src = p->data[0]; + const uint8_t *src = p->data[0]; for (blocky = 0; blocky < C64YRES; blocky += 8) { for (blockx = 0; blockx < C64XRES; blockx += 8) { diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 169a95046d..e27febfd74 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -601,13 +601,13 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, { int st, pkt_size, ret; const int16_t *samples; - int16_t **samples_p; + const int16_t *const *samples_p; uint8_t *dst; ADPCMEncodeContext *c = avctx->priv_data; int channels = avctx->ch_layout.nb_channels; samples = (const int16_t *)frame->data[0]; - samples_p = (int16_t **)frame->extended_data; + samples_p = (const int16_t *const *)frame->extended_data; st = channels == 2; if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI || diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index c6fd6a519e..8b94868c93 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -190,9 +190,9 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame, int linesize = frame->linesize[0]; int i; - uint8_t *ptr_y = frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16; - uint8_t *ptr_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8; - uint8_t *ptr_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8; + const uint8_t *ptr_y = frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16; + const uint8_t *ptr_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8; + const uint8_t *ptr_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8; a->pdsp.get_pixels(block[0], ptr_y, linesize); a->pdsp.get_pixels(block[1], ptr_y + 8, linesize); diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c index a54612ff28..0357e682a9 100644 --- a/libavcodec/avuienc.c +++ b/libavcodec/avuienc.c @@ -72,7 +72,7 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } for (i = 0; i <= interlaced; i++) { - uint8_t *src; + const uint8_t *src; if (interlaced && avctx->height == 486) { src = pic->data[0] + (1 - i) * pic->linesize[0]; } else { diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index 78f64edb1c..964f7cc2ad 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -72,7 +72,8 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint32_t palette256[256]; int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB; int bit_count = avctx->bits_per_coded_sample; - uint8_t *ptr, *buf; + const uint8_t *ptr; + uint8_t *buf; switch (avctx->pix_fmt) { case AV_PIX_FMT_RGB444: diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 3aad4d060f..c2f42c14dd 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -437,7 +437,8 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int a_width = s->plane[plane].band[2][0].a_width; int height = s->plane[plane].band[2][0].height; int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane; - int16_t *input = (int16_t *)frame->data[act_plane]; + const int16_t *input = (int16_t *)frame->data[act_plane]; + int16_t *buf; int16_t *low = s->plane[plane].l_h[6]; int16_t *high = s->plane[plane].l_h[7]; ptrdiff_t in_stride = frame->linesize[act_plane] / 2; @@ -481,13 +482,13 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, high = s->plane[plane].l_h[4]; high_stride = s->plane[plane].band[1][0].a_width; + buf = s->plane[plane].l_h[7]; for (int i = 0; i < height * 2; i++) { for (int j = 0; j < width * 2; j++) - input[j] /= 4; - input += a_width * 2; + buf[j] /= 4; + buf += a_width * 2; } - input = s->plane[plane].l_h[7]; dsp->horiz_filter(input, low, high, a_width * 2, low_stride, high_stride, width * 2, height * 2); @@ -518,14 +519,14 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, high_stride = s->plane[plane].band[0][0].a_width; if (avctx->pix_fmt != AV_PIX_FMT_YUV422P10) { + int16_t *buf = s->plane[plane].l_h[4]; for (int i = 0; i < height * 2; i++) { for (int j = 0; j < width * 2; j++) - input[j] /= 4; - input += a_width * 2; + buf[j] /= 4; + buf += a_width * 2; } } - input = s->plane[plane].l_h[4]; dsp->horiz_filter(input, low, high, a_width * 2, low_stride, high_stride, width * 2, height * 2); diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c index 1b7c901685..479e99389c 100644 --- a/libavcodec/cinepakenc.c +++ b/libavcodec/cinepakenc.c @@ -1019,7 +1019,7 @@ static int rd_frame(CinepakEncContext *s, const AVFrame *frame, // build a copy of the given frame in the correct colorspace for (y = 0; y < s->h; y += 2) for (x = 0; x < s->w; x += 2) { - uint8_t *ir[2]; + const uint8_t *ir[2]; int32_t r, g, b, rr, gg, bb; ir[0] = frame->data[0] + x * 3 + y * frame->linesize[0]; ir[1] = ir[0] + frame->linesize[0]; diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c index 2d171a9376..f84191b427 100644 --- a/libavcodec/cljrenc.c +++ b/libavcodec/cljrenc.c @@ -63,9 +63,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, init_put_bits(&pb, pkt->data, pkt->size); for (y = 0; y < avctx->height; y++) { - uint8_t *luma = &p->data[0][y * p->linesize[0]]; - uint8_t *cb = &p->data[1][y * p->linesize[1]]; - uint8_t *cr = &p->data[2][y * p->linesize[2]]; + const uint8_t *luma = &p->data[0][y * p->linesize[0]]; + const uint8_t *cb = &p->data[1][y * p->linesize[1]]; + const uint8_t *cr = &p->data[2][y * p->linesize[2]]; uint8_t luma_tmp[4]; for (x = 0; x < avctx->width; x += 4) { switch (a->dither_type) { diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index 98987238dd..7bb4bee857 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -67,7 +67,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int ret, i; double energy = 0; int qdbov; - int16_t *samples = (int16_t*) frame->data[0]; + const int16_t *samples = (const int16_t*) frame->data[0]; if ((ret = ff_get_encode_buffer(avctx, avpkt, 1 + p->order, 0))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); diff --git a/libavcodec/dfpwmenc.c b/libavcodec/dfpwmenc.c index 0465dc23ac..41ad645315 100644 --- a/libavcodec/dfpwmenc.c +++ b/libavcodec/dfpwmenc.c @@ -39,7 +39,7 @@ typedef struct { // Licensed in the public domain // note, len denotes how many compressed bytes there are (uncompressed bytes / 8). -static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, uint8_t *inbuf) +static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, const uint8_t *inbuf) { unsigned d = 0; for (int i = 0; i < len; i++) { diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 7e02ff23d6..5029e510ef 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -944,7 +944,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, ctx = ctx->thread[threadnr]; if (ctx->bit_depth == 8) { - uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize); + const uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize); for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum; @@ -973,8 +973,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, } else { // 10-bit const int linesize = ctx->m.linesize >> 1; for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { - uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] + - ((mb_y << 4) * linesize) + (mb_x << 4); + const uint16_t *pix = (const uint16_t *)ctx->thread[0]->src[0] + + ((mb_y << 4) * linesize) + (mb_x << 4); unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum = 0; int sqsum = 0; diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 7726a3915f..e581312ce4 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -86,7 +86,7 @@ typedef struct DNXHDEncContext { uint16_t (*qmatrix_c16)[2][64]; unsigned frame_bits; - uint8_t *src[3]; + const uint8_t *src[3]; uint32_t *orig_vlc_codes; uint8_t *orig_vlc_bits; diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index f51bd82488..5ba4de3213 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -217,7 +217,7 @@ static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi, return pb; } -static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, +static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const uint8_t *data, ptrdiff_t linesize) { if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { @@ -506,7 +506,7 @@ static inline void dv_set_class_number_hd(DVVideoContext *s, bi->cno = 0; } -static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, int linesize, +static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t *data, int linesize, DVVideoContext *s, int chroma) { LOCAL_ALIGNED_16(int16_t, blk, [64]); @@ -849,7 +849,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) int mb_index, i, j; int mb_x, mb_y, c_offset; ptrdiff_t linesize, y_stride; - uint8_t *y_ptr; + const uint8_t *y_ptr; uint8_t *dif, *p; LOCAL_ALIGNED_8(uint8_t, scratch, [128]); EncBlockInfo enc_blks[5 * DV_MAX_BPM]; @@ -908,14 +908,13 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) c_offset = ((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] + (mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) * 8; for (j = 2; j; j--) { - uint8_t *c_ptr = s->frame->data[j] + c_offset; + const uint8_t *c_ptr = s->frame->data[j] + c_offset; linesize = s->frame->linesize[j]; y_stride = (mb_y == 134) ? 8 : (s->frame->linesize[j] * (1 << (3*!enc_blk->dct_mode))); if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) { - uint8_t *d; uint8_t *b = scratch; for (i = 0; i < 8; i++) { - d = c_ptr + linesize * 8; + const uint8_t *d = c_ptr + linesize * 8; b[0] = c_ptr[0]; b[1] = c_ptr[1]; b[2] = c_ptr[2]; diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c index 708404b38f..8cf7827bb6 100644 --- a/libavcodec/exrenc.c +++ b/libavcodec/exrenc.c @@ -253,7 +253,7 @@ static int encode_scanline_rle(EXRContext *s, const AVFrame *frame) for (int p = 0; p < s->planes; p++) { int ch = s->ch_order[p]; uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + frame->width * 2 * p); - uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); + const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); for (int x = 0; x < frame->width; x++) dst[x] = float2half(src[x], s->basetable, s->shifttable); @@ -321,7 +321,7 @@ static int encode_scanline_zip(EXRContext *s, const AVFrame *frame) for (int p = 0; p < s->planes; p++) { int ch = s->ch_order[p]; uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + scanline_size * l + p * frame->width * 2); - uint32_t *src = (uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]); + const uint32_t *src = (const uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]); for (int x = 0; x < frame->width; x++) dst[x] = float2half(src[x], s->basetable, s->shifttable); @@ -479,7 +479,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream2_put_le32(pb, s->planes * avctx->width * 2); for (int p = 0; p < s->planes; p++) { int ch = s->ch_order[p]; - uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); + const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); for (int x = 0; x < frame->width; x++) bytestream2_put_le16(pb, float2half(src[x], s->basetable, s->shifttable)); diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 96da4d0203..ec06636db5 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -270,7 +270,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state, #define RENAME(name) name ## 32 #include "ffv1enc_template.c" -static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h, +static int encode_plane(FFV1Context *s, const uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) { int x, y, i, ret; diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c index 6e0597c8ca..30395b0a43 100644 --- a/libavcodec/fitsenc.c +++ b/libavcodec/fitsenc.c @@ -38,7 +38,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { - uint8_t *bytestream, *ptr; + uint8_t *bytestream; const uint16_t flip = (1 << 15); uint64_t data_size = 0, padded_data_size = 0; int ret, bitpix, naxis3 = 1, i, j, k, bytes_left; @@ -87,7 +87,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, for (k = 0; k < naxis3; k++) { for (i = 0; i < avctx->height; i++) { - ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]]; + const uint8_t *ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]]; if (bitpix == 16) { for (j = 0; j < avctx->width; j++) { // subtracting bzero is equivalent to first bit flip diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 12db53bb8f..11a6e2b134 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -66,16 +66,15 @@ typedef struct FlashSVContext { uint8_t tmpblock[3 * 256 * 256]; } FlashSVContext; -static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, +static int copy_region_enc(const uint8_t *sptr, uint8_t *dptr, int dx, int dy, int h, int w, int stride, uint8_t *pfptr) { int i, j; - uint8_t *nsptr; uint8_t *npfptr; int diff = 0; for (i = dx + h; i > dx; i--) { - nsptr = sptr + i * stride + dy * 3; + const uint8_t *nsptr = sptr + i * stride + dy * 3; npfptr = pfptr + i * stride + dy * 3; for (j = 0; j < w * 3; j++) { diff |= npfptr[j] ^ nsptr[j]; diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index a9aa00a5df..c585d007b4 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -119,7 +119,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, } static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst, - uint8_t *src, int w, + const uint8_t *src, int w, int *red, int *green, int *blue) { int i; @@ -789,7 +789,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, y++; cy++; for (; y < height; y++,cy++) { - uint8_t *ydst, *udst, *vdst; + const uint8_t *ydst, *udst, *vdst; if (s->bitstream_bpp == 12) { while (2 * cy > y) { @@ -812,7 +812,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } else { for (cy = y = 1; y < height; y++, cy++) { - uint8_t *ydst, *udst, *vdst; + const uint8_t *ydst, *udst, *vdst; /* encode a luma only line & y++ */ if (s->bitstream_bpp == 12) { @@ -852,7 +852,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } } else if(avctx->pix_fmt == AV_PIX_FMT_RGB32) { - uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; + const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; const int stride = -p->linesize[0]; const int fake_stride = -fake_ystride; int y; @@ -868,7 +868,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, encode_bgra_bitstream(s, width - 1, 4); for (y = 1; y < s->height; y++) { - uint8_t *dst = data + y*stride; + const uint8_t *dst = data + y*stride; if (s->predictor == PLANE && s->interlaced < y) { s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4); sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width, @@ -880,7 +880,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, encode_bgra_bitstream(s, width, 4); } } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { - uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; + const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; const int stride = -p->linesize[0]; const int fake_stride = -fake_ystride; int y; @@ -896,7 +896,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, encode_bgra_bitstream(s, width-1, 3); for (y = 1; y < s->height; y++) { - uint8_t *dst = data + y * stride; + const uint8_t *dst = data + y * stride; if (s->predictor == PLANE && s->interlaced < y) { s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 3); @@ -939,7 +939,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, lefttop = p->data[plane][0]; for (; y < h; y++) { - uint8_t *dst = p->data[plane] + p->linesize[plane] * y; + const uint8_t *dst = p->data[plane] + p->linesize[plane] * y; sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop); @@ -947,7 +947,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } else { for (y = 1; y < h; y++) { - uint8_t *dst = p->data[plane] + p->linesize[plane] * y; + const uint8_t *dst = p->data[plane] + p->linesize[plane] * y; if (s->predictor == PLANE && s->interlaced < y) { diff_bytes(s, s->temp[1], dst, dst - fake_stride, w); diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 20eb336b8d..5ef7f24b6d 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -507,7 +507,7 @@ static int init_tiles(Jpeg2000EncoderContext *s) static void copy_frame_ ##D(Jpeg2000EncoderContext *s) \ { \ int tileno, compno, i, y, x; \ - PIXEL *line; \ + const PIXEL *line; \ for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ \ Jpeg2000Tile *tile = s->tile + tileno; \ if (s->planar){ \ @@ -515,23 +515,23 @@ static int init_tiles(Jpeg2000EncoderContext *s) Jpeg2000Component *comp = tile->comp + compno; \ int *dst = comp->i_data; \ int cbps = s->cbps[compno]; \ - line = (PIXEL*)s->picture->data[compno] \ + line = (const PIXEL*)s->picture->data[compno] \ + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \ + comp->coord[0][0]; \ for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \ - PIXEL *ptr = line; \ + const PIXEL *ptr = line; \ for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \ *dst++ = *ptr++ - (1 << (cbps - 1)); \ line += s->picture->linesize[compno] / sizeof(PIXEL); \ } \ } \ } else{ \ - line = (PIXEL*)s->picture->data[0] + tile->comp[0].coord[1][0] * (s->picture->linesize[0] / sizeof(PIXEL)) \ + line = (const PIXEL*)(s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0]) \ + tile->comp[0].coord[0][0] * s->ncomponents; \ \ i = 0; \ for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ \ - PIXEL *ptr = line; \ + const PIXEL *ptr = line; \ for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ \ for (compno = 0; compno < s->ncomponents; compno++){ \ int cbps = s->cbps[compno]; \ @@ -1597,7 +1597,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, update_size(chunkstart, s->buf); if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { int i; - uint8_t *palette = pict->data[1]; + const uint8_t *palette = pict->data[1]; chunkstart = s->buf; bytestream_put_be32(&s->buf, 0); bytestream_put_buffer(&s->buf, "pclr", 4); diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 48dd32fc38..b8ab184109 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -459,7 +459,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, const int bytes_per_sample = av_get_bytes_per_sample(avctx->sample_fmt); const int channels = avctx->ch_layout.nb_channels; const int sample_size = channels * bytes_per_sample; - uint8_t *audio; + const uint8_t *audio; int ret; int discard_padding; @@ -470,18 +470,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, if (opus->encoder_channel_map != NULL) { audio = opus->samples; libopus_copy_samples_with_channel_map( - audio, frame->data[0], opus->encoder_channel_map, + opus->samples, frame->data[0], opus->encoder_channel_map, channels, frame->nb_samples, bytes_per_sample); } else if (frame->nb_samples < opus->opts.packet_size) { audio = opus->samples; - memcpy(audio, frame->data[0], frame->nb_samples * sample_size); + memcpy(opus->samples, frame->data[0], frame->nb_samples * sample_size); } else audio = frame->data[0]; } else { if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count)) return 0; audio = opus->samples; - memset(audio, 0, opus->opts.packet_size * sample_size); + memset(opus->samples, 0, opus->opts.packet_size * sample_size); } /* Maximum packet size taken from opusenc in opus-tools. 120ms packets @@ -491,11 +491,11 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, return ret; if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) - ret = opus_multistream_encode_float(opus->enc, (float *)audio, + ret = opus_multistream_encode_float(opus->enc, (const float *)audio, opus->opts.packet_size, avpkt->data, avpkt->size); else - ret = opus_multistream_encode(opus->enc, (opus_int16 *)audio, + ret = opus_multistream_encode(opus->enc, (const opus_int16 *)audio, opus->opts.packet_size, avpkt->data, avpkt->size); diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index a167d1780e..26f42a2db6 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -78,7 +78,7 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb, for (y = 0; y < height; y++) { const int modified_predictor = y ? s->pred : 1; - uint8_t *ptr = frame->data[0] + (linesize * y); + const uint8_t *ptr = frame->data[0] + (linesize * y); if (put_bytes_left(pb, 0) < width * 4 * 4) { av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); @@ -132,7 +132,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb, if (mb_x == 0 || mb_y == 0) { for (i = 0; i < 3; i++) { - uint8_t *ptr; + const uint8_t *ptr; int x, y, h, v, linesize; h = s->hsample[i]; v = s->vsample[i]; @@ -166,7 +166,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb, } } else { for (i = 0; i < 3; i++) { - uint8_t *ptr; + const uint8_t *ptr; int x, y, h, v, linesize; h = s->hsample[i]; v = s->vsample[i]; diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index 1be51f3e88..7d77ef7bba 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -458,11 +458,12 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } if (s->correlate) { - uint8_t *r, *g, *b, *decorrelated[2] = { s->decorrelate_buf[0], + uint8_t *decorrelated[2] = { s->decorrelate_buf[0], s->decorrelate_buf[1] }; const int decorrelate_linesize = FFALIGN(width, 16); const uint8_t *const data[4] = { decorrelated[0], frame->data[0], decorrelated[1], frame->data[3] }; + const uint8_t *r, *g, *b; const int linesize[4] = { decorrelate_linesize, frame->linesize[0], decorrelate_linesize, frame->linesize[3] }; diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index b75151abef..c25f48fabe 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -1202,7 +1202,7 @@ static void input_data_internal(MLPEncodeContext *ctx, const uint8_t *samples, } /** Wrapper function for inputting data in two different bit-depths. */ -static void input_data(MLPEncodeContext *ctx, void *samples, int nb_samples) +static void input_data(MLPEncodeContext *ctx, const void *samples, int nb_samples) { input_data_internal(ctx, samples, nb_samples, ctx->avctx->sample_fmt == AV_SAMPLE_FMT_S32); } @@ -2069,7 +2069,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int bytes_written = 0; int channels = avctx->ch_layout.nb_channels; int restart_frame, ret; - uint8_t *data; + const uint8_t *data; if (!frame && !ctx->last_frames) ctx->last_frames = (ctx->afq.remaining_samples + avctx->frame_size - 1) / avctx->frame_size; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index b0825fd3e3..339a3c2152 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -639,7 +639,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], if (s->max_b_frames > 0) { int i; int x, y, offset; - uint8_t *p_pic; + const uint8_t *p_pic; x = s->mb_x * 16; y = s->mb_y * 16; @@ -649,7 +649,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], s->mb_skipped = 1; for (i = 0; i < s->max_b_frames; i++) { - uint8_t *b_pic; + const uint8_t *b_pic; int diff; Picture *pic = s->reordered_input_picture[i + 1]; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c9d9e2a764..4719a734c9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -953,7 +953,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) return 0; } -static int get_sae(uint8_t *src, int ref, int stride) +static int get_sae(const uint8_t *src, int ref, int stride) { int x,y; int acc = 0; @@ -967,8 +967,8 @@ static int get_sae(uint8_t *src, int ref, int stride) return acc; } -static int get_intra_count(MpegEncContext *s, uint8_t *src, - uint8_t *ref, int stride) +static int get_intra_count(MpegEncContext *s, const uint8_t *src, + const uint8_t *ref, int stride) { int x, y, w, h; int acc = 0; @@ -1087,7 +1087,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) int v_shift = i ? v_chroma_shift : 0; int w = s->width >> h_shift; int h = s->height >> v_shift; - uint8_t *src = pic_arg->data[i]; + const uint8_t *src = pic_arg->data[i]; uint8_t *dst = pic->f->data[i]; int vpad = 16; @@ -1149,7 +1149,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) return 0; } -static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) +static int skip_check(MpegEncContext *s, const Picture *p, const Picture *ref) { int x, y, plane; int score = 0; @@ -1161,8 +1161,8 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) for (y = 0; y < s->mb_height * bw; y++) { for (x = 0; x < s->mb_width * bw; x++) { int off = p->shared ? 0 : 16; - uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; - uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); + const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; + const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8); switch (FFABS(s->frame_skip_exp)) { @@ -1190,7 +1190,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) return 0; } -static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) +static int encode_frame(AVCodecContext *c, const AVFrame *frame, AVPacket *pkt) { int ret; int size = 0; @@ -1990,7 +1990,7 @@ static inline void clip_coeffs(MpegEncContext *s, int16_t *block, overflow, minlevel, maxlevel); } -static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride) +static void get_visual_weight(int16_t *weight, const uint8_t *ptr, int stride) { int x, y; // FIXME optimize @@ -2035,7 +2035,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int skip_dct[12]; int dct_offset = s->linesize * 8; // default for progressive frames int uv_dct_offset = s->uvlinesize * 8; - uint8_t *ptr_y, *ptr_cb, *ptr_cr; + const uint8_t *ptr_y, *ptr_cb, *ptr_cr; ptrdiff_t wrap_y, wrap_c; for (i = 0; i < mb_block_count; i++) @@ -2534,7 +2534,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE } } -static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){ +static int sse(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride){ const uint32_t *sq = ff_square_tab + 256; int acc=0; int x,y; @@ -2641,7 +2641,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xx = mb_x * 16; int yy = mb_y * 16; - uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx; + const uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx; int varc; int sum = s->mpvencdsp.pix_sum(pix, s->linesize); diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c index f14badde21..4e1e94e9ab 100644 --- a/libavcodec/msvideo1enc.c +++ b/libavcodec/msvideo1enc.c @@ -69,7 +69,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, { Msvideo1EncContext * const c = avctx->priv_data; const AVFrame *p = pict; - uint16_t *src; + const uint16_t *src; uint8_t *prevptr; uint8_t *dst, *buf; int keyframe = 0; @@ -85,7 +85,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if(!c->prev) c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); - src = (uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1)); + src = (const uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1)); if(c->keyint >= avctx->keyint_min) keyframe = 1; diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index df23afe67f..6e934ba7a1 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -28,7 +28,8 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { int i, h, w, n, linesize, depth, maxval, ret, header_size; - uint8_t *bytestream, *ptr; + uint8_t *bytestream; + const uint8_t *ptr; const char *tuple_type; char header[100]; diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index c4742e293f..438457da26 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -120,7 +120,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size, } } -static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, +static void sub_png_paeth_prediction(uint8_t *dst, const uint8_t *src, const uint8_t *top, int w, int bpp) { int i; @@ -165,7 +165,7 @@ static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *s } static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type, - uint8_t *src, uint8_t *top, int size, int bpp) + const uint8_t *src, const uint8_t *top, int size, int bpp) { int i; @@ -194,7 +194,7 @@ static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type, } static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t *dst, - uint8_t *src, uint8_t *top, int size, int bpp) + const uint8_t *src, const uint8_t *top, int size, int bpp) { int pred = s->filter_type; av_assert0(bpp || !pred); @@ -486,7 +486,7 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict) const AVFrame *const p = pict; int y, len, ret; int row_size, pass_row_size; - uint8_t *ptr, *top, *crow_buf, *crow; + uint8_t *top, *crow_buf, *crow; uint8_t *crow_base = NULL; uint8_t *progressive_buf = NULL; uint8_t *top_buf = NULL; @@ -523,7 +523,7 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict) top = NULL; for (y = 0; y < pict->height; y++) if ((ff_png_pass_ymask[pass] << (y & 7)) & 0x80) { - ptr = p->data[0] + y * p->linesize[0]; + const uint8_t *ptr = p->data[0] + y * p->linesize[0]; FFSWAP(uint8_t *, progressive_buf, top_buf); png_get_interlaced_row(progressive_buf, pass_row_size, s->bits_per_pixel, pass, @@ -536,9 +536,9 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict) } } } else { - top = NULL; + const uint8_t *top = NULL; for (y = 0; y < pict->height; y++) { - ptr = p->data[0] + y * p->linesize[0]; + const uint8_t *ptr = p->data[0] + y * p->linesize[0]; crow = png_choose_filter(s, crow_buf, ptr, top, row_size, s->bits_per_pixel >> 3); png_write_row(avctx, crow, row_size + 1); @@ -723,7 +723,7 @@ static int apng_do_inverse_blend(AVFrame *output, const AVFrame *input, } for (y = topmost_y; y < bottommost_y; ++y) { - uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x; + const uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x; uint8_t *background = output->data[0] + output_linesize * y + bpp * leftmost_x; output_data = output->data[0] + output_linesize * (y - topmost_y); for (x = leftmost_x; x < rightmost_x; ++x, foreground += bpp, background += bpp, output_data += bpp) { diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 9de63b400f..b16c93c88f 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -40,7 +40,6 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, PHMEncContext *s = avctx->priv_data; uint8_t *bytestream, *bytestream_start, *bytestream_end; int i, h, h1, c, n, linesize, ret; - uint8_t *ptr, *ptr1, *ptr2; int size = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); @@ -135,9 +134,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if ((avctx->pix_fmt == AV_PIX_FMT_GBRPF32LE || avctx->pix_fmt == AV_PIX_FMT_GBRPF32BE) && c == 'F') { - float *r = (float *)p->data[2]; - float *g = (float *)p->data[0]; - float *b = (float *)p->data[1]; + const float *r = (const float *)p->data[2]; + const float *g = (const float *)p->data[0]; + const float *b = (const float *)p->data[1]; for (int i = 0; i < avctx->height; i++) { for (int j = 0; j < avctx->width; j++) { @@ -164,9 +163,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, g += p->linesize[0] / 4; } } else if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'H') { - float *r = (float *)p->data[2]; - float *g = (float *)p->data[0]; - float *b = (float *)p->data[1]; + const float *r = (const float *)p->data[2]; + const float *g = (const float *)p->data[0]; + const float *b = (const float *)p->data[1]; for (int i = 0; i < avctx->height; i++) { for (int j = 0; j < avctx->width; j++) { @@ -192,7 +191,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, g += p->linesize[0] / 4; } } else { - ptr = p->data[0]; + const uint8_t *ptr = p->data[0]; linesize = p->linesize[0]; for (i = 0; i < h; i++) { memcpy(bytestream, ptr, n); @@ -202,10 +201,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) { + const uint8_t *ptr1 = p->data[1], *ptr2 = p->data[2]; h >>= 1; n >>= 1; - ptr1 = p->data[1]; - ptr2 = p->data[2]; for (i = 0; i < h; i++) { memcpy(bytestream, ptr1, n); bytestream += n; diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 95c0f1c244..cfc735bcec 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -305,7 +305,7 @@ static void encode_ac_coeffs(PutBitContext *pb, } } -static void get(uint8_t *pixels, int stride, int16_t* block) +static void get(const uint8_t *pixels, int stride, int16_t* block) { int i; @@ -317,13 +317,13 @@ static void get(uint8_t *pixels, int stride, int16_t* block) } } -static void fdct_get(FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t* block) +static void fdct_get(FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t* block) { get(pixels, stride, block); fdsp->fdct(block); } -static void calc_plane_dct(FDCTDSPContext *fdsp, uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422) +static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422) { int16_t *block; int i; @@ -473,7 +473,7 @@ static av_always_inline int encode_alpha_slice_data(AVCodecContext *avctx, int8_ } } -static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsigned y, +static inline void subimage_with_fill_template(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_alpha_plane, int is_interlaced, int is_top_field) @@ -521,7 +521,7 @@ static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsign } } -static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y, +static void subimage_with_fill(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field) { @@ -529,7 +529,7 @@ static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y, } /* reorganize alpha data and convert 10b -> 16b */ -static void subimage_alpha_with_fill(uint16_t *src, unsigned x, unsigned y, +static void subimage_alpha_with_fill(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field) { @@ -544,7 +544,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x, ProresContext* ctx = avctx->priv_data; int hdr_size = 6 + (ctx->need_alpha * 2); /* v data size is write when there is alpha */ int ret = 0, slice_size; - uint8_t *dest_y, *dest_u, *dest_v; + const uint8_t *dest_y, *dest_u, *dest_v; unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0, a_data_size = 0; FDCTDSPContext *fdsp = &ctx->fdsp; int tgt_bits = (mb_count * bitrate_table[avctx->profile]) >> 2; @@ -577,13 +577,13 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x, } if (unsafe) { - subimage_with_fill((uint16_t *) pic->data[0], mb_x << 4, mb_y << 4, + subimage_with_fill((const uint16_t *) pic->data[0], mb_x << 4, mb_y << 4, luma_stride, avctx->width, avctx->height, (uint16_t *) ctx->fill_y, mb_count << 4, 16, is_interlaced, is_top_field); - subimage_with_fill((uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4, + subimage_with_fill((const uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4, chroma_stride, avctx->width >> ctx->is_422, avctx->height, (uint16_t *) ctx->fill_u, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field); - subimage_with_fill((uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4, + subimage_with_fill((const uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4, chroma_stride, avctx->width >> ctx->is_422, avctx->height, (uint16_t *) ctx->fill_v, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field); @@ -640,7 +640,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x, if (ctx->need_alpha) { AV_WB16(buf + 6, v_data_size); /* write v data size only if there is alpha */ - subimage_alpha_with_fill((uint16_t *) pic->data[3], mb_x << 4, mb_y << 4, + subimage_alpha_with_fill((const uint16_t *) pic->data[3], mb_x << 4, mb_y << 4, alpha_stride, avctx->width, avctx->height, (uint16_t *) ctx->fill_a, mb_count << 4, 16, is_interlaced, is_top_field); ret = encode_alpha_slice_data(avctx, ctx->fill_a, mb_count, diff --git a/libavcodec/qoienc.c b/libavcodec/qoienc.c index 3f043872c5..110297dbda 100644 --- a/libavcodec/qoienc.c +++ b/libavcodec/qoienc.c @@ -33,7 +33,8 @@ static int qoi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t px[4] = { 0, 0, 0, 255 }; uint8_t index[64][4] = { 0 }; int64_t packet_size; - uint8_t *buf, *src; + uint8_t *buf; + const uint8_t *src; int ret, run = 0; packet_size = avctx->width * avctx->height * (channels + 1LL) + 14LL + 8LL; diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index dca6fa7197..139e5b75eb 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -47,7 +47,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, int aligned_width = FFALIGN(avctx->width, avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64); int pad = (aligned_width - avctx->width) * 4; - uint8_t *srcr_line, *srcg_line, *srcb_line; + const uint8_t *srcr_line, *srcg_line, *srcb_line; uint8_t *dst; ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0); @@ -60,9 +60,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, dst = pkt->data; for (i = 0; i < avctx->height; i++) { - uint16_t *srcr = (uint16_t *)srcr_line; - uint16_t *srcg = (uint16_t *)srcg_line; - uint16_t *srcb = (uint16_t *)srcb_line; + const uint16_t *srcr = (const uint16_t *)srcr_line; + const uint16_t *srcg = (const uint16_t *)srcg_line; + const uint16_t *srcb = (const uint16_t *)srcb_line; for (j = 0; j < avctx->width; j++) { uint32_t pixel; unsigned r = *srcr++; diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c index f01103fe11..a470f5d101 100644 --- a/libavcodec/rpzaenc.c +++ b/libavcodec/rpzaenc.c @@ -84,7 +84,7 @@ typedef struct BlockInfo { int total_blocks; } BlockInfo; -static void get_colors(uint8_t *min, uint8_t *max, uint8_t color4[4][3]) +static void get_colors(const uint8_t *min, const uint8_t *max, uint8_t color4[4][3]) { uint8_t step; @@ -135,7 +135,7 @@ static int get_block_info(BlockInfo *bi, int block) return block ? (bi->col * 4) + (bi->row * bi->rowstride * 4) : 0; } -static uint16_t rgb24_to_rgb555(uint8_t *rgb24) +static uint16_t rgb24_to_rgb555(const uint8_t *rgb24) { uint16_t rgb555 = 0; uint32_t r, g, b; @@ -154,7 +154,7 @@ static uint16_t rgb24_to_rgb555(uint8_t *rgb24) /* * Returns the total difference between two 24 bit color values */ -static int diff_colors(uint8_t *colorA, uint8_t *colorB) +static int diff_colors(const uint8_t *colorA, const uint8_t *colorB) { int tot; @@ -168,7 +168,7 @@ static int diff_colors(uint8_t *colorA, uint8_t *colorB) /* * Returns the maximum channel difference */ -static int max_component_diff(uint16_t *colorA, uint16_t *colorB) +static int max_component_diff(const uint16_t *colorA, const uint16_t *colorB) { int diff, max = 0; @@ -192,7 +192,7 @@ static int max_component_diff(uint16_t *colorA, uint16_t *colorB) * color values. Put the minimum value in min, maximum in max and the channel * in chan. */ -static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr, +static void get_max_component_diff(const BlockInfo *bi, const uint16_t *block_ptr, uint8_t *min, uint8_t *max, channel_offset *chan) { int x, y; @@ -242,7 +242,8 @@ static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr, * blocks is greater than the thresh parameter. Returns -1 if difference * exceeds threshold or zero otherwise. */ -static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int thresh) +static int compare_blocks(const uint16_t *block1, const uint16_t *block2, + const BlockInfo *bi, int thresh) { int x, y, diff = 0; for (y = 0; y < bi->block_height; y++) { @@ -262,7 +263,7 @@ static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int * Determine the fit of one channel to another within a 4x4 block. This * is used to determine the best palette choices for 4-color encoding. */ -static int leastsquares(uint16_t *block_ptr, BlockInfo *bi, +static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi, channel_offset xchannel, channel_offset ychannel, double *slope, double *y_intercept, double *correlation_coef) { @@ -315,7 +316,7 @@ static int leastsquares(uint16_t *block_ptr, BlockInfo *bi, /* * Determine the amount of error in the leastsquares fit. */ -static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi, +static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi, int min, int max, int tmp_min, int tmp_max, channel_offset xchannel, channel_offset ychannel) { @@ -356,7 +357,7 @@ static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi, /* * Find the closest match to a color within the 4-color palette */ -static int match_color(uint16_t *color, uint8_t colors[4][3]) +static int match_color(const uint16_t *color, uint8_t colors[4][3]) { int ret = 0; int smallest_variance = INT_MAX; @@ -383,8 +384,8 @@ static int match_color(uint16_t *color, uint8_t colors[4][3]) * blocks encoded (until we implement multi-block 4 color runs this will * always be 1) */ -static int encode_four_color_block(uint8_t *min_color, uint8_t *max_color, - PutBitContext *pb, uint16_t *block_ptr, BlockInfo *bi) +static int encode_four_color_block(const uint8_t *min_color, const uint8_t *max_color, + PutBitContext *pb, const uint16_t *block_ptr, const BlockInfo *bi) { int x, y, idx; uint8_t color4[4][3]; @@ -441,7 +442,7 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels, * the statistics of this block. Otherwise, the stats are unchanged * and don't include the current block. */ -static int update_block_stats(RpzaContext *s, BlockInfo *bi, uint16_t *block, +static int update_block_stats(RpzaContext *s, const BlockInfo *bi, const uint16_t *block, uint8_t min_color[3], uint8_t max_color[3], int *total_rgb, int *total_pixels, uint8_t avg_color[3], int first_block) @@ -562,7 +563,7 @@ static void rpza_encode_stream(RpzaContext *s, const AVFrame *pict) int pixel_count; uint8_t min_color[3], max_color[3]; double slope, y_intercept, correlation_coef; - uint16_t *src_pixels = (uint16_t *)pict->data[0]; + const uint16_t *src_pixels = (const uint16_t *)pict->data[0]; uint16_t *prev_pixels = (uint16_t *)s->prev_frame->data[0]; /* Number of 4x4 blocks in frame. */ @@ -728,7 +729,7 @@ post_skip : } if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK - uint16_t *row_ptr; + const uint16_t *row_ptr; int rgb555; block_offset = get_block_info(&bi, block_counter); diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 5d2cc7e3b9..7edc7cca83 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -96,7 +96,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, SgiContext *s = avctx->priv_data; const AVFrame * const p = frame; PutByteContext pbc; - uint8_t *in_buf, *encode_buf; + uint8_t *encode_buf; int x, y, z, length, tablesize, ret, i; unsigned int width, height, depth, dimension; unsigned int bytes_per_channel, pixmax, put_be; @@ -200,7 +200,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR(ENOMEM); for (z = 0; z < depth; z++) { - in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; + const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; for (y = 0; y < height; y++) { bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc)); @@ -231,7 +231,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_free(encode_buf); } else { for (z = 0; z < depth; z++) { - in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; + const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; for (y = 0; y < height; y++) { for (x = 0; x < width * depth; x += depth) diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 709fef6be5..ed0f9abb42 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -486,7 +486,7 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in } } -static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){ +static inline void init_ref(MotionEstContext *c, const uint8_t *const src[3], uint8_t *const ref[3], uint8_t *const ref2[3], int x, int y, int ref_index){ SnowContext *s = c->avctx->priv_data; const int offset[3]= { y*c-> stride + x, diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 27f5d3c941..50e03439a4 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -151,7 +151,7 @@ static av_cold int encode_init(AVCodecContext *avctx) } //near copy & paste from dsputil, FIXME -static int pix_sum(uint8_t * pix, int line_size, int w, int h) +static int pix_sum(const uint8_t * pix, int line_size, int w, int h) { int s, i, j; @@ -167,7 +167,7 @@ static int pix_sum(uint8_t * pix, int line_size, int w, int h) } //near copy & paste from dsputil, FIXME -static int pix_norm1(uint8_t * pix, int line_size, int w) +static int pix_norm1(const uint8_t * pix, int line_size, int w) { int s, i, j; const uint32_t *sq = ff_square_tab + 256; @@ -245,7 +245,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){ int l,cr,cb; const int stride= s->current_picture->linesize[0]; const int uvstride= s->current_picture->linesize[1]; - uint8_t *current_data[3]= { s->input_picture->data[0] + (x + y* stride)*block_w, + const uint8_t *current_data[3] = { s->input_picture->data[0] + (x + y* stride)*block_w, s->input_picture->data[1] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift), s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)}; int P[10][2]; @@ -508,7 +508,7 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){ const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth]; const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int ref_stride= s->current_picture->linesize[plane_index]; - uint8_t *src= s-> input_picture->data[plane_index]; + const uint8_t *src = s-> input_picture->data[plane_index]; IDWTELEM *dst= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned const int b_stride = s->b_width << s->block_max_depth; const int w= p->width; @@ -603,7 +603,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int ref_stride= s->current_picture->linesize[plane_index]; uint8_t *dst= s->current_picture->data[plane_index]; - uint8_t *src= s-> input_picture->data[plane_index]; + const uint8_t *src = s->input_picture->data[plane_index]; IDWTELEM *pred= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; uint8_t *cur = s->scratchbuf; uint8_t *tmp = s->emu_edge_buffer; @@ -706,7 +706,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int ref_stride= s->current_picture->linesize[plane_index]; uint8_t *dst= s->current_picture->data[plane_index]; - uint8_t *src= s-> input_picture->data[plane_index]; + const uint8_t *src = s-> input_picture->data[plane_index]; //FIXME zero_dst is const but add_yblock changes dst if add is 0 (this is never the case for dst=zero_dst // const has only been removed from zero_dst to suppress a warning static IDWTELEM zero_dst[4096]; //FIXME @@ -1076,7 +1076,7 @@ static void iterative_me(SnowContext *s){ //skip stuff outside the picture if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){ - uint8_t *src= s-> input_picture->data[0]; + const uint8_t *src = s-> input_picture->data[0]; uint8_t *dst= s->current_picture->data[0]; const int stride= s->current_picture->linesize[0]; const int block_w= MB_SIZE >> s->block_max_depth; diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index f188111699..e5216a99cd 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -248,7 +248,7 @@ static void init_block_index(MpegEncContext *s){ } static int svq1_encode_plane(SVQ1EncContext *s, int plane, - unsigned char *src_plane, + const unsigned char *src_plane, unsigned char *ref_plane, unsigned char *decoded_plane, int width, int height, int src_stride, int stride) @@ -371,7 +371,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, int count[2][6]; int offset = y * 16 * stride + x * 16; uint8_t *decoded = decoded_plane + offset; - uint8_t *ref = ref_plane + offset; + const uint8_t *ref = ref_plane + offset; int score[4] = { 0, 0, 0, 0 }, best; uint8_t *temp = s->scratchbuf; diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index f439ba0dc6..7fb8e28c85 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -72,7 +72,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int { int i, n = bpp * w; uint8_t *out = outbuf; - uint8_t *ptr = pic->data[0]; + const uint8_t *ptr = pic->data[0]; for(i=0; i < h; i++) { memcpy(out, ptr, n); diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 7228f66e2d..dba0e89640 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -207,8 +207,8 @@ static void pack_yuv(TiffEncoderContext *s, const AVFrame *p, { int i, j, k; int w = (s->width - 1) / s->subsampling[0] + 1; - uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; - uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; + const uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; + const uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) { for (i = 0; i < w; i++) { for (j = 0; j < s->subsampling[1]; j++) diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 2c1189ed07..f38db96e51 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -277,7 +277,7 @@ static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride, #undef B /* Write data to a plane with median prediction */ -static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, +static void median_predict(UtvideoContext *c, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height) { int i, j; @@ -376,7 +376,7 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, return put_bytes_output(&pb); } -static int encode_plane(AVCodecContext *avctx, uint8_t *src, +static int encode_plane(AVCodecContext *avctx, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int plane_no, int width, int height, PutByteContext *pb) { diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c index bd73b2e95a..c6a270a883 100644 --- a/libavcodec/v308enc.c +++ b/libavcodec/v308enc.c @@ -43,7 +43,7 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { uint8_t *dst; - uint8_t *y, *u, *v; + const uint8_t *y, *u, *v; int i, j, ret; ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0); diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c index c53fa4e2a4..77d2b026b3 100644 --- a/libavcodec/v408enc.c +++ b/libavcodec/v408enc.c @@ -40,7 +40,7 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { uint8_t *dst; - uint8_t *y, *u, *v, *a; + const uint8_t *y, *u, *v, *a; int i, j, ret; ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index a78402c054..f08ccb2147 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -44,7 +44,7 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { uint8_t *dst; - uint16_t *y, *u, *v; + const uint16_t *y, *u, *v; uint32_t val; int i, j, ret; diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index ea33005114..c93b4e37be 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -116,7 +116,7 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE; avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count); } else { - uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); + const uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height); } diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index f776d25b91..e1fd5fa608 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -117,7 +117,7 @@ typedef struct SliceArgs { typedef struct TransformArgs { void *ctx; Plane *plane; - void *idata; + const void *idata; ptrdiff_t istride; int field; VC2TransformContext t; diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 02572d6796..03a5d788c8 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -110,7 +110,7 @@ static av_cold int encode_init(AVCodecContext *avctx) static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame) { WMACodecContext *s = avctx->priv_data; - float **audio = (float **) frame->extended_data; + const float *const *audio = (const float *const *) frame->extended_data; int len = frame->nb_samples; int window_index = s->frame_len_bits - s->block_len_bits; FFTContext *mdct = &s->mdct_ctx[window_index]; diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index 60fb169457..8369f5370c 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -32,7 +32,8 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { int i, j, l, commas, ret, size, linesize, lineout, rowsout; - uint8_t *ptr, *buf; + const uint8_t *ptr; + uint8_t *buf; linesize = lineout = (avctx->width + 7) / 8; commas = avctx->height * linesize; diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index a28fca08e0..01c43c1d81 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -39,7 +39,8 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint32_t rgb[3] = { 0 }, bitorder = 0; uint32_t header_size; int i, out_size, ret; - uint8_t *ptr, *buf; + const uint8_t *ptr; + uint8_t *buf; uint32_t pal[256]; pixdepth = av_get_bits_per_pixel(desc); diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c index 77864909a1..f7ac58c30e 100644 --- a/libavcodec/y41penc.c +++ b/libavcodec/y41penc.c @@ -42,7 +42,7 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { uint8_t *dst; - uint8_t *y, *u, *v; + const uint8_t *y, *u, *v; int i, j, ret; ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 1.5, 0); diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c index 8d72382197..94e9b5dc1b 100644 --- a/libavcodec/yuv4enc.c +++ b/libavcodec/yuv4enc.c @@ -28,7 +28,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { uint8_t *dst; - uint8_t *y, *u, *v; + const uint8_t *y, *u, *v; int i, j, ret; ret = ff_get_encode_buffer(avctx, pkt, 6 * (avctx->width + 1 >> 1) diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index c63f411eb5..cc8578afea 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -84,8 +84,8 @@ typedef struct ZmbvEncContext { /** Block comparing function * XXX should be optimized and moved to DSPContext */ -static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride, - uint8_t *src2, int stride2, int bw, int bh, +static inline int block_cmp(ZmbvEncContext *c, const uint8_t *src, int stride, + const uint8_t *src2, int stride2, int bw, int bh, int *xored) { int sum = 0; @@ -119,7 +119,7 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride, /** Motion estimation function * TODO make better ME decisions */ -static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, +static int zmbv_me(ZmbvEncContext *c, const uint8_t *src, int sstride, const uint8_t *prev, int pstride, int x, int y, int *mx, int *my, int *xored) { int dx, dy, txored, tv, bv, bw, bh; @@ -171,7 +171,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ZmbvEncContext * const c = avctx->priv_data; z_stream *const zstream = &c->zstream.zstream; const AVFrame * const p = pict; - uint8_t *src, *prev, *buf; + const uint8_t *src; + uint8_t *prev, *buf; uint32_t *palptr; int keyframe, chpal; int fl; @@ -218,7 +219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } }else{ int x, y, bh2, bw2, xored; - uint8_t *tsrc, *tprev; + const uint8_t *tsrc, *tprev; uint8_t *mv; int mx = 0, my = 0;