• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Embedded Software » Multimedia Software Codecs » Multimedia Software Codecs forum » DM365 AAC decode with ADTS headers
Share
Multimedia Software Codecs
  • Forum
Options
  • Subscribe via RSS

Forums

DM365 AAC decode with ADTS headers

  • Pete Eberlein
    Posted by Pete Eberlein
    on Sep 16 2011 19:02 PM
    Intellectual280 points

    Hi All,

    Using dm365_aaclcenc_3_5_00 and dm365_aaclcdec_6_1_00 production codecs, I encode the audio using aacenc with ADTS headers just fine.  It plays correctly in VLC and mplayer.  But when I try to decode the file using aacdec, no bytes are consumed nor output, and the Adec1_process call returns no errors.  The Adec1 is configured with ITTIAM_ENHAACPDEC_Params aacParams = ENHAACPDECODER_ITTIAM_PARAMS;

    aacParams.i_max_channels = 2
             .i_flag_08khz_out = 0
             .i_flag_16khz_out = 0
             .i_interleave = 1
             .i_disable_sync = 0
             .i_mp4_flag = 0
             .i_sampfreq = 48000
             .i_coupling_channel = 0

    I tried i_disable_sync = 1, but that didn't work either.

    Here's what I see when I print the results of the Adec1_process call, and the first few bytes sent:

    audioPlaybackThrFxn: AAC process consumed 0, size 512, output 0
      ff f9 4c 80  40 1f fc 21  20 03 40 68  1b ff c0 00
    audioPlaybackThrFxn: AAC process consumed 0, size 677, output 0
      ff f9 4c 80  54 bf fc 21  4e 6c fe ff  3f ff ff ff
    audioPlaybackThrFxn: AAC process consumed 0, size 562, output 0
      ff f9 4c 80  46 5f fc 21  7c 4b bd 7b  ff ff ff fe
    audioPlaybackThrFxn: AAC process consumed 0, size 542, output 0
      ff f9 4c 80  43 df fc 21  1c 4f b9 fe  ff ff ff fe

    I can encode and decode successfully without ADTS headers, but I need to use ADTS headers for this application.  Any suggestions?

    Here's the file: 2055.output.aac

    aacdec adts DM365
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Sonal Gupta
    Posted by Sonal Gupta
    on Sep 23 2011 04:57 AM
    Prodigy10 points

    The issue here is that the params are set for "raw" aac file.

    If you are trying to use a ADTS file, then in the params structure .i_sampfreq should be set to 0.

     

    Regards,

    Sonal

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jing C
    Posted by Jing C
    on Mar 06 2012 23:25 PM
    Intellectual560 points

    Hi Pete,

    I also using dm365_aaclcdec_6_1_00 production codecs to decode the AAC file, but i use the demo "audio.c(dec)" in the folder "dvsdk_2_10_01_18_demos_update" ,  and i cannot decode successfully without /with ADTS headers. The aac file is single channel with 16000 samplerate,  here are my configurations:

    AUDDEC1_Params          defaultParams       = Adec1_Params_DEFAULT;
    AUDDEC1_DynamicParams   defaultDynParams    = Adec1_DynamicParams_DEFAULT;

    const AUDDEC1_Params Adec1_Params_DEFAULT = {
        sizeof(AUDDEC1_Params),
        16,
        IAUDIO_INTERLEAVED,
        XDM_LE_16,
    };

    const AUDDEC1_DynamicParams Adec1_DynamicParams_DEFAULT = {
        sizeof(AUDDEC1_DynamicParams),
        XDAS_FALSE,
    };

    Sound_Attrs  sAttrs = Sound_Attrs_STEREO_DEFAULT;

    sAttrs.sampleRate  = 16000;
    sAttrs.channels  = 1;      
    sAttrs.bufSize     = 4096;
    sAttrs.mode   = Sound_Mode_OUTPUT; 
    sAttrs.soundStd  = Sound_Std_ALSA;

    And the Adec1.c file:

    /******************************************************************************
     * Adec1_create
     ******************************************************************************/
    Adec1_Handle Adec1_create(Engine_Handle hEngine, Char *codecName,
                            AUDDEC1_Params *params,
                            AUDDEC1_DynamicParams *dynParams)
    {
        Adec1_Handle        hAd1;
        AUDDEC1_Handle      hDecode;
        AUDDEC1_Status      decStatus;
        XDAS_Int32          status;

        if (hEngine == NULL || codecName == NULL ||
            params == NULL || dynParams == NULL) {
            Dmai_err0("Cannot pass null for engine, codec name, params or "
                      "dynamic params\n");
            return NULL;
        }

        /* Allocate space for the object */
        hAd1 = (Adec1_Handle)calloc(1, sizeof(Adec1_Object));

        if (hAd1 == NULL) {
            Dmai_err0("Failed to allocate space for Adec1 Object\n");
            return NULL;
        }

        /* Create audio decoder */
        hDecode = AUDDEC1_create(hEngine, codecName, params);

        if (hDecode == NULL) {
            Dmai_err1("Failed to open audio decode algorithm: %s\n", codecName);
            cleanup(hAd1);
            return NULL;
        }

        /* Set dynamic parameters */
        decStatus.data.buf = NULL;
        decStatus.size = sizeof(AUDDEC1_Status);
        status = AUDDEC1_control(hDecode, XDM_SETPARAMS, dynParams, &decStatus);

        if (status != AUDDEC1_EOK) {
            Dmai_err1("XDM_SETPARAMS failed, status=%d\n", status);
            cleanup(hAd1);
            return NULL;
        }

        /* Get buffer information from audio decoder */
        status = AUDDEC1_control(hDecode, XDM_GETBUFINFO, dynParams, &decStatus);

        if (status != AUDDEC1_EOK) {
            Dmai_err0("XDM_GETBUFINFO control failed\n");
            cleanup(hAd1);
            return NULL;
        }

        Dmai_dbg2("Codec requires buffer sizes in %u and out %u\n",
                  decStatus.bufInfo.minInBufSize[0],
                  decStatus.bufInfo.minOutBufSize[0]);

        memcpy(hAd1->minInBufSize,
               decStatus.bufInfo.minInBufSize, sizeof(hAd1->minInBufSize));
        hAd1->minNumInBufs = decStatus.bufInfo.minNumInBufs;
        memcpy(hAd1->minOutBufSize,
               decStatus.bufInfo.minOutBufSize, sizeof(hAd1->minOutBufSize));
        hAd1->minNumOutBufs = decStatus.bufInfo.minNumOutBufs;

        hAd1->hDecode = hDecode;
        hAd1->sampleRate = 0;     //    Do i need to change this to 16000?

        return hAd1;
    }

    Int Adec1_process(Adec1_Handle hAd1, Buffer_Handle hInBuf, Buffer_Handle hOutBuf)
    {
        XDM1_BufDesc            inBufDesc;
        XDM1_BufDesc            outBufDesc;
        XDAS_Int32              status;
        AUDDEC1_InArgs          inArgs;
        AUDDEC1_OutArgs         outArgs;
        Int                     channels;

        assert(hAd1);
        assert(hInBuf);
        assert(hOutBuf);
        assert(Buffer_getUserPtr(hInBuf));
        assert(Buffer_getUserPtr(hOutBuf));
        assert(Buffer_getNumBytesUsed(hInBuf));
        assert(Buffer_getSize(hOutBuf));

        inBufDesc.numBufs           = 1;
        inBufDesc.descs[0].buf      = Buffer_getUserPtr(hInBuf);
        inBufDesc.descs[0].bufSize  = Buffer_getNumBytesUsed(hInBuf);

        outBufDesc.numBufs          = 1;
        outBufDesc.descs[0].buf     = Buffer_getUserPtr(hOutBuf);
        outBufDesc.descs[0].bufSize = Buffer_getSize(hOutBuf);

        inArgs.size                 = sizeof(AUDDEC1_InArgs);
        inArgs.numBytes             = Buffer_getNumBytesUsed(hInBuf);
        inArgs.desiredChannelMode   = IAUDIO_1_0;   // the default value is IAUDIO_2_0, i modify it to IAUDIO_1_0, am i right?
        inArgs.lfeFlag              = XDAS_FALSE;

        outArgs.size                = sizeof(AUDDEC1_OutArgs);

        /* Decode the audio buffer */
        status = AUDDEC1_process(hAd1->hDecode, &inBufDesc, &outBufDesc, &inArgs,
                                 &outArgs);

        Dmai_dbg3("AUDDEC1_process() ret %d, consumed %d, created %d samples\n",
                  (Int) status, (Int) outArgs.bytesConsumed,
                  (Int) outArgs.numSamples);


        if (status != AUDDEC1_EOK) {
            if (XDM_ISFATALERROR(outArgs.extendedError)) {
                Dmai_err2("AUDDEC1_process() failed with error (%d ext: 0x%x)\n",
                          (Int)status, (Uns) outArgs.extendedError);
                return Dmai_EFAIL;
            }
            else {
                Dmai_dbg1("AUDDEC1_process() non-fatal error 0x%x\n",
                          (Uns) outArgs.extendedError);
                return Dmai_EBITERROR;
            }
        }

        Buffer_setNumBytesUsed(hInBuf, outArgs.bytesConsumed);
        channels = numChans[outArgs.channelMode];

        Buffer_setNumBytesUsed(hOutBuf, outArgs.numSamples * 1 * channels); // // the default value is *2, i modify it to *1, am i right?

        hAd1->sampleRate = outArgs.sampleRate;

        return Dmai_EOK;
    }

    The Adec1_process call returns no errors, but the decoded sound is very noisy.  Can you point out which parts is wrong?  Since you can decode successfully without ADTS headers using  ITTIAM_ENHAACPDEC_Params aacParams , can you please provide me a demo using this? 

    I really need your help, any advices will be appreciated. Thanks.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Pete Eberlein
    Posted by Pete Eberlein
    on Mar 07 2012 15:32 PM
    Intellectual280 points

    Hi Jing,

    Here is what I use:

        AUDDEC1_DynamicParams   defaultDynParams    = Adec1_DynamicParams_DEFAULT;
        ITTIAM_ENHAACPDEC_Params aacParams          = ENHAACPDECODER_ITTIAM_PARAMS;

        int  sampleRate = 48000;

                aacParams.s_iauddec_params.size = sizeof (aacParams);
                aacParams.i_sampfreq = sampleRate;
                aacParams.i_disable_sync = 1;
                aacParams.i_mp4_flag = 0;

                hAd1 = Adec1_create(hEngine, "aacdec", &aacParams.s_iauddec_params, &defaultDynParams);

    I didn't need to modify Adec1_create nor Adec1_process, though my recordings are stereo 48kHz.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jing C
    Posted by Jing C
    on Mar 07 2012 19:41 PM
    Intellectual560 points

    Hi Pete,

    Thank you very much for your help. I will try this.  But for "aacParams.i_disable_sync = 1" , i really don't know what is used for, could you explain this for me?  Thanks.

    Also, i remember that your initial problem is to decode AAC file with ADTS headers,  can you decode successfully now?  Which parts need to be modified? 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Pete Eberlein
    Posted by Pete Eberlein
    on Mar 09 2012 12:27 PM
    Intellectual280 points

    From the AACDEC manual:

    i_disable_sync
    To indicate if ADIF/ADTS synchronization is to be
    disabled. In which case the header is expected to be
    at the beginning of the input buffer. Valid values are
    0 or 1. If any other value is sent an
    IAUDDEC1_EFAIL error is returned.

    So, this tells the decoder not to expect ADTS headers.  I then scan for an ADTS header and skip over it before sending data to be decoded, using this code:

                        if (p[0] == 0xff && (p[1]&0xf0) == 0xf0) {
                            header_len = (p[1] & 0x1) ? 7 : 9;
                            len = ((p[3]&0x3)<<11) + (p[4]<<3) + ((p[5]&0xe0)>>5) - header_len;
                        }

    The format of the AAC ADTS header: http://wiki.multimedia.cx/index.php?title=ADTS

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jing C
    Posted by Jing C
    on Mar 11 2012 20:32 PM
    Intellectual560 points

    Hi Pete,

    Follow what you said, I have been able to successfully decode the AAC audio. Thank you very much.

    But i have another issue here,  AAC as encoder, as long as the audio compression rate below 48kbps(16, 24, 32, 40) in source side, i can decoing in very good shape on far side. Other audio compression rate like 48, 56, 64, 72, 80, 88, 86kbps, it's not working.  And that's really confuse me. Did you have this issue before?  Is there any parameter for audio compression rate in ITTIAM_ENHAACPDEC_Params? 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jing C
    Posted by Jing C
    on Mar 12 2012 02:18 AM
    Intellectual560 points

    Hi Pete,

    I have already fixed the audio compression rate issue, my audio data buffer size is not large enough for decode.  Anyway, thank you very much for your reply. You really help me a lot.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use