Skip to content

Commit

Permalink
Fix errors and warnings with FFmpeg 7
Browse files Browse the repository at this point in the history
Some of these warnings were likely already there, but since I'm fixing
a build error I might as well fix the warnings while I'm here.
  • Loading branch information
dougg3 committed Aug 27, 2024
1 parent 060a713 commit 34d3ca7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ffmpeg-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ void ffmpeg_decode_free(struct ffmpeg_decode *decode)
{
if (decode->decoder)
{
#if LIBAVCODEC_VERSION_MAJOR < 61
avcodec_close(decode->decoder);
av_free(decode->decoder);
#else
avcodec_free_context(&decode->decoder);
#endif
}

if (decode->frame)
Expand Down Expand Up @@ -206,7 +210,11 @@ bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
audio->samples_per_sec = decode->frame->sample_rate;
audio->format = convert_sample_format(decode->frame->format);
audio->speakers =
#if LIBAVCODEC_VERSION_MAJOR < 61
convert_speaker_layout((uint8_t)decode->decoder->channels);
#else
convert_speaker_layout((uint8_t)decode->decoder->ch_layout.nb_channels);
#endif

audio->frames = decode->frame->nb_samples;

Expand Down
4 changes: 4 additions & 0 deletions src/ffmpeg-decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ extern "C" {
struct ffmpeg_decode
{
AVCodecContext *decoder;
#if LIBAVCODEC_VERSION_MAJOR < 59
AVCodec *codec;
#else
const AVCodec *codec;
#endif

AVFrame *frame;

Expand Down

0 comments on commit 34d3ca7

Please sign in to comment.