avcodec/vvcdec: deblock, fix uninitialized values
see https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind&time=20240105201935 If tc is zero, the max_len_q, max_len_p are uninitialized. Reported-by: James Almer <jamrial@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -551,6 +551,12 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdif
|
||||
const ptrdiff_t ystride = _ystride / sizeof(pixel);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
#if BIT_DEPTH < 10
|
||||
const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH);
|
||||
#else
|
||||
const int tc = _tc[i] << (BIT_DEPTH - 10);
|
||||
#endif
|
||||
if (tc) {
|
||||
pixel* pix = (pixel*)_pix + i * 4 * ystride;
|
||||
const int dp0 = abs(P2 - 2 * P1 + P0);
|
||||
const int dq0 = abs(Q2 - 2 * Q1 + Q0);
|
||||
@@ -558,11 +564,6 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdif
|
||||
const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0);
|
||||
const int d0 = dp0 + dq0;
|
||||
const int d3 = dp3 + dq3;
|
||||
#if BIT_DEPTH < 10
|
||||
const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH);
|
||||
#else
|
||||
const int tc = _tc[i] << (BIT_DEPTH - 10);
|
||||
#endif
|
||||
const int tc25 = ((tc * 5 + 1) >> 1);
|
||||
|
||||
const int no_p = _no_p[i];
|
||||
@@ -573,14 +574,11 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdif
|
||||
|
||||
const int large_p = (max_len_p > 3 && !hor_ctu_edge);
|
||||
const int large_q = max_len_q > 3;
|
||||
const int beta = _beta[i] << BIT_DEPTH - 8;
|
||||
|
||||
const int beta = _beta[i] << BIT_DEPTH - 8;
|
||||
const int beta_3 = beta >> 3;
|
||||
const int beta_2 = beta >> 2;
|
||||
|
||||
if (!tc)
|
||||
continue;
|
||||
|
||||
if (large_p || large_q) {
|
||||
const int dp0l = large_p ? ((dp0 + abs(P5 - 2 * P4 + P3) + 1) >> 1) : dp0;
|
||||
const int dq0l = large_q ? ((dq0 + abs(Q5 - 2 * Q4 + Q3) + 1) >> 1) : dq0;
|
||||
@@ -616,7 +614,7 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdif
|
||||
abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 &&
|
||||
(d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
|
||||
FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc, tc << 1, tc * 3, no_p, no_q);
|
||||
} else { // weak filtering
|
||||
} else {
|
||||
int nd_p = 1;
|
||||
int nd_q = 1;
|
||||
if (max_len_p > 1 && max_len_q > 1) {
|
||||
@@ -630,6 +628,7 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FUNC(loop_filter_chroma_strong)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride,
|
||||
const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
|
||||
@@ -689,24 +688,26 @@ static void FUNC(vvc_loop_filter_chroma)(uint8_t *_pix, const ptrdiff_t _xstrid
|
||||
const int end = 8 / size; // 8 samples a loop
|
||||
|
||||
for (int i = 0; i < end; i++) {
|
||||
pixel *pix = (pixel *)_pix + i * size * ystride;
|
||||
const uint8_t no_p = _no_p[i];
|
||||
const uint8_t no_q = _no_q[i];
|
||||
const int beta = _beta[i] << (BIT_DEPTH - 8);
|
||||
const int beta_3 = beta >> 3;
|
||||
const int beta_2 = beta >> 2;
|
||||
|
||||
#if BIT_DEPTH < 10
|
||||
const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH);
|
||||
#else
|
||||
const int tc = _tc[i] << (BIT_DEPTH - 10);
|
||||
#endif
|
||||
if (tc) {
|
||||
pixel *pix = (pixel *)_pix + i * size * ystride;
|
||||
const uint8_t no_p = _no_p[i];
|
||||
const uint8_t no_q = _no_q[i];
|
||||
|
||||
const int beta = _beta[i] << (BIT_DEPTH - 8);
|
||||
const int beta_3 = beta >> 3;
|
||||
const int beta_2 = beta >> 2;
|
||||
|
||||
const int tc25 = ((tc * 5 + 1) >> 1);
|
||||
|
||||
uint8_t max_len_p = _max_len_p[i];
|
||||
uint8_t max_len_q = _max_len_q[i];
|
||||
|
||||
if (!max_len_p || !max_len_q || !tc)
|
||||
if (!max_len_p || !max_len_q)
|
||||
continue;
|
||||
|
||||
if (max_len_q == 3){
|
||||
@@ -750,6 +751,7 @@ static void FUNC(vvc_loop_filter_chroma)(uint8_t *_pix, const ptrdiff_t _xstrid
|
||||
FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FUNC(vvc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
|
||||
const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q,
|
||||
|
Reference in New Issue
Block a user