p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_MOVIE_LOADER, "Audio: Failed to allocate context\n");
return -1;
}
+#if LIBAVCODEC_VERSION_MAJOR > 56
avcodec_parameters_to_context(c, audio_stream->codecpar);
-
+#endif
int dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_context, c->sample_rate) + frame->nb_samples,
c->sample_rate, c->sample_rate, AV_ROUND_UP);
//av_ts_make_time_string(str_buf, frame->pts, &audio_dec_ctx->time_base);
st = fmt_ctx->streams[stream_index];
/* find decoder for the stream */
+#if LIBAVCODEC_VERSION_MAJOR <= 56
+ dec_ctx = st->codec;
+ __dec = avcodec_find_decoder(dec_ctx->codec_id);
+#else
__dec = avcodec_find_decoder(st->codecpar->codec_id);
if (!__dec) {
//avcodec_free_context(&dec_ctx);
}
dec_ctx = avcodec_alloc_context3(__dec);
avcodec_parameters_to_context(dec_ctx, st->codecpar);
- printf("CODEC %s\n", __dec->name);
+#endif
+ p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_MOVIE_LOADER, "CODEC %s\n", __dec->name);
if(ctx != NULL) {
*ctx = dec_ctx;
}
if (open_codec_context(&audio_stream_idx, fmt_ctx, &audio_dec_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
audio_stream = fmt_ctx->streams[audio_stream_idx];
+#if LIBAVCODEC_VERSION_MAJOR > 56
sound_rate = audio_stream->codecpar->sample_rate;
+#else
+ sound_rate = audio_stream->codec->sample_rate;
+#endif
}
swr_context = swr_alloc();
if(swr_context == NULL) {
if (*got_frame) {
//size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample((enum AVSampleFormat)frame->format);
//char str_buf[AV_TS_MAX_STRING_SIZE] = {0};
+#if LIBAVCODEC_VERSION_MAJOR > 56
+ AVCodecParameters *c = audio_stream->codecpar;
+#else
AVCodecContext *c = audio_stream->codec;
+#endif
int dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_context, c->sample_rate) + frame->nb_samples,
c->sample_rate, c->sample_rate, AV_ROUND_UP);
//av_ts_make_time_string(str_buf, frame->pts, &audio_dec_ctx->time_base);
st = fmt_ctx->streams[stream_index];
/* find decoder for the stream */
+#if LIBAVCODEC_VERSION_MAJOR > 56
dec = avcodec_find_decoder(st->codecpar->codec_id);
if (!dec) {
p_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_SOUND_LOADER, "Failed to find %s codec\n",
}
dec_ctx = avcodec_alloc_context3(dec);
avcodec_parameters_to_context(dec_ctx, st->codecpar);
+#else
+ dec = avcodec_find_decoder(st->codec->codec_id);
+ dec_ctx = st->codec;
+#endif
if(ctx != NULL) {
*ctx = dec_ctx;
}