Index: src/decoder/dec_lavc.c =================================================================== --- aqualung/src/decoder/dec_lavc.c (revision 1245) +++ aqualung/src/decoder/dec_lavc.c (working copy) @@ -44,8 +44,10 @@ lavc_pdata_t * pd = (lavc_pdata_t *)dec->pdata; file_decoder_t * fdec = dec->fdec; + AVFrame frame; + int ret, got_frame = 0, plane_size; AVPacket packet; - int16_t samples[AVCODEC_MAX_AUDIO_FRAME_SIZE]; + int16_t *samples; float fsamples[AVCODEC_MAX_AUDIO_FRAME_SIZE]; int n_bytes = AVCODEC_MAX_AUDIO_FRAME_SIZE; @@ -54,7 +56,15 @@ if (packet.stream_index == pd->audioStream) { - avcodec_decode_audio3(pd->avCodecCtx, samples, &n_bytes, &packet); + ret = avcodec_decode_audio4(pd->avCodecCtx, &frame, &got_frame, &packet); + if (ret < 0 || !got_frame) + goto out; + n_bytes = av_samples_get_buffer_size(&plane_size, + pd->avCodecCtx->channels, + frame.nb_samples, + pd->avCodecCtx->sample_fmt, 1); + samples = (int16_t*) frame.extended_data[0]; + if (n_bytes > 0) { int i; for (i = 0; i < n_bytes/2; i++) { @@ -63,6 +73,7 @@ rb_write(pd->rb, (char *)fsamples, n_bytes/2 * sample_size); } } +out: av_free_packet(&packet); return 0; } @@ -112,10 +123,10 @@ file_decoder_t * fdec = dec->fdec; int i; - if (av_open_input_file(&pd->avFormatCtx, filename, NULL, 0, NULL) != 0) + if (avformat_open_input(&pd->avFormatCtx, filename, NULL, NULL) != 0) return DECODER_OPEN_BADLIB; - if (av_find_stream_info(pd->avFormatCtx) < 0) + if (avformat_find_stream_info(pd->avFormatCtx, NULL) < 0) return DECODER_OPEN_BADLIB; /* debug */ @@ -141,7 +152,7 @@ if (pd->avCodec == NULL) return DECODER_OPEN_BADLIB; - if (avcodec_open(pd->avCodecCtx, pd->avCodec) < 0) + if (avcodec_open2(pd->avCodecCtx, pd->avCodec, NULL) < 0) return DECODER_OPEN_BADLIB; if ((pd->avCodecCtx->channels != 1) && (pd->avCodecCtx->channels != 2)) { @@ -185,7 +196,7 @@ lavc_pdata_t * pd = (lavc_pdata_t *)dec->pdata; avcodec_close(pd->avCodecCtx); - av_close_input_file(pd->avFormatCtx); + avformat_close_input(&pd->avFormatCtx); rb_free(pd->rb); }