~ft/faad2

e48c2c82a5f9192622a29b052122ef594da891c5 — Fabian Greffrath a month ago f71b5e8 + 2783bda
Merge pull request #63 from awesie/awesie-fix-1

Fix various issues
6 files changed, 42 insertions(+), 15 deletions(-)

M frontend/main.c
M libfaad/mp4.c
M libfaad/pns.c
M libfaad/sbr_dec.c
M libfaad/specrec.c
M libfaad/syntax.c
M frontend/main.c => frontend/main.c +1 -1
@@ 872,7 872,7 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std
        if (NeAACDecAudioSpecificConfig(mp4config.asc.buf, mp4config.asc.size, &mp4ASC) >= 0)
        {
            if (mp4ASC.frameLengthFlag == 1) framesize = 960;
            if (mp4ASC.sbr_present_flag == 1) framesize *= 2;
            if (mp4ASC.sbr_present_flag == 1 || mp4ASC.forceUpSampling) framesize *= 2;
        }
    }


M libfaad/mp4.c => libfaad/mp4.c +7 -3
@@ 107,7 107,11 @@ static uint8_t ObjectTypesTable[32] = {
    0, /* 27 ER Parametric */
#endif
    0, /* 28 (Reserved) */
    0, /* 29 (Reserved) */
#ifdef PS_DEC
    1, /* 29 AAC LC + SBR + PS */
#else
    0, /* 29 AAC LC + SBR + PS */
#endif
    0, /* 30 (Reserved) */
    0  /* 31 (Reserved) */
};


@@ 174,7 178,7 @@ int8_t AudioSpecificConfigFromBitfile(bitfile *ld,

#ifdef SBR_DEC
    mp4ASC->sbr_present_flag = -1;
    if (mp4ASC->objectTypeIndex == 5)
    if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29)
    {
        uint8_t tmp;



@@ 231,7 235,7 @@ int8_t AudioSpecificConfigFromBitfile(bitfile *ld,
    else
		bits_to_decode = (int8_t)(buffer_size*8 - (startpos-faad_get_processed_bits(ld)));

    if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16))
    if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16))
    {
        int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11
            DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));

M libfaad/pns.c => libfaad/pns.c +11 -9
@@ 236,7 236,17 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
                if ((ics_right != NULL)
                    && is_noise(ics_right, g, sfb))
                {
                    if (channel_pair &&
#ifdef LTP_DEC
                    /* See comment above. */
                    ics_right->ltp.long_used[sfb] = 0;
                    ics_right->ltp2.long_used[sfb] = 0;
#endif
#ifdef MAIN_DEC
                    /* See comment above. */
                    ics_right->pred.prediction_used[sfb] = 0;
#endif

                    if (channel_pair && is_noise(ics_left, g, sfb) &&
                        (((ics_left->ms_mask_present == 1) &&
                        (ics_left->ms_used[g][sfb])) ||
                        (ics_left->ms_mask_present == 2)))


@@ 252,14 262,6 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right,

                    } else /*if (ics_left->ms_mask_present == 0)*/ {

#ifdef LTP_DEC
                        ics_right->ltp.long_used[sfb] = 0;
                        ics_right->ltp2.long_used[sfb] = 0;
#endif
#ifdef MAIN_DEC
                        ics_right->pred.prediction_used[sfb] = 0;
#endif

                        offs = ics_right->swb_offset[sfb];
                        size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;


M libfaad/sbr_dec.c => libfaad/sbr_dec.c +8 -1
@@ 97,10 97,17 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
    {
        sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
        sbr->numTimeSlots = NO_TIME_SLOTS_960;
    } else {
    }
    else if (framelength == 1024)
    {
        sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
        sbr->numTimeSlots = NO_TIME_SLOTS;
    }
    else
    {
        faad_free(sbr);
        return NULL;
    }

    sbr->GQ_ringbuf_index[0] = 0;
    sbr->GQ_ringbuf_index[1] = 0;

M libfaad/specrec.c => libfaad/specrec.c +4 -0
@@ 1056,6 1056,8 @@ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics,
#endif
                );
        }
        if (!hDecoder->sbr[ele])
            return 19;

        if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
            hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max);


@@ 1312,6 1314,8 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
#endif
                );
        }
        if (!hDecoder->sbr[ele])
            return 19;

        if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
            hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max);

M libfaad/syntax.c => libfaad/syntax.c +11 -1
@@ 884,7 884,10 @@ static uint8_t ics_info(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld,
                    if ((ics->ltp.data_present = faad_get1bit(ld
                        DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
                    {
                        ltp_data(hDecoder, ics, &(ics->ltp), ld);
                        if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
                        {
                            return retval;
                        }
                    }
                }
#endif


@@ 1091,6 1094,8 @@ static uint8_t fill_element(NeAACDecStruct *hDecoder, bitfile *ld, drc_info *drc
#endif
                    );
            }
            if (!hDecoder->sbr[sbr_ele])
                return 19;

            hDecoder->sbr_present_flag = 1;



@@ 1360,6 1365,11 @@ void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *
            hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0],
                2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
        }
        if (!hDecoder->sbr[0])
        {
            hInfo->error = 19;
            return;
        }

        /* Reverse bit reading of SBR data in DRM audio frame */
        revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t));