Tech-invite3GPPspaceIETFspace
96959493929190898887868584838281807978777675747372717069686766656463626160595857565554535251504948474645444342414039383736353433323130292827262524232221201918171615141312111009080706050403020100
in Index   Prev   Next

RFC 6386

VP8 Data Format and Decoding Guide

Pages: 304
Informational
Errata
Part 9 of 11 – Pages 231 to 263
First   Prev   Next

Top   ToC   RFC6386 - Page 231   prevText

20.15. predict.h

---- Begin code block -------------------------------------- /* * Copyright (c) 2010, 2011, Google Inc. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be * found in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef PREDICT_H #define PREDICT_H void vp8_dixie_predict_init(struct vp8_decoder_ctx *ctx); void vp8_dixie_predict_destroy(struct vp8_decoder_ctx *ctx); void vp8_dixie_predict_process_row(struct vp8_decoder_ctx *ctx, unsigned int row, unsigned int start_col, unsigned int num_cols); void vp8_dixie_release_ref_frame(struct ref_cnt_img *rcimg); struct ref_cnt_img * vp8_dixie_ref_frame(struct ref_cnt_img *rcimg); struct ref_cnt_img * vp8_dixie_find_free_ref_frame(struct ref_cnt_img *frames); #endif ---- End code block ----------------------------------------
Top   ToC   RFC6386 - Page 232

20.16. tokens.c

---- Begin code block -------------------------------------- /* * Copyright (c) 2010, 2011, Google Inc. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be * found in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "vpx_codec_internal.h" #include "dixie.h" #include "tokens.h" #include <stdlib.h> #include <string.h> #include <malloc.h> enum { EOB_CONTEXT_NODE, ZERO_CONTEXT_NODE, ONE_CONTEXT_NODE, LOW_VAL_CONTEXT_NODE, TWO_CONTEXT_NODE, THREE_CONTEXT_NODE, HIGH_LOW_CONTEXT_NODE, CAT_ONE_CONTEXT_NODE, CAT_THREEFOUR_CONTEXT_NODE, CAT_THREE_CONTEXT_NODE, CAT_FIVE_CONTEXT_NODE }; enum { ZERO_TOKEN, ONE_TOKEN, TWO_TOKEN, THREE_TOKEN, FOUR_TOKEN, DCT_VAL_CATEGORY1, DCT_VAL_CATEGORY2, DCT_VAL_CATEGORY3,
Top   ToC   RFC6386 - Page 233
       DCT_VAL_CATEGORY4,
       DCT_VAL_CATEGORY5,
       DCT_VAL_CATEGORY6,
       DCT_EOB_TOKEN,
       MAX_ENTROPY_TOKENS
   };
   struct extrabits
   {
       short         min_val;
       short         length;
       unsigned char probs[12];
   };
   static const unsigned int left_context_index[25] =
   {
       0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
       4, 4, 5, 5, 6, 6, 7, 7, 8
   };
   static const unsigned int above_context_index[25] =
   {
       0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
       4, 5, 4, 5, 6, 7, 6, 7, 8
   };
   #define X(n) ((n) * PREV_COEFF_CONTEXTS * ENTROPY_NODES)
   static const unsigned int bands_x[16] =
   {
       X(0), X(1), X(2), X(3), X(6), X(4), X(5), X(6),
       X(6), X(6), X(6), X(6), X(6), X(6), X(6), X(7)
   };
   #undef X
   static const struct extrabits extrabits[MAX_ENTROPY_TOKENS] =
   {
       { 0, -1, {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //ZERO_TOKEN
       { 1, 0,  {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //ONE_TOKEN
       { 2, 0,  {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //TWO_TOKEN
       { 3, 0,  {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //THREE_TOKEN
       { 4, 0,  {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //FOUR_TOKEN
       { 5, 0,  {159,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //DCT_VAL_CATEGORY1
       { 7, 1,  {145, 165,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //DCT_VAL_CATEGORY2
       {11, 2,  {140, 148, 173,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //DCT_VAL_CATEGORY3
Top   ToC   RFC6386 - Page 234
       {19, 3,  {135, 140, 155, 176,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, //DCT_VAL_CATEGORY4
       {35, 4,  {130, 134, 141, 157, 180,   0,
                   0,   0,   0,   0,   0,   0 } }, //DCT_VAL_CATEGORY5
       {67, 10, {129, 130, 133, 140, 153, 177,
                 196, 230, 243, 254, 254,   0 } }, //DCT_VAL_CATEGORY6
       { 0, -1, {  0,   0,   0,   0,   0,   0,
                   0,   0,   0,   0,   0,   0 } }, // EOB TOKEN
   };

   static const unsigned int zigzag[16] =
   {
       0,  1,  4,  8,  5,  2,  3,  6,  9, 12, 13, 10,  7, 11, 14, 15
   };

   #define DECODE_AND_APPLYSIGN(value_to_sign) \
       v = (bool_get_bit(bool) ? -value_to_sign \
                               : value_to_sign) * dqf[!!c];

   #define DECODE_AND_BRANCH_IF_ZERO(probability,branch) \
       if (!bool_get(bool, probability)) goto branch;

   #define DECODE_AND_LOOP_IF_ZERO(probability,branch) \
       if (!bool_get(bool, probability)) \
       { \
           prob = type_probs; \
           if (c<15) {\
               ++c; \
               prob += bands_x[c]; \
               goto branch; \
           }\
           else \
               goto BLOCK_FINISHED; /* for malformed input */\
       }

   #define DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val) \
       DECODE_AND_APPLYSIGN(val) \
       prob = type_probs + (ENTROPY_NODES*2); \
       if (c < 15){\
           b_tokens[zigzag[c]] = v; \
           ++c; \
           goto DO_WHILE; }\
       b_tokens[zigzag[15]] = v; \
       goto BLOCK_FINISHED;
