~ft/aacdec

c78251b2b5d41ea840fd61ab9502b3d3036bd747 — Andrew Wesie 1 year, 13 days ago e19a5e4
Restrict SBR frame length to 960 and 1024 samples.

Fixes #59 and #60.
3 files changed, 19 insertions(+), 1 deletions(-)

M libfaad/sbr_dec.c
M libfaad/specrec.c
M libfaad/syntax.c
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 +7 -0
@@ 1094,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;



@@ 1363,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));