freshplayerplugin icon indicating copy to clipboard operation
freshplayerplugin copied to clipboard

Fix for failure to build against very recent ffmpeg (2020-05-02)

Open wyatt8740 opened this issue 4 years ago • 3 comments

This is my fix to make freshplayerplugin compile on my Debian Sid system, with ffmpeg git master from 02 May 2020.

I think this is actually a fix, because simply changing the preprocessor checks from, for instance:

#if !HAVE_avcodec_free_context

to

#ifndef HAVE_avcodec_free_context

…let it build.

I just upgraded ffmpeg on my system to today's git master, and that builds with or without my patches; my week-old ffmpeg requires my patches to build however.

src/ppb_video_decoder.c:167:1: error: static declaration of ‘avcodec_free_context’ follows non-static declaration
  167 | avcodec_free_context(AVCodecContext **pavctx)

…and several others in the same file.

wyatt8740 avatar May 09 '20 14:05 wyatt8740

I just finished compiling today's ffmpeg; it appears that this morning's git master does allow freshplayerplugin to build without issues. So my guess is that the preprocessor defines aren't behaving as expected (!<something that is not defined> isn't working to check for undefined values; only defined ones).

My patch still appears to work with the most up-to-date ffmpeg, however (the library compiles with it as well), so I think my PR is still valid as it allows for ffmpeg libraries older than last week to be used.

(I edited the top post to remove some stuff in light of this new build).

wyatt8740 avatar May 09 '20 15:05 wyatt8740

#ifndef HAVE_avcodec_free_context

I used HAVE_ macros in a non-conventional way. Rather than just being defined only when feature is available, they are always defined, but has values of 0 or 1. That's why #if' were used instead of #ifdef or #ifndef. (That confuses readers of the code, I should change it to the conventional way.)

I think the patch is not correct in its current state. Unfortunately, can't say how to make it correct yet.

i-rinat avatar May 11 '20 17:05 i-rinat

Maybe check for a specific libavcodec version? https://ffmpeg.org/doxygen/3.2/libavcodec_2version_8h.html

wyatt8740 avatar May 20 '20 20:05 wyatt8740