您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vpx_codec_control函数代码示例

51自学网 2021-06-03 09:48:28
  C++
这篇教程C++ vpx_codec_control函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vpx_codec_control函数的典型用法代码示例。如果您正苦于以下问题:C++ vpx_codec_control函数的具体用法?C++ vpx_codec_control怎么用?C++ vpx_codec_control使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vpx_codec_control函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: testing_decode

static void testing_decode(vpx_codec_ctx_t *encoder, vpx_codec_ctx_t *decoder,                           unsigned int frame_out, int *mismatch_seen) {  vpx_image_t enc_img, dec_img;  struct vp9_ref_frame ref_enc, ref_dec;  if (*mismatch_seen) return;  ref_enc.idx = 0;  ref_dec.idx = 0;  if (vpx_codec_control(encoder, VP9_GET_REFERENCE, &ref_enc))    die_codec(encoder, "Failed to get encoder reference frame");  enc_img = ref_enc.img;  if (vpx_codec_control(decoder, VP9_GET_REFERENCE, &ref_dec))    die_codec(decoder, "Failed to get decoder reference frame");  dec_img = ref_dec.img;  if (!compare_img(&enc_img, &dec_img)) {    int y[4], u[4], v[4];    *mismatch_seen = 1;    find_mismatch(&enc_img, &dec_img, y, u, v);    printf(        "Encode/decode mismatch on frame %d at"        " Y[%d, %d] {%d/%d},"        " U[%d, %d] {%d/%d},"        " V[%d, %d] {%d/%d}",        frame_out, y[0], y[1], y[2], y[3], u[0], u[1], u[2], u[3], v[0], v[1],        v[2], v[3]);  }  vpx_img_free(&enc_img);  vpx_img_free(&dec_img);}
开发者ID:webmproject,项目名称:libvpx,代码行数:34,


示例2: switch_to_layer

static void switch_to_layer(int layer, unsigned int initial_width,                            unsigned int initial_height,                            vpx_codec_ctx_t *codec) {  // Set layer size  int scaling_factor_num[MAX_LAYERS] = {2, 1, 4, 2, 1};  int scaling_factor_den[MAX_LAYERS] = {9, 3, 9, 3, 1};  int quantizer[MAX_LAYERS] = {60, 53, 39, 33, 27};  unsigned int current_width;  unsigned int current_height;  current_width = initial_width *                  scaling_factor_num[layer + 5 - number_spatial_layers] /                  scaling_factor_den[layer + 5 - number_spatial_layers];  current_height = initial_height *                   scaling_factor_num[layer + 5 - number_spatial_layers] /                   scaling_factor_den[layer + 5 - number_spatial_layers];  current_width += current_width % 2;  current_height += current_height % 2;  vpx_codec_control(codec, VP9E_SET_WIDTH, &current_width);  vpx_codec_control(codec, VP9E_SET_HEIGHT, &current_height);  // Set layer context  vpx_codec_control(codec, VP9E_SET_LAYER, &layer);  vpx_codec_control(codec, VP9E_SET_MAX_Q,                    quantizer[layer + 5 - number_spatial_layers]);  vpx_codec_control(codec, VP9E_SET_MIN_Q,                    quantizer[layer + 5 - number_spatial_layers]);}
开发者ID:huangwenjun06,项目名称:libvpx_mips,代码行数:32,


示例3: setCustomPostInit

void setCustomPostInit(VP8EncoderGlobals glob){  if (glob->settings[12] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_CPUUSED, glob->settings[12]);  if (glob->settings[13] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_NOISE_SENSITIVITY, glob->settings[13]);  if (glob->settings[14] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_SHARPNESS, glob->settings[14]);  if (glob->settings[15] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_STATIC_THRESHOLD, glob->settings[15]);  //setUIntPostInit(glob, VP8E_SET_TOKEN_PARTITIONS, 25);  // TODO not sure how to set this.  //TODO verify this when enabling alt - ref  if (glob->settings[25] != UINT_MAX)  {    vpx_codec_control(glob->codec, VP8E_SET_ENABLEAUTOALTREF, glob->settings[25]);    dbg_printf("[VP8e] Setting enable Altref %d/n", glob->settings[25]);  }  if (glob->settings[26] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_ARNR_MAXFRAMES, glob->settings[26]);  if (glob->settings[27] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_ARNR_STRENGTH, glob->settings[27]);  if (glob->settings[28] != UINT_MAX)    vpx_codec_control(glob->codec, VP8E_SET_ARNR_TYPE, glob->settings[28]);}
开发者ID:NextGenIntelligence,项目名称:webmquicktime,代码行数:25,


示例4: set_roi_map

static void set_roi_map(const vpx_codec_enc_cfg_t *cfg,                        vpx_codec_ctx_t *codec) {  unsigned int i;  vpx_roi_map_t roi;  memset(&roi, 0, sizeof(roi));  roi.rows = (cfg->g_h + 15) / 16;  roi.cols = (cfg->g_w + 15) / 16;  roi.delta_q[0] = 0;  roi.delta_q[1] = -2;  roi.delta_q[2] = -4;  roi.delta_q[3] = -6;  roi.delta_lf[0] = 0;  roi.delta_lf[1] = 1;  roi.delta_lf[2] = 2;  roi.delta_lf[3] = 3;  roi.static_threshold[0] = 1500;  roi.static_threshold[1] = 1000;  roi.static_threshold[2] = 500;  roi.static_threshold[3] = 0;  roi.roi_map = (uint8_t *)malloc(roi.rows * roi.cols);  for (i = 0; i < roi.rows * roi.cols; ++i)    roi.roi_map[i] = i % 4;  if (vpx_codec_control(codec, VP8E_SET_ROI_MAP, &roi))    die_codec(codec, "Failed to set ROI map");  free(roi.roi_map);}
开发者ID:ALEJANDROJ19,项目名称:VTW-server,代码行数:33,


示例5: set_svc_parameters

static void set_svc_parameters(SvcContext *svc_ctx,                               vpx_codec_ctx_t *codec_ctx) {  int layer;  vpx_svc_parameters_t svc_params;  SvcInternal *const si = get_svc_internal(svc_ctx);  memset(&svc_params, 0, sizeof(svc_params));  svc_params.temporal_layer = 0;  svc_params.spatial_layer = si->layer;  layer = si->layer;  if (VPX_CODEC_OK != vpx_svc_get_layer_resolution(svc_ctx, layer,                                                   &svc_params.width,                                                   &svc_params.height)) {    svc_log(svc_ctx, SVC_LOG_ERROR, "vpx_svc_get_layer_resolution failed/n");  }  if (codec_ctx->config.enc->g_pass == VPX_RC_ONE_PASS) {    svc_params.min_quantizer = si->quantizer[layer];    svc_params.max_quantizer = si->quantizer[layer];  } else {    svc_params.min_quantizer = codec_ctx->config.enc->rc_min_quantizer;    svc_params.max_quantizer = codec_ctx->config.enc->rc_max_quantizer;  }  vpx_codec_control(codec_ctx, VP9E_SET_SVC_PARAMETERS, &svc_params);}
开发者ID:awatry,项目名称:libvpx.vp9_opencl,代码行数:27,


示例6: x_vpx_decoder_init

intx_vpx_decoder_init(vpx_codec_ctx_t *_decoder, int numcores){  vpx_codec_dec_cfg_t cfg;  vpx_codec_flags_t flags = 0;  int err;  cfg.threads = 1;  cfg.h = cfg.w = 0; // set after decode#if WEBRTC_LIBVPX_VERSION >= 971  flags = VPX_CODEC_USE_ERROR_CONCEALMENT | VPX_CODEC_USE_POSTPROC;#ifdef INDEPENDENT_PARTITIONS  flags |= VPX_CODEC_USE_INPUT_PARTITION;#endif#endif  if (vpx_codec_dec_init(_decoder, vpx_codec_vp8_dx(), &cfg, flags))    {      return -ENOMEM;    }#if WEBRTC_LIBVPX_VERSION >= 971  vp8_postproc_cfg_t ppcfg;  // Disable deblocking for now due to uninitialized memory being returned.  ppcfg.post_proc_flag = 0;  // Strength of deblocking filter. Valid range:[0,16]  //ppcfg.deblocking_level = 3;  vpx_codec_control(_decoder, VP8_SET_POSTPROC, &ppcfg);#endif  return 0;}
开发者ID:biddyweb,项目名称:xwbot,代码行数:33,


示例7: calloc

krad_vpx_decoder_t *krad_vpx_decoder_create () {  krad_vpx_decoder_t *vpx;    vpx = calloc (1, sizeof(krad_vpx_decoder_t));  vpx->stream_info.sz = sizeof (vpx->stream_info);  vpx->dec_flags = 0;  vpx->cfg.threads = 3;    vpx_codec_dec_init (&vpx->decoder,                     vpx_codec_vp8_dx(),                     &vpx->cfg,                     vpx->dec_flags);  //vpx->ppcfg.post_proc_flag = VP8_DEBLOCK;  //vpx->ppcfg.deblocking_level = 1;  //vpx->ppcfg.noise_level = 0;  vpx->ppcfg.post_proc_flag = VP8_DEMACROBLOCK | VP8_DEBLOCK | VP8_ADDNOISE;  vpx->ppcfg.deblocking_level = 5;  vpx->ppcfg.noise_level = 1;  vpx_codec_control (&vpx->decoder, VP8_SET_POSTPROC, &vpx->ppcfg);  vpx->img = NULL;  return vpx;}
开发者ID:brooss,项目名称:krcam,代码行数:29,


示例8: check_decode_result

static pj_status_t check_decode_result(pjmedia_vid_codec *codec,                                       const vpx_image_t *img,                                       const pj_timestamp *ts) {    vpx_private *vpx = (vpx_private*) codec->codec_data;    pjmedia_video_apply_fmt_param *vafp = &vpx->dec_vafp;    pjmedia_event event;    int res, reference_updates = 0;    /* Check for format change.     */    if (img->d_w != (int) vafp->size.w || img->d_h != (int) vafp->size.h) {        pj_status_t status;        /* Update decoder format in param */        vpx->param.dec_fmt.det.vid.size.w = img->d_w;        vpx->param.dec_fmt.det.vid.size.h = img->d_h;        /* Re-init format info and apply-param of decoder */        vpx->dec_vfi = pjmedia_get_video_format_info(NULL, vpx->param.dec_fmt.id);        if (!vpx->dec_vfi)            return PJ_ENOTSUP;        pj_bzero(&vpx->dec_vafp, sizeof(vpx->dec_vafp));        vpx->dec_vafp.size = vpx->param.dec_fmt.det.vid.size;        vpx->dec_vafp.buffer = NULL;        status = (*vpx->dec_vfi->apply_fmt)(vpx->dec_vfi, &vpx->dec_vafp);        if (status != PJ_SUCCESS)            return status;        /* Realloc buffer if necessary */	if (vpx->dec_vafp.framebytes > vpx->dec_buf_size) {	    PJ_LOG(5,(THIS_FILE, "Reallocating decoding buffer %u --> %u",		       (unsigned)vpx->dec_buf_size,		       (unsigned)vpx->dec_vafp.framebytes));	    vpx->dec_buf_size = (unsigned)vpx->dec_vafp.framebytes;	    vpx->dec_buf = pj_pool_alloc(vpx->pool, vpx->dec_buf_size);	}        /* Broadcast format changed event */        pjmedia_event_init(&event, PJMEDIA_EVENT_FMT_CHANGED, ts, codec);        event.data.fmt_changed.dir = PJMEDIA_DIR_DECODING;        pj_memcpy(&event.data.fmt_changed.new_fmt, &vpx->param.dec_fmt, sizeof(vpx->param.dec_fmt));        pjmedia_event_publish(NULL, codec, &event, 0);    }    /* Check for found keyframe */    res = vpx_codec_control(&vpx->decoder, VP8D_GET_LAST_REF_UPDATES, &reference_updates);    if (res == VPX_CODEC_OK) {        pj_bool_t got_keyframe = (reference_updates & VP8_GOLD_FRAME);        if (got_keyframe) {            pj_get_timestamp(&vpx->last_dec_keyframe_ts);            /* Broadcast keyframe event */            pjmedia_event_init(&event, PJMEDIA_EVENT_KEYFRAME_FOUND, ts, codec);            pjmedia_event_publish(NULL, codec, &event, 0);        }    }    return PJ_SUCCESS;}
开发者ID:acatighera,项目名称:python-sipsimple,代码行数:59,


示例9: vc_reconfigure_encoder

int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist){    if (!vc) {        return -1;    }    vpx_codec_enc_cfg_t cfg2 = *vc->encoder->config.enc;    vpx_codec_err_t rc;    if (cfg2.rc_target_bitrate == bit_rate && cfg2.g_w == width && cfg2.g_h == height && kf_max_dist == -1) {        return 0; /* Nothing changed */    }    if (cfg2.g_w == width && cfg2.g_h == height && kf_max_dist == -1) {        /* Only bit rate changed */        LOGGER_INFO(vc->log, "bitrate change from: %u to: %u", (uint32_t)cfg2.rc_target_bitrate, (uint32_t)bit_rate);        cfg2.rc_target_bitrate = bit_rate;        rc = vpx_codec_enc_config_set(vc->encoder, &cfg2);        if (rc != VPX_CODEC_OK) {            LOGGER_ERROR(vc->log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));            return -1;        }    } else {        /* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support         * reconfiguring encoder to use resolutions greater than initially set.         */        LOGGER_DEBUG(vc->log, "Have to reinitialize vpx encoder on session %p", (void *)vc);        vpx_codec_ctx_t new_c;        vpx_codec_enc_cfg_t  cfg;        vc_init_encoder_cfg(vc->log, &cfg, kf_max_dist);        cfg.rc_target_bitrate = bit_rate;        cfg.g_w = width;        cfg.g_h = height;        LOGGER_DEBUG(vc->log, "Using VP8 codec for encoder");        rc = vpx_codec_enc_init(&new_c, video_codec_encoder_interface(), &cfg, VPX_CODEC_USE_FRAME_THREADING);        if (rc != VPX_CODEC_OK) {            LOGGER_ERROR(vc->log, "Failed to initialize encoder: %s", vpx_codec_err_to_string(rc));            return -1;        }        int cpu_used_value = VP8E_SET_CPUUSED_VALUE;        rc = vpx_codec_control(&new_c, VP8E_SET_CPUUSED, cpu_used_value);        if (rc != VPX_CODEC_OK) {            LOGGER_ERROR(vc->log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));            vpx_codec_destroy(&new_c);            return -1;        }        vpx_codec_destroy(vc->encoder);        memcpy(vc->encoder, &new_c, sizeof(new_c));    }    return 0;}
开发者ID:TokTok,项目名称:toxcore,代码行数:59,


示例10: unset_active_map

static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,                             vpx_codec_ctx_t *codec) {  vpx_active_map_t map = {0, 0, 0};  map.rows = (cfg->g_h + 15) / 16;  map.cols = (cfg->g_w + 15) / 16;  map.active_map = NULL;  if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))    die_codec(codec, "Failed to set active map");}
开发者ID:ALEJANDROJ19,项目名称:VTW-server,代码行数:11,


