aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-07 20:31:37 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-07 20:31:37 +0000
commitd68d03ca93b9a991cc49c32dc170862b472dfdee (patch)
tree02028ff94406bc8af03c969e60cce8d96da7121d
parent55595c6403ac90100bb9e3ea26ed7cef05d4c4c3 (diff)
downloadusdx-d68d03ca93b9a991cc49c32dc170862b472dfdee.tar.gz
usdx-d68d03ca93b9a991cc49c32dc170862b472dfdee.tar.xz
usdx-d68d03ca93b9a991cc49c32dc170862b472dfdee.zip
- Fixed audio-playing in container (video) files. Now audio can be read directly from the video file and does not have to be extracted to a separate audio-file anymore (tested with vob, avi and flv. Note: With some versions of FFMPEG flv does not work correctly).
- Added "pCodecCtx^.workaround_bugs := FF_BUG_AUTODETECT" to let FFMPEG automatically handle known bugs. This might be interesting for video-decoding too. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@936 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UAudioDecoder_FFMpeg.pas44
-rw-r--r--Game/Code/Classes/UMusic.pas4
2 files changed, 34 insertions, 14 deletions
diff --git a/Game/Code/Classes/UAudioDecoder_FFMpeg.pas b/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
index 18d6c03b..e692df6f 100644
--- a/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
+++ b/Game/Code/Classes/UAudioDecoder_FFMpeg.pas
@@ -110,7 +110,7 @@ type
audio_buf : TAudioBuffer;
procedure Lock(); {$IFDEF HasInline}inline;{$ENDIF}
- procedure Unlock(); {$IFDEF HasInline}inline;{$ENDIF}
+ procedure Unlock(); {$IFDEF HasInline}inline;{$ENDIF}
function GetLockMutex(): PSDL_Mutex; {$IFDEF HasInline}inline;{$ENDIF}
procedure ParseAudio();
@@ -119,7 +119,7 @@ type
public
constructor Create(pFormatCtx: PAVFormatContext;
pCodecCtx: PAVCodecContext; pCodec: PAVCodec;
- ffmpegStreamID : Integer; ffmpegStream: PAVStream);
+ ffmpegStreamIndex: Integer; ffmpegStream: PAVStream);
destructor Destroy(); override;
procedure Close(); override;
@@ -154,7 +154,7 @@ var
constructor TFFMpegDecodeStream.Create(pFormatCtx: PAVFormatContext;
pCodecCtx: PAVCodecContext; pCodec: PAVCodec;
- ffmpegStreamID : Integer; ffmpegStream: PAVStream);
+ ffmpegStreamIndex : Integer; ffmpegStream: PAVStream);
begin
inherited Create();
@@ -229,14 +229,14 @@ begin
end;
procedure TFFMpegDecodeStream.Lock();
-begin
- SDL_mutexP(internalLock);
-end;
-
-procedure TFFMpegDecodeStream.Unlock();
-begin
- SDL_mutexV(internalLock);
-end;
+begin
+ SDL_mutexP(internalLock);
+end;
+
+procedure TFFMpegDecodeStream.Unlock();
+begin
+ SDL_mutexV(internalLock);
+end;
function TFFMpegDecodeStream.GetLockMutex(): PSDL_Mutex;
begin
@@ -634,6 +634,7 @@ begin
{$ENDIF}
ffmpegStreamID := FindAudioStreamIndex(pFormatCtx);
+ //Writeln('ID: ' + inttostr(ffmpegStreamID));
if (ffmpegStreamID < 0) then
exit;
@@ -649,7 +650,26 @@ begin
exit;
end;
- avcodec_open(pCodecCtx, pCodec);
+ // set debug options
+ pCodecCtx^.debug_mv := 0;
+ pCodecCtx^.debug := 0;
+
+ // detect bug-workarounds automatically
+ pCodecCtx^.workaround_bugs := FF_BUG_AUTODETECT;
+
+ // TODO: Not sure if these fields are for audio too
+ //pCodecCtx^.lowres := lowres;
+ //if (fast) then pCodecCtx^.flags2 := pCodecCtx^.flags2 or CODEC_FLAG2_FAST;
+ //pCodecCtx^.skip_frame := skip_frame;
+ //pCodecCtx^.skip_loop_filter := skip_loop_filter;
+ //pCodecCtx^.error_resilience := error_resilience;
+ //pCodecCtx^.error_concealment := error_concealment;
+
+ if (avcodec_open(pCodecCtx, pCodec) < 0) then
+ begin
+ Log.LogStatus('avcodec_open failed!', 'UAudio_FFMpeg');
+ exit;
+ end;
//WriteLn( 'Opened the codec' );
stream := TFFMpegDecodeStream.Create(pFormatCtx, pCodecCtx, pCodec,
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 699cfa23..e2538c9d 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -89,10 +89,10 @@ type
const
FFTSize = 512; // size of FFT data (output: FFTSize/2 values)
type
- TFFTData = array[0..(FFTSize div 2-1)] of Single;
+ TFFTData = array[0..(FFTSize div 2)-1] of Single;
type
- TPCMStereoSample = array[0..1] of Smallint;
+ TPCMStereoSample = array[0..1] of SmallInt;
TPCMData = array[0..511] of TPCMStereoSample;
type