Top   ToC   RFC6386 - Page 235
   #define DECODE_EXTRABIT_AND_ADJUST_VAL(t,bits_count)\
       val += bool_get(bool, extrabits[t].probs[bits_count]) << \
       bits_count;


   static int
   decode_mb_tokens(struct bool_decoder  *bool,
                    token_entropy_ctx_t   left,
                    token_entropy_ctx_t   above,
                    short                *tokens,
                    enum prediction_mode  mode,
                    coeff_probs_table_t   probs,
                    short                 factor[TOKEN_BLOCK_TYPES][2])
   {
       int            i, stop, type;
       int            c, t, v;
       int            val, bits_count;
       int            eob_mask;
       short         *b_tokens;   // tokens for this block
       unsigned char *type_probs; // probabilities for this block type
       unsigned char *prob;
       short         *dqf;

       eob_mask = 0;

       if (mode != B_PRED && mode != SPLITMV)
       {
           i = 24;
           stop = 24;
           type = 1;
           b_tokens = tokens + 24 * 16;
           dqf = factor[TOKEN_BLOCK_Y2];
       }
       else
       {
           i = 0;
           stop = 16;
           type = 3;
           b_tokens = tokens;
           dqf = factor[TOKEN_BLOCK_Y1];
       }

       /* Save a pointer to the coefficient probs for the current type.
        * Need to repeat this whenever type changes.
        */
       type_probs = probs[type][0][0];
Top   ToC   RFC6386 - Page 236
   BLOCK_LOOP:
       t = left[left_context_index[i]] + above[above_context_index[i]];
       c = !type; /* all blocks start at 0 except type 0, which starts
                   * at 1. */

       prob = type_probs;
       prob += t * ENTROPY_NODES;

   DO_WHILE:
       prob += bands_x[c];
       DECODE_AND_BRANCH_IF_ZERO(prob[EOB_CONTEXT_NODE],
         BLOCK_FINISHED);

   CHECK_0_:
       DECODE_AND_LOOP_IF_ZERO(prob[ZERO_CONTEXT_NODE], CHECK_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[ONE_CONTEXT_NODE],
                                 ONE_CONTEXT_NODE_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[LOW_VAL_CONTEXT_NODE],
                                 LOW_VAL_CONTEXT_NODE_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[HIGH_LOW_CONTEXT_NODE],
                                 HIGH_LOW_CONTEXT_NODE_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[CAT_THREEFOUR_CONTEXT_NODE],
                                 CAT_THREEFOUR_CONTEXT_NODE_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[CAT_FIVE_CONTEXT_NODE],
                                 CAT_FIVE_CONTEXT_NODE_0_);
       val = extrabits[DCT_VAL_CATEGORY6].min_val;
       bits_count = extrabits[DCT_VAL_CATEGORY6].length;

       do
       {
           DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY6,
             bits_count);
           bits_count --;
       }
       while (bits_count >= 0);

       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);

   CAT_FIVE_CONTEXT_NODE_0_:
       val = extrabits[DCT_VAL_CATEGORY5].min_val;
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY5, 4);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY5, 3);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY5, 2);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY5, 1);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY5, 0);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);
Top   ToC   RFC6386 - Page 237
   CAT_THREEFOUR_CONTEXT_NODE_0_:
       DECODE_AND_BRANCH_IF_ZERO(prob[CAT_THREE_CONTEXT_NODE],
                                 CAT_THREE_CONTEXT_NODE_0_);
       val = extrabits[DCT_VAL_CATEGORY4].min_val;
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY4, 3);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY4, 2);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY4, 1);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY4, 0);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);

   CAT_THREE_CONTEXT_NODE_0_:
       val = extrabits[DCT_VAL_CATEGORY3].min_val;
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY3, 2);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY3, 1);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY3, 0);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);

   HIGH_LOW_CONTEXT_NODE_0_:
       DECODE_AND_BRANCH_IF_ZERO(prob[CAT_ONE_CONTEXT_NODE],
                                 CAT_ONE_CONTEXT_NODE_0_);

       val = extrabits[DCT_VAL_CATEGORY2].min_val;
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY2, 1);
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY2, 0);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);

   CAT_ONE_CONTEXT_NODE_0_:
       val = extrabits[DCT_VAL_CATEGORY1].min_val;
       DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY1, 0);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val);

   LOW_VAL_CONTEXT_NODE_0_:
       DECODE_AND_BRANCH_IF_ZERO(prob[TWO_CONTEXT_NODE],
                                 TWO_CONTEXT_NODE_0_);
       DECODE_AND_BRANCH_IF_ZERO(prob[THREE_CONTEXT_NODE],
                                 THREE_CONTEXT_NODE_0_);
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(4);

   THREE_CONTEXT_NODE_0_:
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(3);

   TWO_CONTEXT_NODE_0_:
       DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(2);

   ONE_CONTEXT_NODE_0_:
       DECODE_AND_APPLYSIGN(1);
       prob = type_probs + ENTROPY_NODES;
