Files
Andreas Rheinhardt 7637009f02 avcodec/x86/diracdsp_init: Avoid cast
put_signed_rect_clamped uses different types for differnt
8bit and >8bit content. The 8bit SSE2 function used the real
type in its function signature; this does not coincide with
the array of function pointers it gets put into and therefore
also not with how it is called which is UB. Also, casts of
function pointers to void* like it is done here are not
legal ISO-C as function pointers and object pointers need not
be convertible.

So just declare the function to have the required type for
the function pointer array.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:28:59 +02:00

115 lines
5.7 KiB
C

/*
* Copyright (C) 2010 David Conrad
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/x86/cpu.h"
#include "libavcodec/diracdsp.h"
#include "fpel.h"
void ff_add_rect_clamped_sse2(uint8_t *dst, const uint16_t *src, ptrdiff_t stride,
const int16_t *idwt, ptrdiff_t idwt_stride,
int width, int height);
void ff_add_dirac_obmc8_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride,
const uint8_t *obmc_weight, int yblen);
void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride,
const uint8_t *obmc_weight, int yblen);
void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, ptrdiff_t stride,
const uint8_t *obmc_weight, int yblen);
void ff_put_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src,
ptrdiff_t src_stride, int width, int height);
void ff_put_signed_rect_clamped_sse2(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src,
ptrdiff_t src_stride, int width, int height);
void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src,
ptrdiff_t src_stride, int width, int height);
void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h);
#define HPEL_FILTER(MMSIZE, EXT) \
void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *dst, const uint8_t *src, \
ptrdiff_t stride, int width); \
void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *dst, const uint8_t *src, int width); \
\
static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
const uint8_t *src, ptrdiff_t stride, int width, int height) \
{ \
while( height-- ) \
{ \
ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \
ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \
\
dsth += stride; \
dstv += stride; \
dstc += stride; \
src += stride; \
} \
}
#define DIRAC_PIXOP(OPNAME, EXT)\
static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
ptrdiff_t stride, int h) \
{\
if (h&3)\
ff_ ## OPNAME ## _dirac_pixels16_c(dst, src, stride, h);\
else\
ff_ ## OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
}\
static void OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
ptrdiff_t stride, int h) \
{\
if (h&3) {\
ff_ ## OPNAME ## _dirac_pixels32_c(dst, src, stride, h);\
} else {\
ff_ ## OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\
ff_ ## OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
}\
}
DIRAC_PIXOP(put, sse2)
DIRAC_PIXOP(avg, sse2)
HPEL_FILTER(16, sse2)
void ff_diracdsp_init_x86(DiracDSPContext* c)
{
int mm_flags = av_get_cpu_flags();
if (EXTERNAL_SSE2(mm_flags)) {
c->dirac_hpel_filter = dirac_hpel_filter_sse2;
c->add_rect_clamped = ff_add_rect_clamped_sse2;
c->put_signed_rect_clamped[0] = ff_put_signed_rect_clamped_sse2;
c->add_dirac_obmc[0] = ff_add_dirac_obmc8_sse2;
c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
c->put_dirac_pixels_tab[1][0] = put_dirac_pixels16_sse2;
c->avg_dirac_pixels_tab[1][0] = avg_dirac_pixels16_sse2;
c->put_dirac_pixels_tab[2][0] = put_dirac_pixels32_sse2;
c->avg_dirac_pixels_tab[2][0] = avg_dirac_pixels32_sse2;
}
if (EXTERNAL_SSE4(mm_flags)) {
c->dequant_subband[1] = ff_dequant_subband_32_sse4;
c->put_signed_rect_clamped[1] = ff_put_signed_rect_clamped_10_sse4;
}
}