program iq24be_to_cf32; {$MODE Delphi} uses Classes, SysUtils; const PAIRS_PER_BLOCK = 8192; SCALE = 1.0 / 8388608.0; var Input, Output: TFileStream; Raw: array[0..PAIRS_PER_BLOCK * 6 - 1] of Byte; IQ: array[0..PAIRS_PER_BLOCK * 2 - 1] of Single; InputName, OutputName: string; BytesRead, Pairs, i, p: Integer; I24, Q24: LongInt; TotalPairs: QWord; begin if ParamCount < 1 then begin WriteLn('Usage: iq24be_to_cf32 [output.cf32le]'); Halt(2); end; InputName := ParamStr(1); if ParamCount >= 2 then OutputName := ParamStr(2) else OutputName := ChangeFileExt(InputName, '.cf32le'); Input := TFileStream.Create(InputName, fmOpenRead or fmShareDenyNone); Output := TFileStream.Create(OutputName, fmCreate); try TotalPairs := 0; repeat BytesRead := Input.Read(Raw[0], SizeOf(Raw)); Pairs := BytesRead div 6; p := 0; for i := 0 to Pairs - 1 do begin I24 := (LongInt(Raw[p]) shl 16) or (LongInt(Raw[p + 1]) shl 8) or LongInt(Raw[p + 2]); Q24 := (LongInt(Raw[p + 3]) shl 16) or (LongInt(Raw[p + 4]) shl 8) or LongInt(Raw[p + 5]); if (I24 and $800000) <> 0 then I24 := I24 or LongInt($FF000000); if (Q24 and $800000) <> 0 then Q24 := Q24 or LongInt($FF000000); IQ[i * 2] := I24 * SCALE; IQ[i * 2 + 1] := Q24 * SCALE; Inc(p, 6); end; if Pairs > 0 then Output.WriteBuffer(IQ[0], Pairs * 2 * SizeOf(Single)); Inc(TotalPairs, Pairs); until BytesRead < SizeOf(Raw); WriteLn('output=', OutputName); WriteLn('iq_pairs=', TotalPairs); finally Output.Free; Input.Free; end; end.