| | 15 | static int decode_audio(AVCodecContext *avctx, int16_t *samples, |
| | 16 | int *frame_size_ptr, |
| | 17 | const uint8_t *buf, int buf_size) |
| | 18 | { |
| | 19 | #if LIBAVCODEC_VERSION_MAJOR >= 52 |
| | 20 | |
| | 21 | // following code segment copied from ffmpeg's avcodec_decode_audio2() |
| | 22 | // implementation to avoid warnings about deprecated function usage. |
| | 23 | AVPacket avpkt; |
| | 24 | av_init_packet(&avpkt); |
| | 25 | avpkt.data = const_cast<uint8_t *>(buf); |
| | 26 | avpkt.size = buf_size; |
| | 27 | |
| | 28 | return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt); |
| | 29 | #else |
| | 30 | // fallback for older versions of ffmpeg that don't have avcodec_decode_audio3. |
| | 31 | return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size); |
| | 32 | #endif |
| | 33 | } |