comparison libmpcodecs/ad_ffmpeg.c @ 36372:c95bdc49af2e

ad_ffmpeg: fix commit fixing sample rate changes to actually work.
author reimar
date Wed, 16 Oct 2013 17:20:31 +0000
parents 3dfc82c0a678
children 741131acf556
comparison
equal deleted inserted replaced
36371:bbf289ad03f2 36372:c95bdc49af2e
66 if (!sample_format) 66 if (!sample_format)
67 sample_format = sh_audio->sample_format; 67 sample_format = sh_audio->sample_format;
68 if(sh_audio->wf){ 68 if(sh_audio->wf){
69 struct adctx *c = lavc_context->opaque; 69 struct adctx *c = lavc_context->opaque;
70 c->srate_changed |= c->last_samplerate && c->last_samplerate != samplerate; 70 c->srate_changed |= c->last_samplerate && c->last_samplerate != samplerate;
71 c->last_samplerate = samplerate;
71 // If the decoder uses the wrong number of channels all is lost anyway. 72 // If the decoder uses the wrong number of channels all is lost anyway.
72 // sh_audio->channels=sh_audio->wf->nChannels; 73 // sh_audio->channels=sh_audio->wf->nChannels;
73 74
74 if (lavc_context->codec_id == AV_CODEC_ID_AAC && 75 if (lavc_context->codec_id == AV_CODEC_ID_AAC &&
75 samplerate == 2*sh_audio->wf->nSamplesPerSec) { 76 samplerate == 2*sh_audio->wf->nSamplesPerSec) {
110 return 0; 111 return 0;
111 } 112 }
112 113
113 lavc_context = avcodec_alloc_context3(lavc_codec); 114 lavc_context = avcodec_alloc_context3(lavc_codec);
114 sh_audio->context=lavc_context; 115 sh_audio->context=lavc_context;
115 lavc_context->opaque = calloc(sizeof(struct adctx), 1); 116 lavc_context->opaque = av_mallocz(sizeof(struct adctx));
116 117
117 snprintf(tmpstr, sizeof(tmpstr), "%f", drc_level); 118 snprintf(tmpstr, sizeof(tmpstr), "%f", drc_level);
118 av_dict_set(&opts, "drc_scale", tmpstr, 0); 119 av_dict_set(&opts, "drc_scale", tmpstr, 0);
119 lavc_context->sample_rate = sh_audio->samplerate; 120 lavc_context->sample_rate = sh_audio->samplerate;
120 lavc_context->bit_rate = sh_audio->i_bps * 8; 121 lavc_context->bit_rate = sh_audio->i_bps * 8;