mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-18 07:18:34 +00:00
[libvpx] Update to v1.17.0-97-gd3335af9e
This commit is contained in:
1 parent
7481baed18
commit
a55111af58
615 files changed
+68654
-28912
No files matched your search
@@ -15,6 +15,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "./vpx_config.h"
|
||||
#include "vpx_ports/compiler_attributes.h"
|
||||
#include "vpx_ports/mem.h"
|
||||
#include "vpx/vp8dx.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
@@ -50,7 +51,8 @@ int vp8dx_start_decode(BOOL_DECODER *br, const unsigned char *source,
|
||||
|
||||
void vp8dx_bool_decoder_fill(BOOL_DECODER *br);
|
||||
|
||||
static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
|
||||
static VPX_NO_UNSIGNED_SHIFT_CHECK int vp8dx_decode_bool(BOOL_DECODER *br,
|
||||
int probability) {
|
||||
unsigned int bit = 0;
|
||||
VP8_BD_VALUE value;
|
||||
unsigned int split;
|
||||
|
||||
@@ -63,7 +63,7 @@ void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
||||
/* Decide whether to use the default or alternate baseline Q value. */
|
||||
if (xd->segmentation_enabled) {
|
||||
/* Abs Value */
|
||||
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA) {
|
||||
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
|
||||
QIndex = xd->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id];
|
||||
|
||||
/* Delta Value */
|
||||
@@ -829,7 +829,7 @@ static void init_frame(VP8D_COMP *pbi) {
|
||||
|
||||
/* reset the segment feature data to 0 with delta coding (Default state). */
|
||||
memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
|
||||
xd->mb_segement_abs_delta = SEGMENT_DELTADATA;
|
||||
xd->mb_segment_abs_delta = SEGMENT_DELTADATA;
|
||||
|
||||
/* reset the mode ref deltasa for loop filter */
|
||||
memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas));
|
||||
@@ -883,7 +883,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
const unsigned char *data = pbi->fragments.ptrs[0];
|
||||
const unsigned int data_sz = pbi->fragments.sizes[0];
|
||||
const unsigned char *data_end = data + data_sz;
|
||||
ptrdiff_t first_partition_length_in_bytes;
|
||||
int first_partition_length_in_bytes;
|
||||
|
||||
int i, j, k, l;
|
||||
const int *const mb_feature_data_bits = vp8_mb_feature_data_bits;
|
||||
@@ -924,10 +924,9 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
first_partition_length_in_bytes =
|
||||
(clear[0] | (clear[1] << 8) | (clear[2] << 16)) >> 5;
|
||||
|
||||
if (!pbi->ec_active && (data + first_partition_length_in_bytes > data_end ||
|
||||
data + first_partition_length_in_bytes < data)) {
|
||||
if (!pbi->ec_active && first_partition_length_in_bytes == 0) {
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Truncated packet or corrupt partition 0 length");
|
||||
"Corrupt partition 0 length");
|
||||
}
|
||||
|
||||
data += 3;
|
||||
@@ -936,22 +935,16 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
vp8_setup_version(pc);
|
||||
|
||||
if (pc->frame_type == KEY_FRAME) {
|
||||
/* vet via sync code */
|
||||
/* When error concealment is enabled we should only check the sync
|
||||
* code if we have enough bits available
|
||||
*/
|
||||
if (data + 3 < data_end) {
|
||||
if (data_end - data >= 7) {
|
||||
/* vet via sync code */
|
||||
/* When error concealment is enabled we should only check the sync
|
||||
* code if we have enough bits available
|
||||
*/
|
||||
if (clear[0] != 0x9d || clear[1] != 0x01 || clear[2] != 0x2a) {
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM,
|
||||
"Invalid frame sync code");
|
||||
}
|
||||
}
|
||||
|
||||
/* If error concealment is enabled we should only parse the new size
|
||||
* if we have enough data. Otherwise we will end up with the wrong
|
||||
* size.
|
||||
*/
|
||||
if (data + 6 < data_end) {
|
||||
pc->Width = (clear[3] | (clear[4] << 8)) & 0x3fff;
|
||||
pc->horiz_scale = clear[4] >> 6;
|
||||
pc->Height = (clear[5] | (clear[6] << 8)) & 0x3fff;
|
||||
@@ -965,14 +958,19 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
data = data_end;
|
||||
}
|
||||
} else {
|
||||
memcpy(&xd->pre, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG));
|
||||
memcpy(&xd->dst, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG));
|
||||
xd->pre = *yv12_fb_new;
|
||||
xd->dst = *yv12_fb_new;
|
||||
}
|
||||
}
|
||||
if ((!pbi->decoded_key_frame && pc->frame_type != KEY_FRAME)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!pbi->ec_active && data_end - data < first_partition_length_in_bytes) {
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Truncated packet or corrupt partition 0 length");
|
||||
}
|
||||
|
||||
init_frame(pbi);
|
||||
|
||||
if (vp8dx_start_decode(bc, data, (unsigned int)(data_end - data),
|
||||
@@ -995,7 +993,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
|
||||
|
||||
if (xd->update_mb_segmentation_data) {
|
||||
xd->mb_segement_abs_delta = (unsigned char)vp8_read_bit(bc);
|
||||
xd->mb_segment_abs_delta = (unsigned char)vp8_read_bit(bc);
|
||||
|
||||
memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
|
||||
|
||||
@@ -1156,7 +1154,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
if (pbi->ec_active && xd->corrupted) pc->refresh_entropy_probs = 0;
|
||||
#endif
|
||||
if (pc->refresh_entropy_probs == 0) {
|
||||
memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
|
||||
pc->lfc = pc->fc;
|
||||
}
|
||||
|
||||
pc->refresh_last_frame = pc->frame_type == KEY_FRAME || vp8_read_bit(bc);
|
||||
@@ -1167,14 +1165,6 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
if (pbi->ec_active && xd->corrupted) pc->refresh_last_frame = 1;
|
||||
#endif
|
||||
|
||||
if (0) {
|
||||
FILE *z = fopen("decodestats.stt", "a");
|
||||
fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n", pc->current_video_frame,
|
||||
pc->frame_type, pc->refresh_golden_frame, pc->refresh_alt_ref_frame,
|
||||
pc->refresh_last_frame, pc->base_qindex);
|
||||
fclose(z);
|
||||
}
|
||||
|
||||
{
|
||||
pbi->independent_partitions = 1;
|
||||
|
||||
@@ -1253,7 +1243,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||
* \n",bc->pos+pbi->bc2.pos); */
|
||||
|
||||
if (pc->refresh_entropy_probs == 0) {
|
||||
memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
|
||||
pc->fc = pc->lfc;
|
||||
pbi->independent_partitions = prev_independent_partitions;
|
||||
}
|
||||
|
||||
|
||||
@@ -372,9 +372,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi,
|
||||
tmp = cnt[CNT_NEAREST];
|
||||
cnt[CNT_NEAREST] = cnt[CNT_NEAR];
|
||||
cnt[CNT_NEAR] = tmp;
|
||||
tmp = near_mvs[CNT_NEAREST].as_int;
|
||||
tmp = (int)near_mvs[CNT_NEAREST].as_int;
|
||||
near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
|
||||
near_mvs[CNT_NEAR].as_int = tmp;
|
||||
near_mvs[CNT_NEAR].as_int = (uint32_t)tmp;
|
||||
}
|
||||
|
||||
if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
|
||||
|
||||
@@ -302,7 +302,7 @@ static int check_fragments_for_errors(VP8D_COMP *pbi) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vp8dx_receive_compressed_data(VP8D_COMP *pbi, int64_t time_stamp) {
|
||||
int vp8dx_receive_compressed_data(VP8D_COMP *pbi) {
|
||||
VP8_COMMON *cm = &pbi->common;
|
||||
int retcode = -1;
|
||||
|
||||
@@ -368,14 +368,12 @@ int vp8dx_receive_compressed_data(VP8D_COMP *pbi, int64_t time_stamp) {
|
||||
#endif
|
||||
|
||||
pbi->ready_for_new_data = 0;
|
||||
pbi->last_time_stamp = time_stamp;
|
||||
|
||||
decode_exit:
|
||||
vpx_clear_system_state();
|
||||
return retcode;
|
||||
}
|
||||
int vp8dx_get_raw_frame(VP8D_COMP *pbi, YV12_BUFFER_CONFIG *sd,
|
||||
int64_t *time_stamp, int64_t *time_end_stamp,
|
||||
vp8_ppflags_t *flags) {
|
||||
int ret = -1;
|
||||
|
||||
@@ -385,8 +383,6 @@ int vp8dx_get_raw_frame(VP8D_COMP *pbi, YV12_BUFFER_CONFIG *sd,
|
||||
if (pbi->common.show_frame == 0) return ret;
|
||||
|
||||
pbi->ready_for_new_data = 1;
|
||||
*time_stamp = pbi->last_time_stamp;
|
||||
*time_end_stamp = 0;
|
||||
|
||||
#if CONFIG_POSTPROC
|
||||
ret = vp8_post_proc_frame(&pbi->common, sd, flags);
|
||||
@@ -432,6 +428,7 @@ int vp8_create_decoder_instances(struct frame_buffers *fb, VP8D_CONFIG *oxcf) {
|
||||
|
||||
#if CONFIG_MULTITHREAD
|
||||
if (setjmp(fb->pbi[0]->common.error.jmp)) {
|
||||
fb->pbi[0]->common.error.setjmp = 0;
|
||||
vp8_remove_decoder_instances(fb);
|
||||
vp8_zero(fb->pbi);
|
||||
vpx_clear_system_state();
|
||||
@@ -456,6 +453,7 @@ int vp8_remove_decoder_instances(struct frame_buffers *fb) {
|
||||
|
||||
/* decoder instance for single thread mode */
|
||||
remove_decompressor(pbi);
|
||||
fb->pbi[0] = NULL;
|
||||
return VPX_CODEC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
#ifndef VPX_VP8_DECODER_ONYXD_INT_H_
|
||||
#define VPX_VP8_DECODER_ONYXD_INT_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "vpx_config.h"
|
||||
#include "vpx_util/vpx_pthread.h"
|
||||
#include "vp8/common/onyxd.h"
|
||||
#include "treereader.h"
|
||||
#include "vp8/common/onyxc_int.h"
|
||||
@@ -92,12 +95,11 @@ typedef struct VP8D_COMP {
|
||||
DECODETHREAD_DATA *de_thread_data;
|
||||
|
||||
pthread_t *h_decoding_thread;
|
||||
sem_t *h_event_start_decoding;
|
||||
sem_t h_event_end_decoding;
|
||||
vp8_sem_t *h_event_start_decoding;
|
||||
vp8_sem_t h_event_end_decoding;
|
||||
/* end of threading data */
|
||||
#endif
|
||||
|
||||
int64_t last_time_stamp;
|
||||
int ready_for_new_data;
|
||||
|
||||
vp8_prob prob_intra;
|
||||
@@ -133,25 +135,6 @@ int vp8_decode_frame(VP8D_COMP *pbi);
|
||||
int vp8_create_decoder_instances(struct frame_buffers *fb, VP8D_CONFIG *oxcf);
|
||||
int vp8_remove_decoder_instances(struct frame_buffers *fb);
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
#define CHECK_MEM_ERROR(lval, expr) \
|
||||
do { \
|
||||
(lval) = (expr); \
|
||||
if (!(lval)) \
|
||||
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, \
|
||||
"Failed to allocate " #lval " at %s:%d", __FILE__, \
|
||||
__LINE__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define CHECK_MEM_ERROR(lval, expr) \
|
||||
do { \
|
||||
(lval) = (expr); \
|
||||
if (!(lval)) \
|
||||
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, \
|
||||
"Failed to allocate " #lval); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user