MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_conf

Function get_conf

libavcodec/libxeve.c:172–255  ·  view source on GitHub ↗

* The function returns a pointer to the object of the XEVE_CDSC type. * XEVE_CDSC contains all encoder parameters that should be initialized before the encoder is used. * * The field values of the XEVE_CDSC structure are populated based on: * - the corresponding field values of the AvCodecConetxt structure, * - the xeve encoder specific option values, * (the full list of options available

Source from the content-addressed store, hash-verified

170 * @return 0 on success, negative error code on failure
171 */
172static int get_conf(AVCodecContext *avctx, XEVE_CDSC *cdsc)
173{
174 XeveContext *xectx = NULL;
175 int ret;
176
177 xectx = avctx->priv_data;
178
179 /* initialize xeve_param struct with default values */
180 ret = xeve_param_default(&cdsc->param);
181 if (XEVE_FAILED(ret)) {
182 av_log(avctx, AV_LOG_ERROR, "Cannot set_default parameter\n");
183 return AVERROR_EXTERNAL;
184 }
185
186 /* read options from AVCodecContext */
187 if (avctx->width > 0)
188 cdsc->param.w = avctx->width;
189
190 if (avctx->height > 0)
191 cdsc->param.h = avctx->height;
192
193 if (avctx->framerate.num > 0) {
194 // fps can be float number, but xeve API doesn't support it
195 cdsc->param.fps.num = avctx->framerate.num;
196 cdsc->param.fps.den = avctx->framerate.den;
197 }
198
199 // GOP size (key-frame interval, I-picture period)
200 cdsc->param.keyint = avctx->gop_size; // 0: only one I-frame at the first time; 1: every frame is coded in I-frame
201
202 if (avctx->max_b_frames == 0 || avctx->max_b_frames == 1 || avctx->max_b_frames == 3 ||
203 avctx->max_b_frames == 7 || avctx->max_b_frames == 15) // number of b-frames
204 cdsc->param.bframes = avctx->max_b_frames;
205 else {
206 av_log(avctx, AV_LOG_ERROR, "Incorrect value for maximum number of B frames: (%d) \n"
207 "Acceptable values for bf option (maximum number of B frames) are 0,1,3,7 or 15\n", avctx->max_b_frames);
208 return AVERROR_INVALIDDATA;
209 }
210
211 cdsc->param.level_idc = avctx->level;
212
213 if (avctx->rc_buffer_size) // VBV buf size
214 cdsc->param.vbv_bufsize = (int)(avctx->rc_buffer_size / 1000);
215
216 cdsc->param.rc_type = xectx->rc_mode;
217
218 if (xectx->rc_mode == XEVE_RC_CQP)
219 cdsc->param.qp = xectx->qp;
220 else if (xectx->rc_mode == XEVE_RC_ABR) {
221 if (avctx->bit_rate / 1000 > INT_MAX || avctx->rc_max_rate / 1000 > INT_MAX) {
222 av_log(avctx, AV_LOG_ERROR, "Not supported bitrate bit_rate and rc_max_rate > %d000\n", INT_MAX);
223 return AVERROR_INVALIDDATA;
224 }
225 cdsc->param.bitrate = (int)(avctx->bit_rate / 1000);
226 } else if (xectx->rc_mode == XEVE_RC_CRF)
227 cdsc->param.crf = xectx->crf;
228 else {
229 av_log(avctx, AV_LOG_ERROR, "Not supported rate control type: %d\n", xectx->rc_mode);

Callers 1

libxeve_initFunction · 0.70

Calls 3

av_logFunction · 0.85
av_cpu_countFunction · 0.85
libxeve_color_fmtFunction · 0.85

Tested by

no test coverage detected