Skip to content

Unable to build against FFmpeg5.1 #11

@umlaeute

Description

@umlaeute

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) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions