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

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

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

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

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

示例1: output_ffmpeg_init

static int output_ffmpeg_init(void){	Log_error("ffmpeg", "output_ffmpeg_init----- ");	SongMetaData_init(&song_meta_);	register_mime_type("audio/*");	register_mime_type("audio/x-mpeg");	register_mime_type("audio/mpeg");    av_register_all();    avformat_network_init();	//:(s_pFormatCtx = avformat_alloc_context();    s_au_convert_ctx = swr_alloc();    s_out_buffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE * 2);    s_pFrame = av_frame_alloc();    mp_msg_init();    char ** ao_list= malloc(sizeof(char*)*2);    const int c_number_count = 10;    *ao_list = malloc(sizeof(char) * c_number_count);    ao_list[1] = malloc(sizeof(char) *c_number_count);    strcpy(ao_list[0],"alsa");    memset(ao_list[1],0, c_number_count);    s_audio_device = init_best_audio_out(ao_list, 0, 44100, 2,AF_FORMAT_S16_LE,0);    assert(s_audio_device != NULL);    free(ao_list[0]);    free(ao_list[1]);    free(ao_list);	    mixer_Init_control_point(&s_mixer, s_audio_device);	pthread_mutex_init(&s_mutex, NULL);    pthread_cond_init(&s_cond, NULL);	return 0;}
开发者ID:alinzai,项目名称:audio,代码行数:35,


示例2: av_get_channel_layout_nb_channels

EC_U32 AudioWaveScale::Init(MediaCtxInfo* pMediaInfo, AudioPCMBuffer *pFirstFrame){    if (EC_NULL == pMediaInfo)        return Audio_Render_Err_InitFail;    EC_S32 out_sample_rate = pMediaInfo->m_nSampleRate;    EC_S64 out_channel_layout = AV_CH_LAYOUT_STEREO;    EC_S32 out_channels = av_get_channel_layout_nb_channels(out_channel_layout);    AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16;    AVCodecContext *pCodecCtx = (AVCodecContext*)(pMediaInfo->m_pAudioCodecInfo);    EC_S64 in_channel_layout = av_get_default_channel_layout(pCodecCtx->channels);    EC_S32 in_sample_rate = pCodecCtx->sample_rate;    AVSampleFormat in_sample_fmt = pCodecCtx->sample_fmt;    m_nOutChannels = out_channels;    m_nOutSampleFormat = out_sample_fmt;    m_pWaveScaleContext = swr_alloc();    m_pWaveScaleContext = swr_alloc_set_opts(m_pWaveScaleContext,                                              out_channel_layout,                                             out_sample_fmt,                                             out_sample_rate,                                             in_channel_layout,                                              in_sample_fmt,                                              in_sample_rate, 0, NULL);    EC_S32 nRet = swr_init(m_pWaveScaleContext);    if (nRet < 0) return Audio_Render_Err_InitFail;    m_pScaleOutbuffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE * 2);    if (m_pScaleOutbuffer == EC_NULL) return EC_Err_Memory_Low;    return Audio_Render_Err_None;}
开发者ID:brooksgod,项目名称:SuPlayer,代码行数:34,


示例3: av_swr_alloc

struct SwrContext * av_swr_alloc(int in_ch,int in_rate,enum AVSampleFormat in_fmt,                          int out_ch,int out_rate,enum AVSampleFormat out_fmt){    int ret;    struct SwrContext * swr = swr_alloc();    if (!swr) {        av_log(NULL, AV_LOG_FATAL, "Could not allocate resampler context./n");        return NULL;    }    /* set options */    av_opt_set_int(swr, "in_channel_count", in_ch, 0);    av_opt_set_int(swr, "in_sample_rate", in_rate, 0);    av_opt_set_sample_fmt(swr, "in_sample_fmt", in_fmt, 0);    av_opt_set_int(swr, "out_channel_count", out_ch, 0);    av_opt_set_int(swr, "out_sample_rate", out_rate, 0);    av_opt_set_sample_fmt(swr, "out_sample_fmt", out_fmt, 0);    /* initialize the resampling context */    if ((ret = swr_init(swr)) < 0) {        av_log(NULL, AV_LOG_FATAL, "Failed to initialize the resampling context/n");        return NULL;    }    return swr;}
开发者ID:JohnCrash,项目名称:ffplayer,代码行数:26,


示例4: control

// Initialization and runtime controlstatic int control(struct af_instance_s* af, int cmd, void* arg){  af_resample_t* s   = (af_resample_t*)af->setup;  af_data_t *data= (af_data_t*)arg;  int out_rate, test_output_res; // helpers for checking input format  switch(cmd){  case AF_CONTROL_REINIT:    if((af->data->rate == data->rate) || (af->data->rate == 0))        return AF_DETACH;    af->data->nch    = data->nch;    if (af->data->nch > AF_NCH) af->data->nch = AF_NCH;    af->data->format = AF_FORMAT_S16_NE;    af->data->bps    = 2;    af->mul = (double)af->data->rate / data->rate;    af->delay = af->data->nch * s->filter_length / FFMIN(af->mul, 1); // *bps*.5    if (s->ctx_out_rate != af->data->rate || s->ctx_in_rate != data->rate || s->ctx_filter_size != s->filter_length ||        s->ctx_phase_shift != s->phase_shift || s->ctx_linear != s->linear || s->ctx_cutoff != s->cutoff) {        swr_free(&s->swrctx);        if((s->swrctx=swr_alloc()) == NULL) return AF_ERROR;        av_opt_set_int(s->swrctx, "out_sample_rate", af->data->rate, 0);        av_opt_set_int(s->swrctx, "in_sample_rate", data->rate, 0);        av_opt_set_int(s->swrctx, "filter_size", s->filter_length, 0);        av_opt_set_int(s->swrctx, "phase_shift", s->phase_shift, 0);        av_opt_set_int(s->swrctx, "linear_interp", s->linear, 0);        av_opt_set_double(s->swrctx, "cutoff", s->cutoff, 0);        av_opt_set_sample_fmt(s->swrctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);        av_opt_set_sample_fmt(s->swrctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);        av_opt_set_int(s->swrctx, "in_channel_count", af->data->nch, 0);        av_opt_set_int(s->swrctx, "out_channel_count", af->data->nch, 0);        if(swr_init(s->swrctx) < 0) return AF_ERROR;        s->ctx_out_rate    = af->data->rate;        s->ctx_in_rate     = data->rate;        s->ctx_filter_size = s->filter_length;        s->ctx_phase_shift = s->phase_shift;        s->ctx_linear      = s->linear;        s->ctx_cutoff      = s->cutoff;    }    // hack to make af_test_output ignore the samplerate change    out_rate = af->data->rate;    af->data->rate = data->rate;    test_output_res = af_test_output(af, (af_data_t*)arg);    af->data->rate = out_rate;    return test_output_res;  case AF_CONTROL_COMMAND_LINE:{    s->cutoff= 0.0;    sscanf((char*)arg,"%d:%d:%d:%d:%lf", &af->data->rate, &s->filter_length, &s->linear, &s->phase_shift, &s->cutoff);    if(s->cutoff <= 0.0) s->cutoff= FFMAX(1.0 - 6.5/(s->filter_length+8), 0.80);    return AF_OK;  }  case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:    af->data->rate = *(int*)arg;    return AF_OK;  }  return AF_UNKNOWN;}
开发者ID:basinilya,项目名称:mplayer,代码行数:60,


示例5: init_opts

void init_opts(void){#if CONFIG_SWSCALE    sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,                              NULL, NULL, NULL);#endif    swr_opts = swr_alloc();}
开发者ID:AlexanderDenkMA,项目名称:TypeChef-mplayerAnalysis,代码行数:8,


示例6: init_opts

void init_opts(void){    if(CONFIG_SWSCALE)        sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,                              NULL, NULL, NULL);    if(CONFIG_SWRESAMPLE)        swr_opts = swr_alloc();}
开发者ID:jonathanpang,项目名称:FFmpeg,代码行数:10,


示例7: open_audio

static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg){    AVCodecContext *c;    int nb_samples;    int ret;    AVDictionary *opt = NULL;        c = ost->st->codec;        /* open it */    av_dict_copy(&opt, opt_arg, 0);    ret = avcodec_open2(c, codec, &opt);    av_dict_free(&opt);    if (ret < 0) {        fprintf(stderr, "Could not open audio codec: %s/n", av_err2str(ret));        exit(1);    }        /* init signal generator */    ost->t     = 0;    ost->tincr = 2 * M_PI * 110.0 / c->sample_rate;    /* increment frequency by 110 Hz per second */    ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;        if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)        nb_samples = 10000;    else        nb_samples = c->frame_size;        ost->frame     = alloc_audio_frame(c->sample_fmt, c->channel_layout,                                       c->sample_rate, nb_samples);    ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,                                       c->sample_rate, nb_samples);        /* create resampler context */    ost->swr_ctx = swr_alloc();    if (!ost->swr_ctx) {        fprintf(stderr, "Could not allocate resampler context/n");        exit(1);    }        /* set options */    av_opt_set_int       (ost->swr_ctx, "in_channel_count",   c->channels,       0);    av_opt_set_int       (ost->swr_ctx, "in_sample_rate",     c->sample_rate,    0);    av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",      AV_SAMPLE_FMT_S16, 0);    av_opt_set_int       (ost->swr_ctx, "out_channel_count",  c->channels,       0);    av_opt_set_int       (ost->swr_ctx, "out_sample_rate",    c->sample_rate,    0);    av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",     c->sample_fmt,     0);        /* initialize the resampling context */    if ((ret = swr_init(ost->swr_ctx)) < 0) {        fprintf(stderr, "Failed to initialize the resampling context/n");        exit(1);    }}
开发者ID:f-v-m,项目名称:ffmpegForUnity,代码行数:55,


