summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc_utils.h
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-10-08 01:47:04 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2016-10-12 11:15:49 +0100
commit230178dfe25ebe27934062c9fa8e2a40e6ad2b0b (patch)
tree9815d504a8744bccf622d80ad2ed4de1f1b62284 /libavcodec/aacenc_utils.h
parentcfa3c2655ac2bafe7b76f1e68c8fe6ecee03f1a8 (diff)
downloadffmpeg-230178dfe25ebe27934062c9fa8e2a40e6ad2b0b.tar.gz
aacenc: use the decoder's lcg PRNG
Using lfg was an overkill in this case where the random numbers were only used for encoder descisions. Should increase result uniformity between different FPUs and gives a slight speedup. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/aacenc_utils.h')
-rw-r--r--libavcodec/aacenc_utils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index bb1dcb4361..ff9188aee3 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -252,6 +252,19 @@ static inline int ff_sfdelta_can_replace(const SingleChannelElement *sce,
&& sce->sf_idx[nextband[band]] <= (new_sf + SCALE_MAX_DIFF);
}
+/**
+ * linear congruential pseudorandom number generator
+ *
+ * @param previous_val pointer to the current state of the generator
+ *
+ * @return Returns a 32-bit pseudorandom integer
+ */
+static av_always_inline int lcg_random(unsigned previous_val)
+{
+ union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 };
+ return v.s;
+}
+
#define ERROR_IF(cond, ...) \
if (cond) { \
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \