Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build against FFmpeg5.1 #11

Open
umlaeute opened this issue Aug 30, 2022 · 3 comments
Open

Unable to build against FFmpeg5.1 #11

umlaeute opened this issue Aug 30, 2022 · 3 comments

Comments

@umlaeute
Copy link

libharvid fails to build against ffmpeg-5.1, where the AVCodec struct has been cleaned purged from private data.

See https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/20f972701806be20a77f808db332d9489343bb78

For whatever reasons, it seems that the data was so private, they didn't even consider bumping the minor version of libavcodec. 🤔

anyhow, here's a patch that fixes the issue with some ugly #ifdefs that test for some later version-bump.
the patch also includes some minor fixes to shut up warnings...

-- harvid.orig/libharvid/ffdecoder.c
+++ harvid/libharvid/ffdecoder.c
@@ -32,6 +32,7 @@
 
 #include "ffcompat.h"
 #include <libswscale/swscale.h>
+#include <libavutil/imgutils.h>
 
 #ifndef MAX
 #define MAX(A,B) ( ( (A) > (B) ) ? (A) : (B) )
@@ -350,7 +351,7 @@
 
 int ff_open_movie(void *ptr, char *file_name, int render_fmt) {
   int i;
-  AVCodec *pCodec;
+  const AVCodec *pCodec;
   ffst *ff = (ffst*) ptr;
 
   if (ff->pFrameFMT) {
@@ -604,7 +605,11 @@
 
   if (ff->avprev < 0 || ff->avprev >= timestamp || ((ff->avprev + 32 * ff->tpf) < timestamp)) {
     rv = av_seek_frame(ff->pFormatCtx, ff->videoStream, timestamp, AVSEEK_FLAG_BACKWARD) ;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 26, 100)
     if (ff->pCodecCtx->codec->flush) {
+#else
+    if (1) {
+#endif
       avcodec_flush_buffers(ff->pCodecCtx);
     }
   }
@@ -683,7 +688,11 @@
 	  fprintf(stdout, " PTS mismatch want: %"PRId64" got: %"PRId64" -> re-seek\n", timestamp, pts);
 	// re-seek - make a guess, since we don't know the keyframe interval
 	rv = av_seek_frame(ff->pFormatCtx, ff->videoStream, MAX(0, timestamp - ff->tpf * 25), AVSEEK_FLAG_BACKWARD) ;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 26, 100)
 	if (ff->pCodecCtx->codec->flush) {
+#else
+	if (1) {
+#endif
 	  avcodec_flush_buffers(ff->pCodecCtx);
 	}
 	if (rv < 0) {
@umlaeute
Copy link
Author

since the flush member was considered private, probably the right solution would be to just purge the test for this member completely, even for older versions of FFmpeg(?)

@x42
Copy link
Owner

x42 commented Aug 30, 2022

Looks good, I am travelling and will merge at the next good opportunity in a day or two
Thanks

@x42
Copy link
Owner

x42 commented Sep 2, 2022

Should now compile again, please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants