Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-15 23:38:28 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-20 05:09:22 +0300
commit05ccfcb7b0ea326a112b1f769588c07bf0e467be (patch)
tree574ffd4e010c57d6e81cb1ed0a026419bfdbbd5e /libavcodec/elbg.c
parentd046e76515d8f30e2960e4888478002852bf0209 (diff)
avcodec/elbg: Merge avpriv_init_elbg() into avpriv_do_elbg()
These functions are always called directly after another with the exact same arguments. This avoids exporting a symbol; it also avoids having to perform two calls for every caller. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/elbg.c')
-rw-r--r--libavcodec/elbg.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 3ca67b400c..b563254bbc 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -332,7 +332,7 @@ static void do_shiftings(elbg_data *elbg)
}
}
-int avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
+static int do_elbg(int *points, int dim, int numpoints, int *codebook,
int numCB, int max_steps, int *closest_cb,
AVLFG *rand_state)
{
@@ -426,7 +426,14 @@ out:
#define BIG_PRIME 433494437LL
-int avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook,
+/**
+ * Initialize the codebook vector for the elbg algorithm.
+ * If numpoints < 8*numCB this function fills codebook with random numbers.
+ * If not, it calls do_elbg for a (smaller) random sample of the points in
+ * points.
+ * @return < 0 in case of error, 0 otherwise
+ */
+static int init_elbg(int *points, int dim, int numpoints, int *codebook,
int num_cb, int max_steps, int *closest_cb,
AVLFG *rand_state)
{
@@ -443,13 +450,13 @@ int avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook,
memcpy(temp_points + i*dim, points + k*dim, dim * sizeof(*temp_points));
}
- ret = avpriv_init_elbg(temp_points, dim, numpoints / 8, codebook,
+ ret = init_elbg(temp_points, dim, numpoints / 8, codebook,
num_cb, 2 * max_steps, closest_cb, rand_state);
if (ret < 0) {
av_freep(&temp_points);
return ret;
}
- ret = avpriv_do_elbg(temp_points, dim, numpoints / 8, codebook,
+ ret = do_elbg (temp_points, dim, numpoints / 8, codebook,
num_cb, 2 * max_steps, closest_cb, rand_state);
av_free(temp_points);
} else // If not, initialize the codebook with random positions
@@ -458,3 +465,17 @@ int avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook,
dim * sizeof(*codebook));
return ret;
}
+
+int avpriv_do_elbg(int *points, int dim, int numpoints,
+ int *codebook, int num_cb, int max_steps,
+ int *closest_cb, AVLFG *rand_state)
+{
+ int ret;
+
+ ret = init_elbg(points, dim, numpoints, codebook,
+ num_cb, max_steps, closest_cb, rand_state);
+ if (ret < 0)
+ return ret;
+ return do_elbg (points, dim, numpoints, codebook,
+ num_cb, max_steps, closest_cb, rand_state);
+}