aboutsummaryrefslogtreecommitdiffstats
path: root/src/media
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-04-22 13:31:47 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-04-22 13:31:47 +0000
commit011198e5b6182245f05a15a8e85b7fde4c402e13 (patch)
tree976302fadf0d30a661d56bb80e4339911656afac /src/media
parentf3bc2f539e2de5e485762a3f953a6a60c748db63 (diff)
downloadusdx-011198e5b6182245f05a15a8e85b7fde4c402e13.tar.gz
usdx-011198e5b6182245f05a15a8e85b7fde4c402e13.tar.xz
usdx-011198e5b6182245f05a15a8e85b7fde4c402e13.zip
updates and extension for ffmpeg-0.8
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2867 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/media')
-rw-r--r--src/media/UAudioConverter.pas12
-rw-r--r--src/media/UAudioDecoder_FFmpeg.pas5
-rw-r--r--src/media/UMediaCore_FFmpeg.pas12
-rw-r--r--src/media/UVideo.pas5
4 files changed, 33 insertions, 1 deletions
diff --git a/src/media/UAudioConverter.pas b/src/media/UAudioConverter.pas
index 657b80dd..696a01f6 100644
--- a/src/media/UAudioConverter.pas
+++ b/src/media/UAudioConverter.pas
@@ -42,6 +42,7 @@ uses
{$ENDIF}
{$IFDEF UseFFmpegResample}
avcodec,
+ avutil,
{$ENDIF}
UMediaCore_SDL,
sdl,
@@ -124,6 +125,9 @@ type
implementation
+uses
+ UConfig;
+
function TAudioConverter_SDL.Init(srcFormatInfo: TAudioFormatInfo; dstFormatInfo: TAudioFormatInfo): boolean;
var
srcFormat: UInt16;
@@ -219,9 +223,17 @@ begin
Exit;
end;
+ {$IF LIBAVCODEC_VERSION < 52122000} // 52.122.0
ResampleContext := audio_resample_init(
dstFormatInfo.Channels, srcFormatInfo.Channels,
Round(dstFormatInfo.SampleRate), Round(srcFormatInfo.SampleRate));
+ {$ELSE}
+ ResampleContext := av_audio_resample_init(
+ dstFormatInfo.Channels, srcFormatInfo.Channels,
+ Round(dstFormatInfo.SampleRate), Round(srcFormatInfo.SampleRate),
+ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16,
+ 16, 10, 0, 0.8);
+ {$IFEND}
if (ResampleContext = nil) then
begin
Log.LogError('audio_resample_init() failed', 'TAudioConverter_FFmpeg.Init');
diff --git a/src/media/UAudioDecoder_FFmpeg.pas b/src/media/UAudioDecoder_FFmpeg.pas
index d5295135..a6749173 100644
--- a/src/media/UAudioDecoder_FFmpeg.pas
+++ b/src/media/UAudioDecoder_FFmpeg.pas
@@ -915,7 +915,10 @@ begin
begin
DataSize := BufferSize;
- {$IF LIBAVCODEC_VERSION >= 51030000} // 51.30.0
+ {$IF LIBAVCODEC_VERSION >= 52122000} // 52.122.0
+ PaketDecodedSize := avcodec_decode_audio3(fCodecCtx, PSmallint(Buffer),
+ DataSize, @fAudioPaket);
+ {$ELSEIF LIBAVCODEC_VERSION >= 51030000} // 51.30.0
PaketDecodedSize := avcodec_decode_audio2(fCodecCtx, PSmallint(Buffer),
DataSize, fAudioPaketData, fAudioPaketSize);
{$ELSE}
diff --git a/src/media/UMediaCore_FFmpeg.pas b/src/media/UMediaCore_FFmpeg.pas
index f04ee7eb..ffc7b1c5 100644
--- a/src/media/UMediaCore_FFmpeg.pas
+++ b/src/media/UMediaCore_FFmpeg.pas
@@ -199,7 +199,12 @@ begin
inherited;
CheckVersions();
+
+ {$IF LIBAVFORMAT_VERSION < 52110000} // 52.110.0
av_register_protocol(@UTF8FileProtocol);
+ {$ELSE}
+ av_register_protocol2(@UTF8FileProtocol, sizeof(UTF8FileProtocol));
+ {$IFEND}
AVCodecLock := SDL_CreateMutex();
end;
@@ -228,6 +233,7 @@ end;
function TMediaCore_FFmpeg.GetErrorString(ErrorNum: integer): string;
begin
+{$IF LIBAVUTIL_VERSION < 50043000} // < 50.43.0
case ErrorNum of
AVERROR_IO: Result := 'AVERROR_IO';
AVERROR_NUMEXPECTED: Result := 'AVERROR_NUMEXPECTED';
@@ -239,6 +245,8 @@ begin
AVERROR_PATCHWELCOME: Result := 'AVERROR_PATCHWELCOME';
else Result := 'AVERROR_#'+inttostr(ErrorNum);
end;
+{$ELSE}
+{$IFEND}
end;
{
@@ -371,7 +379,11 @@ begin
Stream := TBinaryFileStream.Create(FilePath, Mode);
h.priv_data := Stream;
except
+{$IF LIBAVUTIL_VERSION < 50043000} // < 50.43.0
Result := AVERROR_NOENT;
+{$ELSE}
+ Result := -1;
+{$IFEND}
end;
end;
diff --git a/src/media/UVideo.pas b/src/media/UVideo.pas
index add7bdc8..b3030b0c 100644
--- a/src/media/UVideo.pas
+++ b/src/media/UVideo.pas
@@ -669,8 +669,13 @@ begin
fCodecContext^.opaque := @VideoPktPts;
// decode packet
+ {$IF LIBAVFORMAT_VERSION < 5212200)}
avcodec_decode_video(fCodecContext, fAVFrame,
frameFinished, AVPacket.data, AVPacket.size);
+ {$ELSE}
+ avcodec_decode_video2(fCodecContext, fAVFrame,
+ frameFinished, @AVPacket);
+ {$IFEND}
// reset opaque data
fCodecContext^.opaque := nil;