mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
libobs: Fix FFmpeg constants
(This commit also modifies the deps/media-playback, obs-ffmpeg, and win-dshow modules) More fixes due to ffmpeg renaming some constants and deprecating AVFMT_RAWPICTURE and AV_PIX_FMT_VDA_VLD. Latter replaced by AV_PIX_FMT_VIDEOTOOLBOX per ffmpeg dev advice. Closes jp9000/obs-studio#1061
This commit is contained in:
+4
-4
@@ -24,8 +24,8 @@ static AVCodec *find_hardware_decoder(enum AVCodecID id)
|
|||||||
|
|
||||||
while (hwa) {
|
while (hwa) {
|
||||||
if (hwa->id == id) {
|
if (hwa->id == id) {
|
||||||
if (hwa->pix_fmt == AV_PIX_FMT_VDA_VLD ||
|
if (hwa->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ||
|
||||||
hwa->pix_fmt == AV_PIX_FMT_DXVA2_VLD ||
|
hwa->pix_fmt == AV_PIX_FMT_DXVA2_VLD ||
|
||||||
hwa->pix_fmt == AV_PIX_FMT_VAAPI_VLD) {
|
hwa->pix_fmt == AV_PIX_FMT_VAAPI_VLD) {
|
||||||
c = avcodec_find_decoder_by_name(hwa->name);
|
c = avcodec_find_decoder_by_name(hwa->name);
|
||||||
if (c)
|
if (c)
|
||||||
@@ -142,8 +142,8 @@ bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
|
if (d->codec->capabilities & CODEC_CAP_TRUNC)
|
||||||
d->decoder->flags |= AV_CODEC_FLAG_TRUNCATED;
|
d->decoder->flags |= CODEC_FLAG_TRUNC;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
@@ -36,6 +36,14 @@ extern "C" {
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||||
|
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
|
||||||
|
#else
|
||||||
|
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
|
||||||
|
#endif
|
||||||
|
|
||||||
struct mp_media;
|
struct mp_media;
|
||||||
|
|
||||||
struct mp_decode {
|
struct mp_decode {
|
||||||
|
|||||||
@@ -26,6 +26,12 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||||
|
#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#else
|
||||||
|
#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#endif
|
||||||
|
|
||||||
struct media_remux_job {
|
struct media_remux_job {
|
||||||
int64_t in_size;
|
int64_t in_size;
|
||||||
AVFormatContext *ifmt_ctx, *ofmt_ctx;
|
AVFormatContext *ifmt_ctx, *ofmt_ctx;
|
||||||
@@ -95,7 +101,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
|||||||
|
|
||||||
out_stream->codec->codec_tag = 0;
|
out_stream->codec->codec_tag = 0;
|
||||||
if (job->ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
if (job->ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
out_stream->codec->flags |= CODEC_FLAG_GLOBAL_H;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _NDEBUG
|
#ifndef _NDEBUG
|
||||||
|
|||||||
@@ -20,3 +20,12 @@
|
|||||||
# define av_frame_free avcodec_free_frame
|
# define av_frame_free avcodec_free_frame
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||||
|
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
|
||||||
|
#define INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
|
||||||
|
#else
|
||||||
|
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
|
||||||
|
#define INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
|
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||||
|
#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#else
|
||||||
|
#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
struct resize_buf {
|
struct resize_buf {
|
||||||
@@ -312,7 +318,7 @@ static void create_video_stream(struct ffmpeg_mux *ffm)
|
|||||||
ffm->video_stream->time_base = context->time_base;
|
ffm->video_stream->time_base = context->time_base;
|
||||||
|
|
||||||
if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER)
|
if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
context->flags |= CODEC_FLAG_GLOBAL_H;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_audio_stream(struct ffmpeg_mux *ffm, int idx)
|
static void create_audio_stream(struct ffmpeg_mux *ffm, int idx)
|
||||||
@@ -348,7 +354,7 @@ static void create_audio_stream(struct ffmpeg_mux *ffm, int idx)
|
|||||||
av_get_default_channel_layout(context->channels);
|
av_get_default_channel_layout(context->channels);
|
||||||
|
|
||||||
if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER)
|
if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
context->flags |= CODEC_FLAG_GLOBAL_H;
|
||||||
|
|
||||||
ffm->num_audio_streams++;
|
ffm->num_audio_streams++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder,
|
|||||||
/* enable experimental FFmpeg encoder if the only one available */
|
/* enable experimental FFmpeg encoder if the only one available */
|
||||||
enc->context->strict_std_compliance = -2;
|
enc->context->strict_std_compliance = -2;
|
||||||
|
|
||||||
enc->context->flags = AV_CODEC_FLAG_GLOBAL_HEADER;
|
enc->context->flags = CODEC_FLAG_GLOBAL_H;
|
||||||
|
|
||||||
if (initialize_codec(enc))
|
if (initialize_codec(enc))
|
||||||
return enc;
|
return enc;
|
||||||
|
|||||||
@@ -23,3 +23,13 @@
|
|||||||
#if LIBAVCODEC_VERSION_MAJOR >= 57
|
#if LIBAVCODEC_VERSION_MAJOR >= 57
|
||||||
#define av_free_packet av_packet_unref
|
#define av_free_packet av_packet_unref
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||||
|
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
|
||||||
|
#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#else
|
||||||
|
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
|
||||||
|
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
|
||||||
|
#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ static bool create_video_stream(struct ffmpeg_data *data)
|
|||||||
data->video->time_base = context->time_base;
|
data->video->time_base = context->time_base;
|
||||||
|
|
||||||
if (data->output->oformat->flags & AVFMT_GLOBALHEADER)
|
if (data->output->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
context->flags |= CODEC_FLAG_GLOBAL_H;
|
||||||
|
|
||||||
if (!open_video_codec(data))
|
if (!open_video_codec(data))
|
||||||
return false;
|
return false;
|
||||||
@@ -348,7 +348,7 @@ static bool create_audio_stream(struct ffmpeg_data *data)
|
|||||||
data->audio_size = get_audio_size(data->audio_format, aoi.speakers, 1);
|
data->audio_size = get_audio_size(data->audio_format, aoi.speakers, 1);
|
||||||
|
|
||||||
if (data->output->oformat->flags & AVFMT_GLOBALHEADER)
|
if (data->output->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
context->flags |= CODEC_FLAG_GLOBAL_H;
|
||||||
|
|
||||||
return open_audio_codec(data);
|
return open_audio_codec(data);
|
||||||
}
|
}
|
||||||
@@ -686,7 +686,7 @@ static void receive_video(void *param, struct video_data *frame)
|
|||||||
else
|
else
|
||||||
copy_data(&data->dst_picture, frame, context->height, context->pix_fmt);
|
copy_data(&data->dst_picture, frame, context->height, context->pix_fmt);
|
||||||
|
|
||||||
if (data->output->flags & AVFMT_RAWPICTURE) {
|
if (data->output->flags) {
|
||||||
packet.flags |= AV_PKT_FLAG_KEY;
|
packet.flags |= AV_PKT_FLAG_KEY;
|
||||||
packet.stream_index = data->video->index;
|
packet.stream_index = data->video->index;
|
||||||
packet.data = data->dst_picture.data[0];
|
packet.data = data->dst_picture.data[0];
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "ffmpeg-decode.h"
|
#include "ffmpeg-decode.h"
|
||||||
|
#include "obs-ffmpeg-compat.h"
|
||||||
#include <obs-avc.h>
|
#include <obs-avc.h>
|
||||||
|
|
||||||
int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id)
|
int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id)
|
||||||
@@ -37,8 +38,8 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decode->codec->capabilities & CODEC_CAP_TRUNCATED)
|
if (decode->codec->capabilities & CODEC_CAP_TRUNC)
|
||||||
decode->decoder->flags |= CODEC_FLAG_TRUNCATED;
|
decode->decoder->flags |= CODEC_FLAG_TRUNC;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ static inline enum audio_format convert_sample_format(int f)
|
|||||||
static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
size_t new_size = size + FF_INPUT_BUFFER_PADDING_SIZE;
|
size_t new_size = size + INPUT_BUFFER_PADDING_SIZE;
|
||||||
|
|
||||||
if (decode->packet_size < new_size) {
|
if (decode->packet_size < new_size) {
|
||||||
decode->packet_buffer = brealloc(decode->packet_buffer,
|
decode->packet_buffer = brealloc(decode->packet_buffer,
|
||||||
@@ -104,7 +105,7 @@ static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
|||||||
decode->packet_size = new_size;
|
decode->packet_size = new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(decode->packet_buffer + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset(decode->packet_buffer + size, 0, INPUT_BUFFER_PADDING_SIZE);
|
||||||
memcpy(decode->packet_buffer, data, size);
|
memcpy(decode->packet_buffer, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user