mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avcodec/vvc/vvc_ps: Use union for luts to avoid unaligned accesses
These arrays are currently accessed via uint16_t* pointers although nothing guarantees their alignment. Furthermore, this is problematic wrt the effective-type rules. Fix this by using a union of arrays of uint8_t and uint16_t. Reviewed-by: Nuo Mi <nuomi2021@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
1eafbc27e2
commit
ef04737e18
@ -1328,5 +1328,5 @@ void ff_vvc_lmcs_filter(const VVCLocalContext *lc, const int x, const int y)
|
||||
const int height = FFMIN(fc->ps.pps->height - y, ctb_size);
|
||||
uint8_t *data = fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift);
|
||||
if (sc->sh.r->sh_lmcs_used_flag)
|
||||
fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, fc->ps.lmcs.inv_lut);
|
||||
fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, &fc->ps.lmcs.inv_lut);
|
||||
}
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
#include "libavcodec/h26x/h2656_sao_template.c"
|
||||
|
||||
static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const uint8_t *_lut)
|
||||
static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const void *_lut)
|
||||
{
|
||||
const pixel *lut = (const pixel *)_lut;
|
||||
const pixel *lut = _lut;
|
||||
pixel *dst = (pixel*)_dst;
|
||||
dst_stride /= sizeof(pixel);
|
||||
|
||||
|
@ -571,7 +571,7 @@ static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int v
|
||||
const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
|
||||
fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 0);
|
||||
if (sc->sh.r->sh_lmcs_used_flag)
|
||||
fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, fc->ps.lmcs.fwd_lut);
|
||||
fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, &fc->ps.lmcs.fwd_lut);
|
||||
fc->vvcdsp.inter.put_ciip(dst, dst_stride, sbw, sbh, inter, inter_stride, intra_weight);
|
||||
|
||||
}
|
||||
@ -887,7 +887,7 @@ static void predict_inter(VVCLocalContext *lc)
|
||||
|
||||
if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) {
|
||||
uint8_t* dst0 = POS(0, cu->x0, cu->y0);
|
||||
fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, fc->ps.lmcs.fwd_lut);
|
||||
fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,9 +642,9 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw
|
||||
const uint16_t fwd_sample = lmcs_derive_lut_sample(sample, lmcs->pivot,
|
||||
input_pivot, scale_coeff, idx_y, max);
|
||||
if (bit_depth > 8)
|
||||
((uint16_t *)lmcs->fwd_lut)[sample] = fwd_sample;
|
||||
lmcs->fwd_lut.u16[sample] = fwd_sample;
|
||||
else
|
||||
lmcs->fwd_lut[sample] = fwd_sample;
|
||||
lmcs->fwd_lut.u8 [sample] = fwd_sample;
|
||||
|
||||
}
|
||||
|
||||
@ -659,9 +659,9 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw
|
||||
inv_scale_coeff, i, max);
|
||||
|
||||
if (bit_depth > 8)
|
||||
((uint16_t *)lmcs->inv_lut)[sample] = inv_sample;
|
||||
lmcs->inv_lut.u16[sample] = inv_sample;
|
||||
else
|
||||
lmcs->inv_lut[sample] = inv_sample;
|
||||
lmcs->inv_lut.u8 [sample] = inv_sample;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -191,9 +191,10 @@ typedef struct VVCLMCS {
|
||||
uint8_t min_bin_idx;
|
||||
uint8_t max_bin_idx;
|
||||
|
||||
//*2 for high depth
|
||||
uint8_t fwd_lut[LMCS_MAX_LUT_SIZE * 2];
|
||||
uint8_t inv_lut[LMCS_MAX_LUT_SIZE * 2];
|
||||
union {
|
||||
uint8_t u8[LMCS_MAX_LUT_SIZE];
|
||||
uint16_t u16[LMCS_MAX_LUT_SIZE]; ///< for high bit-depth
|
||||
} fwd_lut, inv_lut;
|
||||
|
||||
uint16_t pivot[LMCS_MAX_BIN_SIZE + 1];
|
||||
uint16_t chroma_scale_coeff[LMCS_MAX_BIN_SIZE];
|
||||
|
@ -119,7 +119,7 @@ typedef struct VVCItxDSPContext {
|
||||
} VVCItxDSPContext;
|
||||
|
||||
typedef struct VVCLMCSDSPContext {
|
||||
void (*filter)(uint8_t *dst, ptrdiff_t dst_stride, int width, int height, const uint8_t *lut);
|
||||
void (*filter)(uint8_t *dst, ptrdiff_t dst_stride, int width, int height, const void *lut);
|
||||
} VVCLMCSDSPContext;
|
||||
|
||||
typedef struct VVCLFDSPContext {
|
||||
|
Loading…
x
Reference in New Issue
Block a user