函数aom_codec_encode主要就是根据命令行参数--cpu-used来决定num_enc, 通常情况下,为了通测方便,--cpu-used都是设置为1. 提高--cpu-used的数值会加快编码器的速度,但也会降低编码质量。确定好num_enc之后,就会调用函数encoder_encode
aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img,
aom_codec_pts_t pts, unsigned long duration,
aom_enc_frame_flags_t flags) {
aom_codec_err_t res = AOM_CODEC_OK;
if (!ctx || (img && !duration))
res = AOM_CODEC_INVALID_PARAM;
else if (!ctx->iface || !ctx->priv)
res = AOM_CODEC_ERROR;
else if (!(ctx->iface->caps & AOM_CODEC_CAP_ENCODER))
res = AOM_CODEC_INCAPABLE;
else {
unsigned int num_enc = ctx->priv->enc.total_encoders;//获取encoder的数量
/* Execute in a normalized floating point environment, if the platform
* requires it.
*/
FLOATING_POINT_INIT
if (num_enc == 1