Merge "vp10/decoder,vp10/*.[hc]: apply clang-format" into nextgenv2
This commit is contained in:
Коммит
26777fca7b
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -8,7 +8,6 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VP10_DECODER_DECODEFRAME_H_
|
||||
#define VP10_DECODER_DECODEFRAME_H_
|
||||
|
||||
|
@ -20,13 +19,12 @@ struct VP10Decoder;
|
|||
struct vpx_read_bit_buffer;
|
||||
|
||||
int vp10_read_sync_code(struct vpx_read_bit_buffer *const rb);
|
||||
void vp10_read_frame_size(struct vpx_read_bit_buffer *rb,
|
||||
int *width, int *height);
|
||||
void vp10_read_frame_size(struct vpx_read_bit_buffer *rb, int *width,
|
||||
int *height);
|
||||
BITSTREAM_PROFILE vp10_read_profile(struct vpx_read_bit_buffer *rb);
|
||||
|
||||
void vp10_decode_frame(struct VP10Decoder *pbi,
|
||||
const uint8_t *data, const uint8_t *data_end,
|
||||
const uint8_t **p_data_end);
|
||||
void vp10_decode_frame(struct VP10Decoder *pbi, const uint8_t *data,
|
||||
const uint8_t *data_end, const uint8_t **p_data_end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,8 +24,8 @@ void vp10_read_mode_info(VP10Decoder *const pbi, MACROBLOCKD *xd,
|
|||
int supertx_enabled,
|
||||
#endif
|
||||
|
||||
int mi_row, int mi_col, vp10_reader *r,
|
||||
int x_mis, int y_mis);
|
||||
int mi_row, int mi_col, vp10_reader *r, int x_mis,
|
||||
int y_mis);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -58,12 +58,10 @@ static void vp10_dec_setup_mi(VP10_COMMON *cm) {
|
|||
|
||||
static int vp10_dec_alloc_mi(VP10_COMMON *cm, int mi_size) {
|
||||
cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
|
||||
if (!cm->mip)
|
||||
return 1;
|
||||
if (!cm->mip) return 1;
|
||||
cm->mi_alloc_size = mi_size;
|
||||
cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*));
|
||||
if (!cm->mi_grid_base)
|
||||
return 1;
|
||||
cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *));
|
||||
if (!cm->mi_grid_base) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,8 +76,7 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
|||
VP10Decoder *volatile const pbi = vpx_memalign(32, sizeof(*pbi));
|
||||
VP10_COMMON *volatile const cm = pbi ? &pbi->common : NULL;
|
||||
|
||||
if (!cm)
|
||||
return NULL;
|
||||
if (!cm) return NULL;
|
||||
|
||||
vp10_zero(*pbi);
|
||||
|
||||
|
@ -91,11 +88,10 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
|||
|
||||
cm->error.setjmp = 1;
|
||||
|
||||
CHECK_MEM_ERROR(cm, cm->fc,
|
||||
(FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
|
||||
CHECK_MEM_ERROR(cm, cm->frame_contexts,
|
||||
(FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS,
|
||||
sizeof(*cm->frame_contexts)));
|
||||
CHECK_MEM_ERROR(cm, cm->fc, (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
|
||||
CHECK_MEM_ERROR(
|
||||
cm, cm->frame_contexts,
|
||||
(FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, sizeof(*cm->frame_contexts)));
|
||||
|
||||
pbi->need_resync = 1;
|
||||
once(initialize_dec);
|
||||
|
@ -130,8 +126,7 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
|||
void vp10_decoder_remove(VP10Decoder *pbi) {
|
||||
int i;
|
||||
|
||||
if (!pbi)
|
||||
return;
|
||||
if (!pbi) return;
|
||||
|
||||
vpx_get_worker_interface()->end(&pbi->lf_worker);
|
||||
vpx_free(pbi->lf_worker.data1);
|
||||
|
@ -153,13 +148,13 @@ void vp10_decoder_remove(VP10Decoder *pbi) {
|
|||
|
||||
static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
|
||||
const YV12_BUFFER_CONFIG *b) {
|
||||
return a->y_height == b->y_height && a->y_width == b->y_width &&
|
||||
a->uv_height == b->uv_height && a->uv_width == b->uv_width;
|
||||
return a->y_height == b->y_height && a->y_width == b->y_width &&
|
||||
a->uv_height == b->uv_height && a->uv_width == b->uv_width;
|
||||
}
|
||||
|
||||
vpx_codec_err_t vp10_copy_reference_dec(VP10Decoder *pbi,
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
VP10_COMMON *cm = &pbi->common;
|
||||
|
||||
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
|
||||
|
@ -180,17 +175,15 @@ vpx_codec_err_t vp10_copy_reference_dec(VP10Decoder *pbi,
|
|||
else
|
||||
vpx_yv12_copy_frame(cfg, sd);
|
||||
} else {
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||
"Invalid reference frame");
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
|
||||
}
|
||||
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
|
||||
vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
int idx;
|
||||
YV12_BUFFER_CONFIG *ref_buf = NULL;
|
||||
|
||||
|
@ -235,8 +228,7 @@ vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
|||
idx = cm->ref_frame_map[2];
|
||||
#endif // CONFIG_EXT_REFS
|
||||
} else {
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||
"Invalid reference frame");
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
|
@ -275,8 +267,7 @@ static void swap_frame_buffers(VP10Decoder *pbi) {
|
|||
|
||||
// Release the reference frame holding in the reference map for the decoding
|
||||
// of the next frame.
|
||||
if (mask & 1)
|
||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
||||
if (mask & 1) decrease_ref_count(old_idx, frame_bufs, pool);
|
||||
cm->ref_frame_map[ref_index] = cm->next_ref_frame_map[ref_index];
|
||||
++ref_index;
|
||||
}
|
||||
|
@ -307,8 +298,8 @@ static void swap_frame_buffers(VP10Decoder *pbi) {
|
|||
}
|
||||
}
|
||||
|
||||
int vp10_receive_compressed_data(VP10Decoder *pbi,
|
||||
size_t size, const uint8_t **psource) {
|
||||
int vp10_receive_compressed_data(VP10Decoder *pbi, size_t size,
|
||||
const uint8_t **psource) {
|
||||
VP10_COMMON *volatile const cm = &pbi->common;
|
||||
BufferPool *volatile const pool = cm->buffer_pool;
|
||||
RefCntBuffer *volatile const frame_bufs = cm->buffer_pool->frame_bufs;
|
||||
|
@ -338,15 +329,14 @@ int vp10_receive_compressed_data(VP10Decoder *pbi,
|
|||
|
||||
// Check if the previous frame was a frame without any references to it.
|
||||
// Release frame buffer if not decoding in frame parallel mode.
|
||||
if (!cm->frame_parallel_decode && cm->new_fb_idx >= 0
|
||||
&& frame_bufs[cm->new_fb_idx].ref_count == 0)
|
||||
if (!cm->frame_parallel_decode && cm->new_fb_idx >= 0 &&
|
||||
frame_bufs[cm->new_fb_idx].ref_count == 0)
|
||||
pool->release_fb_cb(pool->cb_priv,
|
||||
&frame_bufs[cm->new_fb_idx].raw_frame_buffer);
|
||||
|
||||
// Find a free frame buffer. Return error if can not find any.
|
||||
cm->new_fb_idx = get_free_fb(cm);
|
||||
if (cm->new_fb_idx == INVALID_IDX)
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
if (cm->new_fb_idx == INVALID_IDX) return VPX_CODEC_MEM_ERROR;
|
||||
|
||||
// Assign a MV array to the frame buffer.
|
||||
cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx];
|
||||
|
@ -388,10 +378,9 @@ int vp10_receive_compressed_data(VP10Decoder *pbi,
|
|||
// Current thread releases the holding of reference frame.
|
||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
||||
|
||||
// Release the reference frame holding in the reference map for the
|
||||
// decoding of the next frame.
|
||||
if (mask & 1)
|
||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
||||
// Release the reference frame holding in the reference map for the
|
||||
// decoding of the next frame.
|
||||
if (mask & 1) decrease_ref_count(old_idx, frame_bufs, pool);
|
||||
++ref_index;
|
||||
}
|
||||
|
||||
|
@ -468,14 +457,12 @@ int vp10_receive_compressed_data(VP10Decoder *pbi,
|
|||
int vp10_get_raw_frame(VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd) {
|
||||
VP10_COMMON *const cm = &pbi->common;
|
||||
int ret = -1;
|
||||
if (pbi->ready_for_new_data == 1)
|
||||
return ret;
|
||||
if (pbi->ready_for_new_data == 1) return ret;
|
||||
|
||||
pbi->ready_for_new_data = 1;
|
||||
|
||||
/* no raw frame to show!!! */
|
||||
if (!cm->show_frame)
|
||||
return ret;
|
||||
if (!cm->show_frame) return ret;
|
||||
|
||||
pbi->ready_for_new_data = 1;
|
||||
*sd = *cm->frame_to_show;
|
||||
|
@ -484,22 +471,19 @@ int vp10_get_raw_frame(VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int vp10_get_frame_to_show(VP10Decoder *pbi,
|
||||
YV12_BUFFER_CONFIG *frame) {
|
||||
int vp10_get_frame_to_show(VP10Decoder *pbi, YV12_BUFFER_CONFIG *frame) {
|
||||
VP10_COMMON *const cm = &pbi->common;
|
||||
|
||||
if (!cm->show_frame || !cm->frame_to_show)
|
||||
return -1;
|
||||
if (!cm->show_frame || !cm->frame_to_show) return -1;
|
||||
|
||||
*frame = *cm->frame_to_show;
|
||||
return 0;
|
||||
}
|
||||
|
||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
||||
size_t data_sz,
|
||||
uint32_t sizes[8], int *count,
|
||||
vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state) {
|
||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data, size_t data_sz,
|
||||
uint32_t sizes[8], int *count,
|
||||
vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state) {
|
||||
// A chunk ending with a byte matching 0xc0 is an invalid chunk unless
|
||||
// it is a super frame index. If the last byte of real video compression
|
||||
// data is 0xc0 the encoder must add a 0 byte. If we have the marker but
|
||||
|
@ -520,18 +504,16 @@ vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
|||
|
||||
// This chunk is marked as having a superframe index but doesn't have
|
||||
// enough data for it, thus it's an invalid superframe index.
|
||||
if (data_sz < index_sz)
|
||||
return VPX_CODEC_CORRUPT_FRAME;
|
||||
if (data_sz < index_sz) return VPX_CODEC_CORRUPT_FRAME;
|
||||
|
||||
{
|
||||
const uint8_t marker2 = read_marker(decrypt_cb, decrypt_state,
|
||||
data + data_sz - index_sz);
|
||||
const uint8_t marker2 =
|
||||
read_marker(decrypt_cb, decrypt_state, data + data_sz - index_sz);
|
||||
|
||||
// This chunk is marked as having a superframe index but doesn't have
|
||||
// the matching marker byte at the front of the index therefore it's an
|
||||
// invalid chunk.
|
||||
if (marker != marker2)
|
||||
return VPX_CODEC_CORRUPT_FRAME;
|
||||
if (marker != marker2) return VPX_CODEC_CORRUPT_FRAME;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -550,8 +532,7 @@ vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
|||
for (i = 0; i < frames - 1; ++i) {
|
||||
uint32_t this_sz = 0;
|
||||
|
||||
for (j = 0; j < mag; ++j)
|
||||
this_sz |= (*x++) << (j * 8);
|
||||
for (j = 0; j < mag; ++j) this_sz |= (*x++) << (j * 8);
|
||||
this_sz += 1;
|
||||
sizes[i] = this_sz;
|
||||
frame_sz_sum += this_sz;
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct TileBufferDec {
|
|||
size_t size;
|
||||
const uint8_t *raw_data_end; // The end of the raw tile buffer in the
|
||||
// bit stream.
|
||||
int col; // only used with multi-threaded decoding
|
||||
int col; // only used with multi-threaded decoding
|
||||
} TileBufferDec;
|
||||
|
||||
typedef struct VP10Decoder {
|
||||
|
@ -66,9 +66,9 @@ typedef struct VP10Decoder {
|
|||
|
||||
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
|
||||
// the same.
|
||||
RefCntBuffer *cur_buf; // Current decoding frame buffer.
|
||||
RefCntBuffer *cur_buf; // Current decoding frame buffer.
|
||||
|
||||
VPxWorker *frame_worker_owner; // frame_worker that owns this pbi.
|
||||
VPxWorker *frame_worker_owner; // frame_worker that owns this pbi.
|
||||
VPxWorker lf_worker;
|
||||
VPxWorker *tile_workers;
|
||||
TileWorkerData *tile_worker_data;
|
||||
|
@ -87,7 +87,7 @@ typedef struct VP10Decoder {
|
|||
|
||||
int max_threads;
|
||||
int inv_tile_order;
|
||||
int need_resync; // wait for key/intra-only frame.
|
||||
int need_resync; // wait for key/intra-only frame.
|
||||
int hold_ref_buf; // hold the reference buffer.
|
||||
|
||||
int tile_size_bytes;
|
||||
|
@ -97,24 +97,23 @@ typedef struct VP10Decoder {
|
|||
#endif // CONFIG_EXT_TILE
|
||||
} VP10Decoder;
|
||||
|
||||
int vp10_receive_compressed_data(struct VP10Decoder *pbi,
|
||||
size_t size, const uint8_t **dest);
|
||||
int vp10_receive_compressed_data(struct VP10Decoder *pbi, size_t size,
|
||||
const uint8_t **dest);
|
||||
|
||||
int vp10_get_raw_frame(struct VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
int vp10_get_frame_to_show(struct VP10Decoder *pbi, YV12_BUFFER_CONFIG *frame);
|
||||
|
||||
vpx_codec_err_t vp10_copy_reference_dec(struct VP10Decoder *pbi,
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
||||
VPX_REFFRAME ref_frame_flag,
|
||||
YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state,
|
||||
const uint8_t *data) {
|
||||
void *decrypt_state, const uint8_t *data) {
|
||||
if (decrypt_cb) {
|
||||
uint8_t marker;
|
||||
decrypt_cb(decrypt_state, data, &marker, 1);
|
||||
|
@ -125,11 +124,10 @@ static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
|
|||
|
||||
// This function is exposed for use in tests, as well as the inlined function
|
||||
// "read_marker".
|
||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
||||
size_t data_sz,
|
||||
uint32_t sizes[8], int *count,
|
||||
vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state);
|
||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data, size_t data_sz,
|
||||
uint32_t sizes[8], int *count,
|
||||
vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state);
|
||||
|
||||
struct VP10Decoder *vp10_decoder_create(BufferPool *const pool);
|
||||
|
||||
|
@ -158,8 +156,7 @@ static INLINE int dec_is_ref_frame_buf(VP10Decoder *const pbi,
|
|||
for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
|
||||
RefBuffer *const ref_frame = &cm->frame_refs[i];
|
||||
if (ref_frame->idx == INVALID_IDX) continue;
|
||||
if (frame_buf == &cm->buffer_pool->frame_bufs[ref_frame->idx])
|
||||
break;
|
||||
if (frame_buf == &cm->buffer_pool->frame_bufs[ref_frame->idx]) break;
|
||||
}
|
||||
return (i < INTER_REFS_PER_FRAME);
|
||||
}
|
||||
|
|
|
@ -19,34 +19,31 @@
|
|||
|
||||
#include "vp10/decoder/detokenize.h"
|
||||
|
||||
#define EOB_CONTEXT_NODE 0
|
||||
#define ZERO_CONTEXT_NODE 1
|
||||
#define ONE_CONTEXT_NODE 2
|
||||
#define LOW_VAL_CONTEXT_NODE 0
|
||||
#define TWO_CONTEXT_NODE 1
|
||||
#define THREE_CONTEXT_NODE 2
|
||||
#define HIGH_LOW_CONTEXT_NODE 3
|
||||
#define CAT_ONE_CONTEXT_NODE 4
|
||||
#define CAT_THREEFOUR_CONTEXT_NODE 5
|
||||
#define CAT_THREE_CONTEXT_NODE 6
|
||||
#define CAT_FIVE_CONTEXT_NODE 7
|
||||
#define EOB_CONTEXT_NODE 0
|
||||
#define ZERO_CONTEXT_NODE 1
|
||||
#define ONE_CONTEXT_NODE 2
|
||||
#define LOW_VAL_CONTEXT_NODE 0
|
||||
#define TWO_CONTEXT_NODE 1
|
||||
#define THREE_CONTEXT_NODE 2
|
||||
#define HIGH_LOW_CONTEXT_NODE 3
|
||||
#define CAT_ONE_CONTEXT_NODE 4
|
||||
#define CAT_THREEFOUR_CONTEXT_NODE 5
|
||||
#define CAT_THREE_CONTEXT_NODE 6
|
||||
#define CAT_FIVE_CONTEXT_NODE 7
|
||||
|
||||
#define INCREMENT_COUNT(token) \
|
||||
do { \
|
||||
if (counts) \
|
||||
++coef_counts[band][ctx][token]; \
|
||||
#define INCREMENT_COUNT(token) \
|
||||
do { \
|
||||
if (counts) ++coef_counts[band][ctx][token]; \
|
||||
} while (0)
|
||||
|
||||
#if !CONFIG_ANS
|
||||
static INLINE int read_coeff(const vpx_prob *probs, int n, vp10_reader *r) {
|
||||
int i, val = 0;
|
||||
for (i = 0; i < n; ++i)
|
||||
val = (val << 1) | vp10_read(r, probs[i]);
|
||||
for (i = 0; i < n; ++i) val = (val << 1) | vp10_read(r, probs[i]);
|
||||
return val;
|
||||
}
|
||||
|
||||
static int decode_coefs(const MACROBLOCKD *xd,
|
||||
PLANE_TYPE type,
|
||||
static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
|
||||
tran_low_t *dqcoeff, TX_SIZE tx_size, TX_TYPE tx_type,
|
||||
const int16_t *dq,
|
||||
#if CONFIG_NEW_QUANT
|
||||
|
@ -60,11 +57,11 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
const int ref = is_inter_block(&xd->mi[0]->mbmi);
|
||||
int band, c = 0;
|
||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
||||
const vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
const vpx_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
fc->coef_probs[tx_size_ctx][type][ref];
|
||||
const vpx_prob *prob;
|
||||
unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||
unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
|
||||
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
|
||||
uint8_t token_cache[MAX_TX_SQUARE];
|
||||
const uint8_t *band_translate = get_band_translate(tx_size);
|
||||
int dq_shift;
|
||||
|
@ -125,8 +122,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
int val = -1;
|
||||
band = *band_translate++;
|
||||
prob = coef_probs[band][ctx];
|
||||
if (counts)
|
||||
++eob_branch_count[band][ctx];
|
||||
if (counts) ++eob_branch_count[band][ctx];
|
||||
if (!vp10_read(r, prob[EOB_CONTEXT_NODE])) {
|
||||
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||
break;
|
||||
|
@ -141,8 +137,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
dqv = dq[1];
|
||||
token_cache[scan[c]] = 0;
|
||||
++c;
|
||||
if (c >= max_eob)
|
||||
return c; // zero tokens at the end (no eob token)
|
||||
if (c >= max_eob) return c; // zero tokens at the end (no eob token)
|
||||
ctx = get_coef_context(nb, token_cache, c);
|
||||
band = *band_translate++;
|
||||
prob = coef_probs[band][ctx];
|
||||
|
@ -158,13 +153,11 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
} else {
|
||||
INCREMENT_COUNT(TWO_TOKEN);
|
||||
token = vp10_read_tree(r, vp10_coef_con_tree,
|
||||
vp10_pareto8_full[prob[PIVOT_NODE] - 1]);
|
||||
vp10_pareto8_full[prob[PIVOT_NODE] - 1]);
|
||||
switch (token) {
|
||||
case TWO_TOKEN:
|
||||
case THREE_TOKEN:
|
||||
case FOUR_TOKEN:
|
||||
val = token;
|
||||
break;
|
||||
case FOUR_TOKEN: val = token; break;
|
||||
case CATEGORY1_TOKEN:
|
||||
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
|
||||
break;
|
||||
|
@ -194,9 +187,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
case VPX_BITS_12:
|
||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return -1;
|
||||
default: assert(0); return -1;
|
||||
}
|
||||
#else
|
||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
|
||||
|
@ -214,8 +205,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
|
||||
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
#if CONFIG_VP9_HIGHBITDEPTH
|
||||
dqcoeff[scan[c]] = highbd_check_range((vp10_read_bit(r) ? -v : v),
|
||||
xd->bd);
|
||||
dqcoeff[scan[c]] = highbd_check_range((vp10_read_bit(r) ? -v : v), xd->bd);
|
||||
#else
|
||||
dqcoeff[scan[c]] = check_range(vp10_read_bit(r) ? -v : v);
|
||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||
|
@ -234,16 +224,13 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
|||
static INLINE int read_coeff(const vpx_prob *const probs, int n,
|
||||
struct AnsDecoder *const ans) {
|
||||
int i, val = 0;
|
||||
for (i = 0; i < n; ++i)
|
||||
val = (val << 1) | uabs_read(ans, probs[i]);
|
||||
for (i = 0; i < n; ++i) val = (val << 1) | uabs_read(ans, probs[i]);
|
||||
return val;
|
||||
}
|
||||
|
||||
static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||
PLANE_TYPE type,
|
||||
static int decode_coefs_ans(const MACROBLOCKD *const xd, PLANE_TYPE type,
|
||||
tran_low_t *dqcoeff, TX_SIZE tx_size,
|
||||
TX_TYPE tx_type,
|
||||
const int16_t *dq,
|
||||
TX_TYPE tx_type, const int16_t *dq,
|
||||
#if CONFIG_NEW_QUANT
|
||||
dequant_val_type_nuq *dq_val,
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
@ -256,14 +243,14 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
int band, c = 0;
|
||||
int skip_eob = 0;
|
||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
||||
const vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
const vpx_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
fc->coef_probs[tx_size_ctx][type][ref];
|
||||
const rans_dec_lut(*coef_cdfs)[COEFF_CONTEXTS] =
|
||||
fc->coef_cdfs[tx_size_ctx][type][ref];
|
||||
const vpx_prob *prob;
|
||||
const rans_dec_lut *cdf;
|
||||
unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||
unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
|
||||
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
|
||||
uint8_t token_cache[MAX_TX_SQUARE];
|
||||
const uint8_t *band_translate = get_band_translate(tx_size);
|
||||
int dq_shift;
|
||||
|
@ -325,8 +312,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
band = *band_translate++;
|
||||
prob = coef_probs[band][ctx];
|
||||
if (!skip_eob) {
|
||||
if (counts)
|
||||
++eob_branch_count[band][ctx];
|
||||
if (counts) ++eob_branch_count[band][ctx];
|
||||
if (!uabs_read(ans, prob[EOB_CONTEXT_NODE])) {
|
||||
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||
break;
|
||||
|
@ -349,9 +335,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
case ONE_TOKEN:
|
||||
case TWO_TOKEN:
|
||||
case THREE_TOKEN:
|
||||
case FOUR_TOKEN:
|
||||
val = token;
|
||||
break;
|
||||
case FOUR_TOKEN: val = token; break;
|
||||
case CATEGORY1_TOKEN:
|
||||
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, ans);
|
||||
break;
|
||||
|
@ -381,9 +365,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
case VPX_BITS_12:
|
||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, ans);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return -1;
|
||||
default: assert(0); return -1;
|
||||
}
|
||||
#else
|
||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, ans);
|
||||
|
@ -391,10 +373,10 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
} break;
|
||||
}
|
||||
#if CONFIG_NEW_QUANT
|
||||
v = vp10_dequant_abscoeff_nuq(val, dqv, dqv_val);
|
||||
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
|
||||
v = vp10_dequant_abscoeff_nuq(val, dqv, dqv_val);
|
||||
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
|
||||
#else
|
||||
v = (val * dqv) >> dq_shift;
|
||||
v = (val * dqv) >> dq_shift;
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
||||
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
|
@ -419,12 +401,12 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
|||
}
|
||||
#endif // !CONFIG_ANS
|
||||
|
||||
// TODO(slavarnway): Decode version of vp10_set_context. Modify vp10_set_context
|
||||
// TODO(slavarnway): Decode version of vp10_set_context. Modify
|
||||
// vp10_set_context
|
||||
// after testing is complete, then delete this version.
|
||||
static
|
||||
void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
|
||||
TX_SIZE tx_size, int has_eob,
|
||||
int aoff, int loff) {
|
||||
static void dec_set_contexts(const MACROBLOCKD *xd,
|
||||
struct macroblockd_plane *pd, TX_SIZE tx_size,
|
||||
int has_eob, int aoff, int loff) {
|
||||
ENTROPY_CONTEXT *const a = pd->above_context + aoff;
|
||||
ENTROPY_CONTEXT *const l = pd->left_context + loff;
|
||||
const int tx_w_in_blocks = num_4x4_blocks_wide_txsize_lookup[tx_size];
|
||||
|
@ -433,16 +415,14 @@ void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
|
|||
// above
|
||||
if (has_eob && xd->mb_to_right_edge < 0) {
|
||||
int i;
|
||||
const int blocks_wide = pd->n4_w +
|
||||
(xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
const int blocks_wide =
|
||||
pd->n4_w + (xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
int above_contexts = tx_w_in_blocks;
|
||||
if (above_contexts + aoff > blocks_wide)
|
||||
above_contexts = blocks_wide - aoff;
|
||||
|
||||
for (i = 0; i < above_contexts; ++i)
|
||||
a[i] = has_eob;
|
||||
for (i = above_contexts; i < tx_w_in_blocks; ++i)
|
||||
a[i] = 0;
|
||||
for (i = 0; i < above_contexts; ++i) a[i] = has_eob;
|
||||
for (i = above_contexts; i < tx_w_in_blocks; ++i) a[i] = 0;
|
||||
} else {
|
||||
memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_w_in_blocks);
|
||||
}
|
||||
|
@ -450,16 +430,13 @@ void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
|
|||
// left
|
||||
if (has_eob && xd->mb_to_bottom_edge < 0) {
|
||||
int i;
|
||||
const int blocks_high = pd->n4_h +
|
||||
(xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
const int blocks_high =
|
||||
pd->n4_h + (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
int left_contexts = tx_h_in_blocks;
|
||||
if (left_contexts + loff > blocks_high)
|
||||
left_contexts = blocks_high - loff;
|
||||
if (left_contexts + loff > blocks_high) left_contexts = blocks_high - loff;
|
||||
|
||||
for (i = 0; i < left_contexts; ++i)
|
||||
l[i] = has_eob;
|
||||
for (i = left_contexts; i < tx_h_in_blocks; ++i)
|
||||
l[i] = 0;
|
||||
for (i = 0; i < left_contexts; ++i) l[i] = has_eob;
|
||||
for (i = left_contexts; i < tx_h_in_blocks; ++i) l[i] = 0;
|
||||
} else {
|
||||
memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_h_in_blocks);
|
||||
}
|
||||
|
@ -471,34 +448,32 @@ void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
|||
MB_MODE_INFO *const mbmi = &mi->mbmi;
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
|
||||
(xd->plane[plane != 0].subsampling_y);
|
||||
(xd->plane[plane != 0].subsampling_y);
|
||||
const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >>
|
||||
(xd->plane[plane != 0].subsampling_x);
|
||||
(xd->plane[plane != 0].subsampling_x);
|
||||
int color_idx, color_ctx, color_order[PALETTE_MAX_SIZE];
|
||||
int n = mbmi->palette_mode_info.palette_size[plane != 0];
|
||||
int i, j;
|
||||
uint8_t *color_map = xd->plane[plane != 0].color_index_map;
|
||||
const vpx_prob (* const prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
|
||||
plane ? vp10_default_palette_uv_color_prob :
|
||||
vp10_default_palette_y_color_prob;
|
||||
const vpx_prob (*const prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
|
||||
plane ? vp10_default_palette_uv_color_prob
|
||||
: vp10_default_palette_y_color_prob;
|
||||
|
||||
for (i = 0; i < rows; ++i) {
|
||||
for (j = (i == 0 ? 1 : 0); j < cols; ++j) {
|
||||
color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, n,
|
||||
color_order);
|
||||
color_ctx =
|
||||
vp10_get_palette_color_context(color_map, cols, i, j, n, color_order);
|
||||
color_idx = vp10_read_tree(r, vp10_palette_color_tree[n - 2],
|
||||
prob[n - 2][color_ctx]);
|
||||
prob[n - 2][color_ctx]);
|
||||
assert(color_idx >= 0 && color_idx < n);
|
||||
color_map[i * cols + j] = color_order[color_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
||||
int plane, const scan_order *sc,
|
||||
int x, int y,
|
||||
TX_SIZE tx_size,
|
||||
TX_TYPE tx_type,
|
||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd, int plane,
|
||||
const scan_order *sc, int x, int y,
|
||||
TX_SIZE tx_size, TX_TYPE tx_type,
|
||||
#if CONFIG_ANS
|
||||
struct AnsDecoder *const r,
|
||||
#else
|
||||
|
@ -507,24 +482,22 @@ int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
|||
int seg_id) {
|
||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
const int16_t *const dequant = pd->seg_dequant[seg_id];
|
||||
const int ctx = get_entropy_context(tx_size, pd->above_context + x,
|
||||
pd->left_context + y);
|
||||
const int ctx =
|
||||
get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
|
||||
#if CONFIG_NEW_QUANT
|
||||
int dq = get_dq_profile_from_ctx(ctx);
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
||||
#if !CONFIG_ANS
|
||||
const int eob = decode_coefs(xd, pd->plane_type,
|
||||
pd->dqcoeff, tx_size, tx_type,
|
||||
dequant,
|
||||
const int eob =
|
||||
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
|
||||
#if CONFIG_NEW_QUANT
|
||||
pd->seg_dequant_nuq[seg_id][dq],
|
||||
pd->seg_dequant_nuq[seg_id][dq],
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
ctx, sc->scan, sc->neighbors, r);
|
||||
ctx, sc->scan, sc->neighbors, r);
|
||||
#else
|
||||
const int eob = decode_coefs_ans(xd, pd->plane_type,
|
||||
pd->dqcoeff, tx_size, tx_type,
|
||||
dequant,
|
||||
const int eob = decode_coefs_ans(xd, pd->plane_type, pd->dqcoeff, tx_size,
|
||||
tx_type, dequant,
|
||||
#if CONFIG_NEW_QUANT
|
||||
pd->seg_dequant_nuq[seg_id][dq],
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VP10_DECODER_DETOKENIZE_H_
|
||||
#define VP10_DECODER_DETOKENIZE_H_
|
||||
|
||||
|
@ -22,11 +21,9 @@ extern "C" {
|
|||
|
||||
void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
||||
vp10_reader *r);
|
||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
||||
int plane, const scan_order *sc,
|
||||
int x, int y,
|
||||
TX_SIZE tx_size,
|
||||
TX_TYPE tx_type,
|
||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd, int plane,
|
||||
const scan_order *sc, int x, int y,
|
||||
TX_SIZE tx_size, TX_TYPE tx_type,
|
||||
#if CONFIG_ANS
|
||||
struct AnsDecoder *const r,
|
||||
#else
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
#include "vp10/decoder/dsubexp.h"
|
||||
|
||||
static int inv_recenter_nonneg(int v, int m) {
|
||||
if (v > 2 * m)
|
||||
return v;
|
||||
if (v > 2 * m) return v;
|
||||
|
||||
return (v & 1) ? m - ((v + 1) >> 1) : m + (v >> 1);
|
||||
}
|
||||
|
@ -25,19 +24,19 @@ static int decode_uniform(vp10_reader *r) {
|
|||
const int l = 8;
|
||||
const int m = (1 << l) - 190;
|
||||
const int v = vp10_read_literal(r, l - 1);
|
||||
return v < m ? v : (v << 1) - m + vp10_read_bit(r);
|
||||
return v < m ? v : (v << 1) - m + vp10_read_bit(r);
|
||||
}
|
||||
|
||||
static int inv_remap_prob(int v, int m) {
|
||||
static uint8_t inv_map_table[MAX_PROB - 1] = {
|
||||
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189,
|
||||
202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11,
|
||||
12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27,
|
||||
28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
|
||||
44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60,
|
||||
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76,
|
||||
77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 92,
|
||||
93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
|
||||
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189,
|
||||
202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11,
|
||||
12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27,
|
||||
28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
|
||||
44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60,
|
||||
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76,
|
||||
77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 91, 92,
|
||||
93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
|
||||
109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 125,
|
||||
126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141,
|
||||
142, 143, 144, 145, 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157,
|
||||
|
@ -59,16 +58,13 @@ static int inv_remap_prob(int v, int m) {
|
|||
}
|
||||
|
||||
static int decode_term_subexp(vp10_reader *r) {
|
||||
if (!vp10_read_bit(r))
|
||||
return vp10_read_literal(r, 4);
|
||||
if (!vp10_read_bit(r))
|
||||
return vp10_read_literal(r, 4) + 16;
|
||||
if (!vp10_read_bit(r))
|
||||
return vp10_read_literal(r, 5) + 32;
|
||||
if (!vp10_read_bit(r)) return vp10_read_literal(r, 4);
|
||||
if (!vp10_read_bit(r)) return vp10_read_literal(r, 4) + 16;
|
||||
if (!vp10_read_bit(r)) return vp10_read_literal(r, 5) + 32;
|
||||
return decode_uniform(r) + 64;
|
||||
}
|
||||
|
||||
void vp10_diff_update_prob(vp10_reader *r, vpx_prob* p) {
|
||||
void vp10_diff_update_prob(vp10_reader *r, vpx_prob *p) {
|
||||
if (vp10_read(r, DIFF_UPDATE_PROB)) {
|
||||
const int delp = decode_term_subexp(r);
|
||||
*p = (vpx_prob)inv_remap_prob(delp, *p);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VP10_DECODER_DSUBEXP_H_
|
||||
#define VP10_DECODER_DSUBEXP_H_
|
||||
|
||||
|
@ -18,7 +17,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void vp10_diff_update_prob(vp10_reader *r, vpx_prob* p);
|
||||
void vp10_diff_update_prob(vp10_reader *r, vpx_prob *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -60,10 +60,9 @@ void vp10_frameworker_signal_stats(VPxWorker *const worker) {
|
|||
|
||||
// TODO(hkuang): Remove worker parameter as it is only used in debug code.
|
||||
void vp10_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
|
||||
int row) {
|
||||
int row) {
|
||||
#if CONFIG_MULTITHREAD
|
||||
if (!ref_buf)
|
||||
return;
|
||||
if (!ref_buf) return;
|
||||
|
||||
#ifndef BUILDING_WITH_TSAN
|
||||
// The following line of code will get harmless tsan error but it is the key
|
||||
|
@ -135,7 +134,7 @@ void vp10_frameworker_broadcast(RefCntBuffer *const buf, int row) {
|
|||
}
|
||||
|
||||
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
||||
VPxWorker *const src_worker) {
|
||||
VPxWorker *const src_worker) {
|
||||
#if CONFIG_MULTITHREAD
|
||||
FrameWorkerData *const src_worker_data = (FrameWorkerData *)src_worker->data1;
|
||||
FrameWorkerData *const dst_worker_data = (FrameWorkerData *)dst_worker->data1;
|
||||
|
@ -147,11 +146,12 @@ void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
|||
vp10_frameworker_lock_stats(src_worker);
|
||||
while (!src_worker_data->frame_context_ready) {
|
||||
pthread_cond_wait(&src_worker_data->stats_cond,
|
||||
&src_worker_data->stats_mutex);
|
||||
&src_worker_data->stats_mutex);
|
||||
}
|
||||
|
||||
dst_cm->last_frame_seg_map = src_cm->seg.enabled ?
|
||||
src_cm->current_frame_seg_map : src_cm->last_frame_seg_map;
|
||||
dst_cm->last_frame_seg_map = src_cm->seg.enabled
|
||||
? src_cm->current_frame_seg_map
|
||||
: src_cm->last_frame_seg_map;
|
||||
dst_worker_data->pbi->need_resync = src_worker_data->pbi->need_resync;
|
||||
vp10_frameworker_unlock_stats(src_worker);
|
||||
|
||||
|
@ -160,19 +160,20 @@ void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
|||
dst_cm->use_highbitdepth = src_cm->use_highbitdepth;
|
||||
#endif
|
||||
#if CONFIG_EXT_REFS
|
||||
// TODO(zoeliu): To handle parallel decoding
|
||||
// TODO(zoeliu): To handle parallel decoding
|
||||
#endif // CONFIG_EXT_REFS
|
||||
dst_cm->prev_frame = src_cm->show_existing_frame ?
|
||||
src_cm->prev_frame : src_cm->cur_frame;
|
||||
dst_cm->last_width = !src_cm->show_existing_frame ?
|
||||
src_cm->width : src_cm->last_width;
|
||||
dst_cm->last_height = !src_cm->show_existing_frame ?
|
||||
src_cm->height : src_cm->last_height;
|
||||
dst_cm->prev_frame =
|
||||
src_cm->show_existing_frame ? src_cm->prev_frame : src_cm->cur_frame;
|
||||
dst_cm->last_width =
|
||||
!src_cm->show_existing_frame ? src_cm->width : src_cm->last_width;
|
||||
dst_cm->last_height =
|
||||
!src_cm->show_existing_frame ? src_cm->height : src_cm->last_height;
|
||||
dst_cm->subsampling_x = src_cm->subsampling_x;
|
||||
dst_cm->subsampling_y = src_cm->subsampling_y;
|
||||
dst_cm->frame_type = src_cm->frame_type;
|
||||
dst_cm->last_show_frame = !src_cm->show_existing_frame ?
|
||||
src_cm->show_frame : src_cm->last_show_frame;
|
||||
dst_cm->last_show_frame = !src_cm->show_existing_frame
|
||||
? src_cm->show_frame
|
||||
: src_cm->last_show_frame;
|
||||
for (i = 0; i < REF_FRAMES; ++i)
|
||||
dst_cm->ref_frame_map[i] = src_cm->next_ref_frame_map[i];
|
||||
|
||||
|
@ -186,7 +187,7 @@ void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
|||
memcpy(dst_cm->frame_contexts, src_cm->frame_contexts,
|
||||
FRAME_CONTEXTS * sizeof(dst_cm->frame_contexts[0]));
|
||||
#else
|
||||
(void) dst_worker;
|
||||
(void) src_worker;
|
||||
(void)dst_worker;
|
||||
(void)src_worker;
|
||||
#endif // CONFIG_MULTITHREAD
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void vp10_frameworker_signal_stats(VPxWorker *const worker);
|
|||
// start decoding next frame. So need to check whether worker is still decoding
|
||||
// ref_buf.
|
||||
void vp10_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
|
||||
int row);
|
||||
int row);
|
||||
|
||||
// FrameWorker broadcasts its decoding progress so other workers that are
|
||||
// waiting on it can resume decoding.
|
||||
|
@ -65,10 +65,10 @@ void vp10_frameworker_broadcast(RefCntBuffer *const buf, int row);
|
|||
|
||||
// Copy necessary decoding context from src worker to dst worker.
|
||||
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
||||
VPxWorker *const src_worker);
|
||||
VPxWorker *const src_worker);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VP10_DECODER_DTHREAD_H_
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -34,7 +34,7 @@ typedef vpx_codec_stream_info_t vp10_stream_info_t;
|
|||
|
||||
// This limit is due to framebuffer numbers.
|
||||
// TODO(hkuang): Remove this limit after implementing ondemand framebuffers.
|
||||
#define FRAME_CACHE_SIZE 6 // Cache maximum 6 decoded frames.
|
||||
#define FRAME_CACHE_SIZE 6 // Cache maximum 6 decoded frames.
|
||||
|
||||
typedef struct cache_frame {
|
||||
int fb_idx;
|
||||
|
@ -42,38 +42,38 @@ typedef struct cache_frame {
|
|||
} cache_frame;
|
||||
|
||||
struct vpx_codec_alg_priv {
|
||||
vpx_codec_priv_t base;
|
||||
vpx_codec_dec_cfg_t cfg;
|
||||
vp10_stream_info_t si;
|
||||
int postproc_cfg_set;
|
||||
vp8_postproc_cfg_t postproc_cfg;
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
void *decrypt_state;
|
||||
vpx_image_t img;
|
||||
int img_avail;
|
||||
int flushed;
|
||||
int invert_tile_order;
|
||||
int last_show_frame; // Index of last output frame.
|
||||
int byte_alignment;
|
||||
int skip_loop_filter;
|
||||
int decode_tile_row;
|
||||
int decode_tile_col;
|
||||
vpx_codec_priv_t base;
|
||||
vpx_codec_dec_cfg_t cfg;
|
||||
vp10_stream_info_t si;
|
||||
int postproc_cfg_set;
|
||||
vp8_postproc_cfg_t postproc_cfg;
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
void *decrypt_state;
|
||||
vpx_image_t img;
|
||||
int img_avail;
|
||||
int flushed;
|
||||
int invert_tile_order;
|
||||
int last_show_frame; // Index of last output frame.
|
||||
int byte_alignment;
|
||||
int skip_loop_filter;
|
||||
int decode_tile_row;
|
||||
int decode_tile_col;
|
||||
|
||||
// Frame parallel related.
|
||||
int frame_parallel_decode; // frame-based threading.
|
||||
VPxWorker *frame_workers;
|
||||
int num_frame_workers;
|
||||
int next_submit_worker_id;
|
||||
int last_submit_worker_id;
|
||||
int next_output_worker_id;
|
||||
int available_threads;
|
||||
cache_frame frame_cache[FRAME_CACHE_SIZE];
|
||||
int frame_cache_write;
|
||||
int frame_cache_read;
|
||||
int num_cache_frames;
|
||||
int need_resync; // wait for key/intra-only frame
|
||||
int frame_parallel_decode; // frame-based threading.
|
||||
VPxWorker *frame_workers;
|
||||
int num_frame_workers;
|
||||
int next_submit_worker_id;
|
||||
int last_submit_worker_id;
|
||||
int next_output_worker_id;
|
||||
int available_threads;
|
||||
cache_frame frame_cache[FRAME_CACHE_SIZE];
|
||||
int frame_cache_write;
|
||||
int frame_cache_read;
|
||||
int num_cache_frames;
|
||||
int need_resync; // wait for key/intra-only frame
|
||||
// BufferPool that holds all reference frames. Shared by all the FrameWorkers.
|
||||
BufferPool *buffer_pool;
|
||||
BufferPool *buffer_pool;
|
||||
|
||||
// External frame buffer info to save for VP10 common.
|
||||
void *ext_priv; // Private data associated with the external frame buffers.
|
||||
|
@ -91,8 +91,7 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
|
|||
if (!ctx->priv) {
|
||||
vpx_codec_alg_priv_t *const priv =
|
||||
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
|
||||
if (priv == NULL)
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
if (priv == NULL) return VPX_CODEC_MEM_ERROR;
|
||||
|
||||
ctx->priv = (vpx_codec_priv_t *)priv;
|
||||
ctx->priv->init_flags = ctx->init_flags;
|
||||
|
@ -101,7 +100,9 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
|
|||
// Only do frame parallel decode when threads > 1.
|
||||
priv->frame_parallel_decode =
|
||||
(ctx->config.dec && (ctx->config.dec->threads > 1) &&
|
||||
(ctx->init_flags & VPX_CODEC_USE_FRAME_THREADING)) ? 1 : 0;
|
||||
(ctx->init_flags & VPX_CODEC_USE_FRAME_THREADING))
|
||||
? 1
|
||||
: 0;
|
||||
if (ctx->config.dec) {
|
||||
priv->cfg = *ctx->config.dec;
|
||||
ctx->config.dec = &priv->cfg;
|
||||
|
@ -147,11 +148,10 @@ static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) {
|
|||
return VPX_CODEC_OK;
|
||||
}
|
||||
|
||||
static int parse_bitdepth_colorspace_sampling(
|
||||
BITSTREAM_PROFILE profile, struct vpx_read_bit_buffer *rb) {
|
||||
static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
|
||||
struct vpx_read_bit_buffer *rb) {
|
||||
vpx_color_space_t color_space;
|
||||
if (profile >= PROFILE_2)
|
||||
rb->bit_offset += 1; // Bit-depth 10 or 12.
|
||||
if (profile >= PROFILE_2) rb->bit_offset += 1; // Bit-depth 10 or 12.
|
||||
color_space = (vpx_color_space_t)vpx_rb_read_literal(rb, 3);
|
||||
if (color_space != VPX_CS_SRGB) {
|
||||
rb->bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range.
|
||||
|
@ -170,17 +170,13 @@ static int parse_bitdepth_colorspace_sampling(
|
|||
return 1;
|
||||
}
|
||||
|
||||
static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si,
|
||||
int *is_intra_only,
|
||||
vpx_decrypt_cb decrypt_cb,
|
||||
void *decrypt_state) {
|
||||
static vpx_codec_err_t decoder_peek_si_internal(
|
||||
const uint8_t *data, unsigned int data_sz, vpx_codec_stream_info_t *si,
|
||||
int *is_intra_only, vpx_decrypt_cb decrypt_cb, void *decrypt_state) {
|
||||
int intra_only_flag = 0;
|
||||
uint8_t clear_buffer[9];
|
||||
|
||||
if (data + data_sz <= data)
|
||||
return VPX_CODEC_INVALID_PARAM;
|
||||
if (data + data_sz <= data) return VPX_CODEC_INVALID_PARAM;
|
||||
|
||||
si->is_kf = 0;
|
||||
si->w = si->h = 0;
|
||||
|
@ -198,30 +194,26 @@ static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
|
|||
const int frame_marker = vpx_rb_read_literal(&rb, 2);
|
||||
const BITSTREAM_PROFILE profile = vp10_read_profile(&rb);
|
||||
|
||||
if (frame_marker != VPX_FRAME_MARKER)
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (frame_marker != VPX_FRAME_MARKER) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
||||
if (profile >= MAX_PROFILES)
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (profile >= MAX_PROFILES) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
||||
if ((profile >= 2 && data_sz <= 1) || data_sz < 1)
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
||||
if (vpx_rb_read_bit(&rb)) { // show an existing frame
|
||||
if (vpx_rb_read_bit(&rb)) { // show an existing frame
|
||||
vpx_rb_read_literal(&rb, 3); // Frame buffer to show.
|
||||
return VPX_CODEC_OK;
|
||||
}
|
||||
|
||||
if (data_sz <= 8)
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (data_sz <= 8) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
||||
si->is_kf = !vpx_rb_read_bit(&rb);
|
||||
show_frame = vpx_rb_read_bit(&rb);
|
||||
error_resilient = vpx_rb_read_bit(&rb);
|
||||
|
||||
if (si->is_kf) {
|
||||
if (!vp10_read_sync_code(&rb))
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (!vp10_read_sync_code(&rb)) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
||||
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
@ -232,8 +224,7 @@ static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
|
|||
rb.bit_offset += error_resilient ? 0 : 2; // reset_frame_context
|
||||
|
||||
if (intra_only_flag) {
|
||||
if (!vp10_read_sync_code(&rb))
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (!vp10_read_sync_code(&rb)) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
if (profile > PROFILE_0) {
|
||||
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
||||
|
@ -243,8 +234,7 @@ static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (is_intra_only != NULL)
|
||||
*is_intra_only = intra_only_flag;
|
||||
if (is_intra_only != NULL) *is_intra_only = intra_only_flag;
|
||||
return VPX_CODEC_OK;
|
||||
}
|
||||
|
||||
|
@ -257,8 +247,8 @@ static vpx_codec_err_t decoder_peek_si(const uint8_t *data,
|
|||
static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx,
|
||||
vpx_codec_stream_info_t *si) {
|
||||
const size_t sz = (si->sz >= sizeof(vp10_stream_info_t))
|
||||
? sizeof(vp10_stream_info_t)
|
||||
: sizeof(vpx_codec_stream_info_t);
|
||||
? sizeof(vp10_stream_info_t)
|
||||
: sizeof(vpx_codec_stream_info_t);
|
||||
memcpy(si, &ctx->si, sz);
|
||||
si->sz = (unsigned int)sz;
|
||||
|
||||
|
@ -270,8 +260,8 @@ static void set_error_detail(vpx_codec_alg_priv_t *ctx,
|
|||
ctx->base.err_detail = error;
|
||||
}
|
||||
|
||||
static vpx_codec_err_t update_error_state(vpx_codec_alg_priv_t *ctx,
|
||||
const struct vpx_internal_error_info *error) {
|
||||
static vpx_codec_err_t update_error_state(
|
||||
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
|
||||
if (error->error_code)
|
||||
set_error_detail(ctx, error->has_detail ? error->detail : NULL);
|
||||
|
||||
|
@ -319,10 +309,8 @@ static int frame_worker_hook(void *arg1, void *arg2) {
|
|||
const uint8_t *data = frame_worker_data->data;
|
||||
(void)arg2;
|
||||
|
||||
frame_worker_data->result =
|
||||
vp10_receive_compressed_data(frame_worker_data->pbi,
|
||||
frame_worker_data->data_size,
|
||||
&data);
|
||||
frame_worker_data->result = vp10_receive_compressed_data(
|
||||
frame_worker_data->pbi, frame_worker_data->data_size, &data);
|
||||
frame_worker_data->data_end = data;
|
||||
|
||||
if (frame_worker_data->pbi->common.frame_parallel_decode) {
|
||||
|
@ -364,25 +352,24 @@ static vpx_codec_err_t init_decoder(vpx_codec_alg_priv_t *ctx) {
|
|||
ctx->num_cache_frames = 0;
|
||||
ctx->need_resync = 1;
|
||||
ctx->num_frame_workers =
|
||||
(ctx->frame_parallel_decode == 1) ? ctx->cfg.threads: 1;
|
||||
(ctx->frame_parallel_decode == 1) ? ctx->cfg.threads : 1;
|
||||
if (ctx->num_frame_workers > MAX_DECODE_THREADS)
|
||||
ctx->num_frame_workers = MAX_DECODE_THREADS;
|
||||
ctx->available_threads = ctx->num_frame_workers;
|
||||
ctx->flushed = 0;
|
||||
|
||||
ctx->buffer_pool = (BufferPool *)vpx_calloc(1, sizeof(BufferPool));
|
||||
if (ctx->buffer_pool == NULL)
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
if (ctx->buffer_pool == NULL) return VPX_CODEC_MEM_ERROR;
|
||||
|
||||
#if CONFIG_MULTITHREAD
|
||||
if (pthread_mutex_init(&ctx->buffer_pool->pool_mutex, NULL)) {
|
||||
set_error_detail(ctx, "Failed to allocate buffer pool mutex");
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
}
|
||||
if (pthread_mutex_init(&ctx->buffer_pool->pool_mutex, NULL)) {
|
||||
set_error_detail(ctx, "Failed to allocate buffer pool mutex");
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
ctx->frame_workers = (VPxWorker *)
|
||||
vpx_malloc(ctx->num_frame_workers * sizeof(*ctx->frame_workers));
|
||||
ctx->frame_workers = (VPxWorker *)vpx_malloc(ctx->num_frame_workers *
|
||||
sizeof(*ctx->frame_workers));
|
||||
if (ctx->frame_workers == NULL) {
|
||||
set_error_detail(ctx, "Failed to allocate frame_workers");
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
|
@ -437,8 +424,7 @@ static vpx_codec_err_t init_decoder(vpx_codec_alg_priv_t *ctx) {
|
|||
|
||||
// If postprocessing was enabled by the application and a
|
||||
// configuration has not been provided, default it.
|
||||
if (!ctx->postproc_cfg_set &&
|
||||
(ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
|
||||
if (!ctx->postproc_cfg_set && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
|
||||
set_default_ppflags(&ctx->postproc_cfg);
|
||||
|
||||
init_buffer_callbacks(ctx);
|
||||
|
@ -468,11 +454,9 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
|
|||
const vpx_codec_err_t res =
|
||||
decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only,
|
||||
ctx->decrypt_cb, ctx->decrypt_state);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
|
||||
if (!ctx->si.is_kf && !is_intra_only)
|
||||
return VPX_CODEC_ERROR;
|
||||
if (!ctx->si.is_kf && !is_intra_only) return VPX_CODEC_ERROR;
|
||||
}
|
||||
|
||||
if (!ctx->frame_parallel_decode) {
|
||||
|
@ -571,8 +555,7 @@ static void wait_worker_and_cache_frame(vpx_codec_alg_priv_t *ctx) {
|
|||
frame_worker_data->user_priv);
|
||||
ctx->frame_cache[ctx->frame_cache_write].img.fb_priv =
|
||||
frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
|
||||
ctx->frame_cache_write =
|
||||
(ctx->frame_cache_write + 1) % FRAME_CACHE_SIZE;
|
||||
ctx->frame_cache_write = (ctx->frame_cache_write + 1) % FRAME_CACHE_SIZE;
|
||||
++ctx->num_cache_frames;
|
||||
}
|
||||
}
|
||||
|
@ -581,7 +564,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
const uint8_t *data, unsigned int data_sz,
|
||||
void *user_priv, long deadline) {
|
||||
const uint8_t *data_start = data;
|
||||
const uint8_t * const data_end = data + data_sz;
|
||||
const uint8_t *const data_end = data + data_sz;
|
||||
vpx_codec_err_t res;
|
||||
uint32_t frame_sizes[8];
|
||||
int frame_count;
|
||||
|
@ -597,14 +580,12 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
// Initialize the decoder workers on the first frame.
|
||||
if (ctx->frame_workers == NULL) {
|
||||
const vpx_codec_err_t res = init_decoder(ctx);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
}
|
||||
|
||||
res = vp10_parse_superframe_index(data, data_sz, frame_sizes, &frame_count,
|
||||
ctx->decrypt_cb, ctx->decrypt_state);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
ctx->decrypt_cb, ctx->decrypt_state);
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
|
||||
if (ctx->frame_parallel_decode) {
|
||||
// Decode in frame parallel mode. When decoding in this mode, the frame
|
||||
|
@ -617,8 +598,8 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
for (i = 0; i < frame_count; ++i) {
|
||||
const uint8_t *data_start_copy = data_start;
|
||||
const uint32_t frame_size = frame_sizes[i];
|
||||
if (data_start < data
|
||||
|| frame_size > (uint32_t) (data_end - data_start)) {
|
||||
if (data_start < data ||
|
||||
frame_size > (uint32_t)(data_end - data_start)) {
|
||||
set_error_detail(ctx, "Invalid frame size in index");
|
||||
return VPX_CODEC_CORRUPT_FRAME;
|
||||
}
|
||||
|
@ -635,10 +616,9 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
res = decode_one(ctx, &data_start_copy, frame_size, user_priv,
|
||||
deadline);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
res =
|
||||
decode_one(ctx, &data_start_copy, frame_size, user_priv, deadline);
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
data_start += frame_size;
|
||||
}
|
||||
} else {
|
||||
|
@ -655,8 +635,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
|
||||
res = decode_one(ctx, &data, data_sz, user_priv, deadline);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
}
|
||||
} else {
|
||||
// Decode in serial mode.
|
||||
|
@ -667,33 +646,30 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
|
|||
const uint8_t *data_start_copy = data_start;
|
||||
const uint32_t frame_size = frame_sizes[i];
|
||||
vpx_codec_err_t res;
|
||||
if (data_start < data
|
||||
|| frame_size > (uint32_t) (data_end - data_start)) {
|
||||
if (data_start < data ||
|
||||
frame_size > (uint32_t)(data_end - data_start)) {
|
||||
set_error_detail(ctx, "Invalid frame size in index");
|
||||
return VPX_CODEC_CORRUPT_FRAME;
|
||||
}
|
||||
|
||||
res = decode_one(ctx, &data_start_copy, frame_size, user_priv,
|
||||
deadline);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
res =
|
||||
decode_one(ctx, &data_start_copy, frame_size, user_priv, deadline);
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
|
||||
data_start += frame_size;
|
||||
}
|
||||
} else {
|
||||
while (data_start < data_end) {
|
||||
const uint32_t frame_size = (uint32_t) (data_end - data_start);
|
||||
const vpx_codec_err_t res = decode_one(ctx, &data_start, frame_size,
|
||||
user_priv, deadline);
|
||||
if (res != VPX_CODEC_OK)
|
||||
return res;
|
||||
const uint32_t frame_size = (uint32_t)(data_end - data_start);
|
||||
const vpx_codec_err_t res =
|
||||
decode_one(ctx, &data_start, frame_size, user_priv, deadline);
|
||||
if (res != VPX_CODEC_OK) return res;
|
||||
|
||||
// Account for suboptimal termination by the encoder.
|
||||
while (data_start < data_end) {
|
||||
const uint8_t marker = read_marker(ctx->decrypt_cb,
|
||||
ctx->decrypt_state, data_start);
|
||||
if (marker)
|
||||
break;
|
||||
const uint8_t marker =
|
||||
read_marker(ctx->decrypt_cb, ctx->decrypt_state, data_start);
|
||||
if (marker) break;
|
||||
++data_start;
|
||||
}
|
||||
}
|
||||
|
@ -728,9 +704,8 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
// Output the frames in the cache first.
|
||||
if (ctx->num_cache_frames > 0) {
|
||||
release_last_output_frame(ctx);
|
||||
ctx->last_show_frame = ctx->frame_cache[ctx->frame_cache_read].fb_idx;
|
||||
if (ctx->need_resync)
|
||||
return NULL;
|
||||
ctx->last_show_frame = ctx->frame_cache[ctx->frame_cache_read].fb_idx;
|
||||
if (ctx->need_resync) return NULL;
|
||||
img = &ctx->frame_cache[ctx->frame_cache_read].img;
|
||||
ctx->frame_cache_read = (ctx->frame_cache_read + 1) % FRAME_CACHE_SIZE;
|
||||
--ctx->num_cache_frames;
|
||||
|
@ -743,8 +718,7 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
do {
|
||||
YV12_BUFFER_CONFIG sd;
|
||||
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
|
||||
VPxWorker *const worker =
|
||||
&ctx->frame_workers[ctx->next_output_worker_id];
|
||||
VPxWorker *const worker = &ctx->frame_workers[ctx->next_output_worker_id];
|
||||
FrameWorkerData *const frame_worker_data =
|
||||
(FrameWorkerData *)worker->data1;
|
||||
ctx->next_output_worker_id =
|
||||
|
@ -762,30 +736,28 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
|
||||
release_last_output_frame(ctx);
|
||||
ctx->last_show_frame = frame_worker_data->pbi->common.new_fb_idx;
|
||||
if (ctx->need_resync)
|
||||
return NULL;
|
||||
if (ctx->need_resync) return NULL;
|
||||
yuvconfig2image(&ctx->img, &sd, frame_worker_data->user_priv);
|
||||
|
||||
|
||||
#if CONFIG_EXT_TILE
|
||||
if (frame_worker_data->pbi->dec_tile_row >= 0) {
|
||||
const int tile_row = VPXMIN(frame_worker_data->pbi->dec_tile_row,
|
||||
cm->tile_rows - 1);
|
||||
const int tile_row =
|
||||
VPXMIN(frame_worker_data->pbi->dec_tile_row, cm->tile_rows - 1);
|
||||
const int mi_row = tile_row * cm->tile_height;
|
||||
const int ssy = ctx->img.y_chroma_shift;
|
||||
int plane;
|
||||
ctx->img.planes[0] += mi_row * MI_SIZE * ctx->img.stride[0];
|
||||
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
||||
ctx->img.planes[plane] += mi_row * (MI_SIZE >> ssy) *
|
||||
ctx->img.stride[plane];
|
||||
ctx->img.planes[plane] +=
|
||||
mi_row * (MI_SIZE >> ssy) * ctx->img.stride[plane];
|
||||
}
|
||||
ctx->img.d_h = VPXMIN(cm->tile_height, cm->mi_rows - mi_row) *
|
||||
MI_SIZE;
|
||||
ctx->img.d_h =
|
||||
VPXMIN(cm->tile_height, cm->mi_rows - mi_row) * MI_SIZE;
|
||||
}
|
||||
|
||||
if (frame_worker_data->pbi->dec_tile_col >= 0) {
|
||||
const int tile_col = VPXMIN(frame_worker_data->pbi->dec_tile_col,
|
||||
cm->tile_cols - 1);
|
||||
const int tile_col =
|
||||
VPXMIN(frame_worker_data->pbi->dec_tile_col, cm->tile_cols - 1);
|
||||
const int mi_col = tile_col * cm->tile_width;
|
||||
const int ssx = ctx->img.x_chroma_shift;
|
||||
int plane;
|
||||
|
@ -793,8 +765,8 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
||||
ctx->img.planes[plane] += mi_col * (MI_SIZE >> ssx);
|
||||
}
|
||||
ctx->img.d_w = VPXMIN(cm->tile_width, cm->mi_cols - mi_col) *
|
||||
MI_SIZE;
|
||||
ctx->img.d_w =
|
||||
VPXMIN(cm->tile_width, cm->mi_cols - mi_col) * MI_SIZE;
|
||||
}
|
||||
#endif // CONFIG_EXT_TILE
|
||||
|
||||
|
@ -807,8 +779,7 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
frame_worker_data->received_frame = 0;
|
||||
++ctx->available_threads;
|
||||
ctx->need_resync = 1;
|
||||
if (ctx->flushed != 1)
|
||||
return NULL;
|
||||
if (ctx->flushed != 1) return NULL;
|
||||
}
|
||||
} while (ctx->next_output_worker_id != ctx->next_submit_worker_id);
|
||||
}
|
||||
|
@ -816,8 +787,7 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
|
||||
static vpx_codec_err_t decoder_set_fb_fn(
|
||||
vpx_codec_alg_priv_t *ctx,
|
||||
vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_codec_alg_priv_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) {
|
||||
if (cb_get == NULL || cb_release == NULL) {
|
||||
return VPX_CODEC_INVALID_PARAM;
|
||||
|
@ -868,13 +838,13 @@ static vpx_codec_err_t ctrl_copy_reference(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
|
||||
if (data) {
|
||||
vpx_ref_frame_t *frame = (vpx_ref_frame_t *) data;
|
||||
vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
|
||||
YV12_BUFFER_CONFIG sd;
|
||||
VPxWorker *const worker = ctx->frame_workers;
|
||||
FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
|
||||
image2yuvconfig(&frame->img, &sd);
|
||||
return vp10_copy_reference_dec(frame_worker_data->pbi,
|
||||
(VPX_REFFRAME)frame->frame_type, &sd);
|
||||
(VPX_REFFRAME)frame->frame_type, &sd);
|
||||
} else {
|
||||
return VPX_CODEC_INVALID_PARAM;
|
||||
}
|
||||
|
@ -891,7 +861,7 @@ static vpx_codec_err_t ctrl_get_reference(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
|
||||
if (data) {
|
||||
YV12_BUFFER_CONFIG* fb;
|
||||
YV12_BUFFER_CONFIG *fb;
|
||||
VPxWorker *const worker = ctx->frame_workers;
|
||||
FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
|
||||
fb = get_ref_frame(&frame_worker_data->pbi->common, data->idx);
|
||||
|
@ -1096,8 +1066,7 @@ static vpx_codec_err_t ctrl_set_byte_alignment(vpx_codec_alg_priv_t *ctx,
|
|||
ctx->byte_alignment = byte_alignment;
|
||||
if (ctx->frame_workers) {
|
||||
VPxWorker *const worker = ctx->frame_workers;
|
||||
FrameWorkerData *const frame_worker_data =
|
||||
(FrameWorkerData *)worker->data1;
|
||||
FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
|
||||
frame_worker_data->pbi->common.byte_alignment = byte_alignment;
|
||||
}
|
||||
return VPX_CODEC_OK;
|
||||
|
@ -1129,32 +1098,32 @@ static vpx_codec_err_t ctrl_set_decode_tile_col(vpx_codec_alg_priv_t *ctx,
|
|||
}
|
||||
|
||||
static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
|
||||
{VP8_COPY_REFERENCE, ctrl_copy_reference},
|
||||
{ VP8_COPY_REFERENCE, ctrl_copy_reference },
|
||||
|
||||
// Setters
|
||||
{VP8_SET_REFERENCE, ctrl_set_reference},
|
||||
{VP8_SET_POSTPROC, ctrl_set_postproc},
|
||||
{VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options},
|
||||
{VP8_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options},
|
||||
{VP8_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options},
|
||||
{VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options},
|
||||
{VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order},
|
||||
{VPXD_SET_DECRYPTOR, ctrl_set_decryptor},
|
||||
{VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment},
|
||||
{VP9_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter},
|
||||
{VP10_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row},
|
||||
{VP10_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col},
|
||||
{ VP8_SET_REFERENCE, ctrl_set_reference },
|
||||
{ VP8_SET_POSTPROC, ctrl_set_postproc },
|
||||
{ VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options },
|
||||
{ VP8_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options },
|
||||
{ VP8_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options },
|
||||
{ VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options },
|
||||
{ VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order },
|
||||
{ VPXD_SET_DECRYPTOR, ctrl_set_decryptor },
|
||||
{ VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment },
|
||||
{ VP9_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
|
||||
{ VP10_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row },
|
||||
{ VP10_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col },
|
||||
|
||||
// Getters
|
||||
{VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates},
|
||||
{VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted},
|
||||
{VP9_GET_REFERENCE, ctrl_get_reference},
|
||||
{VP9D_GET_DISPLAY_SIZE, ctrl_get_render_size},
|
||||
{VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth},
|
||||
{VP9D_GET_FRAME_SIZE, ctrl_get_frame_size},
|
||||
{VP10_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image},
|
||||
{ VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates },
|
||||
{ VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted },
|
||||
{ VP9_GET_REFERENCE, ctrl_get_reference },
|
||||
{ VP9D_GET_DISPLAY_SIZE, ctrl_get_render_size },
|
||||
{ VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth },
|
||||
{ VP9D_GET_FRAME_SIZE, ctrl_get_frame_size },
|
||||
{ VP10_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image },
|
||||
|
||||
{ -1, NULL},
|
||||
{ -1, NULL },
|
||||
};
|
||||
|
||||
#ifndef VERSION_STRING
|
||||
|
@ -1165,24 +1134,26 @@ CODEC_INTERFACE(vpx_codec_vp10_dx) = {
|
|||
VPX_CODEC_INTERNAL_ABI_VERSION,
|
||||
VPX_CODEC_CAP_DECODER |
|
||||
VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER, // vpx_codec_caps_t
|
||||
decoder_init, // vpx_codec_init_fn_t
|
||||
decoder_destroy, // vpx_codec_destroy_fn_t
|
||||
decoder_ctrl_maps, // vpx_codec_ctrl_fn_map_t
|
||||
{ // NOLINT
|
||||
decoder_peek_si, // vpx_codec_peek_si_fn_t
|
||||
decoder_get_si, // vpx_codec_get_si_fn_t
|
||||
decoder_decode, // vpx_codec_decode_fn_t
|
||||
decoder_get_frame, // vpx_codec_frame_get_fn_t
|
||||
decoder_set_fb_fn, // vpx_codec_set_fb_fn_t
|
||||
decoder_init, // vpx_codec_init_fn_t
|
||||
decoder_destroy, // vpx_codec_destroy_fn_t
|
||||
decoder_ctrl_maps, // vpx_codec_ctrl_fn_map_t
|
||||
{
|
||||
// NOLINT
|
||||
decoder_peek_si, // vpx_codec_peek_si_fn_t
|
||||
decoder_get_si, // vpx_codec_get_si_fn_t
|
||||
decoder_decode, // vpx_codec_decode_fn_t
|
||||
decoder_get_frame, // vpx_codec_frame_get_fn_t
|
||||
decoder_set_fb_fn, // vpx_codec_set_fb_fn_t
|
||||
},
|
||||
{ // NOLINT
|
||||
0,
|
||||
NULL, // vpx_codec_enc_cfg_map_t
|
||||
NULL, // vpx_codec_encode_fn_t
|
||||
NULL, // vpx_codec_get_cx_data_fn_t
|
||||
NULL, // vpx_codec_enc_config_set_fn_t
|
||||
NULL, // vpx_codec_get_global_headers_fn_t
|
||||
NULL, // vpx_codec_get_preview_frame_fn_t
|
||||
NULL // vpx_codec_enc_mr_get_mem_loc_fn_t
|
||||
{
|
||||
// NOLINT
|
||||
0,
|
||||
NULL, // vpx_codec_enc_cfg_map_t
|
||||
NULL, // vpx_codec_encode_fn_t
|
||||
NULL, // vpx_codec_get_cx_data_fn_t
|
||||
NULL, // vpx_codec_enc_config_set_fn_t
|
||||
NULL, // vpx_codec_get_global_headers_fn_t
|
||||
NULL, // vpx_codec_get_preview_frame_fn_t
|
||||
NULL // vpx_codec_enc_mr_get_mem_loc_fn_t
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "vpx_ports/mem.h"
|
||||
|
||||
static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
|
||||
static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
|
||||
void *user_priv) {
|
||||
/** vpx_img_wrap() doesn't allow specifying independent strides for
|
||||
* the Y, U, and V planes, nor other alignment adjustments that
|
||||
|
@ -61,9 +61,9 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
|
|||
// of the image.
|
||||
img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
|
||||
img->bit_depth = yv12->bit_depth;
|
||||
img->planes[VPX_PLANE_Y] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->y_buffer);
|
||||
img->planes[VPX_PLANE_U] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->u_buffer);
|
||||
img->planes[VPX_PLANE_V] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->v_buffer);
|
||||
img->planes[VPX_PLANE_Y] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->y_buffer);
|
||||
img->planes[VPX_PLANE_U] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->u_buffer);
|
||||
img->planes[VPX_PLANE_V] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->v_buffer);
|
||||
img->planes[VPX_PLANE_ALPHA] = NULL;
|
||||
img->stride[VPX_PLANE_Y] = 2 * yv12->y_stride;
|
||||
img->stride[VPX_PLANE_U] = 2 * yv12->uv_stride;
|
||||
|
@ -84,17 +84,17 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
|
|||
yv12->u_buffer = img->planes[VPX_PLANE_U];
|
||||
yv12->v_buffer = img->planes[VPX_PLANE_V];
|
||||
|
||||
yv12->y_crop_width = img->d_w;
|
||||
yv12->y_crop_width = img->d_w;
|
||||
yv12->y_crop_height = img->d_h;
|
||||
yv12->render_width = img->r_w;
|
||||
yv12->render_width = img->r_w;
|
||||
yv12->render_height = img->r_h;
|
||||
yv12->y_width = img->d_w;
|
||||
yv12->y_width = img->d_w;
|
||||
yv12->y_height = img->d_h;
|
||||
|
||||
yv12->uv_width = img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2
|
||||
: yv12->y_width;
|
||||
yv12->uv_height = img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2
|
||||
: yv12->y_height;
|
||||
yv12->uv_width =
|
||||
img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2 : yv12->y_width;
|
||||
yv12->uv_height =
|
||||
img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height;
|
||||
yv12->uv_crop_width = yv12->uv_width;
|
||||
yv12->uv_crop_height = yv12->uv_height;
|
||||
|
||||
|
@ -124,9 +124,9 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
|
|||
} else {
|
||||
yv12->flags = 0;
|
||||
}
|
||||
yv12->border = (yv12->y_stride - img->w) / 2;
|
||||
yv12->border = (yv12->y_stride - img->w) / 2;
|
||||
#else
|
||||
yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
|
||||
yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
|
||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||
yv12->subsampling_x = img->x_chroma_shift;
|
||||
yv12->subsampling_y = img->y_chroma_shift;
|
||||
|
@ -135,12 +135,9 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
|
|||
|
||||
static VPX_REFFRAME ref_frame_to_vp10_reframe(vpx_ref_frame_type_t frame) {
|
||||
switch (frame) {
|
||||
case VP8_LAST_FRAME:
|
||||
return VPX_LAST_FLAG;
|
||||
case VP8_GOLD_FRAME:
|
||||
return VPX_GOLD_FLAG;
|
||||
case VP8_ALTR_FRAME:
|
||||
return VPX_ALT_FLAG;
|
||||
case VP8_LAST_FRAME: return VPX_LAST_FLAG;
|
||||
case VP8_GOLD_FRAME: return VPX_GOLD_FLAG;
|
||||
case VP8_ALTR_FRAME: return VPX_ALT_FLAG;
|
||||
}
|
||||
assert(0 && "Invalid Reference Frame");
|
||||
return VPX_LAST_FLAG;
|
||||
|
|
Загрузка…
Ссылка в новой задаче