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.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef VP10_DECODER_DECODEFRAME_H_
|
#ifndef VP10_DECODER_DECODEFRAME_H_
|
||||||
#define VP10_DECODER_DECODEFRAME_H_
|
#define VP10_DECODER_DECODEFRAME_H_
|
||||||
|
|
||||||
|
@ -20,13 +19,12 @@ struct VP10Decoder;
|
||||||
struct vpx_read_bit_buffer;
|
struct vpx_read_bit_buffer;
|
||||||
|
|
||||||
int vp10_read_sync_code(struct vpx_read_bit_buffer *const rb);
|
int vp10_read_sync_code(struct vpx_read_bit_buffer *const rb);
|
||||||
void vp10_read_frame_size(struct vpx_read_bit_buffer *rb,
|
void vp10_read_frame_size(struct vpx_read_bit_buffer *rb, int *width,
|
||||||
int *width, int *height);
|
int *height);
|
||||||
BITSTREAM_PROFILE vp10_read_profile(struct vpx_read_bit_buffer *rb);
|
BITSTREAM_PROFILE vp10_read_profile(struct vpx_read_bit_buffer *rb);
|
||||||
|
|
||||||
void vp10_decode_frame(struct VP10Decoder *pbi,
|
void vp10_decode_frame(struct VP10Decoder *pbi, const uint8_t *data,
|
||||||
const uint8_t *data, const uint8_t *data_end,
|
const uint8_t *data_end, const uint8_t **p_data_end);
|
||||||
const uint8_t **p_data_end);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,8 +24,8 @@ void vp10_read_mode_info(VP10Decoder *const pbi, MACROBLOCKD *xd,
|
||||||
int supertx_enabled,
|
int supertx_enabled,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mi_row, int mi_col, vp10_reader *r,
|
int mi_row, int mi_col, vp10_reader *r, int x_mis,
|
||||||
int x_mis, int y_mis);
|
int y_mis);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // 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) {
|
static int vp10_dec_alloc_mi(VP10_COMMON *cm, int mi_size) {
|
||||||
cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
|
cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip));
|
||||||
if (!cm->mip)
|
if (!cm->mip) return 1;
|
||||||
return 1;
|
|
||||||
cm->mi_alloc_size = mi_size;
|
cm->mi_alloc_size = mi_size;
|
||||||
cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*));
|
cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *));
|
||||||
if (!cm->mi_grid_base)
|
if (!cm->mi_grid_base) return 1;
|
||||||
return 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +76,7 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
||||||
VP10Decoder *volatile const pbi = vpx_memalign(32, sizeof(*pbi));
|
VP10Decoder *volatile const pbi = vpx_memalign(32, sizeof(*pbi));
|
||||||
VP10_COMMON *volatile const cm = pbi ? &pbi->common : NULL;
|
VP10_COMMON *volatile const cm = pbi ? &pbi->common : NULL;
|
||||||
|
|
||||||
if (!cm)
|
if (!cm) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
vp10_zero(*pbi);
|
vp10_zero(*pbi);
|
||||||
|
|
||||||
|
@ -91,11 +88,10 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
||||||
|
|
||||||
cm->error.setjmp = 1;
|
cm->error.setjmp = 1;
|
||||||
|
|
||||||
CHECK_MEM_ERROR(cm, cm->fc,
|
CHECK_MEM_ERROR(cm, cm->fc, (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
|
||||||
(FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc)));
|
CHECK_MEM_ERROR(
|
||||||
CHECK_MEM_ERROR(cm, cm->frame_contexts,
|
cm, cm->frame_contexts,
|
||||||
(FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS,
|
(FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, sizeof(*cm->frame_contexts)));
|
||||||
sizeof(*cm->frame_contexts)));
|
|
||||||
|
|
||||||
pbi->need_resync = 1;
|
pbi->need_resync = 1;
|
||||||
once(initialize_dec);
|
once(initialize_dec);
|
||||||
|
@ -130,8 +126,7 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
|
||||||
void vp10_decoder_remove(VP10Decoder *pbi) {
|
void vp10_decoder_remove(VP10Decoder *pbi) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!pbi)
|
if (!pbi) return;
|
||||||
return;
|
|
||||||
|
|
||||||
vpx_get_worker_interface()->end(&pbi->lf_worker);
|
vpx_get_worker_interface()->end(&pbi->lf_worker);
|
||||||
vpx_free(pbi->lf_worker.data1);
|
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,
|
static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
|
||||||
const YV12_BUFFER_CONFIG *b) {
|
const YV12_BUFFER_CONFIG *b) {
|
||||||
return a->y_height == b->y_height && a->y_width == b->y_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;
|
a->uv_height == b->uv_height && a->uv_width == b->uv_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
vpx_codec_err_t vp10_copy_reference_dec(VP10Decoder *pbi,
|
vpx_codec_err_t vp10_copy_reference_dec(VP10Decoder *pbi,
|
||||||
VPX_REFFRAME ref_frame_flag,
|
VPX_REFFRAME ref_frame_flag,
|
||||||
YV12_BUFFER_CONFIG *sd) {
|
YV12_BUFFER_CONFIG *sd) {
|
||||||
VP10_COMMON *cm = &pbi->common;
|
VP10_COMMON *cm = &pbi->common;
|
||||||
|
|
||||||
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
|
/* 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
|
else
|
||||||
vpx_yv12_copy_frame(cfg, sd);
|
vpx_yv12_copy_frame(cfg, sd);
|
||||||
} else {
|
} else {
|
||||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
|
||||||
"Invalid reference frame");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cm->error.error_code;
|
return cm->error.error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
vpx_codec_err_t vp10_set_reference_dec(VP10_COMMON *cm,
|
||||||
VPX_REFFRAME ref_frame_flag,
|
VPX_REFFRAME ref_frame_flag,
|
||||||
YV12_BUFFER_CONFIG *sd) {
|
YV12_BUFFER_CONFIG *sd) {
|
||||||
int idx;
|
int idx;
|
||||||
YV12_BUFFER_CONFIG *ref_buf = NULL;
|
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];
|
idx = cm->ref_frame_map[2];
|
||||||
#endif // CONFIG_EXT_REFS
|
#endif // CONFIG_EXT_REFS
|
||||||
} else {
|
} else {
|
||||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
vpx_internal_error(&cm->error, VPX_CODEC_ERROR, "Invalid reference frame");
|
||||||
"Invalid reference frame");
|
|
||||||
return cm->error.error_code;
|
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
|
// Release the reference frame holding in the reference map for the decoding
|
||||||
// of the next frame.
|
// of the next frame.
|
||||||
if (mask & 1)
|
if (mask & 1) decrease_ref_count(old_idx, frame_bufs, pool);
|
||||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
|
||||||
cm->ref_frame_map[ref_index] = cm->next_ref_frame_map[ref_index];
|
cm->ref_frame_map[ref_index] = cm->next_ref_frame_map[ref_index];
|
||||||
++ref_index;
|
++ref_index;
|
||||||
}
|
}
|
||||||
|
@ -307,8 +298,8 @@ static void swap_frame_buffers(VP10Decoder *pbi) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp10_receive_compressed_data(VP10Decoder *pbi,
|
int vp10_receive_compressed_data(VP10Decoder *pbi, size_t size,
|
||||||
size_t size, const uint8_t **psource) {
|
const uint8_t **psource) {
|
||||||
VP10_COMMON *volatile const cm = &pbi->common;
|
VP10_COMMON *volatile const cm = &pbi->common;
|
||||||
BufferPool *volatile const pool = cm->buffer_pool;
|
BufferPool *volatile const pool = cm->buffer_pool;
|
||||||
RefCntBuffer *volatile const frame_bufs = cm->buffer_pool->frame_bufs;
|
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.
|
// Check if the previous frame was a frame without any references to it.
|
||||||
// Release frame buffer if not decoding in frame parallel mode.
|
// Release frame buffer if not decoding in frame parallel mode.
|
||||||
if (!cm->frame_parallel_decode && cm->new_fb_idx >= 0
|
if (!cm->frame_parallel_decode && cm->new_fb_idx >= 0 &&
|
||||||
&& frame_bufs[cm->new_fb_idx].ref_count == 0)
|
frame_bufs[cm->new_fb_idx].ref_count == 0)
|
||||||
pool->release_fb_cb(pool->cb_priv,
|
pool->release_fb_cb(pool->cb_priv,
|
||||||
&frame_bufs[cm->new_fb_idx].raw_frame_buffer);
|
&frame_bufs[cm->new_fb_idx].raw_frame_buffer);
|
||||||
|
|
||||||
// Find a free frame buffer. Return error if can not find any.
|
// Find a free frame buffer. Return error if can not find any.
|
||||||
cm->new_fb_idx = get_free_fb(cm);
|
cm->new_fb_idx = get_free_fb(cm);
|
||||||
if (cm->new_fb_idx == INVALID_IDX)
|
if (cm->new_fb_idx == INVALID_IDX) return VPX_CODEC_MEM_ERROR;
|
||||||
return VPX_CODEC_MEM_ERROR;
|
|
||||||
|
|
||||||
// Assign a MV array to the frame buffer.
|
// Assign a MV array to the frame buffer.
|
||||||
cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx];
|
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.
|
// Current thread releases the holding of reference frame.
|
||||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
decrease_ref_count(old_idx, frame_bufs, pool);
|
||||||
|
|
||||||
// Release the reference frame holding in the reference map for the
|
// Release the reference frame holding in the reference map for the
|
||||||
// decoding of the next frame.
|
// decoding of the next frame.
|
||||||
if (mask & 1)
|
if (mask & 1) decrease_ref_count(old_idx, frame_bufs, pool);
|
||||||
decrease_ref_count(old_idx, frame_bufs, pool);
|
|
||||||
++ref_index;
|
++ref_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,14 +457,12 @@ int vp10_receive_compressed_data(VP10Decoder *pbi,
|
||||||
int vp10_get_raw_frame(VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd) {
|
int vp10_get_raw_frame(VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd) {
|
||||||
VP10_COMMON *const cm = &pbi->common;
|
VP10_COMMON *const cm = &pbi->common;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (pbi->ready_for_new_data == 1)
|
if (pbi->ready_for_new_data == 1) return ret;
|
||||||
return ret;
|
|
||||||
|
|
||||||
pbi->ready_for_new_data = 1;
|
pbi->ready_for_new_data = 1;
|
||||||
|
|
||||||
/* no raw frame to show!!! */
|
/* no raw frame to show!!! */
|
||||||
if (!cm->show_frame)
|
if (!cm->show_frame) return ret;
|
||||||
return ret;
|
|
||||||
|
|
||||||
pbi->ready_for_new_data = 1;
|
pbi->ready_for_new_data = 1;
|
||||||
*sd = *cm->frame_to_show;
|
*sd = *cm->frame_to_show;
|
||||||
|
@ -484,22 +471,19 @@ int vp10_get_raw_frame(VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp10_get_frame_to_show(VP10Decoder *pbi,
|
int vp10_get_frame_to_show(VP10Decoder *pbi, YV12_BUFFER_CONFIG *frame) {
|
||||||
YV12_BUFFER_CONFIG *frame) {
|
|
||||||
VP10_COMMON *const cm = &pbi->common;
|
VP10_COMMON *const cm = &pbi->common;
|
||||||
|
|
||||||
if (!cm->show_frame || !cm->frame_to_show)
|
if (!cm->show_frame || !cm->frame_to_show) return -1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
*frame = *cm->frame_to_show;
|
*frame = *cm->frame_to_show;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data, size_t data_sz,
|
||||||
size_t data_sz,
|
uint32_t sizes[8], int *count,
|
||||||
uint32_t sizes[8], int *count,
|
vpx_decrypt_cb decrypt_cb,
|
||||||
vpx_decrypt_cb decrypt_cb,
|
void *decrypt_state) {
|
||||||
void *decrypt_state) {
|
|
||||||
// A chunk ending with a byte matching 0xc0 is an invalid chunk unless
|
// 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
|
// 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
|
// 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
|
// This chunk is marked as having a superframe index but doesn't have
|
||||||
// enough data for it, thus it's an invalid superframe index.
|
// enough data for it, thus it's an invalid superframe index.
|
||||||
if (data_sz < index_sz)
|
if (data_sz < index_sz) return VPX_CODEC_CORRUPT_FRAME;
|
||||||
return VPX_CODEC_CORRUPT_FRAME;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const uint8_t marker2 = read_marker(decrypt_cb, decrypt_state,
|
const uint8_t marker2 =
|
||||||
data + data_sz - index_sz);
|
read_marker(decrypt_cb, decrypt_state, data + data_sz - index_sz);
|
||||||
|
|
||||||
// This chunk is marked as having a superframe index but doesn't have
|
// 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
|
// the matching marker byte at the front of the index therefore it's an
|
||||||
// invalid chunk.
|
// invalid chunk.
|
||||||
if (marker != marker2)
|
if (marker != marker2) return VPX_CODEC_CORRUPT_FRAME;
|
||||||
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) {
|
for (i = 0; i < frames - 1; ++i) {
|
||||||
uint32_t this_sz = 0;
|
uint32_t this_sz = 0;
|
||||||
|
|
||||||
for (j = 0; j < mag; ++j)
|
for (j = 0; j < mag; ++j) this_sz |= (*x++) << (j * 8);
|
||||||
this_sz |= (*x++) << (j * 8);
|
|
||||||
this_sz += 1;
|
this_sz += 1;
|
||||||
sizes[i] = this_sz;
|
sizes[i] = this_sz;
|
||||||
frame_sz_sum += this_sz;
|
frame_sz_sum += this_sz;
|
||||||
|
|
|
@ -52,7 +52,7 @@ typedef struct TileBufferDec {
|
||||||
size_t size;
|
size_t size;
|
||||||
const uint8_t *raw_data_end; // The end of the raw tile buffer in the
|
const uint8_t *raw_data_end; // The end of the raw tile buffer in the
|
||||||
// bit stream.
|
// bit stream.
|
||||||
int col; // only used with multi-threaded decoding
|
int col; // only used with multi-threaded decoding
|
||||||
} TileBufferDec;
|
} TileBufferDec;
|
||||||
|
|
||||||
typedef struct VP10Decoder {
|
typedef struct VP10Decoder {
|
||||||
|
@ -66,9 +66,9 @@ typedef struct VP10Decoder {
|
||||||
|
|
||||||
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
|
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
|
||||||
// the same.
|
// 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 lf_worker;
|
||||||
VPxWorker *tile_workers;
|
VPxWorker *tile_workers;
|
||||||
TileWorkerData *tile_worker_data;
|
TileWorkerData *tile_worker_data;
|
||||||
|
@ -87,7 +87,7 @@ typedef struct VP10Decoder {
|
||||||
|
|
||||||
int max_threads;
|
int max_threads;
|
||||||
int inv_tile_order;
|
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 hold_ref_buf; // hold the reference buffer.
|
||||||
|
|
||||||
int tile_size_bytes;
|
int tile_size_bytes;
|
||||||
|
@ -97,24 +97,23 @@ typedef struct VP10Decoder {
|
||||||
#endif // CONFIG_EXT_TILE
|
#endif // CONFIG_EXT_TILE
|
||||||
} VP10Decoder;
|
} VP10Decoder;
|
||||||
|
|
||||||
int vp10_receive_compressed_data(struct VP10Decoder *pbi,
|
int vp10_receive_compressed_data(struct VP10Decoder *pbi, size_t size,
|
||||||
size_t size, const uint8_t **dest);
|
const uint8_t **dest);
|
||||||
|
|
||||||
int vp10_get_raw_frame(struct VP10Decoder *pbi, YV12_BUFFER_CONFIG *sd);
|
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);
|
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_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,
|
VPX_REFFRAME ref_frame_flag,
|
||||||
YV12_BUFFER_CONFIG *sd);
|
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,
|
static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
|
||||||
void *decrypt_state,
|
void *decrypt_state, const uint8_t *data) {
|
||||||
const uint8_t *data) {
|
|
||||||
if (decrypt_cb) {
|
if (decrypt_cb) {
|
||||||
uint8_t marker;
|
uint8_t marker;
|
||||||
decrypt_cb(decrypt_state, data, &marker, 1);
|
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
|
// This function is exposed for use in tests, as well as the inlined function
|
||||||
// "read_marker".
|
// "read_marker".
|
||||||
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data,
|
vpx_codec_err_t vp10_parse_superframe_index(const uint8_t *data, size_t data_sz,
|
||||||
size_t data_sz,
|
uint32_t sizes[8], int *count,
|
||||||
uint32_t sizes[8], int *count,
|
vpx_decrypt_cb decrypt_cb,
|
||||||
vpx_decrypt_cb decrypt_cb,
|
void *decrypt_state);
|
||||||
void *decrypt_state);
|
|
||||||
|
|
||||||
struct VP10Decoder *vp10_decoder_create(BufferPool *const pool);
|
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) {
|
for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
|
||||||
RefBuffer *const ref_frame = &cm->frame_refs[i];
|
RefBuffer *const ref_frame = &cm->frame_refs[i];
|
||||||
if (ref_frame->idx == INVALID_IDX) continue;
|
if (ref_frame->idx == INVALID_IDX) continue;
|
||||||
if (frame_buf == &cm->buffer_pool->frame_bufs[ref_frame->idx])
|
if (frame_buf == &cm->buffer_pool->frame_bufs[ref_frame->idx]) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return (i < INTER_REFS_PER_FRAME);
|
return (i < INTER_REFS_PER_FRAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,34 +19,31 @@
|
||||||
|
|
||||||
#include "vp10/decoder/detokenize.h"
|
#include "vp10/decoder/detokenize.h"
|
||||||
|
|
||||||
#define EOB_CONTEXT_NODE 0
|
#define EOB_CONTEXT_NODE 0
|
||||||
#define ZERO_CONTEXT_NODE 1
|
#define ZERO_CONTEXT_NODE 1
|
||||||
#define ONE_CONTEXT_NODE 2
|
#define ONE_CONTEXT_NODE 2
|
||||||
#define LOW_VAL_CONTEXT_NODE 0
|
#define LOW_VAL_CONTEXT_NODE 0
|
||||||
#define TWO_CONTEXT_NODE 1
|
#define TWO_CONTEXT_NODE 1
|
||||||
#define THREE_CONTEXT_NODE 2
|
#define THREE_CONTEXT_NODE 2
|
||||||
#define HIGH_LOW_CONTEXT_NODE 3
|
#define HIGH_LOW_CONTEXT_NODE 3
|
||||||
#define CAT_ONE_CONTEXT_NODE 4
|
#define CAT_ONE_CONTEXT_NODE 4
|
||||||
#define CAT_THREEFOUR_CONTEXT_NODE 5
|
#define CAT_THREEFOUR_CONTEXT_NODE 5
|
||||||
#define CAT_THREE_CONTEXT_NODE 6
|
#define CAT_THREE_CONTEXT_NODE 6
|
||||||
#define CAT_FIVE_CONTEXT_NODE 7
|
#define CAT_FIVE_CONTEXT_NODE 7
|
||||||
|
|
||||||
#define INCREMENT_COUNT(token) \
|
#define INCREMENT_COUNT(token) \
|
||||||
do { \
|
do { \
|
||||||
if (counts) \
|
if (counts) ++coef_counts[band][ctx][token]; \
|
||||||
++coef_counts[band][ctx][token]; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#if !CONFIG_ANS
|
#if !CONFIG_ANS
|
||||||
static INLINE int read_coeff(const vpx_prob *probs, int n, vp10_reader *r) {
|
static INLINE int read_coeff(const vpx_prob *probs, int n, vp10_reader *r) {
|
||||||
int i, val = 0;
|
int i, val = 0;
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i) val = (val << 1) | vp10_read(r, probs[i]);
|
||||||
val = (val << 1) | vp10_read(r, probs[i]);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_coefs(const MACROBLOCKD *xd,
|
static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
|
||||||
PLANE_TYPE type,
|
|
||||||
tran_low_t *dqcoeff, TX_SIZE tx_size, TX_TYPE tx_type,
|
tran_low_t *dqcoeff, TX_SIZE tx_size, TX_TYPE tx_type,
|
||||||
const int16_t *dq,
|
const int16_t *dq,
|
||||||
#if CONFIG_NEW_QUANT
|
#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);
|
const int ref = is_inter_block(&xd->mi[0]->mbmi);
|
||||||
int band, c = 0;
|
int band, c = 0;
|
||||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
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];
|
fc->coef_probs[tx_size_ctx][type][ref];
|
||||||
const vpx_prob *prob;
|
const vpx_prob *prob;
|
||||||
unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||||
unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
|
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
|
||||||
uint8_t token_cache[MAX_TX_SQUARE];
|
uint8_t token_cache[MAX_TX_SQUARE];
|
||||||
const uint8_t *band_translate = get_band_translate(tx_size);
|
const uint8_t *band_translate = get_band_translate(tx_size);
|
||||||
int dq_shift;
|
int dq_shift;
|
||||||
|
@ -125,8 +122,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
||||||
int val = -1;
|
int val = -1;
|
||||||
band = *band_translate++;
|
band = *band_translate++;
|
||||||
prob = coef_probs[band][ctx];
|
prob = coef_probs[band][ctx];
|
||||||
if (counts)
|
if (counts) ++eob_branch_count[band][ctx];
|
||||||
++eob_branch_count[band][ctx];
|
|
||||||
if (!vp10_read(r, prob[EOB_CONTEXT_NODE])) {
|
if (!vp10_read(r, prob[EOB_CONTEXT_NODE])) {
|
||||||
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||||
break;
|
break;
|
||||||
|
@ -141,8 +137,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
||||||
dqv = dq[1];
|
dqv = dq[1];
|
||||||
token_cache[scan[c]] = 0;
|
token_cache[scan[c]] = 0;
|
||||||
++c;
|
++c;
|
||||||
if (c >= max_eob)
|
if (c >= max_eob) return c; // zero tokens at the end (no eob token)
|
||||||
return c; // zero tokens at the end (no eob token)
|
|
||||||
ctx = get_coef_context(nb, token_cache, c);
|
ctx = get_coef_context(nb, token_cache, c);
|
||||||
band = *band_translate++;
|
band = *band_translate++;
|
||||||
prob = coef_probs[band][ctx];
|
prob = coef_probs[band][ctx];
|
||||||
|
@ -158,13 +153,11 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
||||||
} else {
|
} else {
|
||||||
INCREMENT_COUNT(TWO_TOKEN);
|
INCREMENT_COUNT(TWO_TOKEN);
|
||||||
token = vp10_read_tree(r, vp10_coef_con_tree,
|
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) {
|
switch (token) {
|
||||||
case TWO_TOKEN:
|
case TWO_TOKEN:
|
||||||
case THREE_TOKEN:
|
case THREE_TOKEN:
|
||||||
case FOUR_TOKEN:
|
case FOUR_TOKEN: val = token; break;
|
||||||
val = token;
|
|
||||||
break;
|
|
||||||
case CATEGORY1_TOKEN:
|
case CATEGORY1_TOKEN:
|
||||||
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
|
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
|
||||||
break;
|
break;
|
||||||
|
@ -194,9 +187,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
|
||||||
case VPX_BITS_12:
|
case VPX_BITS_12:
|
||||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
|
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
|
||||||
break;
|
break;
|
||||||
default:
|
default: assert(0); return -1;
|
||||||
assert(0);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
|
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_COEFFICIENT_RANGE_CHECKING
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
dqcoeff[scan[c]] = highbd_check_range((vp10_read_bit(r) ? -v : v),
|
dqcoeff[scan[c]] = highbd_check_range((vp10_read_bit(r) ? -v : v), xd->bd);
|
||||||
xd->bd);
|
|
||||||
#else
|
#else
|
||||||
dqcoeff[scan[c]] = check_range(vp10_read_bit(r) ? -v : v);
|
dqcoeff[scan[c]] = check_range(vp10_read_bit(r) ? -v : v);
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
#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,
|
static INLINE int read_coeff(const vpx_prob *const probs, int n,
|
||||||
struct AnsDecoder *const ans) {
|
struct AnsDecoder *const ans) {
|
||||||
int i, val = 0;
|
int i, val = 0;
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i) val = (val << 1) | uabs_read(ans, probs[i]);
|
||||||
val = (val << 1) | uabs_read(ans, probs[i]);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
static int decode_coefs_ans(const MACROBLOCKD *const xd, PLANE_TYPE type,
|
||||||
PLANE_TYPE type,
|
|
||||||
tran_low_t *dqcoeff, TX_SIZE tx_size,
|
tran_low_t *dqcoeff, TX_SIZE tx_size,
|
||||||
TX_TYPE tx_type,
|
TX_TYPE tx_type, const int16_t *dq,
|
||||||
const int16_t *dq,
|
|
||||||
#if CONFIG_NEW_QUANT
|
#if CONFIG_NEW_QUANT
|
||||||
dequant_val_type_nuq *dq_val,
|
dequant_val_type_nuq *dq_val,
|
||||||
#endif // CONFIG_NEW_QUANT
|
#endif // CONFIG_NEW_QUANT
|
||||||
|
@ -256,14 +243,14 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||||
int band, c = 0;
|
int band, c = 0;
|
||||||
int skip_eob = 0;
|
int skip_eob = 0;
|
||||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
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];
|
fc->coef_probs[tx_size_ctx][type][ref];
|
||||||
const rans_dec_lut(*coef_cdfs)[COEFF_CONTEXTS] =
|
const rans_dec_lut(*coef_cdfs)[COEFF_CONTEXTS] =
|
||||||
fc->coef_cdfs[tx_size_ctx][type][ref];
|
fc->coef_cdfs[tx_size_ctx][type][ref];
|
||||||
const vpx_prob *prob;
|
const vpx_prob *prob;
|
||||||
const rans_dec_lut *cdf;
|
const rans_dec_lut *cdf;
|
||||||
unsigned int (*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
|
||||||
unsigned int (*eob_branch_count)[COEFF_CONTEXTS];
|
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
|
||||||
uint8_t token_cache[MAX_TX_SQUARE];
|
uint8_t token_cache[MAX_TX_SQUARE];
|
||||||
const uint8_t *band_translate = get_band_translate(tx_size);
|
const uint8_t *band_translate = get_band_translate(tx_size);
|
||||||
int dq_shift;
|
int dq_shift;
|
||||||
|
@ -325,8 +312,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||||
band = *band_translate++;
|
band = *band_translate++;
|
||||||
prob = coef_probs[band][ctx];
|
prob = coef_probs[band][ctx];
|
||||||
if (!skip_eob) {
|
if (!skip_eob) {
|
||||||
if (counts)
|
if (counts) ++eob_branch_count[band][ctx];
|
||||||
++eob_branch_count[band][ctx];
|
|
||||||
if (!uabs_read(ans, prob[EOB_CONTEXT_NODE])) {
|
if (!uabs_read(ans, prob[EOB_CONTEXT_NODE])) {
|
||||||
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||||
break;
|
break;
|
||||||
|
@ -349,9 +335,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||||
case ONE_TOKEN:
|
case ONE_TOKEN:
|
||||||
case TWO_TOKEN:
|
case TWO_TOKEN:
|
||||||
case THREE_TOKEN:
|
case THREE_TOKEN:
|
||||||
case FOUR_TOKEN:
|
case FOUR_TOKEN: val = token; break;
|
||||||
val = token;
|
|
||||||
break;
|
|
||||||
case CATEGORY1_TOKEN:
|
case CATEGORY1_TOKEN:
|
||||||
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, ans);
|
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, ans);
|
||||||
break;
|
break;
|
||||||
|
@ -381,9 +365,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||||
case VPX_BITS_12:
|
case VPX_BITS_12:
|
||||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, ans);
|
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, ans);
|
||||||
break;
|
break;
|
||||||
default:
|
default: assert(0); return -1;
|
||||||
assert(0);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, ans);
|
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;
|
} break;
|
||||||
}
|
}
|
||||||
#if CONFIG_NEW_QUANT
|
#if CONFIG_NEW_QUANT
|
||||||
v = vp10_dequant_abscoeff_nuq(val, dqv, dqv_val);
|
v = vp10_dequant_abscoeff_nuq(val, dqv, dqv_val);
|
||||||
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
|
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
|
||||||
#else
|
#else
|
||||||
v = (val * dqv) >> dq_shift;
|
v = (val * dqv) >> dq_shift;
|
||||||
#endif // CONFIG_NEW_QUANT
|
#endif // CONFIG_NEW_QUANT
|
||||||
|
|
||||||
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||||
|
@ -419,12 +401,12 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
|
||||||
}
|
}
|
||||||
#endif // !CONFIG_ANS
|
#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.
|
// after testing is complete, then delete this version.
|
||||||
static
|
static void dec_set_contexts(const MACROBLOCKD *xd,
|
||||||
void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
|
struct macroblockd_plane *pd, TX_SIZE tx_size,
|
||||||
TX_SIZE tx_size, int has_eob,
|
int has_eob, int aoff, int loff) {
|
||||||
int aoff, int loff) {
|
|
||||||
ENTROPY_CONTEXT *const a = pd->above_context + aoff;
|
ENTROPY_CONTEXT *const a = pd->above_context + aoff;
|
||||||
ENTROPY_CONTEXT *const l = pd->left_context + loff;
|
ENTROPY_CONTEXT *const l = pd->left_context + loff;
|
||||||
const int tx_w_in_blocks = num_4x4_blocks_wide_txsize_lookup[tx_size];
|
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
|
// above
|
||||||
if (has_eob && xd->mb_to_right_edge < 0) {
|
if (has_eob && xd->mb_to_right_edge < 0) {
|
||||||
int i;
|
int i;
|
||||||
const int blocks_wide = pd->n4_w +
|
const int blocks_wide =
|
||||||
(xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
pd->n4_w + (xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||||
int above_contexts = tx_w_in_blocks;
|
int above_contexts = tx_w_in_blocks;
|
||||||
if (above_contexts + aoff > blocks_wide)
|
if (above_contexts + aoff > blocks_wide)
|
||||||
above_contexts = blocks_wide - aoff;
|
above_contexts = blocks_wide - aoff;
|
||||||
|
|
||||||
for (i = 0; i < above_contexts; ++i)
|
for (i = 0; i < above_contexts; ++i) a[i] = has_eob;
|
||||||
a[i] = has_eob;
|
for (i = above_contexts; i < tx_w_in_blocks; ++i) a[i] = 0;
|
||||||
for (i = above_contexts; i < tx_w_in_blocks; ++i)
|
|
||||||
a[i] = 0;
|
|
||||||
} else {
|
} else {
|
||||||
memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_w_in_blocks);
|
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
|
// left
|
||||||
if (has_eob && xd->mb_to_bottom_edge < 0) {
|
if (has_eob && xd->mb_to_bottom_edge < 0) {
|
||||||
int i;
|
int i;
|
||||||
const int blocks_high = pd->n4_h +
|
const int blocks_high =
|
||||||
(xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
pd->n4_h + (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||||
int left_contexts = tx_h_in_blocks;
|
int left_contexts = tx_h_in_blocks;
|
||||||
if (left_contexts + loff > blocks_high)
|
if (left_contexts + loff > blocks_high) left_contexts = blocks_high - loff;
|
||||||
left_contexts = blocks_high - loff;
|
|
||||||
|
|
||||||
for (i = 0; i < left_contexts; ++i)
|
for (i = 0; i < left_contexts; ++i) l[i] = has_eob;
|
||||||
l[i] = has_eob;
|
for (i = left_contexts; i < tx_h_in_blocks; ++i) l[i] = 0;
|
||||||
for (i = left_contexts; i < tx_h_in_blocks; ++i)
|
|
||||||
l[i] = 0;
|
|
||||||
} else {
|
} else {
|
||||||
memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_h_in_blocks);
|
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;
|
MB_MODE_INFO *const mbmi = &mi->mbmi;
|
||||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||||
const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
|
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]) >>
|
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 color_idx, color_ctx, color_order[PALETTE_MAX_SIZE];
|
||||||
int n = mbmi->palette_mode_info.palette_size[plane != 0];
|
int n = mbmi->palette_mode_info.palette_size[plane != 0];
|
||||||
int i, j;
|
int i, j;
|
||||||
uint8_t *color_map = xd->plane[plane != 0].color_index_map;
|
uint8_t *color_map = xd->plane[plane != 0].color_index_map;
|
||||||
const vpx_prob (* const prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
|
const vpx_prob (*const prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
|
||||||
plane ? vp10_default_palette_uv_color_prob :
|
plane ? vp10_default_palette_uv_color_prob
|
||||||
vp10_default_palette_y_color_prob;
|
: vp10_default_palette_y_color_prob;
|
||||||
|
|
||||||
for (i = 0; i < rows; ++i) {
|
for (i = 0; i < rows; ++i) {
|
||||||
for (j = (i == 0 ? 1 : 0); j < cols; ++j) {
|
for (j = (i == 0 ? 1 : 0); j < cols; ++j) {
|
||||||
color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, n,
|
color_ctx =
|
||||||
color_order);
|
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],
|
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);
|
assert(color_idx >= 0 && color_idx < n);
|
||||||
color_map[i * cols + j] = color_order[color_idx];
|
color_map[i * cols + j] = color_order[color_idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
int vp10_decode_block_tokens(MACROBLOCKD *const xd, int plane,
|
||||||
int plane, const scan_order *sc,
|
const scan_order *sc, int x, int y,
|
||||||
int x, int y,
|
TX_SIZE tx_size, TX_TYPE tx_type,
|
||||||
TX_SIZE tx_size,
|
|
||||||
TX_TYPE tx_type,
|
|
||||||
#if CONFIG_ANS
|
#if CONFIG_ANS
|
||||||
struct AnsDecoder *const r,
|
struct AnsDecoder *const r,
|
||||||
#else
|
#else
|
||||||
|
@ -507,24 +482,22 @@ int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
||||||
int seg_id) {
|
int seg_id) {
|
||||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||||
const int16_t *const dequant = pd->seg_dequant[seg_id];
|
const int16_t *const dequant = pd->seg_dequant[seg_id];
|
||||||
const int ctx = get_entropy_context(tx_size, pd->above_context + x,
|
const int ctx =
|
||||||
pd->left_context + y);
|
get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
|
||||||
#if CONFIG_NEW_QUANT
|
#if CONFIG_NEW_QUANT
|
||||||
int dq = get_dq_profile_from_ctx(ctx);
|
int dq = get_dq_profile_from_ctx(ctx);
|
||||||
#endif // CONFIG_NEW_QUANT
|
#endif // CONFIG_NEW_QUANT
|
||||||
|
|
||||||
#if !CONFIG_ANS
|
#if !CONFIG_ANS
|
||||||
const int eob = decode_coefs(xd, pd->plane_type,
|
const int eob =
|
||||||
pd->dqcoeff, tx_size, tx_type,
|
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
|
||||||
dequant,
|
|
||||||
#if CONFIG_NEW_QUANT
|
#if CONFIG_NEW_QUANT
|
||||||
pd->seg_dequant_nuq[seg_id][dq],
|
pd->seg_dequant_nuq[seg_id][dq],
|
||||||
#endif // CONFIG_NEW_QUANT
|
#endif // CONFIG_NEW_QUANT
|
||||||
ctx, sc->scan, sc->neighbors, r);
|
ctx, sc->scan, sc->neighbors, r);
|
||||||
#else
|
#else
|
||||||
const int eob = decode_coefs_ans(xd, pd->plane_type,
|
const int eob = decode_coefs_ans(xd, pd->plane_type, pd->dqcoeff, tx_size,
|
||||||
pd->dqcoeff, tx_size, tx_type,
|
tx_type, dequant,
|
||||||
dequant,
|
|
||||||
#if CONFIG_NEW_QUANT
|
#if CONFIG_NEW_QUANT
|
||||||
pd->seg_dequant_nuq[seg_id][dq],
|
pd->seg_dequant_nuq[seg_id][dq],
|
||||||
#endif // CONFIG_NEW_QUANT
|
#endif // CONFIG_NEW_QUANT
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef VP10_DECODER_DETOKENIZE_H_
|
#ifndef VP10_DECODER_DETOKENIZE_H_
|
||||||
#define 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,
|
void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
||||||
vp10_reader *r);
|
vp10_reader *r);
|
||||||
int vp10_decode_block_tokens(MACROBLOCKD *const xd,
|
int vp10_decode_block_tokens(MACROBLOCKD *const xd, int plane,
|
||||||
int plane, const scan_order *sc,
|
const scan_order *sc, int x, int y,
|
||||||
int x, int y,
|
TX_SIZE tx_size, TX_TYPE tx_type,
|
||||||
TX_SIZE tx_size,
|
|
||||||
TX_TYPE tx_type,
|
|
||||||
#if CONFIG_ANS
|
#if CONFIG_ANS
|
||||||
struct AnsDecoder *const r,
|
struct AnsDecoder *const r,
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
#include "vp10/decoder/dsubexp.h"
|
#include "vp10/decoder/dsubexp.h"
|
||||||
|
|
||||||
static int inv_recenter_nonneg(int v, int m) {
|
static int inv_recenter_nonneg(int v, int m) {
|
||||||
if (v > 2 * m)
|
if (v > 2 * m) return v;
|
||||||
return v;
|
|
||||||
|
|
||||||
return (v & 1) ? m - ((v + 1) >> 1) : m + (v >> 1);
|
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 l = 8;
|
||||||
const int m = (1 << l) - 190;
|
const int m = (1 << l) - 190;
|
||||||
const int v = vp10_read_literal(r, l - 1);
|
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 int inv_remap_prob(int v, int m) {
|
||||||
static uint8_t inv_map_table[MAX_PROB - 1] = {
|
static uint8_t inv_map_table[MAX_PROB - 1] = {
|
||||||
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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) {
|
static int decode_term_subexp(vp10_reader *r) {
|
||||||
if (!vp10_read_bit(r))
|
if (!vp10_read_bit(r)) return vp10_read_literal(r, 4);
|
||||||
return vp10_read_literal(r, 4);
|
if (!vp10_read_bit(r)) return vp10_read_literal(r, 4) + 16;
|
||||||
if (!vp10_read_bit(r))
|
if (!vp10_read_bit(r)) return vp10_read_literal(r, 5) + 32;
|
||||||
return vp10_read_literal(r, 4) + 16;
|
|
||||||
if (!vp10_read_bit(r))
|
|
||||||
return vp10_read_literal(r, 5) + 32;
|
|
||||||
return decode_uniform(r) + 64;
|
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)) {
|
if (vp10_read(r, DIFF_UPDATE_PROB)) {
|
||||||
const int delp = decode_term_subexp(r);
|
const int delp = decode_term_subexp(r);
|
||||||
*p = (vpx_prob)inv_remap_prob(delp, *p);
|
*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.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef VP10_DECODER_DSUBEXP_H_
|
#ifndef VP10_DECODER_DSUBEXP_H_
|
||||||
#define VP10_DECODER_DSUBEXP_H_
|
#define VP10_DECODER_DSUBEXP_H_
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // 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.
|
// TODO(hkuang): Remove worker parameter as it is only used in debug code.
|
||||||
void vp10_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
|
void vp10_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
|
||||||
int row) {
|
int row) {
|
||||||
#if CONFIG_MULTITHREAD
|
#if CONFIG_MULTITHREAD
|
||||||
if (!ref_buf)
|
if (!ref_buf) return;
|
||||||
return;
|
|
||||||
|
|
||||||
#ifndef BUILDING_WITH_TSAN
|
#ifndef BUILDING_WITH_TSAN
|
||||||
// The following line of code will get harmless tsan error but it is the key
|
// 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,
|
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
||||||
VPxWorker *const src_worker) {
|
VPxWorker *const src_worker) {
|
||||||
#if CONFIG_MULTITHREAD
|
#if CONFIG_MULTITHREAD
|
||||||
FrameWorkerData *const src_worker_data = (FrameWorkerData *)src_worker->data1;
|
FrameWorkerData *const src_worker_data = (FrameWorkerData *)src_worker->data1;
|
||||||
FrameWorkerData *const dst_worker_data = (FrameWorkerData *)dst_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);
|
vp10_frameworker_lock_stats(src_worker);
|
||||||
while (!src_worker_data->frame_context_ready) {
|
while (!src_worker_data->frame_context_ready) {
|
||||||
pthread_cond_wait(&src_worker_data->stats_cond,
|
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 ?
|
dst_cm->last_frame_seg_map = src_cm->seg.enabled
|
||||||
src_cm->current_frame_seg_map : src_cm->last_frame_seg_map;
|
? src_cm->current_frame_seg_map
|
||||||
|
: src_cm->last_frame_seg_map;
|
||||||
dst_worker_data->pbi->need_resync = src_worker_data->pbi->need_resync;
|
dst_worker_data->pbi->need_resync = src_worker_data->pbi->need_resync;
|
||||||
vp10_frameworker_unlock_stats(src_worker);
|
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;
|
dst_cm->use_highbitdepth = src_cm->use_highbitdepth;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_EXT_REFS
|
#if CONFIG_EXT_REFS
|
||||||
// TODO(zoeliu): To handle parallel decoding
|
// TODO(zoeliu): To handle parallel decoding
|
||||||
#endif // CONFIG_EXT_REFS
|
#endif // CONFIG_EXT_REFS
|
||||||
dst_cm->prev_frame = src_cm->show_existing_frame ?
|
dst_cm->prev_frame =
|
||||||
src_cm->prev_frame : src_cm->cur_frame;
|
src_cm->show_existing_frame ? src_cm->prev_frame : src_cm->cur_frame;
|
||||||
dst_cm->last_width = !src_cm->show_existing_frame ?
|
dst_cm->last_width =
|
||||||
src_cm->width : src_cm->last_width;
|
!src_cm->show_existing_frame ? src_cm->width : src_cm->last_width;
|
||||||
dst_cm->last_height = !src_cm->show_existing_frame ?
|
dst_cm->last_height =
|
||||||
src_cm->height : src_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_x = src_cm->subsampling_x;
|
||||||
dst_cm->subsampling_y = src_cm->subsampling_y;
|
dst_cm->subsampling_y = src_cm->subsampling_y;
|
||||||
dst_cm->frame_type = src_cm->frame_type;
|
dst_cm->frame_type = src_cm->frame_type;
|
||||||
dst_cm->last_show_frame = !src_cm->show_existing_frame ?
|
dst_cm->last_show_frame = !src_cm->show_existing_frame
|
||||||
src_cm->show_frame : src_cm->last_show_frame;
|
? src_cm->show_frame
|
||||||
|
: src_cm->last_show_frame;
|
||||||
for (i = 0; i < REF_FRAMES; ++i)
|
for (i = 0; i < REF_FRAMES; ++i)
|
||||||
dst_cm->ref_frame_map[i] = src_cm->next_ref_frame_map[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,
|
memcpy(dst_cm->frame_contexts, src_cm->frame_contexts,
|
||||||
FRAME_CONTEXTS * sizeof(dst_cm->frame_contexts[0]));
|
FRAME_CONTEXTS * sizeof(dst_cm->frame_contexts[0]));
|
||||||
#else
|
#else
|
||||||
(void) dst_worker;
|
(void)dst_worker;
|
||||||
(void) src_worker;
|
(void)src_worker;
|
||||||
#endif // CONFIG_MULTITHREAD
|
#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
|
// start decoding next frame. So need to check whether worker is still decoding
|
||||||
// ref_buf.
|
// ref_buf.
|
||||||
void vp10_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const 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
|
// FrameWorker broadcasts its decoding progress so other workers that are
|
||||||
// waiting on it can resume decoding.
|
// 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.
|
// Copy necessary decoding context from src worker to dst worker.
|
||||||
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
|
||||||
VPxWorker *const src_worker);
|
VPxWorker *const src_worker);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // VP10_DECODER_DTHREAD_H_
|
#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.
|
// This limit is due to framebuffer numbers.
|
||||||
// TODO(hkuang): Remove this limit after implementing ondemand framebuffers.
|
// 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 {
|
typedef struct cache_frame {
|
||||||
int fb_idx;
|
int fb_idx;
|
||||||
|
@ -42,38 +42,38 @@ typedef struct cache_frame {
|
||||||
} cache_frame;
|
} cache_frame;
|
||||||
|
|
||||||
struct vpx_codec_alg_priv {
|
struct vpx_codec_alg_priv {
|
||||||
vpx_codec_priv_t base;
|
vpx_codec_priv_t base;
|
||||||
vpx_codec_dec_cfg_t cfg;
|
vpx_codec_dec_cfg_t cfg;
|
||||||
vp10_stream_info_t si;
|
vp10_stream_info_t si;
|
||||||
int postproc_cfg_set;
|
int postproc_cfg_set;
|
||||||
vp8_postproc_cfg_t postproc_cfg;
|
vp8_postproc_cfg_t postproc_cfg;
|
||||||
vpx_decrypt_cb decrypt_cb;
|
vpx_decrypt_cb decrypt_cb;
|
||||||
void *decrypt_state;
|
void *decrypt_state;
|
||||||
vpx_image_t img;
|
vpx_image_t img;
|
||||||
int img_avail;
|
int img_avail;
|
||||||
int flushed;
|
int flushed;
|
||||||
int invert_tile_order;
|
int invert_tile_order;
|
||||||
int last_show_frame; // Index of last output frame.
|
int last_show_frame; // Index of last output frame.
|
||||||
int byte_alignment;
|
int byte_alignment;
|
||||||
int skip_loop_filter;
|
int skip_loop_filter;
|
||||||
int decode_tile_row;
|
int decode_tile_row;
|
||||||
int decode_tile_col;
|
int decode_tile_col;
|
||||||
|
|
||||||
// Frame parallel related.
|
// Frame parallel related.
|
||||||
int frame_parallel_decode; // frame-based threading.
|
int frame_parallel_decode; // frame-based threading.
|
||||||
VPxWorker *frame_workers;
|
VPxWorker *frame_workers;
|
||||||
int num_frame_workers;
|
int num_frame_workers;
|
||||||
int next_submit_worker_id;
|
int next_submit_worker_id;
|
||||||
int last_submit_worker_id;
|
int last_submit_worker_id;
|
||||||
int next_output_worker_id;
|
int next_output_worker_id;
|
||||||
int available_threads;
|
int available_threads;
|
||||||
cache_frame frame_cache[FRAME_CACHE_SIZE];
|
cache_frame frame_cache[FRAME_CACHE_SIZE];
|
||||||
int frame_cache_write;
|
int frame_cache_write;
|
||||||
int frame_cache_read;
|
int frame_cache_read;
|
||||||
int num_cache_frames;
|
int num_cache_frames;
|
||||||
int need_resync; // wait for key/intra-only frame
|
int need_resync; // wait for key/intra-only frame
|
||||||
// BufferPool that holds all reference frames. Shared by all the FrameWorkers.
|
// 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.
|
// External frame buffer info to save for VP10 common.
|
||||||
void *ext_priv; // Private data associated with the external frame buffers.
|
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) {
|
if (!ctx->priv) {
|
||||||
vpx_codec_alg_priv_t *const priv =
|
vpx_codec_alg_priv_t *const priv =
|
||||||
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
|
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
|
||||||
if (priv == NULL)
|
if (priv == NULL) return VPX_CODEC_MEM_ERROR;
|
||||||
return VPX_CODEC_MEM_ERROR;
|
|
||||||
|
|
||||||
ctx->priv = (vpx_codec_priv_t *)priv;
|
ctx->priv = (vpx_codec_priv_t *)priv;
|
||||||
ctx->priv->init_flags = ctx->init_flags;
|
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.
|
// Only do frame parallel decode when threads > 1.
|
||||||
priv->frame_parallel_decode =
|
priv->frame_parallel_decode =
|
||||||
(ctx->config.dec && (ctx->config.dec->threads > 1) &&
|
(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) {
|
if (ctx->config.dec) {
|
||||||
priv->cfg = *ctx->config.dec;
|
priv->cfg = *ctx->config.dec;
|
||||||
ctx->config.dec = &priv->cfg;
|
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;
|
return VPX_CODEC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_bitdepth_colorspace_sampling(
|
static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
|
||||||
BITSTREAM_PROFILE profile, struct vpx_read_bit_buffer *rb) {
|
struct vpx_read_bit_buffer *rb) {
|
||||||
vpx_color_space_t color_space;
|
vpx_color_space_t color_space;
|
||||||
if (profile >= PROFILE_2)
|
if (profile >= PROFILE_2) rb->bit_offset += 1; // Bit-depth 10 or 12.
|
||||||
rb->bit_offset += 1; // Bit-depth 10 or 12.
|
|
||||||
color_space = (vpx_color_space_t)vpx_rb_read_literal(rb, 3);
|
color_space = (vpx_color_space_t)vpx_rb_read_literal(rb, 3);
|
||||||
if (color_space != VPX_CS_SRGB) {
|
if (color_space != VPX_CS_SRGB) {
|
||||||
rb->bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range.
|
rb->bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range.
|
||||||
|
@ -170,17 +170,13 @@ static int parse_bitdepth_colorspace_sampling(
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
|
static vpx_codec_err_t decoder_peek_si_internal(
|
||||||
unsigned int data_sz,
|
const uint8_t *data, unsigned int data_sz, vpx_codec_stream_info_t *si,
|
||||||
vpx_codec_stream_info_t *si,
|
int *is_intra_only, vpx_decrypt_cb decrypt_cb, void *decrypt_state) {
|
||||||
int *is_intra_only,
|
|
||||||
vpx_decrypt_cb decrypt_cb,
|
|
||||||
void *decrypt_state) {
|
|
||||||
int intra_only_flag = 0;
|
int intra_only_flag = 0;
|
||||||
uint8_t clear_buffer[9];
|
uint8_t clear_buffer[9];
|
||||||
|
|
||||||
if (data + data_sz <= data)
|
if (data + data_sz <= data) return VPX_CODEC_INVALID_PARAM;
|
||||||
return VPX_CODEC_INVALID_PARAM;
|
|
||||||
|
|
||||||
si->is_kf = 0;
|
si->is_kf = 0;
|
||||||
si->w = si->h = 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 int frame_marker = vpx_rb_read_literal(&rb, 2);
|
||||||
const BITSTREAM_PROFILE profile = vp10_read_profile(&rb);
|
const BITSTREAM_PROFILE profile = vp10_read_profile(&rb);
|
||||||
|
|
||||||
if (frame_marker != VPX_FRAME_MARKER)
|
if (frame_marker != VPX_FRAME_MARKER) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
|
||||||
|
|
||||||
if (profile >= MAX_PROFILES)
|
if (profile >= MAX_PROFILES) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
|
||||||
|
|
||||||
if ((profile >= 2 && data_sz <= 1) || data_sz < 1)
|
if ((profile >= 2 && data_sz <= 1) || data_sz < 1)
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
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.
|
vpx_rb_read_literal(&rb, 3); // Frame buffer to show.
|
||||||
return VPX_CODEC_OK;
|
return VPX_CODEC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_sz <= 8)
|
if (data_sz <= 8) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
|
||||||
|
|
||||||
si->is_kf = !vpx_rb_read_bit(&rb);
|
si->is_kf = !vpx_rb_read_bit(&rb);
|
||||||
show_frame = vpx_rb_read_bit(&rb);
|
show_frame = vpx_rb_read_bit(&rb);
|
||||||
error_resilient = vpx_rb_read_bit(&rb);
|
error_resilient = vpx_rb_read_bit(&rb);
|
||||||
|
|
||||||
if (si->is_kf) {
|
if (si->is_kf) {
|
||||||
if (!vp10_read_sync_code(&rb))
|
if (!vp10_read_sync_code(&rb)) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
|
||||||
|
|
||||||
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
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
|
rb.bit_offset += error_resilient ? 0 : 2; // reset_frame_context
|
||||||
|
|
||||||
if (intra_only_flag) {
|
if (intra_only_flag) {
|
||||||
if (!vp10_read_sync_code(&rb))
|
if (!vp10_read_sync_code(&rb)) return VPX_CODEC_UNSUP_BITSTREAM;
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
|
||||||
if (profile > PROFILE_0) {
|
if (profile > PROFILE_0) {
|
||||||
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
|
||||||
return VPX_CODEC_UNSUP_BITSTREAM;
|
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)
|
if (is_intra_only != NULL) *is_intra_only = intra_only_flag;
|
||||||
*is_intra_only = intra_only_flag;
|
|
||||||
return VPX_CODEC_OK;
|
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,
|
static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx,
|
||||||
vpx_codec_stream_info_t *si) {
|
vpx_codec_stream_info_t *si) {
|
||||||
const size_t sz = (si->sz >= sizeof(vp10_stream_info_t))
|
const size_t sz = (si->sz >= sizeof(vp10_stream_info_t))
|
||||||
? sizeof(vp10_stream_info_t)
|
? sizeof(vp10_stream_info_t)
|
||||||
: sizeof(vpx_codec_stream_info_t);
|
: sizeof(vpx_codec_stream_info_t);
|
||||||
memcpy(si, &ctx->si, sz);
|
memcpy(si, &ctx->si, sz);
|
||||||
si->sz = (unsigned int)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;
|
ctx->base.err_detail = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vpx_codec_err_t update_error_state(vpx_codec_alg_priv_t *ctx,
|
static vpx_codec_err_t update_error_state(
|
||||||
const struct vpx_internal_error_info *error) {
|
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
|
||||||
if (error->error_code)
|
if (error->error_code)
|
||||||
set_error_detail(ctx, error->has_detail ? error->detail : NULL);
|
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;
|
const uint8_t *data = frame_worker_data->data;
|
||||||
(void)arg2;
|
(void)arg2;
|
||||||
|
|
||||||
frame_worker_data->result =
|
frame_worker_data->result = vp10_receive_compressed_data(
|
||||||
vp10_receive_compressed_data(frame_worker_data->pbi,
|
frame_worker_data->pbi, frame_worker_data->data_size, &data);
|
||||||
frame_worker_data->data_size,
|
|
||||||
&data);
|
|
||||||
frame_worker_data->data_end = data;
|
frame_worker_data->data_end = data;
|
||||||
|
|
||||||
if (frame_worker_data->pbi->common.frame_parallel_decode) {
|
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->num_cache_frames = 0;
|
||||||
ctx->need_resync = 1;
|
ctx->need_resync = 1;
|
||||||
ctx->num_frame_workers =
|
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)
|
if (ctx->num_frame_workers > MAX_DECODE_THREADS)
|
||||||
ctx->num_frame_workers = MAX_DECODE_THREADS;
|
ctx->num_frame_workers = MAX_DECODE_THREADS;
|
||||||
ctx->available_threads = ctx->num_frame_workers;
|
ctx->available_threads = ctx->num_frame_workers;
|
||||||
ctx->flushed = 0;
|
ctx->flushed = 0;
|
||||||
|
|
||||||
ctx->buffer_pool = (BufferPool *)vpx_calloc(1, sizeof(BufferPool));
|
ctx->buffer_pool = (BufferPool *)vpx_calloc(1, sizeof(BufferPool));
|
||||||
if (ctx->buffer_pool == NULL)
|
if (ctx->buffer_pool == NULL) return VPX_CODEC_MEM_ERROR;
|
||||||
return VPX_CODEC_MEM_ERROR;
|
|
||||||
|
|
||||||
#if CONFIG_MULTITHREAD
|
#if CONFIG_MULTITHREAD
|
||||||
if (pthread_mutex_init(&ctx->buffer_pool->pool_mutex, NULL)) {
|
if (pthread_mutex_init(&ctx->buffer_pool->pool_mutex, NULL)) {
|
||||||
set_error_detail(ctx, "Failed to allocate buffer pool mutex");
|
set_error_detail(ctx, "Failed to allocate buffer pool mutex");
|
||||||
return VPX_CODEC_MEM_ERROR;
|
return VPX_CODEC_MEM_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ctx->frame_workers = (VPxWorker *)
|
ctx->frame_workers = (VPxWorker *)vpx_malloc(ctx->num_frame_workers *
|
||||||
vpx_malloc(ctx->num_frame_workers * sizeof(*ctx->frame_workers));
|
sizeof(*ctx->frame_workers));
|
||||||
if (ctx->frame_workers == NULL) {
|
if (ctx->frame_workers == NULL) {
|
||||||
set_error_detail(ctx, "Failed to allocate frame_workers");
|
set_error_detail(ctx, "Failed to allocate frame_workers");
|
||||||
return VPX_CODEC_MEM_ERROR;
|
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
|
// If postprocessing was enabled by the application and a
|
||||||
// configuration has not been provided, default it.
|
// configuration has not been provided, default it.
|
||||||
if (!ctx->postproc_cfg_set &&
|
if (!ctx->postproc_cfg_set && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
|
||||||
(ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
|
|
||||||
set_default_ppflags(&ctx->postproc_cfg);
|
set_default_ppflags(&ctx->postproc_cfg);
|
||||||
|
|
||||||
init_buffer_callbacks(ctx);
|
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 =
|
const vpx_codec_err_t res =
|
||||||
decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only,
|
decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only,
|
||||||
ctx->decrypt_cb, ctx->decrypt_state);
|
ctx->decrypt_cb, ctx->decrypt_state);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
|
|
||||||
if (!ctx->si.is_kf && !is_intra_only)
|
if (!ctx->si.is_kf && !is_intra_only) return VPX_CODEC_ERROR;
|
||||||
return VPX_CODEC_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->frame_parallel_decode) {
|
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);
|
frame_worker_data->user_priv);
|
||||||
ctx->frame_cache[ctx->frame_cache_write].img.fb_priv =
|
ctx->frame_cache[ctx->frame_cache_write].img.fb_priv =
|
||||||
frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
|
frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
|
||||||
ctx->frame_cache_write =
|
ctx->frame_cache_write = (ctx->frame_cache_write + 1) % FRAME_CACHE_SIZE;
|
||||||
(ctx->frame_cache_write + 1) % FRAME_CACHE_SIZE;
|
|
||||||
++ctx->num_cache_frames;
|
++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,
|
const uint8_t *data, unsigned int data_sz,
|
||||||
void *user_priv, long deadline) {
|
void *user_priv, long deadline) {
|
||||||
const uint8_t *data_start = data;
|
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;
|
vpx_codec_err_t res;
|
||||||
uint32_t frame_sizes[8];
|
uint32_t frame_sizes[8];
|
||||||
int frame_count;
|
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.
|
// Initialize the decoder workers on the first frame.
|
||||||
if (ctx->frame_workers == NULL) {
|
if (ctx->frame_workers == NULL) {
|
||||||
const vpx_codec_err_t res = init_decoder(ctx);
|
const vpx_codec_err_t res = init_decoder(ctx);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = vp10_parse_superframe_index(data, data_sz, frame_sizes, &frame_count,
|
res = vp10_parse_superframe_index(data, data_sz, frame_sizes, &frame_count,
|
||||||
ctx->decrypt_cb, ctx->decrypt_state);
|
ctx->decrypt_cb, ctx->decrypt_state);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
|
|
||||||
if (ctx->frame_parallel_decode) {
|
if (ctx->frame_parallel_decode) {
|
||||||
// Decode in frame parallel mode. When decoding in this mode, the frame
|
// 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) {
|
for (i = 0; i < frame_count; ++i) {
|
||||||
const uint8_t *data_start_copy = data_start;
|
const uint8_t *data_start_copy = data_start;
|
||||||
const uint32_t frame_size = frame_sizes[i];
|
const uint32_t frame_size = frame_sizes[i];
|
||||||
if (data_start < data
|
if (data_start < data ||
|
||||||
|| frame_size > (uint32_t) (data_end - data_start)) {
|
frame_size > (uint32_t)(data_end - data_start)) {
|
||||||
set_error_detail(ctx, "Invalid frame size in index");
|
set_error_detail(ctx, "Invalid frame size in index");
|
||||||
return VPX_CODEC_CORRUPT_FRAME;
|
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,
|
res =
|
||||||
deadline);
|
decode_one(ctx, &data_start_copy, frame_size, user_priv, deadline);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
data_start += frame_size;
|
data_start += frame_size;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
res = decode_one(ctx, &data, data_sz, user_priv, deadline);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Decode in serial mode.
|
// 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 uint8_t *data_start_copy = data_start;
|
||||||
const uint32_t frame_size = frame_sizes[i];
|
const uint32_t frame_size = frame_sizes[i];
|
||||||
vpx_codec_err_t res;
|
vpx_codec_err_t res;
|
||||||
if (data_start < data
|
if (data_start < data ||
|
||||||
|| frame_size > (uint32_t) (data_end - data_start)) {
|
frame_size > (uint32_t)(data_end - data_start)) {
|
||||||
set_error_detail(ctx, "Invalid frame size in index");
|
set_error_detail(ctx, "Invalid frame size in index");
|
||||||
return VPX_CODEC_CORRUPT_FRAME;
|
return VPX_CODEC_CORRUPT_FRAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = decode_one(ctx, &data_start_copy, frame_size, user_priv,
|
res =
|
||||||
deadline);
|
decode_one(ctx, &data_start_copy, frame_size, user_priv, deadline);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
|
|
||||||
data_start += frame_size;
|
data_start += frame_size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (data_start < data_end) {
|
while (data_start < data_end) {
|
||||||
const uint32_t frame_size = (uint32_t) (data_end - data_start);
|
const uint32_t frame_size = (uint32_t)(data_end - data_start);
|
||||||
const vpx_codec_err_t res = decode_one(ctx, &data_start, frame_size,
|
const vpx_codec_err_t res =
|
||||||
user_priv, deadline);
|
decode_one(ctx, &data_start, frame_size, user_priv, deadline);
|
||||||
if (res != VPX_CODEC_OK)
|
if (res != VPX_CODEC_OK) return res;
|
||||||
return res;
|
|
||||||
|
|
||||||
// Account for suboptimal termination by the encoder.
|
// Account for suboptimal termination by the encoder.
|
||||||
while (data_start < data_end) {
|
while (data_start < data_end) {
|
||||||
const uint8_t marker = read_marker(ctx->decrypt_cb,
|
const uint8_t marker =
|
||||||
ctx->decrypt_state, data_start);
|
read_marker(ctx->decrypt_cb, ctx->decrypt_state, data_start);
|
||||||
if (marker)
|
if (marker) break;
|
||||||
break;
|
|
||||||
++data_start;
|
++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.
|
// Output the frames in the cache first.
|
||||||
if (ctx->num_cache_frames > 0) {
|
if (ctx->num_cache_frames > 0) {
|
||||||
release_last_output_frame(ctx);
|
release_last_output_frame(ctx);
|
||||||
ctx->last_show_frame = ctx->frame_cache[ctx->frame_cache_read].fb_idx;
|
ctx->last_show_frame = ctx->frame_cache[ctx->frame_cache_read].fb_idx;
|
||||||
if (ctx->need_resync)
|
if (ctx->need_resync) return NULL;
|
||||||
return NULL;
|
|
||||||
img = &ctx->frame_cache[ctx->frame_cache_read].img;
|
img = &ctx->frame_cache[ctx->frame_cache_read].img;
|
||||||
ctx->frame_cache_read = (ctx->frame_cache_read + 1) % FRAME_CACHE_SIZE;
|
ctx->frame_cache_read = (ctx->frame_cache_read + 1) % FRAME_CACHE_SIZE;
|
||||||
--ctx->num_cache_frames;
|
--ctx->num_cache_frames;
|
||||||
|
@ -743,8 +718,7 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
|
||||||
do {
|
do {
|
||||||
YV12_BUFFER_CONFIG sd;
|
YV12_BUFFER_CONFIG sd;
|
||||||
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
|
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
|
||||||
VPxWorker *const worker =
|
VPxWorker *const worker = &ctx->frame_workers[ctx->next_output_worker_id];
|
||||||
&ctx->frame_workers[ctx->next_output_worker_id];
|
|
||||||
FrameWorkerData *const frame_worker_data =
|
FrameWorkerData *const frame_worker_data =
|
||||||
(FrameWorkerData *)worker->data1;
|
(FrameWorkerData *)worker->data1;
|
||||||
ctx->next_output_worker_id =
|
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;
|
RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
|
||||||
release_last_output_frame(ctx);
|
release_last_output_frame(ctx);
|
||||||
ctx->last_show_frame = frame_worker_data->pbi->common.new_fb_idx;
|
ctx->last_show_frame = frame_worker_data->pbi->common.new_fb_idx;
|
||||||
if (ctx->need_resync)
|
if (ctx->need_resync) return NULL;
|
||||||
return NULL;
|
|
||||||
yuvconfig2image(&ctx->img, &sd, frame_worker_data->user_priv);
|
yuvconfig2image(&ctx->img, &sd, frame_worker_data->user_priv);
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_EXT_TILE
|
#if CONFIG_EXT_TILE
|
||||||
if (frame_worker_data->pbi->dec_tile_row >= 0) {
|
if (frame_worker_data->pbi->dec_tile_row >= 0) {
|
||||||
const int tile_row = VPXMIN(frame_worker_data->pbi->dec_tile_row,
|
const int tile_row =
|
||||||
cm->tile_rows - 1);
|
VPXMIN(frame_worker_data->pbi->dec_tile_row, cm->tile_rows - 1);
|
||||||
const int mi_row = tile_row * cm->tile_height;
|
const int mi_row = tile_row * cm->tile_height;
|
||||||
const int ssy = ctx->img.y_chroma_shift;
|
const int ssy = ctx->img.y_chroma_shift;
|
||||||
int plane;
|
int plane;
|
||||||
ctx->img.planes[0] += mi_row * MI_SIZE * ctx->img.stride[0];
|
ctx->img.planes[0] += mi_row * MI_SIZE * ctx->img.stride[0];
|
||||||
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
||||||
ctx->img.planes[plane] += mi_row * (MI_SIZE >> ssy) *
|
ctx->img.planes[plane] +=
|
||||||
ctx->img.stride[plane];
|
mi_row * (MI_SIZE >> ssy) * ctx->img.stride[plane];
|
||||||
}
|
}
|
||||||
ctx->img.d_h = VPXMIN(cm->tile_height, cm->mi_rows - mi_row) *
|
ctx->img.d_h =
|
||||||
MI_SIZE;
|
VPXMIN(cm->tile_height, cm->mi_rows - mi_row) * MI_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame_worker_data->pbi->dec_tile_col >= 0) {
|
if (frame_worker_data->pbi->dec_tile_col >= 0) {
|
||||||
const int tile_col = VPXMIN(frame_worker_data->pbi->dec_tile_col,
|
const int tile_col =
|
||||||
cm->tile_cols - 1);
|
VPXMIN(frame_worker_data->pbi->dec_tile_col, cm->tile_cols - 1);
|
||||||
const int mi_col = tile_col * cm->tile_width;
|
const int mi_col = tile_col * cm->tile_width;
|
||||||
const int ssx = ctx->img.x_chroma_shift;
|
const int ssx = ctx->img.x_chroma_shift;
|
||||||
int plane;
|
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) {
|
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
||||||
ctx->img.planes[plane] += mi_col * (MI_SIZE >> ssx);
|
ctx->img.planes[plane] += mi_col * (MI_SIZE >> ssx);
|
||||||
}
|
}
|
||||||
ctx->img.d_w = VPXMIN(cm->tile_width, cm->mi_cols - mi_col) *
|
ctx->img.d_w =
|
||||||
MI_SIZE;
|
VPXMIN(cm->tile_width, cm->mi_cols - mi_col) * MI_SIZE;
|
||||||
}
|
}
|
||||||
#endif // CONFIG_EXT_TILE
|
#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;
|
frame_worker_data->received_frame = 0;
|
||||||
++ctx->available_threads;
|
++ctx->available_threads;
|
||||||
ctx->need_resync = 1;
|
ctx->need_resync = 1;
|
||||||
if (ctx->flushed != 1)
|
if (ctx->flushed != 1) return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
} while (ctx->next_output_worker_id != ctx->next_submit_worker_id);
|
} 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(
|
static vpx_codec_err_t decoder_set_fb_fn(
|
||||||
vpx_codec_alg_priv_t *ctx,
|
vpx_codec_alg_priv_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||||
vpx_get_frame_buffer_cb_fn_t cb_get,
|
|
||||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) {
|
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) {
|
||||||
if (cb_get == NULL || cb_release == NULL) {
|
if (cb_get == NULL || cb_release == NULL) {
|
||||||
return VPX_CODEC_INVALID_PARAM;
|
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) {
|
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;
|
YV12_BUFFER_CONFIG sd;
|
||||||
VPxWorker *const worker = 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;
|
||||||
image2yuvconfig(&frame->img, &sd);
|
image2yuvconfig(&frame->img, &sd);
|
||||||
return vp10_copy_reference_dec(frame_worker_data->pbi,
|
return vp10_copy_reference_dec(frame_worker_data->pbi,
|
||||||
(VPX_REFFRAME)frame->frame_type, &sd);
|
(VPX_REFFRAME)frame->frame_type, &sd);
|
||||||
} else {
|
} else {
|
||||||
return VPX_CODEC_INVALID_PARAM;
|
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) {
|
if (data) {
|
||||||
YV12_BUFFER_CONFIG* fb;
|
YV12_BUFFER_CONFIG *fb;
|
||||||
VPxWorker *const worker = 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;
|
||||||
fb = get_ref_frame(&frame_worker_data->pbi->common, data->idx);
|
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;
|
ctx->byte_alignment = byte_alignment;
|
||||||
if (ctx->frame_workers) {
|
if (ctx->frame_workers) {
|
||||||
VPxWorker *const worker = ctx->frame_workers;
|
VPxWorker *const worker = ctx->frame_workers;
|
||||||
FrameWorkerData *const frame_worker_data =
|
FrameWorkerData *const frame_worker_data = (FrameWorkerData *)worker->data1;
|
||||||
(FrameWorkerData *)worker->data1;
|
|
||||||
frame_worker_data->pbi->common.byte_alignment = byte_alignment;
|
frame_worker_data->pbi->common.byte_alignment = byte_alignment;
|
||||||
}
|
}
|
||||||
return VPX_CODEC_OK;
|
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[] = {
|
static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
|
||||||
{VP8_COPY_REFERENCE, ctrl_copy_reference},
|
{ VP8_COPY_REFERENCE, ctrl_copy_reference },
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
{VP8_SET_REFERENCE, ctrl_set_reference},
|
{ VP8_SET_REFERENCE, ctrl_set_reference },
|
||||||
{VP8_SET_POSTPROC, ctrl_set_postproc},
|
{ VP8_SET_POSTPROC, ctrl_set_postproc },
|
||||||
{VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options},
|
{ VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options },
|
||||||
{VP8_SET_DBG_COLOR_MB_MODES, 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_COLOR_B_MODES, ctrl_set_dbg_options },
|
||||||
{VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options},
|
{ VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options },
|
||||||
{VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order},
|
{ VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order },
|
||||||
{VPXD_SET_DECRYPTOR, ctrl_set_decryptor},
|
{ VPXD_SET_DECRYPTOR, ctrl_set_decryptor },
|
||||||
{VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment},
|
{ VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment },
|
||||||
{VP9_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter},
|
{ VP9_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
|
||||||
{VP10_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row},
|
{ VP10_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row },
|
||||||
{VP10_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col},
|
{ VP10_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col },
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
{VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates},
|
{ VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates },
|
||||||
{VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted},
|
{ VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted },
|
||||||
{VP9_GET_REFERENCE, ctrl_get_reference},
|
{ VP9_GET_REFERENCE, ctrl_get_reference },
|
||||||
{VP9D_GET_DISPLAY_SIZE, ctrl_get_render_size},
|
{ VP9D_GET_DISPLAY_SIZE, ctrl_get_render_size },
|
||||||
{VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth},
|
{ VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth },
|
||||||
{VP9D_GET_FRAME_SIZE, ctrl_get_frame_size},
|
{ VP9D_GET_FRAME_SIZE, ctrl_get_frame_size },
|
||||||
{VP10_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image},
|
{ VP10_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image },
|
||||||
|
|
||||||
{ -1, NULL},
|
{ -1, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef VERSION_STRING
|
#ifndef VERSION_STRING
|
||||||
|
@ -1165,24 +1134,26 @@ CODEC_INTERFACE(vpx_codec_vp10_dx) = {
|
||||||
VPX_CODEC_INTERNAL_ABI_VERSION,
|
VPX_CODEC_INTERNAL_ABI_VERSION,
|
||||||
VPX_CODEC_CAP_DECODER |
|
VPX_CODEC_CAP_DECODER |
|
||||||
VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER, // vpx_codec_caps_t
|
VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER, // vpx_codec_caps_t
|
||||||
decoder_init, // vpx_codec_init_fn_t
|
decoder_init, // vpx_codec_init_fn_t
|
||||||
decoder_destroy, // vpx_codec_destroy_fn_t
|
decoder_destroy, // vpx_codec_destroy_fn_t
|
||||||
decoder_ctrl_maps, // vpx_codec_ctrl_fn_map_t
|
decoder_ctrl_maps, // vpx_codec_ctrl_fn_map_t
|
||||||
{ // NOLINT
|
{
|
||||||
decoder_peek_si, // vpx_codec_peek_si_fn_t
|
// NOLINT
|
||||||
decoder_get_si, // vpx_codec_get_si_fn_t
|
decoder_peek_si, // vpx_codec_peek_si_fn_t
|
||||||
decoder_decode, // vpx_codec_decode_fn_t
|
decoder_get_si, // vpx_codec_get_si_fn_t
|
||||||
decoder_get_frame, // vpx_codec_frame_get_fn_t
|
decoder_decode, // vpx_codec_decode_fn_t
|
||||||
decoder_set_fb_fn, // vpx_codec_set_fb_fn_t
|
decoder_get_frame, // vpx_codec_frame_get_fn_t
|
||||||
|
decoder_set_fb_fn, // vpx_codec_set_fb_fn_t
|
||||||
},
|
},
|
||||||
{ // NOLINT
|
{
|
||||||
0,
|
// NOLINT
|
||||||
NULL, // vpx_codec_enc_cfg_map_t
|
0,
|
||||||
NULL, // vpx_codec_encode_fn_t
|
NULL, // vpx_codec_enc_cfg_map_t
|
||||||
NULL, // vpx_codec_get_cx_data_fn_t
|
NULL, // vpx_codec_encode_fn_t
|
||||||
NULL, // vpx_codec_enc_config_set_fn_t
|
NULL, // vpx_codec_get_cx_data_fn_t
|
||||||
NULL, // vpx_codec_get_global_headers_fn_t
|
NULL, // vpx_codec_enc_config_set_fn_t
|
||||||
NULL, // vpx_codec_get_preview_frame_fn_t
|
NULL, // vpx_codec_get_global_headers_fn_t
|
||||||
NULL // vpx_codec_enc_mr_get_mem_loc_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"
|
#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) {
|
void *user_priv) {
|
||||||
/** vpx_img_wrap() doesn't allow specifying independent strides for
|
/** vpx_img_wrap() doesn't allow specifying independent strides for
|
||||||
* the Y, U, and V planes, nor other alignment adjustments that
|
* 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.
|
// of the image.
|
||||||
img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
|
img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
|
||||||
img->bit_depth = yv12->bit_depth;
|
img->bit_depth = yv12->bit_depth;
|
||||||
img->planes[VPX_PLANE_Y] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->y_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_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_V] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->v_buffer);
|
||||||
img->planes[VPX_PLANE_ALPHA] = NULL;
|
img->planes[VPX_PLANE_ALPHA] = NULL;
|
||||||
img->stride[VPX_PLANE_Y] = 2 * yv12->y_stride;
|
img->stride[VPX_PLANE_Y] = 2 * yv12->y_stride;
|
||||||
img->stride[VPX_PLANE_U] = 2 * yv12->uv_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->u_buffer = img->planes[VPX_PLANE_U];
|
||||||
yv12->v_buffer = img->planes[VPX_PLANE_V];
|
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->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->render_height = img->r_h;
|
||||||
yv12->y_width = img->d_w;
|
yv12->y_width = img->d_w;
|
||||||
yv12->y_height = img->d_h;
|
yv12->y_height = img->d_h;
|
||||||
|
|
||||||
yv12->uv_width = img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2
|
yv12->uv_width =
|
||||||
: yv12->y_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->uv_height =
|
||||||
: yv12->y_height;
|
img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height;
|
||||||
yv12->uv_crop_width = yv12->uv_width;
|
yv12->uv_crop_width = yv12->uv_width;
|
||||||
yv12->uv_crop_height = yv12->uv_height;
|
yv12->uv_crop_height = yv12->uv_height;
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
|
||||||
} else {
|
} else {
|
||||||
yv12->flags = 0;
|
yv12->flags = 0;
|
||||||
}
|
}
|
||||||
yv12->border = (yv12->y_stride - img->w) / 2;
|
yv12->border = (yv12->y_stride - img->w) / 2;
|
||||||
#else
|
#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
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
yv12->subsampling_x = img->x_chroma_shift;
|
yv12->subsampling_x = img->x_chroma_shift;
|
||||||
yv12->subsampling_y = img->y_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) {
|
static VPX_REFFRAME ref_frame_to_vp10_reframe(vpx_ref_frame_type_t frame) {
|
||||||
switch (frame) {
|
switch (frame) {
|
||||||
case VP8_LAST_FRAME:
|
case VP8_LAST_FRAME: return VPX_LAST_FLAG;
|
||||||
return VPX_LAST_FLAG;
|
case VP8_GOLD_FRAME: return VPX_GOLD_FLAG;
|
||||||
case VP8_GOLD_FRAME:
|
case VP8_ALTR_FRAME: return VPX_ALT_FLAG;
|
||||||
return VPX_GOLD_FLAG;
|
|
||||||
case VP8_ALTR_FRAME:
|
|
||||||
return VPX_ALT_FLAG;
|
|
||||||
}
|
}
|
||||||
assert(0 && "Invalid Reference Frame");
|
assert(0 && "Invalid Reference Frame");
|
||||||
return VPX_LAST_FLAG;
|
return VPX_LAST_FLAG;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче