public int sceAtracAddStreamData(Atrac Atrac, int bytesToAdd) { Atrac.PrimaryBufferReaded += bytesToAdd; //throw (new NotImplementedException()); /* unimplemented(); Atrac3Object atrac3Object = getAtrac3ObjectById(atracID); logInfo("sceAtracAddStreamData(%d, %d)", atracID, bytesToAdd); */ return 0; }
private static void initStaticData() { if (staticInitDone) { return; } initImdctWindow(); Atrac.generateTables(); // Initialize the VLC tables for (int i = 0; i < 7; i++) { spectral_coeff_tab[i] = new VLC(); spectral_coeff_tab[i].initVLCSparse(9, Atrac3Data.huff_tab_sizes[i], Atrac3Data.huff_bits[i], Atrac3Data.huff_codes[i], null); } staticInitDone = true; }
public int sceAtracSetDataAndGetID(byte* DataPointer, int DataLength) { var Data = ArrayUtils.CreateArray<byte>(DataPointer, DataLength); var Atrac = new Atrac(PspEmulatorContext, Data); var AtracId = AtracList.Create(Atrac); return AtracId; }
private int _sceAtracDecodeData(Atrac Atrac, StereoShortSoundSample* SamplesOut, out int DecodedSamples, out int ReachedEnd, out int RemainingFramesToDecode) { // Decode DecodedSamples = Atrac.Decode(SamplesOut); ReachedEnd = 0; RemainingFramesToDecode = Atrac.RemainingFrames; //Console.WriteLine("{0}/{1} -> {2} : {3}", Atrac.DecodingOffsetInSamples, Atrac.TotalSamples, DecodedSamples, Atrac.DecodingReachedEnd); if (Atrac.DecodingReachedEnd) { if (Atrac.NumberOfLoops == 0) { DecodedSamples = 0; ReachedEnd = 1; RemainingFramesToDecode = 0; Console.WriteLine("SceKernelErrors.ERROR_ATRAC_ALL_DATA_DECODED)"); throw (new SceKernelException(SceKernelErrors.ERROR_ATRAC_ALL_DATA_DECODED)); } if (Atrac.NumberOfLoops > 0) Atrac.NumberOfLoops--; Atrac.DecodingOffset = (Atrac.LoopInfoList.Length > 0) ? Atrac.LoopInfoList[0].StartSample : 0; } //return Atrac.GetUidIndex(InjectContext); return 0; }
private Atrac TryToAlloc(Atrac Atrac) { var CodecType = Atrac.CodecType; var Count = InjectContext.GetInstance<HleUidPoolManager>().List<Atrac>().Count(_Atrac => _Atrac.CodecType == CodecType); if (CodecType == CodecType.PSP_MODE_AT_3_PLUS) { if (Count >= MaxAtrac3Plus) { throw (new SceKernelException(SceKernelErrors.ATRAC_ERROR_NO_ATRACID)); } } else if (CodecType == CodecType.PSP_MODE_AT_3) { if (Count >= MaxAtrac3) { throw (new SceKernelException(SceKernelErrors.ATRAC_ERROR_NO_ATRACID)); } } return Atrac; }
public int sceAtracSetLoopNum(Atrac Atrac, int NumberOfLoops) { if (Atrac.Smpl.LoopCount == 0) throw(new SceKernelException(SceKernelErrors.ATRAC_ERROR_UNSET_PARAM)); Atrac.NumberOfLoops = NumberOfLoops; return 0; }
public int sceAtracSetData(Atrac Atrac, byte* BufferPointer, int BufferSizeInBytes) { Atrac.SetData(BufferPointer, BufferSizeInBytes); return 0; }
public int sceAtracReleaseAtracID(Atrac Atrac) { Atrac.RemoveUid(InjectContext); return 0; }
public int sceAtracGetLoopStatus(Atrac Atrac, out int piLoopNum, out uint puiLoopStatus) { piLoopNum = 0; puiLoopStatus = 0; return 0; }
public int sceAtracGetInternalErrorInfo(Atrac Atrac, out int ErrorResult) { ErrorResult = 0; return 0; }
public int sceAtracGetChannel(Atrac Atrac, out int Channels) { Channels = Atrac.Format.AtracChannels; return 0; }
public int sceAtracGetBufferInfoForResetting(Atrac Atrac, uint uiSample, void* BufferInfoAddr) { //throw (new NotImplementedException()); return 0; }
public int sceAtracGetBufferInfoForReseting(Atrac Atrac, uint uiSample, PspBufferInfo* pBufferInfo) { throw (new NotImplementedException()); /* unimplemented(); return 0; */ }
public int sceAtracGetBitrate(Atrac Atrac, out uint Bitrate) { //Bitrate = Atrac.Format.Bitrate; uint _AtracBitrate = (uint)((Atrac.Format.BytesPerFrame * 352800) / 1000); if (Atrac.CodecType == CodecType.PSP_MODE_AT_3_PLUS) { _AtracBitrate = ((_AtracBitrate >> 11) + 8) & 0xFFFFFFF0; } else { _AtracBitrate = (_AtracBitrate + 511) >> 10; } Bitrate = _AtracBitrate; return 0; }
public int sceAtracGetStreamDataInfo(Atrac Atrac, out PspPointer WritePointerPointer, out int AvailableBytes, out int ReadOffset) { //throw (new NotImplementedException()); WritePointerPointer = Atrac.PrimaryBuffer.Low; // @FIXME!! AvailableBytes = Atrac.PrimaryBuffer.Size; ReadOffset = Atrac.PrimaryBufferReaded; return 0; }
public int sceAtracIsSecondBufferNeeded(Atrac Atrac) { return 0; }
public int sceAtracGetMaxSample(Atrac Atrac, out int MaxNumberOfSamples) { MaxNumberOfSamples = Atrac.MaximumSamples; return 0; }
public int sceAtracResetPlayPosition(Atrac Atrac, uint uiSample, uint uiWriteByteFirstBuf, uint uiWriteByteSecondBuf) { //throw (new NotImplementedException()); return 0; }
public int sceAtracGetNextDecodePosition(Atrac Atrac, out int SamplePosition) { if (Atrac.DecodingReachedEnd) throw (new SceKernelException(SceKernelErrors.ERROR_ATRAC_ALL_DATA_DECODED)); SamplePosition = Atrac.DecodingOffset; //Console.WriteLine(" {0}", SamplePosition); return 0; }
public int sceAtracSetHalfwayBuffer(Atrac Atrac, void* halfBuffer, uint readSize, uint halfBufferSize) { //throw (new NotImplementedException()); return 0; }
public int sceAtracGetNextSample(Atrac Atrac, out int NumberOfSamplesInNextFrame) { NumberOfSamplesInNextFrame = 0; try { //Console.Error.WriteLine(Atrac.Format.ToStringDefault()); NumberOfSamplesInNextFrame = Atrac.GetNumberOfSamplesInNextFrame(); return 0; } catch (Exception Exception) { NumberOfSamplesInNextFrame = 1; Console.Error.WriteLine(Exception); return 0; } }
public int sceAtracSetSecondBuffer(Atrac Atrac, out byte pucSecondBufferAddr, uint uiSecondBufferByte) { throw (new NotImplementedException()); /* unimplemented(); //unimplemented(); return 0; */ }
public int sceAtracGetOutputChannel(CpuThreadState CpuThreadState, Atrac Atrac, out int OutputChannel) { OutputChannel = sceAudio.sceAudioChReserve(CpuThreadState, -1, Atrac.MaximumSamples, PspAudio.FormatEnum.Stereo); //Console.WriteLine("{0}", *OutputChannelPointer); Console.ReadKey(); return 0; }
public int sceAtracGetRemainFrame(Atrac Atrac, out int RemainFramePointer) { RemainFramePointer = Atrac.RemainingFrames; return 0; }
public int sceAtracGetSecondBufferInfo(Atrac Atrac, out uint puiPosition, out uint puiDataByte) { //throw (new NotImplementedException()); puiPosition = 0; puiDataByte = 0; throw (new SceKernelException(SceKernelErrors.ERROR_ATRAC_SECOND_BUFFER_NOT_NEEDED)); }
public int sceAtracDecodeData(Atrac Atrac, StereoShortSoundSample* SamplesOut, [HleInvalidAsInvalidPointer] out int DecodedSamples, [HleInvalidAsInvalidPointer] out int ReachedEnd, [HleInvalidAsInvalidPointer] out int RemainingFramesToDecode) { return _sceAtracDecodeData(Atrac, SamplesOut, out DecodedSamples, out ReachedEnd, out RemainingFramesToDecode); }
public int sceAtracGetSoundSample(Atrac Atrac, int* EndSamplePointer, int* LoopStartSamplePointer, int* LoopEndSamplePointer) { var HasLoops = (Atrac.LoopInfoList != null) && (Atrac.LoopInfoList.Length > 0); if (EndSamplePointer != null) *EndSamplePointer = Atrac.Fact.EndSample; if (LoopStartSamplePointer != null) *LoopStartSamplePointer = HasLoops ? Atrac.LoopInfoList[0].StartSample : -1; if (LoopEndSamplePointer != null) *LoopEndSamplePointer = HasLoops ? Atrac.LoopInfoList[0].EndSample : -1; return 0; }
public int sceAtracGetAtracID(CodecType CodecType) { var Atrac = new Atrac(PspEmulatorContext, CodecType); var AtracId = AtracList.Create(Atrac); return AtracId; }
private int decodeFrame() { int ret; if (ctx.codingMode == JOINT_STEREO) { // channel coupling mode // decode Sound Unit 1 ret = decodeChannelSoundUnit(ctx.units[0], ctx.samples[0], 0, JOINT_STEREO); if (ret != 0) { return(ret); } // Framedata of the su2 in the joint-stereo mode is encoded in // reverse byte order so we need read in reverse direction br.seek(ctx.blockAlign - 1); br.Direction = -1; // Skip the sync codes (0xF8). while (br.peek(8) == 0xF8) { br.read(8); } // Fill the Weighting coeffs delay buffer Array.Copy(ctx.weightingDelay, 2, ctx.weightingDelay, 0, 4); ctx.weightingDelay[4] = br.read1(); ctx.weightingDelay[5] = br.read(3); for (int i = 0; i < 4; i++) { ctx.matrixCoeffIndexPrev[i] = ctx.matrixCoeffIndexNow[i]; ctx.matrixCoeffIndexNow[i] = ctx.matrixCoeffIndexNext[i]; ctx.matrixCoeffIndexNext[i] = br.read(2); } // Decode sound Unit 2. ret = decodeChannelSoundUnit(ctx.units[1], ctx.samples[1], 1, JOINT_STEREO); br.Direction = 1; br.seek(ctx.blockAlign); if (ret != 0) { return(ret); } // Reconstruct the channel coefficients reverseMatrixing(ctx.samples[0], ctx.samples[1], ctx.matrixCoeffIndexPrev, ctx.matrixCoeffIndexNow); channelWeighting(ctx.samples[0], ctx.samples[1], ctx.weightingDelay); } else { // normal stereo mode or mono // Decode the channel sound units for (int i = 0; i < ctx.channels; i++) { // Set the bitstream reader at the start of a channel sound unit br.seek(i * ctx.blockAlign / ctx.channels); ret = decodeChannelSoundUnit(ctx.units[i], ctx.samples[i], i, ctx.codingMode); if (ret != 0) { return(ret); } } } // Apply the iQMF synthesis filter for (int i = 0; i < ctx.channels; i++) { Atrac.iqmf(ctx.samples[i], 0, ctx.samples[i], 256, 256, ctx.samples[i], 0, ctx.units[i].delayBuf1, ctx.tempBuf); Atrac.iqmf(ctx.samples[i], 768, ctx.samples[i], 512, 256, ctx.samples[i], 512, ctx.units[i].delayBuf2, ctx.tempBuf); Atrac.iqmf(ctx.samples[i], 0, ctx.samples[i], 512, 512, ctx.samples[i], 0, ctx.units[i].delayBuf3, ctx.tempBuf); } return(0); }