Top   ToC   RFC6386 - Page 238
       if (c < 15)
       {
           b_tokens[zigzag[c]] = v;
           ++c;
           goto DO_WHILE;
       }

       b_tokens[zigzag[15]] = v;
   BLOCK_FINISHED:
       eob_mask |= (c > 1) << i;
       t = (c != !type);   // any non-zero data?
       eob_mask |= t << 31;

       left[left_context_index[i]] = above[above_context_index[i]] = t;
       b_tokens += 16;

       i++;

       if (i < stop)
           goto BLOCK_LOOP;

       if (i == 25)
       {
           type = 0;
           i = 0;
           stop = 16;
           type_probs = probs[type][0][0];
           b_tokens = tokens;
           dqf = factor[TOKEN_BLOCK_Y1];
           goto BLOCK_LOOP;
       }

       if (i == 16)
       {
           type = 2;
           type_probs = probs[type][0][0];
           stop = 24;
           dqf = factor[TOKEN_BLOCK_UV];
           goto BLOCK_LOOP;
       }

       return eob_mask;
   }
Top   ToC   RFC6386 - Page 239
   static void
   reset_row_context(token_entropy_ctx_t *left)
   {
       memset(left, 0, sizeof(*left));
   }


   static void
   reset_above_context(token_entropy_ctx_t *above, unsigned int cols)
   {
       memset(above, 0, cols * sizeof(*above));
   }


   static void
   reset_mb_context(token_entropy_ctx_t  *left,
                    token_entropy_ctx_t  *above,
                    enum prediction_mode  mode)
   {
       /* Reset the macroblock context on the left and right.  We have
        * to preserve the context of the second order block if this mode
        * would not have updated it.
        */
       memset(left, 0, sizeof((*left)[0]) * 8);
       memset(above, 0, sizeof((*above)[0]) * 8);

       if (mode != B_PRED && mode != SPLITMV)
       {
           (*left)[8] = 0;
           (*above)[8] = 0;
       }
   }


   void
   vp8_dixie_tokens_process_row(struct vp8_decoder_ctx *ctx,
                                unsigned int            partition,
                                unsigned int            row,
                                unsigned int            start_col,
                                unsigned int            num_cols)
   {
       struct token_decoder *tokens = &ctx->tokens[partition];
       short              coeffs = tokens->coeffs + 25 * 16 * start_col;
       unsigned int       col;
       token_entropy_ctx_t  *above = ctx->above_token_entropy_ctx
                                     + start_col;
       token_entropy_ctx_t  *left = &tokens->left_token_entropy_ctx;
       struct mb_info       *mbi = ctx->mb_info_rows[row] + start_col;
Top   ToC   RFC6386 - Page 240
       if (row == 0)
           reset_above_context(above, num_cols);

       if (start_col == 0)
           reset_row_context(left);

       for (col = start_col; col < start_col + num_cols; col++)
       {
           memset(coeffs, 0, 25 * 16 * sizeof(short));

           if (mbi->base.skip_coeff)
           {
               reset_mb_context(left, above, mbi->base.y_mode);
               mbi->base.eob_mask = 0;
           }
           else
           {
               struct dequant_factors *dqf;

               dqf = ctx->dequant_factors  + mbi->base.segment_id;
               mbi->base.eob_mask =
                   decode_mb_tokens(&tokens->bool,
                                    *left, *above,
                                    coeffs,
                                    mbi->base.y_mode,
                                    ctx->entropy_hdr.coeff_probs,
                                    dqf->factor);
           }

           above++;
           mbi++;
           coeffs += 25 * 16;
       }
   }


   void
   vp8_dixie_tokens_init(struct vp8_decoder_ctx *ctx)
   {
       unsigned int  partitions = ctx->token_hdr.partitions;

       if (ctx->frame_hdr.frame_size_updated)
       {
           unsigned int i;
           unsigned int coeff_row_sz =
               ctx->mb_cols * 25 * 16 * sizeof(short);
Top   ToC   RFC6386 - Page 241
           for (i = 0; i < partitions; i++)
           {
               free(ctx->tokens[i].coeffs);
               ctx->tokens[i].coeffs = memalign(16, coeff_row_sz);

               if (!ctx->tokens[i].coeffs)
                   vpx_internal_error(&ctx->error, VPX_CODEC_MEM_ERROR,
                                      NULL);
           }

           free(ctx->above_token_entropy_ctx);
           ctx->above_token_entropy_ctx =
               calloc(ctx->mb_cols,
               sizeof(*ctx->above_token_entropy_ctx));

           if (!ctx->above_token_entropy_ctx)
               vpx_internal_error(&ctx->error,
               VPX_CODEC_MEM_ERROR, NULL);
       }
   }


   void
   vp8_dixie_tokens_destroy(struct vp8_decoder_ctx *ctx)
   {
       int i;

       for (i = 0; i < MAX_PARTITIONS; i++)
           free(ctx->tokens[i].coeffs);

       free(ctx->above_token_entropy_ctx);
   }

   ---- End code block ----------------------------------------
