From e92903ca30b87b731981a34dcfc55f52d6918f63 Mon Sep 17 00:00:00 2001 From: Jonathan Bian Date: Wed, 10 Apr 2013 16:26:37 -0700 Subject: Added support for VP8 encoding. --- va/Android.mk | 1 + va/Makefile.am | 1 + va/va.h | 1 + va/va_enc_vp8.h | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 va/va_enc_vp8.h diff --git a/va/Android.mk b/va/Android.mk index 5e260d4..75c938f 100755 --- a/va/Android.mk +++ b/va/Android.mk @@ -67,6 +67,7 @@ LOCAL_COPY_HEADERS := \ va_drmcommon.h \ va_enc.h \ va_enc_h264.h \ + va_enc_vp8.h \ va_enc_mpeg2.h \ va_version.h \ va_vpp.h diff --git a/va/Makefile.am b/va/Makefile.am index 58c7629..cccc5cd 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -46,6 +46,7 @@ libva_source_h = \ va_dec_vp8.h \ va_drmcommon.h \ va_enc_h264.h \ + va_enc_vp8.h \ va_enc_mpeg2.h \ va_tpi.h \ va_version.h \ diff --git a/va/va.h b/va/va.h index 7b21681..3702553 100644 --- a/va/va.h +++ b/va/va.h @@ -910,6 +910,7 @@ typedef enum VAEncPackedHeaderDataBufferType = 26, VAEncMiscParameterBufferType = 27, VAEncMacroblockParameterBufferType = 28, + VAEncMacroblockMapBufferType = 29, /* Following are video processing buffer types */ /** * \brief Video processing pipeline parameter buffer. diff --git a/va/va_enc_vp8.h b/va/va_enc_vp8.h new file mode 100644 index 0000000..31dfe3e --- /dev/null +++ b/va/va_enc_vp8.h @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file va_enc_vp8.h + * \brief VP8 encoding API + * + * This file contains the \ref api_enc_vp8 "VP8 encoding API". + */ + +#ifndef VA_ENC_VP8_H +#define VA_ENC_VP8_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup api_enc_vp8 VP8 encoding API + * + * @{ + */ + +/** + * \brief VP8 Encoding Sequence Parameter Buffer Structure + * + * This structure conveys sequence level parameters. + * + */ +typedef struct _VAEncSequenceParameterBufferVP8 +{ + /* frame width in pixels */ + unsigned int frame_width; + /* frame height in pixels */ + unsigned int frame_height; + /* frame rate */ + unsigned int frame_rate; + /* whether to enable error resilience features */ + unsigned int error_resilient; + /* auto keyframe placement, non-zero means enable auto keyframe placement */ + unsigned int kf_auto; + /* keyframe minimum interval */ + unsigned int kf_min_dist; + /* keyframe maximum interval */ + unsigned int kf_max_dist; + + + /* RC related fields. RC modes are set with VAConfigAttribRateControl */ + /* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */ + + /* target bit-rate */ + unsigned int bits_per_second; + /* min QP */ + unsigned int min_qp; + /* max QP */ + unsigned int max_qp; + /* RC undershoot percentage */ + unsigned int rc_undershoot; + /* RC overshoot percentage */ + unsigned int rc_overshoot; + /* HRD buffer size */ + unsigned int hrd_buf_size; + /* HRD buffer initial fullness */ + unsigned int hrd_buf_initial_fullness; + /* HRD buffer optimal fullness */ + unsigned int hrd_buf_optimal_fullness; + + /* up to 3 modes are honored, quality (1), normal (2) and performance (3) */ + unsigned char target_usage; + /* only valid for avbr mode */ + unsigned int user_max_frame_size; + /** + * min number of frames for bit rate to converge. + * value should be >= 100. used for avbr mode + */ + unsigned int avbr_convergence; + + /* reference and reconstructed frame buffers*/ + VASurfaceID reference_frames[4]; + +} VAEncSequenceParameterBufferVP8; + + +/** + * \brief VP8 Encoding Picture Parameter Buffer Structure + * + * This structure conveys picture level parameters. + * + */ +typedef struct _VAEncPictureParameterBufferVP8 +{ + /* surface to store reconstructed frame */ + VASurfaceID reconstructed_frame; + + /* buffer to store coded data */ + VABufferID coded_buf; + + union { + struct { + /* force this frame to be a keyframe */ + unsigned int force_kf : 1; + /* don't reference the last frame */ + unsigned int no_ref_last : 1; + /* don't reference the golden frame */ + unsigned int no_ref_gf : 1; + /* don't reference the alternate reference frame */ + unsigned int no_ref_arf : 1; + /* 0: bicubic, 1: bilinear, other: none */ + unsigned int recon_filter_type : 2; + /* 0: no loop fitler, 1: simple loop filter */ + unsigned int loop_filter_type : 2; + /* 0: disabled, 1: normal, 2: simple */ + unsigned int auto_partitions : 1; + /* number of token partitions */ + unsigned int num_token_partitions : 2; + + /** + * The following fields correspond to the same VP8 syntax elements + * in the frame header. + */ + /** + * 0: clamping of reconstruction pixels is disabled, + * 1: clamping enabled. + */ + unsigned int clamping_type : 1; + /* indicate segmentation is enabled for the current frame. */ + unsigned int segmentation_enabled : 1; + /** + * Determines if the MB segmentation map is updated in the current + * frame. + */ + unsigned int update_mb_segmentation_map : 1; + /** + * Indicates if the segment feature data is updated in the current + * frame. + */ + unsigned int update_segment_feature_data : 1; + /** + * indicates if the MB level loop filter adjustment is enabled for + * the current frame (0 off, 1 on). + */ + unsigned int loop_filter_adj_enable : 1; + /** + * Determines whether updated token probabilities are used only for + * this frame or until further update. + * It may be used by application to enable error resilient mode. + * In this mode probability updates are allowed only at Key Frames. + */ + unsigned int refresh_entropy_probs : 1; + /** + * Determines if the current decoded frame refreshes the golden frame. + */ + unsigned int refresh_golden_frame : 1; + /** + * Determines if the current decoded frame refreshes the alternate + * reference frame. + */ + unsigned int refresh_alternate_frame : 1; + /** + * Determines if the current decoded frame refreshes the last frame + * reference buffer. + */ + unsigned int refresh_last : 1; + /** + * Determines if the golden reference is replaced by another reference. + */ + unsigned int copy_buffer_to_golden : 2; + /** + * Determines if the alternate reference is replaced by another reference. + */ + unsigned int copy_buffer_to_alternate : 2; + /** + * Controls the sign of motion vectors when the golden frame is referenced. + */ + unsigned int sign_bias_golden : 1; + /** + * Controls the sign of motion vectors when the alternate frame is + * referenced. + */ + unsigned int sign_bias_alternate : 1; + /** + * Enables or disables the skipping of macroblocks containing no + * non-zero coefficients. + */ + unsigned int mb_no_coeff_skip : 1; + /** + * Enforces unconditional per-MB loop filter delta update setting frame + * header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4], + * and all ref_frame_delta_update_flag[4] to 1. + * Since loop filter deltas are not automatically refreshed to default + * values at key frames, dropped frame with delta update may prevent + * correct decoding from the next key frame. + * Encoder application is advised to set this flag to 1 at key frames. + */ + unsigned int forced_lf_adjustment : 1; + unsigned int reserved : 4; + } bits; + unsigned int value; + } pic_flags; + + /* quality setting, equivalent to VP8E_SET_CPUUSED */ + unsigned int quality_setting; + + /** + * Contains a list of 4 loop filter level values (updated value if applicable) + * controlling the deblocking filter strength. Each entry represents a segment. + * When segmentation is disabled, use entry 0. + * When loop_filter_level is 0, loop filter shall be disabled. + */ + char loop_filter_level[4]; + + /** + * Contains a list of 4 delta values for reference frame based MB-level + * loop filter adjustment. + * If no update, then set to 0. + */ + char ref_lf_delta[4]; + + /** + * Contains a list of 4 delta values for coding mode based MB-level loop + * filter adjustment. + * If no update, then set to 0. + */ + char mode_lf_delta[4]; + + /** + * Controls the deblocking filter sensitivity. + * Corresponds to the same VP8 syntax element in frame header. + */ + unsigned char sharpness_level; + + /** + * Application supplied maximum clamp value for Qindex used in quantization. + * Qindex will not be allowed to exceed this value. + * It has a valid range [0..127] inclusive. + */ + unsigned char clamp_qindex_high; + + /** + * Application supplied minimum clamp value for Qindex used in quantization. + * Qindex will not be allowed to be lower than this value. + * It has a valid range [0..127] inclusive. + * Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed, + * otherwise they are ignored. + */ + unsigned char clamp_qindex_low; + +} VAEncPictureParameterBufferVP8; + + +/** + * \brief VP8 MB Segmentation ID Buffer + * + * application provides buffer containing the initial segmentation id for each + * MB, in raster scan order. Rate control may reassign it. + * For an 640x480 video, the buffer has 1200 entries. + * the value of each entry should be in the range [0..3], inclusive. + * If segmentation is not enabled, application does not need to provide it. + */ +typedef struct _VAEncMBMapBufferVP8 +{ + /** + * number of MBs in the frame. + * It is also the number of entries of mb_segment_id[]; + */ + unsigned int num_mbs; + /** + * per MB Segmentation ID Buffer + */ + unsigned char *mb_segment_id; +} VAEncMBMapBufferVP8; + + +/** + * \brief VP8 Quantization Matrix Buffer Structure + * + * Contains quantization indices for yac(0),ydc(1),y2dc(2),y2ac(3),uvdc(4), + * uvac(5) for each segment (0-3). When segmentation is disabled, only + * quantization_index[0][] will be used. This structure is sent once per frame. + */ +typedef struct _VAQMatrixBufferVP8 +{ + /* + * array first dimensional is segment and 2nd dimensional is Q index + */ + unsigned short quantization_index[4][6]; +} VAQMatrixBufferVP8; + + + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* VA_ENC_VP8_H */ -- cgit v1.2.1