aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-02 00:20:04 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-21 19:13:06 +0100
commitb3473841731eebf5c32077f931334820316f16c6 (patch)
tree387fe2562519ea7e4517848d531d843ae6657e98
parent1f9ef2f3cf0812c9ad3e3055946673375c982cac (diff)
downloadffmpeg-b3473841731eebf5c32077f931334820316f16c6.tar.gz
avcodec/me_cmp: Remove ff_check_alignment()
The usage of a static variable presents a potential for data races and means that this function can't be used in init functions of codecs with FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that everything is alright in which case the error is not triggered; but then the whole function is pointless...). This makes the Snow decoder init-threadsafe as it already claims. Notice that this function has been removed in 2014 by Libav in commit 9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths are checked this way and because it only affects legacy compilers. The latter is of course even more true today. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/me_cmp.c23
-rw-r--r--libavcodec/me_cmp.h2
-rw-r--r--libavcodec/mpegvideo_enc.c6
3 files changed, 0 insertions, 31 deletions
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index ba72468240..60545248b3 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -1012,31 +1012,8 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
WRAPPER8_16_SQ(rd8x8_c, rd16_c)
WRAPPER8_16_SQ(bit8x8_c, bit16_c)
-int ff_check_alignment(void)
-{
- static int did_fail = 0;
- LOCAL_ALIGNED_16(int, aligned, [4]);
-
- if ((intptr_t)aligned & 15) {
- if (!did_fail) {
-#if HAVE_MMX || HAVE_ALTIVEC
- av_log(NULL, AV_LOG_ERROR,
- "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
- "and may be very slow or crash. This is not a bug in libavcodec,\n"
- "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
- "Do not report crashes to FFmpeg developers.\n");
-#endif
- did_fail=1;
- }
- return -1;
- }
- return 0;
-}
-
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
{
- ff_check_alignment();
-
c->sum_abs_dctelem = sum_abs_dctelem_c;
/* TODO [0] 16 [1] 8 */
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 0a589e3c3d..e9b5161c9a 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -79,8 +79,6 @@ typedef struct MECmpContext {
me_cmp_func median_sad[6];
} MECmpContext;
-int ff_check_alignment(void);
-
void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx);
void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx);
void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 25d9004199..7db042e5fe 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2786,8 +2786,6 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
static int estimate_motion_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
- ff_check_alignment();
-
s->me.dia_size= s->avctx->dia_size;
s->first_slice_line=1;
for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
@@ -2814,8 +2812,6 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
int mb_x, mb_y;
- ff_check_alignment();
-
for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xx = mb_x * 16;
@@ -2944,8 +2940,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
- ff_check_alignment();
-
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);