hardware/intel/intel-driver
Revisão | 70579a58e6684add8b7f50b8f10be7bb473700cb (tree) |
---|---|
Hora | 2015-04-29 16:52:24 |
Autor | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Fix segmentation fault
The segmentation fault occurs when CBR is selected without HRD parameter
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
@@ -134,8 +134,8 @@ static void intel_mfc_brc_init(struct encode_state *encode_state, | ||
134 | 134 | { |
135 | 135 | struct gen6_mfc_context *mfc_context = encoder_context->mfc_context; |
136 | 136 | VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer; |
137 | - VAEncMiscParameterBuffer* pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer; | |
138 | - VAEncMiscParameterHRD* pParameterHRD = (VAEncMiscParameterHRD*)pMiscParamHRD->data; | |
137 | + VAEncMiscParameterBuffer* pMiscParamHRD = NULL; | |
138 | + VAEncMiscParameterHRD* pParameterHRD = NULL; | |
139 | 139 | double bitrate = pSequenceParameter->bits_per_second; |
140 | 140 | double framerate = (double)pSequenceParameter->time_scale /(2 * (double)pSequenceParameter->num_units_in_tick); |
141 | 141 | int inum = 1, pnum = 0, bnum = 0; /* Gop structure: number of I, P, B frames in the Gop. */ |
@@ -145,6 +145,12 @@ static void intel_mfc_brc_init(struct encode_state *encode_state, | ||
145 | 145 | double qp51_size = 0.001 * 8 * 3 * (pSequenceParameter->picture_width_in_mbs<<4) * (pSequenceParameter->picture_height_in_mbs<<4)/2; |
146 | 146 | double bpf; |
147 | 147 | |
148 | + if (!encode_state->misc_param[VAEncMiscParameterTypeHRD] || !encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer) | |
149 | + return; | |
150 | + | |
151 | + pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer; | |
152 | + pParameterHRD = (VAEncMiscParameterHRD*)pMiscParamHRD->data; | |
153 | + | |
148 | 154 | if (pSequenceParameter->ip_period) { |
149 | 155 | pnum = (intra_period + ip_period - 1)/ip_period - 1; |
150 | 156 | bnum = intra_period - inum - pnum; |