From f55eefac670fe4b514c9a63604e28b2293925c69 Mon Sep 17 00:00:00 2001 From: Idan Sheinberg Date: Wed, 10 Jul 2024 00:30:08 +0300 Subject: [PATCH] Work on decoding stuff --- .../org/sheinbergon/aac/jna/FdkAACLib.java | 79 ++++++---- .../sheinbergon/aac/jna/FdkAACLibFacade.java | 12 +- .../aac/jna/structure/AACDecoder.java | 142 ++++++++++++++++++ .../aac/jna/structure/AACDecoderCAncData.java | 28 ++++ .../structure/AACDecoderFDKSignalDelay.java | 26 ++++ .../jna/structure/AACDecoderSBRParams.java | 24 +++ .../structure/AACDecoderSamplingRateInfo.java | 32 ++++ .../aac/jna/structure/AACEncInfo.java | 2 +- .../jna/structure/DecoderCProgramConfig.java | 79 ++++++++++ .../structure/FDKChannelMapDescription.java | 26 ++++ .../aac/jna/structure/FDKQmfDomainGC.java | 87 +++++++++++ 11 files changed, 498 insertions(+), 39 deletions(-) create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/AACDecoder.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderCAncData.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderFDKSignalDelay.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSBRParams.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSamplingRateInfo.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/DecoderCProgramConfig.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/FDKChannelMapDescription.java create mode 100644 src/main/java/org/sheinbergon/aac/jna/structure/FDKQmfDomainGC.java diff --git a/src/main/java/org/sheinbergon/aac/jna/FdkAACLib.java b/src/main/java/org/sheinbergon/aac/jna/FdkAACLib.java index c8055df..8a13f8d 100644 --- a/src/main/java/org/sheinbergon/aac/jna/FdkAACLib.java +++ b/src/main/java/org/sheinbergon/aac/jna/FdkAACLib.java @@ -1,53 +1,68 @@ package org.sheinbergon.aac.jna; import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; +import com.sun.jna.ptr.ShortByReference; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.experimental.Accessors; -import org.sheinbergon.aac.jna.structure.AACEncBufDesc; -import org.sheinbergon.aac.jna.structure.AACEncInArgs; -import org.sheinbergon.aac.jna.structure.AACEncInfo; -import org.sheinbergon.aac.jna.structure.AACEncOutArgs; -import org.sheinbergon.aac.jna.structure.AACEncoder; +import org.sheinbergon.aac.jna.structure.*; @SuppressWarnings("MethodName") public final class FdkAACLib { - @Getter - @Accessors(fluent = true) - @RequiredArgsConstructor - enum Functions { - INFO("aacEncInfo"), - SET_PARAM("aacEncoder_SetParam"), - OPEN("accEncOpen"), - CLOSE("accEncClose"), - ENCODE("aacEncEncode"); + @Getter + @Accessors(fluent = true) + @RequiredArgsConstructor + enum Functions { + ENCODER_INFO("aacEncInfo"), + ENCODER_SET_PARAM("aacEncoder_SetParam"), + ENCODER_OPEN("accEncOpen"), + ENCODER_CLOSE("accEncClose"), + ENCODER_ENCODE("aacEncEncode"); - private final String libraryFunctionName; - } + private final String libraryFunctionName; + } - private static final String FDK_AAC = "fdk-aac"; + private static final String FDK_AAC = "fdk-aac"; - static { - Native.register(FDK_AAC); - } + static { + Native.register(FDK_AAC); + } - static native int aacEncOpen(PointerByReference handle, int encModules, int maxChannels); + static native int aacEncOpen(PointerByReference handle, int encModules, int maxChannels); - static native int aacEncClose(PointerByReference handle); + static native int aacEncClose(PointerByReference handle); - static native int aacEncEncode( - AACEncoder hAacEncoder, - AACEncBufDesc inBufDesc, - AACEncBufDesc outBufDesc, - AACEncInArgs inargs, - AACEncOutArgs outargs); + static native int aacEncEncode( + AACEncoder hAacEncoder, + AACEncBufDesc inBufDesc, + AACEncBufDesc outBufDesc, + AACEncInArgs inargs, + AACEncOutArgs outargs); - static native int aacEncInfo(AACEncoder hAacEncoder, AACEncInfo pInfo); + static native int aacEncInfo(AACEncoder hAacEncoder, AACEncInfo pInfo); - static native int aacEncoder_SetParam(AACEncoder encoder, int param, int value); + static native int aacEncoder_SetParam(AACEncoder encoder, int param, int value); - private FdkAACLib() { - } + static native Pointer aacDecoder_Open(int transportFmt, int nrOfLayers); + + static native void aacDecoder_Close(AACDecoder self); + + static native int aacDecoder_Fill( + AACDecoder self, + Pointer[] Buffer, + int[] bufferSize, + IntByReference bytesValid); + + static native int aacDecoder_DecodeFrame( + AACDecoder self, + ShortByReference pTimeData, + int timeDataSize, + int flags); + + private FdkAACLib() { + } } diff --git a/src/main/java/org/sheinbergon/aac/jna/FdkAACLibFacade.java b/src/main/java/org/sheinbergon/aac/jna/FdkAACLibFacade.java index a5800f9..de7c288 100644 --- a/src/main/java/org/sheinbergon/aac/jna/FdkAACLibFacade.java +++ b/src/main/java/org/sheinbergon/aac/jna/FdkAACLibFacade.java @@ -47,7 +47,7 @@ public static AACEncoder openEncoder( final int maxChannels) { val pointerRef = new PointerByReference(); val result = AACEncError.valueOf(FdkAACLib.aacEncOpen(pointerRef, modules, maxChannels)); - verifyResult(result, FdkAACLib.Functions.OPEN); + verifyResult(result, FdkAACLib.Functions.ENCODER_OPEN); return AACEncoder.of(pointerRef); } @@ -59,7 +59,7 @@ public static AACEncoder openEncoder( public static void closeEncoder(final @Nonnull AACEncoder encoder) { val pointerRef = new PointerByReference(encoder.getPointer()); val result = AACEncError.valueOf(FdkAACLib.aacEncClose(pointerRef)); - verifyResult(result, FdkAACLib.Functions.CLOSE); + verifyResult(result, FdkAACLib.Functions.ENCODER_CLOSE); } /** @@ -69,7 +69,7 @@ public static void closeEncoder(final @Nonnull AACEncoder encoder) { */ public static void initEncoder(final @Nonnull AACEncoder encoder) { val result = AACEncError.valueOf(FdkAACLib.aacEncEncode(encoder, null, null, null, null)); - verifyResult(result, FdkAACLib.Functions.ENCODE); + verifyResult(result, FdkAACLib.Functions.ENCODER_ENCODE); } /** @@ -101,7 +101,7 @@ public static Optional encode( .filter(result -> result != AACEncError.AACENC_ENCODE_EOF) .map(result -> { outArgs.readField("numOutBytes"); - verifyResult(result, FdkAACLib.Functions.ENCODE); + verifyResult(result, FdkAACLib.Functions.ENCODER_ENCODE); return outBufferDescriptor.bufs .getValue().getByteArray(0, outArgs.numOutBytes); }); @@ -116,7 +116,7 @@ public static Optional encode( public static AACEncInfo getEncoderInfo(final @Nonnull AACEncoder encoder) { val info = new AACEncInfo(); val result = AACEncError.valueOf(FdkAACLib.aacEncInfo(encoder, info)); - verifyResult(result, FdkAACLib.Functions.INFO); + verifyResult(result, FdkAACLib.Functions.ENCODER_INFO); info.read(); return info; } @@ -134,7 +134,7 @@ public static void setEncoderParam( final @Nonnull AACEncParam param, final int value) { val result = AACEncError.valueOf(FdkAACLib.aacEncoder_SetParam(encoder, param.getValue(), value)); - verifyResult(result, FdkAACLib.Functions.SET_PARAM); + verifyResult(result, FdkAACLib.Functions.ENCODER_SET_PARAM); } /** diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoder.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoder.java new file mode 100644 index 0000000..f305a2c --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoder.java @@ -0,0 +1,142 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.PointerByReference; +import org.sheinbergon.aac.jna.util.JNASupport; + +import javax.annotation.Nonnull; +import java.util.List; + +/** + * Maps to AAC_DECODER_INSTANCE struct. + * + * @see fdk-aac/libAACdec/src/aacdecoder.h + */ +@SuppressWarnings({ + "JavadocVariable", + "VisibilityModifier", + "MissingJavadocMethod", + "MagicNumber", + "MemberName", + "PointlessArithmeticExpression", + "unused"}) +public final class AACDecoder extends Structure { + + private static final int AACDEC_MAX_NUM_PREROLL_AU = 3; + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(AACDecoder.class); + + public static AACDecoder of(final @Nonnull PointerByReference pointerReference) { + return new AACDecoder(pointerReference.getValue()); + } + + private AACDecoder(final @Nonnull Pointer pointer) { + super(pointer); + setAlignType(Structure.ALIGN_NONE); // Make sure field size alignments are as expected + read(); // Read once after initialize from provided pointer + } + + public int aacChannels; + public int[] ascChannels = new int[1]; + public int blockNumber; + public int nrOfLayers; + public int outputInterleaved; + public int aacOutDataHeadroom; + public Pointer hInput; + public AACDecoderSamplingRateInfo[] samplingRateInfo = new AACDecoderSamplingRateInfo[1]; + public byte frameOK; + public int[] flags = new int[1]; + public int[] elFlags = new int[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)]; + + public int[] elements = new int[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)]; + + public byte[] elTags = new byte[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)]; + public byte[] chMapping = new byte[((8) * 2)]; + public int[] channelType = new int[(8)]; + public byte[] channelIndices = new byte[(8)]; + public FDKChannelMapDescription mapDescr; + public byte chMapIndex; + public int sbrDataLen; + public DecoderCProgramConfig pce; + CStreamInfo + streamInfo; /*!< Pointer to StreamInfo data (read from the bitstream) */ + CAacDecoderChannelInfo + *pAacDecoderChannelInfo[(8)]; /*!< Temporal channel memory */ + CAacDecoderStaticChannelInfo + *pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */ + + public Pointer workBufferCore1; + public Pointer workBufferCore2; + public Pointer pTimeData2; + public int timeData2Size; + + CpePersistentData *cpeStaticData[( + 3*((8)*2)+(((8)*2))/2+4*(1)+ + 1)]; /*!< Pointer to persistent data shared by both channels of a CPE. +This structure is allocated once for each CPE. */ + + CConcealParams concealCommonData; + CConcealmentMethod concealMethodUser; + + CUsacCoreExtensions usacCoreExt; /*!< Data and handles to extend USAC FD/LPD + core decoder (SBR, MPS, ...) */ + public int[] numUsacElements = new int[(1 * 1)]; + public byte[] usacStereoConfigIndex = new byte[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)]; + public Pointer[] pUsacConfig = new Pointer[(1 * 1)]; + public int nbDiv; + public byte useLdQmfTimeAlign; + public int aacChannelsPrev; + public int[] channelTypePrev = new int[(8)]; + public byte[] channelIndicesPrev = new byte[(8)]; + public byte downscaleFactor; + public byte downscaleFactorInBS; + public Pointer hSbrDecoder; + public byte sbrEnabled; + public byte sbrEnabledPrev; + public byte psPossible; + public AACDecoderSBRParams sbrParams; + public ByteByReference pDrmBsBuffer; + public short drmBsBufferSize; + FDK_QMF_DOMAIN + qmfDomain; /*!< Instance of module for QMF domain data handling */ + public int qmfModeCurr; + public int qmfModeUser; + public Pointer hDrcInfo; + public int metadataExpiry; + public Pointer pMpegSurroundDecoder; + public byte mpsEnableUser; + public byte mpsEnableCurr; + public byte mpsApplicable; + public byte mpsOutputMode; + public int mpsOutChannelsLast; + public int mpsFrameSizeLast; + public AACDecoderCAncData ancData; + public Pointer hPcmUtils; + public Pointer hLimiter; + public byte limiterEnableUser; + public byte limiterEnableCurr; + // TODO - This might need to use smarter size of types, as signed long is 32BIT in windows platforms + public long[] extGain = new long[1]; + public int extGainDelay; + public Pointer hUniDrcDecoder; + public byte multibandDrcPresent; + public byte numTimeSlots; + public int[] loudnessInfoSetPosition = new int[3]; + public byte defaultTargetLoudness; + public Pointer[] pTimeDataFlush = new Pointer[((8) * 2)]; + public byte flushStatus; + public byte flushCnt; + public byte buildUpStatus; + public byte buildUpCnt; + public byte hasAudioPreRoll; + public int[] prerollAULength = new int[AACDEC_MAX_NUM_PREROLL_AU + 1]; + public int accessUnit; + public byte applyCrossfade; + public AACDecoderFDKSignalDelay usacResidualDelay; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderCAncData.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderCAncData.java new file mode 100644 index 0000000..99908ae --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderCAncData.java @@ -0,0 +1,28 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to CAncData struct. + * + * @see fdk-aac/libAACdec/src/aacdecoder.h + */ +@SuppressWarnings("MagicNumber") +public class AACDecoderCAncData extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(AACDecoderCAncData.class); + + public Pointer buffer; + public int bufferSize; + public int[] offset = new int[8]; + public int nrElements; + + protected List getFieldOrder() { + return FIELD_ORDER; + } +} + diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderFDKSignalDelay.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderFDKSignalDelay.java new file mode 100644 index 0000000..94e13b2 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderFDKSignalDelay.java @@ -0,0 +1,26 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to FDK_SignalDelay struct. + * + * @see fdk-aac/libAACdec/src/FDK_delay.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class AACDecoderFDKSignalDelay extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(AACDecoderFDKSignalDelay.class); + public Pointer delay_line; + public short delay; + public byte num_channels; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSBRParams.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSBRParams.java new file mode 100644 index 0000000..f920b78 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSBRParams.java @@ -0,0 +1,24 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ShortByReference; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to SamplingRateInfo struct. + * + * @see fdk-aac/libAACdec/src/aacdecoder.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class AACDecoderSBRParams extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(AACDecoderSBRParams.class); + public int nsDelay; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSamplingRateInfo.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSamplingRateInfo.java new file mode 100644 index 0000000..d86c5f6 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACDecoderSamplingRateInfo.java @@ -0,0 +1,32 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import com.sun.jna.ptr.ShortByReference; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to SamplingRateInfo struct. + * + * @see fdk-aac/libAACdec/include/channelinfo.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class AACDecoderSamplingRateInfo extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(AACDecoderSamplingRateInfo.class); + + public ShortByReference ScaleFactorBands_Long; + public ShortByReference ScaleFactorBands_Short; + public byte NumberOfScaleFactorBands_Long; + public byte NumberOfScaleFactorBands_Short; + public int samplingRateIndex; + public int samplingRate; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/AACEncInfo.java b/src/main/java/org/sheinbergon/aac/jna/structure/AACEncInfo.java index 0429322..4dfd696 100644 --- a/src/main/java/org/sheinbergon/aac/jna/structure/AACEncInfo.java +++ b/src/main/java/org/sheinbergon/aac/jna/structure/AACEncInfo.java @@ -9,7 +9,7 @@ /** * Maps to AACENC_InfoStruct struct. *

- * in @see fdk-aac/libAACenc/include/aacenc_lib.h + * in @see fdk-aac/libAACenc/include/aacenc_lib.h */ @SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) public class AACEncInfo extends Structure { diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/DecoderCProgramConfig.java b/src/main/java/org/sheinbergon/aac/jna/structure/DecoderCProgramConfig.java new file mode 100644 index 0000000..bab2208 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/DecoderCProgramConfig.java @@ -0,0 +1,79 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to FDK_channelMapDescr struct. + * + * @see fdk-aac/libMpegTPDec/include/tp_data.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class DecoderCProgramConfig extends Structure { + + private static final int PC_COMMENTLENGTH = 256; + private static final int PC_FSB_CHANNELS_MAX = 16; + private static final int PC_LFE_CHANNELS_MAX = 4; + private static final int PC_ASSOCDATA_MAX = 8; + + private static final int PC_CCEL_MAX = 16; + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(DecoderCProgramConfig.class); + + /* PCE bitstream elements: */ + public byte ElementInstanceTag; + public byte Profile; + public byte SamplingFrequencyIndex; + public byte NumFrontChannelElements; + public byte NumSideChannelElements; + public byte NumBackChannelElements; + public byte NumLfeChannelElements; + public byte NumAssocDataElements; + public byte NumValidCcElements; + + public byte MonoMixdownPresent; + public byte MonoMixdownElementNumber; + + public byte StereoMixdownPresent; + public byte StereoMixdownElementNumber; + + public byte MatrixMixdownIndexPresent; + public byte MatrixMixdownIndex; + public byte PseudoSurroundEnable; + + public byte[] FrontElementIsCpe = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] FrontElementTagSelect = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] FrontElementHeightInfo = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] SideElementIsCpe = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] SideElementTagSelect = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] SideElementHeightInfo = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] BackElementIsCpe = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] BackElementTagSelect = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] BackElementHeightInfo = new byte[PC_FSB_CHANNELS_MAX]; + ; + public byte[] LfeElementTagSelect = new byte[PC_LFE_CHANNELS_MAX]; + public byte[] AssocDataElementTagSelect = new byte[PC_ASSOCDATA_MAX]; + public byte[] CcElementIsIndSw = new byte[PC_CCEL_MAX]; + public byte[] ValidCcElementTagSelect = new byte[PC_CCEL_MAX]; + public byte CommentFieldBytes; + public byte[] Comment = new byte[PC_COMMENTLENGTH]; + public byte isValid; + public byte NumChannels; + public byte NumEffectiveChannels; + public byte elCounter; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/FDKChannelMapDescription.java b/src/main/java/org/sheinbergon/aac/jna/structure/FDKChannelMapDescription.java new file mode 100644 index 0000000..ab9e094 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/FDKChannelMapDescription.java @@ -0,0 +1,26 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to FDK_channelMapDescr struct. + * + * @see fdk-aac/libSYS/include/syslib_channelMapDescr.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class FDKChannelMapDescription extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(FDKChannelMapDescription.class); + public Pointer pMapInfoTab; + public int mapInfoTabLen; + public int fPassThrough; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +} diff --git a/src/main/java/org/sheinbergon/aac/jna/structure/FDKQmfDomainGC.java b/src/main/java/org/sheinbergon/aac/jna/structure/FDKQmfDomainGC.java new file mode 100644 index 0000000..21b5d96 --- /dev/null +++ b/src/main/java/org/sheinbergon/aac/jna/structure/FDKQmfDomainGC.java @@ -0,0 +1,87 @@ +package org.sheinbergon.aac.jna.structure; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import org.sheinbergon.aac.jna.util.JNASupport; + +import java.util.List; + +/** + * Maps to FDK_QMF_DOMAIN_GC struct. + * + * @see fdk-aac/libFDK/include/FDK_qmf_domain.h + */ +@SuppressWarnings({"JavadocVariable", "VisibilityModifier"}) +public class FDKQmfDomainGC extends Structure { + + private static final List FIELD_ORDER = JNASupport.structureFieldOrder(FDKQmfDomainGC.class); + /* + * Flag to signal that QMF domain is set + * explicitly instead of SBR and MPS init + * routines. + */ + public byte qmfDomainExplicitConfig; + // Number of QMF input channels. */ + public byte nInputChannels; + // Corresponding requested not yet active configuration parameter. + public byte nInputChannels_requested; + // Number of QMF output channels. + public byte nOutputChannels; + public byte nOutputChannels_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + public byte + parkChannel; /*!< signal to automatically allocate additional memory to + park a channel if only one processing channel is + available. */ + public byte parkChannel_requested; + FIXP_DBL * + pWorkBuffer[QMF_MAX_WB_SECTIONS]; /*!< Pointerarray to volatile memory. */ + UINT flags; /*!< Flags to be set on all QMF analysis/synthesis filter + instances. */ + UINT flags_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + public byte nBandsAnalysis; /*!< Number of QMF analysis bands for all input + channels. */ + public byte nBandsAnalysis_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + USHORT nBandsSynthesis; /*!< Number of QMF synthesis bands for all output + channels. */ + USHORT + nBandsSynthesis_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + + // Number of QMF time slots (stored in work buffer memory). + public byte nQmfTimeSlots; + + // Corresponding requested not yet active configuration parameter. + public byte nQmfTimeSlots_requested; + public byte + nQmfOvTimeSlots; /*!< Number of QMF overlap/delay time slots (stored in + persistent memory). */ + public byte nQmfOvTimeSlots_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + + /* Number of QMF bands which are processed by the decoder. + * Typically this is equal to nBandsSynthesis. + * But, it may differ if the QMF based resampler is being used. + */ + public byte nQmfProcBands; + public byte nQmfProcBands_requested; /*!< Corresponding requested not yet active + configuration parameter. */ + + /* + * Number of complete QMF channels which need to + * coexist in memory at the same time. For most cases + * this is 1 which means the work buffer can be shared + * between audio channels. + */ + public byte nQmfProcChannels; + + // Corresponding requested not yet active configuration parameter. + public byte nQmfProcChannels_requested; + + @Override + protected List getFieldOrder() { + return FIELD_ORDER; + } +}