| Index: source/libvpx/vp8/vp8_dx_iface.c
|
| ===================================================================
|
| --- source/libvpx/vp8/vp8_dx_iface.c (revision 179051)
|
| +++ source/libvpx/vp8/vp8_dx_iface.c (working copy)
|
| @@ -77,6 +77,7 @@
|
| vpx_image_t img;
|
| int img_setup;
|
| void *user_priv;
|
| + FRAGMENT_DATA fragments;
|
| };
|
|
|
| static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t flags)
|
| @@ -215,6 +216,13 @@
|
| {
|
| vp8_init_ctx(ctx, &mmap);
|
|
|
| + /* initialize number of fragments to zero */
|
| + ctx->priv->alg_priv->fragments.count = 0;
|
| + /* is input fragments enabled? */
|
| + ctx->priv->alg_priv->fragments.enabled =
|
| + (ctx->priv->alg_priv->base.init_flags &
|
| + VPX_CODEC_USE_INPUT_FRAGMENTS);
|
| +
|
| ctx->priv->alg_priv->defer_alloc = 1;
|
| /*post processing level initialized to do nothing */
|
| }
|
| @@ -343,6 +351,47 @@
|
| img->self_allocd = 0;
|
| }
|
|
|
| +static int
|
| +update_fragments(vpx_codec_alg_priv_t *ctx,
|
| + const uint8_t *data,
|
| + unsigned int data_sz,
|
| + vpx_codec_err_t *res)
|
| +{
|
| + *res = VPX_CODEC_OK;
|
| +
|
| + if (ctx->fragments.count == 0)
|
| + {
|
| + /* New frame, reset fragment pointers and sizes */
|
| + vpx_memset((void*)ctx->fragments.ptrs, 0, sizeof(ctx->fragments.ptrs));
|
| + vpx_memset(ctx->fragments.sizes, 0, sizeof(ctx->fragments.sizes));
|
| + }
|
| + if (ctx->fragments.enabled && !(data == NULL && data_sz == 0))
|
| + {
|
| + /* Store a pointer to this fragment and return. We haven't
|
| + * received the complete frame yet, so we will wait with decoding.
|
| + */
|
| + ctx->fragments.ptrs[ctx->fragments.count] = data;
|
| + ctx->fragments.sizes[ctx->fragments.count] = data_sz;
|
| + ctx->fragments.count++;
|
| + if (ctx->fragments.count > (1 << EIGHT_PARTITION) + 1)
|
| + {
|
| + ctx->fragments.count = 0;
|
| + *res = VPX_CODEC_INVALID_PARAM;
|
| + return -1;
|
| + }
|
| + return 0;
|
| + }
|
| +
|
| + if (!ctx->fragments.enabled)
|
| + {
|
| + ctx->fragments.ptrs[0] = data;
|
| + ctx->fragments.sizes[0] = data_sz;
|
| + ctx->fragments.count = 1;
|
| + }
|
| +
|
| + return 1;
|
| +}
|
| +
|
| static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
|
| const uint8_t *data,
|
| unsigned int data_sz,
|
| @@ -353,6 +402,11 @@
|
| unsigned int resolution_change = 0;
|
| unsigned int w, h;
|
|
|
| +
|
| + /* Update the input fragment data */
|
| + if(update_fragments(ctx, data, data_sz, &res) <= 0)
|
| + return res;
|
| +
|
| /* Determine the stream parameters. Note that we rely on peek_si to
|
| * validate that we have a buffer that does not wrap around the top
|
| * of the heap.
|
| @@ -360,7 +414,8 @@
|
| w = ctx->si.w;
|
| h = ctx->si.h;
|
|
|
| - res = ctx->base.iface->dec.peek_si(data, data_sz, &ctx->si);
|
| + res = ctx->base.iface->dec.peek_si(ctx->fragments.ptrs[0],
|
| + ctx->fragments.sizes[0], &ctx->si);
|
|
|
| if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf)
|
| {
|
| @@ -421,8 +476,6 @@
|
| oxcf.max_threads = ctx->cfg.threads;
|
| oxcf.error_concealment =
|
| (ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT);
|
| - oxcf.input_fragments =
|
| - (ctx->base.init_flags & VPX_CODEC_USE_INPUT_FRAGMENTS);
|
|
|
| optr = vp8dx_create_decompressor(&oxcf);
|
|
|
| @@ -544,12 +597,24 @@
|
| ctx->pbi->common.fb_idx_ref_cnt[0] = 0;
|
| }
|
|
|
| + /* update the pbi fragment data */
|
| + ctx->pbi->num_fragments = ctx->fragments.count;
|
| + ctx->pbi->input_fragments = ctx->fragments.enabled;
|
| + vpx_memcpy(ctx->pbi->fragments, ctx->fragments.ptrs,
|
| + sizeof(ctx->fragments.ptrs));
|
| + vpx_memcpy(ctx->pbi->fragment_sizes, ctx->fragments.sizes,
|
| + sizeof(ctx->fragments.sizes));
|
| +
|
| +
|
| ctx->user_priv = user_priv;
|
| if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
|
| {
|
| VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
|
| res = update_error_state(ctx, &pbi->common.error);
|
| }
|
| +
|
| + /* get ready for the next series of fragments */
|
| + ctx->fragments.count = 0;
|
| }
|
|
|
| return res;
|
|
|