[libvpx] Update to v1.17.0-97-gd3335af9e

This commit is contained in:
Andrey Volk committed 2026-11-16 23:18:46 +03:00
1 parent 7481baed18
commit a55111af58
615 files changed
+68654 -28912

No files matched your search

+51 -29
View File
@@ -15,6 +15,7 @@
#endif
#include "onyxd_int.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_util/vpx_pthread.h"
#include "vp8/common/common.h"
#include "vp8/common/threading.h"
#include "vp8/common/loopfilter.h"
@@ -30,11 +31,13 @@
#include "error_concealment.h"
#endif
#define CALLOC_ARRAY(p, n) CHECK_MEM_ERROR((p), vpx_calloc(sizeof(*(p)), (n)))
#define CALLOC_ARRAY_ALIGNED(p, n, algn) \
do { \
CHECK_MEM_ERROR((p), vpx_memalign((algn), sizeof(*(p)) * (n))); \
memset((p), 0, (n) * sizeof(*(p))); \
#define CALLOC_ARRAY(p, n) \
CHECK_MEM_ERROR(&pbi->common.error, (p), vpx_calloc(sizeof(*(p)), (n)))
#define CALLOC_ARRAY_ALIGNED(p, n, algn) \
do { \
CHECK_MEM_ERROR(&pbi->common.error, (p), \
vpx_memalign((algn), sizeof(*(p)) * (n))); \
memset((p), 0, (n) * sizeof(*(p))); \
} while (0)
static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd,
@@ -44,6 +47,16 @@ static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd,
for (i = 0; i < count; ++i) {
MACROBLOCKD *mbd = &mbrd[i].mbd;
// The worker MACROBLOCKDs persist across frames, so reset the per-frame
// error state in line with the main thread (see vp8_decode_frame()).
// This should only be done for keyframes or when error concealment
// is active.
if (pc->frame_type == KEY_FRAME || pbi->ec_active) {
mbd->corrupted = 0;
}
mbd->error_info.error_code = 0;
mbd->subpixel_predict = xd->subpixel_predict;
mbd->subpixel_predict8x4 = xd->subpixel_predict8x4;
mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
@@ -54,7 +67,7 @@ static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd,
mbd->dst = xd->dst;
mbd->segmentation_enabled = xd->segmentation_enabled;
mbd->mb_segement_abs_delta = xd->mb_segement_abs_delta;
mbd->mb_segment_abs_delta = xd->mb_segment_abs_delta;
memcpy(mbd->segment_feature_data, xd->segment_feature_data,
sizeof(xd->segment_feature_data));
@@ -225,7 +238,7 @@ static void mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
vp8_short_inv_walsh4x4(&b->dqcoeff[0], xd->qcoeff);
memset(b->qcoeff, 0, 16 * sizeof(b->qcoeff[0]));
} else {
b->dqcoeff[0] = b->qcoeff[0] * xd->dequant_y2[0];
b->dqcoeff[0] = (short)(b->qcoeff[0] * xd->dequant_y2[0]);
vp8_short_inv_walsh4x4_1(&b->dqcoeff[0], xd->qcoeff);
memset(b->qcoeff, 0, 2 * sizeof(b->qcoeff[0]));
}
@@ -575,10 +588,10 @@ static void mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd,
/* signal end of decoding of current thread for current frame */
if (last_mb_row + (int)pbi->decoding_thread_count + 1 >= pc->mb_rows)
sem_post(&pbi->h_event_end_decoding);
vp8_sem_post(&pbi->h_event_end_decoding);
}
static THREAD_FUNCTION thread_decoding_proc(void *p_data) {
static THREADFN thread_decoding_proc(void *p_data) {
int ithread = ((DECODETHREAD_DATA *)p_data)->ithread;
VP8D_COMP *pbi = (VP8D_COMP *)(((DECODETHREAD_DATA *)p_data)->ptr1);
MB_ROW_DEC *mbrd = (MB_ROW_DEC *)(((DECODETHREAD_DATA *)p_data)->ptr2);
@@ -587,7 +600,7 @@ static THREAD_FUNCTION thread_decoding_proc(void *p_data) {
while (1) {
if (vpx_atomic_load_acquire(&pbi->b_multithreaded_rd) == 0) break;
if (sem_wait(&pbi->h_event_start_decoding[ithread]) == 0) {
if (vp8_sem_wait(&pbi->h_event_start_decoding[ithread]) == 0) {
if (vpx_atomic_load_acquire(&pbi->b_multithreaded_rd) == 0) {
break;
} else {
@@ -596,16 +609,17 @@ static THREAD_FUNCTION thread_decoding_proc(void *p_data) {
if (setjmp(xd->error_info.jmp)) {
xd->error_info.setjmp = 0;
// Signal the end of decoding for current thread.
sem_post(&pbi->h_event_end_decoding);
vp8_sem_post(&pbi->h_event_end_decoding);
continue;
}
xd->error_info.setjmp = 1;
mt_decode_mb_rows(pbi, xd, ithread + 1);
xd->error_info.setjmp = 0;
}
}
}
return 0;
return THREAD_EXIT_SUCCESS;
}
void vp8_decoder_create_threads(VP8D_COMP *pbi) {
@@ -632,13 +646,13 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi) {
CALLOC_ARRAY_ALIGNED(pbi->mb_row_di, pbi->decoding_thread_count, 32);
CALLOC_ARRAY(pbi->de_thread_data, pbi->decoding_thread_count);
if (sem_init(&pbi->h_event_end_decoding, 0, 0)) {
if (vp8_sem_init(&pbi->h_event_end_decoding, 0, 0)) {
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to initialize semaphore");
}
for (ithread = 0; ithread < pbi->decoding_thread_count; ++ithread) {
if (sem_init(&pbi->h_event_start_decoding[ithread], 0, 0)) break;
if (vp8_sem_init(&pbi->h_event_start_decoding[ithread], 0, 0)) break;
vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd);
@@ -648,7 +662,7 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi) {
if (pthread_create(&pbi->h_decoding_thread[ithread], 0,
thread_decoding_proc, &pbi->de_thread_data[ithread])) {
sem_destroy(&pbi->h_event_start_decoding[ithread]);
vp8_sem_destroy(&pbi->h_event_start_decoding[ithread]);
break;
}
}
@@ -659,7 +673,7 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi) {
/* the remainder of cleanup cases will be handled in
* vp8_decoder_remove_threads(). */
if (pbi->allocated_decoding_thread_count == 0) {
sem_destroy(&pbi->h_event_end_decoding);
vp8_sem_destroy(&pbi->h_event_end_decoding);
}
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to create threads");
@@ -754,7 +768,7 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) {
uv_width = width >> 1;
/* Allocate a vpx_atomic_int for each mb row. */
CHECK_MEM_ERROR(pbi->mt_current_mb_col,
CHECK_MEM_ERROR(&pc->error, pbi->mt_current_mb_col,
vpx_malloc(sizeof(*pbi->mt_current_mb_col) * pc->mb_rows));
for (i = 0; i < pc->mb_rows; ++i)
vpx_atomic_init(&pbi->mt_current_mb_col[i], 0);
@@ -762,7 +776,7 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) {
/* Allocate memory for above_row buffers. */
CALLOC_ARRAY(pbi->mt_yabove_row, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i) {
CHECK_MEM_ERROR(pbi->mt_yabove_row[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_yabove_row[i],
vpx_memalign(16, sizeof(unsigned char) *
(width + (VP8BORDERINPIXELS << 1))));
vp8_zero_array(pbi->mt_yabove_row[i], width + (VP8BORDERINPIXELS << 1));
@@ -770,7 +784,7 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) {
CALLOC_ARRAY(pbi->mt_uabove_row, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i) {
CHECK_MEM_ERROR(pbi->mt_uabove_row[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_uabove_row[i],
vpx_memalign(16, sizeof(unsigned char) *
(uv_width + VP8BORDERINPIXELS)));
vp8_zero_array(pbi->mt_uabove_row[i], uv_width + VP8BORDERINPIXELS);
@@ -778,7 +792,7 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) {
CALLOC_ARRAY(pbi->mt_vabove_row, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i) {
CHECK_MEM_ERROR(pbi->mt_vabove_row[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_vabove_row[i],
vpx_memalign(16, sizeof(unsigned char) *
(uv_width + VP8BORDERINPIXELS)));
vp8_zero_array(pbi->mt_vabove_row[i], uv_width + VP8BORDERINPIXELS);
@@ -787,17 +801,17 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) {
/* Allocate memory for left_col buffers. */
CALLOC_ARRAY(pbi->mt_yleft_col, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i)
CHECK_MEM_ERROR(pbi->mt_yleft_col[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_yleft_col[i],
vpx_calloc(sizeof(unsigned char) * 16, 1));
CALLOC_ARRAY(pbi->mt_uleft_col, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i)
CHECK_MEM_ERROR(pbi->mt_uleft_col[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_uleft_col[i],
vpx_calloc(sizeof(unsigned char) * 8, 1));
CALLOC_ARRAY(pbi->mt_vleft_col, pc->mb_rows);
for (i = 0; i < pc->mb_rows; ++i)
CHECK_MEM_ERROR(pbi->mt_vleft_col[i],
CHECK_MEM_ERROR(&pc->error, pbi->mt_vleft_col[i],
vpx_calloc(sizeof(unsigned char) * 8, 1));
}
}
@@ -810,16 +824,16 @@ void vp8_decoder_remove_threads(VP8D_COMP *pbi) {
/* allow all threads to exit */
for (i = 0; i < pbi->allocated_decoding_thread_count; ++i) {
sem_post(&pbi->h_event_start_decoding[i]);
vp8_sem_post(&pbi->h_event_start_decoding[i]);
pthread_join(pbi->h_decoding_thread[i], NULL);
}
for (i = 0; i < pbi->allocated_decoding_thread_count; ++i) {
sem_destroy(&pbi->h_event_start_decoding[i]);
vp8_sem_destroy(&pbi->h_event_start_decoding[i]);
}
if (pbi->allocated_decoding_thread_count) {
sem_destroy(&pbi->h_event_end_decoding);
vp8_sem_destroy(&pbi->h_event_end_decoding);
}
vpx_free(pbi->h_decoding_thread);
@@ -881,7 +895,7 @@ int vp8mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd) {
pbi->decoding_thread_count);
for (i = 0; i < pbi->decoding_thread_count; ++i) {
sem_post(&pbi->h_event_start_decoding[i]);
vp8_sem_post(&pbi->h_event_start_decoding[i]);
}
if (setjmp(xd->error_info.jmp)) {
@@ -891,15 +905,23 @@ int vp8mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd) {
// the current frame while the main thread starts decoding the next frame,
// which causes a data race.
for (i = 0; i < pbi->decoding_thread_count; ++i)
sem_wait(&pbi->h_event_end_decoding);
vp8_sem_wait(&pbi->h_event_end_decoding);
return -1;
}
xd->error_info.setjmp = 1;
mt_decode_mb_rows(pbi, xd, 0);
xd->error_info.setjmp = 0;
for (i = 0; i < pbi->decoding_thread_count + 1; ++i)
sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */
vp8_sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */
for (i = 0; i < pbi->decoding_thread_count; ++i) {
if (pbi->mb_row_di[i].mbd.error_info.error_code) {
xd->error_info = pbi->mb_row_di[i].mbd.error_info;
return -1;
}
}
return 0;
}