示例11: init_decoder

static switch_status_t init_decoder(switch_codec_t *codec){	vpx_context_t *context = (vpx_context_t *)codec->private_info;	vpx_codec_dec_cfg_t cfg = {0, 0, 0};	vpx_codec_flags_t dec_flags = 0;	if (context->flags & SWITCH_CODEC_FLAG_DECODE && !context->decoder_init) {		vp8_postproc_cfg_t ppcfg;				//if (context->decoder_init) {		//	vpx_codec_destroy(&context->decoder);		//	context->decoder_init = 0;		//}		cfg.threads = switch_core_cpu_count();		if (!context->is_vp9) { // vp8 only			dec_flags = VPX_CODEC_USE_POSTPROC;		}		if (vpx_codec_dec_init(&context->decoder, context->decoder_interface, &cfg, dec_flags) != VPX_CODEC_OK) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec init error: [%d:%s]/n", context->encoder.err, context->encoder.err_detail);			return SWITCH_STATUS_FALSE;		}				context->last_ts = 0;		context->last_received_timestamp = 0;		context->last_received_complete_picture = 0;		context->decoder_init = 1;		context->got_key_frame = 0;		context->got_start_frame = 0;		// the types of post processing to be done, should be combination of "vp8_postproc_level"		ppcfg.post_proc_flag = VP8_DEBLOCK;//VP8_DEMACROBLOCK | VP8_DEBLOCK;		// the strength of deblocking, valid range [0, 16]		ppcfg.deblocking_level = 1;		// Set deblocking settings		vpx_codec_control(&context->decoder, VP8_SET_POSTPROC, &ppcfg);		if (context->vpx_packet_buffer) {			switch_buffer_zero(context->vpx_packet_buffer);		} else {			switch_buffer_create_dynamic(&context->vpx_packet_buffer, 512, 512, 0);		}	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:48,


示例12: vpx_codec_control

HRESULT Inpin::OnApplyPostProcessing(){    const Filter::Config& src = m_pFilter->m_cfg;    vp8_postproc_cfg_t tgt;    tgt.post_proc_flag = src.flags;    tgt.deblocking_level = src.deblock;    tgt.noise_level = src.noise;    const vpx_codec_err_t err = vpx_codec_control(                                    &m_ctx,                                    VP8_SET_POSTPROC,                                    &tgt);    return (err == VPX_CODEC_OK) ? S_OK : E_FAIL;}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:16,


示例13: set_active_map

static void set_active_map(const vpx_codec_enc_cfg_t *cfg,                           vpx_codec_ctx_t *codec) {    unsigned int i;    vpx_active_map_t map = { 0, 0, 0 };    map.rows = (cfg->g_h + 15) / 16;    map.cols = (cfg->g_w + 15) / 16;    map.active_map = (uint8_t *)malloc(map.rows * map.cols);    for (i = 0; i < map.rows * map.cols; ++i) map.active_map[i] = i % 2;    if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))        die_codec(codec, "Failed to set active map");    free(map.active_map);}
开发者ID:Topopiccione,项目名称:libvpx,代码行数:16,