示例8: av_dict_copy

	bool FFMPEGer::open_audio(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg){		AVCodecContext *c;		int nb_samples;		int ret;		AVDictionary *opt = NULL;		c = ost->st->codec;		/* open it */		av_dict_copy(&opt, opt_arg, 0);		ret = avcodec_open2(c, codec, &opt);		av_dict_free(&opt);		if (ret < 0) {			ALOGE("Could not open audio codec: %s", av_err2str(ret));			return false;		}		if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)			nb_samples = 10000;		else			nb_samples = c->frame_size;						ost->frame = alloc_audio_frame(c->sample_fmt, c->channel_layout,									   c->sample_rate, nb_samples);		ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,										   c->sample_rate, nb_samples);		/* create resampler context */        ost->swr_ctx = swr_alloc();        if (!ost->swr_ctx) {            ALOGE("Could not allocate resampler context");            return false;        }		        /* set options */        av_opt_set_int       (ost->swr_ctx, "in_channel_count",   c->channels,       0);        av_opt_set_int       (ost->swr_ctx, "in_sample_rate",     c->sample_rate,    0);        av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",      AV_SAMPLE_FMT_S16, 0);        av_opt_set_int       (ost->swr_ctx, "out_channel_count",  c->channels,       0);        av_opt_set_int       (ost->swr_ctx, "out_sample_rate",    c->sample_rate,    0);        av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",     c->sample_fmt,     0);		/* initialize the resampling context */		ret = swr_init(ost->swr_ctx);        if (ret < 0){            ALOGE("Failed to initialize the resampling context");			return false;		}		return true;	}
开发者ID:forbe,项目名称:recorder,代码行数:50,


示例9: ffmpeg_stream_new_audio

valueffmpeg_stream_new_audio(value ctx, value audio_info_){  CAMLparam2(ctx, audio_info_);  CAMLlocal1(stream);  AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_AAC);  stream = caml_alloc_tuple(StreamSize);  int ret;  Stream_aux_direct_val(stream) = caml_alloc_custom(&streamaux_ops, sizeof(struct StreamAux), 0, 1);  Stream_aux_val(stream)->type = Val_int(STREAM_AUDIO);  Stream_context_direct_val(stream) = ctx;  Stream_aux_val(stream)->avstream = avformat_new_stream(Context_val(ctx)->fmtCtx, codec);  Stream_aux_val(stream)->avstream->codec->codec_id    = AV_CODEC_ID_AAC;  Stream_aux_val(stream)->avstream->codec->sample_rate = Int_val(Field(audio_info_, 0));  Stream_aux_val(stream)->avstream->codec->channels    = Int_val(Field(audio_info_, 1));  Stream_aux_val(stream)->avstream->codec->sample_fmt  = codec->sample_fmts ? codec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;  Stream_aux_val(stream)->avstream->codec->channel_layout = AV_CH_LAYOUT_STEREO;  //Stream_aux_val(stream)->avstream->codec->channels    = av_get_channel_layout_nb_channels(Stream_aux_val(stream)->avstream->codec->channel_layout);  if (Context_val(ctx)->fmtCtx->oformat->flags & AVFMT_GLOBALHEADER) {    Stream_aux_val(stream)->avstream->codec->flags   |= AV_CODEC_FLAG_GLOBAL_HEADER;  }  Stream_aux_val(stream)->avstream->time_base = (AVRational) {1, 10000};  AVDictionary* codecOpts = NULL;  AVCodecContext* codecCtx = Stream_aux_val(stream)->avstream->codec;  caml_enter_blocking_section();  ret = avcodec_open2(codecCtx, codec, &codecOpts);  raise_and_leave_blocking_section_if_not(ret >= 0, ExnOpen, ret);  caml_leave_blocking_section();  if (Stream_aux_val(stream)->avstream->codec->sample_fmt != AV_SAMPLE_FMT_S16) {    Stream_aux_val(stream)->swrCtx = swr_alloc();    assert(Stream_aux_val(stream)->swrCtx);    av_opt_set_int       (Stream_aux_val(stream)->swrCtx, "in_channel_count",   Stream_aux_val(stream)->avstream->codec->channels, 0);    av_opt_set_int       (Stream_aux_val(stream)->swrCtx, "in_sample_rate",     Stream_aux_val(stream)->avstream->codec->sample_rate, 0);    av_opt_set_sample_fmt(Stream_aux_val(stream)->swrCtx, "in_sample_fmt",      AV_SAMPLE_FMT_S16, 0);    av_opt_set_int       (Stream_aux_val(stream)->swrCtx, "out_channel_count",  Stream_aux_val(stream)->avstream->codec->channels, 0);    av_opt_set_int       (Stream_aux_val(stream)->swrCtx, "out_sample_rate",    Stream_aux_val(stream)->avstream->codec->sample_rate, 0);    av_opt_set_sample_fmt(Stream_aux_val(stream)->swrCtx, "out_sample_fmt",     Stream_aux_val(stream)->avstream->codec->sample_fmt, 0);  }    CAMLreturn((value) stream);}
开发者ID:eras,项目名称:webcamviewer,代码行数:50,


示例10: OpenAudio

static void OpenAudio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg, int sample_rate){	AVCodecContext *c = NULL;	int nb_samples = 0;	int ret = 0;	AVDictionary *opt = NULL;	c = ost->st->codec;	// コ
C++ swr_alloc_set_opts函数代码示例
C++ swprintf_s函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。