Стартовый пул
This commit is contained in:
20
acs/Src/fileformats/acs_allformats.pas
Normal file
20
acs/Src/fileformats/acs_allformats.pas
Normal file
@@ -0,0 +1,20 @@
|
||||
unit acs_allformats;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_Vorbis,
|
||||
{$IFDEF MSWINDOWS}
|
||||
ACS_DSFiles,
|
||||
ACS_MAC,
|
||||
{$ELSE}
|
||||
acs_mpeg,
|
||||
{$ENDIF}
|
||||
ACS_FLAC,
|
||||
ACS_LAME,
|
||||
ACS_Wave;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
336
acs/Src/fileformats/acs_dsaudio.pas
Normal file
336
acs/Src/fileformats/acs_dsaudio.pas
Normal file
@@ -0,0 +1,336 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.4.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_dsaudio.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.3 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/13 03:13:57 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.4 2005/09/11 18:06:26 z0m3ie
|
||||
first working Version
|
||||
|
||||
Revision 1.3 2005/09/10 08:25:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/09/07 21:13:24 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/07 20:53:22 z0m3ie
|
||||
begon to add MPEG and WMA support using DirectX
|
||||
|
||||
}
|
||||
unit acs_dsaudio;
|
||||
|
||||
{$ifdef linux}{$message error 'unit not supported'}{$endif linux}
|
||||
|
||||
{$DEFINE DYNAMIC_LINK_ALL}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_File,ACS_Classes,DirectShow9,Classes,ActiveX,MMSystem,Windows;
|
||||
|
||||
const
|
||||
BUF_SIZE = $8000; // 32k
|
||||
|
||||
type
|
||||
{ TDSIn }
|
||||
|
||||
TDSIn = class(TACSFileIn)
|
||||
private
|
||||
buf : PBuffer8; // ring buffer
|
||||
FxFormat: TWaveFormatEx;
|
||||
FxAMMultiMediaStream: IAMMultiMediaStream;
|
||||
FxGraphBuilder: IGraphBuilder;
|
||||
FxMediaSeeking: IMediaSeeking;
|
||||
FxMediaControl: IMediaControl;
|
||||
FxAudioMediaStream: IAudioMediaStream;
|
||||
FxMediaStream: IMediaStream;
|
||||
FxAudioStreamSample: IAudioStreamSample;
|
||||
FxAudioData: IAudioData;
|
||||
FxBuffer: Pointer;
|
||||
FxBufferSize: DWord;
|
||||
FDuration,
|
||||
FxPosition,
|
||||
FxSelStart,
|
||||
FxSelLength,
|
||||
FxLastReadingStartTime,
|
||||
FxLastReadingEndTime : Stream_Time;
|
||||
FSeekScale : Integer;
|
||||
function Read(const Buffer; xSize: DWord): DWord;
|
||||
procedure SetPosition( Value: STREAM_TIME );
|
||||
protected
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
|
||||
procedure Init; override;
|
||||
procedure Flush; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
|
||||
function Seek(SampleNum : Integer) : Boolean; override;
|
||||
end;
|
||||
|
||||
const
|
||||
DSUSER_HRESULT = HResult($08000000);
|
||||
DSUSER_INVALIDSIZE = DSUSER_HRESULT + 1;
|
||||
|
||||
function ErrorCheck( Value: HRESULT ): HRESULT; { Check the result of a COM operation }
|
||||
|
||||
implementation
|
||||
|
||||
procedure TDSIn.OpenFile;
|
||||
var
|
||||
v : WideString;
|
||||
begin
|
||||
FValid := True;
|
||||
if FOpened = 0 then
|
||||
begin
|
||||
ErrorCheck( CoCreateInstance( CLSID_AMMultiMediaStream, nil, CLSCTX_INPROC_SERVER,IID_IAMMultiMediaStream, FxAMMultiMediaStream ) );
|
||||
ErrorCheck( FxAMMultiMediaStream.Initialize(STREAMTYPE_READ, AMMSF_NOGRAPHTHREAD, nil) );
|
||||
ErrorCheck( FxAMMultiMediaStream.AddMediaStream(nil, @MSPID_PrimaryAudio, 0, FxMediaStream) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetMediaStream(MSPID_PrimaryAudio, FxMediaStream) );
|
||||
v := FFileName;
|
||||
ErrorCheck( FxAMMultiMediaStream.OpenFile(PWideChar(v), 0) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetFilterGraph(FxGraphBuilder) );
|
||||
ErrorCheck( FxGraphBuilder.QueryInterface(IID_IMediaControl, FxMediaControl) );
|
||||
ErrorCheck( FxGraphBuilder.QueryInterface(IID_IMediaSeeking, FxMediaSeeking) );
|
||||
ErrorCheck( FxMediaStream.QueryInterface(IID_IAudioMediaStream, FxAudioMediaStream) );
|
||||
ErrorCheck( FxAudioMediaStream.GetFormat(FxFormat) );
|
||||
ErrorCheck( CoCreateInstance(CLSID_AMAudioData, nil, CLSCTX_INPROC_SERVER,IID_IAudioData, FxAudioData) );
|
||||
ErrorCheck( FxAudioData.SetFormat(FxFormat) );
|
||||
ErrorCheck( FxAudioMediaStream.CreateSample(FxAudioData, 0, FxAudioStreamSample) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetDuration(FDuration) );
|
||||
ErrorCheck( FxAMMultiMediaStream.SetState( STREAMSTATE_RUN ) );
|
||||
FxSelLength := 0;
|
||||
FSR := FxFormat.nSamplesPerSec;
|
||||
FBPS := FxFormat.wBitsPerSample;
|
||||
FChan := FxFormat.nChannels;
|
||||
FTotalSamples := FSize;
|
||||
FSeekable := TRUE;
|
||||
FSize := (FDuration div 10000000) *
|
||||
FxFormat.nSamplesPerSec *
|
||||
FxFormat.nChannels *
|
||||
FxFormat.wBitsPerSample div 8;
|
||||
FSeekScale := FDuration div FSize;
|
||||
end;
|
||||
Inc(FOpened);
|
||||
end;
|
||||
|
||||
procedure TDSIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if Assigned(FxAMMultiMediaStream) then
|
||||
ErrorCheck( FxAMMultiMediaStream.SetState( STREAMSTATE_STOP ) );
|
||||
FxAudioStreamSample := nil;
|
||||
FxAudioData := nil;
|
||||
FxAudioMediaStream := nil;
|
||||
FxMediaStream := nil;
|
||||
FxMediaSeeking := nil;
|
||||
FxMediaControl := nil;
|
||||
FxGraphBuilder := nil;
|
||||
FxAMMultiMediaStream := nil;
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TDSIn.GetData(Buffer: Pointer; BufferSize: Integer): Integer;
|
||||
var
|
||||
nDone : Integer;
|
||||
nOffs : Integer;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart > BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
FPosition := FOffset;
|
||||
if FPosition < 0 then
|
||||
FPosition := 0
|
||||
else if FPosition > FSize then
|
||||
FPosition := FSize;
|
||||
SetPosition(Int64(FPosition) * FSeekScale);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 1;
|
||||
nDone := Read(Buf^, BUF_SIZE);
|
||||
if nDone = 0 then
|
||||
begin
|
||||
if FLoop then
|
||||
begin
|
||||
SetPosition(0); // just rewind
|
||||
nDone := Read(Buf^, BUF_SIZE);
|
||||
end else
|
||||
begin
|
||||
Result := 0;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
BufEnd := nDone;
|
||||
end;
|
||||
|
||||
if BufferSize < (BufEnd - BufStart + 1) then
|
||||
Result := BufferSize
|
||||
else
|
||||
Result := BufEnd - BufStart + 1;
|
||||
|
||||
Move(Buf^[BufStart], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
constructor TDSIn.Create(AOwner: TComponent);
|
||||
var
|
||||
AMovie: IGraphBuilder;
|
||||
begin
|
||||
QzInitialize(nil);
|
||||
ErrorCheck(CoCreateInstance( CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, AMovie));
|
||||
inherited Create(AOwner);
|
||||
end;
|
||||
|
||||
destructor TDSIn.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDSIn.Init;
|
||||
begin
|
||||
inherited Init;
|
||||
GetMem(Buf, BUF_SIZE);
|
||||
end;
|
||||
|
||||
procedure TDSIn.Flush;
|
||||
begin
|
||||
FreeMem(Buf);
|
||||
inherited Flush;
|
||||
end;
|
||||
|
||||
function TDSIn.Seek(SampleNum: Integer): Boolean;
|
||||
begin
|
||||
FOffset := SampleNum;
|
||||
end;
|
||||
|
||||
function TDSIn.Read(const Buffer; xSize: DWord): DWord;
|
||||
var
|
||||
hr : DWord;
|
||||
Tmp: STREAM_TIME;
|
||||
begin
|
||||
Result := 0;
|
||||
if (xSize <= 0) then ErrorCheck(DSUSER_INVALIDSIZE);
|
||||
if (FxSelLength <> 0) and (FxPosition >= FxSelStart + FxSelLength) then exit;
|
||||
if (@Buffer <> FxBuffer) or (xSize <> FxBufferSize) then
|
||||
begin
|
||||
FxBuffer := @Buffer;
|
||||
FxBufferSize := xSize;
|
||||
ErrorCheck( FxAudioData.SetBuffer( FxBufferSize, FxBuffer, 0 ) );
|
||||
end;
|
||||
hr := FxAudioStreamSample.Update(0, 0, nil, 0);
|
||||
if (hr = MS_S_ENDOFSTREAM) or (hr = MS_E_NOSTREAM) then exit;
|
||||
ErrorCheck(hr);
|
||||
ErrorCheck( FxAudioData.GetInfo(FxBufferSize, FxBuffer, Result) );
|
||||
ErrorCheck( FxAudioStreamSample.GetSampleTimes( FxLastReadingStartTime,FxLastReadingEndTime, Tmp ) );
|
||||
if FxLastReadingStartTime > FxLastReadingEndTime then
|
||||
FxLastReadingStartTime := FxLastReadingEndTime;
|
||||
if (FxSelLength <> 0) and (FxLastReadingEndTime > FxLastReadingStartTime) and
|
||||
(FxSelStart + FxSelLength < FxLastReadingEndTime) then
|
||||
begin
|
||||
Result := DWord(Trunc(((Result *
|
||||
(FxSelStart + FxSelLength - FxLastReadingStartTime)) /
|
||||
(FxLastReadingEndTime - FxLastReadingStartTime)))) and
|
||||
(not(FxFormat.nBlockAlign-1));
|
||||
FxLastReadingEndTime := FxSelStart + FxSelLength;
|
||||
end;
|
||||
FxPosition := FxLastReadingEndTime;
|
||||
end;
|
||||
|
||||
procedure TDSIn.SetPosition( Value: STREAM_TIME );
|
||||
var pfs: TFilterState;
|
||||
begin
|
||||
if (Value <> FxPosition) then
|
||||
begin
|
||||
if (Value < FxSelStart) then
|
||||
Value := FxSelStart
|
||||
else
|
||||
if (Value > FDuration) then
|
||||
Value := FDuration
|
||||
else
|
||||
if (FxSelLength <> 0) and (Value > FxSelStart + FxSelLength) then
|
||||
Value := FxSelStart + FxSelLength;
|
||||
ErrorCheck(FxMediaControl.StopWhenReady );
|
||||
ErrorCheck(FxMediaSeeking.SetPositions(Value,AM_SEEKING_AbsolutePositioning, Value, AM_SEEKING_NoPositioning));
|
||||
ErrorCheck(FxMediaControl.Run );
|
||||
ErrorCheck(FxMediaControl.GetState(INFINITE, pfs) );
|
||||
FxPosition := Value;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ErrorCheck( Value: HRESULT ): HRESULT; { Check the result of a COM operation }
|
||||
var
|
||||
S: String;
|
||||
S2: array [0..300] of Char;
|
||||
begin
|
||||
Result := Value;
|
||||
if (Value <> S_OK) then
|
||||
begin
|
||||
Case DWord(Value) of
|
||||
DSUSER_INVALIDSIZE: S:='Invalid buffer size.';
|
||||
DWord(REGDB_E_CLASSNOTREG): S:='A specified class is not registered in the registration database.';
|
||||
DWord(CLASS_E_NOAGGREGATION): S:='This class cannot be created as part of an aggregate.';
|
||||
DWord(E_ABORT): S:='The update aborted.';
|
||||
DWOrd(E_INVALIDARG): S:='One of the parameters is invalid.';
|
||||
DWord(E_POINTER): S:='This method tried to access an invalid pointer.';
|
||||
DWord(E_NOINTERFACE): S:='No interface.';
|
||||
MS_S_PENDING: S:='The asynchronous update is pending.';
|
||||
MS_S_NOUPDATE: S:='Sample was not updated after forced completion.';
|
||||
MS_S_ENDOFSTREAM: S:='Reached the end of the stream; the sample wasn''t updated.';
|
||||
MS_E_SAMPLEALLOC: S:='An IMediaStream object could not be removed from an IMultiMediaStream object because it still contains at least one allocated sample.';
|
||||
MS_E_PURPOSEID: S:='The specified purpose ID can''t be used for the call.';
|
||||
MS_E_NOSTREAM: S:='No stream can be found with the specified attributes.';
|
||||
MS_E_NOSEEKING: S:='One or more media streams don''t support seeking.';
|
||||
MS_E_INCOMPATIBLE: S:='The stream formats are not compatible.';
|
||||
MS_E_BUSY: S:='This sample already has a pending update.';
|
||||
MS_E_NOTINIT: S:='The object can''t accept the call because its initialize function or equivalent has not been called.';
|
||||
MS_E_SOURCEALREADYDEFINED: S:='Source already defined.';
|
||||
MS_E_INVALIDSTREAMTYPE: S:='The stream type is not valid for this operation.';
|
||||
MS_E_NOTRUNNING: S:='The IMultiMediaStream object is not in running state.';
|
||||
Else
|
||||
begin
|
||||
if AMGetErrorText( Value, s2, High(s2) ) = 0 then
|
||||
S:='Unrecognized error value.'
|
||||
else
|
||||
S:=String( s2 );
|
||||
end;
|
||||
end;
|
||||
raise EACSException.Create(S);
|
||||
end;
|
||||
end ;
|
||||
|
||||
initialization
|
||||
FileFormats.Add('mp3','Mpeg Audio Layer III',TDSIn);
|
||||
FileFormats.Add('mp2','Mpeg Audio Layer II',TDSIn);
|
||||
FileFormats.Add('mpeg','Mpeg Audio',TDSIn);
|
||||
FileFormats.Add('wma','Windows Media Audio',TDSIn);
|
||||
|
||||
end.
|
||||
|
362
acs/Src/fileformats/acs_dsfiles.pas
Normal file
362
acs/Src/fileformats/acs_dsfiles.pas
Normal file
@@ -0,0 +1,362 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.4.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_dsfiles.pas,v $
|
||||
Revision 1.17 2006/09/04 14:40:16 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.16 2006/08/31 20:10:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.15 2006/08/03 17:31:35 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.14 2006/07/09 16:40:35 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.13 2006/07/04 17:12:45 z0m3ie
|
||||
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
|
||||
|
||||
Revision 1.9 2006/01/01 18:46:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.8 2005/12/26 17:31:39 z0m3ie
|
||||
fixed some problems in acs_dsfiles
|
||||
fixed some problems in acs_vorbis
|
||||
reworked all buffers
|
||||
|
||||
Revision 1.7 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.5 2005/12/18 17:01:54 z0m3ie
|
||||
delphi compatibility
|
||||
|
||||
Revision 1.4 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.3 2005/11/29 18:32:51 z0m3ie
|
||||
bugfixes for win32 version
|
||||
|
||||
Revision 1.2 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.1 2005/09/23 14:04:58 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/13 03:13:57 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.4 2005/09/11 18:06:26 z0m3ie
|
||||
first working Version
|
||||
|
||||
Revision 1.3 2005/09/10 08:25:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/09/07 21:13:24 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/07 20:53:22 z0m3ie
|
||||
begon to add MPEG and WMA support using DirectX
|
||||
|
||||
}
|
||||
unit acs_dsfiles;
|
||||
|
||||
{$ifdef linux}{$message error 'unit not supported'}{$endif linux}
|
||||
|
||||
{$DEFINE DYNAMIC_LINK_ALL}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_File,ACS_Classes,DirectShow9,Classes,ActiveX,MMSystem,Windows,ACS_Types;
|
||||
|
||||
type
|
||||
{ TDSIn }
|
||||
|
||||
TDSIn = class(TACSCustomFileIn)
|
||||
private
|
||||
{$ifdef fpc}
|
||||
FxFormat: _WAVEFORMATEX;
|
||||
{$else}
|
||||
FxFormat: TWaveFormatEx;
|
||||
{$endif}
|
||||
FxAMMultiMediaStream: IAMMultiMediaStream;
|
||||
FxGraphBuilder: IGraphBuilder;
|
||||
FxMediaSeeking: IMediaSeeking;
|
||||
FxMediaControl: IMediaControl;
|
||||
FxAudioMediaStream: IAudioMediaStream;
|
||||
FxMediaStream: IMediaStream;
|
||||
FxAudioStreamSample: IAudioStreamSample;
|
||||
FxAudioData: IAudioData;
|
||||
FxBuffer: Pointer;
|
||||
FxBufferSize: DWord;
|
||||
FDuration,
|
||||
FxPosition,
|
||||
FxSelStart,
|
||||
FxSelLength,
|
||||
FxLastReadingStartTime,
|
||||
FxLastReadingEndTime : Stream_Time;
|
||||
FSeekScale : Integer;
|
||||
function Read(Buffer : Pointer; xSize: DWord): DWord;
|
||||
procedure SetPosition( Value: STREAM_TIME );
|
||||
protected
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
|
||||
function Seek(SampleNum : Integer) : Boolean; override;
|
||||
end;
|
||||
|
||||
const
|
||||
DSUSER_HRESULT = HResult($08000000);
|
||||
DSUSER_INVALIDSIZE = DSUSER_HRESULT + 1;
|
||||
|
||||
function ErrorCheck( Value: HRESULT ): HRESULT; { Check the result of a COM operation }
|
||||
|
||||
implementation
|
||||
|
||||
procedure TDSIn.OpenFile;
|
||||
var
|
||||
v : WideString;
|
||||
begin
|
||||
FValid := True;
|
||||
if FOpened = 0 then
|
||||
begin
|
||||
QzInitialize(nil);
|
||||
ErrorCheck( CoCreateInstance( CLSID_AMMultiMediaStream, nil, CLSCTX_INPROC_SERVER,IID_IAMMultiMediaStream, FxAMMultiMediaStream ) );
|
||||
ErrorCheck( FxAMMultiMediaStream.Initialize(STREAMTYPE_READ, AMMSF_NOGRAPHTHREAD, nil) );
|
||||
ErrorCheck( FxAMMultiMediaStream.AddMediaStream(nil, @MSPID_PrimaryAudio, 0, FxMediaStream) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetMediaStream(MSPID_PrimaryAudio, FxMediaStream) );
|
||||
v := FFileName;
|
||||
ErrorCheck( FxAMMultiMediaStream.OpenFile(PWideChar(v), 0) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetFilterGraph(FxGraphBuilder) );
|
||||
ErrorCheck( FxGraphBuilder.QueryInterface(IID_IMediaControl, FxMediaControl) );
|
||||
ErrorCheck( FxGraphBuilder.QueryInterface(IID_IMediaSeeking, FxMediaSeeking) );
|
||||
ErrorCheck( FxMediaStream.QueryInterface(IID_IAudioMediaStream, FxAudioMediaStream) );
|
||||
ErrorCheck( FxAudioMediaStream.GetFormat(FxFormat) );
|
||||
ErrorCheck( CoCreateInstance(CLSID_AMAudioData, nil, CLSCTX_INPROC_SERVER,IID_IAudioData, FxAudioData) );
|
||||
ErrorCheck( FxAudioData.SetFormat(FxFormat) );
|
||||
ErrorCheck( FxAudioMediaStream.CreateSample(FxAudioData, 0, FxAudioStreamSample) );
|
||||
ErrorCheck( FxAMMultiMediaStream.GetDuration(FDuration) );
|
||||
ErrorCheck( FxAMMultiMediaStream.SetState( STREAMSTATE_RUN ) );
|
||||
FxSelLength := 0;
|
||||
FSR := FxFormat.nSamplesPerSec;
|
||||
FBPS := FxFormat.wBitsPerSample;
|
||||
FChan := FxFormat.nChannels;
|
||||
FTotalSamples := FSize;
|
||||
FSeekable := TRUE;
|
||||
if fDuration = 0 then exit;
|
||||
FSize :=(FDuration div 10000000) *
|
||||
FSR *
|
||||
FChan *
|
||||
FBPS div 8;
|
||||
FSeekScale := FDuration div FSize;
|
||||
end;
|
||||
Inc(FOpened);
|
||||
end;
|
||||
|
||||
procedure TDSIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if Assigned(FxAMMultiMediaStream) then
|
||||
ErrorCheck( FxAMMultiMediaStream.SetState( STREAMSTATE_STOP ) );
|
||||
FxAudioStreamSample := nil;
|
||||
FxAudioData := nil;
|
||||
FxAudioMediaStream := nil;
|
||||
FxMediaStream := nil;
|
||||
FxMediaSeeking := nil;
|
||||
FxMediaControl := nil;
|
||||
FxGraphBuilder := nil;
|
||||
FxAMMultiMediaStream := nil;
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TDSIn.GetData(Buffer: Pointer; BufferSize: Integer): Integer;
|
||||
var
|
||||
nDone : Integer;
|
||||
nOffs : Integer;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart > BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
FPosition := FPosition+Round((FOffset/100)*FSize);
|
||||
if FPosition < 0 then
|
||||
FPosition := 0
|
||||
else if FPosition > FSize then
|
||||
FPosition := FSize;
|
||||
SetPosition(Int64(FPosition) * FSeekScale);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 1;
|
||||
nDone := Read(FBuffer, BufferSize);
|
||||
if nDone = 0 then
|
||||
begin
|
||||
if FLoop then
|
||||
begin
|
||||
SetPosition(0); // just rewind
|
||||
nDone := Read(FBuffer, BufferSize);
|
||||
end else
|
||||
begin
|
||||
Result := 0;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
BufEnd := nDone;
|
||||
end;
|
||||
|
||||
if BufferSize < (BufEnd - BufStart + 1) then
|
||||
Result := BufferSize
|
||||
else
|
||||
Result := BufEnd - BufStart + 1;
|
||||
|
||||
Move(FBuffer[BufStart-1], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
constructor TDSIn.Create(AOwner: TComponent);
|
||||
var
|
||||
AMovie: IGraphBuilder;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
BufferSize := $8000;
|
||||
QzInitialize(nil);
|
||||
ErrorCheck(CoCreateInstance( CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, AMovie));
|
||||
end;
|
||||
|
||||
destructor TDSIn.Destroy;
|
||||
begin
|
||||
QzUninitialize;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TDSIn.Seek(SampleNum : Integer): Boolean;
|
||||
begin
|
||||
FPosition := SampleNum;
|
||||
end;
|
||||
|
||||
function TDSIn.Read(Buffer : Pointer; xSize: DWord): DWord;
|
||||
var
|
||||
hr : DWord;
|
||||
Tmp: STREAM_TIME;
|
||||
begin
|
||||
Result := 0;
|
||||
if (xSize <= 0) then
|
||||
ErrorCheck(DSUSER_INVALIDSIZE);
|
||||
if (FxSelLength <> 0) and (FxPosition >= FxSelStart + FxSelLength) then
|
||||
exit;
|
||||
if (Buffer <> FxBuffer) or (xSize <> FxBufferSize) then
|
||||
begin
|
||||
FxBuffer := Buffer;
|
||||
FxBufferSize := xSize;
|
||||
ErrorCheck( FxAudioData.SetBuffer( FxBufferSize, FxBuffer, 0 ) );
|
||||
end;
|
||||
hr := FxAudioStreamSample.Update(0, 0, nil, 0);
|
||||
if (hr = MS_S_ENDOFSTREAM) or (hr = MS_E_NOSTREAM) then exit;
|
||||
ErrorCheck(hr);
|
||||
ErrorCheck( FxAudioData.GetInfo(FxBufferSize, FxBuffer, Result) );
|
||||
ErrorCheck( FxAudioStreamSample.GetSampleTimes( FxLastReadingStartTime,FxLastReadingEndTime, Tmp ) );
|
||||
if FxLastReadingStartTime > FxLastReadingEndTime then
|
||||
FxLastReadingStartTime := FxLastReadingEndTime;
|
||||
if (FxSelLength <> 0) and (FxLastReadingEndTime > FxLastReadingStartTime) and
|
||||
(FxSelStart + FxSelLength < FxLastReadingEndTime) then
|
||||
begin
|
||||
Result := DWord(Trunc(((Result *
|
||||
(FxSelStart + FxSelLength - FxLastReadingStartTime)) /
|
||||
(FxLastReadingEndTime - FxLastReadingStartTime)))) and
|
||||
(not(FxFormat.nBlockAlign-1));
|
||||
FxLastReadingEndTime := FxSelStart + FxSelLength;
|
||||
end;
|
||||
FxPosition := FxLastReadingEndTime;
|
||||
end;
|
||||
|
||||
procedure TDSIn.SetPosition( Value: STREAM_TIME );
|
||||
var pfs: TFilterState;
|
||||
begin
|
||||
if (Value <> FxPosition) then
|
||||
begin
|
||||
if (Value < FxSelStart) then
|
||||
Value := FxSelStart
|
||||
else
|
||||
if (Value > FDuration) then
|
||||
Value := FDuration
|
||||
else
|
||||
if (FxSelLength <> 0) and (Value > FxSelStart + FxSelLength) then
|
||||
Value := FxSelStart + FxSelLength;
|
||||
ErrorCheck(FxMediaControl.StopWhenReady );
|
||||
ErrorCheck(FxMediaSeeking.SetPositions(Value,AM_SEEKING_AbsolutePositioning, Value, AM_SEEKING_NoPositioning));
|
||||
ErrorCheck(FxMediaControl.Run );
|
||||
ErrorCheck(FxMediaControl.GetState(INFINITE, pfs) );
|
||||
FxPosition := Value;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ErrorCheck( Value: HRESULT ): HRESULT; { Check the result of a COM operation }
|
||||
var
|
||||
S: String;
|
||||
S2: array [0..300] of Char;
|
||||
begin
|
||||
Result := Value;
|
||||
if (Value <> S_OK) then
|
||||
begin
|
||||
Case DWord(Value) of
|
||||
DSUSER_INVALIDSIZE: S:='Invalid buffer size.';
|
||||
DWord(REGDB_E_CLASSNOTREG): S:='A specified class is not registered in the registration database.';
|
||||
DWord(CLASS_E_NOAGGREGATION): S:='This class cannot be created as part of an aggregate.';
|
||||
DWord(E_ABORT): S:='The update aborted.';
|
||||
DWOrd(E_INVALIDARG): S:='One of the parameters is invalid.';
|
||||
DWord(E_POINTER): S:='This method tried to access an invalid pointer.';
|
||||
DWord(E_NOINTERFACE): S:='No interface.';
|
||||
MS_S_PENDING: S:='The asynchronous update is pending.';
|
||||
MS_S_NOUPDATE: S:='Sample was not updated after forced completion.';
|
||||
MS_S_ENDOFSTREAM: S:='Reached the end of the stream; the sample wasn''t updated.';
|
||||
MS_E_SAMPLEALLOC: S:='An IMediaStream object could not be removed from an IMultiMediaStream object because it still contains at least one allocated sample.';
|
||||
MS_E_PURPOSEID: S:='The specified purpose ID can''t be used for the call.';
|
||||
MS_E_NOSTREAM: S:='No stream can be found with the specified attributes.';
|
||||
MS_E_NOSEEKING: S:='One or more media streams don''t support seeking.';
|
||||
MS_E_INCOMPATIBLE: S:='The stream formats are not compatible.';
|
||||
MS_E_BUSY: S:='This sample already has a pending update.';
|
||||
MS_E_NOTINIT: S:='The object can''t accept the call because its initialize function or equivalent has not been called.';
|
||||
MS_E_SOURCEALREADYDEFINED: S:='Source already defined.';
|
||||
MS_E_INVALIDSTREAMTYPE: S:='The stream type is not valid for this operation.';
|
||||
MS_E_NOTRUNNING: S:='The IMultiMediaStream object is not in running state.';
|
||||
Else
|
||||
begin
|
||||
if AMGetErrorText( Value, s2, High(s2) ) = 0 then
|
||||
S:='Unrecognized error value.'
|
||||
else
|
||||
S:=String( s2 );
|
||||
end;
|
||||
end;
|
||||
// raise EACSException.Create(S);
|
||||
end;
|
||||
end ;
|
||||
|
||||
initialization
|
||||
FileFormats.Add('mp3','Mpeg Audio Layer III',TDSIn);
|
||||
FileFormats.Add('mp2','Mpeg Audio Layer II',TDSIn);
|
||||
FileFormats.Add('mpeg','Mpeg Audio',TDSIn);
|
||||
FileFormats.Add('wma','Windows Media Audio',TDSIn);
|
||||
|
||||
end.
|
||||
|
595
acs/Src/fileformats/acs_flac.pas
Normal file
595
acs/Src/fileformats/acs_flac.pas
Normal file
@@ -0,0 +1,595 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_flac.pas,v $
|
||||
Revision 1.7 2006/07/09 16:40:35 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.6 2006/07/04 17:12:45 z0m3ie
|
||||
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
|
||||
|
||||
Revision 1.2 2005/12/30 11:10:57 z0m3ie
|
||||
some corrections to lazarus-linux depending things
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.4 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.3 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit acs_flac;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_File,Classes, SysUtils, ACS_Types, ACS_Classes, FLAC,
|
||||
{$IFDEF LINUX}
|
||||
baseunix;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
|
||||
TFLACOut = class(TACSCustomFileOut)
|
||||
private
|
||||
_encoder : PFLAC__SeekableStreamEncoder;
|
||||
FBufSize : Integer;
|
||||
FVerify : Boolean;
|
||||
FBlockSize : Word;
|
||||
FBestModelSearch : Boolean;
|
||||
FEnableMidSideStereo : Boolean;
|
||||
FMaxLPCOrder : Word;
|
||||
EndOfInput : Boolean;
|
||||
FEnableLooseMidSideStereo : Boolean;
|
||||
FQLPCoeffPrecision : Word;
|
||||
FQLPCoeffPrecisionSearch : Boolean;
|
||||
FMaxResidualPartitionOrder : Word;
|
||||
FMinResidualPartitionOrder : Word;
|
||||
procedure SetEnableLooseMidSideStereo(val : Boolean);
|
||||
procedure SetBestModelSearch(val : Boolean);
|
||||
protected
|
||||
procedure Done; override;
|
||||
function DoOutput(Abort : Boolean):Boolean; override;
|
||||
procedure Prepare; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property BestModelSearch : Boolean read FBestModelSearch write SetBestModelSearch;
|
||||
property BlockSize : Word read FBlockSize write FBlockSize;
|
||||
property EnableMidSideStereo : Boolean read FEnableMidSideStereo write FEnableMidSideStereo;
|
||||
property EnableLooseMidSideStereo : Boolean read FEnableLooseMidSideStereo write SetEnableLooseMidSideStereo;
|
||||
property MaxLPCOrder : Word read FMaxLPCOrder write FMaxLPCOrder;
|
||||
property MaxResidualPartitionOrder : Word read FMaxResidualPartitionOrder write FMaxResidualPartitionOrder;
|
||||
property MinResidualPartitionOrder : Word read FMinResidualPartitionOrder write FMinResidualPartitionOrder;
|
||||
property QLPCoeffPrecision : Word read FQLPCoeffPrecision write FQLPCoeffPrecision;
|
||||
property QLPCoeffPrecisionSearch : Boolean read FQLPCoeffPrecisionSearch write FQLPCoeffPrecisionSearch;
|
||||
property Verify : Boolean read FVerify write FVerify;
|
||||
end;
|
||||
|
||||
TFLACIn = class(TACSCustomFileIn)
|
||||
private
|
||||
Buff : PACSBuffer8;
|
||||
_decoder : PFLAC__SeekableStreamDecoder;
|
||||
FBlockSize: Integer;
|
||||
BytesPerBlock : Integer;
|
||||
EndOfStream : Boolean;
|
||||
MinFrameSize : Integer;
|
||||
protected
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
|
||||
function Seek(SampleNum : Integer) : Boolean; override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
type
|
||||
|
||||
FLACBuf = array[0..0] of FLAC__int32;
|
||||
PFLACBuf = ^FLACBuf;
|
||||
|
||||
function EncWriteCBFunc(encoder : PFLAC__SeekableStreamEncoder;
|
||||
buffer : PFLAC__byte;
|
||||
bytes, samples, current_frame : LongWord;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACOut : TFLACOut;
|
||||
begin
|
||||
FLACOut := TFLACOut(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_ENCODER_OK;
|
||||
try
|
||||
FLACOut.FStream.Write(buffer^, bytes);
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function EncSeekCBFunc(encoder : PFLAC__SeekableStreamEncoder;
|
||||
absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACOut : TFLACOut;
|
||||
begin
|
||||
FLACOut := TFLACOut(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK;
|
||||
try
|
||||
FLACOut.FStream.Seek(absolute_byte_offset, soFromBeginning);
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DecReadCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
buffer : PFLAC__byte;
|
||||
var bytes : LongWord;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
|
||||
if FLACIn.FStream.Position >= FLACIn.FStream.Size then
|
||||
begin
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM;
|
||||
Exit;
|
||||
end;
|
||||
try
|
||||
bytes := FLACIn.FStream.Read(buffer^, bytes);
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DecSeekCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
|
||||
try
|
||||
FLACIn.FStream.Seek(absolute_byte_offset, soFromBeginning);
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DecTellCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
var absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
|
||||
try
|
||||
absolute_byte_offset := FLACIn.FStream.Position;
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DecLengthCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
var stream_length : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
|
||||
try
|
||||
stream_length := FLACIn.FStream.Size;
|
||||
except
|
||||
Result := FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DecEOFCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
client_data : Pointer) : Boolean; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
if FLACIn.FStream.Position >= FLACIn.FStream.Size then Result := True
|
||||
else Result := False;
|
||||
end;
|
||||
|
||||
function DecWriteCBFunc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
frame : PFLAC__Frame;
|
||||
buffer : PFLACChannels;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
Header : PFLAC__FrameHeader;
|
||||
buffer1 : PFLACIntBuf;
|
||||
buffer2 : PFLACIntBuf;
|
||||
B16 : PACSBuffer16;
|
||||
i : Integer;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
Header := PFLAC__FrameHeader(frame);
|
||||
FLACIn.FBlockSize := Header.blocksize;
|
||||
FLACIn.BytesPerBlock := FLACIn.FBlockSize*(FLACIn.FBPS shr 3)*FLACIn.FChan;
|
||||
GetMem(FLACIn.Buff, FLACIn.BytesPerBlock);
|
||||
// FillChar(FLACIn.Buff[0], FLACIn.BytesPerBlock, 255);
|
||||
if FLACIn.FBPS = 16 then
|
||||
begin
|
||||
B16 := PACSBuffer16(FLACIn.Buff);
|
||||
if FLACIn.FChan = 1 then
|
||||
begin
|
||||
buffer1 := buffer[0];
|
||||
for i := 0 to FLACIn.FBlockSize-1 do B16[i] := buffer1[i]
|
||||
end else
|
||||
begin
|
||||
buffer1 := buffer[0];
|
||||
buffer2 := buffer[1];
|
||||
for i := 0 to FLACIn.FBlockSize-1 do
|
||||
begin
|
||||
B16[i shl 1] := buffer1[i];
|
||||
B16[(i shl 1)+1] := buffer2[i];
|
||||
end;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FLACIn.FChan = 1 then
|
||||
begin
|
||||
buffer1 := buffer[0];
|
||||
for i := 0 to FLACIn.FBlockSize-1 do FLACIn.Buff[i] := buffer1[i];
|
||||
end else
|
||||
begin
|
||||
buffer1 := buffer[0];
|
||||
buffer2 := buffer[1];
|
||||
for i := 0 to FLACIn.FBlockSize-1 do
|
||||
begin
|
||||
FLACIn.Buff[i shl 1] := buffer1[i];
|
||||
FLACIn.Buff[(i shl 1)+1] := buffer2[i];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := FLAC__SEEKABLE_STREAM_ENCODER_OK;
|
||||
end;
|
||||
|
||||
procedure DecMetadataCBProc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
metadata : PFLAC__StreamMetadata;
|
||||
client_data : Pointer); cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
P : Pointer;
|
||||
FI : PFLACInfo;
|
||||
begin
|
||||
if LongWord(metadata^) <> 0 then Exit;
|
||||
P := metadata;
|
||||
(*
|
||||
STREAMINFO block format differs in different
|
||||
FLAC codec versions, so we are trying to be flexible here.
|
||||
*)
|
||||
while LongWord(P^) = 0 do Inc(P, 4);
|
||||
Inc(P, 4);
|
||||
if LongWord(P^) = 0 then Inc(P, 4);
|
||||
FI := PFLACInfo(P);
|
||||
FLACIn := TFLACIn(client_data);
|
||||
FLACIn.FSR := FI.sample_rate;
|
||||
FLACIn.FChan := FI.channels;
|
||||
if FLACIn.FChan > 2 then FLACIn.FValid := False;
|
||||
FLACIn.FBPS := FI.bits_per_sample;
|
||||
if FLACIn.FChan > 16 then FLACIn.FValid := False;
|
||||
FLACIn.FTotalSamples := FI.total_samples1;
|
||||
if FLACIn.FTotalSamples = 0 then
|
||||
FLACIn.FTotalSamples := FI.total_samples2;
|
||||
FLACIn.FSize := FLACIn.FTotalSamples*(FLACIn.FBPS shr 3)*FLACIn.FChan;
|
||||
FLACIn.MinFrameSize := FI.min_framesize;
|
||||
end;
|
||||
|
||||
procedure DecErrorCBProc(decoder : PFLAC__SeekableStreamDecoder;
|
||||
status : Integer;
|
||||
client_data : Pointer); cdecl;
|
||||
var
|
||||
FLACIn : TFLACIn;
|
||||
begin
|
||||
FLACIn := TFLACIn(client_data);
|
||||
FLACIn.FValid := False;
|
||||
end;
|
||||
|
||||
constructor TFLACOut.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FVerify := False;
|
||||
FBufferSize := $6000;
|
||||
FBlockSize := 4608;
|
||||
FBestModelSearch := False;
|
||||
FEnableMidSideStereo := True;
|
||||
if not (csDesigning in ComponentState) then
|
||||
if not LibFLACLoaded then
|
||||
raise EACSException.Create(LibFLACPath + ' library could not be loaded.');
|
||||
end;
|
||||
|
||||
destructor TFLACOut.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TFLACOut.Prepare;
|
||||
begin
|
||||
if not FStreamAssigned then
|
||||
begin
|
||||
if FFileName = '' then raise EACSException.Create('File name is not assigned.');
|
||||
if (not FileExists(FFileName)) or (FFileMode = foRewrite) then
|
||||
FStream := TFileStream.Create(FFileName, fmCreate or fmShareExclusive, FAccessMask)
|
||||
else FStream := TFileStream.Create(FFileName, fmOpenReadWrite or fmShareExclusive, FAccessMask);
|
||||
end;
|
||||
EndOfInput := False;
|
||||
_encoder := FLAC__seekable_stream_encoder_new;
|
||||
if _encoder = nil then
|
||||
raise EACSException.Create('Failed to initialize FLAC encoder.');
|
||||
FInput.Init;
|
||||
FLAC__seekable_stream_encoder_set_verify(_encoder, FVerify);
|
||||
FLAC__seekable_stream_encoder_set_channels(_encoder, FInput.Channels);
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample(_encoder, FInput.BitsPerSample);
|
||||
FLAC__seekable_stream_encoder_set_sample_rate(_encoder, FInput.SampleRate);
|
||||
if FInput.Channels = 2 then
|
||||
begin
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo(_encoder, FEnableMidSideStereo);
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo(_encoder, FEnableLooseMidSideStereo);
|
||||
end;
|
||||
FLAC__seekable_stream_encoder_set_blocksize(_encoder, FBlockSize);
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order(_encoder, FMaxLPCOrder);
|
||||
if FQLPCoeffPrecision + FInput.BitsPerSample > 31 then FQLPCoeffPrecision := 31 - FInput.BitsPerSample;
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision(_encoder, FQLPCoeffPrecision);
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(_encoder, FQLPCoeffPrecisionSearch);
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order(_encoder, FMinResidualPartitionOrder);
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order(_encoder, FMaxResidualPartitionOrder);
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search(_encoder, FBestModelSearch);
|
||||
if FInput.Size > 0 then
|
||||
FLAC__seekable_stream_encoder_set_total_samples_estimate(_encoder, Round(FInput.Size/(FInput.BitsPerSample shr 3)/FInput.Channels));
|
||||
FLAC__seekable_stream_encoder_set_seek_callback(_encoder, EncSeekCBFunc);
|
||||
FLAC__seekable_stream_encoder_set_write_callback(_encoder, EncWriteCBFunc);
|
||||
FLAC__seekable_stream_encoder_set_client_data(_encoder, Self);
|
||||
if FLAC__seekable_stream_encoder_init(_encoder) <>
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_OK then
|
||||
begin
|
||||
FInput.Flush;
|
||||
raise EACSException.Create('Failed to initialize FLAC encoder.');
|
||||
end;
|
||||
//TODO: Recreate this stuff with uffersize more equal to FBufferSize
|
||||
FBufSize := FBufferSize div FBlockSize;
|
||||
FBufSize := FBufSize * (FInput.BitsPerSample shr 3) * FInput.Channels;
|
||||
GetMem(FBuffer, FBufSize);
|
||||
end;
|
||||
|
||||
procedure TFLACOut.Done;
|
||||
begin
|
||||
if not FStreamAssigned then
|
||||
FLAC__seekable_stream_encoder_finish(_encoder);
|
||||
FLAC__seekable_stream_encoder_delete(_encoder);
|
||||
if FBuffer <> nil then
|
||||
FreeMem(FBuffer);
|
||||
FBuffer := nil;
|
||||
FStream.Free;
|
||||
FInput.Flush;
|
||||
end;
|
||||
|
||||
function TFLACOut.DoOutput(Abort : Boolean):Boolean;
|
||||
var
|
||||
Len, i, l, samples : Integer;
|
||||
FB : PFLACBuf;
|
||||
B16 : PACSBuffer16;
|
||||
begin
|
||||
Result := True;
|
||||
if not CanOutput then Exit;
|
||||
if Abort or EndOfInput then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
while InputLock do;
|
||||
InputLock := True;
|
||||
Len := 0;
|
||||
while Len < FBufSize do
|
||||
begin
|
||||
l := Finput.GetData(@FBuffer[Len], FBufSize-Len);
|
||||
Inc(Len, l);
|
||||
if l = 0 then
|
||||
begin
|
||||
EndOfInput := True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
InputLock := False;
|
||||
if Len = 0 then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
samples := (Len shl 3) div Finput.BitsPerSample;
|
||||
GetMem(FB, samples*SizeOF(FLAC__int32));
|
||||
if FInput.BitsPerSample = 16 then
|
||||
begin
|
||||
B16 := @FBuffer[0];
|
||||
for i := 0 to samples - 1 do FB[i] := B16[i];
|
||||
end else
|
||||
for i := 0 to samples - 1 do FB[i] := FBuffer[i];
|
||||
if not FLAC__seekable_stream_encoder_process_interleaved(_encoder, @FB[0], samples div FInput.Channels) then
|
||||
raise EACSException.Create('Failed to encode data.');
|
||||
FreeMem(FB);
|
||||
end;
|
||||
|
||||
procedure TFLACOut.SetEnableLooseMidSideStereo;
|
||||
begin
|
||||
if Val then FEnableMidSideStereo := True;
|
||||
FEnableLooseMidSideStereo := Val;
|
||||
end;
|
||||
|
||||
procedure TFLACOut.SetBestModelSearch;
|
||||
begin
|
||||
if Val then
|
||||
begin
|
||||
FEnableMidSideStereo := True;
|
||||
FEnableLooseMidSideStereo := False;
|
||||
end;
|
||||
FBestModelSearch := Val;
|
||||
end;
|
||||
|
||||
constructor TFLACIn.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
if not (csDesigning in ComponentState) then
|
||||
if not LibFLACLoaded then
|
||||
raise EACSException.Create(LibFLACPath + ' library could not be loaded.');
|
||||
end;
|
||||
|
||||
destructor TFLACIn.Destroy;
|
||||
begin
|
||||
CloseFile;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TFLACIn.OpenFile;
|
||||
begin
|
||||
Inc(FOpened);
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if (not FStreamAssigned) and (FFileName = '') then
|
||||
raise EACSException.Create('File name is not assigned');
|
||||
if not FStreamAssigned then FStream := TFileStream.Create(FFileName, fmOpenRead, fmShareDenyNone);
|
||||
FValid := True;
|
||||
_decoder := FLAC__seekable_stream_decoder_new;
|
||||
if _decoder = nil then
|
||||
raise EACSException.Create('Failed to initialize FLAC decoder.');
|
||||
// FLAC__seekable_stream_decoder_set_metadata_ignore_all(_decoder);
|
||||
FLAC__seekable_stream_decoder_set_read_callback(_decoder, DecReadCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_seek_callback(_decoder, DecSeekCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_tell_callback(_decoder, DecTellCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_length_callback(_decoder, DecLengthCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_eof_callback(_decoder, DecEOFCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_write_callback(_decoder, DecWriteCBFunc);
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback(_decoder, DecMetadataCBProc);
|
||||
FLAC__seekable_stream_decoder_set_error_callback(_decoder, DecErrorCBProc);
|
||||
FLAC__seekable_stream_decoder_set_client_data(_decoder, Self);
|
||||
if FLAC__seekable_stream_decoder_init(_decoder) <> FLAC__SEEKABLE_STREAM_DECODER_OK then
|
||||
raise EACSException.Create('Failed to initialize FLAC decoder.');
|
||||
if not FLAC__seekable_stream_decoder_process_until_end_of_metadata(_decoder) then
|
||||
FValid := False;
|
||||
EndOfStream := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFlacIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if _decoder <> nil then
|
||||
begin
|
||||
FLAC__seekable_stream_decoder_flush(_decoder);
|
||||
FLAC__seekable_stream_decoder_finish(_decoder);
|
||||
FLAC__seekable_stream_decoder_delete(_decoder);
|
||||
_decoder := nil;
|
||||
end;
|
||||
if Buff <> nil then FreeMem(Buff);
|
||||
Buff := nil;
|
||||
if not FStreamAssigned then FStream.Free
|
||||
else FStream.Seek(0, soFromBeginning);
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TFLACIn.GetData(Buffer : Pointer; BufferSize : Integer): Integer;
|
||||
var
|
||||
dec_state, offs : Integer;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart >= BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
offs := Round((FOffset/100)*Self.FTotalSamples);
|
||||
FPosition := FPosition + offs*(FBPS shr 3)*FChan;
|
||||
if FPosition < 0 then FPosition := 0
|
||||
else if FPosition > FSize then FPosition := FSize;
|
||||
Seek((FPosition div (FBPS shr 3)) div FChan);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 0;
|
||||
BufEnd := 0;
|
||||
if FPosition+MinFrameSize > FSize then EndOfStream := True;
|
||||
if EndOfStream then
|
||||
begin
|
||||
if FLoop then
|
||||
begin
|
||||
Flush;
|
||||
Init;
|
||||
end else
|
||||
begin
|
||||
Result := 0;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
if Buff <> nil then FreeMem(Buff);
|
||||
Buff := nil;
|
||||
if not FLAC__seekable_stream_decoder_process_single(_decoder) then
|
||||
begin
|
||||
dec_state := FLAC__seekable_stream_decoder_get_state(_decoder);
|
||||
if dec_state = FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Result := 0;
|
||||
Exit;
|
||||
end
|
||||
else raise EACSException.Create('Error reading FLAC file');
|
||||
end else BufEnd := Self.BytesPerBlock;
|
||||
end;
|
||||
if BufferSize < (BufEnd - BufStart)
|
||||
then Result := BufferSize
|
||||
else Result := BufEnd - BufStart;
|
||||
Move(Buff[BufStart], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
function TFLACIn.Seek(SampleNum : Integer) : Boolean;
|
||||
begin
|
||||
Result := FLAC__seekable_stream_decoder_seek_absolute(_decoder, Samplenum);
|
||||
end;
|
||||
|
||||
initialization
|
||||
FileFormats.Add('flac','Free Lossless Audio Codec',TFLACIn);
|
||||
FileFormats.Add('flac','Free Lossless Audio Codec',TFLACOut);
|
||||
|
||||
end.
|
350
acs/Src/fileformats/acs_lame.pas
Normal file
350
acs/Src/fileformats/acs_lame.pas
Normal file
@@ -0,0 +1,350 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_lame.pas,v $
|
||||
Revision 1.5 2006/07/04 17:12:45 z0m3ie
|
||||
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
|
||||
|
||||
Revision 1.2 2006/01/01 18:46:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.6 2005/12/18 17:01:54 z0m3ie
|
||||
delphi compatibility
|
||||
|
||||
Revision 1.5 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.4 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.3 2005/11/28 19:10:14 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit acs_lame;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_File,Classes, SysUtils, ACS_Classes, lame,
|
||||
{$IFDEF LINUX}
|
||||
baseunix;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
|
||||
TMP3Quality = (ql0, ql1, ql2, ql3, ql4, ql5,
|
||||
ql6, ql7, ql8, ql9);
|
||||
|
||||
TMP3Mode = (STEREO = 0,
|
||||
JOINT_STEREO,
|
||||
DUAL_CHANNEL, // LAME doesn't supports this!
|
||||
MONO);
|
||||
|
||||
TMP3SampleRate = (srDefault, sr32kHz, sr41kHz, sr48kHz);
|
||||
|
||||
TMP3BitRate = (br8, br16, br24, br32, br40, br48, br56, br64, br80, br96,
|
||||
br112, br128, br144, br160, br192, br224, br256, br320);
|
||||
|
||||
BOOL = Boolean;
|
||||
|
||||
TMP3Out = class(TACSCustomFileOut)
|
||||
private
|
||||
FBitRate : TMP3BitRate;
|
||||
_plgf : PLame_global_flags;
|
||||
mp3buf : PByte;
|
||||
mp3buf_size : Integer;
|
||||
FTitle : String;
|
||||
FArtist : String;
|
||||
FAlbum : String;
|
||||
FYear : String;
|
||||
FTrack : String;
|
||||
FComment : String;
|
||||
FGenre : String;
|
||||
FCopyright: BOOL;
|
||||
FOriginal: BOOL;
|
||||
FEnableVBR: BOOL;
|
||||
FWriteVBRHeader: BOOL;
|
||||
FCRC: BOOL;
|
||||
FVBRQuality: TMP3Quality;
|
||||
FVBRMinBitrate: integer;
|
||||
FVBRMaxBitrate: integer;
|
||||
FQuality: TMP3Quality;
|
||||
FMode: TMP3Mode;
|
||||
FSampleRate: TMP3SampleRate;
|
||||
protected
|
||||
procedure Done; override;
|
||||
function DoOutput(Abort : Boolean):Boolean; override;
|
||||
procedure Prepare; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property BitRate : TMP3BitRate read FBitRate write FBitRate stored True;
|
||||
property Id3TagTitle : String read FTitle write FTitle;
|
||||
property Id3TagArtist : String read FArtist write FArtist;
|
||||
property Id3TagAlbum : String read FAlbum write FAlbum;
|
||||
property Id3TagYear : String read FYear write FYear;
|
||||
property Id3TagTrack : String read FTrack write FTrack;
|
||||
property Id3TagComment : String read FComment write FComment;
|
||||
property Id3TagGenre : String read FGenre write FGenre;
|
||||
property Quality : TMP3Quality read FQuality write FQuality default ql5;
|
||||
|
||||
property SampleRate : TMP3SampleRate read FSampleRate write FSampleRate default srDefault;
|
||||
property Mode : TMP3Mode read FMode write FMode default STEREO;
|
||||
|
||||
//Extras
|
||||
property CRC : BOOL read FCRC write FCRC default false;
|
||||
property Copyright : BOOL read FCopyright write FCopyright default false;
|
||||
property Original : BOOL read FOriginal write FOriginal default true;
|
||||
|
||||
//VBR encoding
|
||||
property WriteVBRHeader : BOOL read FWriteVBRHeader write FWriteVBRHeader default false;
|
||||
property EnableVBR : BOOL read FEnableVBR write FEnableVBR default false;
|
||||
property VBRQuality : TMP3Quality read FVBRQuality write FVBRQuality default ql5;
|
||||
property VBRMinBitrate : integer read FVBRMinBitrate write FVBRMinBitrate default 128;
|
||||
property VBRMaxBitrate : integer read FVBRMaxBitrate write FVBRMaxBitrate default 192;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TMP3Out.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
LoadLAME;
|
||||
FBitRate := br128;
|
||||
|
||||
FBufferSize := $4000;
|
||||
FQuality := ql5;
|
||||
FSampleRate := srDefault;
|
||||
FMode := STEREO;
|
||||
FCRC := false;
|
||||
FCopyright := false;
|
||||
FOriginal := true;
|
||||
|
||||
FWriteVBRHeader := false;
|
||||
FEnableVBR := false;
|
||||
FVBRQuality := ql5;
|
||||
FVBRMinBitrate := 128;
|
||||
FVBRMaxBitrate := 192;
|
||||
|
||||
if not (csDesigning in ComponentState) then
|
||||
if not LameLoaded then
|
||||
raise EACSException.Create(LAME_PATH + ' library could not be loaded.');
|
||||
end;
|
||||
|
||||
destructor TMP3Out.Destroy;
|
||||
begin
|
||||
UnloadLAME;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMP3Out.Prepare;
|
||||
var
|
||||
samples, br, tbr, sr, ql : Integer;
|
||||
begin
|
||||
GetMem(FBuffer,FBufferSize);
|
||||
if not FStreamAssigned then
|
||||
begin
|
||||
if FFileName = '' then raise EACSException.Create('File name is not assigned.');
|
||||
FStream := TFileStream.Create(FFileName, fmCreate or fmShareExclusive, FAccessMask);
|
||||
end;
|
||||
FInput.Init;
|
||||
_plgf := lame_init;
|
||||
if FInput.Size > 0 then
|
||||
samples := FInput.Size div ((Finput.BitsPerSample shr 3)*Finput.Channels);
|
||||
lame_set_num_samples(_plgf, samples);
|
||||
lame_set_in_samplerate(_plgf, Finput.SampleRate);
|
||||
lame_set_num_channels(_plgf, 2); // not Finput.Channels see the note below
|
||||
case FBitRate of
|
||||
br8 : br := 8;
|
||||
br16 : br := 16;
|
||||
br24 : br := 24;
|
||||
br32 : br := 32;
|
||||
br40 : br := 40;
|
||||
br48 : br := 48;
|
||||
br56 : br := 56;
|
||||
br64 : br := 64;
|
||||
br80 : br := 80;
|
||||
br96 : br := 96;
|
||||
br112 : br := 112;
|
||||
br128 : br := 128;
|
||||
br144 : br := 144;
|
||||
br160 : br := 160;
|
||||
br192 : br := 192;
|
||||
br224 : br := 224;
|
||||
br256 : br := 256;
|
||||
br320 : br := 320;
|
||||
end;
|
||||
case FSampleRate of
|
||||
srDefault: sr := 0;
|
||||
sr32kHz: sr := 32000;
|
||||
sr41kHz: sr := 41000;
|
||||
sr48kHz: sr := 48000;
|
||||
end;
|
||||
lame_set_out_samplerate(_plgf,sr);
|
||||
{ lame_set_mode(_plgf, Integer(FMode));
|
||||
if FCopyright then
|
||||
lame_set_copyright(_plgf,1)
|
||||
else
|
||||
lame_set_copyright(_plgf,0);
|
||||
if FOriginal then
|
||||
lame_set_original(_plgf,1)
|
||||
else
|
||||
lame_set_original(_plgf,0);
|
||||
if FCRC then
|
||||
lame_set_error_protection(_plgf,1)
|
||||
else
|
||||
lame_set_error_protection(_plgf,0);
|
||||
|
||||
if not EnableVBR then
|
||||
begin
|
||||
lame_set_brate(_plgf, br);
|
||||
case FQuality of
|
||||
ql0: ql:=0;
|
||||
ql1: ql:=1;
|
||||
ql2: ql:=2;
|
||||
ql3: ql:=3;
|
||||
ql4: ql:=4;
|
||||
ql5: ql:=5;
|
||||
ql6: ql:=6;
|
||||
ql7: ql:=7;
|
||||
ql8: ql:=8;
|
||||
ql9: ql:=9;
|
||||
end;
|
||||
lame_set_quality(_plgf,ql);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if FWriteVBRHeader then
|
||||
lame_set_bWriteVbrTag(_plgf,1);
|
||||
lame_set_VBR(_plgf,2);
|
||||
case FVBRQuality of
|
||||
ql0: ql:=0;
|
||||
ql1: ql:=1;
|
||||
ql2: ql:=2;
|
||||
ql3: ql:=3;
|
||||
ql4: ql:=4;
|
||||
ql5: ql:=5;
|
||||
ql6: ql:=6;
|
||||
ql7: ql:=7;
|
||||
ql8: ql:=8;
|
||||
ql9: ql:=9;
|
||||
end;
|
||||
lame_set_VBR_q(_plgf,ql);
|
||||
if FVBRMinBitrate > FVBRMaxBitrate then
|
||||
begin
|
||||
tbr := FVBRMinBitrate;
|
||||
FVBRMinBitrate := FVBRMaxBitrate;
|
||||
FVBRMinBitrate := tbr;
|
||||
end;
|
||||
lame_set_VBR_min_bitrate_kbps(_plgf,FVBRMinBitrate);
|
||||
lame_set_VBR_max_bitrate_kbps(_plgf,FVBRMaxBitrate);
|
||||
end;
|
||||
}
|
||||
lame_init_params(_plgf);
|
||||
mp3buf_size := (FBufferSize shr 1) + (FBufferSize shr 3) + 7200;
|
||||
GetMem(mp3buf, mp3buf_size);
|
||||
end;
|
||||
|
||||
procedure TMP3Out.Done;
|
||||
var
|
||||
res : Integer;
|
||||
begin
|
||||
id3tag_init(_plgf);
|
||||
id3tag_set_title(_plgf, PChar(FTitle));
|
||||
id3tag_set_artist(_plgf, PChar(FArtist));
|
||||
id3tag_set_album(_plgf, PChar(FAlbum));
|
||||
id3tag_set_year(_plgf, PChar(FYear));
|
||||
id3tag_set_track(_plgf, PChar(FTrack));
|
||||
id3tag_set_comment(_plgf, PChar(FComment));
|
||||
id3tag_set_genre(_plgf, PChar(FGenre));
|
||||
res := lame_encode_flush(_plgf, mp3buf, mp3buf_size);
|
||||
FStream.Write(mp3buf^, res);
|
||||
if not FStreamAssigned then FStream.Free;
|
||||
lame_close(_plgf);
|
||||
FreeMem(mp3buf);
|
||||
FInput.Flush;
|
||||
FreeMem(FBuffer);
|
||||
end;
|
||||
|
||||
function TMP3Out.DoOutput(Abort : Boolean):Boolean;
|
||||
var
|
||||
Len, res, ns : Integer;
|
||||
begin
|
||||
// No exceptions Here
|
||||
Result := True;
|
||||
if not CanOutput then Exit;
|
||||
if Abort then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
while InputLock do;
|
||||
InputLock := True;
|
||||
Len := Finput.GetData(@FBuffer, FBufferSize);
|
||||
InputLock := False;
|
||||
if Len <> 0 then
|
||||
begin
|
||||
if FInput.Channels = 2 then
|
||||
begin
|
||||
ns := Len shr 2;
|
||||
res := lame_encode_buffer_interleaved(_plgf, @FBuffer, ns, mp3buf, mp3buf_size);
|
||||
end else
|
||||
begin
|
||||
(* If the input stream is mono we turn it into stereo here.
|
||||
This is the way to bypass some pour performance on mono streams,
|
||||
maybe not the best way, but for a while ...*)
|
||||
ns := Len shr 1;
|
||||
res := lame_encode_buffer(_plgf, @FBuffer, @FBuffer, ns, mp3buf, mp3buf_size);
|
||||
end;
|
||||
if res < 0 then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
FStream.Write(mp3buf^, res);
|
||||
end else
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
FileFormats.Add('mp3','Mpeg Layer III',TMP3Out);
|
||||
|
||||
|
||||
end.
|
475
acs/Src/fileformats/acs_mac.pas
Normal file
475
acs/Src/fileformats/acs_mac.pas
Normal file
@@ -0,0 +1,475 @@
|
||||
(*
|
||||
the original version of this file is written by thomas la cour,
|
||||
http://www.top-house.dk/~nr161/delphi/
|
||||
|
||||
This file is a part of Audio Components Suite v 2.4
|
||||
Copyright (c) 2002, 2003 Andrei Borovsky. All rights reserved.
|
||||
See the LICENSE file for more details.
|
||||
You can contact me at acs@compiler4.net
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_mac.pas,v $
|
||||
Revision 1.7 2006/07/04 17:12:45 z0m3ie
|
||||
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
|
||||
|
||||
Revision 1.3 2005/12/30 11:10:57 z0m3ie
|
||||
some corrections to lazarus-linux depending things
|
||||
|
||||
Revision 1.2 2005/12/26 17:31:39 z0m3ie
|
||||
fixed some problems in acs_dsfiles
|
||||
fixed some problems in acs_vorbis
|
||||
reworked all buffers
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.6 2005/12/18 17:01:54 z0m3ie
|
||||
delphi compatibility
|
||||
|
||||
Revision 1.5 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.4 2005/11/29 18:32:51 z0m3ie
|
||||
bugfixes for win32 version
|
||||
|
||||
Revision 1.3 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
}
|
||||
|
||||
unit acs_mac;
|
||||
|
||||
{$ifdef linux}{$message error 'unit not supported'}{$endif linux}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_File,Classes, SysUtils, Windows, ACS_Classes, MACDll;
|
||||
|
||||
type
|
||||
|
||||
// Note by A.B.: It seems that APE compressor supports file output only.
|
||||
|
||||
TMACOut = class(TACSCustomFileOut)
|
||||
private
|
||||
APECompress: TAPECompress;
|
||||
WaveFormatEx: TWaveFormatEx;
|
||||
EndOfStream: Boolean;
|
||||
FCompressionLevel: Integer;
|
||||
FMaxAudioBytes: Integer;
|
||||
procedure SetCompressionLevel(Value: Integer);
|
||||
protected
|
||||
procedure Done; override;
|
||||
function DoOutput(Abort: Boolean): Boolean; override;
|
||||
procedure Prepare; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property CompressionLevel: LongInt read FCompressionLevel write SetCompressionLevel stored True;
|
||||
property MaxAudioBytes: Integer read FMaxAudioBytes write FMaxAudioBytes;
|
||||
end;
|
||||
|
||||
(* Note by A.B.: Due to the reasons described above this component
|
||||
ignores streamed input *)
|
||||
|
||||
TMACIn = class(TACSCustomFileIn)
|
||||
private
|
||||
APEDecompress: TAPEDecompress;
|
||||
EndOfStream: Boolean;
|
||||
function GetAverageBitrate: Integer;
|
||||
function GetCurrentBitrate: Integer;
|
||||
function GetCurrentBlock: Integer;
|
||||
function GetCurrentMS: Integer;
|
||||
function GetLengthMS: Integer;
|
||||
function GetTotalBlocks: Integer;
|
||||
protected
|
||||
function GetBPS: Integer; override;
|
||||
function GetCh: Integer; override;
|
||||
function GetSR: Integer; override;
|
||||
function GetTotalTime: real; override;
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer: Pointer; BufferSize: Integer): Integer; override;
|
||||
|
||||
function Seek(Sample : Integer) : Boolean; override;
|
||||
|
||||
procedure Flush; override;
|
||||
procedure Init; override;
|
||||
|
||||
property AverageBitrate: Integer read GetAverageBitrate;
|
||||
property CurrentBitrate: Integer read GetCurrentBitrate;
|
||||
property CurrentBlock: Integer read GetCurrentBlock;
|
||||
property CurrentMS: Integer read GetCurrentMS;
|
||||
property LengthMS: Integer read GetLengthMS;
|
||||
property TotalBlocks: Integer read GetTotalBlocks;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TMACOut.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FBufferSize := $10000;
|
||||
FCompressionLevel := COMPRESSION_LEVEL_NORMAL;
|
||||
FMaxAudioBytes := MAX_AUDIO_BYTES_UNKNOWN;
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
if not MACLoaded then
|
||||
raise EACSException.Create(MACPath + ' library could not be loaded.');
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TMACOut.Destroy;
|
||||
begin
|
||||
if Assigned(APECompress) then
|
||||
APECompress.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMACOut.Prepare;
|
||||
var
|
||||
r: Integer;
|
||||
begin
|
||||
GetMem(FBuffer,FBufferSize);
|
||||
if FFileName = '' then raise EACSException.Create('File name is not assigned.');
|
||||
FInput.Init;
|
||||
EndOfStream := False;
|
||||
|
||||
APECompress := TAPECompress.Create;
|
||||
|
||||
macFillWaveFormatEx(WaveFormatEx, FInput.SampleRate, FInput.BitsPerSample, FInput.Channels);
|
||||
|
||||
r := APECompress.Start(
|
||||
PChar(FFileName),
|
||||
@WaveFormatEx,
|
||||
FMaxAudioBytes,
|
||||
FCompressionLevel,
|
||||
nil,
|
||||
CREATE_WAV_HEADER_ON_DECOMPRESSION);
|
||||
|
||||
CanOutput := (r = 0);
|
||||
|
||||
if r <> 0 then
|
||||
raise EACSException.Create('Error starting APECompress.' + #13#10 +
|
||||
macErrorExplanation(r));
|
||||
end;
|
||||
|
||||
procedure TMACOut.Done;
|
||||
begin
|
||||
APECompress.Finish(nil, 0, 0);
|
||||
APECompress.Free;
|
||||
APECompress := nil;
|
||||
FInput.Flush;
|
||||
FreeMem(FBuffer);
|
||||
end;
|
||||
|
||||
function TMACOut.DoOutput(Abort: Boolean): Boolean;
|
||||
var
|
||||
Len, i, x, z: Integer;
|
||||
pBuffer: PByteArray;
|
||||
nAudioBytesLeft, nBufferBytesAvailable, nNoiseBytes, nRetVal: Integer;
|
||||
begin
|
||||
// No exceptions Here
|
||||
Result := True;
|
||||
if not CanOutput then Exit;
|
||||
if Abort or EndOfStream then
|
||||
begin
|
||||
(* We don't close file here to avoide exceptions
|
||||
if output componenet's Stop method is called *)
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
Len := Finput.GetData(@FBuffer[0], FBufferSize);
|
||||
x := 0;
|
||||
if Len <> 0 then
|
||||
begin
|
||||
nAudioBytesLeft := Len;
|
||||
while (nAudioBytesLeft > 0) do
|
||||
begin
|
||||
nBufferBytesAvailable := 0;
|
||||
pBuffer := APECompress.LockBuffer(nBufferBytesAvailable);
|
||||
|
||||
nNoiseBytes := nBufferBytesAvailable;
|
||||
if nNoiseBytes > nAudioBytesLeft then
|
||||
nNoiseBytes := nAudioBytesLeft;
|
||||
|
||||
//whats this ? schoult System.Move not be faster ?
|
||||
for z := 0 to nNoiseBytes - 1 do
|
||||
begin
|
||||
pBuffer[z] := FBuffer[x];
|
||||
inc(x);
|
||||
end;
|
||||
|
||||
nRetVal := APECompress.UnlockBuffer(nNoiseBytes, TRUE);
|
||||
if (nRetVal <> 0) then
|
||||
raise EACSException.Create('APECompress.UnlockBuffer Error: ' + inttostr(nRetVal));
|
||||
|
||||
dec(nAudioBytesLeft, nNoiseBytes);
|
||||
end
|
||||
end
|
||||
else
|
||||
EndOfStream := True;
|
||||
end;
|
||||
|
||||
|
||||
constructor TMACIn.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
BufferSize := $2000;
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
if not MACLoaded then
|
||||
raise EACSException.Create(MACPath + ' library could not be loaded.');
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TMACIn.Destroy;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
APEDecompress.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMACIn.OpenFile;
|
||||
begin
|
||||
FValid := True;
|
||||
if FOpened = 0 then
|
||||
begin
|
||||
EndOfStream := False;
|
||||
|
||||
APEDecompress := TAPEDecompress.Create(FileName);
|
||||
if APEDecompress.Handle <> 0 then
|
||||
begin
|
||||
FSize := APEDecompress.InfoWavTotalBytes;
|
||||
FSR := APEDecompress.InfoSampleRate;
|
||||
FBPS := APEDecompress.InfoBitsPerSample;
|
||||
FChan := APEDecompress.InfoChannels;
|
||||
FTime := APEDecompress.InfoLengthMS div 1000; // Round(ov_time_total(VFile, 0));
|
||||
FTotalSamples := (FSize div (FBPS shr 3)) div FChan;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FValid := False;
|
||||
FOpened := -1;
|
||||
end;
|
||||
end;
|
||||
Inc(FOpened);
|
||||
end;
|
||||
|
||||
procedure TMACIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
APEDecompress.Free;
|
||||
APEDecompress := nil;
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TMACIn.GetData(Buffer: Pointer; BufferSize: Integer): Integer;
|
||||
var
|
||||
l, csize, offs: Integer;
|
||||
blocks: Integer;
|
||||
tmp: Double;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart > BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
offs := Round((FOffset / 100) * FSize);
|
||||
FPosition := FPosition + offs;
|
||||
if FPosition < 0 then FPosition := 0
|
||||
else if FPosition > FSize then FPosition := FSize;
|
||||
APEDecompress.Seek(FPosition shr 2);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 1;
|
||||
BufEnd := 0;
|
||||
if not EndOfStream then
|
||||
begin
|
||||
while BufEnd < BufferSize do
|
||||
begin
|
||||
//l := ov_read(VFile, @buf[BufEnd + 1], BUF_SIZE - BufEnd, 0, 2, 1, @cursec);
|
||||
blocks := (BufferSize - BufEnd) div 4;
|
||||
APEDecompress.GetData(@FBuffer[BufEnd], blocks, l);
|
||||
l := l * 4;
|
||||
if l <= 0 then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
Inc(BufEnd, l);
|
||||
if (FEndSample <> -1) then
|
||||
begin
|
||||
csize := (FEndSample-FStartSample)*(FBPS shr 3)*FChan;
|
||||
if (csize - FPosition) <= 0 then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
if (csize - FPosition) < BufEnd then
|
||||
begin
|
||||
BufEnd := csize - FPosition;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if EndOfStream and FLoop then
|
||||
begin
|
||||
Flush;
|
||||
Init;
|
||||
EndOfStream := False;
|
||||
while BufEnd < BufferSize do
|
||||
begin
|
||||
//l := ov_read(VFile, @buf[BufEnd + 1], BUF_SIZE - BufEnd, 0, 2, 1, @cursec);
|
||||
blocks := (BufferSize - BufEnd) div 4;
|
||||
APEDecompress.GetData(@FBuffer[BufEnd], blocks, l);
|
||||
l := l * 4;
|
||||
if l <= 0 then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
Inc(BufEnd, l);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if BufferSize < (BufEnd - BufStart + 1) then
|
||||
Result := BufferSize
|
||||
else
|
||||
Result := BufEnd - BufStart + 1;
|
||||
Move(FBuffer[BufStart - 1], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
function TMACIn.GetTotalTime: real;
|
||||
begin
|
||||
OpenFile;
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.LengthMS / 1000;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TMACIn.GetAverageBitrate: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.AverageBitrate;
|
||||
end;
|
||||
|
||||
function TMACIn.GetCurrentBitrate: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.CurrentBitrate;
|
||||
end;
|
||||
|
||||
function TMACIn.GetCurrentBlock: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.CurrentBlock;
|
||||
end;
|
||||
|
||||
function TMACIn.GetCurrentMS: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.CurrentMS;
|
||||
end;
|
||||
|
||||
function TMACIn.GetLengthMS: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.LengthMS;
|
||||
end;
|
||||
|
||||
function TMACIn.GetTotalBlocks: Integer;
|
||||
begin
|
||||
if Assigned(APEDecompress) then
|
||||
Result := APEDecompress.TotalBlocks;
|
||||
end;
|
||||
|
||||
function TMACIn.GetBPS: Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FBPS;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TMACIn.GetCh: Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FChan;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TMACIn.GetSR: Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FSR;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
procedure TMACOut.SetCompressionLevel(Value: Integer);
|
||||
begin
|
||||
case Value of
|
||||
COMPRESSION_LEVEL_FAST,
|
||||
COMPRESSION_LEVEL_NORMAL,
|
||||
COMPRESSION_LEVEL_HIGH,
|
||||
COMPRESSION_LEVEL_EXTRA_HIGH: FCompressionLevel := Value;
|
||||
else
|
||||
FCompressionLevel := COMPRESSION_LEVEL_NORMAL;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMACIn.Flush;
|
||||
begin
|
||||
inherited Flush;
|
||||
end;
|
||||
|
||||
procedure TMACIn.Init;
|
||||
begin
|
||||
inherited Init;
|
||||
BufStart := 1;
|
||||
BufEnd := 0;
|
||||
end;
|
||||
|
||||
function TMACIn.Seek(Sample : Integer) : Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
if not FSeekable then Exit;
|
||||
Result := True;
|
||||
OpenFile;
|
||||
APEDecompress.Seek(Sample);
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
FileFormats.Add('mac','Monkey Audio',TMACOut);
|
||||
FileFormats.Add('mac','Monkey Audio',TMACIn);
|
||||
|
||||
|
||||
end.
|
||||
|
242
acs/Src/fileformats/acs_mad.pas
Normal file
242
acs/Src/fileformats/acs_mad.pas
Normal file
@@ -0,0 +1,242 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_mad.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.3 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit acs_mad;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_Types, Classes, SysUtils, Math, MAD;
|
||||
|
||||
type
|
||||
|
||||
TRawPCMWaveHeader = record
|
||||
RIFF: array [0..3] of Char;
|
||||
FileSize: Integer;
|
||||
RIFFType: array [0..3] of Char;
|
||||
FmtChunkId: array [0..3] of Char;
|
||||
FmtChunkSize: Integer;
|
||||
FormatTag: Word;
|
||||
Channels: Word;
|
||||
SampleRate: Integer;
|
||||
BytesPerSecond: Integer;
|
||||
BlockAlign: Word;
|
||||
BitsPerSample: Word;
|
||||
DataChunkId: array [0..3] of Char;
|
||||
DataSize: Integer;
|
||||
end;
|
||||
|
||||
TMADProgressEvent = procedure(Sender : TComponent) of object;
|
||||
TMADDoneEvent = procedure(Sender : TComponent; Success : Boolean) of object;
|
||||
|
||||
TMADThread = class(TThread)
|
||||
private
|
||||
_Free : Boolean;
|
||||
Progr : Integer;
|
||||
Owner : TComponent;
|
||||
FDecoder : mad_decoder;
|
||||
FInputStream : TStream;
|
||||
FOutputStream : TStream;
|
||||
HasFirstFrame : Boolean;
|
||||
FSR : Integer;
|
||||
FChan : Integer;
|
||||
FBitrate : Integer;
|
||||
FValid : Boolean;
|
||||
Data : PACSBuffer8;
|
||||
InputDone : Boolean;
|
||||
WaveHdr : TRawPCMWaveHeader;
|
||||
FSize : Integer;
|
||||
FMADProgress : TMADProgressEvent;
|
||||
FMADDone : TMADDoneEvent;
|
||||
WhenDone : procedure of object;
|
||||
protected
|
||||
procedure Execute; override;
|
||||
public
|
||||
constructor Create(AOwner : TComponent; InputStream, OutputStream : TStream);
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
function InputFunc(CData : Pointer; Stream : p_mad_stream) : Integer; cdecl;
|
||||
var
|
||||
MT : TMADThread;
|
||||
Len : Integer;
|
||||
begin
|
||||
|
||||
MT := TMADThread(CData);
|
||||
|
||||
if MT.InputDone then
|
||||
begin
|
||||
Result := MAD_FLOW_STOP;
|
||||
Exit;
|
||||
end;
|
||||
MT.InputDone := True;
|
||||
// Len := MT.FInputStream.Read(Data^, MT.FInputStream.Size);
|
||||
Len := MT.FInputStream.Size;
|
||||
mad_stream_buffer(Stream, MT.Data, Len);
|
||||
if not MT.Terminated then Result := MAD_FLOW_CONTINUE
|
||||
else Result := MAD_FLOW_STOP;
|
||||
end;
|
||||
|
||||
function OutputFunc(CData : Pointer; Header : p_mad_header; pcm : p_mad_pcm) : Integer; cdecl;
|
||||
var
|
||||
MT : TMADThread;
|
||||
i, framesize : Integer;
|
||||
outsamples : array[0..2303] of SmallInt;
|
||||
text : array[0..4] of Char;
|
||||
CProgr : Integer;
|
||||
begin
|
||||
MT := TMADThread(CData);
|
||||
if not MT.HasFirstFrame then
|
||||
begin
|
||||
MT.FSR := pcm.samplerate;
|
||||
MT.FChan := pcm.channels;
|
||||
MT.FBitrate := Header.bitrate;
|
||||
framesize := Ceil(144*MT.FBitrate/MT.FSR);
|
||||
MT.FSize := Round(MT.FInputStream.Size/framesize*1152)*MT.FChan*2;
|
||||
MT.FValid := True;
|
||||
text := 'RIFF';
|
||||
Move(text[0], MT.WaveHdr.RIFF[0], 4);
|
||||
MT.WaveHdr.FileSize := MT.FSize + 44;
|
||||
text := 'WAVE';
|
||||
Move(text[0], MT.WaveHdr.RIFFType[0], 4);
|
||||
text := 'fmt ';
|
||||
Move(text[0], MT.WaveHdr.FmtChunkId[0], 4);
|
||||
MT.WaveHdr.FmtChunkSize := 16;
|
||||
MT.WaveHdr.FormatTag := 1;
|
||||
MT.WaveHdr.Channels := MT.FChan;
|
||||
MT.WaveHdr.SampleRate := MT.FSR;
|
||||
MT.WaveHdr.BitsPerSample := 16;
|
||||
MT.WaveHdr.BlockAlign := 2*MT.FChan;
|
||||
MT.WaveHdr.BytesPerSecond := MT.FSR * MT.WaveHdr.BlockAlign;
|
||||
text := 'data';
|
||||
Move(text[0], MT.WaveHdr.DataChunkId[0], 4);
|
||||
MT.WaveHdr.DataSize := MT.FSize;
|
||||
if MT.FOutputStream is TMemoryStream then
|
||||
begin
|
||||
MT.FOutputStream.Size :=MT.FSize + 44;
|
||||
MT.FOutputStream.Seek(0, soFromBeginning);
|
||||
end;
|
||||
MT.FOutputStream.Write(MT.WaveHdr, 44);
|
||||
MT.HasFirstFrame := True;
|
||||
end;
|
||||
if pcm.channels = 2 then
|
||||
begin
|
||||
for i := 0 to pcm.length -1 do
|
||||
begin
|
||||
if pcm.samples[0][i] >= MAD_F_ONE then
|
||||
pcm.samples[0][i] := MAD_F_ONE - 1;
|
||||
if pcm.samples[0][i] < -MAD_F_ONE then
|
||||
pcm.samples[0][i] := -MAD_F_ONE;
|
||||
pcm.samples[0][i] := pcm.samples[0][i] shr (MAD_F_FRACBITS + 1 - 16);
|
||||
outsamples[i shl 1] := pcm.samples[0][i];
|
||||
if pcm.samples[1][i] >= MAD_F_ONE then
|
||||
pcm.samples[1][i] := MAD_F_ONE - 1;
|
||||
if pcm.samples[1][i] < -MAD_F_ONE then
|
||||
pcm.samples[1][i] := -MAD_F_ONE;
|
||||
pcm.samples[1][i] := pcm.samples[1][i] shr (MAD_F_FRACBITS + 1 - 16);
|
||||
outsamples[(i shl 1)+1] := pcm.samples[1][i];
|
||||
end;
|
||||
MT.FOutputStream.Write(outsamples[0], pcm.length*4);
|
||||
end else
|
||||
begin
|
||||
for i := 0 to pcm.length -1 do
|
||||
begin
|
||||
if pcm.samples[0][i] >= MAD_F_ONE then
|
||||
pcm.samples[0][i] := MAD_F_ONE - 1;
|
||||
if pcm.samples[0][i] < -MAD_F_ONE then
|
||||
pcm.samples[0][i] := -MAD_F_ONE;
|
||||
pcm.samples[0][i] := pcm.samples[0][i] shr (MAD_F_FRACBITS + 1 - 16);
|
||||
outsamples[i] := pcm.samples[0][i];
|
||||
end;
|
||||
MT.FOutputStream.Write(outsamples[0], pcm.length*2);
|
||||
end;
|
||||
if MT.FSize <> 0 then
|
||||
begin
|
||||
CProgr := Round(MT.FOutputStream.Position/MT.FSize*100);
|
||||
if MT.Progr <> CProgr then
|
||||
begin
|
||||
MT.Progr := CProgr;
|
||||
if Assigned(MT.FMADProgress) then
|
||||
MT.FMADProgress(MT.Owner);
|
||||
end;
|
||||
end;
|
||||
if not MT.Terminated then Result := MAD_FLOW_CONTINUE
|
||||
else Result := MAD_FLOW_STOP;
|
||||
end;
|
||||
|
||||
function ErrorFunc(CData : Pointer; Stream : p_mad_stream; Frame : p_mad_frame) : Integer; cdecl;
|
||||
begin
|
||||
Result := MAD_FLOW_CONTINUE;
|
||||
end;
|
||||
|
||||
constructor TMADThread.Create;
|
||||
begin
|
||||
inherited Create(True);
|
||||
Owner := AOwner;
|
||||
FInputStream := InputStream;
|
||||
FOutputStream := OutputStream;
|
||||
FreeOnTerminate := False;
|
||||
end;
|
||||
|
||||
destructor TMADThread.Destroy;
|
||||
begin
|
||||
if not _Free then
|
||||
begin
|
||||
Terminate;
|
||||
{$IFDEF WIN32}
|
||||
while not _Free do;
|
||||
{$ENDIF}
|
||||
end;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMADThread.Execute;
|
||||
begin
|
||||
try
|
||||
GetMem(Data, FInputStream.Size);
|
||||
FInputStream.Read(Data[0], FInputStream.Size);
|
||||
mad_decoder_init(@FDecoder, Self, InputFunc, nil, nil, OutputFunc, ErrorFunc, nil);
|
||||
mad_decoder_run(@FDecoder, MAD_DECODER_MODE_SYNC);
|
||||
mad_decoder_finish(@FDecoder);
|
||||
FreeMem(Data);
|
||||
WhenDone;
|
||||
if Assigned(FMADDone) then FMADDone(Owner, FValid);
|
||||
_Free := True;
|
||||
except
|
||||
FreeMem(Data);
|
||||
WhenDone;
|
||||
_Free := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
153
acs/Src/fileformats/acs_mpeg.pas
Normal file
153
acs/Src/fileformats/acs_mpeg.pas
Normal file
@@ -0,0 +1,153 @@
|
||||
unit acs_mpeg;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,ACS_file,ACS_classes, smpeg;
|
||||
|
||||
type
|
||||
TMPEGIn = class(TACSCustomFileIn)
|
||||
private
|
||||
_M : Pointer;
|
||||
protected
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
|
||||
procedure Init; override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
constructor TMPEGIn.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
BufferSize := $2000;
|
||||
end;
|
||||
|
||||
destructor TMPEGIn.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMPEGIn.Init;
|
||||
begin
|
||||
inherited Init;
|
||||
SMPEG_play(_M);
|
||||
end;
|
||||
|
||||
procedure TMPEGIn.OpenFile;
|
||||
var
|
||||
info : SMPEG_info;
|
||||
spec : SDL_AudioSpec;
|
||||
begin
|
||||
if FOpened = 0 then
|
||||
begin
|
||||
(* the next call is needed just to make sure
|
||||
the SDL library is loaded *)
|
||||
_M := SMPEG_new(PChar(FFileName), info, 1);
|
||||
SMPEG_delete(_M);
|
||||
FValid := True;
|
||||
_M := SMPEG_new(PChar(FFileName), info, 0);
|
||||
if info.has_audio <> 1 then
|
||||
begin
|
||||
FValid := False;
|
||||
Exit;
|
||||
end;
|
||||
FTime := Round(info.total_time);
|
||||
SMPEG_wantedSpec(_M, spec);
|
||||
FSR := spec.freq;
|
||||
FBPS := 16;
|
||||
FChan := spec.channels;
|
||||
FSize := FTime*2*FChan*FSR;
|
||||
end;
|
||||
Inc(FOpened);
|
||||
end;
|
||||
|
||||
procedure TMPEGIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if SMPEG_status(_M) = SMPEG_PLAYING then
|
||||
SMPEG_stop(_M);
|
||||
SMPEG_delete(_M);
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TMPEGIn.GetData(Buffer : Pointer; BufferSize : Integer): Integer;
|
||||
var
|
||||
l, offs : Integer;
|
||||
tmp : Single;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart > BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
offs := Round((FOffset/100)*FSize);
|
||||
FPosition := FPosition + offs;
|
||||
if FPosition < 0 then FPosition := 0
|
||||
else if FPosition > FSize then FPosition := FSize;
|
||||
if FOffset < 0 then
|
||||
begin
|
||||
SMPEG_rewind(_M);
|
||||
SMPEG_play(_M);
|
||||
tmp := (FPosition/FSize)*FTime;
|
||||
SMPEG_skip(_M, tmp);
|
||||
end;
|
||||
tmp := (FOffset/100)*FTime;
|
||||
SMPEG_skip(_M, tmp);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 1;
|
||||
FillChar(FBuffer, BufferSize, 0);
|
||||
l := Buffersize;
|
||||
l := SMPEG_playAudio(_M, @FBuffer[BufEnd + 1], BufferSize - BufEnd);
|
||||
if l = 0 then
|
||||
begin
|
||||
if FLoop then
|
||||
begin
|
||||
Flush;
|
||||
Init;
|
||||
SMPEG_rewind(_M);
|
||||
SMPEG_play(_M);
|
||||
FPosition := 0;
|
||||
l := SMPEG_playAudio(_M, @FBuffer[BufEnd + 1], BufferSize - BufEnd);
|
||||
end else
|
||||
begin
|
||||
Result := 0;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
BufEnd := l;
|
||||
end;
|
||||
if BufferSize < (BufEnd - BufStart + 1)
|
||||
then Result := BufferSize
|
||||
else Result := BufEnd - BufStart + 1;
|
||||
Move(FBuffer[BufStart], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
initialization
|
||||
LoadMPEGLibrary;
|
||||
if LibsmpegLoaded then
|
||||
begin
|
||||
FileFormats.Add('mp3','Mpeg Audio Layer III',TMPEGIn);
|
||||
FileFormats.Add('mp2','Mpeg Audio Layer II',TMPEGIn);
|
||||
FileFormats.Add('mpeg','Mpeg Audio',TMPEGIn);
|
||||
end;
|
||||
|
||||
finalization
|
||||
UnLoadMPEGLibrary;
|
||||
|
||||
end.
|
||||
|
673
acs/Src/fileformats/acs_vorbis.pas
Normal file
673
acs/Src/fileformats/acs_vorbis.pas
Normal file
@@ -0,0 +1,673 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: acs_vorbis.pas,v $
|
||||
Revision 1.8 2006/07/04 17:12:45 z0m3ie
|
||||
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
|
||||
|
||||
Revision 1.4 2006/01/01 18:46:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.3 2005/12/29 20:45:59 z0m3ie
|
||||
fixed some problems with vorbis in lazarus
|
||||
|
||||
Revision 1.2 2005/12/26 17:31:39 z0m3ie
|
||||
fixed some problems in acs_dsfiles
|
||||
fixed some problems in acs_vorbis
|
||||
reworked all buffers
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:38 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.5 2005/12/04 16:54:34 z0m3ie
|
||||
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
|
||||
|
||||
Revision 1.4 2005/11/28 21:57:24 z0m3ie
|
||||
mostly FileOut fixes
|
||||
moved PBuffer to PBuffer8
|
||||
set all to dynamically Buffering
|
||||
|
||||
Revision 1.3 2005/10/02 16:51:01 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/09/13 04:04:50 z0m3ie
|
||||
First release without Components for Fileformats
|
||||
only TFileIn and TFileOut are Visible
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:52 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.3 2005/09/10 08:25:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit acs_vorbis;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
{$DEFINE USE_VORBIS_11}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
ACS_File,Classes, SysUtils, ACS_Classes, ogg, vorbiscodec, VorbisFile, VorbisEnc,ACS_Strings
|
||||
{$IFDEF LINUX}
|
||||
,baseunix;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
,Windows,Dialogs;
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
|
||||
TVorbisBitRate = (brAutoSelect, br45, br48, br56, br64, br80, br96,
|
||||
br112, br128, br144, br160, br192, br224, br256, br320, br499);
|
||||
|
||||
TVorbisOut = class(TACSCustomFileOut)
|
||||
private
|
||||
FComments : TStringList;
|
||||
FSerial : Integer;
|
||||
FDesiredNominalBitrate : TVorbisBitRate;
|
||||
FDesiredMaximumBitrate : TVorbisBitRate;
|
||||
FMinimumBitrate : TVorbisBitRate;
|
||||
OggSS : ogg_stream_state;
|
||||
OggPg : ogg_page;
|
||||
OggPk : ogg_packet;
|
||||
VInfo : vorbis_info;
|
||||
VComm : vorbis_comment;
|
||||
Vdsp : vorbis_dsp_state;
|
||||
VBlock : vorbis_block;
|
||||
header, header_comm, header_code : ogg_packet;
|
||||
FCompression : Single;
|
||||
EndOfStream : Boolean;
|
||||
procedure SetComments(vComments : TStringList);
|
||||
procedure SetDesiredNominalBitrate(Value : TVorbisBitRate);
|
||||
procedure SetDesiredMaximumBitrate(Value : TVorbisBitRate);
|
||||
procedure SetMinimumBitrate(Value : TVorbisBitRate);
|
||||
protected
|
||||
procedure Done; override;
|
||||
function DoOutput(Abort : Boolean):Boolean; override;
|
||||
procedure Prepare; override;
|
||||
procedure SetFileMode(aMode : TACSFileOutputMode); override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property Compression : Single read FCompression write FCompression stored True;
|
||||
property Comments : TStringList read FComments write SetComments stored True;
|
||||
property DesiredMaximumBitrate : TVorbisBitRate read FDesiredMaximumBitrate write SetDesiredMaximumBitrate;
|
||||
property DesiredNominalBitrate : TVorbisBitRate read FDesiredNominalBitrate write SetDesiredNominalBitrate;
|
||||
property MinimumBitrate : TVorbisBitRate read FMinimumBitrate write SetMinimumBitrate;
|
||||
property Serial : Integer read FSerial write FSerial;
|
||||
//property Vendor : String read FVendor write FVendor;
|
||||
end;
|
||||
|
||||
TVorbisIn = class(TACSCustomFileIn)
|
||||
private
|
||||
FComments : TStringList;
|
||||
// FVendor : String;
|
||||
VFile : OggVorbis_File;
|
||||
cursec : Integer;
|
||||
FMaxBitrate: Integer;
|
||||
FNominalBitrate: Integer;
|
||||
FMinBitrate : Integer;
|
||||
EndOfStream : Boolean;
|
||||
function GetMaxBitrate: Integer;
|
||||
function GetNominalBitrate: Integer;
|
||||
function GetMinBitrate : Integer;
|
||||
function GetComments : TStringList;
|
||||
function GetBitStreams : Integer;
|
||||
function GetInstantBitRate : Integer;
|
||||
function GetCurrentBitStream : Integer;
|
||||
procedure SetCurrentBitStream(BS : Integer);
|
||||
protected
|
||||
procedure OpenFile; override;
|
||||
procedure CloseFile; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
|
||||
function Seek(SampleNum : Integer) : Boolean; override;
|
||||
property BitStreams : Integer read GetBitStreams;
|
||||
property Comments : TStringList read GetComments;
|
||||
property CurrentBitStream : Integer read GetCurrentBitStream write SetCurrentBitStream;
|
||||
property InstantBitRate : Integer read GetInstantBitRate;
|
||||
//property Vendor : String read FVendor;
|
||||
property MaxBitrate: Integer read GetMaxBitrate;
|
||||
property MinBitrate: Integer read GetMinBitrate;
|
||||
property NominalBitrate: Integer read GetNominalBitrate;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
function cbRead(ptr : Pointer; size, nmemb : Cardinal;const datasource : Pointer) : Cardinal; cdecl;
|
||||
var
|
||||
VI : TVorbisIn;
|
||||
Buffer : array of Byte;
|
||||
begin
|
||||
VI := TVorbisIn(datasource);
|
||||
SetLength(Buffer, size*nmemb);
|
||||
Result := VI.FStream.Read(Buffer[0], size*nmemb);
|
||||
Move(Buffer[0], ptr^, Result);
|
||||
Setlength(Buffer,0);
|
||||
Buffer := nil;
|
||||
end;
|
||||
|
||||
function cbSeek(const datasource : Pointer; offset : ogg_int64_t; whence : Integer) : Integer; cdecl;
|
||||
var
|
||||
VI : TVorbisIn;
|
||||
Origin : TSeekOrigin;
|
||||
begin
|
||||
VI := TVorbisIn(datasource);
|
||||
if not VI.Seekable then
|
||||
begin
|
||||
Result := -1;
|
||||
Exit;
|
||||
end;
|
||||
case whence of
|
||||
SEEK_SET : Origin := TSeekOrigin(soFromBeginning);
|
||||
SEEK_CUR : Origin := TSeekOrigin(soFromCurrent);
|
||||
SEEK_END : Origin := TSeekOrigin(soFromEnd);
|
||||
end;
|
||||
Result := VI.FStream.Seek(offset, Origin);
|
||||
end;
|
||||
|
||||
function cbClose(const datasource : Pointer) : Integer; cdecl;
|
||||
var
|
||||
VI : TVorbisIn;
|
||||
begin
|
||||
VI := TVorbisIn(datasource);
|
||||
if not VI.FStreamAssigned then VI.FStream.Free
|
||||
else VI.FStream.Seek(0, soFromBeginning);
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function cbTell(const datasource : Pointer) : Integer; cdecl;
|
||||
var
|
||||
VI : TVorbisIn;
|
||||
begin
|
||||
VI := TVorbisIn(datasource);
|
||||
Result := VI.FStream.Position
|
||||
end;
|
||||
|
||||
function VorbisBitrateToInt(Bitrate : TVorbisBitrate) : Integer;
|
||||
begin
|
||||
case Bitrate of
|
||||
br45 : Result := 45000;
|
||||
br48 : Result := 48000;
|
||||
br56 : Result := 46000;
|
||||
br64 : Result := 64000;
|
||||
br80 : Result := 80000;
|
||||
br96 : Result := 96000;
|
||||
br112 : Result := 112000;
|
||||
br128 : Result := 128000;
|
||||
br144 : Result := 144000;
|
||||
br160 : Result := 160000;
|
||||
br192 : Result := 192000;
|
||||
br224 : Result := 224000;
|
||||
br256 : Result := 256000;
|
||||
br320 : Result := 320000;
|
||||
br499 : Result := 499000;
|
||||
else Result := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TVorbisOut.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FBufferSize := $10000;
|
||||
VORBISLoadLibrary;
|
||||
FCompression := 0.2;
|
||||
FComments := TStringList.Create;
|
||||
FDesiredNominalBitrate := br64;
|
||||
FDesiredMaximumBitrate := br112;
|
||||
FMinimumBitrate := br48;
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
VORBISLoadLibrary;
|
||||
if not LiboggLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[Liboggpath]));
|
||||
if not LibvorbisLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisPath]));
|
||||
if not LibvorbisfileLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisfilePath]));
|
||||
//if not LibvorbisencLoaded then
|
||||
//raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisencPath]));
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TVorbisOut.Destroy;
|
||||
begin
|
||||
FComments.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.SetComments;
|
||||
begin
|
||||
FComments.Assign(vComments);
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.Prepare;
|
||||
var
|
||||
i, maxbr, minbr, nombr : Integer;
|
||||
Name, Value : String;
|
||||
rm : ovectl_ratemanage2_arg;
|
||||
begin
|
||||
GetMem(FBuffer,FBufferSize);
|
||||
if not FStreamAssigned then
|
||||
begin
|
||||
if not Assigned(FInput) then
|
||||
raise EACSException.Create(strInputNotAssigned);
|
||||
if FFileName = '' then raise EACSException.Create(strNoFileOpened);
|
||||
if (not FileExists(FFileName)) or (FFileMode = foRewrite) then
|
||||
FStream := TFileStream.Create(FFileName, fmCreate or fmShareExclusive, FAccessMask)
|
||||
else FStream := TFileStream.Create(FFileName, fmOpenReadWrite or fmShareExclusive, FAccessMask);
|
||||
end;
|
||||
FInput.Init;
|
||||
if FFileMode = foAppend then
|
||||
FStream.Seek(0, soFromEnd);
|
||||
EndOfStream := False;
|
||||
vorbis_info_init(VInfo);
|
||||
if DesiredNominalBitrate = brAutoSelect then
|
||||
begin
|
||||
{$IFNDEF USE_VORBIS_11}
|
||||
vorbis_encode_init_vbr(VInfo, FInput.Channels, FInput.SampleRate, FCompression);
|
||||
{$ENDIF}
|
||||
{$IFDEF USE_VORBIS_11}
|
||||
vorbis_encode_setup_vbr(VInfo, FInput.Channels, FInput.SampleRate, FCompression);
|
||||
vorbis_encode_setup_init(VInfo);
|
||||
{$ENDIF}
|
||||
end else
|
||||
begin
|
||||
nombr := VorbisBitrateToInt(FDesiredNominalBitrate);
|
||||
maxbr := VorbisBitrateToInt(FDesiredMaximumBitrate);
|
||||
if maxbr < nombr then maxbr := nombr;
|
||||
minbr := VorbisBitrateToInt(Self.FMinimumBitrate);
|
||||
if minbr < 0 then minbr := nombr;
|
||||
vorbis_encode_init(VInfo, FInput.Channels, FInput.SampleRate, maxbr, nombr, minbr);
|
||||
end;
|
||||
vorbis_comment_init(VComm);
|
||||
for i := 0 to FComments.Count - 1 do
|
||||
begin
|
||||
Name := FComments.Names[i];
|
||||
Value := FComments.Values[Name];
|
||||
vorbis_comment_add_tag(VComm, PChar(Name), PChar(Value));
|
||||
end;
|
||||
vorbis_analysis_init(Vdsp, VInfo);
|
||||
vorbis_block_init(Vdsp, VBlock);
|
||||
ogg_stream_init(OggSS, FSerial);
|
||||
vorbis_analysis_headerout(Vdsp, VComm, header, header_comm, header_code);
|
||||
ogg_stream_packetin(OggSS, header);
|
||||
ogg_stream_packetin(OggSS, header_comm);
|
||||
ogg_stream_packetin(OggSS, header_code);
|
||||
while ogg_stream_flush(OggSS, OggPg) <> 0 do
|
||||
begin
|
||||
FStream.Write(OggPg.header^, OggPg.header_len);
|
||||
FStream.Write(OggPg.body^, OggPg.body_len);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.Done;
|
||||
begin
|
||||
if not FStreamAssigned then
|
||||
FStream.Free;
|
||||
FInput.Flush;
|
||||
FComments.Clear;
|
||||
ogg_stream_clear(OggSS);
|
||||
vorbis_block_clear(VBlock);
|
||||
vorbis_dsp_clear(Vdsp);
|
||||
vorbis_comment_clear(VComm);
|
||||
vorbis_info_clear(VInfo);
|
||||
FreeMem(FBuffer);
|
||||
end;
|
||||
|
||||
function TVorbisOut.DoOutput(Abort : Boolean):Boolean;
|
||||
var
|
||||
Len, i,chc : Integer;
|
||||
out_buf : PPFloat;
|
||||
tmpBuf1, tmpBuf2 : PFloat;
|
||||
begin
|
||||
// No exceptions Here
|
||||
Result := True;
|
||||
if not CanOutput then Exit;
|
||||
if Abort or EndOfStream then
|
||||
begin
|
||||
(* We don't close file here to avoide exceptions
|
||||
if output componenet's Stop method is called *)
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
while InputLock do;
|
||||
InputLock := True;
|
||||
chc := Finput.Channels;
|
||||
Len := Finput.GetData(@FBuffer[0], FBufferSize);
|
||||
InputLock := False;
|
||||
if Len <> 0 then
|
||||
begin
|
||||
if chc = 2 then
|
||||
begin
|
||||
out_buf := vorbis_analysis_buffer(Vdsp, FBufferSize shr 2);
|
||||
(* A bit of pointer arithmetics. What is easy in C
|
||||
is not so easy in Pascal. *)
|
||||
tmpBuf1 := out_buf^;
|
||||
Inc(out_buf);
|
||||
tmpBuf2 := out_buf^;
|
||||
for i:=0 to (Len shr 2)-1 do
|
||||
begin
|
||||
tmpBuf1[i] := FBuffer[i*2]/$8000;
|
||||
tmpBuf2[i] := FBuffer[i*2+1]/$8000;
|
||||
end;
|
||||
vorbis_analysis_wrote(Vdsp, Len shr 2);
|
||||
end else
|
||||
begin
|
||||
out_buf := vorbis_analysis_buffer(Vdsp, FBufferSize shr 1);
|
||||
for i:=0 to (Len shr 1)-1 do
|
||||
out_buf^[i] := FBuffer[i]/$8000;
|
||||
vorbis_analysis_wrote(Vdsp, Len shr 1);
|
||||
end;
|
||||
end else
|
||||
vorbis_analysis_wrote(Vdsp, 0);
|
||||
while vorbis_analysis_blockout(Vdsp, VBlock) = 1 do
|
||||
begin
|
||||
vorbis_analysis(VBlock, nil);
|
||||
vorbis_bitrate_addblock(VBlock);
|
||||
while vorbis_bitrate_flushpacket(Vdsp, OggPk) = 1 do
|
||||
begin
|
||||
ogg_stream_packetin(OggSS, OggPk);
|
||||
while not EndOfStream do
|
||||
begin
|
||||
if ogg_stream_pageout(OggSS, OggPg) = 0 then Break;
|
||||
FStream.Write(OggPg.header^, OggPg.header_len);
|
||||
FStream.Write(OggPg.body^, OggPg.body_len);
|
||||
if ogg_page_eos(OggPg) <> 0 then EndOfStream := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TVorbisIn.Create;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
BufferSize := $2000;
|
||||
FComments := TStringList.Create;
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
VORBISLoadLibrary;
|
||||
if not LiboggLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[LiboggPath]));
|
||||
if not LibvorbisLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisPath]));
|
||||
if not LibvorbisfileLoaded then
|
||||
raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisfilePath]));
|
||||
//if not LibvorbisencLoaded then
|
||||
//raise EACSException.Create(Format(strCoudntloadLib,[LibvorbisencPath]));
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TVorbisIn.Destroy;
|
||||
begin
|
||||
FComments.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TVorbisIn.OpenFile;
|
||||
var
|
||||
PVComm : PVORBIS_COMMENT;
|
||||
PVInfo : PVORBIS_INFO;
|
||||
PComment : PPChar;
|
||||
Comment : PChar;
|
||||
Callbacks : OV_CALLBACKS;
|
||||
begin
|
||||
if FOpened = 0 then
|
||||
begin
|
||||
FValid := True;
|
||||
EndOfStream := False;
|
||||
if not FStreamAssigned then
|
||||
try
|
||||
Stream := TFileStream.Create(FileName, fmOpenRead) as TFileStream;
|
||||
except
|
||||
FValid := False;
|
||||
Exit;
|
||||
end;
|
||||
Callbacks.read_func := cbRead;
|
||||
Callbacks.close_func := cbClose;
|
||||
Callbacks.seek_func := cbSeek;
|
||||
Callbacks.tell_func := cbTell;
|
||||
ov_open_callbacks(Self, VFile, nil, 0, Callbacks);
|
||||
FComments.Clear;
|
||||
{ PVComm := ov_comment(VFile, -1);
|
||||
PComment := PVComm.user_comments;
|
||||
Comment := PComment^;
|
||||
while Comment <> nil do
|
||||
begin
|
||||
FComments.Add(String(Comment));
|
||||
Inc(LongWord(PComment), 4);
|
||||
Comment := PComment^;
|
||||
end;}
|
||||
// FVendor := PVComm.vendor;
|
||||
PVInfo := ov_info(VFile, -1);
|
||||
FChan := PVInfo.channels;
|
||||
FSR := PVInfo.rate;
|
||||
FBPS := 16;
|
||||
FMaxBitrate := PVInfo.bitrate_upper;
|
||||
FNominalBitrate := PVInfo.bitrate_nominal;
|
||||
FMinBitrate := PVInfo.bitrate_lower;
|
||||
FTotalSamples := ov_pcm_total(VFile, -1);
|
||||
FSize := (FTotalSamples shl 1) * PVInfo.channels;
|
||||
cursec := -1;
|
||||
FTime := Round(ov_time_total(VFile, -1));
|
||||
// ov_pcm_seek(VFile, FOffset);
|
||||
end;
|
||||
Inc(FOpened);
|
||||
end;
|
||||
|
||||
procedure TVorbisIn.CloseFile;
|
||||
begin
|
||||
if FOpened = 1 then
|
||||
begin
|
||||
if ov_seekable(VFile) <> 0 then
|
||||
ov_pcm_seek(VFile, 0);
|
||||
ov_clear(VFile);
|
||||
end;
|
||||
if FOpened > 0 then Dec(FOpened);
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetData(Buffer : Pointer; BufferSize : Integer): Integer;
|
||||
var
|
||||
l, offs : Integer;
|
||||
begin
|
||||
if not Busy then raise EACSException.Create('The Stream is not opened');
|
||||
if BufStart > BufEnd then
|
||||
begin
|
||||
if FOffset <> 0 then
|
||||
begin
|
||||
offs := Round((FOffset/100)*FSize);
|
||||
FPosition := FPosition + offs;
|
||||
if FPosition < 0 then FPosition := 0
|
||||
else if FPosition > FSize then FPosition := FSize;
|
||||
// tmp := (FPosition/FSize)*FTime;
|
||||
if ov_seekable(VFile) <> 0 then
|
||||
ov_pcm_seek(VFile, (FPosition shr 1) div FChan);
|
||||
FOffset := 0;
|
||||
end;
|
||||
BufStart := 1;
|
||||
BufEnd := 0;
|
||||
if not EndOfStream then
|
||||
begin
|
||||
(* The ov_read function can return data in quite small chunks
|
||||
(of about 512 bytes). We keep reading data until the buffer is filled
|
||||
or there is no more data to read. *)
|
||||
while BufEnd < BufferSize do
|
||||
begin
|
||||
l := ov_read(VFile, @FBuffer[BufEnd + 1], BufferSize - BufEnd, 0, 2, 1, @cursec);
|
||||
if l <= 0 then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
Inc(BufEnd, l);
|
||||
if (FPosition + BufEnd) >= FSize then
|
||||
begin
|
||||
BufEnd := FSize - FPosition;
|
||||
if BufEnd <= 0 then EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if EndOfStream and FLoop then
|
||||
begin
|
||||
Flush;
|
||||
Init;
|
||||
EndOfStream := False;
|
||||
while BufEnd < BufferSize do
|
||||
begin
|
||||
l := ov_read(VFile, @FBuffer[BufEnd + 1], BufferSize - BufEnd, 0, 2, 1, @cursec);
|
||||
if l <= 0 then
|
||||
begin
|
||||
EndOfStream := True;
|
||||
Break;
|
||||
end;
|
||||
Inc(BufEnd, l);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if BufferSize < (BufEnd - BufStart + 1)
|
||||
then Result := BufferSize
|
||||
else Result := BufEnd - BufStart + 1;
|
||||
Move(FBuffer[BufStart], Buffer^, Result);
|
||||
Inc(BufStart, Result);
|
||||
Inc(FPosition, Result);
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetMaxBitrate : Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FMaxBitrate;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetNominalBitrate : Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FNominalBitrate;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetComments : TStringList;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FComments;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetMinBitrate : Integer;
|
||||
begin
|
||||
OpenFile;
|
||||
Result := FMinBitrate;
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.SetFileMode;
|
||||
begin
|
||||
FFileMode := aMode;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetBitStreams : Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
if Busy then
|
||||
begin
|
||||
if ov_seekable(VFile)<>0 then
|
||||
Result := ov_streams(VFile);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetInstantBitRate : Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
if Busy then
|
||||
begin
|
||||
Result := ov_bitrate_instant(VFile);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVorbisIn.GetCurrentBitStream : Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
if Busy then
|
||||
begin
|
||||
if ov_seekable(VFile)<>0 then
|
||||
Result := VFile.current_link;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVorbisIn.SetCurrentBitStream;
|
||||
var
|
||||
Offset : POGG_INT64_T;
|
||||
begin
|
||||
if Busy then
|
||||
begin
|
||||
if ov_seekable(VFile)<>0 then
|
||||
if (BS >= 0) and (BS < ov_streams(VFile)) then
|
||||
begin
|
||||
Offset := VFile.offsets;
|
||||
Inc(Offset, BS);
|
||||
FStream.Seek(Offset^, soFromBeginning);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.SetDesiredNominalBitrate;
|
||||
begin
|
||||
FDesiredNominalBitrate := Value;
|
||||
if FMinimumBitrate > FDesiredNominalBitrate then
|
||||
FMinimumBitrate := FDesiredNominalBitrate;
|
||||
if FDesiredMaximumBitrate < FDesiredNominalBitrate then
|
||||
FDesiredMaximumBitrate := FDesiredNominalBitrate;
|
||||
if FDesiredNominalBitrate = brAutoSelect then
|
||||
FDesiredMaximumBitrate := brAutoSelect;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.SetDesiredMaximumBitrate;
|
||||
begin
|
||||
if FDesiredNominalBitrate = brAutoSelect then Exit;
|
||||
if (Value = brAutoSelect) or (Value >= FDesiredNominalBitrate) then
|
||||
FDesiredMaximumBitrate := Value;
|
||||
end;
|
||||
|
||||
procedure TVorbisOut.SetMinimumBitrate;
|
||||
begin
|
||||
if Value <= FDesiredNominalBitrate then
|
||||
FMinimumBitrate := Value;
|
||||
end;
|
||||
|
||||
function TVorbisIn.Seek(SampleNum : Integer) : Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
if not FSeekable then Exit;
|
||||
Result := True;
|
||||
OpenFile;
|
||||
ov_pcm_seek(VFile, SampleNum);
|
||||
CloseFile;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
FileFormats.Add('ogg','Ogg Vorbis',TVorbisOut);
|
||||
FileFormats.Add('ogg','Ogg Vorbis',TVorbisIn);
|
||||
|
||||
end.
|
1843
acs/Src/fileformats/acs_wave.pas
Normal file
1843
acs/Src/fileformats/acs_wave.pas
Normal file
File diff suppressed because it is too large
Load Diff
606
acs/Src/fileformats/general/flac.pas
Normal file
606
acs/Src/fileformats/general/flac.pas
Normal file
@@ -0,0 +1,606 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: flac.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit flac;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF WINDOWS}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl, ACS_Procs;
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
|
||||
LibFLACLoaded : Boolean = False;
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
LibFLACPath = 'libFLAC.dll';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
LibFLACPath = 'libFLAC.so*'; // libFLAC.so
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR = 1;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR = 2;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR = 3;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR = 4;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR = 5;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED = 6;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK = 7;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE = 8;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED = 9;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR = 1;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_DECODER_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_SEEKING = 1;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM = 2;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR = 3;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR = 4;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR = 5;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR = 6;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED = 7;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK = 8;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED = 10;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR = 1;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR = 1;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR = 1;
|
||||
|
||||
FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK = 0;
|
||||
FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR = 1;
|
||||
|
||||
type
|
||||
|
||||
FLAC__byte = Byte;
|
||||
PFLAC__byte = ^FLAC__byte;
|
||||
|
||||
FLAC__uint64 = Int64;
|
||||
PFLAC__uint64 = ^FLAC__uint64;
|
||||
|
||||
FLAC__uint32 = LongWord;
|
||||
PFLAC__uint32 = ^FLAC__uint32;
|
||||
|
||||
FLAC__int32 = Integer;
|
||||
PFLAC__int32 = ^FLAC__int32;
|
||||
|
||||
PFLAC__SeekableStreamEncoder = Pointer;
|
||||
|
||||
PFLAC__SeekableStreamDecoder = Pointer;
|
||||
|
||||
FLAC__MetadataType = Integer;
|
||||
|
||||
PFLAC__Frame = Pointer;
|
||||
|
||||
FLAC__FrameHeader = packed record
|
||||
blocksize : LongWord;
|
||||
sample_rate : LongWord;
|
||||
channels : LongWord;
|
||||
channel_assignment : Integer;
|
||||
bits_per_sample : LongWord;
|
||||
frame_number : FLAC__uint32;
|
||||
crc : Byte;
|
||||
end;
|
||||
|
||||
FLACInfo = record
|
||||
min_blocksize : LongWord;
|
||||
max_blocksize : LongWord;
|
||||
min_framesize : LongWord;
|
||||
max_framesize : LongWord;
|
||||
sample_rate : LongWord;
|
||||
channels : LongWord;
|
||||
bits_per_sample : LongWord;
|
||||
total_samples1 : LongWord;
|
||||
total_samples2 : LongWord;
|
||||
end;
|
||||
|
||||
PFLACInfo = ^FLACInfo;
|
||||
|
||||
PFLAC__StreamMetadata = Pointer;
|
||||
|
||||
PFLAC__FrameHeader = ^FLAC__FrameHeader;
|
||||
|
||||
FLACIntBuf = array[0..0] of FLAC__int32;
|
||||
PFLACIntBuf = ^FLACIntBuf;
|
||||
|
||||
FLACChannels = array[0..1] of PFLACIntBuf;
|
||||
PFLACChannels = ^FLACChannels;
|
||||
|
||||
FLAC__SeekableStreamEncoderWriteCallback = function(encoder : PFLAC__SeekableStreamEncoder;
|
||||
buffer : PFLAC__byte;
|
||||
bytes,
|
||||
samples,
|
||||
current_frame : LongWord;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
|
||||
FLAC__SeekableStreamEncoderSeekCallback = function(encoder : PFLAC__SeekableStreamEncoder;
|
||||
absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderReadCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
buffer : PFLAC__byte;
|
||||
var bytes : LongWord;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderSeekCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderTellCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
var absolute_byte_offset : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderLengthCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
var stream_length : FLAC__uint64;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderEofCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
client_data : Pointer) : Boolean; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderWriteCallback = function(decoder : PFLAC__SeekableStreamDecoder;
|
||||
frame : PFLAC__Frame;
|
||||
buffer : PFLACChannels;
|
||||
client_data : Pointer) : Integer; cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderMetadataCallback = procedure(decoder : PFLAC__SeekableStreamDecoder;
|
||||
metadata : PFLAC__StreamMetadata;
|
||||
client_data : Pointer); cdecl;
|
||||
|
||||
FLAC__SeekableStreamDecoderErrorCallback = procedure(decoder : PFLAC__SeekableStreamDecoder;
|
||||
status : Integer;
|
||||
client_data : Pointer); cdecl;
|
||||
|
||||
FLAC__seekable_stream_encoder_new_t = function : PFLAC__SeekableStreamEncoder; cdecl;
|
||||
FLAC__seekable_stream_encoder_delete_t = procedure(encoder : PFLAC__SeekableStreamEncoder); cdecl;
|
||||
FLAC__seekable_stream_encoder_set_verify_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_streamable_subset_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_channels_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_sample_rate_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_blocksize_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_do_escape_coding_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_rice_parameter_search_dist_t = function( encoder : PFLAC__SeekableStreamEncoder; value : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_total_samples_estimate_t = function( encoder : PFLAC__SeekableStreamEncoder; value : FLAC__uint64) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_metadata_t = function( encoder : PFLAC__SeekableStreamEncoder; metadata : Pointer; num_blocks : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_seek_callback_t = function( encoder : PFLAC__SeekableStreamEncoder; value : FLAC__SeekableStreamEncoderSeekCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_write_callback_t = function( encoder : PFLAC__SeekableStreamEncoder; value : FLAC__SeekableStreamEncoderWriteCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_set_client_data_t = function( encoder : PFLAC__SeekableStreamEncoder; value : Pointer) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_state_t = function( encoder : PFLAC__SeekableStreamEncoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_stream_encoder_state_t = function( encoder : PFLAC__SeekableStreamEncoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_state_t = function( encoder : PFLAC__SeekableStreamEncoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_resolved_state_string_t = function( encoder : PFLAC__SeekableStreamEncoder) : PChar; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_error_stats_t = procedure(encoder : PFLAC__SeekableStreamEncoder; absolute_sample : PFLAC__uint64; frame_number, channel, sample : PLongWord; expected, got : FLAC__int32); cdecl;
|
||||
FLAC__seekable_stream_encoder_get_verify_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_streamable_subset_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_do_mid_side_stereo_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_channels_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_bits_per_sample_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_sample_rate_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_blocksize_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_max_lpc_order_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_qlp_coeff_precision_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_do_escape_coding_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search_t = function( encoder : PFLAC__SeekableStreamEncoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_min_residual_partition_order_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_max_residual_partition_order_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_rice_parameter_search_dist_t = function( encoder : PFLAC__SeekableStreamEncoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_encoder_get_total_samples_estimate_t = function( encoder : PFLAC__SeekableStreamEncoder) : FLAC__uint64 cdecl;
|
||||
FLAC__seekable_stream_encoder_init_t = function( encoder : PFLAC__SeekableStreamEncoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_encoder_finish_t = procedure(encoder : PFLAC__SeekableStreamEncoder); cdecl;
|
||||
FLAC__seekable_stream_encoder_process_t = function(encoder : PFLAC__SeekableStreamEncoder; buffer : PFLAC__int32; samples : LongWord) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_encoder_process_interleaved_t = function(encoder : PFLAC__SeekableStreamEncoder; buffer : PFLAC__int32; samples : LongWord) : Boolean; cdecl;
|
||||
|
||||
FLAC__seekable_stream_decoder_new_t = function : PFLAC__SeekableStreamDecoder; cdecl;
|
||||
FLAC__seekable_stream_decoder_delete_t = procedure(decoder : PFLAC__SeekableStreamDecoder); cdecl;
|
||||
FLAC__seekable_stream_decoder_set_md5_checking_t = function( decoder : PFLAC__SeekableStreamDecoder; value : Boolean) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_read_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderReadCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_seek_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderSeekCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_tell_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderTellCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_length_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderLengthCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_eof_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderEofCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_write_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderWriteCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderMetadataCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_error_callback_t = function( decoder : PFLAC__SeekableStreamDecoder; value : FLAC__SeekableStreamDecoderErrorCallback) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_client_data_t = function( decoder : PFLAC__SeekableStreamDecoder; value : Pointer) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_t = function( decoder : PFLAC__SeekableStreamDecoder; _type : FLAC__MetadataType) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_application_t = function( decoder : PFLAC__SeekableStreamDecoder; id : PFLAC__byte) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_all_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_t = function( decoder : PFLAC__SeekableStreamDecoder; _type : FLAC__MetadataType) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_application_t = function( decoder : PFLAC__SeekableStreamDecoder; id : PFLAC__byte) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_all_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_state_t = function( decoder : PFLAC__SeekableStreamDecoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_stream_decoder_state_t = function( decoder : PFLAC__SeekableStreamDecoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_resolved_state_string_t = function( decoder : PFLAC__SeekableStreamDecoder) : PChar; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_md5_checking_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_channels_t = function( decoder : PFLAC__SeekableStreamDecoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_channel_assignment_t = function( decoder : PFLAC__SeekableStreamDecoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_bits_per_sample_t = function( decoder : PFLAC__SeekableStreamDecoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_sample_rate_t = function( decoder : PFLAC__SeekableStreamDecoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_blocksize_t = function( decoder : PFLAC__SeekableStreamDecoder) : LongWord; cdecl;
|
||||
FLAC__seekable_stream_decoder_get_decode_position_t = function( decoder : PFLAC__SeekableStreamDecoder; var position : FLAC__uint64) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_init_t = function( decoder : PFLAC__SeekableStreamDecoder) : Integer; cdecl;
|
||||
FLAC__seekable_stream_decoder_finish_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_flush_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_reset_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_process_single_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_metadata_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_stream_t = function( decoder : PFLAC__SeekableStreamDecoder) : Boolean; cdecl;
|
||||
FLAC__seekable_stream_decoder_seek_absolute_t = function( decoder : PFLAC__SeekableStreamDecoder; sample : FLAC__uint64) : Boolean; cdecl;
|
||||
|
||||
var
|
||||
|
||||
FLAC__seekable_stream_encoder_new : FLAC__seekable_stream_encoder_new_t;
|
||||
FLAC__seekable_stream_encoder_delete : FLAC__seekable_stream_encoder_delete_t;
|
||||
FLAC__seekable_stream_encoder_set_verify : FLAC__seekable_stream_encoder_set_verify_t;
|
||||
FLAC__seekable_stream_encoder_set_streamable_subset : FLAC__seekable_stream_encoder_set_streamable_subset_t;
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo : FLAC__seekable_stream_encoder_set_do_mid_side_stereo_t;
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo : FLAC__seekable_stream_encoder_set_loose_mid_side_stereo_t;
|
||||
FLAC__seekable_stream_encoder_set_channels : FLAC__seekable_stream_encoder_set_channels_t;
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample : FLAC__seekable_stream_encoder_set_bits_per_sample_t;
|
||||
FLAC__seekable_stream_encoder_set_sample_rate : FLAC__seekable_stream_encoder_set_sample_rate_t;
|
||||
FLAC__seekable_stream_encoder_set_blocksize : FLAC__seekable_stream_encoder_set_blocksize_t;
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order : FLAC__seekable_stream_encoder_set_max_lpc_order_t;
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision : FLAC__seekable_stream_encoder_set_qlp_coeff_precision_t;
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search : FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search_t;
|
||||
FLAC__seekable_stream_encoder_set_do_escape_coding : FLAC__seekable_stream_encoder_set_do_escape_coding_t;
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search : FLAC__seekable_stream_encoder_set_do_exhaustive_model_search_t;
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order : FLAC__seekable_stream_encoder_set_min_residual_partition_order_t;
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order : FLAC__seekable_stream_encoder_set_max_residual_partition_order_t;
|
||||
// FLAC__seekable_stream_encoder_set_rice_parameter_search_dist : FLAC__seekable_stream_encoder_set_rice_parameter_search_dist_t;
|
||||
FLAC__seekable_stream_encoder_set_total_samples_estimate : FLAC__seekable_stream_encoder_set_total_samples_estimate_t;
|
||||
FLAC__seekable_stream_encoder_set_metadata : FLAC__seekable_stream_encoder_set_metadata_t;
|
||||
FLAC__seekable_stream_encoder_set_seek_callback : FLAC__seekable_stream_encoder_set_seek_callback_t;
|
||||
FLAC__seekable_stream_encoder_set_write_callback : FLAC__seekable_stream_encoder_set_write_callback_t;
|
||||
FLAC__seekable_stream_encoder_set_client_data : FLAC__seekable_stream_encoder_set_client_data_t;
|
||||
FLAC__seekable_stream_encoder_get_state : FLAC__seekable_stream_encoder_get_state_t;
|
||||
FLAC__seekable_stream_encoder_get_stream_encoder_state : FLAC__seekable_stream_encoder_get_stream_encoder_state_t;
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_state : FLAC__seekable_stream_encoder_get_verify_decoder_state_t;
|
||||
FLAC__seekable_stream_encoder_get_resolved_state_string : FLAC__seekable_stream_encoder_get_resolved_state_string_t;
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_error_stats : FLAC__seekable_stream_encoder_get_verify_decoder_error_stats_t;
|
||||
FLAC__seekable_stream_encoder_get_verify : FLAC__seekable_stream_encoder_get_verify_t;
|
||||
FLAC__seekable_stream_encoder_get_streamable_subset : FLAC__seekable_stream_encoder_get_streamable_subset_t;
|
||||
FLAC__seekable_stream_encoder_get_do_mid_side_stereo : FLAC__seekable_stream_encoder_get_do_mid_side_stereo_t;
|
||||
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo : FLAC__seekable_stream_encoder_get_loose_mid_side_stereo_t;
|
||||
FLAC__seekable_stream_encoder_get_channels : FLAC__seekable_stream_encoder_get_channels_t;
|
||||
FLAC__seekable_stream_encoder_get_bits_per_sample : FLAC__seekable_stream_encoder_get_bits_per_sample_t;
|
||||
FLAC__seekable_stream_encoder_get_sample_rate : FLAC__seekable_stream_encoder_get_sample_rate_t;
|
||||
FLAC__seekable_stream_encoder_get_blocksize : FLAC__seekable_stream_encoder_get_blocksize_t;
|
||||
FLAC__seekable_stream_encoder_get_max_lpc_order : FLAC__seekable_stream_encoder_get_max_lpc_order_t;
|
||||
FLAC__seekable_stream_encoder_get_qlp_coeff_precision : FLAC__seekable_stream_encoder_get_qlp_coeff_precision_t;
|
||||
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search : FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search_t;
|
||||
FLAC__seekable_stream_encoder_get_do_escape_coding : FLAC__seekable_stream_encoder_get_do_escape_coding_t;
|
||||
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search : FLAC__seekable_stream_encoder_get_do_exhaustive_model_search_t;
|
||||
FLAC__seekable_stream_encoder_get_min_residual_partition_order : FLAC__seekable_stream_encoder_get_min_residual_partition_order_t;
|
||||
FLAC__seekable_stream_encoder_get_max_residual_partition_order : FLAC__seekable_stream_encoder_get_max_residual_partition_order_t;
|
||||
// FLAC__seekable_stream_encoder_get_rice_parameter_search_dist : FLAC__seekable_stream_encoder_get_rice_parameter_search_dist_t;
|
||||
FLAC__seekable_stream_encoder_get_total_samples_estimate : FLAC__seekable_stream_encoder_get_total_samples_estimate_t;
|
||||
FLAC__seekable_stream_encoder_init : FLAC__seekable_stream_encoder_init_t;
|
||||
FLAC__seekable_stream_encoder_finish : FLAC__seekable_stream_encoder_finish_t;
|
||||
FLAC__seekable_stream_encoder_process : FLAC__seekable_stream_encoder_process_t;
|
||||
FLAC__seekable_stream_encoder_process_interleaved : FLAC__seekable_stream_encoder_process_interleaved_t;
|
||||
|
||||
FLAC__seekable_stream_decoder_new : FLAC__seekable_stream_decoder_new_t;
|
||||
FLAC__seekable_stream_decoder_delete : FLAC__seekable_stream_decoder_delete_t;
|
||||
FLAC__seekable_stream_decoder_set_md5_checking : FLAC__seekable_stream_decoder_set_md5_checking_t;
|
||||
FLAC__seekable_stream_decoder_set_read_callback : FLAC__seekable_stream_decoder_set_read_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_seek_callback : FLAC__seekable_stream_decoder_set_seek_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_tell_callback : FLAC__seekable_stream_decoder_set_tell_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_length_callback : FLAC__seekable_stream_decoder_set_length_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_eof_callback : FLAC__seekable_stream_decoder_set_eof_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_write_callback : FLAC__seekable_stream_decoder_set_write_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback : FLAC__seekable_stream_decoder_set_metadata_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_error_callback : FLAC__seekable_stream_decoder_set_error_callback_t;
|
||||
FLAC__seekable_stream_decoder_set_client_data : FLAC__seekable_stream_decoder_set_client_data_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond : FLAC__seekable_stream_decoder_set_metadata_respond_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_application : FLAC__seekable_stream_decoder_set_metadata_respond_application_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_all : FLAC__seekable_stream_decoder_set_metadata_respond_all_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore : FLAC__seekable_stream_decoder_set_metadata_ignore_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_application : FLAC__seekable_stream_decoder_set_metadata_ignore_application_t;
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_all : FLAC__seekable_stream_decoder_set_metadata_ignore_all_t;
|
||||
FLAC__seekable_stream_decoder_get_state : FLAC__seekable_stream_decoder_get_state_t;
|
||||
FLAC__seekable_stream_decoder_get_stream_decoder_state : FLAC__seekable_stream_decoder_get_stream_decoder_state_t;
|
||||
FLAC__seekable_stream_decoder_get_resolved_state_string : FLAC__seekable_stream_decoder_get_resolved_state_string_t;
|
||||
FLAC__seekable_stream_decoder_get_md5_checking : FLAC__seekable_stream_decoder_get_md5_checking_t;
|
||||
FLAC__seekable_stream_decoder_get_channels : FLAC__seekable_stream_decoder_get_channels_t;
|
||||
FLAC__seekable_stream_decoder_get_channel_assignment : FLAC__seekable_stream_decoder_get_channel_assignment_t;
|
||||
FLAC__seekable_stream_decoder_get_bits_per_sample : FLAC__seekable_stream_decoder_get_bits_per_sample_t;
|
||||
FLAC__seekable_stream_decoder_get_sample_rate : FLAC__seekable_stream_decoder_get_sample_rate_t;
|
||||
FLAC__seekable_stream_decoder_get_blocksize : FLAC__seekable_stream_decoder_get_blocksize_t;
|
||||
FLAC__seekable_stream_decoder_get_decode_position : FLAC__seekable_stream_decoder_get_decode_position_t;
|
||||
FLAC__seekable_stream_decoder_init : FLAC__seekable_stream_decoder_init_t;
|
||||
FLAC__seekable_stream_decoder_finish : FLAC__seekable_stream_decoder_finish_t;
|
||||
FLAC__seekable_stream_decoder_flush : FLAC__seekable_stream_decoder_flush_t;
|
||||
FLAC__seekable_stream_decoder_reset : FLAC__seekable_stream_decoder_reset_t;
|
||||
FLAC__seekable_stream_decoder_process_single : FLAC__seekable_stream_decoder_process_single_t;
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_metadata : FLAC__seekable_stream_decoder_process_until_end_of_metadata_t;
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_stream : FLAC__seekable_stream_decoder_process_until_end_of_stream_t;
|
||||
FLAC__seekable_stream_decoder_seek_absolute : FLAC__seekable_stream_decoder_seek_absolute_t;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(LibFLACPath, 0, 0);
|
||||
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LibFLACLoaded := True;
|
||||
|
||||
FLAC__seekable_stream_encoder_new := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_new');
|
||||
FLAC__seekable_stream_encoder_delete := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_delete');
|
||||
FLAC__seekable_stream_encoder_set_verify := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_verify');
|
||||
FLAC__seekable_stream_encoder_set_streamable_subset := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_streamable_subset');
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_do_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_loose_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_set_channels := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_channels');
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_bits_per_sample');
|
||||
FLAC__seekable_stream_encoder_set_sample_rate := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_sample_rate');
|
||||
FLAC__seekable_stream_encoder_set_blocksize := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_blocksize');
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_max_lpc_order');
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_qlp_coeff_precision');
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search');
|
||||
FLAC__seekable_stream_encoder_set_do_escape_coding := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_do_escape_coding');
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_do_exhaustive_model_search');
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_min_residual_partition_order');
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_max_residual_partition_order');
|
||||
// FLAC__seekable_stream_encoder_set_rice_parameter_search_dist := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_rice_parameter_search_dist');
|
||||
FLAC__seekable_stream_encoder_set_total_samples_estimate := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_total_samples_estimate');
|
||||
FLAC__seekable_stream_encoder_set_metadata := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_metadata');
|
||||
FLAC__seekable_stream_encoder_set_seek_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_seek_callback');
|
||||
FLAC__seekable_stream_encoder_set_write_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_write_callback');
|
||||
FLAC__seekable_stream_encoder_set_client_data := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_set_client_data');
|
||||
FLAC__seekable_stream_encoder_get_state := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_state');
|
||||
FLAC__seekable_stream_encoder_get_stream_encoder_state := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_stream_encoder_state');
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_state := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_verify_decoder_state');
|
||||
FLAC__seekable_stream_encoder_get_resolved_state_string := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_resolved_state_string');
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_error_stats := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_verify_decoder_error_stats');
|
||||
FLAC__seekable_stream_encoder_get_verify := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_verify');
|
||||
FLAC__seekable_stream_encoder_get_streamable_subset := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_streamable_subset');
|
||||
FLAC__seekable_stream_encoder_get_do_mid_side_stereo := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_do_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_loose_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_get_channels := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_channels');
|
||||
FLAC__seekable_stream_encoder_get_bits_per_sample := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_bits_per_sample');
|
||||
FLAC__seekable_stream_encoder_get_sample_rate := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_sample_rate');
|
||||
FLAC__seekable_stream_encoder_get_blocksize := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_blocksize');
|
||||
FLAC__seekable_stream_encoder_get_max_lpc_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_max_lpc_order');
|
||||
FLAC__seekable_stream_encoder_get_qlp_coeff_precision := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_qlp_coeff_precision');
|
||||
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search');
|
||||
FLAC__seekable_stream_encoder_get_do_escape_coding := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_do_escape_coding');
|
||||
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_do_exhaustive_model_search');
|
||||
FLAC__seekable_stream_encoder_get_min_residual_partition_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_min_residual_partition_order');
|
||||
FLAC__seekable_stream_encoder_get_max_residual_partition_order := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_max_residual_partition_order');
|
||||
// FLAC__seekable_stream_encoder_get_rice_parameter_search_dist := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_rice_parameter_search_dist');
|
||||
FLAC__seekable_stream_encoder_get_total_samples_estimate := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_get_total_samples_estimate');
|
||||
FLAC__seekable_stream_encoder_init := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_init');
|
||||
FLAC__seekable_stream_encoder_finish := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_finish');
|
||||
FLAC__seekable_stream_encoder_process := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_process');
|
||||
FLAC__seekable_stream_encoder_process_interleaved := GetProcAddress(Libhandle, 'FLAC__seekable_stream_encoder_process_interleaved');
|
||||
|
||||
FLAC__seekable_stream_decoder_new := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_new');
|
||||
FLAC__seekable_stream_decoder_delete := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_delete');
|
||||
FLAC__seekable_stream_decoder_set_md5_checking := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_md5_checking');
|
||||
FLAC__seekable_stream_decoder_set_read_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_read_callback');
|
||||
FLAC__seekable_stream_decoder_set_seek_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_seek_callback');
|
||||
FLAC__seekable_stream_decoder_set_tell_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_tell_callback');
|
||||
FLAC__seekable_stream_decoder_set_length_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_length_callback');
|
||||
FLAC__seekable_stream_decoder_set_eof_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_eof_callback');
|
||||
FLAC__seekable_stream_decoder_set_write_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_write_callback');
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_callback');
|
||||
FLAC__seekable_stream_decoder_set_error_callback := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_error_callback');
|
||||
FLAC__seekable_stream_decoder_set_client_data := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_client_data');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_application := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond_application');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_all := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond_all');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_application := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore_application');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_all := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore_all');
|
||||
FLAC__seekable_stream_decoder_get_state := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_state');
|
||||
FLAC__seekable_stream_decoder_get_stream_decoder_state := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_stream_decoder_state');
|
||||
FLAC__seekable_stream_decoder_get_resolved_state_string := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_resolved_state_string');
|
||||
FLAC__seekable_stream_decoder_get_md5_checking := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_md5_checking');
|
||||
FLAC__seekable_stream_decoder_get_channels := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_channels');
|
||||
FLAC__seekable_stream_decoder_get_channel_assignment := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_channel_assignment');
|
||||
FLAC__seekable_stream_decoder_get_bits_per_sample := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_bits_per_sample');
|
||||
FLAC__seekable_stream_decoder_get_sample_rate := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_sample_rate');
|
||||
FLAC__seekable_stream_decoder_get_blocksize := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_blocksize');
|
||||
FLAC__seekable_stream_decoder_get_decode_position := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_get_decode_position');
|
||||
FLAC__seekable_stream_decoder_init := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_init');
|
||||
FLAC__seekable_stream_decoder_finish := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_finish');
|
||||
FLAC__seekable_stream_decoder_flush := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_flush');
|
||||
FLAC__seekable_stream_decoder_reset := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_reset');
|
||||
FLAC__seekable_stream_decoder_process_single := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_process_single');
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_metadata := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_process_until_end_of_metadata');
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_stream := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_process_until_end_of_stream');
|
||||
FLAC__seekable_stream_decoder_seek_absolute := GetProcAddress(Libhandle, 'FLAC__seekable_stream_decoder_seek_absolute');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(LibFLACPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(LibFLACPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
LibFLACLoaded := True;
|
||||
|
||||
FLAC__seekable_stream_encoder_new := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_new');
|
||||
FLAC__seekable_stream_encoder_delete := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_delete');
|
||||
FLAC__seekable_stream_encoder_set_verify := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_verify');
|
||||
FLAC__seekable_stream_encoder_set_streamable_subset := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_streamable_subset');
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_do_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_loose_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_set_channels := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_channels');
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_bits_per_sample');
|
||||
FLAC__seekable_stream_encoder_set_sample_rate := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_sample_rate');
|
||||
FLAC__seekable_stream_encoder_set_blocksize := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_blocksize');
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_max_lpc_order');
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_qlp_coeff_precision');
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search');
|
||||
FLAC__seekable_stream_encoder_set_do_escape_coding := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_do_escape_coding');
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_do_exhaustive_model_search');
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_min_residual_partition_order');
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_max_residual_partition_order');
|
||||
// FLAC__seekable_stream_encoder_set_rice_parameter_search_dist := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_rice_parameter_search_dist');
|
||||
FLAC__seekable_stream_encoder_set_total_samples_estimate := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_total_samples_estimate');
|
||||
FLAC__seekable_stream_encoder_set_metadata := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_metadata');
|
||||
FLAC__seekable_stream_encoder_set_seek_callback := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_seek_callback');
|
||||
FLAC__seekable_stream_encoder_set_write_callback := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_write_callback');
|
||||
FLAC__seekable_stream_encoder_set_client_data := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_set_client_data');
|
||||
FLAC__seekable_stream_encoder_get_state := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_state');
|
||||
FLAC__seekable_stream_encoder_get_stream_encoder_state := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_stream_encoder_state');
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_state := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_verify_decoder_state');
|
||||
FLAC__seekable_stream_encoder_get_resolved_state_string := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_resolved_state_string');
|
||||
FLAC__seekable_stream_encoder_get_verify_decoder_error_stats := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_verify_decoder_error_stats');
|
||||
FLAC__seekable_stream_encoder_get_verify := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_verify');
|
||||
FLAC__seekable_stream_encoder_get_streamable_subset := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_streamable_subset');
|
||||
FLAC__seekable_stream_encoder_get_do_mid_side_stereo := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_do_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_loose_mid_side_stereo');
|
||||
FLAC__seekable_stream_encoder_get_channels := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_channels');
|
||||
FLAC__seekable_stream_encoder_get_bits_per_sample := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_bits_per_sample');
|
||||
FLAC__seekable_stream_encoder_get_sample_rate := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_sample_rate');
|
||||
FLAC__seekable_stream_encoder_get_blocksize := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_blocksize');
|
||||
FLAC__seekable_stream_encoder_get_max_lpc_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_max_lpc_order');
|
||||
FLAC__seekable_stream_encoder_get_qlp_coeff_precision := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_qlp_coeff_precision');
|
||||
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search');
|
||||
FLAC__seekable_stream_encoder_get_do_escape_coding := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_do_escape_coding');
|
||||
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_do_exhaustive_model_search');
|
||||
FLAC__seekable_stream_encoder_get_min_residual_partition_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_min_residual_partition_order');
|
||||
FLAC__seekable_stream_encoder_get_max_residual_partition_order := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_max_residual_partition_order');
|
||||
// FLAC__seekable_stream_encoder_get_rice_parameter_search_dist := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_rice_parameter_search_dist');
|
||||
FLAC__seekable_stream_encoder_get_total_samples_estimate := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_get_total_samples_estimate');
|
||||
FLAC__seekable_stream_encoder_init := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_init');
|
||||
FLAC__seekable_stream_encoder_finish := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_finish');
|
||||
FLAC__seekable_stream_encoder_process := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_process');
|
||||
FLAC__seekable_stream_encoder_process_interleaved := dlsym(Libhandle, 'FLAC__seekable_stream_encoder_process_interleaved');
|
||||
|
||||
FLAC__seekable_stream_decoder_new := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_new');
|
||||
FLAC__seekable_stream_decoder_delete := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_delete');
|
||||
FLAC__seekable_stream_decoder_set_md5_checking := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_md5_checking');
|
||||
FLAC__seekable_stream_decoder_set_read_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_read_callback');
|
||||
FLAC__seekable_stream_decoder_set_seek_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_seek_callback');
|
||||
FLAC__seekable_stream_decoder_set_tell_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_tell_callback');
|
||||
FLAC__seekable_stream_decoder_set_length_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_length_callback');
|
||||
FLAC__seekable_stream_decoder_set_eof_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_eof_callback');
|
||||
FLAC__seekable_stream_decoder_set_write_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_write_callback');
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_callback');
|
||||
FLAC__seekable_stream_decoder_set_error_callback := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_error_callback');
|
||||
FLAC__seekable_stream_decoder_set_client_data := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_client_data');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_application := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond_application');
|
||||
FLAC__seekable_stream_decoder_set_metadata_respond_all := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_respond_all');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_application := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore_application');
|
||||
FLAC__seekable_stream_decoder_set_metadata_ignore_all := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_set_metadata_ignore_all');
|
||||
FLAC__seekable_stream_decoder_get_state := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_state');
|
||||
FLAC__seekable_stream_decoder_get_stream_decoder_state := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_stream_decoder_state');
|
||||
FLAC__seekable_stream_decoder_get_resolved_state_string := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_resolved_state_string');
|
||||
FLAC__seekable_stream_decoder_get_md5_checking := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_md5_checking');
|
||||
FLAC__seekable_stream_decoder_get_channels := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_channels');
|
||||
FLAC__seekable_stream_decoder_get_channel_assignment := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_channel_assignment');
|
||||
FLAC__seekable_stream_decoder_get_bits_per_sample := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_bits_per_sample');
|
||||
FLAC__seekable_stream_decoder_get_sample_rate := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_sample_rate');
|
||||
FLAC__seekable_stream_decoder_get_blocksize := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_blocksize');
|
||||
FLAC__seekable_stream_decoder_get_decode_position := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_get_decode_position');
|
||||
FLAC__seekable_stream_decoder_init := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_init');
|
||||
FLAC__seekable_stream_decoder_finish := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_finish');
|
||||
FLAC__seekable_stream_decoder_flush := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_flush');
|
||||
FLAC__seekable_stream_decoder_reset := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_reset');
|
||||
FLAC__seekable_stream_decoder_process_single := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_process_single');
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_metadata := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_process_until_end_of_metadata');
|
||||
FLAC__seekable_stream_decoder_process_until_end_of_stream := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_process_until_end_of_stream');
|
||||
FLAC__seekable_stream_decoder_seek_absolute := dlsym(Libhandle, 'FLAC__seekable_stream_decoder_seek_absolute');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
1058
acs/Src/fileformats/general/lame.pas
Normal file
1058
acs/Src/fileformats/general/lame.pas
Normal file
File diff suppressed because it is too large
Load Diff
297
acs/Src/fileformats/general/mad.pas
Normal file
297
acs/Src/fileformats/general/mad.pas
Normal file
@@ -0,0 +1,297 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: mad.pas,v $
|
||||
Revision 1.2 2006/08/03 17:31:09 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit mad;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
{$IFDEF WIN32}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl, ACS_Procs;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF WIN32}
|
||||
MADLibPath = 'MADLib.dll';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
MADLibPath = 'libmad.so*'; // libmad.so
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
var
|
||||
|
||||
MADLibLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
mad_bitptr = packed record
|
||||
b : PChar;
|
||||
Cache, Left : Word;
|
||||
end;
|
||||
|
||||
mad_stream = packed record
|
||||
buffer : Pointer;
|
||||
bufend : Pointer;
|
||||
skiplen : LongWord;
|
||||
sync : Integer;
|
||||
freerate : LongWord;
|
||||
this_frame : Pointer;
|
||||
next_frame : Pointer;
|
||||
ptr : mad_bitptr;
|
||||
anc_ptr : mad_bitptr;
|
||||
anc_bitlen : LongWord;
|
||||
main_data : Pointer;
|
||||
md_len : LongWord;
|
||||
options : Integer;
|
||||
error : Integer;
|
||||
end;
|
||||
|
||||
p_mad_stream = ^mad_stream;
|
||||
|
||||
mad_timer_t = packed record
|
||||
seconds : Integer;
|
||||
fraction : LongWord;
|
||||
end;
|
||||
|
||||
mad_header = packed record
|
||||
layer : Integer;
|
||||
mode : Integer;
|
||||
mode_extension : Integer;
|
||||
emphasis : Integer;
|
||||
bitrate : LongWord;
|
||||
samplerate : LongWord;
|
||||
crc_check : Word;
|
||||
crc_target : Word;
|
||||
flags : Integer;
|
||||
private_bits : Integer;
|
||||
duration : mad_timer_t;
|
||||
end;
|
||||
|
||||
p_mad_header = ^mad_header;
|
||||
|
||||
mad_frame = packed record
|
||||
header : mad_header;
|
||||
options : Integer;
|
||||
sbsample : packed array[0..1, 0..35, 0..31] of Integer;
|
||||
overlap : Pointer;
|
||||
end;
|
||||
|
||||
p_mad_frame = ^mad_frame;
|
||||
|
||||
mad_pcm = packed record
|
||||
samplerate : LongWord;
|
||||
channels : Word;
|
||||
length : Word;
|
||||
samples : packed array [0..1, 0..1151] of Integer;
|
||||
end;
|
||||
|
||||
p_mad_pcm = ^mad_pcm;
|
||||
|
||||
mad_synth = packed record
|
||||
filter : array[0..1, 0..1, 0..1, 0..15, 0..7] of Integer;
|
||||
phase : LongWord;
|
||||
pcm : mad_pcm;
|
||||
end;
|
||||
|
||||
async_struct = packed record
|
||||
pid : LongWord;
|
||||
_in : Integer;
|
||||
_out : Integer;
|
||||
end;
|
||||
|
||||
sync_struct = packed record
|
||||
stream : mad_stream;
|
||||
frame : mad_frame;
|
||||
synth : mad_synth;
|
||||
end;
|
||||
|
||||
p_sync_struct = ^sync_struct;
|
||||
|
||||
TInputFunc = function(CData : Pointer; Stream : p_mad_stream) : Integer; cdecl;
|
||||
THeaderFunc = function(CData : Pointer; Header : p_mad_header) : Integer; cdecl;
|
||||
TFilterFunc = function(CData : Pointer; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TOutputFunc = function(CData : Pointer; Header : p_mad_header; pcm : p_mad_pcm) : Integer; cdecl;
|
||||
TErrorFunc = function(CData : Pointer; Stream : p_mad_stream; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TMessageFunc = function(P1, P2 : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_decoder = packed record
|
||||
mode : Integer;
|
||||
options : Integer;
|
||||
async : async_struct;
|
||||
sync : p_sync_struct;
|
||||
data : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc;
|
||||
end;
|
||||
|
||||
p_mad_decoder = ^mad_decoder;
|
||||
|
||||
const
|
||||
|
||||
MAD_F_FRACBITS = 28;
|
||||
MAD_F_ONE = $10000000;
|
||||
|
||||
MAD_FLOW_CONTINUE = $0;
|
||||
MAD_FLOW_STOP = $10;
|
||||
MAD_FLOW_BREAK = $11;
|
||||
MAD_FLOW_IGNORE = $20;
|
||||
|
||||
MAD_DECODER_MODE_SYNC = 0;
|
||||
MAD_DECODER_MODE_ASYNC = 1;
|
||||
|
||||
type
|
||||
|
||||
mad_decoder_init_t = procedure(mad_decoder : p_mad_decoder;
|
||||
CData : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc); cdecl;
|
||||
|
||||
mad_decoder_finish_t = function(mad_decoder : p_mad_decoder) : Integer; cdecl;
|
||||
|
||||
mad_decoder_run_t = function(mad_decoder : p_mad_decoder; mad_decoder_mode : Integer) : Integer; cdecl;
|
||||
|
||||
mad_decoder_message_t = function(mad_decoder : p_mad_decoder; P : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_stream_buffer_t = procedure(MadStream : p_mad_stream; Data : Pointer; l : LongWord); cdecl;
|
||||
|
||||
mad_stream_skip_t = procedure(MadStream : p_mad_stream; Skip : LongWord); cdecl;
|
||||
|
||||
mad_stream_sync_t = function(MadStream : p_mad_stream) : Integer; cdecl;
|
||||
|
||||
var
|
||||
|
||||
mad_decoder_init: mad_decoder_init_t;
|
||||
mad_decoder_finish : mad_decoder_finish_t;
|
||||
mad_decoder_run : mad_decoder_run_t;
|
||||
mad_decoder_message : mad_decoder_message_t;
|
||||
mad_stream_buffer : mad_stream_buffer_t;
|
||||
mad_stream_skip : mad_stream_skip_t;
|
||||
mad_stream_sync : mad_stream_sync_t;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(MADLibPath, 0, 0);
|
||||
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := GetProcAddress(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := GetProcAddress(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := GetProcAddress(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := GetProcAddress(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := GetProcAddress(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := GetProcAddress(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := GetProcAddress(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(MADLibPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(MADLibPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := dlsym(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := dlsym(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := dlsym(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := dlsym(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := dlsym(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := dlsym(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := dlsym(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end.
|
535
acs/Src/fileformats/general/ogg.pas
Normal file
535
acs/Src/fileformats/general/ogg.pas
Normal file
@@ -0,0 +1,535 @@
|
||||
(*
|
||||
delphi/kylix headers for oggvorbis software codec.
|
||||
translated from ogg.h and os_types.h headers
|
||||
by andrei borovsky, acs@compiler4.net
|
||||
the original c/c++ headers and libraries (c) copyright 1994-2001
|
||||
by the xiphophorus company http://www.xiph.org/
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: ogg.pas,v $
|
||||
Revision 1.4 2005/12/29 20:46:00 z0m3ie
|
||||
fixed some problems with vorbis in lazarus
|
||||
|
||||
Revision 1.3 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit ogg;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_Procs,
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
|
||||
(* Type declarations from os_types.h header with
|
||||
some Delphi-specific types added *)
|
||||
|
||||
OGG_INT64_T = int64;
|
||||
|
||||
POGG_INT64_T = ^OGG_INT64_T;
|
||||
|
||||
OGG_INT32_T = Integer;
|
||||
|
||||
OGG_UINT32_T = LongWord;
|
||||
|
||||
OGG_INT16_T = SmallInt; // Word ?
|
||||
|
||||
(* Note by AB: The following three type declarations,
|
||||
strange as they seem, are required to make C
|
||||
pointer/array stuff work in Delphi/Kylix.
|
||||
See TVorbisOut class for details. *)
|
||||
|
||||
FLOAT_T = array[0..0] of Single;
|
||||
|
||||
PFLOAT = ^FLOAT_T;
|
||||
|
||||
PPFLOAT = ^PFLOAT;
|
||||
|
||||
// Type declarations from ogg.h header
|
||||
|
||||
POGGPACK_BUFFER = ^OGGPACK_BUFFER;
|
||||
|
||||
OGGPACK_BUFFER = record
|
||||
endbyte: LongInt;
|
||||
endbit: Integer;
|
||||
buffer: PByte;
|
||||
ptr: PByte;
|
||||
storage: LongInt;
|
||||
end;
|
||||
|
||||
// ogg_page is used to encapsulate the data in one Ogg bitstream page
|
||||
|
||||
OGG_PAGE = record
|
||||
header: PByte;
|
||||
header_len: LongInt;
|
||||
body: PByte;
|
||||
body_len: LongInt;
|
||||
end;
|
||||
|
||||
(* ogg_stream_state contains the current encode/decode state of a logical
|
||||
Ogg bitstream *)
|
||||
|
||||
OGG_STREAM_STATE = record
|
||||
body_data: PByte; // bytes from packet bodies
|
||||
body_storage: LongInt; // storage elements allocated
|
||||
body_fill: LongInt; // elements stored; fill mark
|
||||
body_returned: LongInt; // elements of fill returned
|
||||
lacing_vals: PInteger; // The values that will go to the segment table
|
||||
granule_vals: POGG_INT64_T; (* granulepos values for headers. Not compact
|
||||
this way, but it is simple coupled to the
|
||||
lacing fifo *)
|
||||
lacing_storage: LongInt;
|
||||
lacing_fill: LongInt;
|
||||
lacing_packet: LongInt;
|
||||
lacing_returned: LongInt;
|
||||
header: array[0..281] of Byte; // working space for header encode
|
||||
header_fill: Integer;
|
||||
e_o_s: Integer; (* set when we have buffered the last packet in the
|
||||
logical bitstream *)
|
||||
b_o_s: Integer; (* set after we've written the initial page
|
||||
of a logical bitstream *)
|
||||
serialno: LongInt;
|
||||
pageno: LongInt;
|
||||
packetno: OGG_INT64_T;
|
||||
(* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap *)
|
||||
granulepos: OGG_INT64_T;
|
||||
end;
|
||||
|
||||
(* ogg_packet is used to encapsulate the data and metadata belonging
|
||||
to a single raw Ogg/Vorbis packet *)
|
||||
|
||||
POGG_PACKET = ^OGG_PACKET;
|
||||
|
||||
OGG_PACKET = record
|
||||
packet: PByte;
|
||||
bytes: LongInt;
|
||||
b_o_s: LongInt;
|
||||
e_o_s: LongInt;
|
||||
granulepos: OGG_INT64_T;
|
||||
packetno: OGG_INT64_T;
|
||||
(* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap *)
|
||||
end;
|
||||
|
||||
OGG_SYNC_STATE = record
|
||||
data: PByte;
|
||||
storage: Integer;
|
||||
fill: Integer;
|
||||
returned: Integer;
|
||||
unsynced: Integer;
|
||||
headerbytes: Integer;
|
||||
bodybytes: Integer;
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF LINUX}
|
||||
LiboggPath = 'libogg.so*'; // '/usr/lib/libogg.so';
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
LiboggPath = 'ogg.dll';
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
var
|
||||
LiboggLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
// Ogg BITSTREAM PRIMITIVES: bitstream
|
||||
|
||||
oggpack_writeinit_t = procedure(var b: OGGPACK_BUFFER); cdecl;
|
||||
|
||||
oggpack_reset_t = procedure(var b: OGGPACK_BUFFER); cdecl;
|
||||
|
||||
oggpack_writeclear_t = procedure(var b: OGGPACK_BUFFER); cdecl;
|
||||
|
||||
oggpack_readinit_t = procedure(var b: OGGPACK_BUFFER;
|
||||
buf: PByte;
|
||||
bytes: Integer); cdecl;
|
||||
|
||||
oggpack_write_t = procedure(var b: OGGPACK_BUFFER;
|
||||
value: LongInt;
|
||||
bits: Integer); cdecl;
|
||||
|
||||
oggpack_look_t = function(var b: OGGPACK_BUFFER;
|
||||
bits: Integer): LongInt; cdecl;
|
||||
|
||||
oggpack_look_huff_t = function(var b: OGGPACK_BUFFER;
|
||||
bits: Integer): LongInt; cdecl;
|
||||
|
||||
oggpack_look1_t = function(var b: OGGPACK_BUFFER): LongInt; cdecl;
|
||||
|
||||
oggpack_adv_t = procedure(var b: OGGPACK_BUFFER;
|
||||
bits: Integer); cdecl;
|
||||
|
||||
oggpack_adv_huff_t = function(var b: OGGPACK_BUFFER;
|
||||
bits: Integer): Integer; cdecl;
|
||||
|
||||
oggpack_adv1_t = procedure(var b: OGGPACK_BUFFER); cdecl;
|
||||
|
||||
oggpack_read_t = function(var b: OGGPACK_BUFFER;
|
||||
bits: Integer): LongInt; cdecl;
|
||||
|
||||
oggpack_read1_t = function(var b: OGGPACK_BUFFER): LongInt; cdecl;
|
||||
|
||||
oggpack_bytes_t = function(var b: OGGPACK_BUFFER): LongInt; cdecl;
|
||||
|
||||
oggpack_bits_t = function(var b: OGGPACK_BUFFER): LongInt; cdecl;
|
||||
|
||||
oggpack_get_buffer_t = function(var b: OGGPACK_BUFFER): PByte; cdecl;
|
||||
|
||||
// Ogg BITSTREAM PRIMITIVES: encoding
|
||||
|
||||
ogg_stream_packetin_t = function(var os: OGG_STREAM_STATE;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
ogg_stream_pageout_t = function(var os: OGG_STREAM_STATE;
|
||||
var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_stream_flush_t = function(var os: OGG_STREAM_STATE;
|
||||
var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
// Ogg BITSTREAM PRIMITIVES: decoding
|
||||
|
||||
ogg_sync_init_t = function(var oy: OGG_SYNC_STATE): Integer; cdecl;
|
||||
|
||||
ogg_sync_clear_t = function(var oy: OGG_SYNC_STATE): Integer; cdecl;
|
||||
|
||||
ogg_sync_reset_t = function(var oy: OGG_SYNC_STATE): Integer; cdecl;
|
||||
|
||||
ogg_sync_destroy_t = function(var oy: OGG_SYNC_STATE): Integer; cdecl;
|
||||
|
||||
ogg_sync_buffer_t = function(var oy: OGG_SYNC_STATE;
|
||||
size: LongInt): PChar; cdecl;
|
||||
|
||||
ogg_sync_wrote_t = function(var oy: OGG_SYNC_STATE;
|
||||
bytes: LongInt): Integer; cdecl;
|
||||
|
||||
ogg_sync_pageseek_t = function(var oy: OGG_SYNC_STATE;
|
||||
var og: OGG_PAGE): LongInt; cdecl;
|
||||
|
||||
ogg_sync_pageout_t = function(var oy: OGG_SYNC_STATE;
|
||||
var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_stream_pagein_t = function(var os: OGG_STREAM_STATE;
|
||||
var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_stream_packetout_t = function(var os: OGG_STREAM_STATE;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
ogg_stream_packetpeek_t = function(var os: OGG_STREAM_STATE;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
|
||||
// Ogg BITSTREAM PRIMITIVES: general
|
||||
|
||||
ogg_stream_init_t = function(var os: OGG_STREAM_STATE;
|
||||
serialno: Integer): Integer; cdecl;
|
||||
|
||||
ogg_stream_clear_t = function(var os: OGG_STREAM_STATE): Integer; cdecl;
|
||||
|
||||
ogg_stream_reset_t = function(var os: OGG_STREAM_STATE): Integer; cdecl;
|
||||
|
||||
ogg_stream_destroy_t = function(var os: OGG_STREAM_STATE): Integer; cdecl;
|
||||
|
||||
ogg_stream_eos_t = function(var os: OGG_STREAM_STATE): Integer; cdecl;
|
||||
|
||||
ogg_page_checksum_set_t = procedure(var og: OGG_PAGE); cdecl;
|
||||
|
||||
ogg_page_version_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_page_continued_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_page_bos_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_page_eos_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_page_granulepos_t = function(var og: OGG_PAGE): OGG_INT64_T; cdecl;
|
||||
|
||||
ogg_page_serialno_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_page_pageno_t = function(var og: OGG_PAGE): LongInt; cdecl;
|
||||
|
||||
ogg_page_packets_t = function(var og: OGG_PAGE): Integer; cdecl;
|
||||
|
||||
ogg_packet_clear_t = procedure(var op: OGG_PACKET); cdecl;
|
||||
|
||||
var
|
||||
|
||||
ogg_stream_init : ogg_stream_init_t;
|
||||
|
||||
ogg_stream_clear : ogg_stream_clear_t;
|
||||
|
||||
ogg_stream_reset : ogg_stream_reset_t;
|
||||
|
||||
ogg_stream_destroy : ogg_stream_destroy_t;
|
||||
|
||||
ogg_stream_eos : ogg_stream_eos_t;
|
||||
|
||||
ogg_page_checksum_set : ogg_page_checksum_set_t;
|
||||
|
||||
ogg_page_version : ogg_page_version_t;
|
||||
|
||||
ogg_page_continued : ogg_page_continued_t;
|
||||
|
||||
ogg_page_bos : ogg_page_bos_t;
|
||||
|
||||
ogg_page_eos : ogg_page_eos_t;
|
||||
|
||||
ogg_page_granulepos : ogg_page_granulepos_t;
|
||||
|
||||
ogg_page_serialno : ogg_page_serialno_t;
|
||||
|
||||
ogg_page_pageno : ogg_page_pageno_t;
|
||||
|
||||
ogg_page_packets : ogg_page_packets_t;
|
||||
|
||||
ogg_packet_clear : ogg_packet_clear_t;
|
||||
|
||||
oggpack_writeinit : oggpack_writeinit_t;
|
||||
|
||||
oggpack_reset : oggpack_reset_t;
|
||||
|
||||
oggpack_writeclear : oggpack_writeclear_t;
|
||||
|
||||
oggpack_readinit : oggpack_readinit_t;
|
||||
|
||||
oggpack_write : oggpack_write_t;
|
||||
|
||||
oggpack_look : oggpack_look_t;
|
||||
|
||||
oggpack_look_huff : oggpack_look_huff_t;
|
||||
|
||||
oggpack_look1 : oggpack_look1_t;
|
||||
|
||||
oggpack_adv : oggpack_adv_t;
|
||||
|
||||
oggpack_adv_huff : oggpack_adv_huff_t;
|
||||
|
||||
oggpack_adv1 : oggpack_adv1_t;
|
||||
|
||||
oggpack_read : oggpack_read_t;
|
||||
|
||||
oggpack_read1 : oggpack_read1_t;
|
||||
|
||||
oggpack_bytes : oggpack_bytes_t;
|
||||
|
||||
oggpack_bits : oggpack_bits_t;
|
||||
|
||||
oggpack_get_buffer : oggpack_get_buffer_t;
|
||||
|
||||
ogg_stream_packetin : ogg_stream_packetin_t;
|
||||
|
||||
ogg_stream_pageout : ogg_stream_pageout_t;
|
||||
|
||||
ogg_stream_flush : ogg_stream_flush_t;
|
||||
|
||||
ogg_sync_init : ogg_sync_init_t;
|
||||
|
||||
ogg_sync_clear : ogg_sync_clear_t;
|
||||
|
||||
ogg_sync_reset : ogg_sync_reset_t;
|
||||
|
||||
ogg_sync_destroy : ogg_sync_destroy_t;
|
||||
|
||||
ogg_sync_buffer : ogg_sync_buffer_t;
|
||||
|
||||
ogg_sync_wrote : ogg_sync_wrote_t;
|
||||
|
||||
ogg_sync_pageseek : ogg_sync_pageseek_t;
|
||||
|
||||
ogg_sync_pageout : ogg_sync_pageout_t;
|
||||
|
||||
ogg_stream_pagein : ogg_stream_pagein_t;
|
||||
|
||||
ogg_stream_packetout : ogg_stream_packetout_t;
|
||||
|
||||
ogg_stream_packetpeek : ogg_stream_packetpeek_t;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(LiboggPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(LiboggPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
LiboggLoaded := True;
|
||||
ogg_stream_init := dlsym(Libhandle, 'ogg_stream_init');
|
||||
ogg_stream_clear := dlsym(Libhandle, 'ogg_stream_clear');
|
||||
ogg_stream_reset := dlsym(Libhandle, 'ogg_stream_reset');
|
||||
ogg_stream_destroy := dlsym(Libhandle, 'ogg_stream_destroy');
|
||||
ogg_stream_eos := dlsym(Libhandle, 'ogg_stream_eos');
|
||||
ogg_page_checksum_set := dlsym(Libhandle, 'ogg_page_checksum_set');
|
||||
ogg_page_version := dlsym(Libhandle, 'ogg_page_version');
|
||||
ogg_page_continued := dlsym(Libhandle, 'ogg_page_continued');
|
||||
ogg_page_bos := dlsym(Libhandle, 'ogg_page_bos');
|
||||
ogg_page_eos := dlsym(Libhandle, 'ogg_page_eos');
|
||||
ogg_page_granulepos := dlsym(Libhandle, 'ogg_page_granulepos');
|
||||
ogg_page_serialno := dlsym(Libhandle, 'ogg_page_serialno');
|
||||
ogg_page_pageno := dlsym(Libhandle, 'ogg_page_pageno');
|
||||
ogg_page_packets := dlsym(Libhandle, 'ogg_page_packets');
|
||||
ogg_packet_clear := dlsym(Libhandle, 'ogg_packet_clear');
|
||||
oggpack_writeinit := dlsym(Libhandle, 'oggpack_writeinit');
|
||||
oggpack_reset := dlsym(Libhandle, 'oggpack_reset');
|
||||
oggpack_writeclear := dlsym(Libhandle, 'oggpack_writeclear');
|
||||
oggpack_readinit := dlsym(Libhandle, 'oggpack_readinit');
|
||||
oggpack_write := dlsym(Libhandle, 'oggpack_write');
|
||||
oggpack_look := dlsym(Libhandle, 'oggpack_look');
|
||||
oggpack_look_huff := dlsym(Libhandle, 'oggpack_look_huff');
|
||||
oggpack_look1 := dlsym(Libhandle, 'oggpack_look1');
|
||||
oggpack_adv := dlsym(Libhandle, 'oggpack_adv');
|
||||
oggpack_adv_huff := dlsym(Libhandle, 'oggpack_adv_huff');
|
||||
oggpack_adv1 := dlsym(Libhandle, 'oggpack_adv1');
|
||||
oggpack_read := dlsym(Libhandle, 'oggpack_read');
|
||||
oggpack_read1 := dlsym(Libhandle, 'oggpack_read1');
|
||||
oggpack_bytes := dlsym(Libhandle, 'oggpack_bytes');
|
||||
oggpack_bits := dlsym(Libhandle, 'oggpack_bits');
|
||||
oggpack_get_buffer := dlsym(Libhandle, 'oggpack_get_buffer');
|
||||
ogg_stream_packetin := dlsym(Libhandle, 'ogg_stream_packetin');
|
||||
ogg_stream_pageout := dlsym(Libhandle, 'ogg_stream_pageout');
|
||||
ogg_stream_flush := dlsym(Libhandle, 'ogg_stream_flush');
|
||||
ogg_sync_init := dlsym(Libhandle, 'ogg_sync_init');
|
||||
ogg_sync_clear := dlsym(Libhandle, 'ogg_sync_clear');
|
||||
ogg_sync_reset := dlsym(Libhandle, 'ogg_sync_reset');
|
||||
ogg_sync_destroy := dlsym(Libhandle, 'ogg_sync_destroy');
|
||||
ogg_sync_buffer := dlsym(Libhandle, 'ogg_sync_buffer');
|
||||
ogg_sync_wrote := dlsym(Libhandle, 'ogg_sync_wrote');
|
||||
ogg_sync_pageseek := dlsym(Libhandle, 'ogg_sync_pageseek');
|
||||
ogg_sync_pageout := dlsym(Libhandle, 'ogg_sync_pageout');
|
||||
ogg_stream_pagein := dlsym(Libhandle, 'ogg_stream_pagein');
|
||||
ogg_stream_packetout := dlsym(Libhandle, 'ogg_stream_packetout');
|
||||
ogg_stream_packetpeek := dlsym(Libhandle, 'ogg_stream_packetpeek');
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
Libhandle := LoadLibraryEx(LiboggPath, 0, 0);
|
||||
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LiboggLoaded := True;
|
||||
ogg_stream_init := GetProcAddress(Libhandle, 'ogg_stream_init');
|
||||
ogg_stream_clear := GetProcAddress(Libhandle, 'ogg_stream_clear');
|
||||
ogg_stream_reset := GetProcAddress(Libhandle, 'ogg_stream_reset');
|
||||
ogg_stream_destroy := GetProcAddress(Libhandle, 'ogg_stream_destroy');
|
||||
ogg_stream_eos := GetProcAddress(Libhandle, 'ogg_stream_eos');
|
||||
ogg_page_checksum_set := GetProcAddress(Libhandle, 'ogg_page_checksum_set');
|
||||
ogg_page_version := GetProcAddress(Libhandle, 'ogg_page_version');
|
||||
ogg_page_continued := GetProcAddress(Libhandle, 'ogg_page_continued');
|
||||
ogg_page_bos := GetProcAddress(Libhandle, 'ogg_page_bos');
|
||||
ogg_page_eos := GetProcAddress(Libhandle, 'ogg_page_eos');
|
||||
ogg_page_granulepos := GetProcAddress(Libhandle, 'ogg_page_granulepos');
|
||||
ogg_page_serialno := GetProcAddress(Libhandle, 'ogg_page_serialno');
|
||||
ogg_page_pageno := GetProcAddress(Libhandle, 'ogg_page_pageno');
|
||||
ogg_page_packets := GetProcAddress(Libhandle, 'ogg_page_packets');
|
||||
ogg_packet_clear := GetProcAddress(Libhandle, 'ogg_packet_clear');
|
||||
oggpack_writeinit := GetProcAddress(Libhandle, 'oggpack_writeinit');
|
||||
oggpack_reset := GetProcAddress(Libhandle, 'oggpack_reset');
|
||||
oggpack_writeclear := GetProcAddress(Libhandle, 'oggpack_writeclear');
|
||||
oggpack_readinit := GetProcAddress(Libhandle, 'oggpack_readinit');
|
||||
oggpack_write := GetProcAddress(Libhandle, 'oggpack_write');
|
||||
oggpack_look := GetProcAddress(Libhandle, 'oggpack_look');
|
||||
oggpack_look_huff := GetProcAddress(Libhandle, 'oggpack_look_huff');
|
||||
oggpack_look1 := GetProcAddress(Libhandle, 'oggpack_look1');
|
||||
oggpack_adv := GetProcAddress(Libhandle, 'oggpack_adv');
|
||||
oggpack_adv_huff := GetProcAddress(Libhandle, 'oggpack_adv_huff');
|
||||
oggpack_adv1 := GetProcAddress(Libhandle, 'oggpack_adv1');
|
||||
oggpack_read := GetProcAddress(Libhandle, 'oggpack_read');
|
||||
oggpack_read1 := GetProcAddress(Libhandle, 'oggpack_read1');
|
||||
oggpack_bytes := GetProcAddress(Libhandle, 'oggpack_bytes');
|
||||
oggpack_bits := GetProcAddress(Libhandle, 'oggpack_bits');
|
||||
oggpack_get_buffer := GetProcAddress(Libhandle, 'oggpack_get_buffer');
|
||||
ogg_stream_packetin := GetProcAddress(Libhandle, 'ogg_stream_packetin');
|
||||
ogg_stream_pageout := GetProcAddress(Libhandle, 'ogg_stream_pageout');
|
||||
ogg_stream_flush := GetProcAddress(Libhandle, 'ogg_stream_flush');
|
||||
ogg_sync_init := GetProcAddress(Libhandle, 'ogg_sync_init');
|
||||
ogg_sync_clear := GetProcAddress(Libhandle, 'ogg_sync_clear');
|
||||
ogg_sync_reset := GetProcAddress(Libhandle, 'ogg_sync_reset');
|
||||
ogg_sync_destroy := GetProcAddress(Libhandle, 'ogg_sync_destroy');
|
||||
ogg_sync_buffer := GetProcAddress(Libhandle, 'ogg_sync_buffer');
|
||||
ogg_sync_wrote := GetProcAddress(Libhandle, 'ogg_sync_wrote');
|
||||
ogg_sync_pageseek := GetProcAddress(Libhandle, 'ogg_sync_pageseek');
|
||||
ogg_sync_pageout := GetProcAddress(Libhandle, 'ogg_sync_pageout');
|
||||
ogg_stream_pagein := GetProcAddress(Libhandle, 'ogg_stream_pagein');
|
||||
ogg_stream_packetout := GetProcAddress(Libhandle, 'ogg_stream_packetout');
|
||||
ogg_stream_packetpeek := GetProcAddress(Libhandle, 'ogg_stream_packetpeek');
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
480
acs/Src/fileformats/general/vorbiscodec.pas
Normal file
480
acs/Src/fileformats/general/vorbiscodec.pas
Normal file
@@ -0,0 +1,480 @@
|
||||
(*
|
||||
delphi/kylix headers for oggvorbis software codec.
|
||||
translated from codec.h header
|
||||
by andrei borovsky, acs@compiler4.net
|
||||
the original c/c++ headers and libraries (c) copyright 1994-2001
|
||||
by the xiphophorus company http://www.xiph.org/
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: vorbiscodec.pas,v $
|
||||
Revision 1.1 2005/12/29 20:46:00 z0m3ie
|
||||
fixed some problems with vorbis in lazarus
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF WIN32}
|
||||
{$PACKRECORDS C}
|
||||
{$ENDIF WIN32}
|
||||
{$ENDIF WIN32}
|
||||
|
||||
unit vorbiscodec;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_Procs,
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl,
|
||||
{$ENDIF}
|
||||
{$IFDEF WIN32}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
ogg;
|
||||
|
||||
type
|
||||
|
||||
PVORBIS_INFO = ^VORBIS_INFO;
|
||||
|
||||
VORBIS_INFO = record
|
||||
version: Integer;
|
||||
channels: Integer;
|
||||
rate: LongInt;
|
||||
|
||||
(* The below bitrate declarations are *hints*.
|
||||
Combinations of the three values carry the following implications:
|
||||
all three set to the same value:
|
||||
implies a fixed rate bitstream
|
||||
only nominal set:
|
||||
implies a VBR stream that averages the nominal bitrate. No hard
|
||||
upper/lower limit
|
||||
upper and or lower set:
|
||||
implies a VBR bitstream that obeys the bitrate limits. nominal
|
||||
may also be set to give a nominal rate.
|
||||
none set:
|
||||
the coder does not care to speculate. *)
|
||||
|
||||
bitrate_upper: LongInt;
|
||||
bitrate_nominal: LongInt;
|
||||
bitrate_lower: LongInt;
|
||||
bitrate_window: LongInt;
|
||||
codec_setup: Pointer;
|
||||
end;
|
||||
|
||||
(* vorbis_dsp_state buffers the current vorbis audio
|
||||
analysis/synthesis state. The DSP state belongs to a specific
|
||||
logical bitstream *)
|
||||
|
||||
PVORBIS_DSP_STATE = ^VORBIS_DSP_STATE;
|
||||
|
||||
VORBIS_DSP_STATE = record
|
||||
analysisp: Integer;
|
||||
vi: PVORBIS_INFO;
|
||||
pcm: PPFLOAT;
|
||||
pcmret: PPFLOAT;
|
||||
pcm_storage: Integer;
|
||||
pcm_current: Integer;
|
||||
pcm_returned: Integer;
|
||||
preextrapolate: Integer;
|
||||
eofflag: Integer;
|
||||
lW: LongInt;
|
||||
W: LongInt;
|
||||
nW: LongInt;
|
||||
centerW: LongInt;
|
||||
granulepos: OGG_INT64_T;
|
||||
sequence: OGG_INT64_T;
|
||||
glue_bits: OGG_INT64_T;
|
||||
time_bits: OGG_INT64_T;
|
||||
floor_bits: OGG_INT64_T;
|
||||
res_bits: OGG_INT64_T;
|
||||
backend_state: Pointer;
|
||||
end;
|
||||
|
||||
PALLOC_CHAIN = ^ALLOC_CHAIN;
|
||||
|
||||
ALLOC_CHAIN = record
|
||||
ptr: Pointer;
|
||||
next: PALLOC_CHAIN;
|
||||
end;
|
||||
|
||||
|
||||
VORBIS_BLOCK = record
|
||||
// necessary stream state for linking to the framing abstraction
|
||||
pcm: PPFLOAT;
|
||||
// this is a pointer into local storage
|
||||
opb: OGGPACK_BUFFER;
|
||||
lW: LongInt;
|
||||
W: LongInt;
|
||||
nW: LongInt;
|
||||
pcmend: Integer;
|
||||
mode: Integer;
|
||||
eofflag: Integer;
|
||||
granulepos: OGG_INT64_T;
|
||||
sequence: OGG_INT64_T;
|
||||
vd: PVORBIS_DSP_STATE; // For read-only access of configuration
|
||||
(* local storage to avoid remallocing; it's up to the mapping to
|
||||
structure it *)
|
||||
localstore: Pointer;
|
||||
localtop: LongInt;
|
||||
localalloc: LongInt;
|
||||
totaluse: LongInt;
|
||||
reap: PALLOC_CHAIN;
|
||||
// bitmetrics for the frame
|
||||
glue_bits: LongInt;
|
||||
time_bits: LongInt;
|
||||
floor_bits: LongInt;
|
||||
res_bits: LongInt;
|
||||
internal: Pointer;
|
||||
end;
|
||||
|
||||
(* vorbis_block is a single block of data to be processed as part of
|
||||
the analysis/synthesis stream; it belongs to a specific logical
|
||||
bitstream, but is independant from other vorbis_blocks belonging to
|
||||
that logical bitstream. *)
|
||||
|
||||
(* vorbis_info contains all the setup information specific to the
|
||||
specific compression/decompression mode in progress (eg,
|
||||
psychoacoustic settings, channel setup, options, codebook
|
||||
etc). vorbis_info and substructures are in backends.h. *)
|
||||
|
||||
(* the comments are not part of vorbis_info so that vorbis_info can be
|
||||
static storage *)
|
||||
|
||||
PVORBIS_COMMENT = ^VORBIS_COMMENT;
|
||||
|
||||
VORBIS_COMMENT = record
|
||||
(* unlimited user comment fields. libvorbis writes 'libvorbis'
|
||||
whatever vendor is set to in encode *)
|
||||
user_comments: PPChar;
|
||||
comment_lengths: PInteger;
|
||||
comments: Integer;
|
||||
vendor: PChar;
|
||||
end;
|
||||
|
||||
(* libvorbis encodes in two abstraction layers; first we perform DSP
|
||||
and produce a packet (see docs/analysis.txt). The packet is then
|
||||
coded into a framed OggSquish bitstream by the second layer (see
|
||||
docs/framing.txt). Decode is the reverse process; we sync/frame
|
||||
the bitstream and extract individual packets, then decode the
|
||||
packet back into PCM audio. *)
|
||||
|
||||
(* The extra framing/packetizing is used in streaming formats, such as
|
||||
files. Over the net (such as with UDP), the framing and
|
||||
packetization aren't necessary as they're provided by the transport
|
||||
and the streaming layer is not used *)
|
||||
|
||||
// Vorbis PRIMITIVES: general
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF LINUX}
|
||||
LibvorbisPath = 'libvorbis.so*'; //'/usr/lib/libvorbis.so';
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
LibvorbisPath = 'vorbis.dll';
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
LibvorbisLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
vorbis_info_init_t = procedure(var vi: VORBIS_INFO); cdecl;
|
||||
|
||||
vorbis_info_clear_t = procedure(var vi: VORBIS_INFO); cdecl;
|
||||
|
||||
vorbis_info_blocksize_t = function(var vi: VORBIS_INFO;
|
||||
zo: Integer): Integer; cdecl;
|
||||
|
||||
vorbis_comment_init_t = procedure(var vc: VORBIS_COMMENT); cdecl;
|
||||
|
||||
vorbis_comment_add_t = procedure(var vc: VORBIS_COMMENT;
|
||||
comment: PChar); cdecl;
|
||||
|
||||
vorbis_comment_add_tag_t = procedure(var vc: VORBIS_COMMENT;
|
||||
tag: PChar;
|
||||
contents: PChar); cdecl;
|
||||
|
||||
vorbis_comment_query_t = function(var vc: VORBIS_COMMENT;
|
||||
tag: PChar;
|
||||
count: Integer): PChar; cdecl;
|
||||
|
||||
vorbis_comment_query_count_t = function(var vc: VORBIS_COMMENT;
|
||||
tag: PChar): Integer; cdecl;
|
||||
|
||||
vorbis_comment_clear_t = procedure(var vc: VORBIS_COMMENT) cdecl;
|
||||
|
||||
vorbis_block_init_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vb: VORBIS_BLOCK): Integer; cdecl;
|
||||
|
||||
vorbis_block_clear_t = function(var vb: VORBIS_BLOCK): Integer; cdecl;
|
||||
|
||||
vorbis_dsp_clear_t = procedure(var v: VORBIS_DSP_STATE); cdecl;
|
||||
|
||||
// Vorbis PRIMITIVES: analysis/DSP layer
|
||||
|
||||
vorbis_analysis_init_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vi: VORBIS_INFO): Integer; cdecl;
|
||||
|
||||
vorbis_commentheader_out_t = function(var vc: VORBIS_COMMENT;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
vorbis_analysis_headerout_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vc: VORBIS_COMMENT;
|
||||
var op: OGG_PACKET;
|
||||
var op_comm: OGG_PACKET;
|
||||
var op_code: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
vorbis_analysis_buffer_t = function(var v: VORBIS_DSP_STATE;
|
||||
vals: Integer): PPFLOAT; cdecl;
|
||||
|
||||
vorbis_analysis_wrote_t = function(var v: VORBIS_DSP_STATE;
|
||||
vals: Integer): Integer; cdecl;
|
||||
|
||||
vorbis_analysis_blockout_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vb: VORBIS_BLOCK): Integer; cdecl;
|
||||
|
||||
vorbis_analysis_t = function(var vb: VORBIS_BLOCK;
|
||||
op: POGG_PACKET): Integer; cdecl;
|
||||
|
||||
vorbis_bitrate_addblock_t = function(var vb: VORBIS_BLOCK): Integer; cdecl;
|
||||
|
||||
vorbis_bitrate_flushpacket_t = function(var vd: VORBIS_DSP_STATE;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
// Vorbis PRIMITIVES: synthesis layer
|
||||
|
||||
vorbis_synthesis_headerin_t = function(var vi: VORBIS_INFO;
|
||||
var vc: VORBIS_COMMENT;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
vorbis_synthesis_init_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vi: VORBIS_INFO): Integer; cdecl;
|
||||
|
||||
vorbis_synthesis_t = function(var vb: VORBIS_BLOCK;
|
||||
var op: OGG_PACKET): Integer; cdecl;
|
||||
|
||||
vorbis_synthesis_blockin_t = function(var v: VORBIS_DSP_STATE;
|
||||
var vb: VORBIS_BLOCK): Integer; cdecl;
|
||||
|
||||
vorbis_synthesis_pcmout_t = function(var v: VORBIS_DSP_STATE;
|
||||
var pcm: PPFLOAT): Integer; cdecl;
|
||||
|
||||
vorbis_synthesis_read_t = function(var v: VORBIS_DSP_STATE;
|
||||
samples: Integer): Integer; cdecl;
|
||||
|
||||
vorbis_packet_blocksize_t = function(var vi: VORBIS_INFO;
|
||||
var op: OGG_PACKET): LongInt; cdecl;
|
||||
var
|
||||
|
||||
vorbis_info_init : vorbis_info_init_t;
|
||||
|
||||
vorbis_info_clear : vorbis_info_clear_t;
|
||||
|
||||
vorbis_info_blocksize : vorbis_info_blocksize_t;
|
||||
|
||||
vorbis_comment_init : vorbis_comment_init_t;
|
||||
|
||||
vorbis_comment_add : vorbis_comment_add_t;
|
||||
|
||||
vorbis_comment_add_tag : vorbis_comment_add_tag_t;
|
||||
|
||||
vorbis_comment_query : vorbis_comment_query_t;
|
||||
|
||||
vorbis_comment_query_count : vorbis_comment_query_count_t;
|
||||
|
||||
vorbis_comment_clear : vorbis_comment_clear_t;
|
||||
|
||||
vorbis_block_init : vorbis_block_init_t;
|
||||
|
||||
vorbis_block_clear : vorbis_block_clear_t;
|
||||
|
||||
vorbis_dsp_clear : vorbis_dsp_clear_t;
|
||||
|
||||
vorbis_analysis_init : vorbis_analysis_init_t;
|
||||
|
||||
vorbis_commentheader_out : vorbis_commentheader_out_t;
|
||||
|
||||
vorbis_analysis_headerout : vorbis_analysis_headerout_t;
|
||||
|
||||
vorbis_analysis_buffer : vorbis_analysis_buffer_t;
|
||||
|
||||
vorbis_analysis_wrote : vorbis_analysis_wrote_t;
|
||||
|
||||
vorbis_analysis_blockout : vorbis_analysis_blockout_t;
|
||||
|
||||
vorbis_analysis : vorbis_analysis_t;
|
||||
|
||||
vorbis_bitrate_addblock : vorbis_bitrate_addblock_t;
|
||||
|
||||
vorbis_bitrate_flushpacket : vorbis_bitrate_flushpacket_t;
|
||||
|
||||
vorbis_synthesis_headerin : vorbis_synthesis_headerin_t;
|
||||
|
||||
vorbis_synthesis_init : vorbis_synthesis_init_t;
|
||||
|
||||
vorbis_synthesis : vorbis_synthesis_t;
|
||||
|
||||
vorbis_synthesis_blockin : vorbis_synthesis_blockin_t;
|
||||
|
||||
vorbis_synthesis_pcmout : vorbis_synthesis_pcmout_t;
|
||||
|
||||
vorbis_synthesis_read : vorbis_synthesis_read_t;
|
||||
|
||||
vorbis_packet_blocksize : vorbis_packet_blocksize_t;
|
||||
|
||||
// Vorbis ERRORS and return codes
|
||||
|
||||
const
|
||||
|
||||
OV_FALSE = -1;
|
||||
OV_EOF = -2;
|
||||
OV_HOLE = -3;
|
||||
OV_EREAD = -128;
|
||||
OV_EFAULT = -129;
|
||||
OV_EIMPL = -130;
|
||||
OV_EINVAL = -131;
|
||||
OV_ENOTVORBIS = -132;
|
||||
OV_EBADHEADER = -133;
|
||||
OV_EVERSION = -134;
|
||||
OV_ENOTAUDIO = -135;
|
||||
OV_EBADPACKET = -136;
|
||||
OV_EBADLINK = -137;
|
||||
OV_ENOSEEK = -138;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(LibvorbisPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(LibvorbisPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
LibvorbisLoaded := True;
|
||||
vorbis_info_init := dlsym(Libhandle, 'vorbis_info_init');
|
||||
vorbis_info_clear := dlsym(Libhandle, 'vorbis_info_clear');
|
||||
vorbis_info_blocksize := dlsym(Libhandle, 'vorbis_info_blocksize');
|
||||
vorbis_comment_init := dlsym(Libhandle, 'vorbis_comment_init');
|
||||
vorbis_comment_add := dlsym(Libhandle, 'vorbis_comment_add');
|
||||
vorbis_comment_add_tag := dlsym(Libhandle, 'vorbis_comment_add_tag');
|
||||
vorbis_comment_query := dlsym(Libhandle, 'vorbis_comment_query');
|
||||
vorbis_comment_query_count := dlsym(Libhandle, 'vorbis_comment_query_count');
|
||||
vorbis_comment_clear := dlsym(Libhandle, 'vorbis_comment_clear');
|
||||
vorbis_block_init := dlsym(Libhandle, 'vorbis_block_init');
|
||||
vorbis_block_clear := dlsym(Libhandle, 'vorbis_block_clear');
|
||||
vorbis_dsp_clear := dlsym(Libhandle, 'vorbis_dsp_clear');
|
||||
vorbis_analysis_init := dlsym(Libhandle, 'vorbis_analysis_init');
|
||||
vorbis_commentheader_out := dlsym(Libhandle, 'vorbis_commentheader_out');
|
||||
vorbis_analysis_headerout := dlsym(Libhandle, 'vorbis_analysis_headerout');
|
||||
vorbis_analysis_buffer := dlsym(Libhandle, 'vorbis_analysis_buffer');
|
||||
vorbis_analysis_wrote := dlsym(Libhandle, 'vorbis_analysis_wrote');
|
||||
vorbis_analysis_blockout := dlsym(Libhandle, 'vorbis_analysis_blockout');
|
||||
vorbis_analysis := dlsym(Libhandle, 'vorbis_analysis');
|
||||
vorbis_bitrate_addblock := dlsym(Libhandle, 'vorbis_bitrate_addblock');
|
||||
vorbis_bitrate_flushpacket := dlsym(Libhandle, 'vorbis_bitrate_flushpacket');
|
||||
vorbis_synthesis_headerin := dlsym(Libhandle, 'vorbis_synthesis_headerin');
|
||||
vorbis_synthesis_init := dlsym(Libhandle, 'vorbis_synthesis_init');
|
||||
vorbis_synthesis := dlsym(Libhandle, 'vorbis_synthesis');
|
||||
vorbis_synthesis_blockin := dlsym(Libhandle, 'vorbis_synthesis_blockin');
|
||||
vorbis_synthesis_pcmout := dlsym(Libhandle, 'vorbis_synthesis_pcmout');
|
||||
vorbis_synthesis_read := dlsym(Libhandle, 'vorbis_synthesis_read');
|
||||
vorbis_packet_blocksize := dlsym(Libhandle, 'vorbis_packet_blocksize');
|
||||
end;
|
||||
|
||||
finalization
|
||||
if libhandle <> nil then dlclose(libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(LibvorbisPath, 0, 0);
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LibvorbisLoaded := True;
|
||||
vorbis_info_init := GetProcAddress(Libhandle, 'vorbis_info_init');
|
||||
vorbis_info_clear := GetProcAddress(Libhandle, 'vorbis_info_clear');
|
||||
vorbis_info_blocksize := GetProcAddress(Libhandle, 'vorbis_info_blocksize');
|
||||
vorbis_comment_init := GetProcAddress(Libhandle, 'vorbis_comment_init');
|
||||
vorbis_comment_add := GetProcAddress(Libhandle, 'vorbis_comment_add');
|
||||
vorbis_comment_add_tag := GetProcAddress(Libhandle, 'vorbis_comment_add_tag');
|
||||
vorbis_comment_query := GetProcAddress(Libhandle, 'vorbis_comment_query');
|
||||
vorbis_comment_query_count := GetProcAddress(Libhandle, 'vorbis_comment_query_count');
|
||||
vorbis_comment_clear := GetProcAddress(Libhandle, 'vorbis_comment_clear');
|
||||
vorbis_block_init := GetProcAddress(Libhandle, 'vorbis_block_init');
|
||||
vorbis_block_clear := GetProcAddress(Libhandle, 'vorbis_block_clear');
|
||||
vorbis_dsp_clear := GetProcAddress(Libhandle, 'vorbis_dsp_clear');
|
||||
vorbis_analysis_init := GetProcAddress(Libhandle, 'vorbis_analysis_init');
|
||||
vorbis_commentheader_out := GetProcAddress(Libhandle, 'vorbis_commentheader_out');
|
||||
vorbis_analysis_headerout := GetProcAddress(Libhandle, 'vorbis_analysis_headerout');
|
||||
vorbis_analysis_buffer := GetProcAddress(Libhandle, 'vorbis_analysis_buffer');
|
||||
vorbis_analysis_wrote := GetProcAddress(Libhandle, 'vorbis_analysis_wrote');
|
||||
vorbis_analysis_blockout := GetProcAddress(Libhandle, 'vorbis_analysis_blockout');
|
||||
vorbis_analysis := GetProcAddress(Libhandle, 'vorbis_analysis');
|
||||
vorbis_bitrate_addblock := GetProcAddress(Libhandle, 'vorbis_bitrate_addblock');
|
||||
vorbis_bitrate_flushpacket := GetProcAddress(Libhandle, 'vorbis_bitrate_flushpacket');
|
||||
vorbis_synthesis_headerin := GetProcAddress(Libhandle, 'vorbis_synthesis_headerin');
|
||||
vorbis_synthesis_init := GetProcAddress(Libhandle, 'vorbis_synthesis_init');
|
||||
vorbis_synthesis := GetProcAddress(Libhandle, 'vorbis_synthesis');
|
||||
vorbis_synthesis_blockin := GetProcAddress(Libhandle, 'vorbis_synthesis_blockin');
|
||||
vorbis_synthesis_pcmout := GetProcAddress(Libhandle, 'vorbis_synthesis_pcmout');
|
||||
vorbis_synthesis_read := GetProcAddress(Libhandle, 'vorbis_synthesis_read');
|
||||
vorbis_packet_blocksize := GetProcAddress(Libhandle, 'vorbis_packet_blocksize');
|
||||
end;
|
||||
|
||||
finalization
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end.
|
199
acs/Src/fileformats/general/vorbisenc.pas
Normal file
199
acs/Src/fileformats/general/vorbisenc.pas
Normal file
@@ -0,0 +1,199 @@
|
||||
(*
|
||||
delphi/kylix headers for oggvorbis software codec.
|
||||
translated from vorbisenc.h header
|
||||
by andrei borovsky, acs@compiler4.net
|
||||
the original c/c++ headers and libraries (c) copyright 1994-2001
|
||||
by the xiphophorus company http://www.xiph.org/
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: vorbisenc.pas,v $
|
||||
Revision 1.2 2005/12/29 20:46:00 z0m3ie
|
||||
fixed some problems with vorbis in lazarus
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
|
||||
unit vorbisenc;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_Procs,
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl,
|
||||
{$ENDIF}
|
||||
{$IFDEF WIN32}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
|
||||
vorbiscodec;
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF LINUX}
|
||||
LibvorbisencPath = 'libvorbisenc.so*'; //'/usr/lib/libvorbisenc.so';
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
LibvorbisencPath = 'vorbisenc.dll';
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
OV_ECTL_RATEMANAGE2_GET = $14;
|
||||
OV_ECTL_RATEMANAGE2_SET = $15;
|
||||
|
||||
|
||||
var
|
||||
LibvorbisencLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
vorbis_encode_init_t = function(var vi: VORBIS_INFO;
|
||||
channels: LongInt;
|
||||
rate: LongInt;
|
||||
max_bitrate: LongInt;
|
||||
nominal_bitrate: LongInt;
|
||||
min_bitrate: LongInt): Integer cdecl;
|
||||
|
||||
vorbis_encode_setup_managed_t = function(var vi: VORBIS_INFO;
|
||||
channels: LongInt;
|
||||
rate: LongInt;
|
||||
max_bitrate: LongInt;
|
||||
nominal_bitrate: LongInt;
|
||||
min_bitrate: LongInt): Integer; cdecl;
|
||||
|
||||
vorbis_encode_setup_vbr_t = function(var vi: VORBIS_INFO;
|
||||
channels: LongInt;
|
||||
rate: LongInt;
|
||||
fl: Single): Integer; cdecl;
|
||||
|
||||
vorbis_encode_init_vbr_t = function(var vi: VORBIS_INFO;
|
||||
channels: LongInt;
|
||||
rate: LongInt;
|
||||
base_quality: Single): Integer; cdecl;
|
||||
|
||||
vorbis_encode_setup_init_t = function(var vi: VORBIS_INFO): Integer; cdecl;
|
||||
|
||||
vorbis_encode_ctl_t = function(var vi: VORBIS_INFO;
|
||||
number: Integer;
|
||||
arg: Pointer): Integer; cdecl;
|
||||
|
||||
ovectl_ratemanage2_arg = record
|
||||
management_active : Integer;
|
||||
bitrate_limit_min_kbps : LongWord;
|
||||
bitrate_limit_max_kbps : LongWord;
|
||||
bitrate_limit_reservoir_bits : LongWord;
|
||||
bitrate_limit_reservoir_bias : Double;
|
||||
bitrate_average_kbps : LongWord;
|
||||
bitrate_average_damping : Double;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
|
||||
vorbis_encode_init : vorbis_encode_init_t;
|
||||
|
||||
vorbis_encode_setup_managed : vorbis_encode_setup_managed_t;
|
||||
|
||||
vorbis_encode_setup_vbr : vorbis_encode_setup_vbr_t;
|
||||
|
||||
vorbis_encode_init_vbr : vorbis_encode_init_vbr_t;
|
||||
|
||||
vorbis_encode_setup_init : vorbis_encode_setup_init_t;
|
||||
|
||||
vorbis_encode_ctl : vorbis_encode_ctl_t;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(LibvorbisencPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(LibvorbisencPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
LibvorbisencLoaded := True;
|
||||
vorbis_encode_init := dlsym(Libhandle, 'vorbis_encode_init');
|
||||
vorbis_encode_setup_managed := dlsym(Libhandle, 'vorbis_encode_setup_managed');
|
||||
vorbis_encode_setup_vbr := dlsym(Libhandle, 'vorbis_encode_setup_vbr');
|
||||
vorbis_encode_init_vbr := dlsym(Libhandle, 'vorbis_encode_init_vbr');
|
||||
vorbis_encode_setup_init := dlsym(Libhandle, 'vorbis_encode_setup_init');
|
||||
vorbis_encode_ctl := dlsym(Libhandle, 'vorbis_encode_ctl');
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(LibvorbisencPath, 0, 0);
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LibvorbisencLoaded := True;
|
||||
vorbis_encode_init := GetProcAddress(Libhandle, 'vorbis_encode_init');
|
||||
vorbis_encode_setup_managed := GetProcAddress(Libhandle, 'vorbis_encode_setup_managed');
|
||||
vorbis_encode_setup_vbr := GetProcAddress(Libhandle, 'vorbis_encode_setup_vbr');
|
||||
vorbis_encode_init_vbr := GetProcAddress(Libhandle, 'vorbis_encode_init_vbr');
|
||||
vorbis_encode_setup_init := GetProcAddress(Libhandle, 'vorbis_encode_setup_init');
|
||||
vorbis_encode_ctl := GetProcAddress(Libhandle, 'vorbis_encode_ctl');
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
316
acs/Src/fileformats/general/vorbisfile.pas
Normal file
316
acs/Src/fileformats/general/vorbisfile.pas
Normal file
@@ -0,0 +1,316 @@
|
||||
(*
|
||||
delphi/kylix headers for oggvorbis software codec.
|
||||
translated from vorbisfile.h header
|
||||
by andrei borovsky, acs@compiler4.net
|
||||
the original c/c++ headers and libraries (c) copyright 1994-2001
|
||||
by the xiphophorus company http://www.xiph.org/
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: vorbisfile.pas,v $
|
||||
Revision 1.2 2005/12/29 20:46:00 z0m3ie
|
||||
fixed some problems with vorbis in lazarus
|
||||
|
||||
Revision 1.1 2005/12/19 18:36:56 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2005/10/09 19:01:03 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.2 2005/09/10 08:25:40 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF WIN32}
|
||||
{$PACKRECORDS C}
|
||||
{$ENDIF WIN32}
|
||||
{$ENDIF WIN32}
|
||||
|
||||
unit vorbisfile;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
ACS_Procs,
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix,dl,
|
||||
{$ENDIF}
|
||||
{$IFDEF WIN32}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
ogg,
|
||||
vorbiscodec,
|
||||
dynlibs;
|
||||
|
||||
(* The function prototypes for the callbacks are basically the same as for
|
||||
the stdio functions fread, fseek, fclose, ftell.
|
||||
The one difference is that the FILE* arguments have been replaced with
|
||||
a void* - this is to be used as a pointer to whatever internal data these
|
||||
functions might need. In the stdio case, it's just a FILE* cast to a void*
|
||||
|
||||
If you use other functions, check the docs for these functions and return
|
||||
the right values. For seek_func(), you*MUST* return -1 if the stream is
|
||||
unseekable *)
|
||||
|
||||
type
|
||||
|
||||
read_func_t = function(ptr : Pointer; size, nmemb : Cardinal;const datasource : Pointer) : Cardinal; cdecl;
|
||||
seek_func_t = function(const datasource : Pointer; offset : ogg_int64_t; whence : Integer) : Integer; cdecl;
|
||||
close_func_t = function(const datasource : Pointer) : Integer; cdecl;
|
||||
tell_func_t = function(const datasource : Pointer) : Integer; cdecl;
|
||||
|
||||
OV_CALLBACKS = record
|
||||
read_func : read_func_t;
|
||||
seek_func : seek_func_t;
|
||||
close_func : close_func_t;
|
||||
tell_func : tell_func_t;
|
||||
end;
|
||||
|
||||
const
|
||||
|
||||
NOTOPEN = 0;
|
||||
PARTOPEN = 1;
|
||||
OPENED = 2;
|
||||
STREAMSET = 3;
|
||||
INITSET = 4;
|
||||
|
||||
type
|
||||
|
||||
OGGVORBIS_FILE = record
|
||||
datasource: Pointer; // Pointer to a FILE*, etc.
|
||||
seekable: Integer;
|
||||
offset: OGG_INT64_T;
|
||||
_end: OGG_INT64_T;
|
||||
oy: OGG_SYNC_STATE;
|
||||
(* If the FILE handle isn't seekable (eg, a pipe),
|
||||
only the current stream appears *)
|
||||
links: Integer;
|
||||
offsets: POGG_INT64_T;
|
||||
dataoffsets: POGG_INT64_T;
|
||||
serialnos: PLongInt;
|
||||
pcmlengths: POGG_INT64_T;
|
||||
vi: PVORBIS_INFO;
|
||||
vc: PVORBIS_COMMENT;
|
||||
// Decoding working state local storage
|
||||
pcm_offset: OGG_INT64_T;
|
||||
ready_state: Integer;
|
||||
current_serialno: LongInt;
|
||||
current_link: Integer;
|
||||
bittrack: Double;
|
||||
samptrack: Double;
|
||||
os: OGG_STREAM_STATE;
|
||||
(* take physical pages, weld into a logical
|
||||
stream of packets *)
|
||||
vd: VORBIS_DSP_STATE;
|
||||
// central working state for the packet->PCM decoder
|
||||
vb: VORBIS_BLOCK;
|
||||
// local working space for packet->PCM decode
|
||||
callbacks: OV_CALLBACKS;
|
||||
end;
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF LINUX}
|
||||
LibvorbisfilePath = 'libvorbisfile.so*'; //'/usr/lib/libvorbisfile.so';
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
{$IFDEF WINDOWS}
|
||||
LibvorbisfilePath = 'vorbisfile.dll';
|
||||
{$ENDIF}
|
||||
|
||||
// stdio.h constants
|
||||
SEEK_CUR = 1;
|
||||
SEEK_END = 2;
|
||||
SEEK_SET = 0;
|
||||
|
||||
var
|
||||
LibvorbisfileLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
{$IFDEF LINUX}
|
||||
ov_open_t = function(f: Pointer;var vf: OGGVORBIS_FILE;initial: PChar;ibytes: LongInt): Integer; cdecl;
|
||||
ov_test_t = function(f: Pointer;var vf: OGGVORBIS_FILE;initial: PChar;ibytes: LongInt): Integer; cdecl;
|
||||
{$ENDIF}
|
||||
ov_clear_t = function(var vf: OGGVORBIS_FILE): Integer; cdecl;
|
||||
ov_open_callbacks_t = function(datasource: Pointer;var vf: OGGVORBIS_FILE;initial: PChar;ibytes: LongInt; callbacks: OV_CALLBACKS): Integer; cdecl;
|
||||
ov_test_callbacks_t = function(datasource: Pointer;var vf: OGGVORBIS_FILE;initial: PChar;ibytes: LongInt; callbacks: OV_CALLBACKS): Integer; cdecl;
|
||||
ov_test_open_t = function(var vf: OGGVORBIS_FILE): Integer; cdecl;
|
||||
ov_bitrate_t = function(var vf: OGGVORBIS_FILE;i: Integer): LongInt cdecl;
|
||||
ov_bitrate_instant_t = function(var vf: OGGVORBIS_FILE): LongInt cdecl;
|
||||
ov_streams_t = function(var vf: OGGVORBIS_FILE): LongInt cdecl;
|
||||
ov_seekable_t = function(var vf: OGGVORBIS_FILE): LongInt cdecl;
|
||||
ov_serialnumber_t = function(var vf: OGGVORBIS_FILE;i: Integer): LongInt cdecl;
|
||||
ov_raw_total_t = function(var vf: OGGVORBIS_FILE;i: Integer): OGG_INT64_T cdecl;
|
||||
ov_pcm_total_t = function(var vf: OGGVORBIS_FILE;i: Integer): OGG_INT64_T cdecl;
|
||||
ov_time_total_t = function(var vf: OGGVORBIS_FILE;i: Integer): Double cdecl;
|
||||
ov_raw_seek_t = function(var vf: OGGVORBIS_FILE;pos: LongInt): Integer cdecl;
|
||||
ov_pcm_seek_t = function(var vf: OGGVORBIS_FILE;pos: OGG_INT64_T): Integer cdecl;
|
||||
ov_pcm_seek_page_t = function(var vf: OGGVORBIS_FILE;pos: OGG_INT64_T): Integer cdecl;
|
||||
ov_time_seek_t = function(var vf: OGGVORBIS_FILE;pos: Double): Integer cdecl;
|
||||
ov_time_seek_page_t = function(var vf: OGGVORBIS_FILE;pos: Double): Integer cdecl;
|
||||
ov_raw_tell_t = function(var vf: OGGVORBIS_FILE): OGG_INT64_T cdecl;
|
||||
ov_pcm_tell_t = function(var vf: OGGVORBIS_FILE): OGG_INT64_T cdecl;
|
||||
ov_time_tell_t = function(var vf: OGGVORBIS_FILE): Double cdecl;
|
||||
ov_info_t = function(var vf: OGGVORBIS_FILE;link : Integer): PVORBIS_INFO cdecl;
|
||||
ov_comment_t = function(var vf: OGGVORBIS_FILE;link : Integer): PVORBIS_COMMENT cdecl;
|
||||
ov_read_float_t = function(var vf: OGGVORBIS_FILE;var pcm_channels: PPFLOAT;bitstream: PInteger): LongInt cdecl;
|
||||
ov_read_t = function(var vf: OGGVORBIS_FILE;buffer: PChar;length: Integer;bigendianp: Integer;word: Integer;sgned: Integer;bitstream: PInteger): LongInt cdecl;
|
||||
var
|
||||
{$IFDEF LINUX}
|
||||
ov_open : ov_open_t;
|
||||
ov_test : ov_test_t;
|
||||
{$ENDIF}
|
||||
ov_clear : ov_clear_t;
|
||||
ov_open_callbacks : ov_open_callbacks_t;
|
||||
ov_test_callbacks : ov_test_callbacks_t;
|
||||
ov_test_open : ov_test_open_t;
|
||||
ov_bitrate : ov_bitrate_t;
|
||||
ov_bitrate_instant : ov_bitrate_instant_t;
|
||||
ov_streams : ov_streams_t;
|
||||
ov_seekable : ov_seekable_t;
|
||||
ov_serialnumber : ov_serialnumber_t;
|
||||
ov_raw_total : ov_raw_total_t;
|
||||
ov_pcm_total : ov_pcm_total_t;
|
||||
ov_time_total : ov_time_total_t;
|
||||
ov_raw_seek : ov_raw_seek_t;
|
||||
ov_pcm_seek : ov_pcm_seek_t;
|
||||
ov_pcm_seek_page : ov_pcm_seek_page_t;
|
||||
ov_time_seek : ov_time_seek_t;
|
||||
ov_time_seek_page : ov_time_seek_page_t;
|
||||
ov_raw_tell : ov_raw_tell_t;
|
||||
ov_pcm_tell : ov_pcm_tell_t;
|
||||
ov_time_tell : ov_time_tell_t;
|
||||
ov_info : ov_info_t;
|
||||
ov_comment : ov_comment_t;
|
||||
ov_read_float : ov_read_float_t;
|
||||
ov_read : ov_read_t;
|
||||
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
Libhandle : HMODULE;
|
||||
{$ELSE}
|
||||
Libhandle : Pointer;
|
||||
{$ENDIF}
|
||||
|
||||
procedure VORBISLoadLibrary;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
var
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
procedure VORBISLoadLibrary;
|
||||
begin
|
||||
if LibvorbisfileLoaded then
|
||||
exit;
|
||||
{$IFDEF MSWINDOWS}
|
||||
Libhandle := LoadLibrary(PChar(LibvorbisfilePath));
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LibvorbisfileLoaded := True;
|
||||
ov_clear := GetProcAddress(Libhandle, 'ov_clear');
|
||||
ov_open_callbacks := GetProcAddress(Libhandle, 'ov_open_callbacks');
|
||||
ov_test_callbacks := GetProcAddress(Libhandle, 'ov_test_callbacks');
|
||||
ov_test_open := GetProcAddress(Libhandle, 'ov_test_open');
|
||||
ov_bitrate := GetProcAddress(Libhandle, 'ov_bitrate');
|
||||
ov_bitrate_instant := GetProcAddress(Libhandle, 'ov_bitrate_instant');
|
||||
ov_streams := GetProcAddress(Libhandle, 'ov_streams');
|
||||
ov_seekable := GetProcAddress(Libhandle, 'ov_seekable');
|
||||
ov_serialnumber := GetProcAddress(Libhandle, 'ov_serialnumber');
|
||||
ov_raw_total := GetProcAddress(Libhandle, 'ov_raw_total');
|
||||
ov_pcm_total := GetProcAddress(Libhandle, 'ov_pcm_total');
|
||||
ov_time_total := GetProcAddress(Libhandle, 'ov_time_total');
|
||||
ov_raw_seek := GetProcAddress(Libhandle, 'ov_raw_seek');
|
||||
ov_pcm_seek := GetProcAddress(Libhandle, 'ov_pcm_seek');
|
||||
ov_pcm_seek_page := GetProcAddress(Libhandle, 'ov_pcm_seek_page');
|
||||
ov_time_seek := GetProcAddress(Libhandle, 'ov_time_seek');
|
||||
ov_time_seek_page := GetProcAddress(Libhandle, 'ov_time_seek_page');
|
||||
ov_raw_tell := GetProcAddress(Libhandle, 'ov_raw_tell');
|
||||
ov_pcm_tell := GetProcAddress(Libhandle, 'ov_pcm_tell');
|
||||
ov_time_tell := GetProcAddress(Libhandle, 'ov_time_tell');
|
||||
ov_info := GetProcAddress(Libhandle, 'ov_info');
|
||||
ov_comment := GetProcAddress(Libhandle, 'ov_comment');
|
||||
ov_read_float := GetProcAddress(Libhandle, 'ov_read_float');
|
||||
ov_read := GetProcAddress(Libhandle, 'ov_read');
|
||||
end;
|
||||
{$ELSE}
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(LibvorbisfilePath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
{$ELSE}
|
||||
Libhandle := dlopen(LibvorbisfilePath, RTLD_NOW or RTLD_GLOBAL);
|
||||
{$ENDIF}
|
||||
if Libhandle <> nil then
|
||||
begin {$IFDEF FPC}
|
||||
{$IFDEF WIN32}
|
||||
{$PACKRECORDS C}
|
||||
{$ENDIF WIN32}
|
||||
{$ENDIF WIN32}
|
||||
|
||||
LibvorbisfileLoaded := True;
|
||||
ov_open := dlsym(Libhandle, 'ov_open');
|
||||
ov_test := dlsym(Libhandle, 'ov_test');
|
||||
ov_clear := dlsym(Libhandle, 'ov_clear');
|
||||
ov_open_callbacks := dlsym(Libhandle, 'ov_open_callbacks');
|
||||
ov_test_callbacks := dlsym(Libhandle, 'ov_test_callbacks');
|
||||
ov_test_open := dlsym(Libhandle, 'ov_test_open');
|
||||
ov_bitrate := dlsym(Libhandle, 'ov_bitrate');
|
||||
ov_bitrate_instant := dlsym(Libhandle, 'ov_bitrate_instant');
|
||||
ov_streams := dlsym(Libhandle, 'ov_streams');
|
||||
ov_seekable := dlsym(Libhandle, 'ov_seekable');
|
||||
ov_serialnumber := dlsym(Libhandle, 'ov_serialnumber');
|
||||
ov_raw_total := dlsym(Libhandle, 'ov_raw_total');
|
||||
ov_pcm_total := dlsym(Libhandle, 'ov_pcm_total');
|
||||
ov_time_total := dlsym(Libhandle, 'ov_time_total');
|
||||
ov_raw_seek := dlsym(Libhandle, 'ov_raw_seek');
|
||||
ov_pcm_seek := dlsym(Libhandle, 'ov_pcm_seek');
|
||||
ov_pcm_seek_page := dlsym(Libhandle, 'ov_pcm_seek_page');
|
||||
ov_time_seek := dlsym(Libhandle, 'ov_time_seek');
|
||||
ov_time_seek_page := dlsym(Libhandle, 'ov_time_seek_page');
|
||||
ov_raw_tell := dlsym(Libhandle, 'ov_raw_tell');
|
||||
ov_pcm_tell := dlsym(Libhandle, 'ov_pcm_tell');
|
||||
ov_time_tell := dlsym(Libhandle, 'ov_time_tell');
|
||||
ov_info := dlsym(Libhandle, 'ov_info');
|
||||
ov_comment := dlsym(Libhandle, 'ov_comment');
|
||||
ov_read_float := dlsym(Libhandle, 'ov_read_float');
|
||||
ov_read := dlsym(Libhandle, 'ov_read');
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
finalization
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
{$ELSE}
|
||||
if libhandle <> nil then dlclose(Libhandle);
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
253
acs/Src/fileformats/linux/smpeg.pas
Normal file
253
acs/Src/fileformats/linux/smpeg.pas
Normal file
@@ -0,0 +1,253 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3.
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at mail@z0m3ie.de
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: smpeg.pas,v $
|
||||
Revision 1.5 2006/09/04 14:40:16 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.4 2006/08/30 18:59:51 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.3 2005/12/19 18:37:03 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.4 2005/08/22 20:17:01 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
|
||||
{$weakpackageunit on}
|
||||
|
||||
// Linux and Windows C-Compilers use different byte-allignment
|
||||
{$IFDEF Linux}
|
||||
{$align 4} // linux uses dword alignment
|
||||
{$endif}
|
||||
{$ifdef win32}
|
||||
{$ifdef ver140}
|
||||
{$align 8} // windows uses quad-word alignment
|
||||
{$endif}
|
||||
{$endif}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$PACKRECORDS 4}
|
||||
{$ENDIF FPC}
|
||||
|
||||
unit smpeg;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$endif}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils,ACS_Procs,Dialogs
|
||||
{$ifdef LINUX}
|
||||
, baseunix,dl
|
||||
{$else}
|
||||
, Windows
|
||||
{$endif}
|
||||
;
|
||||
|
||||
const
|
||||
|
||||
SMPEG_ERROR = -1;
|
||||
SMPEG_STOPPED = 0;
|
||||
SMPEG_PLAYING = 1;
|
||||
|
||||
type
|
||||
|
||||
_SMPEG = record
|
||||
//obj: PMPEG;
|
||||
end;
|
||||
TSMPEG = _SMPEG;
|
||||
PSMPEG = ^_SMPEG;
|
||||
|
||||
SDL_AudioSpec = record
|
||||
freq: Integer;
|
||||
format: Word;
|
||||
channels: Byte;
|
||||
silence: Byte;
|
||||
samples: Word;
|
||||
padding: Word;
|
||||
size: LongWord;
|
||||
callback: Pointer;
|
||||
userdata: Pointer;
|
||||
end;
|
||||
|
||||
SMPEG_Info ={ packed} record
|
||||
has_audio : Integer;
|
||||
has_video : Integer;
|
||||
width : Integer;
|
||||
height: Integer;
|
||||
current_frame: Integer;
|
||||
current_fps: Double;
|
||||
audio_string : array[0..79] of Char;
|
||||
audio_current_frame : Integer;
|
||||
current_offset: LongWord;
|
||||
total_size: LongWord;
|
||||
current_time: Double;
|
||||
total_time: Double;
|
||||
end;
|
||||
|
||||
const
|
||||
|
||||
{$ifdef LINUX}
|
||||
LibsmpegPath = 'libsmpeg*.so*';
|
||||
LibSDLPath = 'libSDL*.so*';
|
||||
{$ELSE}
|
||||
LibsmpegPath = 'smpeg.dll';
|
||||
LibSDLPath = 'SDL.dll';
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
LibsmpegLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
SMPEG_new_t = function(const filename : PChar; var info : SMPEG_Info; sdl_audio : Integer): PSMPEG; cdecl;
|
||||
|
||||
SMPEG_delete_t = procedure(mpeg: Pointer); cdecl;
|
||||
|
||||
SMPEG_wantedSpec_t = function(mpeg: Pointer; var spec: SDL_AudioSpec): Integer; cdecl;
|
||||
|
||||
SMPEG_play_t = procedure(mpeg: Pointer); cdecl;
|
||||
|
||||
SMPEG_status_t = function(mpeg: Pointer) : Integer; cdecl;
|
||||
|
||||
SMPEG_stop_t = procedure(mpeg: Pointer); cdecl;
|
||||
|
||||
SMPEG_playAudio_t = function(mpeg: Pointer; stream: Pointer; len: Integer): Integer; cdecl;
|
||||
|
||||
SMPEG_skip_t = procedure(mpeg : Pointer; Pos : Single); cdecl;
|
||||
|
||||
SMPEG_rewind_t = procedure(mpeg : Pointer); cdecl;
|
||||
|
||||
var
|
||||
|
||||
SMPEG_new : SMPEG_new_t;
|
||||
|
||||
SMPEG_delete : SMPEG_delete_t;
|
||||
|
||||
SMPEG_wantedSpec : SMPEG_wantedSpec_t;
|
||||
|
||||
SMPEG_play : SMPEG_play_t;
|
||||
|
||||
SMPEG_status : SMPEG_status_t;
|
||||
|
||||
SMPEG_stop : SMPEG_stop_t;
|
||||
|
||||
SMPEG_playAudio : SMPEG_playAudio_t;
|
||||
|
||||
SMPEG_skip : SMPEG_skip_t;
|
||||
|
||||
SMPEG_rewind : SMPEG_rewind_t;
|
||||
|
||||
procedure LoadMPEGLibrary;
|
||||
procedure UnloadMPEGLibrary;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
type
|
||||
SDL_Init_t = function(Flags : LongWord) : Integer; cdecl;
|
||||
SDL_Quit_t = procedure; cdecl;
|
||||
|
||||
const
|
||||
SDL_INIT_AUDIO = $00000010;
|
||||
|
||||
var
|
||||
{$ifdef LINUX}
|
||||
Libhandle : Pointer;
|
||||
SDLhandle : Pointer;
|
||||
{$else}
|
||||
Libhandle : Cardinal;
|
||||
SDLhandle : Cardinal;
|
||||
{$endif}
|
||||
SDL_Init : SDL_Init_t;
|
||||
SDL_Quit : SDL_Quit_t;
|
||||
|
||||
procedure LoadMPEGLibrary;
|
||||
var
|
||||
Path : string;
|
||||
begin
|
||||
{$ifdef LINUX}
|
||||
Path := FindLibs(LibSDLPath);
|
||||
if Path <> '' then SDLhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
// SDLhandle := dlopen(LibSDLPath, RTLD_NOW{$IFDEF LINUX} or RTLD_GLOBAL{$ENDIF});
|
||||
if SDLhandle = nil then exit;
|
||||
SDL_Init := dlsym(SDLhandle, 'SDL_Init');
|
||||
SDL_Quit := dlsym(SDLhandle, 'SDL_Quit');
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
|
||||
Path := FindLibs(LibsmpegPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
// Libhandle := dlopen(LibsmpegPath, RTLD_NOW{$IFDEF LINUX} or RTLD_GLOBAL{$ENDIF});
|
||||
if Libhandle = nil then exit;
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
LibsmpegLoaded := True;
|
||||
SMPEG_new := dlsym(Libhandle, 'SMPEG_new');
|
||||
SMPEG_delete := dlsym(Libhandle, 'SMPEG_delete');
|
||||
SMPEG_wantedSpec := dlsym(Libhandle, 'SMPEG_wantedSpec');
|
||||
SMPEG_play := dlsym(Libhandle, 'SMPEG_play');
|
||||
SMPEG_status := dlsym(Libhandle, 'SMPEG_status');
|
||||
SMPEG_stop := dlsym(Libhandle, 'SMPEG_stop');
|
||||
SMPEG_playAudio := dlsym(Libhandle, 'SMPEG_playAudio');
|
||||
SMPEG_skip := dlsym(Libhandle, 'SMPEG_skip');
|
||||
SMPEG_rewind := dlsym(Libhandle, 'SMPEG_rewind');
|
||||
end;
|
||||
{$ELSE}
|
||||
SDLhandle := LoadLibrary(LibSDLPath);
|
||||
if SDLhandle = 0 then exit;
|
||||
SDL_Init := GetProcAddress(SDLhandle, 'SDL_Init');
|
||||
SDL_Quit := GetProcAddress(SDLhandle, 'SDL_Quit');
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
Libhandle := LoadLibrary(LibsmpegPath);
|
||||
if Libhandle = 0 then exit;
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
LibsmpegLoaded := True;
|
||||
SMPEG_new := GetProcAddress(Libhandle, 'SMPEG_new');
|
||||
SMPEG_delete := GetProcAddress(Libhandle, 'SMPEG_delete');
|
||||
SMPEG_wantedSpec := GetProcAddress(Libhandle, 'SMPEG_wantedSpec');
|
||||
SMPEG_play := GetProcAddress(Libhandle, 'SMPEG_play');
|
||||
SMPEG_status := GetProcAddress(Libhandle, 'SMPEG_status');
|
||||
SMPEG_stop := GetProcAddress(Libhandle, 'SMPEG_stop');
|
||||
SMPEG_playAudio := GetProcAddress(Libhandle, 'SMPEG_playAudio');
|
||||
SMPEG_skip := GetProcAddress(Libhandle, 'SMPEG_skip');
|
||||
SMPEG_rewind := GetProcAddress(Libhandle, 'SMPEG_rewind');
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure UnloadMPEGLibrary;
|
||||
|
||||
begin
|
||||
SDL_Quit;
|
||||
{$ifdef LINUX}
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
if SDLhandle <> nil then dlclose(SDLhandle);
|
||||
{$else}
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
if SDLhandle <> 0 then FreeLibrary(SDLhandle);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
end.
|
3619
acs/Src/fileformats/windows/direct3d9.pas
Normal file
3619
acs/Src/fileformats/windows/direct3d9.pas
Normal file
File diff suppressed because it is too large
Load Diff
6340
acs/Src/fileformats/windows/directdraw.pas
Normal file
6340
acs/Src/fileformats/windows/directdraw.pas
Normal file
File diff suppressed because it is too large
Load Diff
32049
acs/Src/fileformats/windows/directshow9.pas
Normal file
32049
acs/Src/fileformats/windows/directshow9.pas
Normal file
File diff suppressed because it is too large
Load Diff
1821
acs/Src/fileformats/windows/directsound.pas
Normal file
1821
acs/Src/fileformats/windows/directsound.pas
Normal file
File diff suppressed because it is too large
Load Diff
29
acs/Src/fileformats/windows/directx.inc
Normal file
29
acs/Src/fileformats/windows/directx.inc
Normal file
@@ -0,0 +1,29 @@
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ The contents of this file are subject to the Mozilla Public License Version }
|
||||
{ 1.1 (the "License"); you may not use this file except in compliance with the }
|
||||
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
|
||||
{ }
|
||||
{ Software distributed under the License is distributed on an "AS IS" basis, }
|
||||
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
|
||||
{ the specific language governing rights and limitations under the License. }
|
||||
{ }
|
||||
{ The Original Code is DirectX.inc. }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
// Borland compilers support
|
||||
{$INCLUDE Jedi.inc}
|
||||
|
||||
{$DEFINE TYPE_IDENTITY}
|
||||
{$DEFINE SUPPORTS_EXCEPTIONS}
|
||||
|
||||
// Additional settings
|
||||
{$MINENUMSIZE 4}
|
||||
{$ALIGN ON}
|
||||
|
||||
{$IFDEF COMPILER7_UP}
|
||||
{$WARN UNSAFE_CODE OFF}
|
||||
{$WARN UNSAFE_TYPE OFF}
|
||||
{$WARN UNSAFE_CAST OFF}
|
||||
{$ENDIF}
|
133
acs/Src/fileformats/windows/dxtypes.pas
Normal file
133
acs/Src/fileformats/windows/dxtypes.pas
Normal file
@@ -0,0 +1,133 @@
|
||||
{******************************************************************************}
|
||||
{* *}
|
||||
{* copyright (c) microsoft corporation. all rights reserved. *}
|
||||
{* *}
|
||||
{* files: dxsdkver.h, extracts from various directx sdk include files *}
|
||||
{* content: directx 9.0 headers common types *}
|
||||
{* *}
|
||||
{* directx 9.0 delphi / freepascal adaptation by alexey barkovoy *}
|
||||
{* e-mail: directx@clootie.ru *}
|
||||
{* *}
|
||||
{* latest version can be downloaded from: *}
|
||||
{* http://www.clootie.ru *}
|
||||
{* http://sourceforge.net/projects/delphi-dx9sdk *}
|
||||
{* *}
|
||||
{*----------------------------------------------------------------------------*}
|
||||
{* $id: dxtypes.pas,v 1.1 2005/09/12 22:04:53 z0m3ie exp $ }
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ the contents of this file are used with permission, subject to the mozilla }
|
||||
{ public license version 1.1 (the "license"); you may not use this file except }
|
||||
{ in compliance with the license. you may obtain a copy of the license at }
|
||||
{ http://www.mozilla.org/mpl/mpl-1.1.html }
|
||||
{ }
|
||||
{ software distributed under the license is distributed on an "as is" basis, }
|
||||
{ without warranty of any kind, either express or implied. see the license for }
|
||||
{ the specific language governing rights and limitations under the license. }
|
||||
{ }
|
||||
{ alternatively, the contents of this file may be used under the terms of the }
|
||||
{ gnu lesser general public license (the "lgpl license"), in which case the }
|
||||
{ provisions of the lgpl license are applicable instead of those above. }
|
||||
{ if you wish to allow use of your version of this file only under the terms }
|
||||
{ of the lgpl license and not to allow others to use your version of this file }
|
||||
{ under the mpl, indicate your decision by deleting the provisions above and }
|
||||
{ replace them with the notice and other provisions required by the lgpl }
|
||||
{ license. if you do not delete the provisions above, a recipient may use }
|
||||
{ your version of this file under either the mpl or the lgpl license. }
|
||||
{ }
|
||||
{ for more information about the lgpl: http://www.gnu.org/copyleft/lesser.html }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
{.$I DirectX.inc}
|
||||
|
||||
unit dxtypes;
|
||||
|
||||
interface
|
||||
|
||||
|
||||
uses windows;
|
||||
|
||||
(*==========================================================================;
|
||||
*
|
||||
* File: dxsdkver.h
|
||||
* Content: DirectX SDK Version Include File
|
||||
*
|
||||
****************************************************************************)
|
||||
const
|
||||
_DXSDK_PRODUCT_MAJOR = 9;
|
||||
_DXSDK_PRODUCT_MINOR = 08;
|
||||
_DXSDK_BUILD_MAJOR = 299;
|
||||
_DXSDK_BUILD_MINOR = 0000;
|
||||
|
||||
|
||||
|
||||
(****************************************************************************
|
||||
* Other files
|
||||
****************************************************************************)
|
||||
type
|
||||
// TD3DValue is the fundamental Direct3D fractional data type
|
||||
D3DVALUE = Single;
|
||||
TD3DValue = D3DVALUE;
|
||||
PD3DValue = ^TD3DValue;
|
||||
|
||||
D3DCOLOR = DWord;
|
||||
TD3DColor = D3DCOLOR;
|
||||
PD3DColor = ^TD3DColor;
|
||||
|
||||
_D3DVECTOR = packed record
|
||||
x: Single;
|
||||
y: Single;
|
||||
z: Single;
|
||||
end {_D3DVECTOR};
|
||||
D3DVECTOR = _D3DVECTOR;
|
||||
TD3DVector = _D3DVECTOR;
|
||||
PD3DVector = ^TD3DVector;
|
||||
|
||||
REFERENCE_TIME = LONGLONG;
|
||||
TReferenceTime = REFERENCE_TIME;
|
||||
PReferenceTime = ^TReferenceTime;
|
||||
|
||||
|
||||
// ==================================================================
|
||||
// Here comes generic Windows types for Win32 / Win64 compatibility
|
||||
//
|
||||
|
||||
//
|
||||
// The INT_PTR is guaranteed to be the same size as a pointer. Its
|
||||
// size with change with pointer size (32/64). It should be used
|
||||
// anywhere that a pointer is cast to an integer type. UINT_PTR is
|
||||
// the unsigned variation.
|
||||
//
|
||||
{$IFDEF WIN64}
|
||||
INT_PTR = Int64;
|
||||
UINT_PTR = Int64; // not yet: UInt64;
|
||||
LONG_PTR = Int64;
|
||||
ULONG_PTR = Int64; // not yet: UInt64;
|
||||
DWORD_PTR = Int64; // not yet: UInt64;
|
||||
{$ELSE}
|
||||
INT_PTR = Longint;
|
||||
UINT_PTR = Longword;
|
||||
LONG_PTR = Longint;
|
||||
ULONG_PTR = Longword;
|
||||
DWORD_PTR = Longword;
|
||||
{$ENDIF}
|
||||
PINT_PTR = ^INT_PTR;
|
||||
PUINT_PTR = ^UINT_PTR;
|
||||
PLONG_PTR = ^LONG_PTR;
|
||||
PULONG_PTR = ^ULONG_PTR;
|
||||
|
||||
|
||||
//
|
||||
// SIZE_T used for counts or ranges which need to span the range of
|
||||
// of a pointer. SSIZE_T is the signed variation.
|
||||
//
|
||||
SIZE_T = ULONG_PTR;
|
||||
SSIZE_T = LONG_PTR;
|
||||
PSIZE_T = ^SIZE_T;
|
||||
PSSIZE_T = ^SSIZE_T;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
578
acs/Src/fileformats/windows/jedi.inc
Normal file
578
acs/Src/fileformats/windows/jedi.inc
Normal file
@@ -0,0 +1,578 @@
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ The contents of this file are subject to the Mozilla Public License Version }
|
||||
{ 1.1 (the "License"); you may not use this file except in compliance with the }
|
||||
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
|
||||
{ }
|
||||
{ Software distributed under the License is distributed on an "AS IS" basis, }
|
||||
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
|
||||
{ the specific language governing rights and limitations under the License. }
|
||||
{ }
|
||||
{ The Original Code is JEDI.INC. }
|
||||
{ }
|
||||
{ The Initial Developer of the Original Code is Project JEDI }
|
||||
{ http://www.delphi-jedi.org }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
{ }
|
||||
{ This file defines various generic compiler directives used in the JEDI Code }
|
||||
{ Library (JCL) and JEDI Visual Component Library Library (J-VCL). The }
|
||||
{ directives in this file are of generic nature and consist mostly of mappings }
|
||||
{ from the VERXXX directives defined by Delphi and C++ Builder to friendly }
|
||||
{ names such as DELPHI5 and SUPPORTS_WIDESTRING. These friendly names are }
|
||||
{ subsequently used in both libraries to test for compiler versions and/or }
|
||||
{ whether the compiler supports certain features (such as widestring's or 64 }
|
||||
{ bit integers. Both libraries provide an additional, library specific, }
|
||||
{ include file. For the JCL this is JCL.INC. These files should be included in }
|
||||
{ source files instead of this file (which is pulled in automatically). }
|
||||
{ }
|
||||
{ Maintainer: Marcel van Brakel }
|
||||
{ Last modified: May 25, 2002 }
|
||||
{ }
|
||||
{******************************************************************************}
|
||||
|
||||
(*
|
||||
|
||||
- Development environment directives
|
||||
|
||||
This file defines two driectives to indicate which development environment the
|
||||
library is being compiled with. Currently this can either be Delphi or
|
||||
C++ Builder (in the near future "Kylix" will be added).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
DELPHI Defined if compiled with Delphi
|
||||
CBUILDER Defined if compiled with C++ Builder
|
||||
|
||||
- Platform Directives
|
||||
|
||||
Platform directives are not explicitly defined in this file but are defined
|
||||
by the compiler itself. They are listed here only for completeness.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
WIN32 Defined when target platform is 32 bit Windows
|
||||
LINUX Defined when target platform is Linux
|
||||
|
||||
- Delphi Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. These directives are only defined if
|
||||
the compiler is Delphi (ie DELPHI is defined).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
DELPHI1 Defined when compiling with Delphi 1
|
||||
DELPHI2 Defined when compiling with Delphi 2
|
||||
DELPHI3 Defined when compiling with Delphi 3
|
||||
DELPHI4 Defined when compiling with Delphi 4
|
||||
DELPHI5 Defined when compiling with Delphi 5
|
||||
DELPHI6 Defined when compiling with Delphi 6
|
||||
DELPHI7 Defined when compiling with Delphi 7
|
||||
DELPHI8 Defined when compiling with Delphi 8
|
||||
DELPHI9 Defined when compiling with Delphi 9
|
||||
DELPHI1_UP Defined when compiling with Delphi 1 or higher
|
||||
DELPHI2_UP Defined when compiling with Delphi 2 or higher
|
||||
DELPHI3_UP Defined when compiling with Delphi 3 or higher
|
||||
DELPHI4_UP Defined when compiling with Delphi 4 or higher
|
||||
DELPHI5_UP Defined when compiling with Delphi 5 or higher
|
||||
DELPHI6_UP Defined when compiling with Delphi 6 or higher
|
||||
DELPHI7_UP Defined when compiling with Delphi 7 or higher
|
||||
DELPHI8_UP Defined when compiling with Delphi 8 or higher
|
||||
DELPHI9_UP Defined when compiling with Delphi 9 or higher
|
||||
|
||||
- C++ Builder Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. These directives are only defined if
|
||||
the compiler is C++ Builder (ie BCB is defined).
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
BCB1 Defined when compiling with C++ Builder 1
|
||||
BCB3 Defined when compiling with C++ Builder 3
|
||||
BCB4 Defined when compiling with C++ Builder 4
|
||||
BCB5 Defined when compiling with C++ Builder 5
|
||||
BCB6 Defined when compiling with C++ Builder 6
|
||||
BCB7 Defined when compiling with C++ Builder 7
|
||||
BCB1_UP Defined when compiling with C++ Builder 1 or higher
|
||||
BCB3_UP Defined when compiling with C++ Builder 3 or higher
|
||||
BCB4_UP Defined when compiling with C++ Builder 4 or higher
|
||||
BCB5_UP Defined when compiling with C++ Builder 5 or higher
|
||||
BCB6_UP Defined when compiling with C++ Builder 6 or higher
|
||||
BCB7_UP Defined when compiling with C++ Builder 7 or higher
|
||||
|
||||
- Compiler Versions
|
||||
|
||||
The following directives are direct mappings from the VERXXX directives to a
|
||||
friendly name of the associated compiler. Unlike the DELPHI_X and BCB_X
|
||||
directives, these directives are indepedent of the development environment.
|
||||
That is, they are defined regardless of whether compilation takes place using
|
||||
Delphi or C++ Builder.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
COMPILER1 Defined when compiling with Delphi 1
|
||||
COMPILER2 Defined when compiling with Delphi 2 or C++ Builder 1
|
||||
COMPILER3 Defined when compiling with Delphi 3
|
||||
COMPILER35 Defined when compiling with C++ Builder 3
|
||||
COMPILER4 Defined when compiling with Delphi 4 or C++ Builder 4
|
||||
COMPILER5 Defined when compiling with Delphi 5 or C++ Builder 5
|
||||
COMPILER6 Defined when compiling with Delphi 6 or C++ Builder 6
|
||||
COMPILER1_UP Defined when compiling with Delphi 1 or higher
|
||||
COMPILER2_UP Defined when compiling with Delphi 2 or C++ Builder 1 or higher
|
||||
COMPILER3_UP Defined when compiling with Delphi 3 or higher
|
||||
COMPILER35_UP Defined when compiling with C++ Builder 3 or higher
|
||||
COMPILER4_UP Defined when compiling with Delphi 4 or C++ Builder 4 or higher
|
||||
COMPILER5_UP Defined when compiling with Delphi 5 or C++ Builder 5 or higher
|
||||
COMPILER6_UP Defined when compiling with Delphi 6 or C++ Builder 6 or higher
|
||||
COMPILER7_UP Defined when compiling with Delphi 6 or C++ Builder 6 or higher
|
||||
|
||||
- Feature Directives
|
||||
|
||||
The features directives are used to test if the compiler supports specific
|
||||
features, such as method overloading, and adjust the sources accordingly. Use
|
||||
of these directives is preferred over the use of the DELPHI and COMPILER
|
||||
directives.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
SUPPORTS_WIDESTRING Compiler supports the WideString type (D3/BCB3 up)
|
||||
SUPPORTS_INTERFACE Compiler supports interfaces (D3/BCB3)
|
||||
SUPPORTS_EXTSYM Compiler supports the $EXTERNALSYM directive (D4/BCB3)
|
||||
SUPPORTS_NODEFINE Compiler supports the $NODEFINE directive (D4/BCB3)
|
||||
SUPPORTS_INT64 Compiler supports the Int64 type (D4/BCB4)
|
||||
SUPPORTS_DYNAMICARRAYS Compiler supports dynamic arrays (D4/BCB4)
|
||||
SUPPORTS_DEFAULTPARAMS Compiler supports default parameters (D4/BCB4)
|
||||
SUPPORTS_OVERLOAD Compiler supports overloading (D4/BCB4)
|
||||
SUPPORTS_INLINE Compiler supports inline directive (D9)
|
||||
|
||||
- Compiler Settings
|
||||
|
||||
The compiler settings directives indicate whether a specific compiler setting
|
||||
is in effect. This facilitates changing compiler settings locally in a more
|
||||
compact and readible manner.
|
||||
|
||||
Directive Description
|
||||
------------------------------------------------------------------------------
|
||||
ALIGN_ON Compiling in the A+ state (no alignment)
|
||||
BOOLEVAL_ON Compiling in the B+ state (complete boolean evaluation)
|
||||
ASSERTIONS_ON Compiling in the C+ state (assertions on)
|
||||
DEBUGINFO_ON Compiling in the D+ state (debug info generation on)
|
||||
IMPORTEDDATA_ON Compiling in the G+ state (creation of imported data references)
|
||||
LONGSTRINGS_ON Compiling in the H+ state (string defined as AnsiString)
|
||||
IOCHECKS_ON Compiling in the I+ state (I/O checking enabled)
|
||||
WRITEABLECONST_ON Compiling in the J+ state (typed constants can be modified)
|
||||
LOCALSYMBOLS Compiling in the L+ state (local symbol generation)
|
||||
TYPEINFO_ON Compiling in the M+ state (RTTI generation on)
|
||||
OPTIMIZATION_ON Compiling in the O+ state (code optimization on)
|
||||
OPENSTRINGS_ON Compiling in the P+ state (variable string parameters are openstrings)
|
||||
OVERFLOWCHECKS_ON Compiling in the Q+ state (overflow checing on)
|
||||
RANGECHECKS_ON Compiling in the R+ state (range checking on)
|
||||
TYPEDADDRESS_ON Compiling in the T+ state (pointers obtained using the @ operator are typed)
|
||||
SAFEDIVIDE_ON Compiling in the U+ state (save FDIV instruction through RTL emulation)
|
||||
VARSTRINGCHECKS_ON Compiling in the V+ state (type checking of shortstrings)
|
||||
STACKFRAMES_ON Compiling in the W+ state (generation of stack frames)
|
||||
EXTENDEDSYNTAX_ON Compiling in the X+ state (Delphi extended syntax enabled)
|
||||
|
||||
*)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Compiler settings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFOPT A+} {$DEFINE ALIGN_ON} {$ENDIF}
|
||||
{$IFOPT B+} {$DEFINE BOOLEVAL_ON} {$ENDIF}
|
||||
{$IFOPT C+} {$DEFINE ASSERTIONS_ON} {$ENDIF}
|
||||
{$IFOPT D+} {$DEFINE DEBUGINFO_ON} {$ENDIF}
|
||||
{$IFOPT G+} {$DEFINE IMPORTEDDATA_ON} {$ENDIF}
|
||||
{$IFOPT H+} {$DEFINE LONGSTRINGS_ON} {$ENDIF}
|
||||
//HINTS
|
||||
{$IFOPT I+} {$DEFINE IOCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT J+} {$DEFINE WRITEABLECONST_ON} {$ENDIF}
|
||||
{$IFOPT L+} {$DEFINE LOCALSYMBOLS} {$ENDIF}
|
||||
{$IFOPT M+} {$DEFINE TYPEINFO_ON} {$ENDIF}
|
||||
{$IFOPT O+} {$DEFINE OPTIMIZATION_ON} {$ENDIF}
|
||||
{$IFOPT P+} {$DEFINE OPENSTRINGS_ON} {$ENDIF}
|
||||
{$IFOPT Q+} {$DEFINE OVERFLOWCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT R+} {$DEFINE RANGECHECKS_ON} {$ENDIF}
|
||||
//REALCOMPATIBILITY
|
||||
{$IFOPT T+} {$DEFINE TYPEDADDRESS_ON} {$ENDIF}
|
||||
{$IFOPT U+} {$DEFINE SAFEDIVIDE_ON} {$ENDIF}
|
||||
{$IFOPT V+} {$DEFINE VARSTRINGCHECKS_ON} {$ENDIF}
|
||||
{$IFOPT W+} {$DEFINE STACKFRAMES_ON} {$ENDIF}
|
||||
//WARNINGS
|
||||
{$IFOPT X+} {$DEFINE EXTENDEDSYNTAX_ON} {$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VERXXX to COMPILERX, DELPHIX and BCBX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF VER170}
|
||||
{$DEFINE COMPILER9}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB9}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI9}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER160}
|
||||
{$DEFINE COMPILER8}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB8}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI8}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER150}
|
||||
{$DEFINE COMPILER7}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB7}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI7}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER140}
|
||||
{$DEFINE COMPILER6}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB6}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI6}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER130}
|
||||
{$DEFINE COMPILER5}
|
||||
{$IFDEF BCB}
|
||||
{$DEFINE BCB5}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI5}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER125}
|
||||
{$DEFINE COMPILER4}
|
||||
{$DEFINE BCB4}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER120}
|
||||
{$DEFINE COMPILER4}
|
||||
{$DEFINE DELPHI4}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER110}
|
||||
{$DEFINE COMPILER35}
|
||||
{$DEFINE BCB3}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER100}
|
||||
{$DEFINE COMPILER3}
|
||||
{$DEFINE DELPHI3}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER93}
|
||||
{$DEFINE COMPILER2}
|
||||
{$DEFINE BCB1}
|
||||
{$DEFINE CBUILDER}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER90}
|
||||
{$DEFINE COMPILER2}
|
||||
{$DEFINE DELPHI2}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER80}
|
||||
{$DEFINE COMPILER1}
|
||||
{$DEFINE DELPHI1}
|
||||
{$DEFINE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// DELPHIX_UP from DELPHIX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF DELPHI9}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI8}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI7}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI6}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI5}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI4}
|
||||
{$DEFINE DELPHI4_UP}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI3}
|
||||
{$DEFINE DELPHI3_UP}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI2}
|
||||
{$DEFINE DELPHI2_UP}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI1}
|
||||
{$DEFINE DELPHI1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BCBX_UP from BCBX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF BCB9}
|
||||
{$DEFINE BCB9_UP}
|
||||
{$DEFINE BCB8_UP}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB8}
|
||||
{$DEFINE BCB8_UP}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB7}
|
||||
{$DEFINE BCB7_UP}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB6}
|
||||
{$DEFINE BCB6_UP}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB5}
|
||||
{$DEFINE BCB5_UP}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB4}
|
||||
{$DEFINE BCB4_UP}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB3}
|
||||
{$DEFINE BCB3_UP}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF BCB1}
|
||||
{$DEFINE BCB1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// COMPILERX_UP from COMPILERX mappings
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
{$IFDEF COMPILER9}
|
||||
{$DEFINE COMPILER9_UP}
|
||||
{$DEFINE COMPILER8_UP}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER8}
|
||||
{$DEFINE COMPILER8_UP}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER7}
|
||||
{$DEFINE COMPILER7_UP}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER6}
|
||||
{$DEFINE COMPILER6_UP}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER5}
|
||||
{$DEFINE COMPILER5_UP}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER4}
|
||||
{$DEFINE COMPILER4_UP}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER35}
|
||||
{$DEFINE COMPILER35_UP}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER3}
|
||||
{$DEFINE COMPILER3_UP}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER2}
|
||||
{$DEFINE COMPILER2_UP}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER1}
|
||||
{$DEFINE COMPILER1_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Map COMPILERX_UP to friendly feature names
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF COMPILER3_UP}
|
||||
{$DEFINE SUPPORTS_WIDESTRING}
|
||||
{$DEFINE SUPPORTS_INTERFACE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER35_UP}
|
||||
{$DEFINE SUPPORTS_EXTSYM}
|
||||
{$DEFINE SUPPORTS_NODEFINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER4_UP}
|
||||
{$DEFINE SUPPORTS_INT64}
|
||||
{$DEFINE SUPPORTS_DYNAMICARRAYS}
|
||||
{$DEFINE SUPPORTS_DEFAULTPARAMS}
|
||||
{$DEFINE SUPPORTS_OVERLOAD}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF COMPILER9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Cross-platform related defines
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
{$IFDEF WIN32}
|
||||
{$DEFINE MSWINDOWS}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$DEFINE UNIX}
|
||||
{$DEFINE COMPLIB_CLX}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF COMPLIB_CLX}
|
||||
{$DEFINE COMPLIB_VCL}
|
||||
{$ENDIF}
|
1200
acs/Src/fileformats/windows/macdll.pas
Normal file
1200
acs/Src/fileformats/windows/macdll.pas
Normal file
File diff suppressed because it is too large
Load Diff
290
acs/Src/fileformats/windows/mad.pas
Normal file
290
acs/Src/fileformats/windows/mad.pas
Normal file
@@ -0,0 +1,290 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3 (delphi version).
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at acs@compiler4.net
|
||||
this is the acs for delphi (windows) version of the unit.
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: mad.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:49 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:02 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit mad;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
{$IFDEF WIN32}
|
||||
Windows;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
baseunix, ACS_Procs;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
const
|
||||
|
||||
{$IFDEF WIN32}
|
||||
MADLibPath = 'MADLib.dll';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
MADLibPath = 'libmad.so*'; // libmad.so
|
||||
{$DEFINE SEARCH_LIBS}
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
var
|
||||
|
||||
MADLibLoaded : Boolean = False;
|
||||
|
||||
type
|
||||
|
||||
mad_bitptr = packed record
|
||||
b : PChar;
|
||||
Cache, Left : Word;
|
||||
end;
|
||||
|
||||
mad_stream = packed record
|
||||
buffer : Pointer;
|
||||
bufend : Pointer;
|
||||
skiplen : LongWord;
|
||||
sync : Integer;
|
||||
freerate : LongWord;
|
||||
this_frame : Pointer;
|
||||
next_frame : Pointer;
|
||||
ptr : mad_bitptr;
|
||||
anc_ptr : mad_bitptr;
|
||||
anc_bitlen : LongWord;
|
||||
main_data : Pointer;
|
||||
md_len : LongWord;
|
||||
options : Integer;
|
||||
error : Integer;
|
||||
end;
|
||||
|
||||
p_mad_stream = ^mad_stream;
|
||||
|
||||
mad_timer_t = packed record
|
||||
seconds : Integer;
|
||||
fraction : LongWord;
|
||||
end;
|
||||
|
||||
mad_header = packed record
|
||||
layer : Integer;
|
||||
mode : Integer;
|
||||
mode_extension : Integer;
|
||||
emphasis : Integer;
|
||||
bitrate : LongWord;
|
||||
samplerate : LongWord;
|
||||
crc_check : Word;
|
||||
crc_target : Word;
|
||||
flags : Integer;
|
||||
private_bits : Integer;
|
||||
duration : mad_timer_t;
|
||||
end;
|
||||
|
||||
p_mad_header = ^mad_header;
|
||||
|
||||
mad_frame = packed record
|
||||
header : mad_header;
|
||||
options : Integer;
|
||||
sbsample : packed array[0..1, 0..35, 0..31] of Integer;
|
||||
overlap : Pointer;
|
||||
end;
|
||||
|
||||
p_mad_frame = ^mad_frame;
|
||||
|
||||
mad_pcm = packed record
|
||||
samplerate : LongWord;
|
||||
channels : Word;
|
||||
length : Word;
|
||||
samples : packed array [0..1, 0..1151] of Integer;
|
||||
end;
|
||||
|
||||
p_mad_pcm = ^mad_pcm;
|
||||
|
||||
mad_synth = packed record
|
||||
filter : array[0..1, 0..1, 0..1, 0..15, 0..7] of Integer;
|
||||
phase : LongWord;
|
||||
pcm : mad_pcm;
|
||||
end;
|
||||
|
||||
async_struct = packed record
|
||||
pid : LongWord;
|
||||
_in : Integer;
|
||||
_out : Integer;
|
||||
end;
|
||||
|
||||
sync_struct = packed record
|
||||
stream : mad_stream;
|
||||
frame : mad_frame;
|
||||
synth : mad_synth;
|
||||
end;
|
||||
|
||||
p_sync_struct = ^sync_struct;
|
||||
|
||||
TInputFunc = function(CData : Pointer; Stream : p_mad_stream) : Integer; cdecl;
|
||||
THeaderFunc = function(CData : Pointer; Header : p_mad_header) : Integer; cdecl;
|
||||
TFilterFunc = function(CData : Pointer; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TOutputFunc = function(CData : Pointer; Header : p_mad_header; pcm : p_mad_pcm) : Integer; cdecl;
|
||||
TErrorFunc = function(CData : Pointer; Stream : p_mad_stream; Frame : p_mad_frame) : Integer; cdecl;
|
||||
TMessageFunc = function(P1, P2 : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_decoder = packed record
|
||||
mode : Integer;
|
||||
options : Integer;
|
||||
async : async_struct;
|
||||
sync : p_sync_struct;
|
||||
data : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc;
|
||||
end;
|
||||
|
||||
p_mad_decoder = ^mad_decoder;
|
||||
|
||||
const
|
||||
|
||||
MAD_F_FRACBITS = 28;
|
||||
MAD_F_ONE = $10000000;
|
||||
|
||||
MAD_FLOW_CONTINUE = $0;
|
||||
MAD_FLOW_STOP = $10;
|
||||
MAD_FLOW_BREAK = $11;
|
||||
MAD_FLOW_IGNORE = $20;
|
||||
|
||||
MAD_DECODER_MODE_SYNC = 0;
|
||||
MAD_DECODER_MODE_ASYNC = 1;
|
||||
|
||||
type
|
||||
|
||||
mad_decoder_init_t = procedure(mad_decoder : p_mad_decoder; CData : Pointer;
|
||||
InputFunc : TInputFunc;
|
||||
HeaderFunc : THeaderFunc;
|
||||
FilterFunc : TFilterFunc;
|
||||
OutputFunc : TOutputFunc;
|
||||
ErrorFunc : TErrorFunc;
|
||||
MessageFunc : TMessageFunc); cdecl;
|
||||
|
||||
mad_decoder_finish_t = function(mad_decoder : p_mad_decoder) : Integer; cdecl;
|
||||
|
||||
mad_decoder_run_t = function(mad_decoder : p_mad_decoder; mad_decoder_mode : Integer) : Integer; cdecl;
|
||||
|
||||
mad_decoder_message_t = function(mad_decoder : p_mad_decoder; P : Pointer; var l : LongWord) : Integer; cdecl;
|
||||
|
||||
mad_stream_buffer_t = procedure(MadStream : p_mad_stream; Data : Pointer; l : LongWord); cdecl;
|
||||
|
||||
mad_stream_skip_t = procedure(MadStream : p_mad_stream; Skip : LongWord); cdecl;
|
||||
|
||||
mad_stream_sync_t = function(MadStream : p_mad_stream) : Integer; cdecl;
|
||||
|
||||
var
|
||||
|
||||
mad_decoder_init: mad_decoder_init_t;
|
||||
mad_decoder_finish : mad_decoder_finish_t;
|
||||
mad_decoder_run : mad_decoder_run_t;
|
||||
mad_decoder_message : mad_decoder_message_t;
|
||||
mad_stream_buffer : mad_stream_buffer_t;
|
||||
mad_stream_skip : mad_stream_skip_t;
|
||||
mad_stream_sync : mad_stream_sync_t;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
var
|
||||
Libhandle : HMODULE;
|
||||
|
||||
initialization
|
||||
|
||||
Libhandle := LoadLibraryEx(MADLibPath, 0, 0);
|
||||
|
||||
if Libhandle <> 0 then
|
||||
begin
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := GetProcAddress(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := GetProcAddress(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := GetProcAddress(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := GetProcAddress(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := GetProcAddress(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := GetProcAddress(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := GetProcAddress(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> 0 then FreeLibrary(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
|
||||
var
|
||||
Libhandle : Pointer;
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
Path : String;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF SEARCH_LIBS}
|
||||
|
||||
Libhandle := nil;
|
||||
Path := FindLibs(MADLibPath);
|
||||
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ELSE}
|
||||
|
||||
Libhandle := dlopen(MADLibPath, RTLD_NOW or RTLD_GLOBAL);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
if Libhandle <> nil then
|
||||
begin
|
||||
|
||||
MADLibLoaded := True;
|
||||
|
||||
mad_decoder_init := dlsym(Libhandle, 'mad_decoder_init');
|
||||
mad_decoder_finish := dlsym(Libhandle, 'mad_decoder_finish');
|
||||
mad_decoder_run := dlsym(Libhandle, 'mad_decoder_run');
|
||||
mad_decoder_message := dlsym(Libhandle, 'mad_decoder_message');
|
||||
mad_stream_buffer := dlsym(Libhandle, 'mad_stream_buffer');
|
||||
mad_stream_skip := dlsym(Libhandle, 'mad_stream_skip');
|
||||
mad_stream_sync := dlsym(Libhandle, 'mad_stream_sync');
|
||||
|
||||
end;
|
||||
|
||||
finalization
|
||||
|
||||
if Libhandle <> nil then dlclose(Libhandle);
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end.
|
1411
acs/Src/fileformats/windows/msacm.pas
Normal file
1411
acs/Src/fileformats/windows/msacm.pas
Normal file
File diff suppressed because it is too large
Load Diff
334
acs/Src/fileformats/windows/waveconverter.pas
Normal file
334
acs/Src/fileformats/windows/waveconverter.pas
Normal file
@@ -0,0 +1,334 @@
|
||||
(*
|
||||
this file is a part of audio components suite v 2.3 (delphi version).
|
||||
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
|
||||
see the license file for more details.
|
||||
you can contact me at acs@compiler4.net
|
||||
this is the acs for delphi (windows) version of the unit.
|
||||
*)
|
||||
|
||||
{
|
||||
$Log: waveconverter.pas,v $
|
||||
Revision 1.1 2005/12/19 18:36:49 z0m3ie
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1 2005/09/12 22:04:53 z0m3ie
|
||||
modified structure again, fileformats are now in an sperat folder.
|
||||
all File In/Out classes are capsulated from TFileIn and TFileOut
|
||||
|
||||
Revision 1.1 2005/08/25 20:18:00 z0m3ie
|
||||
Version 2.4 restructure
|
||||
TCDPlayer removed (fits not in component structure)
|
||||
TMP3ToWavConverter removed (fits not in component structure)
|
||||
|
||||
Revision 1.2 2005/08/22 20:17:02 z0m3ie
|
||||
changed Headers to log
|
||||
changed mail adress
|
||||
|
||||
}
|
||||
|
||||
unit waveconverter;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
Windows, Classes, MMSystem, MSAcm;
|
||||
|
||||
type
|
||||
{$IFDEF FPC}
|
||||
TWaveFormat = WAVEFORMAT;
|
||||
{$ENDIF}
|
||||
|
||||
TRiffID = array[0..3] of char;
|
||||
TRiffHeader = packed record
|
||||
ID: TRiffID;
|
||||
BytesFollowing: DWord;
|
||||
end;
|
||||
|
||||
|
||||
TACMWaveFormat = packed record
|
||||
case integer of
|
||||
0 : (Format : TWaveFormatEx);
|
||||
1 : (RawData : Array[0..128] of byte);
|
||||
end;
|
||||
|
||||
TWaveConverter = class(TMemoryStream)
|
||||
private
|
||||
FMaxFmtSize: DWord;
|
||||
public
|
||||
CurrentFormat: TACMWaveFormat;
|
||||
NewFormat: TACMWaveFormat;
|
||||
function LoadStream(Stream : TStream): integer;
|
||||
function Convert: integer;
|
||||
function SaveWavToStream(MS: TStream): Integer;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TWaveConverter }
|
||||
|
||||
function TWaveConverter.Convert: integer;
|
||||
var
|
||||
FStreamHandle: HACMStream;
|
||||
OutputBufferSize: DWord;
|
||||
FStreamHeader: TACMStreamHeader;
|
||||
OutPut: Pointer;
|
||||
begin
|
||||
FStreamHandle := nil;
|
||||
|
||||
//
|
||||
// Open the stream we're going to use to convert from the current to the
|
||||
// new format
|
||||
//
|
||||
Result := acmStreamOpen(FStreamhandle, nil, CurrentFormat.Format,
|
||||
NewFormat.Format, nil, 0, 0, ACM_STREAMOPENF_NONREALTIME);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
//SetError('acmStreamOpen', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Calculate the size of the converted data
|
||||
//
|
||||
Result := acmStreamSize(FStreamHandle, self. Size, OutputBufferSize,
|
||||
ACM_STREAMSIZEF_SOURCE);
|
||||
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamSize', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Allocate memory for the converted data
|
||||
//
|
||||
GetMem(OutPut, OutputBufferSize);
|
||||
FillChar(OutPut^,OutputBufferSize,#0);
|
||||
|
||||
Self.Seek(0,0);
|
||||
|
||||
//
|
||||
// Initialize and prepare a header
|
||||
//
|
||||
with FStreamHeader do
|
||||
begin
|
||||
cbStruct := SizeOf(TACMStreamHeader);
|
||||
fdwStatus := 0;
|
||||
dwUser := 0;
|
||||
pbSrc := self.Memory;
|
||||
cbSrcLength := self.Size;
|
||||
cbSrcLengthUsed := 0;
|
||||
dwSrcUser := 0;
|
||||
pbDst := OutPut;
|
||||
cbDstLength := OutputBufferSize;
|
||||
cbDstLengthUsed := 0;
|
||||
dwDstUser := 0;
|
||||
end;
|
||||
Result := acmStreamPrepareHeader(FStreamHandle,FStreamHeader, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamPrepareHeader', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Tell acm to convert the stream
|
||||
//
|
||||
Result := acmStreamConvert(FStreamHandle,FStreamHeader,
|
||||
ACM_STREAMCONVERTF_BLOCKALIGN);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamConvert', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Set the format eqaul to the newformat and copy the
|
||||
// data over to the streams memory
|
||||
//
|
||||
Move(NewFormat.RawData, CurrentFormat.RawData, FMaxFmtSize);
|
||||
Self.SetSize(OutputBufferSize);
|
||||
Self.Seek(0,0);
|
||||
Self.Write(Output^, OutputBufferSize);
|
||||
|
||||
//
|
||||
// Unprepeare the header
|
||||
//
|
||||
Result := acmStreamUnprepareHeader(FStreamHandle,FStreamHeader, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamUnprepareHeader', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//
|
||||
// Close the stream
|
||||
//
|
||||
Result := acmStreamClose(FStreamHandle, 0);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
// SetError('acmStreamClose', Result);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
FreeMem(OutPut);
|
||||
end;
|
||||
|
||||
constructor TWaveConverter.Create;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize);
|
||||
|
||||
FillChar(CurrentFormat.Format, FMaxFmtSize, 0);
|
||||
FillChar(NewFormat.Format, FMaxFmtSize, 0);
|
||||
end;
|
||||
|
||||
destructor TWaveConverter.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TWaveConverter.LoadStream(Stream : TStream): integer;
|
||||
var
|
||||
Header: TRiffHeader;
|
||||
ID: TRiffID;
|
||||
Mem: Pointer;
|
||||
Data: PByteArray;
|
||||
|
||||
|
||||
NumRead: Integer;
|
||||
Pos: Integer;
|
||||
|
||||
begin
|
||||
Result := 0;
|
||||
try
|
||||
//read the header
|
||||
NumRead := Stream.Read(Header, SizeOf(Header));
|
||||
Pos := NumRead;
|
||||
|
||||
NumRead := Stream.Read(ID, SizeOf(ID));
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
if (Header.ID <> 'RIFF') or (ID <> 'WAVE') then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
while Pos < Stream.Size -1 do
|
||||
begin
|
||||
Dec(Pos,7);
|
||||
Stream.Seek(Pos, soFromBeginning);
|
||||
|
||||
NumRead := Stream.Read(Header, SizeOf(Header));
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
|
||||
if Header.ID = 'fmt ' then
|
||||
begin
|
||||
GetMem(Mem, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Mem^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
if Header.BytesFollowing < SizeOf(TWaveFormatEx) then
|
||||
Move(Mem^, CurrentFormat.Format , SizeOf(TWaveFormatEx))
|
||||
else
|
||||
Move(Mem^, CurrentFormat.Format, Header.BytesFollowing);
|
||||
finally
|
||||
FreeMem(Mem);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if Header.ID = 'fact' then
|
||||
begin
|
||||
GetMem(Data, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Data^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
finally
|
||||
FreeMem(Data);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if Header.ID = 'data' then
|
||||
begin
|
||||
if Header.BytesFollowing > 0 then
|
||||
begin
|
||||
GetMem(Data, Header.BytesFollowing);
|
||||
try
|
||||
NumRead := Stream.Read(Data^, Header.BytesFollowing);
|
||||
Pos := Pos + NumRead;
|
||||
|
||||
Self.SetSize(Header.BytesFollowing);
|
||||
Self.Seek(0,0);
|
||||
Self.Write(Data^, (*Header.BytesFollowing*)self.Size);
|
||||
finally
|
||||
FreeMem(Data);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Seek(0,0);
|
||||
finally
|
||||
// FileStream.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TWaveConverter.SaveWavToStream(MS: TStream): Integer;
|
||||
var
|
||||
CurrentPos : Integer;
|
||||
H : TRiffHeader;
|
||||
ID : TRiffID;
|
||||
begin
|
||||
Result := 0;
|
||||
try
|
||||
CurrentPos := Position;
|
||||
|
||||
H.ID := 'RIFF';
|
||||
H.BytesFollowing := 0;
|
||||
MS.Write(H, SizeOf(H));
|
||||
|
||||
ID := 'WAVE';
|
||||
MS.Write(ID, SizeOf(ID));
|
||||
|
||||
H.ID := 'fmt ';
|
||||
H.BytesFollowing := SizeOf(TWaveFormat) + 2;
|
||||
MS.Write(H, SizeOf(H));
|
||||
MS.Write(CurrentFormat.Format, SizeOf(TWaveFormat) + 2);
|
||||
|
||||
H.ID := 'data';
|
||||
H.BytesFollowing := Size;
|
||||
MS.Write(H, SizeOf(H));
|
||||
Seek(0,0);
|
||||
// MS.CopyFrom(Self, Size);
|
||||
// ms.Write( Self, Size);
|
||||
self.SaveToStream(MS);
|
||||
|
||||
|
||||
MS.Seek(0,0);
|
||||
H.ID := 'RIFF';
|
||||
H.BytesFollowing := MS.Size - SizeOf(H) +1;
|
||||
MS.Write(H,SizeOf(H));
|
||||
|
||||
Position := CurrentPos;
|
||||
// MS.Free;
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
Result := MCIERR_FILE_NOT_SAVED;
|
||||
// SetError('SaveFile', MCIERR_FILE_NOT_SAVED);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user