Top   ToC   RFC6386 - Page 242

20.17. tokens.h

---- Begin code block -------------------------------------- /* * Copyright (c) 2010, 2011, Google Inc. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be * found in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef TOKENS_H #define TOKENS_H void vp8_dixie_tokens_init(struct vp8_decoder_ctx *ctx); void vp8_dixie_tokens_destroy(struct vp8_decoder_ctx *ctx); void vp8_dixie_tokens_process_row(struct vp8_decoder_ctx *ctx, unsigned int partition, unsigned int row, unsigned int start_col, unsigned int num_cols); #endif ---- End code block ----------------------------------------
Top   ToC   RFC6386 - Page 243

20.18. vp8_prob_data.h

---- Begin code block -------------------------------------- /* * Copyright (c) 2010, 2011, Google Inc. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be * found in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ static const unsigned char k_coeff_entropy_update_probs[BLOCK_TYPES][COEFF_BANDS] [PREV_COEFF_CONTEXTS] [ENTROPY_NODES] = { { { {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, }, { {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255}, {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, }, { {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255}, {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, }, { {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255}, {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, }, { {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255}, {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, },
Top   ToC   RFC6386 - Page 244
           {
               {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255},
               {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255},
               {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
       },
       {
           {
               {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255},
               {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255},
           },
           {
               {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
Top   ToC   RFC6386 - Page 245
           {
               {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
       },
       {
           {
               {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255},
               {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255},
               {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255},
           },
           {
               {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
Top   ToC   RFC6386 - Page 246
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
       },
       {
           {
               {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255},
               {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255},
               {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
           },
           {
               {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255},
               {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
Top   ToC   RFC6386 - Page 247
           {
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
               {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
           },
       },
   };


   static const
   unsigned char k_default_y_mode_probs        [] =
   { 112,  86, 140,  37};


   static const
   unsigned char k_default_uv_mode_probs       [] =
   { 162, 101, 204};


   static const
   unsigned char k_default_coeff_probs [BLOCK_TYPES][COEFF_BANDS]
   [PREV_COEFF_CONTEXTS][ENTROPY_NODES] =
   {
       { /* block type 0 */
           { /* coeff band 0 */
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
           },
           { /* coeff band 1 */
               { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128},
               { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128},
               { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128}
           },
           { /* coeff band 2 */
               {   1,  98, 248, 255, 236, 226, 255, 255, 128, 128, 128},
               { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128},
               {  78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128}
           },
           { /* coeff band 3 */
               {   1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128},
               { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128},
               {  77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128}
           },
