aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UAudioConverter.pas32
-rw-r--r--Game/Code/Classes/UAudioDecoder_FFMpeg.pas147
-rw-r--r--Game/Code/Classes/UAudioPlayback_SoftMixer.pas4
-rw-r--r--Game/Code/Classes/UConfig.pas2
-rw-r--r--Game/Code/Classes/UMediaCore_FFMpeg.pas32
-rw-r--r--Game/Code/Classes/UMusic.pas2
-rw-r--r--Game/Code/Classes/UVideo.pas56
7 files changed, 138 insertions, 137 deletions
diff --git a/Game/Code/Classes/UAudioConverter.pas b/Game/Code/Classes/UAudioConverter.pas
index 74ae88df..5647f27b 100644
--- a/Game/Code/Classes/UAudioConverter.pas
+++ b/Game/Code/Classes/UAudioConverter.pas
@@ -15,7 +15,7 @@ uses
{$IFDEF UseSRCResample}
samplerate,
{$ENDIF}
- {$IFDEF UseFFMpegResample}
+ {$IFDEF UseFFmpegResample}
avcodec,
{$ENDIF}
UMediaCore_SDL,
@@ -35,7 +35,7 @@ type
* with the video or the lyrics timer.
* - float<->int16 conversion is not supported (will be part of 1.3) and
* SDL (<1.3) is not capable of handling floats at all.
- * -> Using FFMpeg or libsamplerate for resampling is preferred.
+ * -> Using FFmpeg or libsamplerate for resampling is preferred.
* Use SDL for channel and format conversion only.
*}
TAudioConverter_SDL = class(TAudioConverter)
@@ -50,10 +50,10 @@ type
function GetRatio(): double; override;
end;
- {$IFDEF UseFFMpegResample}
- // Note: FFMpeg seems to be using "kaiser windowed sinc" for resampling, so
+ {$IFDEF UseFFmpegResample}
+ // Note: FFmpeg seems to be using "kaiser windowed sinc" for resampling, so
// the quality should be good.
- TAudioConverter_FFMpeg = class(TAudioConverter)
+ TAudioConverter_FFmpeg = class(TAudioConverter)
private
// TODO: use SDL for multi-channel->stereo and format conversion
ResampleContext: PReSampleContext;
@@ -92,7 +92,7 @@ type
// because it interpolates the samples. Normal "non-audiophile" users should not
// be able to hear a difference between the SINC_* ones and LINEAR. Especially
// if people sing along with the song.
- // But FFMpeg might offer a better quality/speed ratio than SRC_LINEAR.
+ // But FFmpeg might offer a better quality/speed ratio than SRC_LINEAR.
const
SRC_CONVERTER_TYPE = SRC_LINEAR;
{$ENDIF}
@@ -171,9 +171,9 @@ begin
end;
-{$IFDEF UseFFMpegResample}
+{$IFDEF UseFFmpegResample}
-function TAudioConverter_FFMpeg.Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean;
+function TAudioConverter_FFmpeg.Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean;
begin
inherited Init(SrcFormatInfo, DstFormatInfo);
@@ -183,14 +183,14 @@ begin
if (srcFormatInfo.Format <> asfS16) then
begin
- Log.LogError('Unsupported format', 'TAudioConverter_FFMpeg.Init');
+ Log.LogError('Unsupported format', 'TAudioConverter_FFmpeg.Init');
Exit;
end;
// TODO: use SDL here
if (srcFormatInfo.Format <> dstFormatInfo.Format) then
begin
- Log.LogError('Incompatible formats', 'TAudioConverter_FFMpeg.Init');
+ Log.LogError('Incompatible formats', 'TAudioConverter_FFmpeg.Init');
Exit;
end;
@@ -199,7 +199,7 @@ begin
Round(dstFormatInfo.SampleRate), Round(srcFormatInfo.SampleRate));
if (ResampleContext = nil) then
begin
- Log.LogError('audio_resample_init() failed', 'TAudioConverter_FFMpeg.Init');
+ Log.LogError('audio_resample_init() failed', 'TAudioConverter_FFmpeg.Init');
Exit;
end;
@@ -210,14 +210,14 @@ begin
Result := true;
end;
-destructor TAudioConverter_FFMpeg.Destroy();
+destructor TAudioConverter_FFmpeg.Destroy();
begin
if (ResampleContext <> nil) then
audio_resample_close(ResampleContext);
inherited;
end;
-function TAudioConverter_FFMpeg.Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer;
+function TAudioConverter_FFmpeg.Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer;
var
InputSampleCount: integer;
OutputSampleCount: integer;
@@ -238,18 +238,18 @@ begin
InputSampleCount);
if (OutputSampleCount = -1) then
begin
- Log.LogError('audio_resample() failed', 'TAudioConverter_FFMpeg.Convert');
+ Log.LogError('audio_resample() failed', 'TAudioConverter_FFmpeg.Convert');
Exit;
end;
Result := OutputSampleCount * DstFormatInfo.FrameSize;
end;
-function TAudioConverter_FFMpeg.GetOutputBufferSize(InputSize: integer): integer;
+function TAudioConverter_FFmpeg.GetOutputBufferSize(InputSize: integer): integer;
begin
Result := Ceil(InputSize * GetRatio());
end;
-function TAudioConverter_FFMpeg.GetRatio(): double;
+function TAudioConverter_FFmpeg.GetRatio(): double;
begin
Result := Ratio;
end;
diff --git a/Game/Code/Classes/UAudioDecoder_FFMpeg.pas b/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
index e81acf80..d9b4c93c 100644
--- a/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
+++ b/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
@@ -1,4 +1,4 @@
-unit UAudioDecoder_FFMpeg;
+unit UAudioDecoder_FFmpeg;
(*******************************************************************************
*
@@ -19,7 +19,8 @@ interface
{$I switches.inc}
-{.$DEFINE DebugFFMpegDecode}
+// show FFmpeg specific debug output
+{.$DEFINE DebugFFmpegDecode}
// FFmpeg is very verbose and shows a bunch of errors.
// Those errors (they can be considered as warnings by us) can be ignored
@@ -42,7 +43,7 @@ uses
avio,
mathematics, // used for av_rescale_q
rational,
- UMediaCore_FFMpeg,
+ UMediaCore_FFmpeg,
SDL,
ULog,
UCommon,
@@ -57,7 +58,7 @@ const
AUDIO_BUFFER_SIZE = (AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) div 2;
type
- TFFMpegDecodeStream = class(TAudioDecodeStream)
+ TFFmpegDecodeStream = class(TAudioDecodeStream)
private
StateLock: PSDL_Mutex;
@@ -86,7 +87,7 @@ type
FormatInfo: TAudioFormatInfo;
- // FFMpeg specific data
+ // FFmpeg specific data
FormatCtx: PAVFormatContext;
CodecCtx: PAVCodecContext;
Codec: PAVCodec;
@@ -151,7 +152,7 @@ type
end;
type
- TAudioDecoder_FFMpeg = class( TInterfacedObject, IAudioDecoder )
+ TAudioDecoder_FFmpeg = class( TInterfacedObject, IAudioDecoder )
public
function GetName: string;
@@ -161,14 +162,14 @@ type
end;
var
- FFMpegCore: TMediaCore_FFMpeg;
+ FFmpegCore: TMediaCore_FFmpeg;
function ParseThreadMain(Data: Pointer): integer; cdecl; forward;
-{ TFFMpegDecodeStream }
+{ TFFmpegDecodeStream }
-constructor TFFMpegDecodeStream.Create();
+constructor TFFmpegDecodeStream.Create();
begin
inherited Create();
@@ -200,7 +201,7 @@ begin
Reset();
end;
-procedure TFFMpegDecodeStream.Reset();
+procedure TFFmpegDecodeStream.Reset();
begin
ParseThread := nil;
@@ -227,7 +228,7 @@ end;
{*
* Frees the decode-stream data.
*}
-destructor TFFMpegDecodeStream.Destroy();
+destructor TFFmpegDecodeStream.Destroy();
begin
Close();
@@ -244,7 +245,7 @@ begin
inherited;
end;
-function TFFMpegDecodeStream.Open(const Filename: string): boolean;
+function TFFmpegDecodeStream.Open(const Filename: string): boolean;
var
SampleFormat: TAudioSampleFormat;
AVResult: integer;
@@ -256,7 +257,7 @@ begin
if (not FileExists(Filename)) then
begin
- Log.LogError('Audio-file does not exist: "' + Filename + '"', 'UAudio_FFMpeg');
+ Log.LogError('Audio-file does not exist: "' + Filename + '"', 'UAudio_FFmpeg');
Exit;
end;
@@ -265,7 +266,7 @@ begin
// open audio file
if (av_open_input_file(FormatCtx, PChar(Filename), nil, 0, nil) <> 0) then
begin
- Log.LogError('av_open_input_file failed: "' + Filename + '"', 'UAudio_FFMpeg');
+ Log.LogError('av_open_input_file failed: "' + Filename + '"', 'UAudio_FFmpeg');
Exit;
end;
@@ -275,7 +276,7 @@ begin
// retrieve stream information
if (av_find_stream_info(FormatCtx) < 0) then
begin
- Log.LogError('av_find_stream_info failed: "' + Filename + '"', 'UAudio_FFMpeg');
+ Log.LogError('av_find_stream_info failed: "' + Filename + '"', 'UAudio_FFmpeg');
Close();
Exit;
end;
@@ -283,19 +284,19 @@ begin
// FIXME: hack used by ffplay. Maybe should not use url_feof() to test for the end
FormatCtx^.pb.eof_reached := 0;
- {$IFDEF DebugFFMpegDecode}
+ {$IFDEF DebugFFmpegDecode}
dump_format(FormatCtx, 0, pchar(Filename), 0);
{$ENDIF}
- AudioStreamIndex := FFMpegCore.FindAudioStreamIndex(FormatCtx);
+ AudioStreamIndex := FFmpegCore.FindAudioStreamIndex(FormatCtx);
if (AudioStreamIndex < 0) then
begin
- Log.LogError('FindAudioStreamIndex: No Audio-stream found "' + Filename + '"', 'UAudio_FFMpeg');
+ Log.LogError('FindAudioStreamIndex: No Audio-stream found "' + Filename + '"', 'UAudio_FFmpeg');
Close();
Exit;
end;
- //Log.LogStatus('AudioStreamIndex is: '+ inttostr(ffmpegStreamID), 'UAudio_FFMpeg');
+ //Log.LogStatus('AudioStreamIndex is: '+ inttostr(ffmpegStreamID), 'UAudio_FFmpeg');
AudioStream := FormatCtx.streams[AudioStreamIndex];
CodecCtx := AudioStream^.codec;
@@ -313,7 +314,7 @@ begin
Codec := avcodec_find_decoder(CodecCtx^.codec_id);
if (Codec = nil) then
begin
- Log.LogError('Unsupported codec!', 'UAudio_FFMpeg');
+ Log.LogError('Unsupported codec!', 'UAudio_FFmpeg');
CodecCtx := nil;
Close();
Exit;
@@ -332,22 +333,22 @@ begin
// Note: avcodec_open() and avcodec_close() are not thread-safe and will
// fail if called concurrently by different threads.
- FFMpegCore.LockAVCodec();
+ FFmpegCore.LockAVCodec();
try
AVResult := avcodec_open(CodecCtx, Codec);
finally
- FFMpegCore.UnlockAVCodec();
+ FFmpegCore.UnlockAVCodec();
end;
if (AVResult < 0) then
begin
- Log.LogError('avcodec_open failed!', 'UAudio_FFMpeg');
+ Log.LogError('avcodec_open failed!', 'UAudio_FFmpeg');
Close();
Exit;
end;
// now initialize the audio-format
- if (not FFMpegCore.ConvertFFMpegToAudioFormat(CodecCtx^.sample_fmt, SampleFormat)) then
+ if (not FFmpegCore.ConvertFFmpegToAudioFormat(CodecCtx^.sample_fmt, SampleFormat)) then
begin
// try standard format
SampleFormat := asfS16;
@@ -368,7 +369,7 @@ begin
Result := true;
end;
-procedure TFFMpegDecodeStream.Close();
+procedure TFFmpegDecodeStream.Close();
var
ThreadResult: integer;
begin
@@ -396,11 +397,11 @@ begin
if (CodecCtx <> nil) then
begin
// avcodec_close() is not thread-safe
- FFMpegCore.LockAVCodec();
+ FFmpegCore.LockAVCodec();
try
avcodec_close(CodecCtx);
finally
- FFMpegCore.UnlockAVCodec();
+ FFmpegCore.UnlockAVCodec();
end;
CodecCtx := nil;
end;
@@ -418,60 +419,60 @@ begin
FreeAndNil(FormatInfo);
end;
-function TFFMpegDecodeStream.GetLength(): real;
+function TFFmpegDecodeStream.GetLength(): real;
begin
// do not forget to consider the start_time value here
Result := (FormatCtx^.start_time + FormatCtx^.duration) / AV_TIME_BASE;
end;
-function TFFMpegDecodeStream.GetAudioFormatInfo(): TAudioFormatInfo;
+function TFFmpegDecodeStream.GetAudioFormatInfo(): TAudioFormatInfo;
begin
Result := FormatInfo;
end;
-function TFFMpegDecodeStream.IsEOF(): boolean;
+function TFFmpegDecodeStream.IsEOF(): boolean;
begin
SDL_mutexP(StateLock);
Result := EOFState;
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.SetEOF(State: boolean);
+procedure TFFmpegDecodeStream.SetEOF(State: boolean);
begin
SDL_mutexP(StateLock);
EOFState := State;
SDL_mutexV(StateLock);
end;
-function TFFMpegDecodeStream.IsError(): boolean;
+function TFFmpegDecodeStream.IsError(): boolean;
begin
SDL_mutexP(StateLock);
Result := ErrorState;
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.SetError(State: boolean);
+procedure TFFmpegDecodeStream.SetError(State: boolean);
begin
SDL_mutexP(StateLock);
ErrorState := State;
SDL_mutexV(StateLock);
end;
-function TFFMpegDecodeStream.IsSeeking(): boolean;
+function TFFmpegDecodeStream.IsSeeking(): boolean;
begin
SDL_mutexP(StateLock);
Result := SeekRequest;
SDL_mutexV(StateLock);
end;
-function TFFMpegDecodeStream.IsQuit(): boolean;
+function TFFmpegDecodeStream.IsQuit(): boolean;
begin
SDL_mutexP(StateLock);
Result := QuitRequest;
SDL_mutexV(StateLock);
end;
-function TFFMpegDecodeStream.GetPosition(): real;
+function TFFmpegDecodeStream.GetPosition(): real;
var
BufferSizeSec: double;
begin
@@ -488,19 +489,19 @@ begin
ResumeDecoder();
end;
-procedure TFFMpegDecodeStream.SetPosition(Time: real);
+procedure TFFmpegDecodeStream.SetPosition(Time: real);
begin
SetPositionIntern(Time, true, true);
end;
-function TFFMpegDecodeStream.GetLoop(): boolean;
+function TFFmpegDecodeStream.GetLoop(): boolean;
begin
SDL_mutexP(StateLock);
Result := Loop;
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.SetLoop(Enabled: boolean);
+procedure TFFmpegDecodeStream.SetLoop(Enabled: boolean);
begin
SDL_mutexP(StateLock);
Loop := Enabled;
@@ -512,7 +513,7 @@ end;
* Parser section
********************************************)
-procedure TFFMpegDecodeStream.PauseParser();
+procedure TFFmpegDecodeStream.PauseParser();
begin
if (SDL_ThreadID() = ParseThread.threadid) then
Exit;
@@ -524,7 +525,7 @@ begin
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.ResumeParser();
+procedure TFFmpegDecodeStream.ResumeParser();
begin
if (SDL_ThreadID() = ParseThread.threadid) then
Exit;
@@ -535,7 +536,7 @@ begin
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.SetPositionIntern(Time: real; Flush: boolean; Blocking: boolean);
+procedure TFFmpegDecodeStream.SetPositionIntern(Time: real; Flush: boolean; Blocking: boolean);
begin
// - Pause the parser first to prevent it from putting obsolete packages
// into the queue after the queue was flushed and before seeking is done.
@@ -583,15 +584,15 @@ end;
function ParseThreadMain(Data: Pointer): integer; cdecl;
var
- Stream: TFFMpegDecodeStream;
+ Stream: TFFmpegDecodeStream;
begin
- Stream := TFFMpegDecodeStream(Data);
+ Stream := TFFmpegDecodeStream(Data);
if (Stream <> nil) then
Stream.Parse();
Result := 0;
end;
-procedure TFFMpegDecodeStream.Parse();
+procedure TFFmpegDecodeStream.Parse();
begin
// reuse thread as long as the stream is not terminated
while (ParseLoop()) do
@@ -614,7 +615,7 @@ end;
* Returns true if the stream can be resumed or false if the stream has to
* be terminated.
*)
-function TFFMpegDecodeStream.ParseLoop(): boolean;
+function TFFmpegDecodeStream.ParseLoop(): boolean;
var
Packet: TAVPacket;
StatusPacket: PAVPacket;
@@ -691,7 +692,7 @@ begin
begin
// seeking failed
ErrorState := true;
- Log.LogStatus('Seek Error in "'+FormatCtx^.filename+'"', 'UAudioDecoder_FFMpeg');
+ Log.LogStatus('Seek Error in "'+FormatCtx^.filename+'"', 'UAudioDecoder_FFmpeg');
end
else
begin
@@ -796,7 +797,7 @@ end;
* Decoder section
********************************************)
-procedure TFFMpegDecodeStream.PauseDecoder();
+procedure TFFmpegDecodeStream.PauseDecoder();
begin
SDL_mutexP(StateLock);
Inc(DecoderPauseRequestCount);
@@ -805,7 +806,7 @@ begin
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.ResumeDecoder();
+procedure TFFmpegDecodeStream.ResumeDecoder();
begin
SDL_mutexP(StateLock);
Dec(DecoderPauseRequestCount);
@@ -813,7 +814,7 @@ begin
SDL_mutexV(StateLock);
end;
-procedure TFFMpegDecodeStream.FlushCodecBuffers();
+procedure TFFmpegDecodeStream.FlushCodecBuffers();
begin
// if no flush operation is specified, avcodec_flush_buffers will not do anything.
if (@CodecCtx.codec.flush <> nil) then
@@ -824,25 +825,25 @@ begin
else
begin
// we need a Workaround to avoid plopping noise with ogg-vorbis and
- // mp3 (in older versions of FFMpeg).
+ // mp3 (in older versions of FFmpeg).
// We will just reopen the codec.
- FFMpegCore.LockAVCodec();
+ FFmpegCore.LockAVCodec();
try
avcodec_close(CodecCtx);
avcodec_open(CodecCtx, Codec);
finally
- FFMpegCore.UnlockAVCodec();
+ FFmpegCore.UnlockAVCodec();
end;
end;
end;
-function TFFMpegDecodeStream.DecodeFrame(Buffer: PChar; BufferSize: integer): integer;
+function TFFmpegDecodeStream.DecodeFrame(Buffer: PChar; BufferSize: integer): integer;
var
PaketDecodedSize: integer; // size of packet data used for decoding
- DataSize: integer; // size of output data decoded by FFMpeg
+ DataSize: integer; // size of output data decoded by FFmpeg
BlockQueue: boolean;
SilenceDuration: double;
- {$IFDEF DebugFFMpegDecode}
+ {$IFDEF DebugFFmpegDecode}
TmpPos: double;
{$ENDIF}
begin
@@ -881,7 +882,7 @@ begin
if(PaketDecodedSize < 0) then
begin
// if error, skip frame
- {$IFDEF DebugFFMpegDecode}
+ {$IFDEF DebugFFmpegDecode}
DebugWriteln('Skip audio frame');
{$ENDIF}
AudioPaketSize := 0;
@@ -942,7 +943,7 @@ begin
PKT_STATUS_FLAG_ERROR:
begin
SetError(true);
- Log.LogStatus('I/O Error', 'TFFMpegDecodeStream.DecodeFrame');
+ Log.LogStatus('I/O Error', 'TFFmpegDecodeStream.DecodeFrame');
Exit;
end;
PKT_STATUS_FLAG_EMPTY:
@@ -953,7 +954,7 @@ begin
end
else
begin
- Log.LogStatus('Unknown status', 'TFFMpegDecodeStream.DecodeFrame');
+ Log.LogStatus('Unknown status', 'TFFmpegDecodeStream.DecodeFrame');
end;
end;
@@ -966,11 +967,11 @@ begin
// if available, update the stream position to the presentation time of this package
if(AudioPaket.pts <> AV_NOPTS_VALUE) then
begin
- {$IFDEF DebugFFMpegDecode}
+ {$IFDEF DebugFFmpegDecode}
TmpPos := AudioStreamPos;
{$ENDIF}
AudioStreamPos := av_q2d(AudioStream^.time_base) * AudioPaket.pts;
- {$IFDEF DebugFFMpegDecode}
+ {$IFDEF DebugFFmpegDecode}
DebugWriteln('Timestamp: ' + floattostrf(AudioStreamPos, ffFixed, 15, 3) + ' ' +
'(Calc: ' + floattostrf(TmpPos, ffFixed, 15, 3) + '), ' +
'Diff: ' + floattostrf(AudioStreamPos-TmpPos, ffFixed, 15, 3));
@@ -979,7 +980,7 @@ begin
end;
end;
-function TFFMpegDecodeStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TFFmpegDecodeStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
var
CopyByteCount: integer; // number of bytes to copy
RemainByteCount: integer; // number of bytes left (remain) to read
@@ -1054,17 +1055,17 @@ begin
end;
-{ TAudioDecoder_FFMpeg }
+{ TAudioDecoder_FFmpeg }
-function TAudioDecoder_FFMpeg.GetName: String;
+function TAudioDecoder_FFmpeg.GetName: String;
begin
- Result := 'FFMpeg_Decoder';
+ Result := 'FFmpeg_Decoder';
end;
-function TAudioDecoder_FFMpeg.InitializeDecoder: boolean;
+function TAudioDecoder_FFmpeg.InitializeDecoder: boolean;
begin
- //Log.LogStatus('InitializeDecoder', 'UAudioDecoder_FFMpeg');
- FFMpegCore := TMediaCore_FFMpeg.GetInstance();
+ //Log.LogStatus('InitializeDecoder', 'UAudioDecoder_FFmpeg');
+ FFmpegCore := TMediaCore_FFmpeg.GetInstance();
av_register_all();
// Do not show uninformative error messages by default.
@@ -1085,18 +1086,18 @@ begin
Result := true;
end;
-function TAudioDecoder_FFMpeg.FinalizeDecoder(): boolean;
+function TAudioDecoder_FFmpeg.FinalizeDecoder(): boolean;
begin
Result := true;
end;
-function TAudioDecoder_FFMpeg.Open(const Filename: string): TAudioDecodeStream;
+function TAudioDecoder_FFmpeg.Open(const Filename: string): TAudioDecodeStream;
var
- Stream: TFFMpegDecodeStream;
+ Stream: TFFmpegDecodeStream;
begin
Result := nil;
- Stream := TFFMpegDecodeStream.Create();
+ Stream := TFFmpegDecodeStream.Create();
if (not Stream.Open(Filename)) then
begin
Stream.Free;
@@ -1108,6 +1109,6 @@ end;
initialization
- MediaManager.Add(TAudioDecoder_FFMpeg.Create);
+ MediaManager.Add(TAudioDecoder_FFmpeg.Create);
end.
diff --git a/Game/Code/Classes/UAudioPlayback_SoftMixer.pas b/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
index 31d0412b..6ddae980 100644
--- a/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
+++ b/Game/Code/Classes/UAudioPlayback_SoftMixer.pas
@@ -403,8 +403,8 @@ begin
DstFormatInfo := GetAudioFormatInfo();
// TODO: selection should not be done here, use a factory (TAudioConverterFactory) instead
- {$IF Defined(UseFFMpegResample)}
- Converter := TAudioConverter_FFMpeg.Create();
+ {$IF Defined(UseFFmpegResample)}
+ Converter := TAudioConverter_FFmpeg.Create();
{$ELSEIF Defined(UseSRCResample)}
Converter := TAudioConverter_SRC.Create();
{$ELSE}
diff --git a/Game/Code/Classes/UConfig.pas b/Game/Code/Classes/UConfig.pas
index 58aa704c..b77c2a5a 100644
--- a/Game/Code/Classes/UConfig.pas
+++ b/Game/Code/Classes/UConfig.pas
@@ -130,7 +130,7 @@ const
(FPC_PATCH * VERSION_RELEASE);
- {$IFDEF HaveFFMpeg}
+ {$IFDEF HaveFFmpeg}
LIBAVCODEC_VERSION = (LIBAVCODEC_VERSION_MAJOR * VERSION_MAJOR) +
(LIBAVCODEC_VERSION_MINOR * VERSION_MINOR) +
diff --git a/Game/Code/Classes/UMediaCore_FFMpeg.pas b/Game/Code/Classes/UMediaCore_FFMpeg.pas
index b914f6be..cdd320ac 100644
--- a/Game/Code/Classes/UMediaCore_FFMpeg.pas
+++ b/Game/Code/Classes/UMediaCore_FFMpeg.pas
@@ -1,4 +1,4 @@
-unit UMediaCore_FFMpeg;
+unit UMediaCore_FFmpeg;
interface
@@ -51,18 +51,18 @@ const
PKT_STATUS_FLAG_EMPTY = 4; // request the decoder to output empty data (silence or black frames)
type
- TMediaCore_FFMpeg = class
+ TMediaCore_FFmpeg = class
private
AVCodecLock: PSDL_Mutex;
public
constructor Create();
destructor Destroy(); override;
- class function GetInstance(): TMediaCore_FFMpeg;
+ class function GetInstance(): TMediaCore_FFmpeg;
function GetErrorString(ErrorNum: integer): string;
function FindStreamIDs(FormatCtx: PAVFormatContext; out FirstVideoStream, FirstAudioStream: integer ): boolean;
function FindAudioStreamIndex(FormatCtx: PAVFormatContext): integer;
- function ConvertFFMpegToAudioFormat(FFMpegFormat: TSampleFormat; out Format: TAudioSampleFormat): boolean;
+ function ConvertFFmpegToAudioFormat(FFmpegFormat: TSampleFormat; out Format: TAudioSampleFormat): boolean;
procedure LockAVCodec();
procedure UnlockAVCodec();
end;
@@ -73,38 +73,38 @@ uses
SysUtils;
var
- Instance: TMediaCore_FFMpeg;
+ Instance: TMediaCore_FFmpeg;
-constructor TMediaCore_FFMpeg.Create();
+constructor TMediaCore_FFmpeg.Create();
begin
inherited;
AVCodecLock := SDL_CreateMutex();
end;
-destructor TMediaCore_FFMpeg.Destroy();
+destructor TMediaCore_FFmpeg.Destroy();
begin
SDL_DestroyMutex(AVCodecLock);
inherited;
end;
-class function TMediaCore_FFMpeg.GetInstance(): TMediaCore_FFMpeg;
+class function TMediaCore_FFmpeg.GetInstance(): TMediaCore_FFmpeg;
begin
if (not Assigned(Instance)) then
- Instance := TMediaCore_FFMpeg.Create();
+ Instance := TMediaCore_FFmpeg.Create();
Result := Instance;
end;
-procedure TMediaCore_FFMpeg.LockAVCodec();
+procedure TMediaCore_FFmpeg.LockAVCodec();
begin
SDL_mutexP(AVCodecLock);
end;
-procedure TMediaCore_FFMpeg.UnlockAVCodec();
+procedure TMediaCore_FFmpeg.UnlockAVCodec();
begin
SDL_mutexV(AVCodecLock);
end;
-function TMediaCore_FFMpeg.GetErrorString(ErrorNum: integer): string;
+function TMediaCore_FFmpeg.GetErrorString(ErrorNum: integer): string;
begin
case ErrorNum of
AVERROR_IO: Result := 'AVERROR_IO';
@@ -125,7 +125,7 @@ end;
@param(FirstAudioStream is an OUT value of type integer, this is the index of the audio stream)
@returns(@true on success, @false otherwise)
}
-function TMediaCore_FFMpeg.FindStreamIDs(FormatCtx: PAVFormatContext; out FirstVideoStream, FirstAudioStream: integer): boolean;
+function TMediaCore_FFmpeg.FindStreamIDs(FormatCtx: PAVFormatContext; out FirstVideoStream, FirstAudioStream: integer): boolean;
var
i: integer;
Stream: PAVStream;
@@ -156,7 +156,7 @@ begin
(FirstVideoStream > -1) ;
end;
-function TMediaCore_FFMpeg.FindAudioStreamIndex(FormatCtx: PAVFormatContext): integer;
+function TMediaCore_FFmpeg.FindAudioStreamIndex(FormatCtx: PAVFormatContext): integer;
var
i: integer;
StreamIndex: integer;
@@ -179,9 +179,9 @@ begin
Result := StreamIndex;
end;
-function TMediaCore_FFMpeg.ConvertFFMpegToAudioFormat(FFMpegFormat: TSampleFormat; out Format: TAudioSampleFormat): boolean;
+function TMediaCore_FFmpeg.ConvertFFmpegToAudioFormat(FFmpegFormat: TSampleFormat; out Format: TAudioSampleFormat): boolean;
begin
- case FFMpegFormat of
+ case FFmpegFormat of
SAMPLE_FMT_U8: Format := asfU8;
SAMPLE_FMT_S16: Format := asfS16;
SAMPLE_FMT_S24: Format := asfS24;
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 4090bd2f..6476f629 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -1115,7 +1115,7 @@ begin
// calculate average time difference (some sort of weighted mean).
// The bigger AVG_HISTORY_FACTOR is, the smoother is the average diff.
// This means that older diffs are weighted more with a higher history factor
- // than with a lower. Do not use a too low history factor. FFMpeg produces
+ // than with a lower. Do not use a too low history factor. FFmpeg produces
// very instable timestamps (pts) for ogg due to some bugs. They may differ
// +-50ms from the real stream position. Without filtering those glitches we
// would synch without any need, resulting in ugly plopping sounds.
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index 698fb2de..0ab1d350 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -44,7 +44,7 @@ uses
{$IFDEF UseSWScale}
swscale,
{$ENDIF}
- UMediaCore_FFMpeg,
+ UMediaCore_FFmpeg,
math,
gl,
glext,
@@ -66,7 +66,7 @@ const
{$ENDIF}
type
- TVideoPlayback_FFMpeg = class( TInterfacedObject, IVideoPlayback )
+ TVideoPlayback_FFmpeg = class( TInterfacedObject, IVideoPlayback )
private
fVideoOpened,
fVideoPaused: Boolean;
@@ -121,7 +121,7 @@ type
end;
var
- FFMpegCore: TMediaCore_FFMpeg;
+ FFmpegCore: TMediaCore_FFmpeg;
// These are called whenever we allocate a frame buffer.
@@ -155,12 +155,12 @@ end;
* TVideoPlayback_ffmpeg
*------------------------------------------------------------------------------}
-function TVideoPlayback_FFMpeg.GetName: String;
+function TVideoPlayback_FFmpeg.GetName: String;
begin
- result := 'FFMpeg_Video';
+ result := 'FFmpeg_Video';
end;
-function TVideoPlayback_FFMpeg.Init(): boolean;
+function TVideoPlayback_FFmpeg.Init(): boolean;
begin
Result := true;
@@ -168,21 +168,21 @@ begin
Exit;
Initialized := true;
- FFMpegCore := TMediaCore_FFMpeg.GetInstance();
+ FFmpegCore := TMediaCore_FFmpeg.GetInstance();
Reset();
av_register_all();
glGenTextures(1, PGLuint(@fVideoTex));
end;
-function TVideoPlayback_FFMpeg.Finalize(): boolean;
+function TVideoPlayback_FFmpeg.Finalize(): boolean;
begin
Close();
glDeleteTextures(1, PGLuint(@fVideoTex));
Result := true;
end;
-procedure TVideoPlayback_FFMpeg.Reset();
+procedure TVideoPlayback_FFmpeg.Reset();
begin
// close previously opened video
Close();
@@ -201,7 +201,7 @@ begin
fLoopTime := 0;
end;
-function TVideoPlayback_FFMpeg.Open(const aFileName : string): boolean; // true if succeed
+function TVideoPlayback_FFmpeg.Open(const aFileName : string): boolean; // true if succeed
var
errnum: Integer;
AudioStreamIndex: integer;
@@ -213,7 +213,7 @@ begin
errnum := av_open_input_file(VideoFormatContext, PChar(aFileName), nil, 0, nil);
if (errnum <> 0) then
begin
- Log.LogError('Failed to open file "'+aFileName+'" ('+FFMpegCore.GetErrorString(errnum)+')');
+ Log.LogError('Failed to open file "'+aFileName+'" ('+FFmpegCore.GetErrorString(errnum)+')');
Exit;
end;
@@ -227,7 +227,7 @@ begin
Log.LogInfo('VideoStreamIndex : ' + inttostr(VideoStreamIndex), 'TVideoPlayback_ffmpeg.Open');
// find video stream
- FFMpegCore.FindStreamIDs(VideoFormatContext, VideoStreamIndex, AudioStreamIndex);
+ FFmpegCore.FindStreamIDs(VideoFormatContext, VideoStreamIndex, AudioStreamIndex);
if (VideoStreamIndex < 0) then
begin
Log.LogError('No video stream found', 'TVideoPlayback_ffmpeg.Open');
@@ -259,11 +259,11 @@ begin
// Note: avcodec_open() and avcodec_close() are not thread-safe and will
// fail if called concurrently by different threads.
- FFMpegCore.LockAVCodec();
+ FFmpegCore.LockAVCodec();
try
errnum := avcodec_open(VideoCodecContext, VideoCodec);
finally
- FFMpegCore.UnlockAVCodec();
+ FFmpegCore.UnlockAVCodec();
end;
if (errnum < 0) then
begin
@@ -306,7 +306,7 @@ begin
VideoCodecContext^.width, VideoCodecContext^.height);
if (errnum < 0) then
begin
- Log.LogError('avpicture_fill failed: ' + FFMpegCore.GetErrorString(errnum), 'TVideoPlayback_ffmpeg.Open');
+ Log.LogError('avpicture_fill failed: ' + FFmpegCore.GetErrorString(errnum), 'TVideoPlayback_ffmpeg.Open');
Close();
Exit;
end;
@@ -373,7 +373,7 @@ begin
Result := true;
end;
-procedure TVideoPlayback_FFMpeg.Close;
+procedure TVideoPlayback_FFmpeg.Close;
begin
if (FrameBuffer <> nil) then
av_free(FrameBuffer);
@@ -389,11 +389,11 @@ begin
if (VideoCodecContext <> nil) then
begin
// avcodec_close() is not thread-safe
- FFMpegCore.LockAVCodec();
+ FFmpegCore.LockAVCodec();
try
avcodec_close(VideoCodecContext);
finally
- FFMpegCore.UnlockAVCodec();
+ FFmpegCore.UnlockAVCodec();
end;
end;
@@ -406,7 +406,7 @@ begin
fVideoOpened := False;
end;
-procedure TVideoPlayback_FFMpeg.SynchronizeVideo(Frame: PAVFrame; var pts: double);
+procedure TVideoPlayback_FFmpeg.SynchronizeVideo(Frame: PAVFrame; var pts: double);
var
FrameDelay: double;
begin
@@ -426,7 +426,7 @@ begin
VideoTime := VideoTime + FrameDelay;
end;
-function TVideoPlayback_FFMpeg.DecodeFrame(var AVPacket: TAVPacket; out pts: double): boolean;
+function TVideoPlayback_FFmpeg.DecodeFrame(var AVPacket: TAVPacket; out pts: double): boolean;
var
FrameFinished: Integer;
VideoPktPts: int64;
@@ -520,7 +520,7 @@ begin
Result := true;
end;
-procedure TVideoPlayback_FFMpeg.GetFrame(Time: Extended);
+procedure TVideoPlayback_FFmpeg.GetFrame(Time: Extended);
var
AVPacket: TAVPacket;
errnum: Integer;
@@ -660,7 +660,7 @@ begin
{$ENDIF}
end;
-procedure TVideoPlayback_FFMpeg.DrawGL(Screen: integer);
+procedure TVideoPlayback_FFmpeg.DrawGL(Screen: integer);
var
TexVideoRightPos, TexVideoLowerPos: Single;
ScreenLeftPos, ScreenRightPos: Single;
@@ -773,20 +773,20 @@ begin
{$ENDIF}
end;
-procedure TVideoPlayback_FFMpeg.Play;
+procedure TVideoPlayback_FFmpeg.Play;
begin
end;
-procedure TVideoPlayback_FFMpeg.Pause;
+procedure TVideoPlayback_FFmpeg.Pause;
begin
fVideoPaused := not fVideoPaused;
end;
-procedure TVideoPlayback_FFMpeg.Stop;
+procedure TVideoPlayback_FFmpeg.Stop;
begin
end;
-procedure TVideoPlayback_FFMpeg.SetPosition(Time: real);
+procedure TVideoPlayback_FFmpeg.SetPosition(Time: real);
var
SeekFlags: integer;
begin
@@ -816,13 +816,13 @@ begin
avcodec_flush_buffers(VideoCodecContext);
end;
-function TVideoPlayback_FFMpeg.GetPosition: real;
+function TVideoPlayback_FFmpeg.GetPosition: real;
begin
// TODO: return video-position in seconds
Result := VideoTime;
end;
initialization
- MediaManager.Add(TVideoPlayback_FFMpeg.Create);
+ MediaManager.Add(TVideoPlayback_FFmpeg.Create);
end.