/******************************************************************************
* Copyright 2005 Analog Devices Inc. 
* This program is the confidential and proprietary product of Analog Devices Inc.
* This code is based on code purchased from Epigon Media Technologies Pvt Ltd.
* Any unauthorized, reproduction or transfer of this file is strictly
* prohibited.
*
* File Name		: adi_aaci_indexer_internal.h
* Function Name	: 
*
* Revision		:
*
* Description	: AAC indexer internal API header file
*
* Author		: Conrad Jakob
*
* Date			:
*
******************************************************************************/

#ifndef __ADI_AACI_INTERNAL_indexer_H__
#define __ADI_AACI_INTERNAL_indexer_H__

#include "adi_aaci_indexer.h"

// Macros
#define ADI_AACI_ADTS_NUM_SAMPLES_PER_FRAME	(1024)
#define ADI_AACI_ADTS_HEADER_NUM_BYTES		(7)				// ADTS header is 56 bits long

// Memory allocation macros
#define FAST_CODE_SECTION section("adi_aaci_fast_prio0_code")

// Typedefs
typedef struct
{
	int						sampling_frequency_index;
	int						aac_frame_length;
	int                     number_of_raw_data_blocks_in_frame;
} adi_aaci_adts_header;

typedef struct
{
	int								prev_stream_index;		// The stream index before the seek time
	adi_aaci_time_t					prev_milliseconds;		// Absolute time before the seek time
} adi_aaci_seek_state;

typedef struct
{
	long int						length;					// Length of input buffer
	adi_aaci_bitstream_data_t		*base;					// Input buffer
	long int						num_bytes_remaining;	// Num bytes remaining in input buffer for parsing
	int                             is_circular;            // flag indicating if the buffer is circular or linear
} adi_aaci_buffer;

typedef struct
{
	int								stream_offset;			// Absolute position in the stream file
	adi_aaci_time_t					milliseconds;			// Absolute time of the stream
} adi_aaci_index;

typedef struct
{
	adi_aaci_index					index[ADI_AACI_MAX_NUM_INDICES];	// Array of indices
	int								current_index;
} adi_aaci_index_list;

// Instance
struct adi_aaci_t
{
	adi_aaci_buffer			input_buffer;
	adi_aaci_index_list		index_list;
	adi_aaci_seek_state		seek_state;
};


#endif // __ADI_AACI_INTERNAL_indexer_H__