Top   ToC   RFC6386 - Page 248
           { /* coeff band 4 */
               {   1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128},
               { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128},
               {  37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128}
           },
           { /* coeff band 5 */
               {   1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128},
               { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128},
               { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128}
           },
           { /* coeff band 6 */
               {   1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128},
               { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128},
               {  80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128}
           },
           { /* coeff band 7 */
               {   1,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 246,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
           }
       },
       { /* block type 1 */
           { /* coeff band 0 */
               { 198,  35, 237, 223, 193, 187, 162, 160, 145, 155,  62},
               { 131,  45, 198, 221, 172, 176, 220, 157, 252, 221,   1},
               {  68,  47, 146, 208, 149, 167, 221, 162, 255, 223, 128}
           },
           { /* coeff band 1 */
               {   1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128},
               { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128},
               {  81,  99, 181, 242, 176, 190, 249, 202, 255, 255, 128}
           },
           { /* coeff band 2 */
               {   1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128},
               {  99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128},
               {  23,  91, 163, 242, 170, 187, 247, 210, 255, 255, 128}
           },
           { /* coeff band 3 */
               {   1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128},
               { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128},
               {  44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128}
           },
           { /* coeff band 4 */
               {   1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128},
               {  94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128},
               {  22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128}
           },
Top   ToC   RFC6386 - Page 249
           { /* coeff band 5 */
               {   1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128},
               { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128},
               {  35,  77, 181, 251, 193, 211, 255, 205, 128, 128, 128}
           },
           { /* coeff band 6 */
               {   1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128},
               { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128},
               {  45,  99, 188, 251, 195, 217, 255, 224, 128, 128, 128}
           },
           { /* coeff band 7 */
               {   1,   1, 251, 255, 213, 255, 128, 128, 128, 128, 128},
               { 203,   1, 248, 255, 255, 128, 128, 128, 128, 128, 128},
               { 137,   1, 177, 255, 224, 255, 128, 128, 128, 128, 128}
           }
       },
       { /* block type 2 */
           { /* coeff band 0 */
               { 253,   9, 248, 251, 207, 208, 255, 192, 128, 128, 128},
               { 175,  13, 224, 243, 193, 185, 249, 198, 255, 255, 128},
               {  73,  17, 171, 221, 161, 179, 236, 167, 255, 234, 128}
           },
           { /* coeff band 1 */
               {   1,  95, 247, 253, 212, 183, 255, 255, 128, 128, 128},
               { 239,  90, 244, 250, 211, 209, 255, 255, 128, 128, 128},
               { 155,  77, 195, 248, 188, 195, 255, 255, 128, 128, 128}
           },
           { /* coeff band 2 */
               {   1,  24, 239, 251, 218, 219, 255, 205, 128, 128, 128},
               { 201,  51, 219, 255, 196, 186, 128, 128, 128, 128, 128},
               {  69,  46, 190, 239, 201, 218, 255, 228, 128, 128, 128}
           },
           { /* coeff band 3 */
               {   1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128},
               { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128},
               { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128}
           },
           { /* coeff band 4 */
               {   1,  16, 248, 255, 255, 128, 128, 128, 128, 128, 128},
               { 190,  36, 230, 255, 236, 255, 128, 128, 128, 128, 128},
               { 149,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128}
           },
           { /* coeff band 5 */
               {   1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128}
           },
Top   ToC   RFC6386 - Page 250
           { /* coeff band 6 */
               {   1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128},
               { 213,  62, 250, 255, 255, 128, 128, 128, 128, 128, 128},
               {  55,  93, 255, 128, 128, 128, 128, 128, 128, 128, 128}
           },
           { /* coeff band 7 */
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
               { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
           }
       },
       { /* block type 3 */
           { /* coeff band 0 */
               { 202,  24, 213, 235, 186, 191, 220, 160, 240, 175, 255},
               { 126,  38, 182, 232, 169, 184, 228, 174, 255, 187, 128},
               {  61,  46, 138, 219, 151, 178, 240, 170, 255, 216, 128}
           },
           { /* coeff band 1 */
               {   1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128},
               { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128},
               {  39,  77, 162, 232, 172, 180, 245, 178, 255, 255, 128}
           },
           { /* coeff band 2 */
               {   1,  52, 220, 246, 198, 199, 249, 220, 255, 255, 128},
               { 124,  74, 191, 243, 183, 193, 250, 221, 255, 255, 128},
               {  24,  71, 130, 219, 154, 170, 243, 182, 255, 255, 128}
           },
           { /* coeff band 3 */
               {   1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128},
               { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128},
               {  28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128}
           },
           { /* coeff band 4 */
               {   1,  81, 230, 252, 204, 203, 255, 192, 128, 128, 128},
               { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128},
               {  20,  95, 153, 243, 164, 173, 255, 203, 128, 128, 128}
           },
           { /* coeff band 5 */
               {   1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128},
               { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128},
               {  47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128}
           },
           { /* coeff band 6 */
               {   1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128},
               { 141,  84, 213, 252, 201, 202, 255, 219, 128, 128, 128},
               {  42,  80, 160, 240, 162, 185, 255, 205, 128, 128, 128}
           },
Top   ToC   RFC6386 - Page 251
           { /* coeff band 7 */
               {   1,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 244,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
               { 238,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128}
           }
       }
   };


   static const
   unsigned char k_mv_entropy_update_probs[2][MV_PROB_CNT] =
   {
       {
           237,
           246,
           253, 253, 254, 254, 254, 254, 254,
           254, 254, 254, 254, 254, 250, 250, 252, 254, 254
       },
       {
           231,
           243,
           245, 253, 254, 254, 254, 254, 254,
           254, 254, 254, 254, 254, 251, 251, 254, 254, 254
       }
   };


   static const
   unsigned char k_default_mv_probs[2][MV_PROB_CNT] =
   {
       {                                                  // row
           162,                                           // is short
           128,                                           // sign
           225, 146, 172, 147, 214,  39, 156,             // short tree
           128, 129, 132,  75, 145, 178, 206, 239, 254, 254 // long bits
       },
       {
           164,
           128,
           204, 170, 119, 235, 140, 230, 228,
           128, 130, 130,  74, 148, 180, 203, 236, 254, 254

       }
   };

   ---- End code block ----------------------------------------
Top   ToC   RFC6386 - Page 252

20.19. vpx_codec_internal.h

---- Begin code block -------------------------------------- /* * Copyright (c) 2010, 2011, Google Inc. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be * found in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ /*!\file vpx_codec_internal.h * \brief Describes the decoder algorithm interface for algorithm * implementations. * * This file defines the private structures and data types that are * only relevant to implementing an algorithm, as opposed to using * it. * * To create a decoder algorithm class, an interface structure is put * into the global namespace: * <pre> * my_codec.c: * vpx_codec_iface_t my_codec = { * "My Codec v1.0", * VPX_CODEC_ALG_ABI_VERSION, * ... * }; * </pre> * * An application instantiates a specific decoder instance by using * vpx_codec_init() and a pointer to the algorithm's interface * structure: * <pre> * my_app.c: * extern vpx_codec_iface_t my_codec; * { * vpx_codec_ctx_t algo; * res = vpx_codec_init(&algo, &my_codec); * } * </pre> *
Top   ToC   RFC6386 - Page 253
    * Once initialized, the instance is managed using other functions
    * from the vpx_codec_* family.
    */
   #ifndef VPX_CODEC_INTERNAL_H
   #define VPX_CODEC_INTERNAL_H
   #include "vpx_decoder.h"
   #include <stdarg.h>


   /*!\brief Current ABI version number
    *
    * \internal
    * If this file is altered in any way that changes the Application
    * Binary Interface (ABI), this value must be bumped.  Examples
    * include, but are not limited to, changing types, removing or
    * reassigning enums, adding/removing/rearranging fields to
    * structures.
    */
   #define VPX_CODEC_INTERNAL_ABI_VERSION (3)

   typedef struct vpx_codec_alg_priv  vpx_codec_alg_priv_t;

   /*!\brief init function pointer prototype
    *
    * Performs algorithm-specific initialization of the decoder context.
    * This function is called by the generic vpx_codec_init() wrapper
    * function, so plugins implementing this interface may trust the
    * input parameters to be properly initialized.
    *
    * \param[in] ctx   Pointer to this instance's context
    * \retval #VPX_CODEC_OK
    *     The input stream was recognized and decoder initialized.
    * \retval #VPX_CODEC_MEM_ERROR
    *     Memory operation failed.
    */
   typedef vpx_codec_err_t (*vpx_codec_init_fn_t)(vpx_codec_ctx_t *ctx);
Top   ToC   RFC6386 - Page 254
   /*!\brief destroy function pointer prototype
    *
    * Performs algorithm-specific destruction of the decoder context.
    * This function is called by the generic vpx_codec_destroy() wrapper
    * function, so plugins implementing this interface may trust the
    * input parameters to be properly initialized.
    *
    * \param[in] ctx   Pointer to this instance's context
    * \retval #VPX_CODEC_OK
    *     The input stream was recognized and decoder initialized.
    * \retval #VPX_CODEC_MEM_ERROR
    *     Memory operation failed.
    */
   typedef vpx_codec_err_t (*vpx_codec_destroy_fn_t)(
       vpx_codec_alg_priv_t *ctx);

   /*!\brief parse stream info function pointer prototype
    *
    * Performs high level parsing of the bitstream.  This function is
    * called by the generic vpx_codec_parse_stream() wrapper function,
    * so plugins implementing this interface may trust the input
    * parameters to be properly initialized.
    *
    * \param[in]      data    Pointer to a block of data to parse
    * \param[in]      data_sz Size of the data buffer
    * \param[in,out]  si      Pointer to stream info to update.  The
    *                         size member \ref MUST be properly
    *                         initialized, but \ref MAY be clobbered by
    *                         the algorithm.  This parameter \ref MAY
    *                         be NULL.
    *
    * \retval #VPX_CODEC_OK
    *     Bitstream is parsable and stream information updated
    */
   typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(
       const uint8_t         *data,
       unsigned int           data_sz,
       vpx_codec_stream_info_t *si);
Top   ToC   RFC6386 - Page 255
   /*!\brief Return information about the current stream.
    *
    * Returns information about the stream that has been parsed during
    * decoding.
    *
    * \param[in]      ctx     Pointer to this instance's context
    * \param[in,out]  si      Pointer to stream info to update.  The
    *                         size member \ref MUST be properly
    *                         initialized, but \ref MAY be clobbered by
    *                         the algorithm.  This parameter \ref MAY
    *                         be NULL.
    *
    * \retval #VPX_CODEC_OK
    *     Bitstream is parsable and stream information updated
    */
   typedef vpx_codec_err_t (*vpx_codec_get_si_fn_t)(
       vpx_codec_alg_priv_t    *ctx,
       vpx_codec_stream_info_t *si);

   /*!\brief control function pointer prototype
    *
    * This function is used to exchange algorithm-specific data with the
    * decoder instance.  This can be used to implement features specific
    * to a particular algorithm.
    *
    * This function is called by the generic vpx_codec_control() wrapper
    * function, so plugins implementing this interface may trust the
    * input parameters to be properly initialized.  However, this
    * interface does not provide type safety for the exchanged data or
    * assign meanings to the control codes.  Those details should be
    * specified in the algorithm's header file.  In particular, the
    * ctrl_id parameter is guaranteed to exist in the algorithm's
    * control mapping table, and the data parameter may be NULL.
    *
    *
    * \param[in]     ctx       Pointer to this instance's context
    * \param[in]     ctrl_id   Algorithm-specific control identifier
    * \param[in,out] data      Data to exchange with algorithm instance.
    *
    * \retval #VPX_CODEC_OK
    *     The internal state data was deserialized.
    */
   typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(
       vpx_codec_alg_priv_t  *ctx,
       int                   ctrl_id,
       va_list               ap);
Top   ToC   RFC6386 - Page 256
   /*!\brief control function pointer mapping
    *
    * This structure stores the mapping between control identifiers and
    * implementing functions.  Each algorithm provides a list of these
    * mappings.  This list is searched by the vpx_codec_control()
    * wrapper function to determine which function to invoke.  The
    * special value {0, NULL} is used to indicate end-of-list, and must
    * be present.  The special value {0, <non-null>} can be used as a
    * catch-all mapping.  This implies that ctrl_id values chosen by the
    * algorithm \ref MUST be non-zero.
    */
   typedef const struct
   {
       int                    ctrl_id;
       vpx_codec_control_fn_t   fn;
   } vpx_codec_ctrl_fn_map_t;

   /*!\brief decode data function pointer prototype
    *
    * Processes a buffer of coded data.  If the processing results in a
    * new decoded frame becoming available, #VPX_CODEC_CB_PUT_SLICE and
    * #VPX_CODEC_CB_PUT_FRAME events are generated as appropriate.
    * This function is called by the generic vpx_codec_decode() wrapper
    * function, so plugins implementing this interface may trust the
    * input parameters to be properly initialized.
    *
    * \param[in] ctx         Pointer to this instance's context
    * \param[in] data        Pointer to this block of new coded data.
    *                        If NULL, a #VPX_CODEC_CB_PUT_FRAME event is
    *                        posted for the previously decoded frame.
    * \param[in] data_sz     Size of the coded data, in bytes.
    *
    * \return Returns #VPX_CODEC_OK if the coded data was processed
    *         completely and future pictures can be decoded without
    *         error.  Otherwise, see the descriptions of the other error
    *         codes in ::vpx_codec_err_t for recoverability
    *         capabilities.
    */
   typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(
       vpx_codec_alg_priv_t  *ctx,
       const uint8_t         *data,
       unsigned int     data_sz,
       void        *user_priv,
       long         deadline);
Top   ToC   RFC6386 - Page 257
   /*!\brief Decoded frames iterator
    *
    * Iterates over a list of the frames available for display.  The
    * iterator storage should be initialized to NULL to start the
    * iteration.  Iteration is complete when this function returns NULL.
    *
    * The list of available frames becomes valid upon completion of the
    * vpx_codec_decode call, and remains valid until the next call to
    * vpx_codec_decode.
    *
    * \param[in]     ctx      Pointer to this instance's context
    * \param[in out] iter     Iterator storage, initialized to NULL
    *
    * \return Returns a pointer to an image, if one is ready for
    *         display.  Frames produced will always be in PTS
    *         (presentation time stamp) order.
    */
   typedef vpx_image_t*(*vpx_codec_get_frame_fn_t)(
       vpx_codec_alg_priv_t *ctx,
       vpx_codec_iter_t     *iter);

   /*\brief External Memory Allocation memory map get iterator
    *
    * Iterates over a list of the memory maps requested by the decoder.
    * The iterator storage should be initialized to NULL to start the
    * iteration.  Iteration is complete when this function returns NULL.
    *
    * \param[in out] iter     Iterator storage, initialized to NULL
    *
    * \return Returns a pointer to a memory segment descriptor, or NULL
    *         to indicate end-of-list.
    */
   typedef vpx_codec_err_t (*vpx_codec_get_mmap_fn_t)(
       const vpx_codec_ctx_t      *ctx,
       vpx_codec_mmap_t           *mmap,
       vpx_codec_iter_t           *iter);
Top   ToC   RFC6386 - Page 258
   /*\brief External Memory Allocation memory map set iterator
    *
    * Sets a memory descriptor inside the decoder instance.
    *
    * \param[in] ctx      Pointer to this instance's context
    * \param[in] mmap     Memory map to store.
    *
    * \retval #VPX_CODEC_OK
    *     The memory map was accepted and stored.
    * \retval #VPX_CODEC_MEM_ERROR
    *     The memory map was rejected.
    */
   typedef vpx_codec_err_t (*vpx_codec_set_mmap_fn_t)(
       vpx_codec_ctx_t         *ctx,
       const vpx_codec_mmap_t  *mmap);


   typedef vpx_codec_err_t (*vpx_codec_encode_fn_t)(
       vpx_codec_alg_priv_t  *ctx,
       const vpx_image_t     *img,
       vpx_codec_pts_t        pts,
       unsigned long          duration,
       vpx_enc_frame_flags_t  flags,
       unsigned long          deadline);
   typedef const vpx_codec_cx_pkt_t*(*vpx_codec_get_cx_data_fn_t)(
       vpx_codec_alg_priv_t *ctx,
       vpx_codec_iter_t     *iter);

   typedef vpx_codec_err_t
   (*vpx_codec_enc_config_set_fn_t)(
       vpx_codec_alg_priv_t       *ctx,
       const vpx_codec_enc_cfg_t  *cfg);
   typedef vpx_fixed_buf_t *
   (*vpx_codec_get_global_headers_fn_t)(vpx_codec_alg_priv_t   *ctx);

   typedef vpx_image_t *
   (*vpx_codec_get_preview_frame_fn_t)(vpx_codec_alg_priv_t   *ctx);

   /*!\brief usage configuration mapping
    *
    * This structure stores the mapping between usage identifiers and
    * configuration structures.  Each algorithm provides a list of these
    * mappings.  This list is searched by the
    * vpx_codec_enc_config_default() wrapper function to determine which
Top   ToC   RFC6386 - Page 259
    * config to return.  The special value {-1, {0}} is used to indicate
    * end-of-list, and must be present.  At least one mapping must be
    * present, in addition to the end-of-list.
    *
    */
   typedef const struct
   {
       int                 usage;
       vpx_codec_enc_cfg_t cfg;
   } vpx_codec_enc_cfg_map_t;

   #define NOT_IMPLEMENTED 0

   /*!\brief Decoder algorithm interface
    *
    * All decoders \ref MUST expose a variable of this type.
    */
   struct vpx_codec_iface
   {
       const char               *name;
       int                       abi_version;
       vpx_codec_caps_t          caps;
       vpx_codec_init_fn_t       init;
       vpx_codec_destroy_fn_t    destroy;
       vpx_codec_ctrl_fn_map_t  *ctrl_maps;
       vpx_codec_get_mmap_fn_t   get_mmap;
       vpx_codec_set_mmap_fn_t   set_mmap;
       struct
       {
           vpx_codec_peek_si_fn_t    peek_si;
           vpx_codec_get_si_fn_t     get_si;
           vpx_codec_decode_fn_t     decode;
           vpx_codec_get_frame_fn_t  get_frame;
       } dec;
       struct
       {
           vpx_codec_enc_cfg_map_t           *cfg_maps;
           vpx_codec_encode_fn_t              encode;
           vpx_codec_get_cx_data_fn_t         get_cx_data;
           vpx_codec_enc_config_set_fn_t      cfg_set;
           vpx_codec_get_global_headers_fn_t  get_glob_hdrs;
           vpx_codec_get_preview_frame_fn_t   get_preview;
       } enc;
   };
Top   ToC   RFC6386 - Page 260
   /*!\brief Callback function pointer / user data pair storage */
   typedef struct vpx_codec_priv_cb_pair
   {
       union
       {
           vpx_codec_put_frame_cb_fn_t    put_frame;
           vpx_codec_put_slice_cb_fn_t    put_slice;
       };
       void                            *user_priv;
   } vpx_codec_priv_cb_pair_t;


   /*!\brief Instance private storage
    *
    * This structure is allocated by the algorithm's init function.  It
    * can be extended in one of two ways.  First, a second, algorithm
    * specific structure can be allocated and the priv member pointed to
    * it.  Alternatively, this structure can be made the first member of
    * the algorithm-specific structure, and the pointer casted to the
    * proper type.
    */
   struct vpx_codec_priv
   {
       unsigned int                    sz;
       vpx_codec_iface_t              *iface;
       struct vpx_codec_alg_priv      *alg_priv;
       const char                     *err_detail;
       vpx_codec_flags_t               init_flags;
       struct
       {
           vpx_codec_priv_cb_pair_t    put_frame_cb;
           vpx_codec_priv_cb_pair_t    put_slice_cb;
       } dec;
       struct
       {
           struct vpx_fixed_buf        cx_data_dst_buf;
           unsigned int                cx_data_pad_before;
           unsigned int                cx_data_pad_after;
           vpx_codec_cx_pkt_t          cx_data_pkt;
       } enc;
   };

   #undef VPX_CTRL_USE_TYPE
   #define VPX_CTRL_USE_TYPE(id, typ) \
       static typ id##__value(va_list args) \
       {return va_arg(args, typ);} \
       static typ id##__convert(void *x)\
       {\
Top   ToC   RFC6386 - Page 261
           union\
           {\
               void *x;\
               typ   d;\
           } u;\
           u.x = x;\
           return u.d;\
       }


   #undef VPX_CTRL_USE_TYPE_DEPRECATED
   #define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
       static typ id##__value(va_list args) \
       {return va_arg(args, typ);} \
       static typ id##__convert(void *x)\
       {\
           union\
           {\
               void *x;\
               typ   d;\
           } u;\
           u.x = x;\
           return u.d;\
       }

   #define CAST(id, arg) id##__value(arg)
   #define RECAST(id, x) id##__convert(x)


   /* Internal Utility Functions
    *
    * The following functions are intended to be used inside algorithms
    * as utilities for manipulating vpx_codec_* data structures.
    */
   struct vpx_codec_pkt_list
   {
       unsigned int            cnt;
       unsigned int            max;
       struct vpx_codec_cx_pkt pkts[1];
   };

   #define vpx_codec_pkt_list_decl(n)\
       union {struct vpx_codec_pkt_list head;\
           struct {struct vpx_codec_pkt_list head;\
               struct vpx_codec_cx_pkt    pkts[n];} alloc;}
Top   ToC   RFC6386 - Page 262
   #define vpx_codec_pkt_list_init(m)\
       (m)->alloc.head.cnt = 0,\
       (m)->alloc.head.max = \
       sizeof((m)->alloc.pkts) / sizeof((m)->alloc.pkts[0])

   int
   vpx_codec_pkt_list_add(struct vpx_codec_pkt_list *,
                          const struct vpx_codec_cx_pkt *);

   const vpx_codec_cx_pkt_t*
   vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list,
                          vpx_codec_iter_t           *iter);


   #include <stdio.h>
   #include <setjmp.h>
   struct vpx_internal_error_info
   {
       vpx_codec_err_t  error_code;
       int              has_detail;
       char             detail[80];
       int              setjmp;
       jmp_buf          jmp;
   };

   static void vpx_internal_error(struct vpx_internal_error_info *info,
                                  vpx_codec_err_t                 error,
                                  const char                     *fmt,
                                  ...)
   {
       va_list ap;

       info->error_code = error;
       info->has_detail = 0;

       if (fmt)
       {
           size_t  sz = sizeof(info->detail);

           info->has_detail = 1;
           va_start(ap, fmt);
           vsnprintf(info->detail, sz - 1, fmt, ap);
           va_end(ap);
           info->detail[sz-1] = '\0';
       }
Top   ToC   RFC6386 - Page 263
       if (info->setjmp)
           longjmp(info->jmp, info->error_code);
   }
   #endif

   ---- End code block ----------------------------------------



(page 263 continued on part 10)

Next Section