示例14: pj_vpx_codec_encode_begin

static pj_status_t pj_vpx_codec_encode_begin(pjmedia_vid_codec *codec,        const pjmedia_vid_encode_opt *opt, const pjmedia_frame *input,        unsigned out_size, pjmedia_frame *output, pj_bool_t *has_more) {    vpx_private *vpx = (vpx_private*) codec->codec_data;    vpx_image_t *rawimg;    vpx_enc_frame_flags_t flags = 0;    pj_uint8_t *p;    int i, res;    PJ_ASSERT_RETURN(codec && input, PJ_EINVAL);    p = (pj_uint8_t*) input->buf;    *has_more = PJ_FALSE;    rawimg = &vpx->rawimg;    if(input->size < vpx->enc_vafp.framebytes){        PJ_LOG(1, (THIS_FILE, "Frame provided is too small !"));        return PJ_ETOOSMALL;    }    for (i = 0; i < vpx->enc_vfi->plane_cnt; ++i) {        rawimg->planes[i] = p;        rawimg->stride[i] = vpx->enc_vafp.strides[i];        p += vpx->enc_vafp.plane_bytes[i];    }    if (opt && opt->force_keyframe) {        flags |= VPX_EFLAG_FORCE_KF;        vpx_codec_control(&vpx->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT, vpx->rc_max_intra_target);    }    res = vpx_codec_encode(&vpx->encoder, rawimg, input->timestamp.u64, 1, flags, VPX_DL_REALTIME);    if (res != VPX_CODEC_OK) {        PJ_LOG(1, (THIS_FILE, "Failed to encode : %s %s", vpx_codec_err_to_string(res), vpx->encoder.err_detail));        return PJMEDIA_CODEC_EFAILED;    }    vpx->enc_iter = NULL;    vpx->enc_frame_len = 0;    vpx->enc_processed = 0;    return pj_vpx_codec_encode_more(codec, out_size, output, has_more);}
开发者ID:acatighera,项目名称:python-sipsimple,代码行数:43,


示例15: init_video_encoder

static int init_video_encoder(CSSession *cs, uint16_t max_width, uint16_t max_height, uint32_t video_bitrate){    vpx_codec_enc_cfg_t  cfg;    int rc = vpx_codec_enc_config_default(VIDEO_CODEC_ENCODER_INTERFACE, &cfg, 0);    if (rc != VPX_CODEC_OK) {        LOGGER_ERROR("Failed to get config: %s", vpx_codec_err_to_string(rc));        return -1;    }    cfg.rc_target_bitrate = video_bitrate;    cfg.g_w = max_width;    cfg.g_h = max_height;    cfg.g_pass = VPX_RC_ONE_PASS;    cfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT | VPX_ERROR_RESILIENT_PARTITIONS;    cfg.g_lag_in_frames = 0;    cfg.kf_min_dist = 0;    cfg.kf_max_dist = 48;    cfg.kf_mode = VPX_KF_AUTO;    rc = vpx_codec_enc_init_ver(&cs->v_encoder, VIDEO_CODEC_ENCODER_INTERFACE, &cfg, 0, VPX_ENCODER_ABI_VERSION);    if ( rc != VPX_CODEC_OK) {        LOGGER_ERROR("Failed to initialize encoder: %s", vpx_codec_err_to_string(rc));        return -1;    }    rc = vpx_codec_control(&cs->v_encoder, VP8E_SET_CPUUSED, 8);    if ( rc != VPX_CODEC_OK) {        LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));        return -1;    }    cs->max_width = max_width;    cs->max_height = max_height;    cs->video_bitrate = video_bitrate;    return 0;}
开发者ID:ittner,项目名称:toxcore,代码行数:40,


示例16: initialize_codec

