Skip to content

Commit

Permalink
obs-ffmpeg: Fix for FFmpeg 6 deprecating a flag
Browse files Browse the repository at this point in the history
Also modifies libobs & deps/media-playback.
AV_CODEC_CAP_TRUNCATED was deprecated by avcodec 59.8.100 [1].
We ifdef the code depending on it to allow compilation.

[1] lavc: deprecate AV_CODEC_(FLAG|CAP)_TRUNCATED
FFmpeg/FFmpeg@dd846bc

Signed-off-by: pkv <pkv@obsproject.com>
  • Loading branch information
pkviet committed Feb 28, 2023
1 parent 77e4c1c commit fd173db
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deps/media-playback/media-playback/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw)
d->in_frame = d->sw_frame;
}

#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 8, 100)
if (d->codec->capabilities & CODEC_CAP_TRUNC)
d->decoder->flags |= CODEC_FLAG_TRUNC;
#endif

d->orig_pkt = av_packet_alloc();
d->pkt = av_packet_alloc();
Expand Down
2 changes: 2 additions & 0 deletions deps/media-playback/media-playback/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ extern "C" {
#endif

#if LIBAVCODEC_VERSION_MAJOR >= 58
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 8, 100)
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
#endif
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
Expand Down
2 changes: 2 additions & 0 deletions libobs/obs-ffmpeg-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#endif

#if LIBAVCODEC_VERSION_MAJOR >= 58
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 8, 100)
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
#endif
#define INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
Expand Down
3 changes: 3 additions & 0 deletions plugins/obs-ffmpeg/obs-ffmpeg-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
#endif

#if LIBAVCODEC_VERSION_MAJOR >= 58
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 8, 100)
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
#endif
#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER
#endif

2 changes: 2 additions & 0 deletions plugins/win-dshow/ffmpeg-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id,
return ret;
}

#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 8, 100)
if (decode->codec->capabilities & CODEC_CAP_TRUNC)
decode->decoder->flags |= CODEC_FLAG_TRUNC;
#endif

return 0;
}
Expand Down

0 comments on commit fd173db

Please sign in to comment.