multimedia/xine-lib: add upstream fixes, from Brad (maintainer)

- ffmpeg 4 compatibility attempt.
- Fix avformat.
- Fix video failure after temporary video out jam.
This commit is contained in:
sthen 2022-01-25 18:10:36 +00:00
parent 093e365b1b
commit 8426c0b599
5 changed files with 692 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.148 2021/07/08 10:43:26 sthen Exp $
# $OpenBSD: Makefile,v 1.149 2022/01/25 18:10:36 sthen Exp $
COMMENT= multimedia decoding library
DISTNAME= xine-lib-1.2.11
REVISION= 0
REVISION= 1
CATEGORIES= multimedia
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=xine/}
EXTRACT_SUFX= .tar.xz

View File

@ -0,0 +1,115 @@
$OpenBSD: patch-src_combined_ffmpeg_demux_avformat_c,v 1.1 2022/01/25 18:10:36 sthen Exp $
- ffmpeg 4 compatibility attempt.
4e5ad7ebed6111ba9e1ea2eab4a6b94477b066a8
- Fix avformat.
6087f17933a15a0fee6a1ba58dc3a65841cf6232
Index: src/combined/ffmpeg/demux_avformat.c
--- src/combined/ffmpeg/demux_avformat.c.orig
+++ src/combined/ffmpeg/demux_avformat.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
+#include <errno.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
@@ -543,28 +544,28 @@ static int send_avpacket(avformat_demux_plugin_t *this
{
int64_t stream_pos = avio_tell(this->fmt_ctx->pb);
int64_t stream_length = avio_size(this->fmt_ctx->pb);
- AVPacket pkt;
+ XFF_PACKET_DECL (pkt);
uint32_t buffer_type = 0;
fifo_buffer_t *fifo = NULL;
- av_init_packet(&pkt);
- pkt.data = NULL;
- pkt.size = 0;
+ XFF_PACKET_NEW (pkt);
+ pkt->data = NULL;
+ pkt->size = 0;
/* read frame from the file */
- if (av_read_frame(this->fmt_ctx, &pkt) < 0) {
+ if (av_read_frame(this->fmt_ctx, pkt) < 0) {
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE": av_read_frame() failed\n");
return -1;
}
/* map to xine fifo / buffer type */
- if (pkt.stream_index >= 0 && (unsigned)pkt.stream_index < this->num_streams) {
- buffer_type = this->xine_buf_type[pkt.stream_index];
+ if (pkt->stream_index >= 0 && (unsigned)pkt->stream_index < this->num_streams) {
+ buffer_type = this->xine_buf_type [pkt->stream_index];
} else {
// TODO: new streams found
}
- if (this->video_stream_idx >= 0 && pkt.stream_index == this->video_stream_idx) {
+ if (this->video_stream_idx >= 0 && pkt->stream_index == this->video_stream_idx) {
fifo = this->stream->video_fifo;
} else {
fifo = this->stream->audio_fifo;
@@ -577,17 +578,17 @@ static int send_avpacket(avformat_demux_plugin_t *this
int total_time = (int)((int64_t)this->fmt_ctx->duration * 1000 / AV_TIME_BASE);
int input_time = input_normpos * total_time / 65535;
- if (pkt.pts != AV_NOPTS_VALUE) {
- AVStream *stream = this->fmt_ctx->streams[pkt.stream_index];
- pts = (int64_t)(pkt.pts * stream->time_base.num * 90000 / stream->time_base.den);
+ if (pkt->pts != AV_NOPTS_VALUE) {
+ AVStream *stream = this->fmt_ctx->streams [pkt->stream_index];
+ pts = (int64_t)(pkt->pts * stream->time_base.num * 90000 / stream->time_base.den);
check_newpts(this, pts);
}
- _x_demux_send_data(fifo, pkt.data, pkt.size, pts, buffer_type, 0/*decoder_flags*/,
+ _x_demux_send_data (fifo, pkt->data, pkt->size, pts, buffer_type, 0/*decoder_flags*/,
input_normpos, input_time, total_time, 0/*frame_number*/);
}
- XFF_PACKET_UNREF(&pkt);
+ XFF_PACKET_UNREF (pkt);
return 1;
}
@@ -749,11 +750,23 @@ static void demux_avformat_dispose (demux_plugin_t *th
static int pb_input_read_packet(void *opaque, uint8_t *buf, int buf_size) {
input_plugin_t *input = (input_plugin_t *)opaque;
- return input->read(input, buf, buf_size);
+ int r = input->read (input, buf, buf_size);
+ /* avoid eternal misunderstanding :-O */
+ if (r > 0)
+ return r;
+ if (r == 0) {
+#ifdef AVERROR_EOF
+ return AVERROR_EOF;
+#else
+ return 0;
+#endif
+ }
+ return AVERROR (errno);
}
static int64_t pb_input_seek(void *opaque, int64_t offset, int whence) {
input_plugin_t *input = (input_plugin_t *)opaque;
+ int64_t r;
if (whence == AVSEEK_SIZE) {
off_t len = input->get_length(input);
@@ -762,7 +775,10 @@ static int64_t pb_input_seek(void *opaque, int64_t off
return -1;
}
- return input->seek(input, offset, whence);
+ r = input->seek (input, offset, whence);
+ if (r >= 0)
+ return r;
+ return AVERROR (errno);
}
static AVIOContext *get_io_context(xine_stream_t *stream, input_plugin_t *input)

View File

@ -0,0 +1,89 @@
$OpenBSD: patch-src_combined_ffmpeg_ff_audio_decoder_c,v 1.12 2022/01/25 18:10:36 sthen Exp $
ffmpeg 4 compatibility attempt.
4e5ad7ebed6111ba9e1ea2eab4a6b94477b066a8
Index: src/combined/ffmpeg/ff_audio_decoder.c
--- src/combined/ffmpeg/ff_audio_decoder.c.orig
+++ src/combined/ffmpeg/ff_audio_decoder.c
@@ -74,7 +74,7 @@ typedef struct ff_audio_decoder_s {
int size;
AVCodecContext *context;
- AVCodec *codec;
+ const AVCodec *codec;
char *decode_buffer;
int decoder_ok;
@@ -83,6 +83,9 @@ typedef struct ff_audio_decoder_s {
#if XFF_AUDIO > 3
AVFrame *av_frame;
#endif
+#if XFF_AUDIO > 2
+ XFF_PACKET_DECL (avpkt);
+#endif
/* AAC ADTS */
uint32_t buftype;
@@ -690,11 +693,9 @@ static int ff_audio_decode (ff_audio_decoder_t *this,
else parsed = 0;
#if XFF_AUDIO > 2
- AVPacket avpkt;
- av_init_packet (&avpkt);
- avpkt.data = buf;
- avpkt.size = size;
- avpkt.flags = AV_PKT_FLAG_KEY;
+ this->avpkt->data = buf;
+ this->avpkt->size = size;
+ this->avpkt->flags = AV_PKT_FLAG_KEY;
# if XFF_AUDIO > 3
int got_frame;
float gain = this->class->gain;
@@ -702,7 +703,7 @@ static int ff_audio_decode (ff_audio_decoder_t *this,
this->av_frame = XFF_ALLOC_FRAME ();
# if XFF_AUDIO == 5
{
- int err = avcodec_send_packet (this->context, &avpkt);
+ int err = avcodec_send_packet (this->context, this->avpkt);
/* xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "ff_audio_dec: send (%d) = %d.\n", (int)size, err); */
/* multiple frames per packet */
consumed = (err >= 0) ? size : ((err == AVERROR (EAGAIN)) ? 0 : err);
@@ -712,7 +713,7 @@ static int ff_audio_decode (ff_audio_decoder_t *this,
got_frame = (err == 0);
}
# else
- consumed = avcodec_decode_audio4 (this->context, this->av_frame, &got_frame, &avpkt);
+ consumed = avcodec_decode_audio4 (this->context, this->av_frame, &got_frame, this->avpkt);
# endif
if ((consumed >= 0) && got_frame) {
/* setup may have altered while decoding */
@@ -970,7 +971,7 @@ static int ff_audio_decode (ff_audio_decoder_t *this,
}
} else *decode_buffer_size = 0;
# else
- consumed = avcodec_decode_audio3 (this->context, decode_buffer, decode_buffer_size, &avpkt);
+ consumed = avcodec_decode_audio3 (this->context, decode_buffer, decode_buffer_size, this->avpkt);
ff_map_channels (this);
# endif
#else
@@ -1286,6 +1287,8 @@ static void ff_audio_dispose (audio_decoder_t *this_ge
this->context->extradata_size = 0;
XFF_FREE_CONTEXT (this->context);
+ XFF_PACKET_UNREF (this->avpkt);
+
free (this_gen);
}
@@ -1311,6 +1314,10 @@ static audio_decoder_t *ff_audio_open_plugin (audio_de
# if XFF_AUDIO > 3
this->av_frame = NULL;
# endif
+#endif
+
+# if XFF_AUDIO > 2
+ XFF_PACKET_NEW (this->avpkt);
#endif
this->class = (ff_audio_class_t *)class_gen;

View File

@ -0,0 +1,396 @@
$OpenBSD: patch-src_combined_ffmpeg_ff_video_decoder_c,v 1.24 2022/01/25 18:10:36 sthen Exp $
- ffmpeg 4 compatibility attempt.
4e5ad7ebed6111ba9e1ea2eab4a6b94477b066a8
- Fix video failure after temporary video out jam.
c87919f2efbb51cbeda963e4cb5db9a8cd08163
Index: src/combined/ffmpeg/ff_video_decoder.c
--- src/combined/ffmpeg/ff_video_decoder.c.orig
+++ src/combined/ffmpeg/ff_video_decoder.c
@@ -51,23 +51,33 @@
#include "ffmpeg_decoder.h"
#include "ff_mpeg_parser.h"
+#include "ffmpeg_compat.h"
+
+#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(59,0,100)
+# undef HAVE_POSTPROC
+#endif
+
#ifdef HAVE_POSTPROC
-#ifdef HAVE_FFMPEG_AVUTIL_H
-# include <postprocess.h>
-#else
-# include <libpostproc/postprocess.h>
-# include <libavutil/mem.h>
+# ifdef HAVE_FFMPEG_AVUTIL_H
+# include <postprocess.h>
+# else
+# include <libpostproc/postprocess.h>
+# include <libavutil/mem.h>
+# endif
#endif
-#endif
#ifdef HAVE_VA_VA_X11_H
-# include <libavcodec/vaapi.h>
+# if XFF_VAAPI == 1
+# include <libavcodec/vaapi.h>
+# elif XFF_VAAPI == 2
+# warning rumms
+# include <libavutil/hwcontext.h>
+# include <libavutil/hwcontext_vaapi.h>
+# endif
# include "accel_vaapi.h"
# define ENABLE_VAAPI 1
#endif
-#include "ffmpeg_compat.h"
-
#if defined(ARCH_X86) && defined(HAVE_MMX)
# include "xine_mmx.h"
# define ENABLE_EMMS
@@ -140,7 +150,7 @@ struct ff_video_decoder_s {
AVFrame *av_frame;
AVFrame *av_frame2;
AVCodecContext *context;
- AVCodec *codec;
+ const AVCodec *codec;
#ifdef HAVE_POSTPROC
int pp_quality;
@@ -187,7 +197,15 @@ struct ff_video_decoder_s {
#ifdef ENABLE_VAAPI
int vaapi_width, vaapi_height;
int vaapi_profile;
+# if XFF_VAAPI == 1
struct vaapi_context vaapi_context;
+# elif XFF_VAAPI == 2
+ /* these are _here_ for debugging mostly. */
+ AVBufferRef *vaapi_av_ctx_ref;
+ AVHWDeviceContext *vaapi_av_ctx;
+ AVVAAPIDeviceContext *vaapi_hw_ctx;
+ AVVAAPIHWConfig *vaapi_hw_cfg;
+# endif
const struct vaapi_accel_funcs_s *accel;
vo_frame_t *accel_img;
#endif
@@ -210,13 +228,80 @@ struct ff_video_decoder_s {
/* see get_buffer () */
int use_emms;
#endif
+
+#if XFF_VIDEO > 1
+ XFF_PACKET_DECL (avpkt);
+#endif
};
/* import color matrix names */
#define CM_HAVE_YCGCO_SUPPORT 1
#include "../../video_out/color_matrix.c"
+#ifdef ENABLE_VAAPI
+# if XFF_VAAPI == 2
+static void ff_vaapi_stop (ff_video_decoder_t *this) {
+ if (this->vaapi_av_ctx) {
+ av_buffer_unref (&this->vaapi_av_ctx_ref);
+ this->vaapi_av_ctx = NULL;
+ this->vaapi_av_ctx_ref = NULL;
+ }
+}
+
+static void ff_vaapi_free_ctx (AVHWDeviceContext *ctx) {
+ ff_video_decoder_t *this;
+
+ if (!ctx)
+ return;
+ this = (ff_video_decoder_t *)ctx->user_opaque;
+ if (!this)
+ return;
+
+ av_free (this->vaapi_hw_cfg);
+ this->vaapi_hw_cfg = NULL;
+}
+
+static int ff_vaapi_start (ff_video_decoder_t *this, VADisplay display, VAConfigID config_id) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: ff_vaapi_start (display = %p, config_id = %d).\n",
+ (void *)display, (int)config_id);
+
+ this->vaapi_av_ctx_ref = av_hwdevice_ctx_alloc (AV_HWDEVICE_TYPE_VAAPI);
+ if (!this->vaapi_av_ctx_ref)
+ return 0;
+ this->vaapi_av_ctx = (AVHWDeviceContext *)this->vaapi_av_ctx_ref->data;
+ if (!this->vaapi_av_ctx) {
+ ff_vaapi_stop (this);
+ return 0;
+ }
+
+ this->vaapi_hw_ctx = (AVVAAPIDeviceContext *)this->vaapi_av_ctx->hwctx;
+ if (!this->vaapi_hw_ctx) {
+ ff_vaapi_stop (this);
+ return 0;
+ }
+ this->vaapi_av_ctx->user_opaque = this;
+ this->vaapi_av_ctx->free = ff_vaapi_free_ctx;
+ this->vaapi_hw_ctx->display = display;
+
+ this->vaapi_hw_cfg = (AVVAAPIHWConfig *)av_hwdevice_hwconfig_alloc (this->vaapi_av_ctx_ref);
+ if (!this->vaapi_hw_cfg) {
+ ff_vaapi_stop (this);
+ return 0;
+ }
+ this->vaapi_hw_cfg->config_id = config_id;
+
+ if (av_hwdevice_ctx_init (this->vaapi_av_ctx_ref)) {
+ ff_vaapi_stop (this);
+ return 0;
+ }
+ return 1;
+}
+
+# endif
+#endif
+
static void ff_check_colorspace (ff_video_decoder_t *this) {
int i, cm, caps;
@@ -481,9 +566,20 @@ static int get_buffer_vaapi_vld (AVCodecContext *conte
ff_vaapi_context_t *va_context = this->accel->get_context (this->accel_img);
if (va_context) {
+# if XFF_VAAPI == 2
+ /* avcodec.h saye custom frame allocators shall use AVCodecContext.hw_frames_ctx instead.
+ * however, avcodec_default_get_buffer2 () seems the only 1 using it as such. */
+ if (ff_vaapi_start (this, va_context->va_display, va_context->va_config_id)) {
+ AVBufferRef *old_vaapi_av_ctx_ref = context->hw_device_ctx;
+
+ context->hw_device_ctx = this->vaapi_av_ctx_ref;
+ av_buffer_unref (&old_vaapi_av_ctx_ref);
+ }
+# else
this->vaapi_context.config_id = va_context->va_config_id;
this->vaapi_context.context_id = va_context->va_context_id;
this->vaapi_context.display = va_context->va_display;
+# endif
}
}
}
@@ -867,11 +963,22 @@ static enum PixelFormat get_format(struct AVCodecConte
context->draw_horiz_band = NULL;
context->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
+# if XFF_VAAPI == 2
+ /* avcodec.h saye custom frame allocators shall use AVCodecContext.hw_frames_ctx instead.
+ * however, avcodec_default_get_buffer2 () seems the only 1 using it as such. */
+ if (ff_vaapi_start (this, va_context->va_display, va_context->va_config_id)) {
+ AVBufferRef *old_vaapi_av_ctx_ref = context->hw_device_ctx;
+
+ context->hw_device_ctx = this->vaapi_av_ctx_ref;
+ av_buffer_unref (&old_vaapi_av_ctx_ref);
+ }
+# else
this->vaapi_context.config_id = va_context->va_config_id;
this->vaapi_context.context_id = va_context->va_context_id;
this->vaapi_context.display = va_context->va_display;
context->hwaccel_context = &this->vaapi_context;
+# endif
this->pts = 0;
return fmt[i];
@@ -955,7 +1062,12 @@ static void init_video_codec (ff_video_decoder_t *this
if( this->codec->capabilities & AV_CODEC_CAP_DR1 && this->class->enable_dri ) {
# ifdef XFF_AV_BUFFER
this->context->get_buffer2 = get_buffer;
+# if XFF_THREAD_SAFE_CB == 2
+# warning h.264 still needs this set, or falls back to indirect rendering. please ignore the next warning.
+# endif
+# if XFF_THREAD_SAFE_CB != 0
this->context->thread_safe_callbacks = 1;
+# endif
# if XFF_VIDEO != 3
this->context->refcounted_frames = 1;
# endif
@@ -1162,9 +1274,9 @@ static void pp_change_quality (ff_video_decoder_t *thi
static void init_postprocess (ff_video_decoder_t *this) {
#ifdef HAVE_POSTPROC
-#if defined(ARCH_X86)
+# if defined(ARCH_X86)
uint32_t cpu_caps;
-#endif
+# endif
/* Allow post processing on mpeg-4 (based) codecs */
switch(this->codec->id) {
@@ -1183,7 +1295,7 @@ static void init_postprocess (ff_video_decoder_t *this
this->pp_flags = PP_FORMAT_420;
-#if defined(ARCH_X86)
+# if defined(ARCH_X86)
/* Detect what cpu accel we have */
cpu_caps = xine_mm_accel();
@@ -1195,10 +1307,12 @@ static void init_postprocess (ff_video_decoder_t *this
if(cpu_caps & MM_ACCEL_X86_3DNOW)
this->pp_flags |= PP_CPU_CAPS_3DNOW;
-#endif
+# endif
/* Set level */
pp_change_quality(this);
+#else
+ (void)this;
#endif /* HAVE_POSTPROC */
}
@@ -1848,15 +1962,13 @@ static int decode_video_wrapper (ff_video_decoder_t *t
#endif /* ENABLE_VAAPI */
#if XFF_VIDEO > 1
- AVPacket avpkt;
- av_init_packet(&avpkt);
- avpkt.data = buf;
- avpkt.size = buf_size;
- avpkt.flags = AV_PKT_FLAG_KEY;
+ this->avpkt->data = buf;
+ this->avpkt->size = buf_size;
+ this->avpkt->flags = AV_PKT_FLAG_KEY;
# if XFF_PALETTE == 2 || XFF_PALETTE == 3
if (buf && this->palette_changed) {
- uint8_t *sd = av_packet_new_side_data (&avpkt, AV_PKT_DATA_PALETTE, 256 * 4);
+ uint8_t *sd = av_packet_new_side_data (this->avpkt, AV_PKT_DATA_PALETTE, 256 * 4);
if (sd)
memcpy (sd, this->palette, 256 * 4);
}
@@ -1868,7 +1980,7 @@ static int decode_video_wrapper (ff_video_decoder_t *t
{
int e = AVERROR (EAGAIN);
if (buf || !this->flush_packet_sent) {
- e = avcodec_send_packet (this->context, &avpkt);
+ e = avcodec_send_packet (this->context, this->avpkt);
this->flush_packet_sent = (buf == NULL);
}
len = (e == AVERROR (EAGAIN)) ? 0 : buf_size;
@@ -1878,7 +1990,7 @@ static int decode_video_wrapper (ff_video_decoder_t *t
# else
{
int got_picture = 0;
- len = avcodec_decode_video2 (this->context, av_frame, &got_picture, &avpkt);
+ len = avcodec_decode_video2 (this->context, av_frame, &got_picture, this->avpkt);
if ((len < 0) || (len > (int)buf_size)) {
*err = got_picture ? 0 : len;
len = buf_size;
@@ -1891,16 +2003,16 @@ static int decode_video_wrapper (ff_video_decoder_t *t
# if XFF_PALETTE == 2 || XFF_PALETTE == 3
if (buf && this->palette_changed) {
/* Prevent freeing our data buffer */
- avpkt.data = NULL;
- avpkt.size = 0;
+ this->avpkt->data = NULL;
+ this->avpkt->size = 0;
# if XFF_PALETTE == 2
/* TJ. Oh dear and sigh.
AVPacket side data handling is broken even in ffmpeg 1.1.1 - see avcodec/avpacket.c
The suggested av_free_packet () would leave a memory leak here, and
ff_packet_free_side_data () is private. */
- av_destruct_packet (&avpkt);
+ av_destruct_packet (this->avpkt);
# else /* XFF_PALETTE == 3 */
- XFF_PACKET_UNREF (&avpkt);
+ /* XFF_PACKET_UNREF (this->avpkt); */ ;
# endif
this->palette_changed = 0;
}
@@ -1929,6 +2041,8 @@ static int decode_video_wrapper (ff_video_decoder_t *t
return len;
}
+static void ff_reset (video_decoder_t *this_gen);
+
static void ff_handle_mpeg12_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
vo_frame_t *img;
@@ -2012,8 +2126,20 @@ static void ff_handle_mpeg12_buffer (ff_video_decoder_
flush = next_flush;
if ((err < 0) && (err != AVERROR (EAGAIN))) {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "ffmpeg_video_dec: error decompressing frame (%d).\n", err);
+#ifdef AVERROR_EOF
+ if (err == AVERROR_EOF) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: lost track, reinitializing.\n");
+ ff_reset (&this->video_decoder);
+ } else
+#endif
+ {
+ char b[20];
+
+ _x_tag32_me2str (b, -err);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: error decompressing frame [%s] (%d).\n", b, err);
+ }
}
size -= len;
offset += len;
@@ -2266,8 +2392,20 @@ static void ff_handle_buffer (ff_video_decoder_t *this
this->size -= len;
continue;
}
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "ffmpeg_video_dec: error decompressing frame (%d).\n", err);
+#ifdef AVERROR_EOF
+ if (err == AVERROR_EOF) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: lost track, reinitializing.\n");
+ ff_reset (&this->video_decoder);
+ } else
+#endif
+ {
+ char b[20];
+
+ _x_tag32_me2str (b, -err);
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "ffmpeg_video_dec: error decompressing frame [%s] (%d).\n", b, err);
+ }
this->size = 0;
} else {
@@ -2763,6 +2901,10 @@ static void ff_dispose (video_decoder_t *this_gen) {
XFF_FREE_CONTEXT (this->context);
}
+#if XFF_VIDEO > 1
+ XFF_PACKET_UNREF (this->avpkt);
+#endif
+
if( this->av_frame )
XFF_FREE_FRAME( this->av_frame );
if (this->av_frame2)
@@ -2805,7 +2947,7 @@ static void ff_dispose (video_decoder_t *this_gen) {
static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
ff_video_decoder_t *this ;
- AVCodec *codec = NULL;
+ const AVCodec *codec = NULL;
uint32_t video_type;
size_t i;
@@ -2913,6 +3055,10 @@ static video_decoder_t *ff_video_open_plugin (video_de
this->pix_fmt = -1;
#ifdef LOG
this->debug_fmt = -1;
+#endif
+
+#if XFF_VIDEO > 1
+ XFF_PACKET_NEW (this->avpkt);
#endif
#ifdef ENABLE_VAAPI

View File

@ -0,0 +1,90 @@
$OpenBSD: patch-src_combined_ffmpeg_ffmpeg_compat_h,v 1.7 2022/01/25 18:10:36 sthen Exp $
ffmpeg 4 compatibility attempt.
4e5ad7ebed6111ba9e1ea2eab4a6b94477b066a8
Index: src/combined/ffmpeg/ffmpeg_compat.h
--- src/combined/ffmpeg/ffmpeg_compat.h.orig
+++ src/combined/ffmpeg/ffmpeg_compat.h
@@ -130,6 +130,14 @@
# define XFF_PALETTE 3
#endif
+#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100) /** << revise this */
+# define XFF_VAAPI 1 /** << libavcodec/vaapi.h */
+#else
+# define XFF_VAAPI 2 /** << libavutil/hwcontext.h, libavutil/hwcontext_vaapi.h */
+#endif
+
+
+
#if LIBAVUTIL_VERSION_INT >= XFF_INT_VERSION(52,0,0)
# define PIX_FMT_NONE AV_PIX_FMT_NONE
# define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
@@ -138,7 +146,6 @@
# define PIX_FMT_YUVJ444P AV_PIX_FMT_YUVJ444P
# define PIX_FMT_YUV410P AV_PIX_FMT_YUV410P
# define PIX_FMT_YUV411P AV_PIX_FMT_YUV411P
-# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI_VLD
# define PIX_FMT_ARGB AV_PIX_FMT_ARGB
# define PIX_FMT_BGRA AV_PIX_FMT_BGRA
# define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
@@ -150,8 +157,17 @@
# define PIX_FMT_PAL8 AV_PIX_FMT_PAL8
# define PixelFormat AVPixelFormat
/* video_out/video_out_vaapi */
-# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI_IDCT
-# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI_MOCO
+# if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100) /** << revise this */
+# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI_VLD
+# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI_IDCT
+# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI_MOCO
+# else
+# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI
+# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI
+# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI
+# endif
+
+# define CODEC_FLAG_BITEXACT AV_CODEC_FLAG_BITEXACT
#endif
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(54,25,0)
@@ -188,6 +204,18 @@
# define XFF_AV_BUFFER 1
#endif
+/* 0 (no), 1 (yes), 2 (deprecated but still needed to make direct rendering work) */
+#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,0,100)
+# define XFF_THREAD_SAFE_CB 0
+#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
+# define XFF_THREAD_SAFE_CB 1
+#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(60,0,0)
+# define XFF_THREAD_SAFE_CB 2
+#else
+/* now callbacks shall always be thread safe. */
+# define XFF_THREAD_SAFE_CB 0
+#endif
+
/* function aliases */
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(52,66,0)
@@ -235,9 +263,17 @@
#endif
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(57,12,100)
-#define XFF_PACKET_UNREF av_free_packet
+# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
+# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
+# define XFF_PACKET_UNREF(_p) av_free_packet (_p)
+#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100) /** << revise this */
+# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
+# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
+# define XFF_PACKET_UNREF(_p) av_packet_unref (_p)
#else
-#define XFF_PACKET_UNREF av_packet_unref
+# define XFF_PACKET_DECL(_p) AVPacket *_p
+# define XFF_PACKET_NEW(_p) _p = av_packet_alloc ()
+# define XFF_PACKET_UNREF(_p) av_packet_free (&(_p))
#endif
#ifndef AV_INPUT_BUFFER_PADDING_SIZE