diff mbox series

[FFmpeg-devel,14/14] avcodec/elbg: Mark ELBGContext as being unaliased by using av_restrict

Message ID AM7PR03MB66603EB53A32C839D46744908FA09@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit bb98212930721f223fb77f25c3c9e016640f9c9b
Headers show
Series [FFmpeg-devel,01/13] avcodec/elbg: Remove avoidable buffer | expand

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch

Commit Message

Andreas Rheinhardt Sept. 20, 2021, 9:18 p.m. UTC
This improves performance: For msvideo1, the performance improved by
4.8% when encoding the sample from the fate-vsynth1-msvideo1 test;
when encoding the sample from fate-vsynth1-cinepak, performance
improved by 2%. The compiler user was GCC 10 and the calls to encode2
have been timed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/elbg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Tomas Härdin Sept. 23, 2021, 7:35 p.m. UTC | #1
mån 2021-09-20 klockan 23:18 +0200 skrev Andreas Rheinhardt:
> This improves performance: For msvideo1, the performance improved by
> 4.8% when encoding the sample from the fate-vsynth1-msvideo1 test;
> when encoding the sample from fate-vsynth1-cinepak, performance
> improved by 2%. The compiler user was GCC 10 and the calls to encode2
> have been timed.

Median wall time for three cinepak runs went from 1m36,455s to
1m35,251s. Not a huge difference. Not worse anyway.

/Tomas
diff mbox series

Patch

diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 712c125a58..d97a7bc3f9 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -346,7 +346,7 @@  static void do_shiftings(ELBGContext *elbg)
         }
 }
 
-static void do_elbg(ELBGContext *elbg, int *points, int numpoints,
+static void do_elbg(ELBGContext *av_restrict elbg, int *points, int numpoints,
                     int max_steps)
 {
     int *const size_part = elbg->size_part;
@@ -419,7 +419,7 @@  static void do_elbg(ELBGContext *elbg, int *points, int numpoints,
  * If not, it calls do_elbg for a (smaller) random sample of the points in
  * points.
  */
-static void init_elbg(ELBGContext *elbg, int *points, int *temp_points,
+static void init_elbg(ELBGContext *av_restrict elbg, int *points, int *temp_points,
                       int numpoints, int max_steps)
 {
     int dim = elbg->dim;
@@ -447,7 +447,7 @@  int avpriv_elbg_do(ELBGContext **elbgp, int *points, int dim, int numpoints,
                    int *codebook, int num_cb, int max_steps,
                    int *closest_cb, AVLFG *rand_state, uintptr_t flags)
 {
-    ELBGContext *const elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg));
+    ELBGContext *const av_restrict elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg));
 
     if (!elbg)
         return AVERROR(ENOMEM);