static void
intel_mfc_bit_rate_control_context_init(struct encode_state *encode_state,
- struct gen6_mfc_context *mfc_context)
+ struct intel_encoder_context *encoder_context)
{
- VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
- int width_in_mbs = pSequenceParameter->picture_width_in_mbs;
- int height_in_mbs = pSequenceParameter->picture_height_in_mbs;
- float fps = pSequenceParameter->time_scale * 0.5 / pSequenceParameter->num_units_in_tick ;
- int inter_mb_size = pSequenceParameter->bits_per_second * 1.0 / (fps+4.0) / width_in_mbs / height_in_mbs;
- int intra_mb_size = inter_mb_size * 5.0;
+ struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
int i;
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].target_mb_size = intra_mb_size;
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].target_frame_size = intra_mb_size * width_in_mbs * height_in_mbs;
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].target_mb_size = inter_mb_size;
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].target_frame_size = inter_mb_size * width_in_mbs * height_in_mbs;
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].target_mb_size = inter_mb_size;
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].target_frame_size = inter_mb_size * width_in_mbs * height_in_mbs;
-
for(i = 0 ; i < 3; i++) {
- mfc_context->bit_rate_control_context[i].QpPrimeY = 26;
mfc_context->bit_rate_control_context[i].MaxQpNegModifier = 6;
mfc_context->bit_rate_control_context[i].MaxQpPosModifier = 6;
mfc_context->bit_rate_control_context[i].GrowInit = 6;
mfc_context->bit_rate_control_context[i].Correct[4] = 4;
mfc_context->bit_rate_control_context[i].Correct[5] = 8;
}
-
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord = (intra_mb_size + 16)/ 16;
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord = (inter_mb_size + 16)/ 16;
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].TargetSizeInWord = (inter_mb_size + 16)/ 16;
-
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord = mfc_context->bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord * 1.5;
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].MaxSizeInWord = mfc_context->bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord * 1.5;
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].MaxSizeInWord = mfc_context->bit_rate_control_context[SLICE_TYPE_B].TargetSizeInWord * 1.5;
}
static void intel_mfc_brc_init(struct encode_state *encode_state,
struct intel_encoder_context* encoder_context)
{
struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
- VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
- VAEncMiscParameterBuffer* pMiscParamHRD = NULL;
- VAEncMiscParameterHRD* pParameterHRD = NULL;
- double bitrate = pSequenceParameter->bits_per_second;
- double framerate = (double)pSequenceParameter->time_scale /(2 * (double)pSequenceParameter->num_units_in_tick);
- int inum = 1, pnum = 0, bnum = 0; /* Gop structure: number of I, P, B frames in the Gop. */
- int intra_period = pSequenceParameter->intra_period;
- int ip_period = pSequenceParameter->ip_period;
- double qp1_size = 0.1 * 8 * 3 * (pSequenceParameter->picture_width_in_mbs<<4) * (pSequenceParameter->picture_height_in_mbs<<4)/2;
- double qp51_size = 0.001 * 8 * 3 * (pSequenceParameter->picture_width_in_mbs<<4) * (pSequenceParameter->picture_height_in_mbs<<4)/2;
+ double bitrate = encoder_context->brc.bits_per_second[0];
+ double framerate = (double)encoder_context->brc.framerate_per_100s[0] / 100.0;
+ int inum = encoder_context->brc.num_iframes_in_gop,
+ pnum = encoder_context->brc.num_pframes_in_gop,
+ bnum = encoder_context->brc.num_bframes_in_gop; /* Gop structure: number of I, P, B frames in the Gop. */
+ int intra_period = encoder_context->brc.gop_size;
+ double qp1_size = 0.1 * 8 * 3 * encoder_context->frame_width_in_pixel * encoder_context->frame_height_in_pixel / 2;
+ double qp51_size = 0.001 * 8 * 3 * encoder_context->frame_width_in_pixel * encoder_context->frame_height_in_pixel / 2;
double bpf;
+ int i;
- if (!encode_state->misc_param[VAEncMiscParameterTypeHRD] || !encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer)
- return;
-
- pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer;
- pParameterHRD = (VAEncMiscParameterHRD*)pMiscParamHRD->data;
+ mfc_context->brc.mode = encoder_context->rate_control_mode;
- if (pSequenceParameter->ip_period) {
- pnum = (intra_period + ip_period - 1)/ip_period - 1;
- bnum = intra_period - inum - pnum;
+ for (i = 0; i < 3; i++) {
+ mfc_context->brc.qp_prime_y[i] = 26;
}
- mfc_context->brc.mode = encoder_context->rate_control_mode;
-
mfc_context->brc.target_frame_size[SLICE_TYPE_I] = (int)((double)((bitrate * intra_period)/framerate) /
(double)(inum + BRC_PWEIGHT * pnum + BRC_BWEIGHT * bnum));
mfc_context->brc.target_frame_size[SLICE_TYPE_P] = BRC_PWEIGHT * mfc_context->brc.target_frame_size[SLICE_TYPE_I];
bpf = mfc_context->brc.bits_per_frame = bitrate/framerate;
- mfc_context->hrd.buffer_size = (double)pParameterHRD->buffer_size;
+ mfc_context->hrd.buffer_size = encoder_context->brc.hrd_buffer_size;
mfc_context->hrd.current_buffer_fullness =
- (double)(pParameterHRD->initial_buffer_fullness < mfc_context->hrd.buffer_size)?
- pParameterHRD->initial_buffer_fullness: mfc_context->hrd.buffer_size/2.;
+ (double)(encoder_context->brc.hrd_initial_buffer_fullness < mfc_context->hrd.buffer_size) ?
+ encoder_context->brc.hrd_initial_buffer_fullness : mfc_context->hrd.buffer_size / 2.;
mfc_context->hrd.target_buffer_fullness = (double)mfc_context->hrd.buffer_size/2.;
mfc_context->hrd.buffer_capacity = (double)mfc_context->hrd.buffer_size/qp1_size;
mfc_context->hrd.violation_noted = 0;
if ((bpf > qp51_size) && (bpf < qp1_size)) {
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
}
else if (bpf >= qp1_size)
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 1;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 1;
else if (bpf <= qp51_size)
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 51;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 51;
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY = mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY;
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY = mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_I] = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_B] = mfc_context->brc.qp_prime_y[SLICE_TYPE_I];
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY, 1, 51);
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY, 1, 51);
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY, 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_I], 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_P], 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_B], 1, 51);
}
int intel_mfc_update_hrd(struct encode_state *encode_state,
- struct gen6_mfc_context *mfc_context,
+ struct intel_encoder_context *encoder_context,
int frame_bits)
{
+ struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
double prev_bf = mfc_context->hrd.current_buffer_fullness;
mfc_context->hrd.current_buffer_fullness -= frame_bits;
}
int intel_mfc_brc_postpack(struct encode_state *encode_state,
- struct gen6_mfc_context *mfc_context,
+ struct intel_encoder_context *encoder_context,
int frame_bits)
{
+ struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
gen6_brc_status sts = BRC_NO_HRD_VIOLATION;
VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
int slicetype = intel_avc_enc_slice_type_fixup(pSliceParameter->slice_type);
- int qpi = mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY;
- int qpp = mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY;
- int qpb = mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY;
+ int qpi = mfc_context->brc.qp_prime_y[SLICE_TYPE_I];
+ int qpp = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
+ int qpb = mfc_context->brc.qp_prime_y[SLICE_TYPE_B];
int qp; // quantizer of previously encoded slice of current type
int qpn; // predicted quantizer for next frame of current type in integer format
double qpf; // predicted quantizer for next frame of current type in float format
double x, y;
double frame_size_alpha;
- qp = mfc_context->bit_rate_control_context[slicetype].QpPrimeY;
+ qp = mfc_context->brc.qp_prime_y[slicetype];
target_frame_size = mfc_context->brc.target_frame_size[slicetype];
if (mfc_context->hrd.buffer_capacity < 5)
BRC_CLIP(qpn, 1, 51);
/* checking wthether HRD compliance is still met */
- sts = intel_mfc_update_hrd(encode_state, mfc_context, frame_bits);
+ sts = intel_mfc_update_hrd(encode_state, encoder_context, frame_bits);
/* calculating QP delta as some function*/
x = mfc_context->hrd.target_buffer_fullness - mfc_context->hrd.current_buffer_fullness;
/* correcting QPs of slices of other types */
if (slicetype == SLICE_TYPE_P) {
if (abs(qpn + BRC_P_B_QP_DIFF - qpb) > 2)
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY += (qpn + BRC_P_B_QP_DIFF - qpb) >> 1;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_P_B_QP_DIFF - qpb) >> 1;
if (abs(qpn - BRC_I_P_QP_DIFF - qpi) > 2)
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY += (qpn - BRC_I_P_QP_DIFF - qpi) >> 1;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi) >> 1;
} else if (slicetype == SLICE_TYPE_I) {
if (abs(qpn + BRC_I_B_QP_DIFF - qpb) > 4)
- mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY += (qpn + BRC_I_B_QP_DIFF - qpb) >> 2;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_I_B_QP_DIFF - qpb) >> 2;
if (abs(qpn + BRC_I_P_QP_DIFF - qpp) > 2)
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
} else { // SLICE_TYPE_B
if (abs(qpn - BRC_P_B_QP_DIFF - qpp) > 2)
- mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY += (qpn - BRC_P_B_QP_DIFF - qpp) >> 1;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn - BRC_P_B_QP_DIFF - qpp) >> 1;
if (abs(qpn - BRC_I_B_QP_DIFF - qpi) > 4)
- mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY += (qpn - BRC_I_B_QP_DIFF - qpi) >> 2;
+ mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_B_QP_DIFF - qpi) >> 2;
}
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY, 1, 51);
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY, 1, 51);
- BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY, 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_I], 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_P], 1, 51);
+ BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_B], 1, 51);
} else if (sts == BRC_UNDERFLOW) { // underflow
if (qpn <= qp) qpn = qp + 1;
if (qpn > 51) {
}
}
- mfc_context->bit_rate_control_context[slicetype].QpPrimeY = qpn;
+ mfc_context->brc.qp_prime_y[slicetype] = qpn;
return sts;
}
struct intel_encoder_context *encoder_context)
{
struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
- VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
unsigned int rate_control_mode = encoder_context->rate_control_mode;
- int target_bit_rate = pSequenceParameter->bits_per_second;
+ int target_bit_rate = encoder_context->brc.bits_per_second[0];
// current we only support CBR mode.
if (rate_control_mode == VA_RC_CBR) {
mfc_context->vui_hrd.i_bit_rate_value = target_bit_rate >> 10;
- mfc_context->vui_hrd.i_cpb_size_value = (target_bit_rate * 8) >> 10;
- mfc_context->vui_hrd.i_initial_cpb_removal_delay = mfc_context->vui_hrd.i_cpb_size_value * 0.5 * 1024 / target_bit_rate * 90000;
+ mfc_context->vui_hrd.i_initial_cpb_removal_delay = ((target_bit_rate * 8) >> 10) * 0.5 * 1024 / target_bit_rate * 90000;
mfc_context->vui_hrd.i_cpb_removal_delay = 2;
mfc_context->vui_hrd.i_frame_number = 0;
return 1;
}
-/*
- * Check whether the parameters related with CBR are updated and decide whether
- * it needs to reinitialize the configuration related with CBR.
- * Currently it will check the following parameters:
- * bits_per_second
- * frame_rate
- * gop_configuration(intra_period, ip_period, intra_idr_period)
- */
-static bool intel_mfc_brc_updated_check(struct encode_state *encode_state,
- struct intel_encoder_context *encoder_context)
-{
- unsigned int rate_control_mode = encoder_context->rate_control_mode;
- struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
- double cur_fps, cur_bitrate;
- VAEncSequenceParameterBufferH264 *pSequenceParameter;
-
-
- if (rate_control_mode != VA_RC_CBR) {
- return false;
- }
-
- pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
-
- cur_bitrate = pSequenceParameter->bits_per_second;
- cur_fps = (double)pSequenceParameter->time_scale /
- (2 * (double)pSequenceParameter->num_units_in_tick);
-
- if ((cur_bitrate == mfc_context->brc.saved_bps) &&
- (cur_fps == mfc_context->brc.saved_fps) &&
- (pSequenceParameter->intra_period == mfc_context->brc.saved_intra_period) &&
- (pSequenceParameter->intra_idr_period == mfc_context->brc.saved_idr_period) &&
- (pSequenceParameter->intra_period == mfc_context->brc.saved_intra_period)) {
- /* the parameters related with CBR are not updaetd */
- return false;
- }
-
- mfc_context->brc.saved_ip_period = pSequenceParameter->ip_period;
- mfc_context->brc.saved_intra_period = pSequenceParameter->intra_period;
- mfc_context->brc.saved_idr_period = pSequenceParameter->intra_idr_period;
- mfc_context->brc.saved_fps = cur_fps;
- mfc_context->brc.saved_bps = cur_bitrate;
- return true;
-}
-
void intel_mfc_brc_prepare(struct encode_state *encode_state,
struct intel_encoder_context *encoder_context)
{
unsigned int rate_control_mode = encoder_context->rate_control_mode;
- struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
-
- if (rate_control_mode == VA_RC_CBR) {
- bool brc_updated;
- assert(encoder_context->codec != CODEC_MPEG2);
- brc_updated = intel_mfc_brc_updated_check(encode_state, encoder_context);
+ if (encoder_context->codec != CODEC_H264 &&
+ encoder_context->codec != CODEC_H264_MVC)
+ return;
+ if (rate_control_mode == VA_RC_CBR) {
/*Programing bit rate control */
- if ((mfc_context->bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord == 0) ||
- brc_updated) {
- intel_mfc_bit_rate_control_context_init(encode_state, mfc_context);
+ if (encoder_context->brc.need_reset) {
+ intel_mfc_bit_rate_control_context_init(encode_state, encoder_context);
intel_mfc_brc_init(encode_state, encoder_context);
}
/*Programing HRD control */
- if ((mfc_context->vui_hrd.i_cpb_size_value == 0) || brc_updated )
+ if (encoder_context->brc.need_reset)
intel_mfc_hrd_context_init(encode_state, encoder_context);
}
}
lambda = intel_lambda_qp(qp);
m_cost = lambda;
- vme_state_message[MODE_CHROMA_INTRA] = intel_format_lutvalue(m_cost, 0x8f);
+ vme_state_message[MODE_CHROMA_INTRA] = 0;
vme_state_message[MODE_REFID_COST] = intel_format_lutvalue(m_cost, 0x8f);
if (slice_type == SLICE_TYPE_I) {
if (encoder_context->rate_control_mode == VA_RC_CQP)
qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
else
- qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+ qp = mfc_context->brc.qp_prime_y[slice_type];
if (vme_state_message == NULL)
return;
if (encoder_context->rate_control_mode == VA_RC_CQP)
qp = q_matrix->quantization_index[0];
else
- qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+ qp = mfc_context->brc.qp_prime_y[slice_type];
lambda = intel_lambda_qp(qp * QP_MAX / VP8_QP_MAX);
if (encoder_context->rate_control_mode == VA_RC_CQP)
qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
else
- qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+ qp = mfc_context->brc.qp_prime_y[slice_type];
#define USE_SCOREBOARD (1 << 21)
int roi_qp;
} ROIRegionParam;
-static void
+static VAStatus
intel_h264_enc_roi_cbr(VADriverContextP ctx,
int base_qp,
VAEncMiscParameterBufferROI *pMiscParamROI,
bool quickfill = 0;
ROIRegionParam param_regions[I965_MAX_NUM_ROI_REGIONS];
- int num_roi;
+ int num_roi = 0;
int i,j;
float temp;
int mbs_in_picture = width_in_mbs * height_in_mbs;
struct gen6_vme_context *vme_context = encoder_context->vme_context;
+ VAStatus vaStatus = VA_STATUS_SUCCESS;
- num_roi = (pMiscParamROI->num_roi > I965_MAX_NUM_ROI_REGIONS) ? I965_MAX_NUM_ROI_REGIONS : pMiscParamROI->num_roi;
+ if(pMiscParamROI != NULL)
+ {
+ num_roi = (pMiscParamROI->num_roi > I965_MAX_NUM_ROI_REGIONS) ? I965_MAX_NUM_ROI_REGIONS : pMiscParamROI->num_roi;
+
+ /* currently roi_value_is_qp_delta is the only supported mode of priority.
+ *
+ * qp_delta set by user is added to base_qp, which is then clapped by
+ * [base_qp-min_delta, base_qp+max_delta].
+ */
+ ASSERT_RET(pMiscParamROI->roi_flags.bits.roi_value_is_qp_delta,VA_STATUS_ERROR_INVALID_PARAMETER);
+ }
/* when the base_qp is lower than 12, the quality is quite good based
* on the H264 test experience.
goto qp_fill;
}
- /* currently roi_value_is_qp_delta is the only supported mode of priority.
- *
- * qp_delta set by user is added to base_qp, which is then clapped by
- * [base_qp-min_delta, base_qp+max_delta].
- */
- assert (pMiscParamROI->roi_flags.bits.roi_value_is_qp_delta);
-
sum_roi = 0.0f;
roi_area = 0;
for (i = 0; i < num_roi; i++) {
}
}
}
- return ;
+ return vaStatus;
}
extern void
char *qp_ptr;
int i, j;
VAEncROI *region_roi;
+ struct i965_driver_data *i965 = i965_driver_data(ctx);
VAEncMiscParameterBuffer* pMiscParamROI;
- VAEncMiscParameterBufferROI *pParamROI;
+ VAEncMiscParameterBufferROI *pParamROI = NULL;
struct gen6_vme_context *vme_context = encoder_context->vme_context;
struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
int height_in_mbs = pSequenceParameter->picture_height_in_mbs;
int row_start, row_end, col_start, col_end;
- int num_roi;
+ int num_roi = 0;
vme_context->roi_enabled = 0;
/* Restriction: Disable ROI when multi-slice is enabled */
if (!encoder_context->context_roi || (encode_state->num_slice_params_ext > 1))
return;
- if (encode_state->misc_param[VAEncMiscParameterTypeROI] == NULL) {
- return;
- }
+ if (encode_state->misc_param[VAEncMiscParameterTypeROI][0] != NULL) {
+ pMiscParamROI = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeROI][0]->buffer;
+ pParamROI = (VAEncMiscParameterBufferROI *)pMiscParamROI->data;
- pMiscParamROI = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeROI]->buffer;
- pParamROI = (VAEncMiscParameterBufferROI *)pMiscParamROI->data;
+ /* check whether number of ROI is correct */
+ num_roi = (pParamROI->num_roi > I965_MAX_NUM_ROI_REGIONS) ? I965_MAX_NUM_ROI_REGIONS : pParamROI->num_roi;
+ }
- /* check whether number of ROI is correct */
- num_roi = (pParamROI->num_roi > I965_MAX_NUM_ROI_REGIONS) ? I965_MAX_NUM_ROI_REGIONS : pParamROI->num_roi;
+ if (num_roi > 0)
+ vme_context->roi_enabled = 1;
- vme_context->roi_enabled = 1;
+ if (!vme_context->roi_enabled)
+ return;
if ((vme_context->saved_width_mbs != width_in_mbs) ||
(vme_context->saved_height_mbs != height_in_mbs)) {
int qp;
int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type);
- qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
- intel_h264_enc_roi_cbr(ctx, qp, pParamROI,
- encode_state, encoder_context);
+ qp = mfc_context->brc.qp_prime_y[slice_type];
+ intel_h264_enc_roi_cbr(ctx, qp, pParamROI,encode_state, encoder_context);
} else if (encoder_context->rate_control_mode == VA_RC_CQP){
VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
*/
vme_context->roi_enabled = 0;
}
- if (vme_context->roi_enabled)
+
+ if (vme_context->roi_enabled && IS_GEN7(i965->intel.device_info))
encoder_context->soft_batch_force = 1;
+
return;
}
struct object_surface *obj_surface = NULL;
struct i965_driver_data *i965 = i965_driver_data(ctx);
VASurfaceID ref_surface_id;
+ VAEncSequenceParameterBufferHEVC *pSequenceParameter = (VAEncSequenceParameterBufferHEVC *)encode_state->seq_param_ext->buffer;
VAEncPictureParameterBufferHEVC *pic_param = (VAEncPictureParameterBufferHEVC *)encode_state->pic_param_ext->buffer;
VAEncSliceParameterBufferHEVC *slice_param = (VAEncSliceParameterBufferHEVC *)encode_state->slice_params_ext[0]->buffer;
int max_num_references;
VAPictureHEVC *curr_pic;
VAPictureHEVC *ref_list;
int ref_idx;
+ unsigned int is_hevc10 = 0;
+ GenHevcSurface *hevc_encoder_surface = NULL;
+
+ if((pSequenceParameter->seq_fields.bits.bit_depth_luma_minus8 > 0)
+ || (pSequenceParameter->seq_fields.bits.bit_depth_chroma_minus8 > 0))
+ is_hevc10 = 1;
if (list_index == 0) {
max_num_references = pic_param->num_ref_idx_l0_default_active_minus1 + 1;
obj_surface->bo) {
assert(ref_idx >= 0);
vme_context->used_reference_objects[list_index] = obj_surface;
+
+ if(is_hevc10){
+ hevc_encoder_surface = (GenHevcSurface *) obj_surface->private_data;
+ assert(hevc_encoder_surface);
+ obj_surface = hevc_encoder_surface->nv12_surface_obj;
+ }
vme_source_surface_state(ctx, surface_index, obj_surface, encoder_context);
vme_context->ref_index_in_mb[list_index] = (ref_idx << 24 |
ref_idx << 16 |