static void initialize_codec(vpx_codec_ctx_t *codec, vpx_codec_enc_cfg_t *cfg) {  int max_intra_size_pct;  /* Initialize codec *///  if (vpx_codec_enc_init(codec, interface, cfg, VPX_CODEC_USE_PSNR))//    die_codec(codec, "Failed to initialize encoder");  vpx_codec_control(codec, VP9E_SET_SVC, 1);  /* Cap CPU & first I-frame size */  vpx_codec_control(codec, VP8E_SET_CPUUSED, 1);  vpx_codec_control(codec, VP8E_SET_STATIC_THRESHOLD, 1);  vpx_codec_control(codec, VP8E_SET_NOISE_SENSITIVITY, 1);  vpx_codec_control(codec, VP8E_SET_TOKEN_PARTITIONS, 1);  max_intra_size_pct =      (int)(((double)cfg->rc_buf_optimal_sz * 0.5) *            ((double)cfg->g_timebase.den / cfg->g_timebase.num) / 10.0);  /* printf ("max_intra_size_pct=%d/n", max_intra_size_pct); */  vpx_codec_control(codec, VP8E_SET_MAX_INTRA_BITRATE_PCT, max_intra_size_pct);}
开发者ID:huangwenjun06,项目名称:libvpx_mips,代码行数:21,


示例17: main

int main(int argc, char **argv) {  FILE *infile = NULL;  vpx_codec_ctx_t codec;  vpx_codec_enc_cfg_t cfg;  int frame_count = 0;  vpx_image_t raw;  vpx_codec_err_t res;  VpxVideoInfo info;  VpxVideoWriter *writer = NULL;  const VpxInterface *encoder = NULL;  int update_frame_num = 0;  const int fps = 30;       // TODO(dkovalev) add command line argument  const int bitrate = 200;  // kbit/s TODO(dkovalev) add command line argument  vp8_zero(codec);  vp8_zero(cfg);  vp8_zero(info);  exec_name = argv[0];  if (argc != 6) die("Invalid number of arguments");  // TODO(dkovalev): add vp9 support and rename the file accordingly  encoder = get_vpx_encoder_by_name("vp8");  if (!encoder) die("Unsupported codec.");  update_frame_num = atoi(argv[5]);  if (!update_frame_num) die("Couldn't parse frame number '%s'/n", argv[5]);  info.codec_fourcc = encoder->fourcc;  info.frame_width = (int)strtol(argv[1], NULL, 0);  info.frame_height = (int)strtol(argv[2], NULL, 0);  info.time_base.numerator = 1;  info.time_base.denominator = fps;  if (info.frame_width <= 0 || info.frame_height <= 0 ||      (info.frame_width % 2) != 0 || (info.frame_height % 2) != 0) {    die("Invalid frame size: %dx%d", info.frame_width, info.frame_height);  }  if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,                     info.frame_height, 1)) {    die("Failed to allocate image.");  }  printf("Using %s/n", vpx_codec_iface_name(encoder->codec_interface()));  res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);  if (res) die_codec(&codec, "Failed to get default codec config.");  cfg.g_w = info.frame_width;  cfg.g_h = info.frame_height;  cfg.g_timebase.num = info.time_base.numerator;  cfg.g_timebase.den = info.time_base.denominator;  cfg.rc_target_bitrate = bitrate;  writer = vpx_video_writer_open(argv[4], kContainerIVF, &info);  if (!writer) die("Failed to open %s for writing.", argv[4]);  if (!(infile = fopen(argv[3], "rb")))    die("Failed to open %s for reading.", argv[3]);  if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))    die_codec(&codec, "Failed to initialize encoder");  // Encode frames.  while (vpx_img_read(&raw, infile)) {    if (frame_count + 1 == update_frame_num) {      vpx_ref_frame_t ref;      ref.frame_type = VP8_LAST_FRAME;      ref.img = raw;      if (vpx_codec_control(&codec, VP8_SET_REFERENCE, &ref))        die_codec(&codec, "Failed to set reference frame");    }    encode_frame(&codec, &raw, frame_count++, writer);  }  // Flush encoder.  while (encode_frame(&codec, NULL, -1, writer)) {  }  printf("/n");  fclose(infile);  printf("Processed %d frames./n", frame_count);  vpx_img_free(&raw);  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");  vpx_video_writer_close(writer);  return EXIT_SUCCESS;}
开发者ID:Italtel-Unimi,项目名称:libvpx,代码行数:93,


示例18: main

//.........这里部分代码省略.........        layer_flags[9]  =        layer_flags[11] =        layer_flags[13] =        layer_flags[15] = VP8_EFLAG_NO_UPD_LAST |                          VP8_EFLAG_NO_UPD_GF   |                          VP8_EFLAG_NO_UPD_ARF  |                          VP8_EFLAG_NO_UPD_ENTROPY;        layer_flags[2]  =        layer_flags[6]  =        layer_flags[10] =        layer_flags[14] = 0;        layer_flags[4]  =        layer_flags[12] = VP8_EFLAG_NO_REF_LAST;        layer_flags[8]  = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF |                          VP8_EFLAG_NO_UPD_ENTROPY;        break;    }    default:        break;    }    // Open input file    if(!(infile = fopen(argv[1], "rb")))        die("Failed to open %s for reading", argv[1]);    // Open an output file for each stream    for (i=0; i<cfg.ts_number_layers; i++)    {        char file_name[512];        sprintf (file_name, "%s_%d.ivf", argv[2], i);        if (!(outfile[i] = fopen(file_name, "wb")))            die("Failed to open %s for writing", file_name);        write_ivf_file_header(outfile[i], &cfg, 0);    }    // Initialize codec    if (vpx_codec_enc_init (&codec, interface, &cfg, 0))        die_codec (&codec, "Failed to initialize encoder");    // Cap CPU & first I-frame size    vpx_codec_control (&codec, VP8E_SET_CPUUSED, -6);    vpx_codec_control (&codec, VP8E_SET_MAX_INTRA_BITRATE_PCT, 600);    frame_avail = 1;    while (frame_avail || got_data) {        vpx_codec_iter_t iter = NULL;        const vpx_codec_cx_pkt_t *pkt;        flags = layer_flags[frame_cnt % cfg.ts_periodicity];        frame_avail = read_frame(infile, &raw);        if (vpx_codec_encode(&codec, frame_avail? &raw : NULL, pts,                            1, flags, VPX_DL_REALTIME))            die_codec(&codec, "Failed to encode frame");        // Reset KF flag        layer_flags[0] &= ~VPX_EFLAG_FORCE_KF;        got_data = 0;        while ( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {            got_data = 1;            switch (pkt->kind) {            case VPX_CODEC_CX_FRAME_PKT:                for (i=cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];                                              i<cfg.ts_number_layers; i++)                {                    write_ivf_frame_header(outfile[i], pkt);                    if (fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,                              outfile[i]));                    frames_in_layer[i]++;                }                break;            default:                break;            }            printf (pkt->kind == VPX_CODEC_CX_FRAME_PKT                    && (pkt->data.frame.flags & VPX_FRAME_IS_KEY)? "K":".");            fflush (stdout);        }        frame_cnt++;        pts += frame_duration;    }    printf ("/n");    fclose (infile);    printf ("Processed %d frames./n",frame_cnt-1);    if (vpx_codec_destroy(&codec))            die_codec (&codec, "Failed to destroy codec");    // Try to rewrite the output file headers with the actual frame count    for (i=0; i<cfg.ts_number_layers; i++)    {        if (!fseek(outfile[i], 0, SEEK_SET))            write_ivf_file_header (outfile[i], &cfg, frames_in_layer[i]);        fclose (outfile[i]);    }    return EXIT_SUCCESS;}
开发者ID:AirDev,项目名称:linphone-android,代码行数:101,


示例19: main_loop

//.........这里部分代码省略.........    if (vpx_input_ctx.file_type == FILE_TYPE_WEBM) {      if (webm_guess_framerate(input.webm_ctx, input.vpx_input_ctx)) {        fprintf(stderr, "Failed to guess framerate -- error parsing "                "webm file?/n");        return EXIT_FAILURE;      }    }#endif  }  fourcc_interface = get_vpx_decoder_by_fourcc(vpx_input_ctx.fourcc);  if (interface && fourcc_interface && interface != fourcc_interface)    warn("Header indicates codec: %s/n", fourcc_interface->name);  else    interface = fourcc_interface;  if (!interface)    interface = get_vpx_decoder_by_index(0);  dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) |              (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0);  if (vpx_codec_dec_init(&decoder, interface->interface(), &cfg, dec_flags)) {    fprintf(stderr, "Failed to initialize decoder: %s/n",            vpx_codec_error(&decoder));    return EXIT_FAILURE;  }  if (!quiet)    fprintf(stderr, "%s/n", decoder.name);#if CONFIG_VP8_DECODER  if (vp8_pp_cfg.post_proc_flag      && vpx_codec_control(&decoder, VP8_SET_POSTPROC, &vp8_pp_cfg)) {    fprintf(stderr, "Failed to configure postproc: %s/n", vpx_codec_error(&decoder));    return EXIT_FAILURE;  }  if (vp8_dbg_color_ref_frame      && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_REF_FRAME, vp8_dbg_color_ref_frame)) {    fprintf(stderr, "Failed to configure reference block visualizer: %s/n", vpx_codec_error(&decoder));    return EXIT_FAILURE;  }  if (vp8_dbg_color_mb_modes      && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_MB_MODES, vp8_dbg_color_mb_modes)) {    fprintf(stderr, "Failed to configure macro block visualizer: %s/n", vpx_codec_error(&decoder));    return EXIT_FAILURE;  }  if (vp8_dbg_color_b_modes      && vpx_codec_control(&decoder, VP8_SET_DBG_COLOR_B_MODES, vp8_dbg_color_b_modes)) {    fprintf(stderr, "Failed to configure block visualizer: %s/n", vpx_codec_error(&decoder));    return EXIT_FAILURE;  }  if (vp8_dbg_display_mv      && vpx_codec_control(&decoder, VP8_SET_DBG_DISPLAY_MV, vp8_dbg_display_mv)) {    fprintf(stderr, "Failed to configure motion vector visualizer: %s/n", vpx_codec_error(&decoder));    return EXIT_FAILURE;  }#endif  if (arg_skip)    fprintf(stderr, "Skipping first %d frames./n", arg_skip);
开发者ID:Eric013,项目名称:videoconverter.js,代码行数:67,


示例20: main

//.........这里部分代码省略.........  // Real time parameters.  cfg.rc_dropframe_thresh = strtol(argv[9], NULL, 0);  cfg.rc_end_usage = VPX_CBR;  cfg.rc_min_quantizer = 2;  cfg.rc_max_quantizer = 56;  if (strncmp(encoder->name, "vp9", 3) == 0)    cfg.rc_max_quantizer = 52;  cfg.rc_undershoot_pct = 50;  cfg.rc_overshoot_pct = 50;  cfg.rc_buf_initial_sz = 500;  cfg.rc_buf_optimal_sz = 600;  cfg.rc_buf_sz = 1000;  // Disable dynamic resizing by default.  cfg.rc_resize_allowed = 0;  // Use 1 thread as default.  cfg.g_threads = 1;  // Enable error resilient mode.  cfg.g_error_resilient = 1;  cfg.g_lag_in_frames   = 0;  cfg.kf_mode = VPX_KF_AUTO;  // Disable automatic keyframe placement.  cfg.kf_min_dist = cfg.kf_max_dist = 3000;  cfg.temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;  set_temporal_layer_pattern(layering_mode,                             &cfg,                             layer_flags,                             &flag_periodicity);  set_rate_control_metrics(&rc, &cfg);  // Target bandwidth for the whole stream.  // Set to layer_target_bitrate for highest layer (total bitrate).  cfg.rc_target_bitrate = rc.layer_target_bitrate[cfg.ts_number_layers - 1];  // Open input file.  if (!(infile = fopen(argv[1], "rb"))) {    die("Failed to open %s for reading", argv[1]);  }  framerate = cfg.g_timebase.den / cfg.g_timebase.num;  // Open an output file for each stream.  for (i = 0; i < cfg.ts_number_layers; ++i) {    char file_name[PATH_MAX];    VpxVideoInfo info;    info.codec_fourcc = encoder->fourcc;    info.frame_width = cfg.g_w;    info.frame_height = cfg.g_h;    info.time_base.numerator = cfg.g_timebase.num;    info.time_base.denominator = cfg.g_timebase.den;    snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);    outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);    if (!outfile[i])      die("Failed to open %s for writing", file_name);    assert(outfile[i] != NULL);  }  // No spatial layers in this encoder.  cfg.ss_number_layers = 1;  // Initialize codec.#if CONFIG_VP9_HIGHBITDEPTH  if (vpx_codec_enc_init(          &codec, encoder->codec_interface(), &cfg,          bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH))#else  if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))#endif  // CONFIG_VP9_HIGHBITDEPTH    die_codec(&codec, "Failed to initialize encoder");  // configuration for vp8/vp9  if (strncmp(encoder->name, "vp8", 3) == 0) {    vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);    vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOff);    vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);  } else if (strncmp(encoder->name, "vp9", 3) == 0) {    vpx_svc_extra_cfg_t svc_params;    vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);    vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);    vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);    vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);    vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);    vpx_codec_control(&codec, VP9E_SET_TUNE_CONTENT, 0);    vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));    if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0))      die_codec(&codec, "Failed to set SVC");    for (i = 0; i < cfg.ts_number_layers; ++i) {      svc_params.max_quantizers[i] = cfg.rc_max_quantizer;      svc_params.min_quantizers[i] = cfg.rc_min_quantizer;    }    svc_params.scaling_factor_num[0] = cfg.g_h;    svc_params.scaling_factor_den[0] = cfg.g_h;    vpx_codec_control(&codec, VP9E_SET_SVC_PARAMETERS, &svc_params);  }
开发者ID:nvnhcmus,项目名称:libvpx,代码行数:101,


示例21: main

int main(int argc, char **argv) {    FILE                *infile, *outfile;    vpx_codec_ctx_t      codec;    vpx_codec_enc_cfg_t  cfg;    int                  frame_cnt = 0;    vpx_image_t          raw;    vpx_codec_err_t      res;    long                 width;    long                 height;    int                  frame_avail;    int                  got_data;    int                  flags = 0;    /* Open files */    if(argc!=5)        die("Usage: %s <width> <height> <infile> <outfile>/n", argv[0]);    width = strtol(argv[1], NULL, 0);    height = strtol(argv[2], NULL, 0);    if(width < 16 || width%2 || height <16 || height%2)        die("Invalid resolution: %ldx%ld", width, height);    if(!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 1))        die("Faile to allocate image", width, height);    if(!(outfile = fopen(argv[4], "wb")))        die("Failed to open %s for writing", argv[4]);    printf("Using %s/n",vpx_codec_iface_name(interface));    /* Populate encoder configuration */    res = vpx_codec_enc_config_default(interface, &cfg, 0);    if(res) {        printf("Failed to get config: %s/n", vpx_codec_err_to_string(res));        return EXIT_FAILURE;    }    /* Update the default configuration with our settings */    cfg.rc_target_bitrate = width * height * cfg.rc_target_bitrate                            / cfg.g_w / cfg.g_h;    cfg.g_w = width;    cfg.g_h = height;    write_ivf_file_header(outfile, &cfg, 0);        /* Open input file for this encoding pass */        if(!(infile = fopen(argv[3], "rb")))            die("Failed to open %s for reading", argv[3]);        /* Initialize codec */        if(vpx_codec_enc_init(&codec, interface, &cfg, 0))            die_codec(&codec, "Failed to initialize encoder");        frame_avail = 1;        got_data = 0;        while(frame_avail || got_data) {            vpx_codec_iter_t iter = NULL;            const vpx_codec_cx_pkt_t *pkt;            if(frame_cnt + 1 == 22) {                                         //                vpx_roi_map_t  roi;                                           //                int            i;                                             //                                                                              //                roi.rows = cfg.g_h/16;                                        //                roi.cols = cfg.g_w/16;                                        //                                                                              //                roi.delta_q[0] = 0;                                           //                roi.delta_q[1] = -2;                                          //                roi.delta_q[2] = -4;                                          //                roi.delta_q[3] = -6;                                          //                                                                              //                roi.delta_lf[0] = 0;                                          //                roi.delta_lf[1] = 1;                                          //                roi.delta_lf[2] = 2;                                          //                roi.delta_lf[3] = 3;                                          //                                                                              //                roi.static_threshold[0] = 1500;                               //                roi.static_threshold[1] = 1000;                               //                roi.static_threshold[2] =  500;                               //                roi.static_threshold[3] =    0;                               //                                                                              //                /* generate an ROI map for example */                         //                roi.roi_map = malloc(roi.rows * roi.cols);                    //                for(i=0;i<roi.rows*roi.cols;i++)                              //                    roi.roi_map[i] = i & 3;                                   //                                                                              //                if(vpx_codec_control(&codec, VP8E_SET_ROI_MAP, &roi))         //                    die_codec(&codec, "Failed to set ROI map");               //                                                                              //                free(roi.roi_map);                                            //            } else if(frame_cnt + 1 == 33) {                                  //                vpx_active_map_t  active;                                     //                int               i;                                          //                                                                              //                active.rows = cfg.g_h/16;                                     //                active.cols = cfg.g_w/16;                                     //                                                                              //                /* generate active map for example */                         //                active.active_map = malloc(active.rows * active.cols);        //                for(i=0;i<active.rows*active.cols;i++)                        //                    active.active_map[i] = i & 1;                             //                                                                              ////.........这里部分代码省略.........
开发者ID:Aboutdept,项目名称:Plugin_Videoplayer,代码行数:101,


示例22: pj_vpx_encoder_open

static pj_status_t pj_vpx_encoder_open(vpx_private *vpx) {    vpx_codec_flags_t flags = 0;    const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;    struct vpx_codec_enc_cfg enccfg;    int cpu_speed, rc_max_intra_target;    int res;    PJ_LOG(4, (THIS_FILE, "vpx pj_vpx_encoder_open"));    res = vpx_codec_enc_config_default(iface, &enccfg, 0);    if (res != VPX_CODEC_OK) {        PJ_LOG(1,                (THIS_FILE, "Failed to get vpx default config : %s", vpx_codec_err_to_string(res)));        return PJMEDIA_CODEC_EFAILED;    }    enccfg.g_w = vpx->param.enc_fmt.det.vid.size.w;    enccfg.g_h = vpx->param.enc_fmt.det.vid.size.h;    enccfg.g_timebase.num = vpx->param.enc_fmt.det.vid.fps.num;    enccfg.g_timebase.den = vpx->param.enc_fmt.det.vid.fps.denum;    //provide dummy value to initialize wrapper, values will be updated each _encode()    vpx_img_wrap(&vpx->rawimg, VPX_IMG_FMT_I420,            vpx->param.enc_fmt.det.vid.size.w, vpx->param.enc_fmt.det.vid.size.h,            1, (unsigned char*)1);    // Following config taken from webRTC project.    // vpx seems to support more configurable/complex settings.    // could be interesting to have a look, but for now, consider    // webRTC settings as optimized for our needs#if defined(PJ_HAS_UNISTD_H) && PJ_HAS_UNISTD_H!=0    if (enccfg.g_w * enccfg.g_h > 704 * 576            && sysconf(_SC_NPROCESSORS_CONF) > 1) {        // 2 threads when larger than 4CIF        enccfg.g_threads = 2;    } else#endif    {        enccfg.g_threads = 1;    }    enccfg.g_lag_in_frames = 0;    enccfg.g_pass = VPX_RC_ONE_PASS;    enccfg.rc_end_usage = VPX_CBR;    enccfg.rc_target_bitrate = vpx->param.enc_fmt.det.vid.avg_bps / 1000; // in kbit/s    enccfg.g_timebase.num = 1;    enccfg.g_timebase.den = 90000;    // TODO : need a setting for 2 following ?    enccfg.g_error_resilient = 0;    enccfg.rc_resize_allowed = 1;    enccfg.rc_min_quantizer = 2;    enccfg.rc_max_quantizer = 56;    enccfg.rc_undershoot_pct = 100;    enccfg.rc_overshoot_pct = 15;    enccfg.rc_buf_initial_sz = 500;    enccfg.rc_buf_optimal_sz = 600;    enccfg.rc_buf_sz = 1000;    // Not use feedback_mode    enccfg.kf_mode = VPX_KF_AUTO;    enccfg.kf_max_dist = 3000;    /* scalePar = 0.5; maxFrameRate = 30fps*/    /* Don't go below 3 times the per frame bandwidth. */    rc_max_intra_target = PJ_MAX(300, enccfg.rc_buf_sz * 0.5 * 30 / 10);    // for android cpu speed set to -12    // TODO : adjust for other platform as done in webRTC    cpu_speed = -12;    //flags |= VPX_CODEC_USE_OUTPUT_PARTITION;    res = vpx_codec_enc_init(&vpx->encoder, vpx_codec_vp8_cx(), &enccfg, flags);    if (res != VPX_CODEC_OK) {        PJ_LOG(1,                (THIS_FILE, "Failed to init vpx encoder : %s", vpx_codec_err_to_string(res)));        return PJMEDIA_CODEC_EFAILED;    }    vpx_codec_control(&vpx->encoder, VP8E_SET_STATIC_THRESHOLD, 1);    vpx_codec_control(&vpx->encoder, VP8E_SET_CPUUSED, cpu_speed);    vpx_codec_control(&vpx->encoder, VP8E_SET_TOKEN_PARTITIONS,            VP8_ONE_TOKENPARTITION);    vpx_codec_control(&vpx->encoder, VP8E_SET_NOISE_SENSITIVITY, 1);    vpx_codec_control(&vpx->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT,            rc_max_intra_target);    vpx->enc_iter = NULL;    vpx->enc_buf_size = vpx->enc_vafp.framebytes;    vpx->enc_buf = pj_pool_alloc(vpx->pool, vpx->enc_buf_size);    vpx->dec_buf_size = vpx->dec_vafp.framebytes;    vpx->dec_buf = pj_pool_alloc(vpx->pool, vpx->dec_buf_size);    return PJ_SUCCESS;}
开发者ID:iTeach,项目名称:SipClient,代码行数:89,


示例23: dec_process

static void dec_process(MSFilter *f) {	DecState *s = (DecState *)f->data;	mblk_t *im;	vpx_codec_err_t err;	vpx_image_t *img;	vpx_codec_iter_t iter = NULL;	MSQueue frame;	MSQueue mtofree_queue;	Vp8RtpFmtFrameInfo frame_info;		if (!s->ready){		ms_queue_flush(f->inputs[0]);		return;	}		ms_filter_lock(f);	ms_queue_init(&frame);	ms_queue_init(&mtofree_queue);	/* Unpack RTP payload format for VP8. */	vp8rtpfmt_unpacker_feed(&s->unpacker, f->inputs[0]);	/* Decode unpacked VP8 frames. */	while (vp8rtpfmt_unpacker_get_frame(&s->unpacker, &frame, &frame_info) == 0) {		while ((im = ms_queue_get(&frame)) != NULL) {			err = vpx_codec_decode(&s->codec, im->b_rptr, (unsigned int)(im->b_wptr - im->b_rptr), NULL, 0);			if ((s->flags & VPX_CODEC_USE_INPUT_FRAGMENTS) && mblk_get_marker_info(im)) {				err = vpx_codec_decode(&s->codec, NULL, 0, NULL, 0);			}			if (err) {				ms_warning("vp8 decode failed : %d %s (%s)/n", err, vpx_codec_err_to_string(err), vpx_codec_error_detail(&s->codec)?vpx_codec_error_detail(&s->codec):"no details");			}			ms_queue_put(&mtofree_queue, im);		}		/* Get decoded frame */		if ((img = vpx_codec_get_frame(&s->codec, &iter))) {			int i, j;			int reference_updates = 0;			if (vpx_codec_control(&s->codec, VP8D_GET_LAST_REF_UPDATES, &reference_updates) == 0) {				if (frame_info.pictureid_present && ((reference_updates & VP8_GOLD_FRAME) || (reference_updates & VP8_ALTR_FRAME))) {					vp8rtpfmt_send_rpsi(&s->unpacker, frame_info.pictureid);				}			}			if (s->yuv_width != img->d_w || s->yuv_height != img->d_h) {				if (s->yuv_msg) freemsg(s->yuv_msg);				s->yuv_msg = ms_yuv_buf_alloc(&s->outbuf, img->d_w, img->d_h);				ms_message("MSVp8Dec: video is %ix%i", img->d_w, img->d_h);				s->yuv_width = img->d_w;				s->yuv_height = img->d_h;				ms_filter_notify_no_arg(f, MS_FILTER_OUTPUT_FMT_CHANGED);			}			/* scale/copy frame to destination mblk_t */			for (i = 0; i < 3; i++) {				uint8_t *dest = s->outbuf.planes[i];				uint8_t *src = img->planes[i];				int h = img->d_h >> ((i > 0) ? 1 : 0);				for (j = 0; j < h; j++) {					memcpy(dest, src, s->outbuf.strides[i]);					dest += s->outbuf.strides[i];					src += img->stride[i];				}			}			ms_queue_put(f->outputs[0], dupmsg(s->yuv_msg));			ms_average_fps_update(&s->fps, (uint32_t)f->ticker->time);			if (!s->first_image_decoded) {				s->first_image_decoded = TRUE;				ms_filter_notify_no_arg(f, MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);			}		}		while ((im = ms_queue_get(&mtofree_queue)) != NULL) {			freemsg(im);		}	}
开发者ID:Accontech,项目名称:mediastreamer2,代码行数:81,


示例24: enc_preprocess

static void enc_preprocess(MSFilter *f) {	EncState *s = (EncState *)f->data;	vpx_codec_err_t res;	vpx_codec_caps_t caps;	int cpuused=0;	/* Populate encoder configuration */	s->flags = 0;	caps = vpx_codec_get_caps(s->iface);	if ((s->avpf_enabled == TRUE) && (caps & VPX_CODEC_CAP_OUTPUT_PARTITION)) {		s->flags |= VPX_CODEC_USE_OUTPUT_PARTITION;	}	res = vpx_codec_enc_config_default(s->iface, &s->cfg, 0);	if (res) {		ms_error("Failed to get config: %s", vpx_codec_err_to_string(res));		return;	}	s->cfg.rc_target_bitrate = (unsigned int)(((float)s->vconf.required_bitrate) * 0.92f / 1024.0f); //0.92=take into account IP/UDP/RTP overhead, in average.	s->cfg.g_pass = VPX_RC_ONE_PASS; /* -p 1 */	s->cfg.g_timebase.num = 1;	s->cfg.g_timebase.den = (int)s->vconf.fps;	s->cfg.rc_end_usage = VPX_CBR; /* --end-usage=cbr */	if (s->avpf_enabled == TRUE) {		s->cfg.kf_mode = VPX_KF_DISABLED;	} else {		s->cfg.kf_mode = VPX_KF_AUTO; /* encoder automatically places keyframes */		s->cfg.kf_max_dist = 10 * s->cfg.g_timebase.den; /* 1 keyframe each 10s. */	}#if TARGET_IPHONE_SIMULATOR	s->cfg.g_threads = 1; /*workaround to remove crash on ipad simulator*/#else	s->cfg.g_threads = ms_factory_get_cpu_count(f->factory);#endif	ms_message("VP8 g_threads=%d", s->cfg.g_threads);	s->cfg.rc_undershoot_pct = 95; /* --undershoot-pct=95 */	s->cfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT|VPX_ERROR_RESILIENT_PARTITIONS;	s->cfg.g_lag_in_frames = 0;#if defined(ANDROID) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM)	cpuused = 10 - s->cfg.g_threads; /*cpu/quality tradeoff: positive values decrease CPU usage at the expense of quality*/	if (cpuused < 7) cpuused = 7; /*values beneath 7 consume too much CPU*/	if( s->cfg.g_threads == 1 ){		/* on mono-core iOS devices, we reduce the quality a bit more due to VP8 being slower with new Clang compilers */		cpuused = 16;	}#endif	s->cfg.g_w = s->vconf.vsize.width;	s->cfg.g_h = s->vconf.vsize.height;	/* Initialize codec */	res =  vpx_codec_enc_init(&s->codec, s->iface, &s->cfg, s->flags);	if (res) {		ms_error("vpx_codec_enc_init failed: %s (%s)", vpx_codec_err_to_string(res), vpx_codec_error_detail(&s->codec));		return;	}	vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, cpuused);	vpx_codec_control(&s->codec, VP8E_SET_STATIC_THRESHOLD, 0);	vpx_codec_control(&s->codec, VP8E_SET_ENABLEAUTOALTREF, !s->avpf_enabled);	vpx_codec_control(&s->codec, VP8E_SET_MAX_INTRA_BITRATE_PCT, 400); /*limite iFrame size to 4 pframe*/	if (s->flags & VPX_CODEC_USE_OUTPUT_PARTITION) {		vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 2); /* Output 4 partitions per frame */	} else {		vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 0);	}	s->invalid_frame_reported = FALSE;	vp8rtpfmt_packer_init(&s->packer);	if (s->avpf_enabled == TRUE) {		s->force_keyframe = TRUE;	} else if (s->frame_count == 0) {		ms_video_starter_init(&s->starter);	}	s->ready = TRUE;}
开发者ID:Accontech,项目名称:mediastreamer2,代码行数:76,


示例25: pj_vpx_encoder_open

static pj_status_t pj_vpx_encoder_open(vpx_private *vpx) {    vpx_codec_flags_t flags = 0;    /* XXX: use VPX_CODEC_USE_OUTPUT_PARTITION ? */    const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;    struct vpx_codec_enc_cfg enccfg;    int res;    TRACE_((THIS_FILE, "vpx pj_vpx_encoder_open"));    res = vpx_codec_enc_config_default(iface, &enccfg, 0);    if (res != VPX_CODEC_OK) {        PJ_LOG(1, (THIS_FILE, "Failed to get vpx default config : %s", vpx_codec_err_to_string(res)));        return PJMEDIA_CODEC_EFAILED;    }    enccfg.g_w = vpx->param.enc_fmt.det.vid.size.w;    enccfg.g_h = vpx->param.enc_fmt.det.vid.size.h;    enccfg.g_timebase.num = vpx->param.enc_fmt.det.vid.fps.num;    enccfg.g_timebase.den = vpx->param.enc_fmt.det.vid.fps.denum;    //provide dummy value to initialize wrapper, values will be updated each _encode()    vpx_img_wrap(&vpx->rawimg,                 VPX_IMG_FMT_I420,                 vpx->param.enc_fmt.det.vid.size.w,                 vpx->param.enc_fmt.det.vid.size.h,                 1,                 NULL);    enccfg.g_threads = number_of_threads(enccfg.g_w, enccfg.g_h, number_of_cores());    PJ_LOG(4, (THIS_FILE, "Using %d threads for VPX encoding", enccfg.g_threads));    enccfg.g_lag_in_frames = 0;    enccfg.g_pass = VPX_RC_ONE_PASS;    enccfg.rc_end_usage = VPX_CBR;    enccfg.rc_target_bitrate = vpx->param.enc_fmt.det.vid.avg_bps / 1000; // in kbit/s    enccfg.g_timebase.num = 1;    enccfg.g_timebase.den = 90000;    enccfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT;    enccfg.rc_resize_allowed = 1;    enccfg.rc_min_quantizer = 2;    enccfg.rc_max_quantizer = 56;    enccfg.rc_undershoot_pct = 100;    enccfg.rc_overshoot_pct = 15;    enccfg.rc_buf_initial_sz = 500;    enccfg.rc_buf_optimal_sz = 600;    enccfg.rc_buf_sz = 1000;    enccfg.kf_mode = VPX_KF_AUTO;    enccfg.kf_max_dist = 3000;    vpx->rc_max_intra_target = PJ_MAX(300, enccfg.rc_buf_sz * 0.5 * enccfg.g_timebase.num / 10);    res = vpx_codec_enc_init(&vpx->encoder, vpx_codec_vp8_cx(), &enccfg, flags);    if (res != VPX_CODEC_OK) {        PJ_LOG(1, (THIS_FILE, "Failed to init vpx encoder : %s", vpx_codec_err_to_string(res)));        return PJMEDIA_CODEC_EFAILED;    }    vpx_codec_control(&vpx->encoder, VP8E_SET_STATIC_THRESHOLD, 1);    vpx_codec_control(&vpx->encoder, VP8E_SET_CPUUSED, -6);   // XXX: test    vpx_codec_control(&vpx->encoder, VP8E_SET_TOKEN_PARTITIONS, VP8_ONE_TOKENPARTITION);    vpx_codec_control(&vpx->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT, vpx->rc_max_intra_target);#ifdef VP8E_SET_SCREEN_CONTENT_MODE    vpx_codec_control(&vpx->encoder, VP8E_SET_SCREEN_CONTENT_MODE, 0);#endif    vpx->enc_iter = NULL;    vpx->enc_buf_size = vpx->enc_vafp.framebytes;    vpx->enc_buf = pj_pool_alloc(vpx->pool, vpx->enc_buf_size);    vpx->dec_buf_size = vpx->dec_vafp.framebytes;    vpx->dec_buf = pj_pool_alloc(vpx->pool, vpx->dec_buf_size);    return PJ_SUCCESS;}
开发者ID:acatighera,项目名称:python-sipsimple,代码行数:73,


示例26: gst_vp8_enc_handle_frame

static gbooleangst_vp8_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder,    GstVideoFrame * frame){  GstVP8Enc *encoder;  const GstVideoState *state;  vpx_codec_err_t status;  int flags = 0;  vpx_codec_iter_t iter = NULL;  const vpx_codec_cx_pkt_t *pkt;  vpx_image_t *image;  GstVP8EncCoderHook *hook;  GST_DEBUG_OBJECT (base_video_encoder, "handle_frame");  encoder = GST_VP8_ENC (base_video_encoder);  state = gst_base_video_encoder_get_state (base_video_encoder);  encoder->n_frames++;  GST_DEBUG_OBJECT (base_video_encoder, "size %d %d", state->width,      state->height);  if (!encoder->inited) {    vpx_codec_enc_cfg_t cfg;    status = vpx_codec_enc_config_default (&vpx_codec_vp8_cx_algo, &cfg, 0);    if (status != VPX_CODEC_OK) {      GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,          ("Failed to get default encoder configuration"), ("%s",              gst_vpx_error_name (status)));      return FALSE;    }    cfg.g_w = state->width;    cfg.g_h = state->height;    cfg.g_timebase.num = state->fps_d;    cfg.g_timebase.den = state->fps_n;    cfg.g_error_resilient = encoder->error_resilient;    cfg.g_lag_in_frames = encoder->max_latency;    cfg.g_threads = encoder->threads;    cfg.rc_end_usage = encoder->mode;    if (encoder->bitrate) {      cfg.rc_target_bitrate = encoder->bitrate / 1000;    } else {      cfg.rc_min_quantizer = 63 - encoder->quality * 5.0;      cfg.rc_max_quantizer = 63 - encoder->quality * 5.0;      cfg.rc_target_bitrate = encoder->bitrate;    }    cfg.kf_mode = VPX_KF_AUTO;    cfg.kf_min_dist = 0;    cfg.kf_max_dist = encoder->max_keyframe_distance;    cfg.g_pass = encoder->multipass_mode;    if (encoder->multipass_mode == VPX_RC_FIRST_PASS) {      encoder->first_pass_cache_content = g_byte_array_sized_new (4096);    } else if (encoder->multipass_mode == VPX_RC_LAST_PASS) {      GError *err = NULL;      if (!encoder->multipass_cache_file) {        GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,            ("No multipass cache file provided"), (NULL));        return GST_FLOW_ERROR;      }      if (!g_file_get_contents (encoder->multipass_cache_file,              (gchar **) & encoder->last_pass_cache_content.buf,              &encoder->last_pass_cache_content.sz, &err)) {        GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,            ("Failed to read multipass cache file provided"), ("%s",                err->message));        g_error_free (err);        return GST_FLOW_ERROR;      }      cfg.rc_twopass_stats_in = encoder->last_pass_cache_content;    }    status = vpx_codec_enc_init (&encoder->encoder, &vpx_codec_vp8_cx_algo,        &cfg, 0);    if (status != VPX_CODEC_OK) {      GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,          ("Failed to initialize encoder"), ("%s",              gst_vpx_error_name (status)));      return GST_FLOW_ERROR;    }    status = vpx_codec_control (&encoder->encoder, VP8E_SET_CPUUSED, 0);    if (status != VPX_CODEC_OK) {      GST_WARNING_OBJECT (encoder, "Failed to set VP8E_SET_CPUUSED to 0: %s",          gst_vpx_error_name (status));    }    status =        vpx_codec_control (&encoder->encoder, VP8E_SET_ENABLEAUTOALTREF,        (encoder->auto_alt_ref_frames ? 1 : 0));    if (status != VPX_CODEC_OK) {      GST_WARNING_OBJECT (encoder,//.........这里部分代码省略.........
开发者ID:PeterXu,项目名称:gst-mobile,代码行数:101,


示例27: vpx_svc_init

//.........这里部分代码省略.........      int sl2 = (svc_ctx->spatial_layers == 2) ? sl + 1 : sl;      si->svc_params.scaling_factor_num[sl] = DEFAULT_SCALE_FACTORS_NUM_2x[sl2];      si->svc_params.scaling_factor_den[sl] = DEFAULT_SCALE_FACTORS_DEN_2x[sl2];    }    if (svc_ctx->spatial_layers == 1) {      si->svc_params.scaling_factor_num[0] = 1;      si->svc_params.scaling_factor_den[0] = 1;    }  }  for (tl = 0; tl < svc_ctx->temporal_layers; ++tl) {    for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {      i = sl * svc_ctx->temporal_layers + tl;      si->svc_params.max_quantizers[i] = MAX_QUANTIZER;      si->svc_params.min_quantizers[i] = 0;      if (enc_cfg->rc_end_usage == VPX_CBR &&          enc_cfg->g_pass == VPX_RC_ONE_PASS) {        si->svc_params.max_quantizers[i] = 56;        si->svc_params.min_quantizers[i] = 2;      }    }  }  // Parse aggregate command line options. Options must start with  // "layers=xx" then followed by other options  res = parse_options(svc_ctx, si->options);  if (res != VPX_CODEC_OK) return res;  if (svc_ctx->spatial_layers < 1) svc_ctx->spatial_layers = 1;  if (svc_ctx->spatial_layers > VPX_SS_MAX_LAYERS)    svc_ctx->spatial_layers = VPX_SS_MAX_LAYERS;  if (svc_ctx->temporal_layers < 1) svc_ctx->temporal_layers = 1;  if (svc_ctx->temporal_layers > VPX_TS_MAX_LAYERS)    svc_ctx->temporal_layers = VPX_TS_MAX_LAYERS;  if (svc_ctx->temporal_layers * svc_ctx->spatial_layers > VPX_MAX_LAYERS) {    svc_log(svc_ctx, SVC_LOG_ERROR,            "spatial layers * temporal layers exceeds the maximum number of "            "allowed layers of %d/n",            svc_ctx->spatial_layers * svc_ctx->temporal_layers,            (int)VPX_MAX_LAYERS);    return VPX_CODEC_INVALID_PARAM;  }  res = assign_layer_bitrates(svc_ctx, enc_cfg);  if (res != VPX_CODEC_OK) {    svc_log(svc_ctx, SVC_LOG_ERROR,            "layer bitrates incorrect: /n"            "1) spatial layer bitrates should sum up to target /n"            "2) temporal layer bitrates should be increasing within /n"            "a spatial layer /n");    return VPX_CODEC_INVALID_PARAM;  }#if CONFIG_SPATIAL_SVC  for (i = 0; i < svc_ctx->spatial_layers; ++i)    enc_cfg->ss_enable_auto_alt_ref[i] = si->enable_auto_alt_ref[i];#endif  if (svc_ctx->temporal_layers > 1) {    int i;    for (i = 0; i < svc_ctx->temporal_layers; ++i) {      enc_cfg->ts_target_bitrate[i] =          enc_cfg->rc_target_bitrate / svc_ctx->temporal_layers;      enc_cfg->ts_rate_decimator[i] = 1 << (svc_ctx->temporal_layers - 1 - i);    }  }  if (svc_ctx->threads) enc_cfg->g_threads = svc_ctx->threads;  // Modify encoder configuration  enc_cfg->ss_number_layers = svc_ctx->spatial_layers;  enc_cfg->ts_number_layers = svc_ctx->temporal_layers;  if (enc_cfg->rc_end_usage == VPX_CBR) {    enc_cfg->rc_resize_allowed = 0;    enc_cfg->rc_min_quantizer = 2;    enc_cfg->rc_max_quantizer = 56;    enc_cfg->rc_undershoot_pct = 50;    enc_cfg->rc_overshoot_pct = 50;    enc_cfg->rc_buf_initial_sz = 500;    enc_cfg->rc_buf_optimal_sz = 600;    enc_cfg->rc_buf_sz = 1000;    enc_cfg->rc_dropframe_thresh = 0;  }  if (enc_cfg->g_error_resilient == 0 && si->use_multiple_frame_contexts == 0)    enc_cfg->g_error_resilient = 1;  // Initialize codec  res = vpx_codec_enc_init(codec_ctx, iface, enc_cfg, VPX_CODEC_USE_PSNR);  if (res != VPX_CODEC_OK) {    svc_log(svc_ctx, SVC_LOG_ERROR, "svc_enc_init error/n");    return res;  }  if (svc_ctx->spatial_layers > 1 || svc_ctx->temporal_layers > 1) {    vpx_codec_control(codec_ctx, VP9E_SET_SVC, 1);    vpx_codec_control(codec_ctx, VP9E_SET_SVC_PARAMETERS, &si->svc_params);  }  return VPX_CODEC_OK;}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:101,


示例28: main

int main(int argc, char **argv) {    FILE                *infile, *outfile;    vpx_codec_ctx_t      codec;    vpx_codec_enc_cfg_t  cfg;    int                  frame_cnt = 0;    vpx_image_t          raw;    vpx_codec_err_t      res;    long                 width;    long                 height;    int                  frame_avail;    int                  got_data;    int                  flags = 0;    int                  update_frame_num = 0;    /* Open files */    if(argc!=6)        die("Usage: %s <width> <height> <infile> <outfile> <frame>/n",            argv[0]);        update_frame_num = atoi(argv[5]);        if(!update_frame_num)            die("Couldn't parse frame number '%s'/n", argv[5]);    width = strtol(argv[1], NULL, 0);    height = strtol(argv[2], NULL, 0);    if(width < 16 || width%2 || height <16 || height%2)        die("Invalid resolution: %ldx%ld", width, height);    if(!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 1))        die("Faile to allocate image", width, height);    if(!(outfile = fopen(argv[4], "wb")))        die("Failed to open %s for writing", argv[4]);    printf("Using %s/n",vpx_codec_iface_name(interface));    /* Populate encoder configuration */    res = vpx_codec_enc_config_default(interface, &cfg, 0);    if(res) {        printf("Failed to get config: %s/n", vpx_codec_err_to_string(res));        return EXIT_FAILURE;    }    /* Update the default configuration with our settings */    cfg.rc_target_bitrate = width * height * cfg.rc_target_bitrate                            / cfg.g_w / cfg.g_h;    cfg.g_w = width;    cfg.g_h = height;    write_ivf_file_header(outfile, &cfg, 0);        /* Open input file for this encoding pass */        if(!(infile = fopen(argv[3], "rb")))            die("Failed to open %s for reading", argv[3]);        /* Initialize codec */        if(vpx_codec_enc_init(&codec, interface, &cfg, 0))            die_codec(&codec, "Failed to initialize encoder");        frame_avail = 1;        got_data = 0;        while(frame_avail || got_data) {            vpx_codec_iter_t iter = NULL;            const vpx_codec_cx_pkt_t *pkt;            frame_avail = read_frame(infile, &raw);            if(frame_cnt + 1 == update_frame_num) {                vpx_ref_frame_t ref;                ref.frame_type = VP8_LAST_FRAME;                ref.img        = raw;                if(vpx_codec_control(&codec, VP8_SET_REFERENCE, &ref))                    die_codec(&codec, "Failed to set reference frame");            }            if(vpx_codec_encode(&codec, frame_avail? &raw : NULL, frame_cnt,                                1, flags, VPX_DL_REALTIME))                die_codec(&codec, "Failed to encode frame");            got_data = 0;            while( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {                got_data = 1;                switch(pkt->kind) {                case VPX_CODEC_CX_FRAME_PKT:                    write_ivf_frame_header(outfile, pkt);                    (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,                                  outfile);                    break;                default:                    break;                }                printf(pkt->kind == VPX_CODEC_CX_FRAME_PKT                       && (pkt->data.frame.flags & VPX_FRAME_IS_KEY)? "K":".");                fflush(stdout);            }            frame_cnt++;        }        printf("/n");        fclose(infile);//.........这里部分代码省略.........
开发者ID:JasonOldWoo,项目名称:webrtc-qt,代码行数:101,


示例29: LOGGER_WARNING

VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,                  toxav_video_receive_frame_cb *cb, void *cb_data){    VCSession *vc = (VCSession *)calloc(sizeof(VCSession), 1);    vpx_codec_err_t rc;    if (!vc) {        LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");        return nullptr;    }    if (create_recursive_mutex(vc->queue_mutex) != 0) {        LOGGER_WARNING(log, "Failed to create recursive mutex!");        free(vc);        return nullptr;    }    int cpu_used_value = VP8E_SET_CPUUSED_VALUE;    vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE);    if (!vc->vbuf_raw) {        goto BASE_CLEANUP;    }    /*     * VPX_CODEC_USE_FRAME_THREADING     *    Enable frame-based multi-threading     *     * VPX_CODEC_USE_ERROR_CONCEALMENT     *    Conceal errors in decoded frames     */    vpx_codec_dec_cfg_t  dec_cfg;    dec_cfg.threads = VPX_MAX_DECODER_THREADS; // Maximum number of threads to use    dec_cfg.w = VIDEO_CODEC_DECODER_MAX_WIDTH;    dec_cfg.h = VIDEO_CODEC_DECODER_MAX_HEIGHT;    LOGGER_DEBUG(log, "Using VP8 codec for decoder (0)");    rc = vpx_codec_dec_init(vc->decoder, video_codec_decoder_interface(), &dec_cfg,                            VPX_CODEC_USE_FRAME_THREADING | VPX_CODEC_USE_POSTPROC);    if (rc == VPX_CODEC_INCAPABLE) {        LOGGER_WARNING(log, "Postproc not supported by this decoder (0)");        rc = vpx_codec_dec_init(vc->decoder, video_codec_decoder_interface(), &dec_cfg, VPX_CODEC_USE_FRAME_THREADING);    }    if (rc != VPX_CODEC_OK) {        LOGGER_ERROR(log, "Init video_decoder failed: %s", vpx_codec_err_to_string(rc));        goto BASE_CLEANUP;    }    if (VIDEO_VP8_DECODER_POST_PROCESSING_ENABLED == 1) {        vp8_postproc_cfg_t pp = {VP8_DEBLOCK, 1, 0};        vpx_codec_err_t cc_res = vpx_codec_control(vc->decoder, VP8_SET_POSTPROC, &pp);        if (cc_res != VPX_CODEC_OK) {            LOGGER_WARNING(log, "Failed to turn on postproc");        } else {            LOGGER_DEBUG(log, "turn on postproc: OK");        }    } else {        vp8_postproc_cfg_t pp = {0, 0, 0};        vpx_codec_err_t cc_res = vpx_codec_control(vc->decoder, VP8_SET_POSTPROC, &pp);        if (cc_res != VPX_CODEC_OK) {            LOGGER_WARNING(log, "Failed to turn OFF postproc");        } else {            LOGGER_DEBUG(log, "Disable postproc: OK");        }    }    /* Set encoder to some initial values     */    vpx_codec_enc_cfg_t  cfg;    vc_init_encoder_cfg(log, &cfg, 1);    LOGGER_DEBUG(log, "Using VP8 codec for encoder (0.1)");    rc = vpx_codec_enc_init(vc->encoder, video_codec_encoder_interface(), &cfg, VPX_CODEC_USE_FRAME_THREADING);    if (rc != VPX_CODEC_OK) {        LOGGER_ERROR(log, "Failed to initialize encoder: %s", vpx_codec_err_to_string(rc));        goto BASE_CLEANUP_1;    }    rc = vpx_codec_control(vc->encoder, VP8E_SET_CPUUSED, cpu_used_value);    if (rc != VPX_CODEC_OK) {        LOGGER_ERROR(log, "Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));        vpx_codec_destroy(vc->encoder);        goto BASE_CLEANUP_1;    }    /*    VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY,  unsigned int)    control function to set noise sensitivity      0: off, 1: OnYOnly, 2: OnYUV, 3: OnYUVAggressive, 4: Adaptive    */    /*      rc = vpx_codec_control(vc->encoder, VP8E_SET_NOISE_SENSITIVITY, 2);//.........这里部分代码省略.........
开发者ID:TokTok,项目名称:toxcore,代码行数:101,



注:本文中的vpx_codec_control函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ vpx_codec_err_to_string函数代码示例
C++ vpx_calloc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。