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.
Unified · Split
| @@ -1328,5 +1328,5 @@ void ff_vvc_lmcs_filter(const VVCLocalContext *lc, const int x, const int y) · 1327 unmodified lines | ||
| 1328 | 1328 | const int height = FFMIN(fc->ps.pps->height - y, ctb_size); |
| 1329 | 1329 | uint8_t *data = fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift); |
| 1330 | 1330 | if (sc->sh.r->sh_lmcs_used_flag) |
| 1331 | − fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, fc->ps.lmcs.inv_lut); | |
| 1331 | + fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, &fc->ps.lmcs.inv_lut); | |
| 1332 | 1332 | } |
| @@ -22,9 +22,9 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "libavcodec/h26x/h2656_sao_template.c" |
| 24 | 24 | |
| 25 | −static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const uint8_t *_lut) | |
| 25 | +static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const void *_lut) | |
| 26 | 26 | { |
| 27 | − const pixel *lut = (const pixel *)_lut; | |
| 27 | + const pixel *lut = _lut; | |
| 28 | 28 | pixel *dst = (pixel*)_dst; |
| 29 | 29 | dst_stride /= sizeof(pixel); |
| 30 | 30 | |
| @@ -571,7 +571,7 @@ static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int v · 570 unmodified lines | ||
| 571 | 571 | const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh); |
| 572 | 572 | fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 0); |
| 573 | 573 | if (sc->sh.r->sh_lmcs_used_flag) |
| 574 | − fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, fc->ps.lmcs.fwd_lut); | |
| 574 | + fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, &fc->ps.lmcs.fwd_lut); | |
| 575 | 575 | fc->vvcdsp.inter.put_ciip(dst, dst_stride, sbw, sbh, inter, inter_stride, intra_weight); |
| 576 | 576 | |
| 577 | 577 | } |
| @@ -887,7 +887,7 @@ static void predict_inter(VVCLocalContext *lc) · 309 unmodified lines | ||
| 887 | 887 | |
| 888 | 888 | if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) { |
| 889 | 889 | uint8_t* dst0 = POS(0, cu->x0, cu->y0); |
| 890 | − fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, fc->ps.lmcs.fwd_lut); | |
| 890 | + fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut); | |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
| @@ -642,9 +642,9 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw · 641 unmodified lines | ||
| 642 | 642 | const uint16_t fwd_sample = lmcs_derive_lut_sample(sample, lmcs->pivot, |
| 643 | 643 | input_pivot, scale_coeff, idx_y, max); |
| 644 | 644 | if (bit_depth > 8) |
| 645 | − ((uint16_t *)lmcs->fwd_lut)[sample] = fwd_sample; | |
| 645 | + lmcs->fwd_lut.u16[sample] = fwd_sample; | |
| 646 | 646 | else |
| 647 | − lmcs->fwd_lut[sample] = fwd_sample; | |
| 647 | + lmcs->fwd_lut.u8 [sample] = fwd_sample; | |
| 648 | 648 | |
| 649 | 649 | } |
| 650 | 650 | |
| @@ -659,9 +659,9 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw · 8 unmodified lines | ||
| 659 | 659 | inv_scale_coeff, i, max); |
| 660 | 660 | |
| 661 | 661 | if (bit_depth > 8) |
| 662 | − ((uint16_t *)lmcs->inv_lut)[sample] = inv_sample; | |
| 662 | + lmcs->inv_lut.u16[sample] = inv_sample; | |
| 663 | 663 | else |
| 664 | − lmcs->inv_lut[sample] = inv_sample; | |
| 664 | + lmcs->inv_lut.u8 [sample] = inv_sample; | |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | return 0; |
| @@ -191,9 +191,10 @@ typedef struct VVCLMCS { · 190 unmodified lines | ||
| 191 | 191 | uint8_t min_bin_idx; |
| 192 | 192 | uint8_t max_bin_idx; |
| 193 | 193 | |
| 194 | − //*2 for high depth | |
| 195 | − uint8_t fwd_lut[LMCS_MAX_LUT_SIZE * 2]; | |
| 196 | − uint8_t inv_lut[LMCS_MAX_LUT_SIZE * 2]; | |
| 194 | + union { | |
| 195 | + uint8_t u8[LMCS_MAX_LUT_SIZE]; | |
| 196 | + uint16_t u16[LMCS_MAX_LUT_SIZE]; ///< for high bit-depth | |
| 197 | + } fwd_lut, inv_lut; | |
| 197 | 198 | |
| 198 | 199 | uint16_t pivot[LMCS_MAX_BIN_SIZE + 1]; |
| 199 | 200 | uint16_t chroma_scale_coeff[LMCS_MAX_BIN_SIZE]; |
| @@ -119,7 +119,7 @@ typedef struct VVCItxDSPContext { · 118 unmodified lines | ||
| 119 | 119 | } VVCItxDSPContext; |
| 120 | 120 | |
| 121 | 121 | typedef struct VVCLMCSDSPContext { |
| 122 | − void (*filter)(uint8_t *dst, ptrdiff_t dst_stride, int width, int height, const uint8_t *lut); | |
| 122 | + void (*filter)(uint8_t *dst, ptrdiff_t dst_stride, int width, int height, const void *lut); | |
| 123 | 123 | } VVCLMCSDSPContext; |
| 124 | 124 | |
| 125 | 125 | typedef struct VVCLFDSPContext { |