提交 17a9fcaa 编写于 作者: B BtbN

Use propper ffmpeg compatiblity instead of relying on deprecated functions

上级 ed9d5b1d
......@@ -223,7 +223,8 @@ set(libobs_libobs_HEADERS
obs-module.h
obs-scene.h
obs-source.h
obs-output.h)
obs-output.h
obs-ffmpeg-compat.h)
set(libobs_SOURCES
${libobs_callback_SOURCES}
......
......@@ -4,6 +4,8 @@
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include "../obs-ffmpeg-compat.h"
struct ffmpeg_image {
const char *file;
AVFormatContext *fmt_ctx;
......@@ -121,7 +123,7 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
{
AVPacket packet = {0};
bool success = false;
AVFrame *frame = avcodec_alloc_frame();
AVFrame *frame = av_frame_alloc();
int got_frame = 0;
int ret;
......@@ -152,7 +154,7 @@ static bool ffmpeg_image_decode(struct ffmpeg_image *info, uint8_t *out,
fail:
av_free_packet(&packet);
avcodec_free_frame(&frame);
av_frame_free(&frame);
return success;
}
......
#pragma once
#include <libavcodec/avcodec.h>
/* LIBAVCODEC_VERSION_CHECK checks for the right version of libav and FFmpeg
* a is the major version
* b and c the minor and micro versions of libav
* d and e the minor and micro versions of FFmpeg */
#define LIBAVCODEC_VERSION_CHECK( a, b, c, d, e ) \
( (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \
(LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) )
#if !LIBAVCODEC_VERSION_CHECK(54, 28, 0, 59, 100)
# define avcodec_free_frame av_freep
#endif
#if LIBAVCODEC_VERSION_INT < 0x371c01
# define av_frame_alloc avcodec_alloc_frame
# define av_frame_unref avcodec_get_frame_defaults
# define av_frame_free avcodec_free_frame
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册