Hey,
I don't knwo if this helps but you can check out my classes used in
QDVDAuthor
the file you are looking for is located under
qdvdauthor/qrender/engine/ffmpeg_enc.cpp
http://qdvdauthor.cvs.sourceforge.net/viewvc/qdvdauthor/qdvdauthor/qrender/engine/
Hope that helps.
Varol :)
Álan Crístoffer wrote:
> Sorry, forgot the code:
>
> void AVConverter::decode_audio()
> {
> out.audio.outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE * 2;
> if ( ( out.audio.outbuf_size = avcodec_decode_audio2 (
> in.audio.codec_ctx, out.audio.samples,
> &out.audio.outbuf_size,
> in.packet->data, in.packet->size ) ) <= 0
> )
> {
> error = CouldNotDecodeAudioFrame;
> }
>
> if ( in.audio.codec_ctx->sample_rate != out.audio.codec_ctx->sample_rate
> || out.audio.codec_ctx->channels != in.audio.codec_ctx->channels )
> {
> int16_t* buffer = ( int16_t* ) av_malloc (
> AVCODEC_MAX_AUDIO_FRAME_SIZE * 2 );
>
> int isize =
> av_get_bits_per_sample_format(out.audio.codec_ctx->sample_fmt)/8;
>
> ReSampleContext *rsctx = av_audio_resample_init (
> out.audio.codec_ctx->channels,
> in.audio.codec_ctx->channels,
> out.audio.codec_ctx->sample_rate,
> in.audio.codec_ctx->sample_rate,
> out.audio.codec_ctx->sample_fmt,
> in.audio.codec_ctx->sample_fmt,
> 16, 10, 0, 0.8 );
> int size = audio_resample ( rsctx, buffer, out.audio.samples, 2 );
>
> AVResampleContext *avrsctx = av_resample_init (
> out.audio.codec_ctx->sample_rate, in.audio.codec_ctx->sample_rate,
> 16, 10, 0, 0.8 );
>
> int consumed;
> if ( av_resample ( avrsctx, buffer, out.audio.samples, &consumed,
> out.audio.outbuf_size/isize,
> AVCODEC_MAX_AUDIO_FRAME_SIZE*2, 0 ) <= 0 )
> {
> return;
> }
>
> out.audio.samples = buffer;
> out.audio.outbuf_size = size;
>
> av_freep ( &buffer );
> av_freep ( &rsctx );
> }
> }
>
>
> thanks,
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user