From 80a8ea634bc90d9f286e96ec9f8a60f70e6c3bdf Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Mon, 13 Jul 2009 02:34:41 +0000 Subject: [PATCH] Hack in some compatibility #defines in FFMS2's utils.h so it'll compile with both older and newer ffmpeg versions. Reverts r3012. Part of this change based on a patch by CharlieB. Fixes #909. Originally committed to SVN as r3108. --- aegisub/FFmpegSource2/ffaudiosource.cpp | 4 ++-- aegisub/FFmpegSource2/ffvideosource.cpp | 4 ++-- aegisub/FFmpegSource2/indexing.cpp | 8 ++++---- aegisub/FFmpegSource2/utils.h | 10 ++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/aegisub/FFmpegSource2/ffaudiosource.cpp b/aegisub/FFmpegSource2/ffaudiosource.cpp index 860e67e8f..7bf4ac960 100644 --- a/aegisub/FFmpegSource2/ffaudiosource.cpp +++ b/aegisub/FFmpegSource2/ffaudiosource.cpp @@ -453,7 +453,7 @@ int FFMatroskaAudio::DecodeNextAudioBlock(int64_t *Count, int AudioBlock, char * TempPacket.data = MC.Buffer; TempPacket.size = FrameSize; if (Frames[AudioBlock].KeyFrame) - TempPacket.flags = PKT_FLAG_KEY; + TempPacket.flags = AV_PKT_FLAG_KEY; else TempPacket.flags = 0; @@ -512,7 +512,7 @@ int FFHaaliAudio::DecodeNextAudioBlock(int64_t *AFirstStartTime, int64_t *Count, Packet.data = Data; Packet.size = pMMF->GetActualDataLength(); if (pMMF->IsSyncPoint() == S_OK) - Packet.flags = PKT_FLAG_KEY; + Packet.flags = AV_PKT_FLAG_KEY; else Packet.flags = 0; diff --git a/aegisub/FFmpegSource2/ffvideosource.cpp b/aegisub/FFmpegSource2/ffvideosource.cpp index b6a4d0812..bbe8cb881 100644 --- a/aegisub/FFmpegSource2/ffvideosource.cpp +++ b/aegisub/FFmpegSource2/ffvideosource.cpp @@ -528,7 +528,7 @@ int FFMatroskaVideo::DecodeNextFrame(int64_t *AFirstStartTime, char *ErrorMsg, u Packet.data = MC.Buffer; Packet.size = FrameSize; if (FrameFlags & FRAME_KF) - Packet.flags = PKT_FLAG_KEY; + Packet.flags = AV_PKT_FLAG_KEY; else Packet.flags = 0; @@ -769,7 +769,7 @@ int FFHaaliVideo::DecodeNextFrame(int64_t *AFirstStartTime, char *ErrorMsg, unsi Packet.data = Data; Packet.size = pMMF->GetActualDataLength(); if (pMMF->IsSyncPoint() == S_OK) - Packet.flags = PKT_FLAG_KEY; + Packet.flags = AV_PKT_FLAG_KEY; else Packet.flags = 0; diff --git a/aegisub/FFmpegSource2/indexing.cpp b/aegisub/FFmpegSource2/indexing.cpp index ce5656586..5cd1696a9 100644 --- a/aegisub/FFmpegSource2/indexing.cpp +++ b/aegisub/FFmpegSource2/indexing.cpp @@ -312,7 +312,7 @@ FFIndex *FFHaaliIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) { pMMF->GetPointer(&TempPacket.data); TempPacket.size = pMMF->GetActualDataLength(); if (pMMF->IsSyncPoint() == S_OK) - TempPacket.flags = PKT_FLAG_KEY; + TempPacket.flags = AV_PKT_FLAG_KEY; else TempPacket.flags = 0; @@ -457,7 +457,7 @@ FFIndex *FFMatroskaIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) { TempPacket.data = MC.Buffer; TempPacket.size = FrameSize; if ((FrameFlags & FRAME_KF) != 0) - TempPacket.flags = PKT_FLAG_KEY; + TempPacket.flags = AV_PKT_FLAG_KEY; else TempPacket.flags = 0; @@ -600,9 +600,9 @@ FFIndex *FFLAVFIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) { // Only create index entries for video for now to save space if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) { - (*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, (Packet.flags & PKT_FLAG_KEY) ? 1 : 0)); + (*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, (Packet.flags & AV_PKT_FLAG_KEY) ? 1 : 0)); } else if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_AUDIO && (IndexMask & (1 << Packet.stream_index))) { - (*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, AudioContexts[Packet.stream_index].CurrentSample, (Packet.flags & PKT_FLAG_KEY) ? 1 : 0)); + (*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, AudioContexts[Packet.stream_index].CurrentSample, (Packet.flags & AV_PKT_FLAG_KEY) ? 1 : 0)); AVCodecContext *AudioCodecContext = FormatContext->streams[Packet.stream_index]->codec; TempPacket.data = Packet.data; TempPacket.size = Packet.size; diff --git a/aegisub/FFmpegSource2/utils.h b/aegisub/FFmpegSource2/utils.h index ad9ce1355..9ab240196 100644 --- a/aegisub/FFmpegSource2/utils.h +++ b/aegisub/FFmpegSource2/utils.h @@ -45,6 +45,16 @@ extern "C" { # include "guids.h" #endif + +// Compatibility with older/newer ffmpegs +#if (LIBAVFORMAT_VERSION_INT) > (AV_VERSION_INT(52,34,0)) +#define codec_bmp_tags ff_codec_bmp_tags +#endif +#ifndef AV_PKT_FLAG_KEY +#define AV_PKT_FLAG_KEY PKT_FLAG_KEY +#endif + + struct TFrameInfo { FFMS_FRAMEINFO_COMMON int64_t SampleStart;