From patchwork Thu Dec 10 11:16:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24483 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 1499F44AF7C for ; Thu, 10 Dec 2020 13:19:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB81E68A64D; Thu, 10 Dec 2020 13:19:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF62D68A0D3 for ; Thu, 10 Dec 2020 13:19:04 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id l9so5042678wrt.13 for ; Thu, 10 Dec 2020 03:19:04 -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:reply-to :mime-version:content-transfer-encoding; bh=0RNefyFQ6HFFh1j60AlhJpCIlBWXGDfKjk421ogySCk=; b=ZAowZy0iNJvIAgILZMYtpnlqSZNPInR2E4oCmRw0TTCY0navYD/059+Ina6vGkGrRP DFsLRf4toyeN136YwZ/sWR3lVgvTH+oJij2YyBpZdCmDVYKbIjG0zDiI8CXaIqz7RVan SJBtU2ftWLzmmd7Ty8IZk3DneOQcUbF/IEXHelQgBNFeZSrrfs5Xvf3TZnMcTUtsytvQ lcay2qtxlz6L+4tT4/gd7jI+SyedKUr902ke5bWf+sLmWRwJlSu6C931rVUFRNTyON8t FTsfjoeL0BELRmXjv+3qF+ew6hkY/pCWQ9dTs5gwcVQ30DHfxLVBjlkdEYcFyU3Q1eZ8 nIYA== 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:reply-to:mime-version:content-transfer-encoding; bh=0RNefyFQ6HFFh1j60AlhJpCIlBWXGDfKjk421ogySCk=; b=L51mr+4gfkc0cYvA26HqtEHSkaAVHBRaF1qgNh483sFZx5Nsozdk6qaVghT4RkifJ7 3giYRX6mvsec56tgLiOvVd/qG2EbD8dNpyVVAWkYCv2GXgMnL/2USkvcK59hrEJvWQC8 xNE/xt/ECFQ3MgmgmC66kRRBh35EhCWgRQg2EMWt3jjdWZR8sLmDENalX2rEgGrACNlI GnAmFoUrypJOjp3anr95mxL8jXY22/BUGHp6KTpBwuqL2mYy64kNfAwMBuHWWBW/oZOv epte+kC9xTquo9lNLy8guZsnWFLlpHjMYhm+OqrA2OfZjPoSR9Bx8U5PofNCDoUsbmFs mbog== X-Gm-Message-State: AOAM533mwnreFAUBaEJ1PUWUkLeELmfaLIDTSxxmvVOtKlrzQ4zJQDF5 iYogip7DrCvccPaG0SCE+zi/dVjgZR3xXQ== X-Google-Smtp-Source: ABdhPJyfL/Fhd6wLFu8BhP10uvRv1btyqIfUbQlXsTpBRArfUrlFg97pDb52/C1/iWKZw0vF+QCTMg== X-Received: by 2002:a5d:510d:: with SMTP id s13mr7783510wrt.380.1607599143918; Thu, 10 Dec 2020 03:19:03 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id s133sm8942330wmf.38.2020.12.10.03.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:19:03 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:16:36 +0100 Message-Id: <20201210111657.2276739-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> References: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/39] avcodec/motion_est, mpegvideo: Make pointers to static storage const 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" Modifying static storage must not happen because of multithreading (except initialization of course), so add const to the pointed-to type for pointers that point to static storage. Signed-off-by: Andreas Rheinhardt --- libavcodec/motion_est.c | 12 ++++++------ libavcodec/motion_est.h | 4 ++-- libavcodec/motion_est_template.c | 2 +- libavcodec/mpegvideo.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 02c75fd470..5a339fc1c7 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -578,7 +578,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) int dmin_sum=0, mx4_sum=0, my4_sum=0, i; int same=1; const int stride= c->stride; - uint8_t *mv_penalty= c->current_mv_penalty; + const uint8_t *mv_penalty = c->current_mv_penalty; int safety_clipping= s->unrestricted_mv && (s->width&15) && (s->height&15); init_mv4_ref(c); @@ -743,7 +743,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index, const int h=8; int block; int P[10][2]; - uint8_t * const mv_penalty= c->current_mv_penalty; + const uint8_t * const mv_penalty = c->current_mv_penalty; int same=1; const int stride= 2*s->linesize; int dmin_sum= 0; @@ -1120,7 +1120,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, const int shift= 1+s->quarter_sample; const int mot_stride = s->mb_stride; const int mot_xy = mb_y*mot_stride + mb_x; - uint8_t * const mv_penalty= c->mv_penalty[f_code] + MAX_DMV; + const uint8_t * const mv_penalty = c->mv_penalty[f_code] + MAX_DMV; int mv_scale; c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); @@ -1184,8 +1184,8 @@ static inline int check_bidir_mv(MpegEncContext * s, //FIXME better f_code prediction (max mv & distance) //FIXME pointers MotionEstContext * const c= &s->me; - uint8_t * const mv_penalty_f= c->mv_penalty[s->f_code] + MAX_DMV; // f_code of the prev frame - uint8_t * const mv_penalty_b= c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame + const uint8_t * const mv_penalty_f = c->mv_penalty[s->f_code] + MAX_DMV; // f_code of the prev frame + const uint8_t * const mv_penalty_b = c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame int stride= c->stride; uint8_t *dest_y = c->scratchpad; uint8_t *ptr; @@ -1600,7 +1600,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) if (s->motion_est != FF_ME_ZERO) { int score[8]; int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2); - uint8_t * fcode_tab= s->fcode_tab; + const uint8_t * fcode_tab = s->fcode_tab; int best_fcode=-1; int best_score=-10000000; diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h index 817220f340..5742e51486 100644 --- a/libavcodec/motion_est.h +++ b/libavcodec/motion_est.h @@ -90,8 +90,8 @@ typedef struct MotionEstContext { op_pixels_func(*hpel_avg)[4]; qpel_mc_func(*qpel_put)[16]; qpel_mc_func(*qpel_avg)[16]; - uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV - uint8_t *current_mv_penalty; + const uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV + const uint8_t *current_mv_penalty; int (*sub_motion_search)(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 13e73f2653..d3b2f97744 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -34,7 +34,7 @@ const int av_unused ymin= c->ymin;\ const int av_unused xmax= c->xmax;\ const int av_unused ymax= c->ymax;\ - uint8_t *mv_penalty= c->current_mv_penalty;\ + const uint8_t *mv_penalty = c->current_mv_penalty; \ const int pred_x= c->pred_x;\ const int pred_y= c->pred_y;\ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index aa84449c2d..5f6e1da133 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -276,7 +276,7 @@ typedef struct MpegEncContext { int mv[2][4][2]; int field_select[2][2]; int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4 - uint8_t *fcode_tab; ///< smallest fcode needed for each MV + const uint8_t *fcode_tab; ///< smallest fcode needed for each MV int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv MotionEstContext me;