Home | History | Annotate | Download | only in vp8
      1 /*
      2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 
     12 #include <stdlib.h>
     13 #include <string.h>
     14 #include "vpx/vpx_decoder.h"
     15 #include "vpx/vp8dx.h"
     16 #include "vpx/internal/vpx_codec_internal.h"
     17 #include "vpx_version.h"
     18 #include "onyxd.h"
     19 #include "onyxd_int.h"
     20 
     21 #define VP8_CAP_POSTPROC (CONFIG_POSTPROC ? VPX_CODEC_CAP_POSTPROC : 0)
     22 
     23 #if CONFIG_BIG_ENDIAN
     24 # define swap4(d)\
     25     ((d&0x000000ff)<<24) |  \
     26     ((d&0x0000ff00)<<8)  |  \
     27     ((d&0x00ff0000)>>8)  |  \
     28     ((d&0xff000000)>>24)
     29 # define swap2(d)\
     30     ((d&0x000000ff)<<8) |  \
     31     ((d&0x0000ff00)>>8)
     32 #else
     33 # define swap4(d) d
     34 # define swap2(d) d
     35 #endif
     36 typedef vpx_codec_stream_info_t  vp8_stream_info_t;
     37 
     38 /* Structures for handling memory allocations */
     39 typedef enum
     40 {
     41     VP8_SEG_ALG_PRIV     = 256,
     42     VP8_SEG_MAX
     43 } mem_seg_id_t;
     44 #define NELEMENTS(x) (sizeof(x)/sizeof(x[0]))
     45 
     46 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t);
     47 
     48 typedef struct
     49 {
     50     unsigned int   id;
     51     unsigned long  sz;
     52     unsigned int   align;
     53     unsigned int   flags;
     54     unsigned long(*calc_sz)(const vpx_codec_dec_cfg_t *, vpx_codec_flags_t);
     55 } mem_req_t;
     56 
     57 static const mem_req_t vp8_mem_req_segs[] =
     58 {
     59     {VP8_SEG_ALG_PRIV,    0, 8, VPX_CODEC_MEM_ZERO, vp8_priv_sz},
     60     {VP8_SEG_MAX, 0, 0, 0, NULL}
     61 };
     62 
     63 struct vpx_codec_alg_priv
     64 {
     65     vpx_codec_priv_t        base;
     66     vpx_codec_mmap_t        mmaps[NELEMENTS(vp8_mem_req_segs)-1];
     67     vpx_codec_dec_cfg_t     cfg;
     68     vp8_stream_info_t   si;
     69     int                     defer_alloc;
     70     int                     decoder_init;
     71     VP8D_PTR                pbi;
     72     int                     postproc_cfg_set;
     73     vp8_postproc_cfg_t      postproc_cfg;
     74     vpx_image_t             img;
     75     int                     img_setup;
     76     int                     img_avail;
     77 };
     78 
     79 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t flags)
     80 {
     81     /* Although this declaration is constant, we can't use it in the requested
     82      * segments list because we want to define the requested segments list
     83      * before defining the private type (so that the number of memory maps is
     84      * known)
     85      */
     86     (void)si;
     87     return sizeof(vpx_codec_alg_priv_t);
     88 }
     89 
     90 
     91 static void vp8_mmap_dtor(vpx_codec_mmap_t *mmap)
     92 {
     93     free(mmap->priv);
     94 }
     95 
     96 static vpx_codec_err_t vp8_mmap_alloc(vpx_codec_mmap_t *mmap)
     97 {
     98     vpx_codec_err_t  res;
     99     unsigned int   align;
    100 
    101     align = mmap->align ? mmap->align - 1 : 0;
    102 
    103     if (mmap->flags & VPX_CODEC_MEM_ZERO)
    104         mmap->priv = calloc(1, mmap->sz + align);
    105     else
    106         mmap->priv = malloc(mmap->sz + align);
    107 
    108     res = (mmap->priv) ? VPX_CODEC_OK : VPX_CODEC_MEM_ERROR;
    109     mmap->base = (void *)((((uintptr_t)mmap->priv) + align) & ~(uintptr_t)align);
    110     mmap->dtor = vp8_mmap_dtor;
    111     return res;
    112 }
    113 
    114 static vpx_codec_err_t vp8_validate_mmaps(const vp8_stream_info_t *si,
    115         const vpx_codec_mmap_t        *mmaps,
    116         vpx_codec_flags_t              init_flags)
    117 {
    118     int i;
    119     vpx_codec_err_t res = VPX_CODEC_OK;
    120 
    121     for (i = 0; i < NELEMENTS(vp8_mem_req_segs) - 1; i++)
    122     {
    123         /* Ensure the segment has been allocated */
    124         if (!mmaps[i].base)
    125         {
    126             res = VPX_CODEC_MEM_ERROR;
    127             break;
    128         }
    129 
    130         /* Verify variable size segment is big enough for the current si. */
    131         if (vp8_mem_req_segs[i].calc_sz)
    132         {
    133             vpx_codec_dec_cfg_t cfg;
    134 
    135             cfg.w = si->w;
    136             cfg.h = si->h;
    137 
    138             if (mmaps[i].sz < vp8_mem_req_segs[i].calc_sz(&cfg, init_flags))
    139             {
    140                 res = VPX_CODEC_MEM_ERROR;
    141                 break;
    142             }
    143         }
    144     }
    145 
    146     return res;
    147 }
    148 
    149 static void vp8_init_ctx(vpx_codec_ctx_t *ctx, const vpx_codec_mmap_t *mmap)
    150 {
    151     int i;
    152 
    153     ctx->priv = mmap->base;
    154     ctx->priv->sz = sizeof(*ctx->priv);
    155     ctx->priv->iface = ctx->iface;
    156     ctx->priv->alg_priv = mmap->base;
    157 
    158     for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++)
    159         ctx->priv->alg_priv->mmaps[i].id = vp8_mem_req_segs[i].id;
    160 
    161     ctx->priv->alg_priv->mmaps[0] = *mmap;
    162     ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si);
    163     ctx->priv->init_flags = ctx->init_flags;
    164 
    165     if (ctx->config.dec)
    166     {
    167         /* Update the reference to the config structure to an internal copy. */
    168         ctx->priv->alg_priv->cfg = *ctx->config.dec;
    169         ctx->config.dec = &ctx->priv->alg_priv->cfg;
    170     }
    171 }
    172 
    173 static void *mmap_lkup(vpx_codec_alg_priv_t *ctx, int id)
    174 {
    175     int i;
    176 
    177     for (i = 0; i < NELEMENTS(vp8_mem_req_segs); i++)
    178         if (ctx->mmaps[i].id == id)
    179             return ctx->mmaps[i].base;
    180 
    181     return NULL;
    182 }
    183 static void vp8_finalize_mmaps(vpx_codec_alg_priv_t *ctx)
    184 {
    185     /*
    186     ctx->pbi = mmap_lkup(ctx, VP6_SEG_PB_INSTANCE);
    187     ctx->pbi->mbi.block_dx_info[0].idct_output_ptr = mmap_lkup(ctx, VP6_SEG_IDCT_BUFFER);
    188     ctx->pbi->loop_filtered_block = mmap_lkup(ctx, VP6_SEG_LF_BLOCK);
    189     ctx->pbi->huff = mmap_lkup(ctx, VP6_SEG_HUFF);
    190     ctx->pbi->mbi.coeffs_base_ptr = mmap_lkup(ctx, VP6_SEG_COEFFS);
    191     ctx->pbi->fc.above_y = mmap_lkup(ctx, VP6_SEG_ABOVEY);
    192     ctx->pbi->fc.above_u = mmap_lkup(ctx, VP6_SEG_ABOVEU);
    193     ctx->pbi->fc.above_v = mmap_lkup(ctx, VP6_SEG_ABOVEV);
    194     ctx->pbi->prediction_mode = mmap_lkup(ctx, VP6_SEG_PRED_MODES);
    195     ctx->pbi->mbmotion_vector = mmap_lkup(ctx, VP6_SEG_MV_FIELD);
    196     ctx->pbi->fb_storage_ptr[0] = mmap_lkup(ctx, VP6_SEG_IMG0_STRG);
    197     ctx->pbi->fb_storage_ptr[1] = mmap_lkup(ctx, VP6_SEG_IMG1_STRG);
    198     ctx->pbi->fb_storage_ptr[2] = mmap_lkup(ctx, VP6_SEG_IMG2_STRG);
    199     #if CONFIG_POSTPROC
    200     ctx->pbi->postproc.deblock.fragment_variances = mmap_lkup(ctx, VP6_SEG_DEBLOCKER);
    201     ctx->pbi->fb_storage_ptr[3] = mmap_lkup(ctx, VP6_SEG_PP_IMG_STRG);
    202     #endif
    203     */
    204 }
    205 
    206 static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx)
    207 {
    208     vpx_codec_err_t        res = VPX_CODEC_OK;
    209 
    210     /* This function only allocates space for the vpx_codec_alg_priv_t
    211      * structure. More memory may be required at the time the stream
    212      * information becomes known.
    213      */
    214     if (!ctx->priv)
    215     {
    216         vpx_codec_mmap_t mmap;
    217 
    218         mmap.id = vp8_mem_req_segs[0].id;
    219         mmap.sz = sizeof(vpx_codec_alg_priv_t);
    220         mmap.align = vp8_mem_req_segs[0].align;
    221         mmap.flags = vp8_mem_req_segs[0].flags;
    222 
    223         res = vp8_mmap_alloc(&mmap);
    224 
    225         if (!res)
    226         {
    227             vp8_init_ctx(ctx, &mmap);
    228 
    229             ctx->priv->alg_priv->defer_alloc = 1;
    230             /*post processing level initialized to do nothing */
    231         }
    232     }
    233 
    234     return res;
    235 }
    236 
    237 static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx)
    238 {
    239     int i;
    240 
    241     vp8dx_remove_decompressor(ctx->pbi);
    242 
    243     for (i = NELEMENTS(ctx->mmaps) - 1; i >= 0; i--)
    244     {
    245         if (ctx->mmaps[i].dtor)
    246             ctx->mmaps[i].dtor(&ctx->mmaps[i]);
    247     }
    248 
    249     return VPX_CODEC_OK;
    250 }
    251 
    252 static vpx_codec_err_t vp8_peek_si(const uint8_t         *data,
    253                                    unsigned int           data_sz,
    254                                    vpx_codec_stream_info_t *si)
    255 {
    256 
    257     vpx_codec_err_t res = VPX_CODEC_OK;
    258     {
    259         /* Parse uncompresssed part of key frame header.
    260          * 3 bytes:- including version, frame type and an offset
    261          * 3 bytes:- sync code (0x9d, 0x01, 0x2a)
    262          * 4 bytes:- including image width and height in the lowest 14 bits
    263          *           of each 2-byte value.
    264          */
    265         si->is_kf = 0;
    266 
    267         if (data_sz >= 10 && !(data[0] & 0x01))  /* I-Frame */
    268         {
    269             const uint8_t *c = data + 3;
    270             si->is_kf = 1;
    271 
    272             // vet via sync code
    273             if (c[0] != 0x9d || c[1] != 0x01 || c[2] != 0x2a)
    274                 res = VPX_CODEC_UNSUP_BITSTREAM;
    275 
    276             si->w = swap2(*(const unsigned short *)(c + 3)) & 0x3fff;
    277             si->h = swap2(*(const unsigned short *)(c + 5)) & 0x3fff;
    278 
    279             //printf("w=%d, h=%d\n", si->w, si->h);
    280             if (!(si->h | si->w))
    281                 res = VPX_CODEC_UNSUP_BITSTREAM;
    282         }
    283         else
    284             res = VPX_CODEC_UNSUP_BITSTREAM;
    285     }
    286 
    287     return res;
    288 
    289 }
    290 
    291 static vpx_codec_err_t vp8_get_si(vpx_codec_alg_priv_t    *ctx,
    292                                   vpx_codec_stream_info_t *si)
    293 {
    294 
    295     unsigned int sz;
    296 
    297     if (si->sz >= sizeof(vp8_stream_info_t))
    298         sz = sizeof(vp8_stream_info_t);
    299     else
    300         sz = sizeof(vpx_codec_stream_info_t);
    301 
    302     memcpy(si, &ctx->si, sz);
    303     si->sz = sz;
    304 
    305     return VPX_CODEC_OK;
    306 }
    307 
    308 
    309 static vpx_codec_err_t
    310 update_error_state(vpx_codec_alg_priv_t                 *ctx,
    311                    const struct vpx_internal_error_info *error)
    312 {
    313     vpx_codec_err_t res;
    314 
    315     if ((res = error->error_code))
    316         ctx->base.err_detail = error->has_detail
    317                                ? error->detail
    318                                : NULL;
    319 
    320     return res;
    321 }
    322 
    323 
    324 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t  *ctx,
    325                                   const uint8_t         *data,
    326                                   unsigned int            data_sz,
    327                                   void                    *user_priv,
    328                                   long                    deadline)
    329 {
    330     vpx_codec_err_t res = VPX_CODEC_OK;
    331 
    332     ctx->img_avail = 0;
    333 
    334     /* Determine the stream parameters */
    335     if (!ctx->si.h)
    336         res = ctx->base.iface->dec.peek_si(data, data_sz, &ctx->si);
    337 
    338 
    339     /* Perform deferred allocations, if required */
    340     if (!res && ctx->defer_alloc)
    341     {
    342         int i;
    343 
    344         for (i = 1; !res && i < NELEMENTS(ctx->mmaps); i++)
    345         {
    346             vpx_codec_dec_cfg_t cfg;
    347 
    348             cfg.w = ctx->si.w;
    349             cfg.h = ctx->si.h;
    350             ctx->mmaps[i].id = vp8_mem_req_segs[i].id;
    351             ctx->mmaps[i].sz = vp8_mem_req_segs[i].sz;
    352             ctx->mmaps[i].align = vp8_mem_req_segs[i].align;
    353             ctx->mmaps[i].flags = vp8_mem_req_segs[i].flags;
    354 
    355             if (!ctx->mmaps[i].sz)
    356                 ctx->mmaps[i].sz = vp8_mem_req_segs[i].calc_sz(&cfg,
    357                                    ctx->base.init_flags);
    358 
    359             res = vp8_mmap_alloc(&ctx->mmaps[i]);
    360         }
    361 
    362         if (!res)
    363             vp8_finalize_mmaps(ctx);
    364 
    365         ctx->defer_alloc = 0;
    366     }
    367 
    368     /* Initialize the decoder instance on the first frame*/
    369     if (!res && !ctx->decoder_init)
    370     {
    371         res = vp8_validate_mmaps(&ctx->si, ctx->mmaps, ctx->base.init_flags);
    372 
    373         if (!res)
    374         {
    375             VP8D_CONFIG oxcf;
    376             VP8D_PTR optr;
    377 
    378             vp8dx_initialize();
    379 
    380             oxcf.Width = ctx->si.w;
    381             oxcf.Height = ctx->si.h;
    382             oxcf.Version = 9;
    383             oxcf.postprocess = 0;
    384             oxcf.max_threads = ctx->cfg.threads;
    385 
    386             optr = vp8dx_create_decompressor(&oxcf);
    387 
    388             /* If postprocessing was enabled by the application and a
    389              * configuration has not been provided, default it.
    390              */
    391             if (!ctx->postproc_cfg_set
    392                 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
    393             {
    394                 ctx->postproc_cfg.post_proc_flag =
    395                     VP8_DEBLOCK | VP8_DEMACROBLOCK;
    396                 ctx->postproc_cfg.deblocking_level = 4;
    397                 ctx->postproc_cfg.noise_level = 0;
    398             }
    399 
    400             if (!optr)
    401                 res = VPX_CODEC_ERROR;
    402             else
    403                 ctx->pbi = optr;
    404         }
    405 
    406         ctx->decoder_init = 1;
    407     }
    408 
    409     if (!res && ctx->pbi)
    410     {
    411         YV12_BUFFER_CONFIG sd;
    412         INT64 time_stamp = 0, time_end_stamp = 0;
    413         int ppflag       = 0;
    414         int ppdeblocking = 0;
    415         int ppnoise      = 0;
    416 
    417         if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)
    418         {
    419             ppflag      = ctx->postproc_cfg.post_proc_flag;
    420             ppdeblocking = ctx->postproc_cfg.deblocking_level;
    421             ppnoise     = ctx->postproc_cfg.noise_level;
    422         }
    423 
    424         if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
    425         {
    426             VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
    427             res = update_error_state(ctx, &pbi->common.error);
    428         }
    429 
    430         if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, ppdeblocking, ppnoise, ppflag))
    431         {
    432             /* Align width/height */
    433             unsigned int a_w = (sd.y_width + 15) & ~15;
    434             unsigned int a_h = (sd.y_height + 15) & ~15;
    435 
    436             vpx_img_wrap(&ctx->img, VPX_IMG_FMT_I420,
    437                          a_w + 2 * VP8BORDERINPIXELS,
    438                          a_h + 2 * VP8BORDERINPIXELS,
    439                          1,
    440                          sd.buffer_alloc);
    441             vpx_img_set_rect(&ctx->img,
    442                              VP8BORDERINPIXELS, VP8BORDERINPIXELS,
    443                              sd.y_width, sd.y_height);
    444             ctx->img_avail = 1;
    445 
    446         }
    447     }
    448 
    449     return res;
    450 }
    451 
    452 static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t  *ctx,
    453                                   vpx_codec_iter_t      *iter)
    454 {
    455     vpx_image_t *img = NULL;
    456 
    457     if (ctx->img_avail)
    458     {
    459         /* iter acts as a flip flop, so an image is only returned on the first
    460          * call to get_frame.
    461          */
    462         if (!(*iter))
    463         {
    464             img = &ctx->img;
    465             *iter = img;
    466         }
    467     }
    468 
    469     return img;
    470 }
    471 
    472 
    473 static
    474 vpx_codec_err_t vp8_xma_get_mmap(const vpx_codec_ctx_t      *ctx,
    475                                  vpx_codec_mmap_t           *mmap,
    476                                  vpx_codec_iter_t           *iter)
    477 {
    478     vpx_codec_err_t     res;
    479     const mem_req_t  *seg_iter = *iter;
    480 
    481     /* Get address of next segment request */
    482     do
    483     {
    484         if (!seg_iter)
    485             seg_iter = vp8_mem_req_segs;
    486         else if (seg_iter->id != VP8_SEG_MAX)
    487             seg_iter++;
    488 
    489         *iter = (vpx_codec_iter_t)seg_iter;
    490 
    491         if (seg_iter->id != VP8_SEG_MAX)
    492         {
    493             mmap->id = seg_iter->id;
    494             mmap->sz = seg_iter->sz;
    495             mmap->align = seg_iter->align;
    496             mmap->flags = seg_iter->flags;
    497 
    498             if (!seg_iter->sz)
    499                 mmap->sz = seg_iter->calc_sz(ctx->config.dec, ctx->init_flags);
    500 
    501             res = VPX_CODEC_OK;
    502         }
    503         else
    504             res = VPX_CODEC_LIST_END;
    505     }
    506     while (!mmap->sz && res != VPX_CODEC_LIST_END);
    507 
    508     return res;
    509 }
    510 
    511 static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t         *ctx,
    512                                         const vpx_codec_mmap_t  *mmap)
    513 {
    514     vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
    515     int i, done;
    516 
    517     if (!ctx->priv)
    518     {
    519         if (mmap->id == VP8_SEG_ALG_PRIV)
    520         {
    521             if (!ctx->priv)
    522             {
    523                 vp8_init_ctx(ctx, mmap);
    524                 res = VPX_CODEC_OK;
    525             }
    526         }
    527     }
    528 
    529     done = 1;
    530 
    531     if (!res && ctx->priv->alg_priv)
    532     {
    533         for (i = 0; i < NELEMENTS(vp8_mem_req_segs); i++)
    534         {
    535             if (ctx->priv->alg_priv->mmaps[i].id == mmap->id)
    536                 if (!ctx->priv->alg_priv->mmaps[i].base)
    537                 {
    538                     ctx->priv->alg_priv->mmaps[i] = *mmap;
    539                     res = VPX_CODEC_OK;
    540                 }
    541 
    542             done &= (ctx->priv->alg_priv->mmaps[i].base != NULL);
    543         }
    544     }
    545 
    546     if (done && !res)
    547     {
    548         vp8_finalize_mmaps(ctx->priv->alg_priv);
    549         res = ctx->iface->init(ctx);
    550     }
    551 
    552     return res;
    553 }
    554 
    555 static vpx_codec_err_t image2yuvconfig(const vpx_image_t   *img,
    556                                        YV12_BUFFER_CONFIG  *yv12)
    557 {
    558     vpx_codec_err_t        res = VPX_CODEC_OK;
    559     yv12->y_buffer = img->planes[VPX_PLANE_Y];
    560     yv12->u_buffer = img->planes[VPX_PLANE_U];
    561     yv12->v_buffer = img->planes[VPX_PLANE_V];
    562 
    563     yv12->y_width  = img->d_w;
    564     yv12->y_height = img->d_h;
    565     yv12->uv_width = yv12->y_width / 2;
    566     yv12->uv_height = yv12->y_height / 2;
    567 
    568     yv12->y_stride = img->stride[VPX_PLANE_Y];
    569     yv12->uv_stride = img->stride[VPX_PLANE_U];
    570 
    571     yv12->border  = (img->stride[VPX_PLANE_Y] - img->d_w) / 2;
    572     yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12);
    573 
    574     return res;
    575 }
    576 
    577 
    578 static vpx_codec_err_t vp8_set_reference(vpx_codec_alg_priv_t *ctx,
    579         int ctr_id,
    580         va_list args)
    581 {
    582 
    583     vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
    584 
    585     if (data)
    586     {
    587         vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
    588         YV12_BUFFER_CONFIG sd;
    589 
    590         image2yuvconfig(&frame->img, &sd);
    591 
    592         vp8dx_set_reference(ctx->pbi, frame->frame_type, &sd);
    593         return VPX_CODEC_OK;
    594     }
    595     else
    596         return VPX_CODEC_INVALID_PARAM;
    597 
    598 }
    599 
    600 static vpx_codec_err_t vp8_get_reference(vpx_codec_alg_priv_t *ctx,
    601         int ctr_id,
    602         va_list args)
    603 {
    604 
    605     vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
    606 
    607     if (data)
    608     {
    609         vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
    610         YV12_BUFFER_CONFIG sd;
    611 
    612         image2yuvconfig(&frame->img, &sd);
    613 
    614         vp8dx_get_reference(ctx->pbi, frame->frame_type, &sd);
    615         return VPX_CODEC_OK;
    616     }
    617     else
    618         return VPX_CODEC_INVALID_PARAM;
    619 
    620 }
    621 
    622 static vpx_codec_err_t vp8_set_postproc(vpx_codec_alg_priv_t *ctx,
    623                                         int ctr_id,
    624                                         va_list args)
    625 {
    626     vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
    627 #if CONFIG_POSTPROC
    628 
    629     if (data)
    630     {
    631         ctx->postproc_cfg_set = 1;
    632         ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data);
    633         return VPX_CODEC_OK;
    634     }
    635     else
    636         return VPX_CODEC_INVALID_PARAM;
    637 
    638 #else
    639     return VPX_CODEC_INCAPABLE;
    640 #endif
    641 }
    642 
    643 
    644 vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] =
    645 {
    646     {VP8_SET_REFERENCE,  vp8_set_reference},
    647     {VP8_COPY_REFERENCE, vp8_get_reference},
    648     {VP8_SET_POSTPROC,   vp8_set_postproc},
    649     { -1, NULL},
    650 };
    651 
    652 
    653 #ifndef VERSION_STRING
    654 #define VERSION_STRING
    655 #endif
    656 vpx_codec_iface_t vpx_codec_vp8_dx_algo =
    657 {
    658     "WebM Project VP8 Decoder" VERSION_STRING,
    659     VPX_CODEC_INTERNAL_ABI_VERSION,
    660     VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC,
    661     /* vpx_codec_caps_t          caps; */
    662     vp8_init,         /* vpx_codec_init_fn_t       init; */
    663     vp8_destroy,      /* vpx_codec_destroy_fn_t    destroy; */
    664     vp8_ctf_maps,     /* vpx_codec_ctrl_fn_map_t  *ctrl_maps; */
    665     vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t   get_mmap; */
    666     vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t   set_mmap; */
    667     {
    668         vp8_peek_si,      /* vpx_codec_peek_si_fn_t    peek_si; */
    669         vp8_get_si,       /* vpx_codec_get_si_fn_t     get_si; */
    670         vp8_decode,       /* vpx_codec_decode_fn_t     decode; */
    671         vp8_get_frame,    /* vpx_codec_frame_get_fn_t  frame_get; */
    672     },
    673     {NOT_IMPLEMENTED} /* encoder functions */
    674 };
    675 
    676 /*
    677  * BEGIN BACKWARDS COMPATIBILITY SHIM.
    678  */
    679 vpx_codec_iface_t vpx_codec_vp8_algo =
    680 {
    681     "WebM Project VP8 Decoder (Deprecated API)" VERSION_STRING,
    682     VPX_CODEC_INTERNAL_ABI_VERSION,
    683     VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC,
    684     /* vpx_codec_caps_t          caps; */
    685     vp8_init,         /* vpx_codec_init_fn_t       init; */
    686     vp8_destroy,      /* vpx_codec_destroy_fn_t    destroy; */
    687     vp8_ctf_maps,     /* vpx_codec_ctrl_fn_map_t  *ctrl_maps; */
    688     vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t   get_mmap; */
    689     vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t   set_mmap; */
    690     {
    691         vp8_peek_si,      /* vpx_codec_peek_si_fn_t    peek_si; */
    692         vp8_get_si,       /* vpx_codec_get_si_fn_t     get_si; */
    693         vp8_decode,       /* vpx_codec_decode_fn_t     decode; */
    694         vp8_get_frame,    /* vpx_codec_frame_get_fn_t  frame_get; */
    695     },
    696     {NOT_IMPLEMENTED} /* encoder functions */
    697 };
    698