[PORT FROM MAIN] Enable HW VP8 decoder for merrifield VP [MRFLD-VIDEO]
BZ: 66073
Enable HW VP8 decoder for merrifield VP
Change-Id: I91ce7f1eaa65b4014c38ee794f7a3ad22925b85e
Signed-off-by: Tianmi Chen <tianmi.chen@intel.com>
Reviewed-on: http://android.intel.com:8080/76396
Tested-by: Tong, BoX <box.tong@intel.com>
Reviewed-by: Tong, BoX <box.tong@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/mix_vbp/Android.mk b/mix_vbp/Android.mk
index 42082ef..3899789 100644
--- a/mix_vbp/Android.mk
+++ b/mix_vbp/Android.mk
@@ -7,3 +7,12 @@
include $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/h264/parser/Android.mk
include $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/mp4/parser/Android.mk
include $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/vc1/parser/Android.mk
+
+# Add source codes for Merrifield
+MERRIFIELD_PRODUCT := \
+ mrfl_vp \
+ mrfl_hvp \
+ mrfl_sle
+ifneq ($(filter $(TARGET_PRODUCT),$(MERRIFIELD_PRODUCT)),)
+include $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/vp8/parser/Android.mk
+endif
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/include/bool_coder.h b/mix_vbp/viddec_fw/fw/codecs/vp8/include/bool_coder.h
new file mode 100644
index 0000000..57660b7
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/include/bool_coder.h
@@ -0,0 +1,54 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#ifndef _BOOL_CODER_H_
+#define _BOOL_CODER_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+typedef struct _BOOL_CODER
+{
+ uint32_t range; // always idential to encoder's range
+ uint32_t value; // contains at least 24 significant bits
+ int32_t count; // # of bits shifted out of value, at most 7
+ uint32_t pos;
+ uint8_t *buffer; // pointer to next compressed data byte to be read
+} BOOL_CODER;
+
+typedef struct _BITREADER
+{
+ int32_t bitsinremainder; // # of bits still used in remainder
+ uint32_t remainder; // remaining bits from original long
+ const uint8_t *position; // character pointer position within data
+} BITREADER;
+
+void vp8_start_decode(BOOL_CODER *br, uint8_t *source);
+int32_t vp8_decode_bool(BOOL_CODER *br, int32_t probability);
+uint32_t vp8_read_bits(BOOL_CODER *br, int32_t bits);
+
+#endif
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8.h b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8.h
new file mode 100644
index 0000000..06a7e61
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8.h
@@ -0,0 +1,356 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#ifndef _VP8_H_
+#define _VP8_H_
+#include "bool_coder.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* VP8 specifies only frame is supported */
+#define VP8_MAX_NUM_PICTURES 1
+/* VP8 has no definition of slice */
+#define VP8_MAX_NUM_SLICES 1
+
+#define MAX_MB_SEGMENTS 4
+#define MB_FEATURE_TREE_PROBS 3
+#define MAX_REF_LF_DELTAS 4
+#define MAX_MODE_LF_DELTAS 4
+#define MAX_PARTITIONS 9
+#define BLOCK_TYPES 4
+#define COEF_BANDS 8
+#define PREV_COEF_CONTEXTS 3
+#define MAX_COEF_TOKENS 12
+#define MAX_ENTROPY_TOKENS 12
+#define SEGMENT_DELTADATA 0
+#define SEGMENT_ABSDATA 1
+#define MAX_LOOP_FILTER 63
+#define MAX_QINDEX 127
+
+ typedef uint8_t vp8_prob;
+
+ typedef enum
+ {
+ /*!\brief Operation completed without error */
+ VP8_NO_ERROR,
+
+ /*!\brief Unspecified error */
+ VP8_UNKNOWN_ERROR,
+
+ /*!\brief Memory operation failed */
+ VP8_MEMORY_ERROR,
+
+ VP8_NO_INITIALIZATION,
+
+ VP8_CORRUPT_FRAME,
+
+ VP8_UNSUPPORTED_BITSTREAM,
+
+ VP8_UNSUPPORTED_VERSION,
+
+ VP8_INVALID_FRAME_SYNC_CODE,
+
+ VP8_UNEXPECTED_END_OF_BITSTREAM,
+
+ } vp8_Status;
+
+ enum
+ {
+ VP8_MV_max = 1023, /* max absolute value of a MV component */
+ VP8_MV_vals = (2 * VP8_MV_max) + 1, /* # possible values "" */
+
+ VP8_MV_long_width = 10, /* Large MVs have 9 bit magnitudes */
+ VP8_MV_num_short = 8, /* magnitudes 0 through 7 */
+
+ /* probability offsets for coding each MV component */
+ VP8_MV_pis_short = 0, /* short (<= 7) vs long (>= 8) */
+ VP8_MV_Psign, /* sign for non-zero */
+ VP8_MV_Pshort, /* 8 short values = 7-position tree */
+
+ VP8_MV_Pbits = VP8_MV_Pshort + VP8_MV_num_short - 1, /* mvlong_width long value bits */
+ VP8_MV_Pcount = VP8_MV_Pbits + VP8_MV_long_width /* (with independent probabilities) */
+ };
+
+ typedef enum
+ {
+ DC_PRED, // average of above and left pixels
+ V_PRED, // vertical prediction
+ H_PRED, // horizontal prediction
+ TM_PRED, // Truemotion prediction
+ B_PRED, // block based prediction, each block has its own prediction mode
+ NEARESTMV,
+ NEARMV,
+ ZEROMV,
+ NEWMV,
+ SPLITMV,
+ MB_MODE_COUNT
+ } VP8_MB_PREDICTION_MODE;
+
+// Segment Feature Masks
+#define VP8_SEGMENT_ALTQ 0x01
+#define VP8_SEGMENT_ALT_LF 0x02
+
+#define VP8_YMODES (B_PRED + 1)
+#define VP8_UV_MODES (TM_PRED + 1)
+
+#define VP8_MVREFS (1 + SPLITMV - NEARESTMV)
+
+ typedef enum
+ {
+ B_DC_PRED, // average of above and left pixels
+ B_TM_PRED,
+
+ B_VE_PRED, // vertical prediction
+ B_HE_PRED, // horizontal prediction
+
+ B_LD_PRED,
+ B_RD_PRED,
+
+ B_VR_PRED,
+ B_VL_PRED,
+ B_HD_PRED,
+ B_HU_PRED,
+
+ LEFT4X4,
+ ABOVE4X4,
+ ZERO4X4,
+ NEW4X4,
+
+ B_MODE_COUNT
+ } VP8_B_PREDICTION_MODE;
+
+#define VP8_BINTRAMODES (B_HU_PRED + 1) /* 10 */
+#define VP8_SUBMVREFS (1 + NEW4X4 - LEFT4X4)
+
+// frame type
+ typedef enum
+ {
+ KEY_FRAME = 0,
+ INTER_FRAME,
+ SKIPPED_FRAME
+ } FRAME_TYPE;
+
+
+// Color Space
+ typedef enum
+ {
+ REG_YUV = 0, /* Regular yuv */
+ INT_YUV = 1 /* The type of yuv that can be tranfer to and from RGB through integer transform */
+ } YUV_TYPE;
+
+// Clamp type
+ typedef enum
+ {
+ RECON_CLAMP_REQUIRED = 0,
+ RECON_CLAMP_NOTREQUIRED = 1
+ } CLAMP_TYPE;
+
+ /* Token partition */
+ typedef enum
+ {
+ ONE_PARTITION = 0,
+ TWO_PARTITION = 1,
+ FOUR_PARTITION = 2,
+ EIGHT_PARTITION = 3
+ } TOKEN_PARTITION;
+
+// Buffer copied
+ typedef enum
+ {
+ BufferCopied_NoneToGolden = 0,
+ BufferCopied_LastToGolden = 1,
+ BufferCopied_AltRefToGolden = 2
+ } GoldenBufferCopiedType;
+
+ typedef enum
+ {
+ BufferCopied_NoneToAltref = 0,
+ BufferCopied_LastToAltRef = 1,
+ BufferCopied_GoldenToAltRef = 2
+ } AltRefBufferCopiedType;
+
+// Macroblock level features
+ typedef enum
+ {
+ MB_LVL_ALT_Q = 0, /* Use alternate Quantizer .... */
+ MB_LVL_ALT_LF = 1, /* Use alternate loop filter value... */
+ MB_LVL_MAX = 2 /* Number of MB level features supported */
+ } MB_LVL_FEATURES;
+
+// Loop filter Type
+ typedef enum
+ {
+ NORMAL_LOOPFILTER = 0,
+ SIMPLE_LOOPFILTER = 1
+ } LoopFilterType;
+
+// Segmentation data
+ typedef struct
+ {
+ uint8_t Enabled;
+ uint8_t UpdateMap;
+ uint8_t UpdateData;
+ uint8_t AbsDelta;
+ int8_t FeatureData[MB_LVL_MAX][MAX_MB_SEGMENTS];
+ vp8_prob TreeProbs[MB_FEATURE_TREE_PROBS];
+ } SegmentationData;
+
+// Loop filter data
+ typedef struct
+ {
+ LoopFilterType Type;
+ uint8_t Level;
+ uint8_t Sharpness;
+ uint8_t DeltaEnabled;
+ uint8_t DeltaUpdate;
+ int8_t DeltasRef[MAX_REF_LF_DELTAS];
+ int8_t DeltasMode[MAX_MODE_LF_DELTAS];
+ } LoopFilterData;
+
+// Quantization data
+ typedef struct
+ {
+ int8_t Y1_AC;
+ int8_t Y1_DC_Delta;
+ int8_t Y2_DC_Delta;
+ int8_t Y2_AC_Delta;
+ int8_t UV_DC_Delta;
+ int8_t UV_AC_Delta;
+ } QuantizationData;
+
+// Frame context
+ typedef struct
+ {
+ vp8_prob B_Mode_Prob[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES-1];
+ vp8_prob Y_Mode_Prob [VP8_YMODES-1]; /* interframe intra mode probs */
+ vp8_prob UV_Mode_Prob [VP8_UV_MODES-1];
+ vp8_prob DCT_Coefficients [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_COEF_TOKENS-1];
+ vp8_prob MVContext[2][VP8_MV_Pcount];
+ vp8_prob Pre_MVContext[2][VP8_MV_Pcount]; //not to caculate the mvcost for the frame if mvc doesn't change.
+ } FrameContextData;
+
+// Extern to tables
+ extern const vp8_prob VP8_Coefficient_Default_Probabilites[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_COEF_TOKENS-1];
+ extern const vp8_prob VP8_Coefficient_Update_Probabilites[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_COEF_TOKENS-1];
+ extern const int VP8_MB_FeatureDataBits[MB_LVL_MAX];
+ extern const vp8_prob VP8_BMode_Const[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES-1];
+ extern const vp8_prob VP8_YMode_Const[VP8_YMODES-1];
+ extern const vp8_prob VP8_UVMode_Const[VP8_UV_MODES-1];
+ extern const vp8_prob VP8_MV_UpdateProbs[2][VP8_MV_Pcount], VP8_MV_DefaultMVContext[2][VP8_MV_Pcount];
+
+ typedef struct
+ {
+ FRAME_TYPE frame_type;
+ uint8_t version;
+ uint8_t show_frame;
+ uint32_t first_part_size;
+ } FrameTagHeader;
+
+ typedef struct _vp8_Info
+ {
+ // Frame Tag Header
+ FrameTagHeader frame_tag;
+
+ // Key Frame data
+ uint32_t width;
+ uint32_t height;
+ uint32_t horiz_scale;
+ uint32_t vert_scale;
+ YUV_TYPE clr_type;
+ CLAMP_TYPE clamp_type;
+
+ vp8_prob prob_intra;
+ vp8_prob prob_lf;
+ vp8_prob prob_gf;
+
+ uint8_t y_prob_valid;
+ uint8_t c_prob_valid;
+
+ uint32_t header_bits;
+ uint32_t frame_data_offset;
+
+ uint8_t *source;
+ uint32_t source_sz;
+
+ // Decoded picture number
+ uint32_t decoded_frame_number;
+
+ BOOL_CODER bool_coder;
+
+ // Refresh flags
+ uint8_t refresh_lf;
+
+ uint8_t refresh_gf;
+ uint8_t refresh_af;
+ uint8_t sign_bias_golden;
+ uint8_t sign_bias_alternate;
+
+ GoldenBufferCopiedType golden_copied;
+ AltRefBufferCopiedType altref_copied;
+
+ // Degmentation data
+ SegmentationData Segmentation;
+
+ // Loop filter data
+ LoopFilterData LoopFilter;
+
+ // Partitions
+ uint8_t partition_count;
+ uint8_t partition_number;
+ uint32_t partition_size[1<<EIGHT_PARTITION];
+
+ // Quantization
+ QuantizationData Quantization;
+
+ // Refresh entropy
+ uint8_t refresh_entropy;
+ // Refresh entropy
+ uint8_t refresh_entropy_lf;
+
+ // Macroblock No Coeff Skip
+ uint8_t mb_no_coeff_skip;
+ vp8_prob prob_skip_false;
+ vp8_prob mb_skip_coeff;
+
+ // Frame context
+ FrameContextData FrameContext;
+ // Same thing exist in the reference.
+ // The variable RefreshEntropy is controling storage/saving of that.
+ FrameContextData LastFrameContext;
+ } vp8_Info;
+
+ typedef struct _vp8_viddec_parser
+ {
+ int got_start;
+
+ vp8_Info info;
+ } vp8_viddec_parser;
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8_tables.h b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8_tables.h
new file mode 100644
index 0000000..6980834
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8_tables.h
@@ -0,0 +1,538 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#ifndef _VP8_TABLES_H_
+#define _VP8_TABLES_H_
+
+#include "vp8.h"
+const int VP8_MB_FeatureDataBits[MB_LVL_MAX] = {7, 6};
+
+const vp8_prob VP8_BMode_Const[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES-1] =
+{
+ {
+ { 231, 120, 48, 89, 115, 113, 120, 152, 112},
+ { 152, 179, 64, 126, 170, 118, 46, 70, 95},
+ { 175, 69, 143, 80, 85, 82, 72, 155, 103},
+ { 56, 58, 10, 171, 218, 189, 17, 13, 152},
+ { 144, 71, 10, 38, 171, 213, 144, 34, 26},
+ { 114, 26, 17, 163, 44, 195, 21, 10, 173},
+ { 121, 24, 80, 195, 26, 62, 44, 64, 85},
+ { 170, 46, 55, 19, 136, 160, 33, 206, 71},
+ { 63, 20, 8, 114, 114, 208, 12, 9, 226},
+ { 81, 40, 11, 96, 182, 84, 29, 16, 36}
+ },
+ {
+ { 134, 183, 89, 137, 98, 101, 106, 165, 148},
+ { 72, 187, 100, 130, 157, 111, 32, 75, 80},
+ { 66, 102, 167, 99, 74, 62, 40, 234, 128},
+ { 41, 53, 9, 178, 241, 141, 26, 8, 107},
+ { 104, 79, 12, 27, 217, 255, 87, 17, 7},
+ { 74, 43, 26, 146, 73, 166, 49, 23, 157},
+ { 65, 38, 105, 160, 51, 52, 31, 115, 128},
+ { 87, 68, 71, 44, 114, 51, 15, 186, 23},
+ { 47, 41, 14, 110, 182, 183, 21, 17, 194},
+ { 66, 45, 25, 102, 197, 189, 23, 18, 22}
+ },
+ {
+ { 88, 88, 147, 150, 42, 46, 45, 196, 205},
+ { 43, 97, 183, 117, 85, 38, 35, 179, 61},
+ { 39, 53, 200, 87, 26, 21, 43, 232, 171},
+ { 56, 34, 51, 104, 114, 102, 29, 93, 77},
+ { 107, 54, 32, 26, 51, 1, 81, 43, 31},
+ { 39, 28, 85, 171, 58, 165, 90, 98, 64},
+ { 34, 22, 116, 206, 23, 34, 43, 166, 73},
+ { 68, 25, 106, 22, 64, 171, 36, 225, 114},
+ { 34, 19, 21, 102, 132, 188, 16, 76, 124},
+ { 62, 18, 78, 95, 85, 57, 50, 48, 51}
+ },
+ {
+ { 193, 101, 35, 159, 215, 111, 89, 46, 111},
+ { 60, 148, 31, 172, 219, 228, 21, 18, 111},
+ { 112, 113, 77, 85, 179, 255, 38, 120, 114},
+ { 40, 42, 1, 196, 245, 209, 10, 25, 109},
+ { 100, 80, 8, 43, 154, 1, 51, 26, 71},
+ { 88, 43, 29, 140, 166, 213, 37, 43, 154},
+ { 61, 63, 30, 155, 67, 45, 68, 1, 209},
+ { 142, 78, 78, 16, 255, 128, 34, 197, 171},
+ { 41, 40, 5, 102, 211, 183, 4, 1, 221},
+ { 51, 50, 17, 168, 209, 192, 23, 25, 82}
+ },
+ {
+ { 125, 98, 42, 88, 104, 85, 117, 175, 82},
+ { 95, 84, 53, 89, 128, 100, 113, 101, 45},
+ { 75, 79, 123, 47, 51, 128, 81, 171, 1},
+ { 57, 17, 5, 71, 102, 57, 53, 41, 49},
+ { 115, 21, 2, 10, 102, 255, 166, 23, 6},
+ { 38, 33, 13, 121, 57, 73, 26, 1, 85},
+ { 41, 10, 67, 138, 77, 110, 90, 47, 114},
+ { 101, 29, 16, 10, 85, 128, 101, 196, 26},
+ { 57, 18, 10, 102, 102, 213, 34, 20, 43},
+ { 117, 20, 15, 36, 163, 128, 68, 1, 26}
+ },
+ {
+ { 138, 31, 36, 171, 27, 166, 38, 44, 229},
+ { 67, 87, 58, 169, 82, 115, 26, 59, 179},
+ { 63, 59, 90, 180, 59, 166, 93, 73, 154},
+ { 40, 40, 21, 116, 143, 209, 34, 39, 175},
+ { 57, 46, 22, 24, 128, 1, 54, 17, 37},
+ { 47, 15, 16, 183, 34, 223, 49, 45, 183},
+ { 46, 17, 33, 183, 6, 98, 15, 32, 183},
+ { 65, 32, 73, 115, 28, 128, 23, 128, 205},
+ { 40, 3, 9, 115, 51, 192, 18, 6, 223},
+ { 87, 37, 9, 115, 59, 77, 64, 21, 47}
+ },
+ {
+ { 104, 55, 44, 218, 9, 54, 53, 130, 226},
+ { 64, 90, 70, 205, 40, 41, 23, 26, 57},
+ { 54, 57, 112, 184, 5, 41, 38, 166, 213},
+ { 30, 34, 26, 133, 152, 116, 10, 32, 134},
+ { 75, 32, 12, 51, 192, 255, 160, 43, 51},
+ { 39, 19, 53, 221, 26, 114, 32, 73, 255},
+ { 31, 9, 65, 234, 2, 15, 1, 118, 73},
+ { 88, 31, 35, 67, 102, 85, 55, 186, 85},
+ { 56, 21, 23, 111, 59, 205, 45, 37, 192},
+ { 55, 38, 70, 124, 73, 102, 1, 34, 98}
+ },
+ {
+ { 102, 61, 71, 37, 34, 53, 31, 243, 192},
+ { 69, 60, 71, 38, 73, 119, 28, 222, 37},
+ { 68, 45, 128, 34, 1, 47, 11, 245, 171},
+ { 62, 17, 19, 70, 146, 85, 55, 62, 70},
+ { 75, 15, 9, 9, 64, 255, 184, 119, 16},
+ { 37, 43, 37, 154, 100, 163, 85, 160, 1},
+ { 63, 9, 92, 136, 28, 64, 32, 201, 85},
+ { 86, 6, 28, 5, 64, 255, 25, 248, 1},
+ { 56, 8, 17, 132, 137, 255, 55, 116, 128},
+ { 58, 15, 20, 82, 135, 57, 26, 121, 40}
+ },
+ {
+ { 164, 50, 31, 137, 154, 133, 25, 35, 218},
+ { 51, 103, 44, 131, 131, 123, 31, 6, 158},
+ { 86, 40, 64, 135, 148, 224, 45, 183, 128},
+ { 22, 26, 17, 131, 240, 154, 14, 1, 209},
+ { 83, 12, 13, 54, 192, 255, 68, 47, 28},
+ { 45, 16, 21, 91, 64, 222, 7, 1, 197},
+ { 56, 21, 39, 155, 60, 138, 23, 102, 213},
+ { 85, 26, 85, 85, 128, 128, 32, 146, 171},
+ { 18, 11, 7, 63, 144, 171, 4, 4, 246},
+ { 35, 27, 10, 146, 174, 171, 12, 26, 128}
+ },
+ {
+ { 190, 80, 35, 99, 180, 80, 126, 54, 45},
+ { 85, 126, 47, 87, 176, 51, 41, 20, 32},
+ { 101, 75, 128, 139, 118, 146, 116, 128, 85},
+ { 56, 41, 15, 176, 236, 85, 37, 9, 62},
+ { 146, 36, 19, 30, 171, 255, 97, 27, 20},
+ { 71, 30, 17, 119, 118, 255, 17, 18, 138},
+ { 101, 38, 60, 138, 55, 70, 43, 26, 142},
+ { 138, 45, 61, 62, 219, 1, 81, 188, 64},
+ { 32, 41, 20, 117, 151, 142, 20, 21, 163},
+ { 112, 19, 12, 61, 195, 128, 48, 4, 24}
+ }
+};
+
+const vp8_prob VP8_Coefficient_Update_Probabilites[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_COEF_TOKENS-1] =
+{
+ {
+ {
+ {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, },
+ },
+ {
+ {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, },
+ },
+ {
+ {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, },
+ },
+ {
+ {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, },
+ },
+ {
+ {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, },
+ },
+ },
+};
+
+const vp8_prob VP8_MV_UpdateProbs[2][VP8_MV_Pcount] =
+{
+ {
+ 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
+ }
+};
+
+const vp8_prob VP8_MV_DefaultMVContext[2][VP8_MV_Pcount] =
+{
+ {
+ // 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
+ },
+ {
+ // same for column
+ 164, // is short
+ 128,
+ 204, 170, 119, 235, 140, 230, 228,
+ 128, 130, 130, 74, 148, 180, 203, 236, 254, 254 // long bits
+ }
+};
+
+const vp8_prob VP8_Coefficient_Default_Probabilites[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_COEF_TOKENS-1] =
+{
+ {
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ }
+ },
+ {
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ }
+ },
+ {
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ }
+ },
+ {
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ },
+ {
+ { 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}
+ }
+ }
+};
+
+const vp8_prob VP8_YMode_Const[VP8_YMODES-1] = {112,86,140,37};
+
+const vp8_prob VP8_UVMode_Const[VP8_UV_MODES-1] = {162, 101,204};
+
+#endif
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8parse.h b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8parse.h
new file mode 100644
index 0000000..a5c9c13
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/include/vp8parse.h
@@ -0,0 +1,72 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#ifndef _VP8PARSE_H_
+#define _VP8PARSE_H_
+
+#include "vp8.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int32_t vp8_parse_frame_tag(FrameTagHeader *frame_tag, uint8_t *data, uint32_t data_sz);
+
+//vp8_Status vp8_translate_parse_status(vp8_Status status);
+
+void vp8_init_Info(vp8_Info *pi);
+
+void vp8_init_frame(vp8_Info *pi);
+
+void vp8_parse_segmentation_adjustments_data(vp8_Info *pi);
+
+void vp8_parse_loop_filter_type_level(vp8_Info *pi);
+
+void vp8_parse_loop_filter_adjustments_data(vp8_Info *pi);
+
+int32_t vp8_read_partition_size(uint8_t *cx_size);
+
+void vp8_parse_token_partition_data(vp8_Info *pi, uint8_t *cx_size);
+
+int read_q_delta(BOOL_CODER *bool_coder);
+
+void vp8_parse_dequantization_indices(vp8_Info *pi);
+
+void vp8_parse_gf_af_refresh_flags(vp8_Info *pi);
+
+void vp8_parse_coef_probs_tree(vp8_Info *pi);
+
+void vp8_parse_mb_mv_info(vp8_Info *pi);
+
+void vp8_parse_yuv_probs_update(vp8_Info *pi);
+
+void vp8_parse_remaining_frame_header_data(vp8_Info *pi);
+
+int32_t vp8_parse_frame_header(vp8_viddec_parser *parser);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/parser/Android.mk b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/Android.mk
new file mode 100644
index 0000000..df0d270
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/Android.mk
@@ -0,0 +1,25 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ vp8parse.c \
+ bool_coder.c \
+ viddec_vp8_parse.c
+
+LOCAL_CFLAGS := -DVBP -DHOST_ONLY
+
+LOCAL_C_INCLUDES := \
+ $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/include \
+ $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/include \
+ $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/parser/include \
+ $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/vp8/include
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libmixvbp_vp8
+
+LOCAL_SHARED_LIBRARIES := \
+ libmixvbp \
+ liblog
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/parser/bool_coder.c b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/bool_coder.c
new file mode 100644
index 0000000..746d63e
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/bool_coder.c
@@ -0,0 +1,95 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#include "bool_coder.h"
+
+uint32_t vp8_read_bits(BOOL_CODER *br, int32_t bits)
+{
+ uint32_t z = 0;
+ int bit;
+ for (bit=bits-1; bit>=0; bit--)
+ {
+ z |= (vp8_decode_bool(br, 128)<<bit);
+ }
+ return z;
+}
+
+void vp8_start_decode(BOOL_CODER *br, uint8_t *source)
+{
+ br->range = 255;
+ br->count = 8;
+ br->buffer = source;
+ br->pos = 0;
+ br->value = (br->buffer[0]<<24)+(br->buffer[1]<<16)+(br->buffer[2]<<8)+(br->buffer[3]);
+ br->pos += 4;
+}
+
+int32_t vp8_decode_bool(BOOL_CODER *br, int32_t probability)
+{
+ uint32_t bit=0;
+ uint32_t split;
+ uint32_t bigsplit;
+ uint32_t count = br->count;
+ uint32_t range = br->range;
+ uint32_t value = br->value;
+
+ split = 1 + (((range-1) * probability) >> 8);
+ bigsplit = (split<<24);
+
+ range = split;
+ if(value >= bigsplit)
+ {
+ range = br->range-split;
+ value = value-bigsplit;
+ bit = 1;
+ }
+
+ if(range>=0x80)
+ {
+ br->value = value;
+ br->range = range;
+ return bit;
+ }
+ else
+ {
+ do
+ {
+ range +=range;
+ value +=value;
+
+ if (!--count)
+ {
+ count = 8;
+ value |= br->buffer[br->pos];
+ br->pos++;
+ }
+ }
+ while(range < 0x80 );
+ }
+ br->count = count;
+ br->value = value;
+ br->range = range;
+ return bit;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/parser/viddec_vp8_parse.c b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/viddec_vp8_parse.c
new file mode 100644
index 0000000..b5dfbe6
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/viddec_vp8_parse.c
@@ -0,0 +1,121 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#include "viddec_fw_debug.h"
+#include "viddec_parser_ops.h"
+
+#include "viddec_fw_workload.h"
+#include "viddec_pm.h"
+
+#include <utils/Log.h>
+#include "vp8.h"
+#include "vp8parse.h"
+#include "viddec_vp8_parse.h"
+
+/* Init function which can be called to intialized local context on open and flush and preserve*/
+void viddec_vp8_init(void *ctxt, uint32_t *persist_mem, uint32_t preserve)
+{
+ vp8_viddec_parser* parser = ctxt;
+ vp8_Info *pi = &(parser->info);
+
+ /* Avoid compiler warning */
+ persist_mem = persist_mem;
+
+ if (!preserve)
+ {
+ /* Init frame header information */
+ vp8_init_Info(pi);
+ }
+ else
+ {
+ /* Initialise the parser */
+ pi->decoded_frame_number = 0;
+ pi->refresh_entropy_lf = 1;
+ }
+
+ parser->got_start = 1;
+ return;
+}
+
+uint32_t viddec_vp8_parse(void *parent, void *ctxt)
+{
+ vp8_Status status = VP8_NO_ERROR;
+
+ vp8_viddec_parser *parser = (vp8_viddec_parser*)ctxt;
+ if (1 != parser->got_start) return VP8_NO_INITIALIZATION;
+
+ vp8_Info *pi = &(parser->info);
+ viddec_pm_cxt_t *pm_cxt = (viddec_pm_cxt_t *)parent;
+ pi->source = pm_cxt->parse_cubby.buf;
+ pi->source_sz = pm_cxt->parse_cubby.size;
+
+ if (pi->source_sz < 0)
+ {
+ return VP8_UNEXPECTED_END_OF_BITSTREAM;
+ }
+ else if (pi->source_sz == 0)
+ {
+ pi->frame_tag.frame_type = SKIPPED_FRAME;
+ status = VP8_NO_ERROR;
+ }
+ else if (pi->source_sz > 0)
+ {
+ status = vp8_parse_frame_header(parser);
+ }
+
+ return status;
+}
+
+uint32_t viddec_vp8_wkld_done(void *parent, void *ctxt, unsigned int next_sc,
+ uint32_t *codec_specific_errors)
+{
+ return 0;
+}
+
+void viddec_vp8_get_context_size(viddec_parser_memory_sizes_t *size)
+{
+ /* Should return size of my structure */
+ size->context_size = sizeof(vp8_viddec_parser);
+ size->persist_size = 0;
+ return;
+}
+
+uint32_t viddec_vp8_is_frame_start(void *ctxt)
+{
+ vp8_viddec_parser* parser = ctxt;
+
+ return parser->got_start;
+}
+
+void viddec_vp8_get_ops(viddec_parser_ops_t *ops)
+{
+ ops->init = viddec_vp8_init;
+
+ ops->parse_syntax = viddec_vp8_parse;
+ ops->get_cxt_size = viddec_vp8_get_context_size;
+ ops->is_wkld_done = viddec_vp8_wkld_done;
+ ops->is_frame_start = viddec_vp8_is_frame_start;
+ return;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vp8/parser/vp8parse.c b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/vp8parse.c
new file mode 100644
index 0000000..4f15736
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/codecs/vp8/parser/vp8parse.c
@@ -0,0 +1,605 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+* Copyright (c) Imagination Technologies Limited, UK
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#include "vp8_tables.h"
+#include "vp8parse.h"
+
+static const uint8_t kVp8SyncCodeByte[] = {0x9d, 0x01, 0x2a};
+
+void vp8_init_Info(vp8_Info *pi)
+{
+ memset(pi, 0, sizeof(vp8_Info));
+
+ /* Initialise the parser */
+ pi->decoded_frame_number = 0;
+ pi->refresh_entropy_lf = 1;
+}
+
+int32_t vp8_parse_frame_tag(FrameTagHeader *frame_tag, uint8_t *data, uint32_t data_sz)
+{
+ if (data_sz < 3)
+ {
+ return VP8_CORRUPT_FRAME;
+ }
+
+ /* 1-bit frame type */
+ frame_tag->frame_type = (FRAME_TYPE)(data[0] & 1);
+
+ /* 3-bit version number */
+ frame_tag->version = (data[0] >> 1) & 7;
+ if (frame_tag->version > 3)
+ {
+ return VP8_UNSUPPORTED_VERSION ;
+ }
+
+ /* 1-bit show frame flag */
+ frame_tag->show_frame = (data[0] >> 4) & 1;
+
+ /* 19-bit field containing the sie of the first data partition in bytes */
+ frame_tag->first_part_size = (data[0] | (data[1] << 8) | (data[2] << 16)) >> 5;
+
+ return VP8_NO_ERROR;
+}
+
+void vp8_init_frame(vp8_Info *pi)
+{
+ pi->golden_copied = BufferCopied_NoneToGolden;
+ pi->altref_copied = BufferCopied_NoneToAltref;
+
+ if (pi->frame_tag.frame_type == KEY_FRAME)
+ {
+ /* Various keyframe initializations */
+ /* vp8_prob data initialization */
+ memcpy(pi->FrameContext.B_Mode_Prob, VP8_BMode_Const, sizeof(VP8_BMode_Const));
+ memcpy(pi->FrameContext.Y_Mode_Prob, VP8_YMode_Const, sizeof(VP8_YMode_Const));
+ memcpy(pi->FrameContext.UV_Mode_Prob, VP8_UVMode_Const, sizeof(VP8_UVMode_Const));
+ memcpy(pi->FrameContext.MVContext, VP8_MV_DefaultMVContext, sizeof(VP8_MV_DefaultMVContext));
+ memcpy(pi->FrameContext.DCT_Coefficients, VP8_Coefficient_Default_Probabilites, sizeof(VP8_Coefficient_Default_Probabilites));
+
+ /* reset the segment feature data to 0 with delta coding (Default state)*/
+ memset(pi->Segmentation.FeatureData, 0, sizeof(pi->Segmentation.FeatureData));
+ pi->Segmentation.AbsDelta = SEGMENT_DELTADATA;
+
+ /* reset the mode ref deltasa for loop filter */
+ memset(pi->LoopFilter.DeltasRef, 0, sizeof(pi->LoopFilter.DeltasRef));
+ memset(pi->LoopFilter.DeltasMode, 0, sizeof(pi->LoopFilter.DeltasMode));
+
+ /* All buffers are implicitly updated on key frames */
+ pi->refresh_gf = 1;
+ pi->refresh_af = 1;
+
+ pi->sign_bias_golden = 0;
+ pi->sign_bias_alternate = 0;
+ }
+ else if (pi->frame_tag.frame_type == INTER_FRAME)
+ {
+ pi->refresh_gf = 0;
+ pi->refresh_af = 0;
+ }
+}
+
+/* This function provides vp8_prob and value infomation for implementing
+ * segment adaptive adjustments to default decoder behaviors.
+ * The data parsed here applies to the entire frame. The adjustments can be
+ * quantization level or loop filter strength.
+ * */
+void vp8_parse_segmentation_adjustments_data(vp8_Info *pi)
+{
+ int i,j;
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ const int *const mb_feature_data_bits = VP8_MB_FeatureDataBits;
+
+ /* Is segmentation enabled */
+ pi->Segmentation.Enabled = (uint8_t)vp8_decode_bool(bc, 128); //chapter 9.2 - macroblock uses segments ? 1: 0
+
+ if(pi->Segmentation.Enabled )
+ {
+ /* Signal whether or not the segmentation map is being explicitly updated this frame */
+ pi->Segmentation.UpdateMap = (uint8_t)vp8_decode_bool(bc, 128);
+ pi->Segmentation.UpdateData = (uint8_t)vp8_decode_bool(bc, 128);
+
+ if (pi->Segmentation.UpdateData)
+ {
+ pi->Segmentation.AbsDelta = (uint8_t)vp8_decode_bool(bc, 128);
+
+ memset(pi->Segmentation.FeatureData, 0, sizeof(pi->Segmentation.FeatureData));
+
+ /* For each segmentation feature (Quant and loop filter level) */
+ for (i = 0; i < MB_LVL_MAX; ++i)
+ {
+ for (j = 0; j < MAX_MB_SEGMENTS; ++j)
+ {
+ /* Frame level data */
+ if (vp8_decode_bool(bc, 128))
+ {
+ /* Parse magnitude */
+ pi->Segmentation.FeatureData[i][j] = (int8_t) vp8_read_bits(bc, mb_feature_data_bits[i]) ;
+
+ /* Parse sign data */
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->Segmentation.FeatureData[i][j] = -pi->Segmentation.FeatureData[i][j];
+ }
+ }
+ else
+ {
+ pi->Segmentation.FeatureData[i][j] = 0;
+ }
+ }
+ }
+
+ }
+
+ if (pi->Segmentation.UpdateMap)
+ {
+ /* Which macro block level features are enabled */
+ memset(pi->Segmentation.TreeProbs, 255, sizeof(pi->Segmentation.TreeProbs));
+
+ /* Read the probs used to decode the segment id for each macro block */
+ for (i = 0; i < MB_FEATURE_TREE_PROBS; ++i)
+ {
+ /* If not explicitly set value is defaulted to 255 by memset above */
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->Segmentation.TreeProbs[i] = (uint8_t)vp8_read_bits(bc, 8);
+ }
+ }
+ }
+ }
+}
+
+/* VP8 supprots two types of loop filter. The data parsed in the header
+ * to support the selection of the type, strength and sharpness behavior
+ * of the loop filter used for the current frame.
+ */
+void vp8_parse_loop_filter_type_level(vp8_Info *pi)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* Read the loop filter level and type */
+ pi->LoopFilter.Type = (LoopFilterType)vp8_decode_bool(bc, 128);
+ pi->LoopFilter.Level = (uint8_t)vp8_read_bits(bc, 6);
+ pi->LoopFilter.Sharpness = (uint8_t)vp8_read_bits(bc, 3);
+}
+
+/* This function provides flag and value information for implmenting
+ * per-macroblock loop filter level adjustments to default decoder
+ * behaviors. Data parsed here applies to the entire frame.
+ */
+void vp8_parse_loop_filter_adjustments_data(vp8_Info *pi)
+{
+ int i;
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* Read in loop filter deltas applied at the MB level based on mode or ref frame */
+ pi->LoopFilter.DeltaUpdate = 0;
+ pi->LoopFilter.DeltaEnabled = (uint8_t)vp8_decode_bool(bc, 128);
+
+ if (pi->LoopFilter.DeltaEnabled)
+ {
+ /* Do the deltas need to be updated */
+ pi->LoopFilter.DeltaUpdate = (uint8_t)vp8_decode_bool(bc, 128);
+
+ if (pi->LoopFilter.DeltaUpdate)
+ {
+ /* Update based on reference */
+ for (i = 0; i < MAX_REF_LF_DELTAS; ++i)
+ {
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->LoopFilter.DeltasRef[i] = (int8_t)vp8_read_bits(bc, 6);
+
+ /* Parse sign */
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->LoopFilter.DeltasRef[i] = -1 * pi->LoopFilter.DeltasRef[i];
+ }
+ }
+ }
+
+ /* Update based on macroblock mode */
+ for (i = 0; i < MAX_MODE_LF_DELTAS; ++i)
+ {
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->LoopFilter.DeltasMode[i] = (int8_t)vp8_read_bits(bc, 6);
+
+ /* Parse sign */
+ if (vp8_decode_bool(bc, 128))
+ {
+ pi->LoopFilter.DeltasMode[i] = -1 * pi->LoopFilter.DeltasMode[i];
+ }
+ }
+ } /* End for (i = 0; i < MAX_MODE_LF_DELTAS; ++i) */
+ } /* End if (pi->LoopFilter.DeltaUpdate) */
+ }
+}
+
+/* Token partition and partition data offsets */
+void vp8_parse_token_partition_data(vp8_Info *pi, uint8_t *cx_size)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+ uint8_t *partition = NULL;
+ uint8_t *source_end = pi->source + pi->source_sz;
+ uint32_t partition_size = 0, i = 0;
+ uint8_t *partition_size_ptr = NULL;
+
+ /* Parse number of token partitions to use */
+ pi->partition_count = 1 << (uint8_t)vp8_read_bits(bc, 2);
+
+ /* Set up pointers to the first partition */
+ partition = cx_size;
+ if (pi->partition_count > 1)
+ {
+ /* Each partition offset is written in 3 bytes */
+ partition += 3 * (pi->partition_count - 1);
+ }
+
+ for (i = 0; i < pi->partition_count; i++)
+ {
+ partition_size_ptr = cx_size + i * 3;
+
+ if (i < pi->partition_count - 1)
+ {
+ pi->partition_size[i] = vp8_read_partition_size(partition_size_ptr);
+ }
+ else
+ {
+ /* Last offset can be calculated implictly */
+ pi->partition_size[i] = source_end - partition;
+ }
+
+ partition += pi->partition_size[i];
+ }
+}
+
+int32_t vp8_read_partition_size(uint8_t *cx_size)
+{
+ uint32_t size = cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16);
+
+ return size;
+}
+
+int read_q_delta(BOOL_CODER *bool_coder)
+{
+ int q_delta = 0;
+
+ /* presence flag */
+ if (vp8_decode_bool(bool_coder, 128))
+ {
+ /* magnitude */
+ q_delta = (uint8_t)vp8_read_bits(bool_coder, 4) ;
+
+ /* sign */
+ if (vp8_decode_bool(bool_coder, 128))
+ {
+ q_delta = -q_delta;
+ }
+ }
+
+ return q_delta;
+}
+
+/* Read the default quantizers */
+void vp8_parse_dequantization_indices(vp8_Info *pi)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* AC 1st order Q = default as a baseline for other 5 items */
+ pi->Quantization.Y1_AC = (int8_t)vp8_read_bits(bc, 7);
+ pi->Quantization.Y1_DC_Delta = (int8_t)read_q_delta(bc);
+ pi->Quantization.Y2_DC_Delta = (int8_t)read_q_delta(bc);
+ pi->Quantization.Y2_AC_Delta = (int8_t)read_q_delta(bc);
+ pi->Quantization.UV_DC_Delta = (int8_t)read_q_delta(bc);
+ pi->Quantization.UV_AC_Delta = (int8_t)read_q_delta(bc);
+}
+
+
+/* Determine if the golden frame or ARF buffer should be updated and how.
+ * For all non key frames the GF and ARF refresh flags and sign bias
+ * flags must be set explicitly.
+ */
+void vp8_parse_gf_af_refresh_flags(vp8_Info *pi)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* Read Golden and AltRef frame refresh */
+ pi->refresh_gf = (uint8_t)vp8_decode_bool(bc, 128);
+ pi->refresh_af = (uint8_t)vp8_decode_bool(bc, 128);
+
+ /* If not refreshed using the current reconstructed frame */
+ if (0 == pi->refresh_gf)
+ {
+ /* 2 bit indicating which buffer is copied to golden frame */
+ pi->golden_copied = (GoldenBufferCopiedType)(int8_t)vp8_read_bits(bc, 2);
+ }
+ else
+ {
+ /* No buffer is copied */
+ pi->golden_copied = (GoldenBufferCopiedType)0;
+ }
+
+ if (0 == pi->refresh_af)
+ {
+ /* 2 bit indicating which buffer is copied to alternative frame */
+ pi->altref_copied = (AltRefBufferCopiedType)vp8_read_bits(bc, 2);
+ }
+ else
+ {
+ pi->altref_copied = (AltRefBufferCopiedType)0;
+ }
+
+ pi->sign_bias_golden = (uint8_t)vp8_decode_bool(bc, 128);
+ pi->sign_bias_alternate = (uint8_t)vp8_decode_bool(bc, 128);
+
+}
+
+void vp8_parse_coef_probs_tree(vp8_Info *pi)
+{
+ int i, j, k, l;
+
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* DCT coeffienct probability tree update */
+ for (i = 0; i < BLOCK_TYPES; i++)
+ {
+ for (j = 0; j < COEF_BANDS; j++)
+ {
+ for (k = 0; k < PREV_COEF_CONTEXTS; k++)
+ {
+ for (l = 0; l < MAX_COEF_TOKENS - 1; l++)
+ {
+ if (vp8_decode_bool(bc, VP8_Coefficient_Update_Probabilites[i][j][k][l]))
+ {
+ pi->FrameContext.DCT_Coefficients[i][j][k][l] = (vp8_prob)vp8_read_bits(bc, 8);
+ }
+ }
+ }
+ }
+ }
+}
+
+/* Parse remaining non-key-frame only data from frame header */
+void vp8_parse_mb_mv_info(vp8_Info *pi)
+{
+ // read_mvcontexts
+ int i = 0;
+
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ do
+ {
+ const vp8_prob *up = VP8_MV_UpdateProbs[i];
+ vp8_prob *p = pi->FrameContext.MVContext[i];
+ vp8_prob *const pstop = p + VP8_MV_Pcount;
+
+ do
+ {
+ if (vp8_decode_bool(bc , *up++ ))
+ {
+ const vp8_prob x = (vp8_prob)vp8_read_bits(bc, 7);
+
+ *p = x ? x << 1 : 1;
+ }
+ }
+ while (++p < pstop);
+ }
+ while (++i < 2);
+}
+
+/* Parse remaining non-key-frame only data from frame header */
+void vp8_parse_yuv_probs_update(vp8_Info *pi)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* Read probabilities */
+ pi->prob_intra = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->prob_lf = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->prob_gf = (vp8_prob)vp8_read_bits(bc, 8);
+
+ pi->y_prob_valid = (uint8_t)vp8_decode_bool(bc , 128);
+ if (1 == pi->y_prob_valid)
+ {
+ pi->FrameContext.Y_Mode_Prob[0] = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->FrameContext.Y_Mode_Prob[1] = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->FrameContext.Y_Mode_Prob[2] = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->FrameContext.Y_Mode_Prob[3] = (vp8_prob)vp8_read_bits(bc, 8);
+ }
+
+ pi->c_prob_valid = (uint8_t)vp8_decode_bool(bc , 128);
+ if (1 == pi->c_prob_valid)
+ {
+ pi->FrameContext.UV_Mode_Prob[0] = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->FrameContext.UV_Mode_Prob[1] = (vp8_prob)vp8_read_bits(bc, 8);
+ pi->FrameContext.UV_Mode_Prob[2] = (vp8_prob)vp8_read_bits(bc, 8);
+ }
+}
+
+
+void vp8_parse_remaining_frame_header_data(vp8_Info *pi)
+{
+ BOOL_CODER *bc = &(pi->bool_coder);
+
+ /* MB no coefficients skip */
+ pi->mb_no_coeff_skip = (uint8_t)vp8_decode_bool(bc, 128);
+
+ if (1 == pi->mb_no_coeff_skip)
+ {
+ pi->prob_skip_false = (vp8_prob)vp8_read_bits(bc, 8);
+ }
+ else
+ {
+ pi->mb_skip_coeff = 0;
+ }
+
+ if (pi->frame_tag.frame_type == INTER_FRAME)
+ {
+ vp8_parse_yuv_probs_update(pi);
+
+ /* Read motion vector info */
+ vp8_parse_mb_mv_info(pi);
+ }
+
+}
+
+#if 0
+vp8_Status vp8_translate_parse_status(vp8_Status status)
+{
+ switch (status)
+ {
+ case VP8_UNSUPPORTED_VERSION:
+ LOGE("Parser returned VP8_UNSUPPORTED_VERSION");
+ return VP8_UNSUPPORTED_VERSION;
+ case VP8_UNSUPPORTED_BITSTREAM:
+ LOGE("Parser returned VP8_UNSUPPORTED_BITSTREAM");
+ return VP8_UNSUPPORTED_BITSTREAM;
+ case VP8_INVALID_FRAME_SYNC_CODE:
+ LOGE("Parser returned VP8_INVALID_FRAME_SYNC_CODE");
+ return VP8_INVALID_FRAME_SYNC_CODE;
+ case VP8_UNEXPECTED_END_OF_BITSTREAM:
+ LOGE("Parser returned VP8_UNEXPECTED_END_OF_BITSTREAM");
+ return VP8_UNEXPECTED_END_OF_BITSTREAM;
+ default:
+ LOGE("Parser returned VP8_UNKNOWN_ERROR");
+ return VP8_UNKNOWN_ERROR;
+ }
+}
+#endif
+
+/* Parse VP8 frame header */
+int32_t vp8_parse_frame_header(vp8_viddec_parser *parser)
+{
+ vp8_Status ret = VP8_NO_ERROR;
+
+ vp8_Info *pi = &(parser->info);
+
+ uint8_t *data = pi->source;
+ uint32_t data_sz = pi->source_sz;
+
+ if (0 == pi->refresh_entropy_lf)
+ {
+ memcpy(&(pi->FrameContext), &(pi->LastFrameContext), sizeof(FrameContextData));
+ }
+
+ /* Step 1 : parse frame tag containing 3 bytes*/
+ ret = vp8_parse_frame_tag(&(pi->frame_tag), data, data_sz);
+ if (ret != VP8_NO_ERROR)
+ {
+ return ret;
+ }
+
+ /* Pointer advances 3 bytes */
+ data += 3;
+
+ /* Start the frame data offset */
+ pi->frame_data_offset = 3;
+
+ /* Step 2 : parse key frame parameters*/
+ if (pi->frame_tag.frame_type == KEY_FRAME)
+ {
+ /* Check sync code containg 3 bytes*/
+ if ((data[0] != kVp8SyncCodeByte[0]) || (data[1] != kVp8SyncCodeByte[1]) || (data[2] != kVp8SyncCodeByte[2]))
+ {
+ return VP8_INVALID_FRAME_SYNC_CODE;
+ }
+
+ pi->width = (data[3] | (data[4] << 8)) & 0x3fff;
+ pi->horiz_scale = data[4] >> 6;
+ pi->height = (data[5] | (data[6] << 8)) & 0x3fff;
+ pi->vert_scale = data[6] >> 6;
+
+ /* Pointer advances 7 bytes in this case*/
+ data += 7;
+ pi->frame_data_offset += 7;
+ }
+
+ if (0 == pi->width || 0 == pi->height)
+ {
+ return VP8_UNSUPPORTED_BITSTREAM;
+ }
+
+ /* Initialize frame parameters*/
+ vp8_init_frame(pi);
+
+ /* Initialize bool coder */
+ BOOL_CODER *bc = &(pi->bool_coder);
+ vp8_start_decode(bc, (uint8_t*)data);
+
+ /* Parse key frame parameters */
+ if (pi->frame_tag.frame_type == KEY_FRAME)
+ {
+ pi->clr_type = (YUV_TYPE)vp8_decode_bool(bc, 128);
+ pi->clamp_type = (CLAMP_TYPE)vp8_decode_bool(bc, 128);
+ }
+
+ /* Step 3 : parse macroblock-level segmentation flag */
+ vp8_parse_segmentation_adjustments_data(pi);
+
+ /* Step 4 : parse loop filter type and levels */
+ vp8_parse_loop_filter_type_level(pi);
+
+ /* Step 5 : parse macroblock-level loop filter adjustments */
+ vp8_parse_loop_filter_adjustments_data(pi);
+
+ /* Step 6: parse token partition and partition data offsets */
+ vp8_parse_token_partition_data(pi, data + pi->frame_tag.first_part_size);
+
+ /* Step 7: parse dequantization indices */
+ vp8_parse_dequantization_indices(pi);
+
+ /* For key frames, both golden frame and altref frame are refreshed/replaced by the current reconstructed frame, by default */
+ if (pi->frame_tag.frame_type == INTER_FRAME)
+ {
+ /* Step 8: parse golden frame and altref frame refresh flags */
+ vp8_parse_gf_af_refresh_flags(pi);
+ }
+
+ /* Step 9: update proability to decode DCT coef */
+ pi->refresh_entropy = (uint8_t)vp8_decode_bool(bc, 128);
+ if (pi->refresh_entropy == 0)
+ {
+ memcpy(&(pi->LastFrameContext), &(pi->FrameContext), sizeof(FrameContextData));
+ }
+
+ /* Step 10: refresh last frame buffer */
+ pi->refresh_lf = (pi->frame_tag.frame_type == KEY_FRAME) || (uint8_t)(vp8_decode_bool(bc, 128));
+
+ /* Step 11: read coef vp8_prob tree */
+ vp8_parse_coef_probs_tree(pi);
+
+ /* Step 12: read remaining frame header data */
+ vp8_parse_remaining_frame_header_data(pi);
+
+ /* Hold the current offset in the bitstream */
+ pi->frame_data_offset += pi->bool_coder.pos;
+
+ /* Get the frame header bits */
+ pi->header_bits = pi->frame_data_offset * 8 - 16 - pi->bool_coder.count;
+
+ pi->refresh_entropy_lf = pi->refresh_entropy;
+
+ return ret;
+}
diff --git a/mix_vbp/viddec_fw/fw/parser/Android.mk b/mix_vbp/viddec_fw/fw/parser/Android.mk
index 882b081..b578ec2 100644
--- a/mix_vbp/viddec_fw/fw/parser/Android.mk
+++ b/mix_vbp/viddec_fw/fw/parser/Android.mk
@@ -45,4 +45,14 @@
LOCAL_SHARED_LIBRARIES += liblog
endif
+MERRIFIELD_PRODUCT := \
+ mrfl_vp \
+ mrfl_hvp \
+ mrfl_sle
+ifneq ($(filter $(TARGET_PRODUCT),$(MERRIFIELD_PRODUCT)),)
+LOCAL_SRC_FILES += vbp_vp8_parser.c
+LOCAL_C_INCLUDES += $(VENDORS_INTEL_MRST_MIXVBP_ROOT)/viddec_fw/fw/codecs/vp8/include
+LOCAL_CFLAGS += -DUSE_HW_VP8
+endif
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/mix_vbp/viddec_fw/fw/parser/include/viddec_vp8_parse.h b/mix_vbp/viddec_fw/fw/parser/include/viddec_vp8_parse.h
new file mode 100644
index 0000000..6d3583f
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/parser/include/viddec_vp8_parse.h
@@ -0,0 +1,6 @@
+#ifndef VIDDEC_VP8_PARSE_H
+#define VIDDEC_VP8_PARSE_H
+
+void viddec_vp8_get_ops(viddec_parser_ops_t *ops);
+
+#endif
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_loader.h b/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
index ffeb332..53988ab 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_loader.h
@@ -28,8 +28,9 @@
#include <va/va.h>
-
-
+#ifdef USE_HW_VP8
+#include <va/va_dec_vp8.h>
+#endif
#ifndef TRUE
#define TRUE 1
@@ -319,6 +320,54 @@
vbp_picture_data_vc1* pic_data;
} vbp_data_vc1;
+#ifdef USE_HW_VP8
+typedef struct _vbp_codec_data_vp8
+{
+ uint8 frame_type;
+ uint8 version_num;
+ int show_frame;
+
+ uint32 frame_width;
+ uint32 frame_height;
+
+ int refresh_alt_frame;
+ int refresh_golden_frame;
+ int refresh_last_frame;
+
+ int golden_copied;
+ int altref_copied;
+} vbp_codec_data_vp8;
+
+typedef struct _vbp_slice_data_vp8
+{
+ uint8 *buffer_addr;
+ uint32 slice_offset;
+ uint32 slice_size;
+ VASliceParameterBufferBase slc_parms; /* pointer to slice parms */
+} vbp_slice_data_vp8;
+
+typedef struct _vbp_picture_data_vp8
+{
+ VAPictureParameterBufferVP8* pic_parms; /* current parsed picture header */
+
+ uint32 num_slices; /* number of slices. always one for VP8 */
+ vbp_slice_data_vp8 *slc_data; /* pointer to array of slice data */
+} vbp_picture_data_vp8;
+
+typedef struct _vbp_data_vp8
+{
+ uint32 buf_number; /* rolling counter of buffers sent by vbp_parse */
+ vbp_codec_data_vp8 *codec_data;
+
+ uint32 num_pictures;
+
+ vbp_picture_data_vp8* pic_data;
+
+ VAProbabilityDataBufferVP8* prob_data;
+ VAIQMatrixBufferVP8* IQ_matrix_buf;
+} vbp_data_vp8;
+#endif
+
enum _picture_type
{
VC1_PTYPE_I,
@@ -347,9 +396,13 @@
VBP_VC1,
VBP_MPEG2,
VBP_MPEG4,
- VBP_H264
+ VBP_H264,
+#ifdef USE_HW_VP8
+ VBP_VP8
+#endif
};
+
/*
* open video bitstream parser to parse a specific media type.
* @param parser_type: one of the types defined in #vbp_parser_type
@@ -382,7 +435,7 @@
* query parsing result.
* @param hcontext: handle to VBP context.
* @param data: pointer to hold a data blob that contains parsing result.
- * Structure of data blob is determined by the media type.
+ * Structure of data blob is determined by the media type.
* @return VBP_OK on success, anything else on failure.
*
*/
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_utils.c b/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
index 42f9c96..83a38ac 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
@@ -32,6 +32,9 @@
#include "vbp_vc1_parser.h"
#include "vbp_h264_parser.h"
#include "vbp_mp42_parser.h"
+#ifdef USE_HW_VP8
+#include "vbp_vp8_parser.h"
+#endif
/* buffer counter */
@@ -115,7 +118,15 @@
parser_name = "libmixvbp_h264.so";
#endif
break;
-
+#ifdef USE_HW_VP8
+ case VBP_VP8:
+#ifndef ANDROID
+ parser_name = "libmixvbp_vp8.so.0";
+#else
+ parser_name = "libmixvbp_vp8.so";
+#endif
+ break;
+#endif
default:
WTRACE("Unsupported parser type!");
return VBP_TYPE;
@@ -153,6 +164,9 @@
SET_FUNC_POINTER(VBP_VC1, vc1);
SET_FUNC_POINTER(VBP_MPEG4, mp42);
SET_FUNC_POINTER(VBP_H264, h264);
+#ifdef USE_HW_VP8
+ SET_FUNC_POINTER(VBP_VP8, vp8);
+#endif
}
/* set entry points for parser operations:
@@ -248,7 +262,11 @@
/* OK for VC-1, MPEG2 and MPEG4. */
if ((VBP_VC1 == pcontext->parser_type) ||
(VBP_MPEG2 == pcontext->parser_type) ||
- (VBP_MPEG4 == pcontext->parser_type))
+ (VBP_MPEG4 == pcontext->parser_type)
+#ifdef USE_HW_VP8
+ || (VBP_VP8 == pcontext->parser_type)
+#endif
+)
{
pcontext->persist_mem = NULL;
}
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.c b/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.c
new file mode 100644
index 0000000..25aa85d
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.c
@@ -0,0 +1,540 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+#include <dlfcn.h>
+
+#include "vp8.h"
+#include "vbp_loader.h"
+#include "vbp_utils.h"
+#include "vbp_vp8_parser.h"
+
+uint32 vbp_init_parser_entries_vp8(vbp_context *pcontext)
+{
+ if (NULL == pcontext->parser_ops)
+ {
+ return VBP_PARM;
+ }
+
+ pcontext->parser_ops->init = dlsym(pcontext->fd_parser, "viddec_vp8_init");
+ if (NULL == pcontext->parser_ops->init)
+ {
+ ETRACE ("Failed to set entry point." );
+ return VBP_LOAD;
+ }
+
+ pcontext->parser_ops->parse_sc = NULL;
+
+ pcontext->parser_ops->parse_syntax = dlsym(pcontext->fd_parser, "viddec_vp8_parse");
+ if (NULL == pcontext->parser_ops->parse_syntax)
+ {
+ ETRACE ("Failed to set entry point." );
+ return VBP_LOAD;
+ }
+
+ pcontext->parser_ops->get_cxt_size = dlsym(pcontext->fd_parser, "viddec_vp8_get_context_size");
+ if (NULL == pcontext->parser_ops->get_cxt_size)
+ {
+ ETRACE ("Failed to set entry point." );
+ return VBP_LOAD;
+ }
+
+ pcontext->parser_ops->is_wkld_done = NULL;
+
+ /* entry point not needed */
+ pcontext->parser_ops->is_frame_start = NULL;
+
+ return VBP_OK;
+}
+
+uint32 vbp_allocate_query_data_vp8(vbp_context *pcontext)
+{
+ if (NULL != pcontext->query_data)
+ {
+ return VBP_PARM;
+ }
+
+ vbp_data_vp8 *query_data = vbp_malloc_set0(vbp_data_vp8, 1);
+ if (NULL == query_data)
+ {
+ goto cleanup;
+ }
+
+ /* assign the pointer */
+ pcontext->query_data = (void *)query_data;
+
+ query_data->pic_data = vbp_malloc_set0(vbp_picture_data_vp8, VP8_MAX_NUM_PICTURES);
+ if (NULL == query_data->pic_data)
+ {
+ goto cleanup;
+ }
+
+ int i = 0;
+ for (i = 0; i < VP8_MAX_NUM_PICTURES; i++)
+ {
+ query_data->pic_data[i].pic_parms = vbp_malloc_set0(VAPictureParameterBufferVP8, 1);
+ if (NULL == query_data->pic_data[i].pic_parms)
+ {
+ goto cleanup;
+ }
+ query_data->pic_data[i].num_slices = 0;
+ query_data->pic_data[i].slc_data = vbp_malloc_set0(vbp_slice_data_vp8, VP8_MAX_NUM_SLICES);
+ if (NULL == query_data->pic_data[i].slc_data)
+ {
+ goto cleanup;
+ }
+ }
+
+ query_data->codec_data = vbp_malloc_set0(vbp_codec_data_vp8, 1);
+ if (NULL == query_data->codec_data)
+ {
+ goto cleanup;
+ }
+
+ query_data->prob_data = vbp_malloc_set0(VAProbabilityDataBufferVP8, 1);
+ if (NULL == query_data->prob_data)
+ {
+ goto cleanup;
+ }
+
+ query_data->IQ_matrix_buf = vbp_malloc_set0(VAIQMatrixBufferVP8, 1);
+ if (NULL == query_data->IQ_matrix_buf)
+ {
+ goto cleanup;
+ }
+
+ pcontext->parser_private = NULL;
+
+ return VBP_OK;
+
+cleanup:
+ vbp_free_query_data_vp8(pcontext);
+
+ return VBP_MEM;
+}
+
+uint32 vbp_free_query_data_vp8(vbp_context *pcontext)
+{
+ if (NULL == pcontext->query_data)
+ {
+ return VBP_OK;
+ }
+
+ vbp_data_vp8 *query_data = (vbp_data_vp8 *)pcontext->query_data;
+ if (query_data->pic_data)
+ {
+ int i = 0;
+ for (i = 0; i < VP8_MAX_NUM_PICTURES; i++)
+ {
+ if (query_data->pic_data[i].pic_parms)
+ {
+ free(query_data->pic_data[i].pic_parms);
+ query_data->pic_data[i].pic_parms = NULL;
+ }
+ if (query_data->pic_data[i].slc_data)
+ {
+ free(query_data->pic_data[i].slc_data);
+ query_data->pic_data[i].slc_data = NULL;
+ }
+ }
+ free(query_data->pic_data);
+ query_data->pic_data = NULL;
+ }
+
+ if (query_data->codec_data)
+ {
+ free(query_data->codec_data);
+ query_data->codec_data = NULL;
+ }
+
+ if (query_data->prob_data)
+ {
+ free(query_data->prob_data);
+ query_data->prob_data = NULL;
+ }
+
+ if (query_data->IQ_matrix_buf)
+ {
+ free(query_data->IQ_matrix_buf);
+ query_data->IQ_matrix_buf = NULL;
+ }
+
+ free(query_data);
+ pcontext->query_data = NULL;
+
+ return VBP_OK;
+}
+
+
+/**
+* parse decoder configuration data
+*/
+uint32 vbp_parse_init_data_vp8(vbp_context* pcontext)
+{
+ // could never be there
+ return VBP_OK;
+}
+
+uint32 vbp_parse_start_code_vp8(vbp_context *pcontext)
+{
+ viddec_pm_cxt_t *cxt = pcontext->parser_cxt;
+ uint8 *buf = cxt->parse_cubby.buf;
+ uint32 length = cxt->parse_cubby.size;
+ if (length < 3)
+ {
+ return VBP_DATA;
+ }
+
+ // check whether it is a key frame
+ if ((length >= 10) && !(buf[0] & 0x01))
+ {
+ uint8 *c = buf + 3;
+
+ // check start code
+ if ((c[0] != 0x9d) || (c[1] != 0x01) || (c[2] != 0x2a))
+ {
+ return VBP_PARM;
+ }
+ }
+
+ // ugly behavior
+ cxt->list.num_items = 1;
+
+ vbp_data_vp8 *query_data = (vbp_data_vp8*)pcontext->query_data;
+ query_data->num_pictures = 0;
+
+ return VBP_OK;
+}
+
+/**
+*
+* process parsing result after a NAL unit is parsed
+*
+*/
+uint32 vbp_process_parsing_result_vp8( vbp_context *pcontext, int i)
+{
+ vp8_viddec_parser *parser = (vp8_viddec_parser *)pcontext->parser_cxt->codec_data;
+ switch (parser->info.frame_tag.frame_type)
+ {
+ case KEY_FRAME:
+ ITRACE("This is a key frame.");
+ parser->info.decoded_frame_number++;
+ break;
+ case INTER_FRAME:
+ ITRACE("This is an inter frame.");
+ parser->info.decoded_frame_number++;
+ break;
+ case SKIPPED_FRAME:
+ ITRACE("This is skipped frame. We have done nothing.");
+ break;
+ default:
+ WTRACE("Unknown frame type %d", parser->info.frame_tag.frame_type);
+ break;
+ }
+
+ //ITRACE("Decoded frame ID = %d", parser->info.decoded_frame_number);
+
+ return VBP_OK;
+}
+
+static void vbp_add_quantization_data_vp8(vp8_viddec_parser *parser, vbp_data_vp8 *query_data)
+{
+ vp8_Info *pi = &(parser->info);
+ VAIQMatrixBufferVP8 *IQ_buf = query_data->IQ_matrix_buf;
+
+ int i = 0;
+ if (pi->Segmentation.Enabled)
+ {
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ if (SEGMENT_ABSDATA == pi->Segmentation.AbsDelta)
+ {
+ IQ_buf->quantization_index[i][0] = pi->Segmentation.FeatureData[MB_LVL_ALT_Q][i];
+ }
+ else
+ {
+ int temp = pi->Quantization.Y1_AC + pi->Segmentation.FeatureData[MB_LVL_ALT_Q][i];
+ IQ_buf->quantization_index[i][0] = (temp >= 0) ? ((temp <= MAX_QINDEX) ? temp : MAX_QINDEX) : 0;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ IQ_buf->quantization_index[i][0] = pi->Quantization.Y1_AC;
+ }
+ }
+
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ IQ_buf->quantization_index[i][1] = IQ_buf->quantization_index[i][0] + pi->Quantization.Y1_DC_Delta;
+ IQ_buf->quantization_index[i][2] = IQ_buf->quantization_index[i][0] + pi->Quantization.Y2_DC_Delta;
+ IQ_buf->quantization_index[i][3] = IQ_buf->quantization_index[i][0] + pi->Quantization.Y2_AC_Delta;
+ IQ_buf->quantization_index[i][4] = IQ_buf->quantization_index[i][0] + pi->Quantization.UV_DC_Delta;
+ IQ_buf->quantization_index[i][5] = IQ_buf->quantization_index[i][0] + pi->Quantization.UV_AC_Delta;
+ }
+}
+
+static void vbp_add_probs_data_vp8(vp8_viddec_parser *parser, vbp_data_vp8 *query_data)
+{
+ FrameContextData *fc = &(parser->info.FrameContext);
+ VAProbabilityDataBufferVP8 *prob_data = query_data->prob_data;
+
+ /* DCT coefficients probability */
+ int i, j, k, l;
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ for (l = 0; l < 11; l++)
+ {
+ prob_data->dct_coeff_probs[i][j][k][l] = fc->DCT_Coefficients[i][j][k][l];
+ }
+ }
+ }
+ }
+}
+
+static void vbp_set_codec_data_vp8(vp8_viddec_parser *parser, vbp_codec_data_vp8* codec_data)
+{
+ vp8_Info *pi = &(parser->info);
+
+ codec_data->frame_type = pi->frame_tag.frame_type;
+ codec_data->version_num = pi->frame_tag.version;
+ codec_data->show_frame = pi->frame_tag.show_frame;
+
+ //codec_data->frame_width = pi->width;
+ //codec_data->frame_height = pi->height;
+ codec_data->frame_width = ((pi->width + 15) / 16) * 16;
+ codec_data->frame_height = ((pi->height + 15) / 16) * 16;
+
+ codec_data->refresh_alt_frame = pi->refresh_af;
+ codec_data->refresh_golden_frame = pi->refresh_gf;
+ codec_data->refresh_last_frame = pi->refresh_lf;
+
+ codec_data->golden_copied = pi->golden_copied;
+ codec_data->altref_copied = pi->altref_copied;
+}
+
+static uint32_t vbp_add_pic_data_vp8(vp8_viddec_parser *parser, vbp_data_vp8 *query_data)
+{
+ vp8_Info *pi = &(parser->info);
+ query_data->num_pictures++;
+
+ if (query_data->num_pictures > 1)
+ {
+ ETRACE("Num of pictures (%d) per sample buffer exceeds the limit %d.", query_data->num_pictures, VP8_MAX_NUM_PICTURES);
+ return VBP_DATA;
+ }
+
+ int i = 0;
+ int pic_data_index = query_data->num_pictures - 1;
+ if (pic_data_index < 0)
+ {
+ ETRACE("MB address does not start from 0!");
+ return VBP_DATA;
+ }
+
+ vbp_picture_data_vp8 *pic_data = &(query_data->pic_data[pic_data_index]);
+ VAPictureParameterBufferVP8 *pic_parms = pic_data->pic_parms;
+
+ pic_parms->frame_width = pi->width;
+ pic_parms->frame_height = pi->height;
+
+ pic_parms->pic_fields.value = 0;
+ pic_parms->pic_fields.bits.key_frame = pi->frame_tag.frame_type;
+ pic_parms->pic_fields.bits.version = pi->frame_tag.version;
+ pic_parms->partition_size[0] = pi->frame_tag.first_part_size;
+
+ /* Segmentation */
+ pic_parms->pic_fields.bits.segmentation_enabled = pi->Segmentation.Enabled;
+ pic_parms->pic_fields.bits.update_mb_segmentation_map = pi->Segmentation.UpdateMap;
+ pic_parms->pic_fields.bits.update_segment_feature_data = pi->Segmentation.UpdateData;
+ memcpy(pic_parms->mb_segment_tree_probs, pi->Segmentation.TreeProbs, sizeof(unsigned char) * MB_FEATURE_TREE_PROBS);
+
+ /* Loop filter data */
+ pic_parms->pic_fields.bits.filter_type = pi->LoopFilter.Type;
+ pic_parms->pic_fields.bits.sharpness_level = pi->LoopFilter.Sharpness;
+ pic_parms->pic_fields.bits.loop_filter_adj_enable = pi->LoopFilter.DeltaEnabled;
+ pic_parms->pic_fields.bits.mode_ref_lf_delta_update = pi->LoopFilter.DeltaUpdate;
+
+ int baseline_filter_level[MAX_MB_SEGMENTS];
+ if (pi->Segmentation.Enabled)
+ {
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ if (SEGMENT_ABSDATA == pi->Segmentation.AbsDelta)
+ {
+ baseline_filter_level[i] = pi->Segmentation.FeatureData[MB_LVL_ALT_LF][i];
+ }
+ else
+ {
+ baseline_filter_level[i] = pi->LoopFilter.Level + pi->Segmentation.FeatureData[MB_LVL_ALT_LF][i];
+ baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((baseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOOP_FILTER) : 0; /* Clamp to valid range */
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ baseline_filter_level[i] = pi->LoopFilter.Level;
+ }
+ }
+ for (i = 0; i < MAX_MB_SEGMENTS; i++)
+ {
+ pic_parms->loop_filter_level[i] = baseline_filter_level[i];
+ }
+ if ((pic_parms->pic_fields.bits.version == 0) || (pic_parms->pic_fields.bits.version == 1))
+ {
+ pic_parms->pic_fields.bits.loop_filter_disable = pic_parms->loop_filter_level[0] > 0 ? true : false;
+ }
+ memcpy(pic_parms->loop_filter_deltas_ref_frame, pi->LoopFilter.DeltasRef, sizeof(char) * MAX_REF_LF_DELTAS);
+ memcpy(pic_parms->loop_filter_deltas_mode, pi->LoopFilter.DeltasMode, sizeof(char) * MAX_MODE_LF_DELTAS);
+
+ pic_parms->pic_fields.bits.sign_bias_golden = pi->sign_bias_golden;
+ pic_parms->pic_fields.bits.sign_bias_alternate = pi->sign_bias_alternate;
+
+ pic_parms->pic_fields.bits.mb_no_coeff_skip = pi->mb_no_coeff_skip;
+ pic_parms->pic_fields.bits.mb_skip_coeff = pi->mb_skip_coeff;
+
+
+ /* Token Partitions */
+ pic_parms->num_of_partitions = pi->partition_count;
+ for (i = 1; i < 9; i++)
+ {
+ pic_parms->partition_size[i] = pi->partition_size[i - 1];
+ }
+
+ pic_parms->prob_skip_false = pi->prob_skip_false;
+ pic_parms->prob_intra = pi->prob_intra;
+ pic_parms->prob_last = pi->prob_lf;
+ pic_parms->prob_gf = pi->prob_gf;
+
+ FrameContextData *fc = &(parser->info.FrameContext);
+ memcpy(pic_parms->y_mode_probs, fc->Y_Mode_Prob, sizeof(unsigned char) * 4);
+ memcpy(pic_parms->uv_mode_probs, fc->UV_Mode_Prob, sizeof(unsigned char) * 3);
+ /* Motion vector context */
+ for (i = 0; i < 2; i++)
+ {
+ memcpy(pic_parms->mv_probs[i], fc->MVContext[i], sizeof(unsigned char) * 19);
+ }
+
+ /* Bool coder */
+ pic_parms->bool_coder_ctx.range = pi->bool_coder.range;
+ pic_parms->bool_coder_ctx.value = pi->bool_coder.value;
+ pic_parms->bool_coder_ctx.count = pi->bool_coder.count;
+
+ //pic_parms->current_picture = VA_INVALID_SURFACE;
+ pic_parms->last_ref_frame = VA_INVALID_SURFACE;
+ pic_parms->golden_ref_frame = VA_INVALID_SURFACE;
+ pic_parms->alt_ref_frame = VA_INVALID_SURFACE;
+ pic_parms->out_of_loop_frame = VA_INVALID_SURFACE; //Reserved for future use
+
+ /* the offset to the first bit of MB from the first byte of slice data */
+ pic_parms->macroblock_offset = pi->header_bits;
+
+ /* specify the slice number */
+ pic_data->num_slices = 0;
+
+ return VBP_OK;
+}
+
+static uint32_t vbp_add_slice_data_vp8(vp8_viddec_parser *parser, vbp_data_vp8 *query_data)
+{
+ vp8_Info *pi = &(parser->info);
+ uint32_t pic_index = query_data->num_pictures - 1;
+ if (pic_index < 0)
+ {
+ ETRACE("Invalid picture data index.");
+ return VBP_DATA;
+ }
+
+ vbp_picture_data_vp8 *pic_data = &(query_data->pic_data[pic_index]);
+ vbp_slice_data_vp8 *slc_data = &(pic_data->slc_data[pic_data->num_slices]);
+
+ slc_data->buffer_addr = pi->source;
+ slc_data->slice_offset = 0;
+ slc_data->slice_size = pi->source_sz;
+
+ VASliceParameterBufferBase *slc_parms = &(slc_data->slc_parms);
+ /* number of bytes in the slice data buffer for this slice */
+ slc_parms->slice_data_size = slc_data->slice_size;
+
+ /* the offset to the first byte of slice data */
+ slc_parms->slice_data_offset = 0;
+
+ /* see VA_SLICE_DATA_FLAG_XXX definitions */
+ slc_parms->slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
+
+ pic_data->num_slices++;
+ if (pic_data->num_slices > VP8_MAX_NUM_SLICES) {
+ ETRACE("Number of slices (%d) per picture exceeds the limit (%d).", pic_data->num_slices, VP8_MAX_NUM_SLICES);
+ return VBP_DATA;
+ }
+ return VBP_OK;
+}
+
+/*
+*
+* fill query data structure after sample buffer is parsed
+*
+*/
+uint32 vbp_populate_query_data_vp8(vbp_context *pcontext)
+{
+ int32_t error = VBP_OK;
+
+ vbp_data_vp8 *query_data = NULL;
+ vp8_viddec_parser *parser = NULL;
+
+ parser = (vp8_viddec_parser *)pcontext->parser_cxt->codec_data;
+ query_data = (vbp_data_vp8 *)pcontext->query_data;
+
+ /* buffer number */
+ query_data->buf_number = buffer_counter;
+
+ /* Populate picture data */
+ error = vbp_add_pic_data_vp8(parser, query_data);
+
+ /* Populate slice data */
+ if (error == VBP_OK)
+ {
+ error = vbp_add_slice_data_vp8(parser, query_data);
+ if (error != VBP_OK)
+ return error;
+ }
+
+ /* Populate codec data */
+ vbp_set_codec_data_vp8(parser, query_data->codec_data);
+
+ /* Populate probability table */
+ vbp_add_probs_data_vp8(parser, query_data);
+
+ /* Populate quantization */
+ vbp_add_quantization_data_vp8(parser, query_data);
+
+ return VBP_OK;
+}
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.h b/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.h
new file mode 100644
index 0000000..3b6407e
--- /dev/null
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_vp8_parser.h
@@ -0,0 +1,67 @@
+/* INTEL CONFIDENTIAL
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
+*
+* The source code contained or described herein and all documents
+* related to the source code ("Material") are owned by Intel
+* Corporation or its suppliers or licensors. Title to the
+* Material remains with Intel Corporation or its suppliers and
+* licensors. The Material contains trade secrets and proprietary
+* and confidential information of Intel or its suppliers and
+* licensors. The Material is protected by worldwide copyright and
+* trade secret laws and treaty provisions. No part of the Material
+* may be used, copied, reproduced, modified, published, uploaded,
+* posted, transmitted, distributed, or disclosed in any way without
+* Intel's prior express written permission.
+*
+* No license under any patent, copyright, trade secret or other
+* intellectual property right is granted to or conferred upon you
+* by disclosure or delivery of the Materials, either expressly, by
+* implication, inducement, estoppel or otherwise. Any license
+* under such intellectual property rights must be express and
+* approved by Intel in writing.
+*
+*/
+
+
+#ifndef VBP_VP8_PARSER_H
+#define VBP_VP8_PARSER_H
+
+/*
+ * setup parser's entry points
+ */
+uint32 vbp_init_parser_entries_vp8(vbp_context *pcontext);
+
+/*
+ * allocate query data
+ */
+uint32 vbp_allocate_query_data_vp8(vbp_context *pcontext);
+
+/*
+ * free query data
+ */
+uint32 vbp_free_query_data_vp8(vbp_context *pcontext);
+
+/*
+ * parse initialization data
+ */
+uint32 vbp_parse_init_data_vp8(vbp_context *pcontext);
+
+/*
+ * parse start code. Only support lenght prefixed mode. Start
+ * code prefixed is not supported.
+ */
+uint32 vbp_parse_start_code_vp8(vbp_context *pcontext);
+
+/*
+ * process parsing result
+ */
+uint32 vbp_process_parsing_result_vp8(vbp_context *pcontext, int list_index);
+
+/*
+ * query parsing result
+ */
+uint32 vbp_populate_query_data_vp8(vbp_context *pcontext);
+
+
+
+#endif /*VBP_VP8_PARSER_H*/
diff --git a/videodecoder/Android.mk b/videodecoder/Android.mk
index 26fa709..5bde2ce 100644
--- a/videodecoder/Android.mk
+++ b/videodecoder/Android.mk
@@ -8,7 +8,6 @@
VideoDecoderWMV.cpp \
VideoDecoderMPEG4.cpp \
VideoDecoderAVC.cpp \
- VideoDecoderVP8.cpp \
VideoDecoderPAVC.cpp \
VideoDecoderAVCSecure.cpp \
VideoDecoderTrace.cpp
@@ -45,4 +44,14 @@
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva_videodecoder
+# Add source codes for Merrifield
+MERRIFIELD_PRODUCT := \
+ mrfl_vp \
+ mrfl_hvp \
+ mrfl_sle
+ifneq ($(filter $(TARGET_PRODUCT),$(MERRIFIELD_PRODUCT)),)
+LOCAL_SRC_FILES += VideoDecoderVP8.cpp
+LOCAL_CFLAGS += -DUSE_HW_VP8
+endif
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/videodecoder/VideoDecoderHost.cpp b/videodecoder/VideoDecoderHost.cpp
index 4e6b1b4..f990fa6 100644
--- a/videodecoder/VideoDecoderHost.cpp
+++ b/videodecoder/VideoDecoderHost.cpp
@@ -27,6 +27,9 @@
#include "VideoDecoderAVC.h"
#include "VideoDecoderPAVC.h"
#include "VideoDecoderAVCSecure.h"
+#ifdef USE_HW_VP8
+#include "VideoDecoderVP8.h"
+#endif
#include "VideoDecoderHost.h"
#include "VideoDecoderTrace.h"
#include <string.h>
@@ -57,7 +60,15 @@
} else if (strcasecmp(mimeType, "video/avc-secure") == 0) {
VideoDecoderAVC *p = new VideoDecoderAVCSecure(mimeType);
return (IVideoDecoder *)p;
- } else {
+ }
+#ifdef USE_HW_VP8
+ else if (strcasecmp(mimeType, "video/vp8") == 0 ||
+ strcasecmp(mimeType, "video/x-vnd.on2.vp8") == 0) {
+ VideoDecoderVP8 *p = new VideoDecoderVP8(mimeType);
+ return (IVideoDecoder *)p;
+ }
+#endif
+ else {
ETRACE("Unknown mime type: %s", mimeType);
}
return NULL;
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index 0329c2a..bc6274c 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -1,5 +1,5 @@
/* INTEL CONFIDENTIAL
-* Copyright (c) 2009 Intel Corporation. All rights reserved.
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
*
* The source code contained or described herein and all documents
* related to the source code ("Material") are owned by Intel
@@ -27,31 +27,80 @@
#include <string.h>
VideoDecoderVP8::VideoDecoderVP8(const char *mimeType)
- : VideoDecoderBase(mimeType, (_vbp_parser_type)VBP_INVALID) {
+ : VideoDecoderBase(mimeType, VBP_VP8) {
+ invalidateReferenceFrames(0);
+ invalidateReferenceFrames(1);
}
VideoDecoderVP8::~VideoDecoderVP8() {
stop();
}
+void VideoDecoderVP8::invalidateReferenceFrames(int toggle) {
+ ReferenceFrameBuffer *p = mRFBs[toggle];
+ for (int i = 0; i < VP8_REF_SIZE; i++) {
+ p->index = (uint32_t) -1;
+ p->surfaceBuffer = NULL;
+ p++;
+ }
+}
+
+void VideoDecoderVP8::updateFormatInfo(vbp_data_vp8 *data) {
+ int32_t width = data->codec_data->frame_width;
+ int32_t height = data->codec_data->frame_height;
+ ITRACE("updateFormatInfo: current size: %d x %d, new size: %d x %d",
+ mVideoFormatInfo.width, mVideoFormatInfo.height, width, height);
+
+ if ((mVideoFormatInfo.width != width ||
+ mVideoFormatInfo.height != height) &&
+ width && height) {
+ mVideoFormatInfo.width = width;
+ mVideoFormatInfo.height = height;
+ mSizeChanged = true;
+ ITRACE("Video size is changed.");
+ }
+
+ mVideoFormatInfo.valid = true;
+}
+
+Decode_Status VideoDecoderVP8::startVA(vbp_data_vp8 *data) {
+ updateFormatInfo(data);
+
+ VAProfile vaProfile = VAProfileVP8Version0_3;
+ if (data->codec_data->version_num > 3) {
+ return DECODE_PARSER_FAIL;
+ }
+
+ return VideoDecoderBase::setupVA(VP8_SURFACE_NUMBER + VP8_REF_SIZE, vaProfile);
+}
+
Decode_Status VideoDecoderVP8::start(VideoConfigBuffer *buffer) {
Decode_Status status;
status = VideoDecoderBase::start(buffer);
CHECK_STATUS("VideoDecoderBase::start");
- // config VP8 software decoder if necessary
- // TODO: update mVideoFormatInfo here
+ // We don't want base class to manage reference.
+ VideoDecoderBase::ManageReference(false);
- status = VideoDecoderBase::setupVA(
- VP8_SURFACE_NUMBER,
- (VAProfile)VAProfileSoftwareDecoding);
+ if (buffer->data == NULL || buffer->size == 0) {
+ WTRACE("No config data to start VA.");
+ return DECODE_SUCCESS;
+ }
+ vbp_data_vp8 *data = NULL;
+ status = VideoDecoderBase::parseBuffer(buffer->data, buffer->size, true, (void**)&data);
+ CHECK_STATUS("VideoDecoderBase::parseBuffer");
+
+ status = startVA(data);
return status;
}
void VideoDecoderVP8::stop(void) {
VideoDecoderBase::stop();
+
+ invalidateReferenceFrames(0);
+ invalidateReferenceFrames(1);
}
void VideoDecoderVP8::flush(void) {
@@ -60,21 +109,73 @@
Decode_Status VideoDecoderVP8::decode(VideoDecodeBuffer *buffer) {
Decode_Status status;
+ vbp_data_vp8 *data = NULL;
+ if (buffer == NULL) {
+ ETRACE("VideoDecodeBuffer is NULL.");
+ return DECODE_INVALID_DATA;
+ }
+
+ status = VideoDecoderBase::parseBuffer(
+ buffer->data,
+ buffer->size,
+ false,
+ (void**)&data);
+ CHECK_STATUS("VideoDecoderBase::parseBuffer");
+
+ if (!mVAStarted) {
+ status = startVA(data);
+ CHECK_STATUS("startVA");
+ }
+
+ status = decodeFrame(buffer, data);
+ CHECK_STATUS("decodeFrame");
+ if (mSizeChanged) {
+ mSizeChanged = false;
+ return DECODE_FORMAT_CHANGE;
+ }
+ return status;
+}
+
+Decode_Status VideoDecoderVP8::decodeFrame(VideoDecodeBuffer* buffer, vbp_data_vp8 *data) {
+ Decode_Status status;
+ mCurrentPTS = buffer->timeStamp;
+ if (0 == data->num_pictures || NULL == data->pic_data) {
+ WTRACE("Number of pictures is 0.");
+ return DECODE_SUCCESS;
+ }
+
+ if (data->codec_data->frame_type == VP8_SKIPPED_FRAME) {
+ // Do nothing for skip frame as the last frame will be rendered agian by natively
+ return DECODE_SUCCESS;
+ }
status = acquireSurfaceBuffer();
CHECK_STATUS("acquireSurfaceBuffer");
- // TODO: decode sample to mAcquiredBuffer->mappedAddr.
- // make sure decoded output is in NV12 format.
- // << add decoding codes here>>
-
-
// set referenceFrame to true if frame decoded is I/P frame, false otherwise.
- mAcquiredBuffer->referenceFrame = true;
+ int frameType = data->codec_data->frame_type;
+ mAcquiredBuffer->referenceFrame = (frameType == VP8_KEY_FRAME || frameType == VP8_INTER_FRAME);
// assume it is frame picture.
mAcquiredBuffer->renderBuffer.scanFormat = VA_FRAME_PICTURE;
mAcquiredBuffer->renderBuffer.timeStamp = buffer->timeStamp;
mAcquiredBuffer->renderBuffer.flag = 0;
+ if (buffer->flag & WANT_DECODE_ONLY) {
+ mAcquiredBuffer->renderBuffer.flag |= WANT_DECODE_ONLY;
+ }
+
+
+ // Here data->num_pictures is always equal to 1
+ for (int index = 0; index < data->num_pictures; index++) {
+ status = decodePicture(data, index);
+ if (status != DECODE_SUCCESS) {
+ endDecodingFrame(true);
+ return status;
+ }
+ }
+
+ if (frameType != VP8_SKIPPED_FRAME) {
+ updateReferenceFrames(data);
+ }
// if sample is successfully decoded, call outputSurfaceBuffer(); otherwise
// call releaseSurfacebuffer();
@@ -82,4 +183,216 @@
return status;
}
+Decode_Status VideoDecoderVP8::decodePicture(vbp_data_vp8 *data, int32_t picIndex) {
+ VAStatus vaStatus = VA_STATUS_SUCCESS;
+ Decode_Status status;
+ uint32_t bufferIDCount = 0;
+ VABufferID bufferIDs[5];
+
+ vbp_picture_data_vp8 *picData = &(data->pic_data[picIndex]);
+ VAPictureParameterBufferVP8 *picParams = picData->pic_parms;
+
+ status = setReference(picParams, picIndex);
+ CHECK_STATUS("setReference");
+
+ vaStatus = vaBeginPicture(mVADisplay, mVAContext, mAcquiredBuffer->renderBuffer.surface);
+ CHECK_VA_STATUS("vaBeginPicture");
+ // setting mDecodingFrame to true so vaEndPicture will be invoked to end the picture decoding.
+ mDecodingFrame = true;
+
+ vaStatus = vaCreateBuffer(
+ mVADisplay,
+ mVAContext,
+ VAPictureParameterBufferType,
+ sizeof(VAPictureParameterBufferVP8),
+ 1,
+ picParams,
+ &bufferIDs[bufferIDCount]);
+ CHECK_VA_STATUS("vaCreatePictureParameterBuffer");
+ bufferIDCount++;
+
+ vaStatus = vaCreateBuffer(
+ mVADisplay,
+ mVAContext,
+ VAProbabilityBufferType,
+ sizeof(VAProbabilityDataBufferVP8),
+ 1,
+ data->prob_data,
+ &bufferIDs[bufferIDCount]);
+ CHECK_VA_STATUS("vaCreateProbabilityBuffer");
+ bufferIDCount++;
+
+ vaStatus = vaCreateBuffer(
+ mVADisplay,
+ mVAContext,
+ VAIQMatrixBufferType,
+ sizeof(VAIQMatrixBufferVP8),
+ 1,
+ data->IQ_matrix_buf,
+ &bufferIDs[bufferIDCount]);
+ CHECK_VA_STATUS("vaCreateIQMatrixBuffer");
+ bufferIDCount++;
+
+ /* Here picData->num_slices is always equal to 1 */
+ for (uint32_t i = 0; i < picData->num_slices; i++) {
+ vaStatus = vaCreateBuffer(
+ mVADisplay,
+ mVAContext,
+ VASliceParameterBufferType,
+ sizeof(VASliceParameterBufferBase),
+ 1,
+ &(picData->slc_data[i].slc_parms),
+ &bufferIDs[bufferIDCount]);
+ CHECK_VA_STATUS("vaCreateSliceParameterBuffer");
+ bufferIDCount++;
+
+ vaStatus = vaCreateBuffer(
+ mVADisplay,
+ mVAContext,
+ VASliceDataBufferType,
+ picData->slc_data[i].slice_size, //size
+ 1, //num_elements
+ picData->slc_data[i].buffer_addr + picData->slc_data[i].slice_offset,
+ &bufferIDs[bufferIDCount]);
+ CHECK_VA_STATUS("vaCreateSliceDataBuffer");
+ bufferIDCount++;
+ }
+
+ vaStatus = vaRenderPicture(
+ mVADisplay,
+ mVAContext,
+ bufferIDs,
+ bufferIDCount);
+ CHECK_VA_STATUS("vaRenderPicture");
+
+ vaStatus = vaEndPicture(mVADisplay, mVAContext);
+ mDecodingFrame = false;
+ CHECK_VA_STATUS("vaEndPicture");
+
+ return DECODE_SUCCESS;
+}
+
+Decode_Status VideoDecoderVP8::setReference(VAPictureParameterBufferVP8 *picParam, int32_t picIndex) {
+ int frameType = picParam->pic_fields.bits.key_frame;
+ switch (frameType) {
+ case VP8_KEY_FRAME:
+ picParam->last_ref_frame = VA_INVALID_SURFACE;
+ picParam->alt_ref_frame = VA_INVALID_SURFACE;
+ picParam->golden_ref_frame = VA_INVALID_SURFACE;
+ break;
+ case VP8_INTER_FRAME:
+ if (mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer == NULL ||
+ mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer == NULL ||
+ mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer == NULL) {
+ return DECODE_NO_REFERENCE;
+ }
+ //mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer = mLastReference;
+ picParam->last_ref_frame = mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer->renderBuffer.surface;
+ picParam->alt_ref_frame = mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer->renderBuffer.surface;
+ picParam->golden_ref_frame = mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer->renderBuffer.surface;
+ break;
+ case VP8_SKIPPED_FRAME:
+ // will never happen here
+ break;
+ default:
+ return DECODE_PARSER_FAIL;
+ }
+
+ return DECODE_SUCCESS;
+}
+
+void VideoDecoderVP8::updateReferenceFrames(vbp_data_vp8 *data) {
+ /* Refresh last frame reference buffer using the currently reconstructed frame */
+ refreshLastReference(data);
+
+ /* Refresh golden frame reference buffer using the currently reconstructed frame */
+ refreshGoldenReference(data);
+
+ /* Refresh alternative frame reference buffer using the currently reconstructed frame */
+ refreshAltReference(data);
+}
+
+void VideoDecoderVP8::refreshLastReference(vbp_data_vp8 *data) {
+ /* Save previous last reference */
+ mRFBs[1][VP8_LAST_REF_PIC].surfaceBuffer = mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer;
+ mRFBs[1][VP8_LAST_REF_PIC].index = mRFBs[0][VP8_LAST_REF_PIC].index;
+
+ /* For key frame, this is always true */
+ if (data->codec_data->refresh_last_frame) {
+ mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer = mAcquiredBuffer;
+ mRFBs[0][VP8_LAST_REF_PIC].index = mAcquiredBuffer->renderBuffer.surface;
+
+ if (mRFBs[1][VP8_LAST_REF_PIC].surfaceBuffer) {
+ mRFBs[1][VP8_LAST_REF_PIC].surfaceBuffer->asReferernce = false;
+ }
+ }
+
+ if (mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer) {
+ mRFBs[0][VP8_LAST_REF_PIC].surfaceBuffer->asReferernce = true;
+ }
+}
+
+void VideoDecoderVP8::refreshGoldenReference(vbp_data_vp8 *data) {
+ /* Save previous golden reference */
+ mRFBs[1][VP8_GOLDEN_REF_PIC].surfaceBuffer = mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer;
+ mRFBs[1][VP8_GOLDEN_REF_PIC].index = mRFBs[0][VP8_GOLDEN_REF_PIC].index;
+
+ if (data->codec_data->golden_copied != BufferCopied_NoneToGolden) {
+ if (data->codec_data->golden_copied == BufferCopied_LastToGolden) {
+ /* LastFrame is copied to GoldenFrame */
+ mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer = mRFBs[1][VP8_LAST_REF_PIC].surfaceBuffer;
+ mRFBs[0][VP8_GOLDEN_REF_PIC].index = mRFBs[1][VP8_LAST_REF_PIC].index;
+ } else if (data->codec_data->golden_copied == BufferCopied_AltRefToGolden) {
+ /* AltRefFrame is copied to GoldenFrame */
+ mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer = mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer;
+ mRFBs[0][VP8_GOLDEN_REF_PIC].index = mRFBs[0][VP8_ALT_REF_PIC].index;
+ }
+ }
+
+ /* For key frame, this is always true */
+ if (data->codec_data->refresh_golden_frame) {
+ mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer = mAcquiredBuffer;
+ mRFBs[0][VP8_GOLDEN_REF_PIC].index = mAcquiredBuffer->renderBuffer.surface;
+
+ if (mRFBs[1][VP8_GOLDEN_REF_PIC].surfaceBuffer) {
+ mRFBs[1][VP8_GOLDEN_REF_PIC].surfaceBuffer->asReferernce = false;
+ }
+ }
+
+ if (mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer) {
+ mRFBs[0][VP8_GOLDEN_REF_PIC].surfaceBuffer->asReferernce = true;
+ }
+}
+
+void VideoDecoderVP8::refreshAltReference(vbp_data_vp8 *data) {
+ /* Save previous alternative reference */
+ mRFBs[1][VP8_ALT_REF_PIC].surfaceBuffer = mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer;
+ mRFBs[1][VP8_ALT_REF_PIC].index = mRFBs[0][VP8_ALT_REF_PIC].index;
+
+ if (data->codec_data->altref_copied != BufferCopied_NoneToAltRef) {
+ if (data->codec_data->altref_copied == BufferCopied_LastToAltRef) {
+ /* LastFrame is copied to AltRefFrame */
+ mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer = mRFBs[1][VP8_LAST_REF_PIC].surfaceBuffer;
+ mRFBs[0][VP8_ALT_REF_PIC].index = mRFBs[1][VP8_LAST_REF_PIC].index;
+ } else if (data->codec_data->altref_copied == BufferCopied_GoldenToAltRef) {
+ /* GoldenFrame is copied to AltRefFrame */
+ mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer = mRFBs[1][VP8_GOLDEN_REF_PIC].surfaceBuffer;
+ mRFBs[0][VP8_ALT_REF_PIC].index = mRFBs[1][VP8_GOLDEN_REF_PIC].index;
+ }
+ }
+
+ /* For key frame, this is always true */
+ if (data->codec_data->refresh_alt_frame) {
+ mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer = mAcquiredBuffer;
+ mRFBs[0][VP8_ALT_REF_PIC].index = mAcquiredBuffer->renderBuffer.surface;
+
+ if (mRFBs[1][VP8_ALT_REF_PIC].surfaceBuffer) {
+ mRFBs[1][VP8_ALT_REF_PIC].surfaceBuffer->asReferernce = false;
+ }
+ }
+
+ if (mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer) {
+ mRFBs[0][VP8_ALT_REF_PIC].surfaceBuffer->asReferernce = true;
+ }
+}
diff --git a/videodecoder/VideoDecoderVP8.h b/videodecoder/VideoDecoderVP8.h
index 676bd1a..f3b64e9 100644
--- a/videodecoder/VideoDecoderVP8.h
+++ b/videodecoder/VideoDecoderVP8.h
@@ -1,5 +1,5 @@
/* INTEL CONFIDENTIAL
-* Copyright (c) 2009 Intel Corporation. All rights reserved.
+* Copyright (c) 2012 Intel Corporation. All rights reserved.
*
* The source code contained or described herein and all documents
* related to the source code ("Material") are owned by Intel
@@ -38,11 +38,56 @@
virtual void flush(void);
virtual Decode_Status decode(VideoDecodeBuffer *buffer);
+private:
+ Decode_Status decodeFrame(VideoDecodeBuffer* buffer, vbp_data_vp8 *data);
+ Decode_Status decodePicture(vbp_data_vp8 *data, int32_t picIndex);
+ Decode_Status setReference(VAPictureParameterBufferVP8 *picParam, int32_t picIndex);
+ Decode_Status startVA(vbp_data_vp8 *data);
+ void updateReferenceFrames(vbp_data_vp8 *data);
+ void refreshLastReference(vbp_data_vp8 *data);
+ void refreshGoldenReference(vbp_data_vp8 *data);
+ void refreshAltReference(vbp_data_vp8 *data);
+ void updateFormatInfo(vbp_data_vp8 *data);
+ void invalidateReferenceFrames(int toggle);
private:
enum {
- VP8_SURFACE_NUMBER = 10,
+ VP8_SURFACE_NUMBER = 9,
+ VP8_REF_SIZE = 3,
};
+
+ enum {
+ VP8_KEY_FRAME = 0,
+ VP8_INTER_FRAME,
+ VP8_SKIPPED_FRAME,
+ };
+
+ enum {
+ VP8_LAST_REF_PIC = 0,
+ VP8_GOLDEN_REF_PIC,
+ VP8_ALT_REF_PIC,
+ };
+
+ enum {
+ BufferCopied_NoneToGolden = 0,
+ BufferCopied_LastToGolden = 1,
+ BufferCopied_AltRefToGolden = 2
+ };
+
+ enum {
+ BufferCopied_NoneToAltRef = 0,
+ BufferCopied_LastToAltRef = 1,
+ BufferCopied_GoldenToAltRef = 2
+ };
+
+ struct ReferenceFrameBuffer {
+ VideoSurfaceBuffer *surfaceBuffer;
+ int32_t index;
+ };
+
+ //[2] : [0 for current each reference frame, 1 for the previous each reference frame]
+ //[VP8_REF_SIZE] : [0 for last ref pic, 1 for golden ref pic, 2 for alt ref pic]
+ ReferenceFrameBuffer mRFBs[2][VP8_REF_SIZE];
};