| @@ -1319,19 +1319,20 @@ static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, · 1318 unmodified lines |
| 1319 | 1319 | #define TQ2 pix[2 * xstride + 3 * ystride] |
| 1320 | 1320 | #define TQ3 pix[3 * xstride + 3 * ystride] |
| 1321 | 1321 | |
| 1322 | +#include "h26x/h2656_deblock_template.c" |
| 1323 | + |
| 1322 | 1324 | static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, |
| 1323 | 1325 | ptrdiff_t _xstride, ptrdiff_t _ystride, |
| 1324 | 1326 | int beta, const int *_tc, |
| 1325 | 1327 | const uint8_t *_no_p, const uint8_t *_no_q) |
| 1326 | 1328 | { |
| 1327 | | − int d, j; |
| 1328 | | − pixel *pix = (pixel *)_pix; |
| 1329 | 1329 | ptrdiff_t xstride = _xstride / sizeof(pixel); |
| 1330 | 1330 | ptrdiff_t ystride = _ystride / sizeof(pixel); |
| 1331 | 1331 | |
| 1332 | 1332 | beta <<= BIT_DEPTH - 8; |
| 1333 | 1333 | |
| 1334 | | − for (j = 0; j < 2; j++) { |
| 1334 | + for (int j = 0; j < 2; j++) { |
| 1335 | + pixel* pix = (pixel*)_pix + j * 4 * ystride; |
| 1335 | 1336 | const int dp0 = abs(P2 - 2 * P1 + P0); |
| 1336 | 1337 | const int dq0 = abs(Q2 - 2 * Q1 + Q0); |
| 1337 | 1338 | const int dp3 = abs(TP2 - 2 * TP1 + TP0); |
| @@ -1342,10 +1343,7 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, · 4 unmodified lines |
| 1342 | 1343 | const int no_p = _no_p[j]; |
| 1343 | 1344 | const int no_q = _no_q[j]; |
| 1344 | 1345 | |
| 1345 | | − if (d0 + d3 >= beta) { |
| 1346 | | − pix += 4 * ystride; |
| 1347 | | − continue; |
| 1348 | | − } else { |
| 1346 | + if (d0 + d3 < beta) { |
| 1349 | 1347 | const int beta_3 = beta >> 3; |
| 1350 | 1348 | const int beta_2 = beta >> 2; |
| 1351 | 1349 | const int tc25 = ((tc * 5 + 1) >> 1); |
| @@ -1353,63 +1351,16 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, · 1 unmodified line |
| 1353 | 1351 | if (abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 && |
| 1354 | 1352 | abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 && |
| 1355 | 1353 | (d0 << 1) < beta_2 && (d3 << 1) < beta_2) { |
| 1356 | | − // strong filtering |
| 1357 | 1354 | const int tc2 = tc << 1; |
| 1358 | | − for (d = 0; d < 4; d++) { |
| 1359 | | − const int p3 = P3; |
| 1360 | | − const int p2 = P2; |
| 1361 | | − const int p1 = P1; |
| 1362 | | − const int p0 = P0; |
| 1363 | | − const int q0 = Q0; |
| 1364 | | − const int q1 = Q1; |
| 1365 | | − const int q2 = Q2; |
| 1366 | | − const int q3 = Q3; |
| 1367 | | − if (!no_p) { |
| 1368 | | − P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc2, tc2); |
| 1369 | | − P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2); |
| 1370 | | − P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc2, tc2); |
| 1371 | | − } |
| 1372 | | − if (!no_q) { |
| 1373 | | − Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc2, tc2); |
| 1374 | | − Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2); |
| 1375 | | − Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc2, tc2); |
| 1376 | | − } |
| 1377 | | − pix += ystride; |
| 1378 | | − } |
| 1379 | | − } else { // normal filtering |
| 1355 | + FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc2, tc2, tc2, no_p, no_q); |
| 1356 | + } else { |
| 1380 | 1357 | int nd_p = 1; |
| 1381 | 1358 | int nd_q = 1; |
| 1382 | | − const int tc_2 = tc >> 1; |
| 1383 | 1359 | if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3)) |
| 1384 | 1360 | nd_p = 2; |
| 1385 | 1361 | if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3)) |
| 1386 | 1362 | nd_q = 2; |
| 1387 | | − |
| 1388 | | − for (d = 0; d < 4; d++) { |
| 1389 | | − const int p2 = P2; |
| 1390 | | − const int p1 = P1; |
| 1391 | | − const int p0 = P0; |
| 1392 | | − const int q0 = Q0; |
| 1393 | | − const int q1 = Q1; |
| 1394 | | − const int q2 = Q2; |
| 1395 | | − int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4; |
| 1396 | | − if (abs(delta0) < 10 * tc) { |
| 1397 | | − delta0 = av_clip(delta0, -tc, tc); |
| 1398 | | − if (!no_p) |
| 1399 | | − P0 = av_clip_pixel(p0 + delta0); |
| 1400 | | − if (!no_q) |
| 1401 | | − Q0 = av_clip_pixel(q0 - delta0); |
| 1402 | | − if (!no_p && nd_p > 1) { |
| 1403 | | − const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2); |
| 1404 | | − P1 = av_clip_pixel(p1 + deltap1); |
| 1405 | | − } |
| 1406 | | − if (!no_q && nd_q > 1) { |
| 1407 | | − const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2); |
| 1408 | | − Q1 = av_clip_pixel(q1 + deltaq1); |
| 1409 | | − } |
| 1410 | | − } |
| 1411 | | − pix += ystride; |
| 1412 | | − } |
| 1363 | + FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q); |
| 1413 | 1364 | } |
| 1414 | 1365 | } |
| 1415 | 1366 | } |
| @@ -1419,32 +1370,19 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride, · 3 unmodified lines |
| 1419 | 1370 | ptrdiff_t _ystride, const int *_tc, |
| 1420 | 1371 | const uint8_t *_no_p, const uint8_t *_no_q) |
| 1421 | 1372 | { |
| 1422 | | − int d, j, no_p, no_q; |
| 1423 | | − pixel *pix = (pixel *)_pix; |
| 1373 | + int no_p, no_q; |
| 1424 | 1374 | ptrdiff_t xstride = _xstride / sizeof(pixel); |
| 1425 | 1375 | ptrdiff_t ystride = _ystride / sizeof(pixel); |
| 1376 | + const int size = 4; |
| 1426 | 1377 | |
| 1427 | | − for (j = 0; j < 2; j++) { |
| 1378 | + for (int j = 0; j < 2; j++) { |
| 1379 | + pixel *pix = (pixel *)_pix + j * size * ystride; |
| 1428 | 1380 | const int tc = _tc[j] << (BIT_DEPTH - 8); |
| 1429 | | − if (tc <= 0) { |
| 1430 | | − pix += 4 * ystride; |
| 1431 | | − continue; |
| 1432 | | − } |
| 1433 | | − no_p = _no_p[j]; |
| 1434 | | − no_q = _no_q[j]; |
| 1435 | | − |
| 1436 | | − for (d = 0; d < 4; d++) { |
| 1437 | | − int delta0; |
| 1438 | | − const int p1 = P1; |
| 1439 | | − const int p0 = P0; |
| 1440 | | − const int q0 = Q0; |
| 1441 | | − const int q1 = Q1; |
| 1442 | | − delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc); |
| 1443 | | − if (!no_p) |
| 1444 | | − P0 = av_clip_pixel(p0 + delta0); |
| 1445 | | − if (!no_q) |
| 1446 | | − Q0 = av_clip_pixel(q0 - delta0); |
| 1447 | | − pix += ystride; |
| 1381 | + if (tc > 0) { |
| 1382 | + no_p = _no_p[j]; |
| 1383 | + no_q = _no_q[j]; |
| 1384 | + |
| 1385 | + FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q); |
| 1448 | 1386 | } |
| 1449 | 1387 | } |
| 1450 | 1388 | } |