| Index: source/libvpx/vp9/vp9_dx_iface.c
|
| ===================================================================
|
| --- source/libvpx/vp9/vp9_dx_iface.c (revision 247498)
|
| +++ source/libvpx/vp9/vp9_dx_iface.c (working copy)
|
| @@ -25,7 +25,7 @@
|
|
|
| /* Structures for handling memory allocations */
|
| typedef enum {
|
| - VP9_SEG_ALG_PRIV = 256,
|
| + VP9_SEG_ALG_PRIV = 256,
|
| VP9_SEG_MAX
|
| } mem_seg_id_t;
|
| #define NELEMENTS(x) ((int)(sizeof(x)/sizeof(x[0])))
|
| @@ -59,13 +59,6 @@
|
| int img_setup;
|
| int img_avail;
|
| int invert_tile_order;
|
| - int fb_lru;
|
| -
|
| - /* External buffer info to save for VP9 common. */
|
| - vpx_codec_frame_buffer_t *fb_list; // External frame buffers
|
| - int fb_count; // Total number of frame buffers
|
| - vpx_realloc_frame_buffer_cb_fn_t realloc_fb_cb;
|
| - void *user_priv; // Private data associated with the external frame buffers.
|
| };
|
|
|
| static unsigned long priv_sz(const vpx_codec_dec_cfg_t *si,
|
| @@ -107,12 +100,11 @@
|
|
|
| static vpx_codec_err_t vp9_init(vpx_codec_ctx_t *ctx,
|
| vpx_codec_priv_enc_mr_cfg_t *data) {
|
| - vpx_codec_err_t res = VPX_CODEC_OK;
|
| + vpx_codec_err_t res = VPX_CODEC_OK;
|
|
|
| - /* This function only allocates space for the vpx_codec_alg_priv_t
|
| - * structure. More memory may be required at the time the stream
|
| - * information becomes known.
|
| - */
|
| + // This function only allocates space for the vpx_codec_alg_priv_t
|
| + // structure. More memory may be required at the time the stream
|
| + // information becomes known.
|
| if (!ctx->priv) {
|
| vpx_codec_mmap_t mmap;
|
|
|
| @@ -122,12 +114,10 @@
|
| mmap.flags = vp9_mem_req_segs[0].flags;
|
|
|
| res = vpx_mmap_alloc(&mmap);
|
| -
|
| if (!res) {
|
| vp9_init_ctx(ctx, &mmap);
|
|
|
| ctx->priv->alg_priv->defer_alloc = 1;
|
| - /*post processing level initialized to do nothing */
|
| }
|
| }
|
|
|
| @@ -147,8 +137,7 @@
|
| return VPX_CODEC_OK;
|
| }
|
|
|
| -static vpx_codec_err_t vp9_peek_si(const uint8_t *data,
|
| - unsigned int data_sz,
|
| +static vpx_codec_err_t vp9_peek_si(const uint8_t *data, unsigned int data_sz,
|
| vpx_codec_stream_info_t *si) {
|
| if (data_sz <= 8) return VPX_CODEC_UNSUP_BITSTREAM;
|
| if (data + data_sz <= data) return VPX_CODEC_INVALID_PARAM;
|
| @@ -160,7 +149,8 @@
|
| struct vp9_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL };
|
| const int frame_marker = vp9_rb_read_literal(&rb, 2);
|
| const int version = vp9_rb_read_bit(&rb) | (vp9_rb_read_bit(&rb) << 1);
|
| - if (frame_marker != 0x2) return VPX_CODEC_UNSUP_BITSTREAM;
|
| + if (frame_marker != VP9_FRAME_MARKER)
|
| + return VPX_CODEC_UNSUP_BITSTREAM;
|
| #if CONFIG_NON420
|
| if (version > 1) return VPX_CODEC_UNSUP_BITSTREAM;
|
| #else
|
| @@ -212,13 +202,9 @@
|
|
|
| static vpx_codec_err_t vp9_get_si(vpx_codec_alg_priv_t *ctx,
|
| vpx_codec_stream_info_t *si) {
|
| - unsigned int sz;
|
| -
|
| - if (si->sz >= sizeof(vp9_stream_info_t))
|
| - sz = sizeof(vp9_stream_info_t);
|
| - else
|
| - sz = sizeof(vpx_codec_stream_info_t);
|
| -
|
| + const size_t sz = (si->sz >= sizeof(vp9_stream_info_t))
|
| + ? sizeof(vp9_stream_info_t)
|
| + : sizeof(vpx_codec_stream_info_t);
|
| memcpy(si, &ctx->si, sz);
|
| si->sz = sz;
|
|
|
| @@ -226,24 +212,17 @@
|
| }
|
|
|
|
|
| -static vpx_codec_err_t
|
| -update_error_state(vpx_codec_alg_priv_t *ctx,
|
| - const struct vpx_internal_error_info *error) {
|
| - vpx_codec_err_t res;
|
| +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)
|
| + ctx->base.err_detail = error->has_detail ? error->detail : NULL;
|
|
|
| - if ((res = error->error_code))
|
| - ctx->base.err_detail = error->has_detail
|
| - ? error->detail
|
| - : NULL;
|
| -
|
| - return res;
|
| + return error->error_code;
|
| }
|
|
|
| -static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
|
| - const uint8_t **data,
|
| - unsigned int data_sz,
|
| - void *user_priv,
|
| - long deadline) {
|
| +static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
|
| + const uint8_t **data, unsigned int data_sz,
|
| + void *user_priv, int64_t deadline) {
|
| vpx_codec_err_t res = VPX_CODEC_OK;
|
|
|
| ctx->img_avail = 0;
|
| @@ -303,43 +282,19 @@
|
| oxcf.inv_tile_order = ctx->invert_tile_order;
|
| optr = vp9_create_decompressor(&oxcf);
|
|
|
| - /* 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)) {
|
| - ctx->postproc_cfg.post_proc_flag =
|
| - VP8_DEBLOCK | VP8_DEMACROBLOCK;
|
| + // 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)) {
|
| + ctx->postproc_cfg.post_proc_flag = VP8_DEBLOCK | VP8_DEMACROBLOCK;
|
| ctx->postproc_cfg.deblocking_level = 4;
|
| ctx->postproc_cfg.noise_level = 0;
|
| }
|
|
|
| - if (!optr) {
|
| + if (!optr)
|
| res = VPX_CODEC_ERROR;
|
| - } else {
|
| - VP9D_COMP *const pbi = (VP9D_COMP*)optr;
|
| - VP9_COMMON *const cm = &pbi->common;
|
| - if (ctx->fb_list != NULL && ctx->realloc_fb_cb != NULL &&
|
| - ctx->fb_count > 0) {
|
| - cm->fb_list = ctx->fb_list;
|
| - cm->fb_count = ctx->fb_count;
|
| - cm->realloc_fb_cb = ctx->realloc_fb_cb;
|
| - cm->user_priv = ctx->user_priv;
|
| - } else {
|
| - cm->fb_count = FRAME_BUFFERS;
|
| - }
|
| - cm->fb_lru = ctx->fb_lru;
|
| - CHECK_MEM_ERROR(cm, cm->yv12_fb,
|
| - vpx_calloc(cm->fb_count, sizeof(*cm->yv12_fb)));
|
| - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_cnt,
|
| - vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_cnt)));
|
| - if (cm->fb_lru) {
|
| - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru,
|
| - vpx_calloc(cm->fb_count,
|
| - sizeof(*cm->fb_idx_ref_lru)));
|
| - }
|
| + else
|
| ctx->pbi = optr;
|
| - }
|
| }
|
|
|
| ctx->decoder_init = 1;
|
| @@ -353,25 +308,20 @@
|
| if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC) {
|
| flags.post_proc_flag =
|
| #if CONFIG_POSTPROC_VISUALIZER
|
| - ((ctx->dbg_color_ref_frame_flag != 0) ?
|
| - VP9D_DEBUG_CLR_FRM_REF_BLKS : 0)
|
| - | ((ctx->dbg_color_mb_modes_flag != 0) ?
|
| - VP9D_DEBUG_CLR_BLK_MODES : 0)
|
| - | ((ctx->dbg_color_b_modes_flag != 0) ?
|
| - VP9D_DEBUG_CLR_BLK_MODES : 0)
|
| - | ((ctx->dbg_display_mv_flag != 0) ?
|
| - VP9D_DEBUG_DRAW_MV : 0)
|
| - |
|
| + (ctx->dbg_color_ref_frame_flag ? VP9D_DEBUG_CLR_FRM_REF_BLKS : 0) |
|
| + (ctx->dbg_color_mb_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0) |
|
| + (ctx->dbg_color_b_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0) |
|
| + (ctx->dbg_display_mv_flag ? VP9D_DEBUG_DRAW_MV : 0) |
|
| #endif
|
| ctx->postproc_cfg.post_proc_flag;
|
|
|
| - flags.deblocking_level = ctx->postproc_cfg.deblocking_level;
|
| - flags.noise_level = ctx->postproc_cfg.noise_level;
|
| + flags.deblocking_level = ctx->postproc_cfg.deblocking_level;
|
| + flags.noise_level = ctx->postproc_cfg.noise_level;
|
| #if CONFIG_POSTPROC_VISUALIZER
|
| flags.display_ref_frame_flag = ctx->dbg_color_ref_frame_flag;
|
| flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag;
|
| - flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag;
|
| - flags.display_mv_flag = ctx->dbg_display_mv_flag;
|
| + flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag;
|
| + flags.display_mv_flag = ctx->dbg_display_mv_flag;
|
| #endif
|
| }
|
|
|
| @@ -390,10 +340,8 @@
|
| return res;
|
| }
|
|
|
| -static void parse_superframe_index(const uint8_t *data,
|
| - size_t data_sz,
|
| - uint32_t sizes[8],
|
| - int *count) {
|
| +static void parse_superframe_index(const uint8_t *data, size_t data_sz,
|
| + uint32_t sizes[8], int *count) {
|
| uint8_t marker;
|
|
|
| assert(data_sz);
|
| @@ -504,34 +452,12 @@
|
| return img;
|
| }
|
|
|
| -static vpx_codec_err_t vp9_set_frame_buffers(
|
| - vpx_codec_alg_priv_t *ctx,
|
| - vpx_codec_frame_buffer_t *fb_list, int fb_count,
|
| - vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) {
|
| - if (fb_count < (VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS)) {
|
| - /* The application must pass in at least VP9_MAXIMUM_REF_BUFFERS +
|
| - * VPX_MAXIMUM_WORK_BUFFERS frame buffers. */
|
| - return VPX_CODEC_INVALID_PARAM;
|
| - } else if (!ctx->pbi) {
|
| - /* If the decoder has already been initialized, do not accept external
|
| - * frame buffers.
|
| - */
|
| - ctx->fb_list = fb_list;
|
| - ctx->fb_count = fb_count;
|
| - ctx->realloc_fb_cb = cb;
|
| - ctx->user_priv = user_priv;
|
| - return VPX_CODEC_OK;
|
| - }
|
| +static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx,
|
| + vpx_codec_mmap_t *mmap,
|
| + vpx_codec_iter_t *iter) {
|
| + vpx_codec_err_t res;
|
| + const mem_req_t *seg_iter = *iter;
|
|
|
| - return VPX_CODEC_ERROR;
|
| -}
|
| -
|
| -static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx,
|
| - vpx_codec_mmap_t *mmap,
|
| - vpx_codec_iter_t *iter) {
|
| - vpx_codec_err_t res;
|
| - const mem_req_t *seg_iter = *iter;
|
| -
|
| /* Get address of next segment request */
|
| do {
|
| if (!seg_iter)
|
| @@ -559,7 +485,7 @@
|
| return res;
|
| }
|
|
|
| -static vpx_codec_err_t vp9_xma_set_mmap(vpx_codec_ctx_t *ctx,
|
| +static vpx_codec_err_t vp9_xma_set_mmap(vpx_codec_ctx_t *ctx,
|
| const vpx_codec_mmap_t *mmap) {
|
| vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
|
| int i, done;
|
| @@ -595,8 +521,7 @@
|
| return res;
|
| }
|
|
|
| -static vpx_codec_err_t set_reference(vpx_codec_alg_priv_t *ctx,
|
| - int ctr_id,
|
| +static vpx_codec_err_t set_reference(vpx_codec_alg_priv_t *ctx, int ctr_id,
|
| va_list args) {
|
| vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
|
|
|
| @@ -605,7 +530,6 @@
|
| YV12_BUFFER_CONFIG sd;
|
|
|
| image2yuvconfig(&frame->img, &sd);
|
| -
|
| return vp9_set_reference_dec(ctx->pbi,
|
| (VP9_REFFRAME)frame->frame_type, &sd);
|
| } else {
|
| @@ -613,8 +537,7 @@
|
| }
|
| }
|
|
|
| -static vpx_codec_err_t copy_reference(vpx_codec_alg_priv_t *ctx,
|
| - int ctr_id,
|
| +static vpx_codec_err_t copy_reference(vpx_codec_alg_priv_t *ctx, int ctr_id,
|
| va_list args) {
|
| vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
|
|
|
| @@ -631,8 +554,7 @@
|
| }
|
| }
|
|
|
| -static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx,
|
| - int ctr_id,
|
| +static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx, int ctr_id,
|
| va_list args) {
|
| vp9_ref_frame_t *data = va_arg(args, vp9_ref_frame_t *);
|
|
|
| @@ -647,8 +569,7 @@
|
| }
|
| }
|
|
|
| -static vpx_codec_err_t set_postproc(vpx_codec_alg_priv_t *ctx,
|
| - int ctr_id,
|
| +static vpx_codec_err_t set_postproc(vpx_codec_alg_priv_t *ctx, int ctr_id,
|
| va_list args) {
|
| #if CONFIG_VP9_POSTPROC
|
| vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
|
| @@ -665,8 +586,7 @@
|
| #endif
|
| }
|
|
|
| -static vpx_codec_err_t set_dbg_options(vpx_codec_alg_priv_t *ctx,
|
| - int ctrl_id,
|
| +static vpx_codec_err_t set_dbg_options(vpx_codec_alg_priv_t *ctx, int ctrl_id,
|
| va_list args) {
|
| #if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC
|
| int data = va_arg(args, int);
|
| @@ -687,8 +607,7 @@
|
| }
|
|
|
| static vpx_codec_err_t get_last_ref_updates(vpx_codec_alg_priv_t *ctx,
|
| - int ctrl_id,
|
| - va_list args) {
|
| + int ctrl_id, va_list args) {
|
| int *update_info = va_arg(args, int *);
|
| VP9D_COMP *pbi = (VP9D_COMP*)ctx->pbi;
|
|
|
| @@ -703,8 +622,7 @@
|
|
|
|
|
| static vpx_codec_err_t get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
|
| - int ctrl_id,
|
| - va_list args) {
|
| + int ctrl_id, va_list args) {
|
| int *corrupted = va_arg(args, int *);
|
|
|
| if (corrupted) {
|
| @@ -720,8 +638,7 @@
|
| }
|
|
|
| static vpx_codec_err_t get_display_size(vpx_codec_alg_priv_t *ctx,
|
| - int ctrl_id,
|
| - va_list args) {
|
| + int ctrl_id, va_list args) {
|
| int *const display_size = va_arg(args, int *);
|
|
|
| if (display_size) {
|
| @@ -745,21 +662,6 @@
|
| return VPX_CODEC_OK;
|
| }
|
|
|
| -static vpx_codec_err_t set_frame_buffer_lru_cache(vpx_codec_alg_priv_t *ctx,
|
| - int ctr_id,
|
| - va_list args) {
|
| - VP9D_COMP *const pbi = (VP9D_COMP*)ctx->pbi;
|
| -
|
| - // Save for later to pass into vp9 common.
|
| - ctx->fb_lru = va_arg(args, int);
|
| -
|
| - if (pbi) {
|
| - VP9_COMMON *const cm = &pbi->common;
|
| - cm->fb_lru = ctx->fb_lru;
|
| - }
|
| - return VPX_CODEC_OK;
|
| -}
|
| -
|
| static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
|
| {VP8_SET_REFERENCE, set_reference},
|
| {VP8_COPY_REFERENCE, copy_reference},
|
| @@ -773,7 +675,6 @@
|
| {VP9_GET_REFERENCE, get_reference},
|
| {VP9D_GET_DISPLAY_SIZE, get_display_size},
|
| {VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order},
|
| - {VP9D_SET_FRAME_BUFFER_LRU_CACHE, set_frame_buffer_lru_cache},
|
| { -1, NULL},
|
| };
|
|
|
| @@ -784,8 +685,7 @@
|
| CODEC_INTERFACE(vpx_codec_vp9_dx) = {
|
| "WebM Project VP9 Decoder" VERSION_STRING,
|
| VPX_CODEC_INTERNAL_ABI_VERSION,
|
| - VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC |
|
| - VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER,
|
| + VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC,
|
| /* vpx_codec_caps_t caps; */
|
| vp9_init, /* vpx_codec_init_fn_t init; */
|
| vp9_destroy, /* vpx_codec_destroy_fn_t destroy; */
|
| @@ -797,7 +697,6 @@
|
| vp9_get_si, /* vpx_codec_get_si_fn_t get_si; */
|
| vp9_decode, /* vpx_codec_decode_fn_t decode; */
|
| vp9_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
|
| - vp9_set_frame_buffers, /* vpx_codec_set_frame_buffers_fn_t set_fb; */
|
| },
|
| { // NOLINT
|
| /* encoder functions */
|
|
|