Skip to content

Commit

Permalink
ffmpeg 5.1 compat -- closes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
x42 committed Sep 2, 2022
1 parent 46d0113 commit 973f004
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/xjadeo/ffcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,16 @@ register_codecs_compat ()
#endif
}

static inline void
maybe_avcodec_flush_buffers(AVCodecContext *avctx)
{
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 26, 100)
if (avctx->codec->flush) {
avcodec_flush_buffers(avctx);
}
#else
avcodec_flush_buffers(avctx);
#endif
}

#endif /* FFCOMPAT_H */
28 changes: 11 additions & 17 deletions src/xjadeo/xjadeo.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,7 @@ static int seek_frame (AVPacket *packet, int64_t framenumber) {
seek = av_seek_frame (pFormatCtx, videoStream, fidx[framenumber].seekpts, AVSEEK_FLAG_BACKWARD);
}

if (pCodecCtx->codec->flush) {
avcodec_flush_buffers (pCodecCtx);
}
maybe_avcodec_flush_buffers (pCodecCtx);

if (seek < 0) {
if (!want_quiet)
Expand Down Expand Up @@ -915,9 +913,7 @@ static int index_frames () {
error |= 16;
break;
}
if (pCodecCtx->codec->flush) {
avcodec_flush_buffers (pCodecCtx);
}
maybe_avcodec_flush_buffers (pCodecCtx);

int err = 0;
int bailout = 100;
Expand Down Expand Up @@ -1053,9 +1049,7 @@ static int index_frames () {
printf("NOBYTE 2\n");
break;
}
if (pCodecCtx->codec->flush) {
avcodec_flush_buffers (pCodecCtx);
}
maybe_avcodec_flush_buffers (pCodecCtx);

int64_t pts = AV_NOPTS_VALUE;
while (!got_pic) {
Expand Down Expand Up @@ -1118,9 +1112,7 @@ static int index_frames () {
} else {
av_seek_frame (pFormatCtx, videoStream, fidx[i].seekpts, AVSEEK_FLAG_BACKWARD);
}
if (pCodecCtx->codec->flush) {
avcodec_flush_buffers (pCodecCtx);
}
maybe_avcodec_flush_buffers (pCodecCtx);
while (!got_pic) {

if (av_read_frame (pFormatCtx, &packet) < 0) {
Expand Down Expand Up @@ -1192,9 +1184,7 @@ static int index_frames () {
}

av_seek_frame (pFormatCtx, videoStream, 0, AVSEEK_FLAG_BACKWARD);
if (pCodecCtx->codec->flush) {
avcodec_flush_buffers (pCodecCtx);
}
maybe_avcodec_flush_buffers (pCodecCtx);
if (!error) {
scan_complete = 1;
}
Expand Down Expand Up @@ -1271,8 +1261,12 @@ static void clear_info () {

int open_movie (char* file_name) {
int i;
AVCodec *pCodec;
AVStream *av_stream;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 100)
AVCodec* pCodec;
#else
AVCodec const* pCodec;
#endif
AVStream* av_stream;

if (pFrameFMT) {
close_movie ();
Expand Down

0 comments on commit 973f004

Please sign in to comment.