From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/pngdsp: Fix unaligned accesses, effective type violations Date: Fri, 29 Mar 2024 04:24:27 +0100 Message-ID: <GV1P250MB0737D370417DDB5BBD2413048F3A2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <GV1P250MB07377A6CF76BB88E41854D698F3A2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> Affected the lscr fate-test (only visible on x86 if the SSE2 is disabled). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/pngdsp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavcodec/pngdsp.c b/libavcodec/pngdsp.c index 65916b1386..50ee96a684 100644 --- a/libavcodec/pngdsp.c +++ b/libavcodec/pngdsp.c @@ -21,20 +21,33 @@ #include "config.h" #include "libavutil/attributes.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/macros.h" #include "png.h" #include "pngdsp.h" +#if HAVE_FAST_64BIT +#define BITS 64 +typedef uint64_t uint_native; +#else +#define BITS 32 +typedef uint32_t uint_native; +#endif +#define RN AV_JOIN(AV_RN, BITS) +#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A) +#define WN AV_JOIN(AV_WN, BITS) + // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size -#define pb_7f (~0UL / 255 * 0x7f) -#define pb_80 (~0UL / 255 * 0x80) +#define pb_7f (~(uint_native)0 / 255 * 0x7f) +#define pb_80 (~(uint_native)0 / 255 * 0x80) static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) { long i; - for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) { - long a = *(long *)(src1 + i); - long b = *(long *)(src2 + i); - *(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); + for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) { + uint_native a = RNA(src1 + i); + uint_native b = RN (src2 + i); + WN(dst + i, ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80)); } for (; i < w; i++) dst[i] = src1[i] + src2[i]; -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-03-29 3:24 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-29 3:23 [FFmpeg-devel] [PATCH 1/5] avcodec/ppc/hpeldsp_altivec: Fix left-shift of negative number Andreas Rheinhardt 2024-03-29 3:24 ` [FFmpeg-devel] [PATCH 2/5] fate/ffmpeg: Explicitly set pix fmt for sub2video tests Andreas Rheinhardt 2024-03-29 14:28 ` Sean McGovern 2024-03-29 14:45 ` Andreas Rheinhardt 2024-03-29 3:24 ` Andreas Rheinhardt [this message] 2024-03-29 3:24 ` [FFmpeg-devel] [PATCH 4/5] avfilter/vf_spp: Fix left-shift of negative value Andreas Rheinhardt 2024-03-29 3:24 ` [FFmpeg-devel] [PATCH 5/5] avcodec/huffyuvencdsp: Fix load of misaligned values Andreas Rheinhardt 2024-03-29 16:45 ` [FFmpeg-devel] [PATCH 6/6] fate/image: Fix EXR tests on big endian Andreas Rheinhardt 2024-03-30 18:28 ` Sean McGovern 2024-03-29 18:07 ` [FFmpeg-devel] [PATCH 7/7] fate/video: Only use bitexact IDCT in avid meridian Andreas Rheinhardt 2024-03-29 18:11 ` [FFmpeg-devel] [PATCH 8/8] fate/filter-video: Always use little endian pixel format Andreas Rheinhardt 2024-03-29 18:26 ` [FFmpeg-devel] [PATCH 9/9] fate/filter-video: Insert scale, format filters in filter-yadif tests Andreas Rheinhardt 2024-03-29 18:45 ` [FFmpeg-devel] [PATCH v2 9/9] fate/filter-video: Insert scale, format filters in filter-yadif, bwdif10 Andreas Rheinhardt 2024-03-30 3:15 ` [FFmpeg-devel] [PATCH 10/12] fate/fits: Fix tests on BE Andreas Rheinhardt 2024-03-30 3:15 ` [FFmpeg-devel] [PATCH 11/12] avcodec/vlc, bitstream: Fix multi VLC with uint8_t syms " Andreas Rheinhardt 2024-03-30 3:15 ` [FFmpeg-devel] [PATCH 12/12] avcodec/vlc: Use union of uint8_t and uint16_t in VLC_MULTI_ELEM Andreas Rheinhardt 2024-03-30 3:39 ` [FFmpeg-devel] [PATCH v2 " Andreas Rheinhardt 2024-04-01 18:41 ` [FFmpeg-devel] [PATCH 1/5] avcodec/ppc/hpeldsp_altivec: Fix left-shift of negative number Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=GV1P250MB0737D370417DDB5BBD2413048F3A2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git