You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.1 KiB
114 lines
4.1 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2012-2019. All rights reserved.
|
|
* Description: IEC61937 data parser function
|
|
* Author: audio
|
|
* Create: 2012-05-30
|
|
*/
|
|
|
|
#ifndef __IEC61937_PARSER_H__
|
|
#define __IEC61937_PARSER_H__
|
|
|
|
#include "drv_audio_ext.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cpluscplus */
|
|
|
|
typedef td_void *ext_parser_handle;
|
|
|
|
/* the repetition period between 2 data-burst of AC3, also indicate the out buffer length */
|
|
#define BITS_BURSTLENGTH_AC3 (1536 * 4)
|
|
#define BITS_BURSTLENGTH_EAC3 (1536 * 4 * 4)
|
|
|
|
/* the repetition period between 2 data-burst of MAT, also indicate the out buffer length */
|
|
#define BITS_BURSTLENGTH_TUREHD 61440
|
|
#define BITS_BURSTLENGTH_MAT 61440
|
|
|
|
/* the repetition period between 2 data-burst of DTS, also indicate the out buffer length */
|
|
#define BITS_BURSTLENGTH_DTS_TYPE_I (512 * 4)
|
|
#define BITS_BURSTLENGTH_DTS_TYPE_II (1024 * 4)
|
|
#define BITS_BURSTLENGTH_DTS_TYPE_III (2048 * 4)
|
|
#define BITS_BURSTLENGTH_DTSCD (1024 * 4)
|
|
#define BITS_BURSTLENGTH_DTSHD 32768
|
|
|
|
/* the length of burst-preamble */
|
|
#define LENGTH_OF_PREAMBLE 8
|
|
#define LENGTH_OF_PA_AND_PB 4
|
|
|
|
#define DTSHD_HEADER_SIZE 12
|
|
|
|
#define IEC61937_SYNCWORD_LE 0xF8724E1F
|
|
#define IEC61937_SYNCWORD_BE 0x72F81F4E
|
|
|
|
/* * DCA syncwords, also used for bitstream type detection */
|
|
#define DCA_MARKER_RAW_BE 0x7FFE8001
|
|
#define DCA_MARKER_RAW_LE 0xFE7F0180
|
|
#define DCA_MARKER_14B_BE 0x1FFFE800
|
|
#define DCA_MARKER_14B_LE 0xFF1F00E8
|
|
|
|
#define IEC61937_PARSER_LENGTH_MIN 6 /* sizeof(pa + pb + pc) */
|
|
#define IEC61937_PARSER_LENGTH_MAX (BITS_BURSTLENGTH_MAT + IEC61937_PARSER_LENGTH_MIN)
|
|
|
|
/* the data type code, see IEC61917-2 */
|
|
#define IEC61937_DATATYPE_NULL 0 /* null data */
|
|
#define IEC61937_DATATYPE_AC3 1 /* AC-3 data */
|
|
#define IEC61937_DATATYPE_PAUSE 3 /* pause */
|
|
#define IEC61937_DATATYPE_DTS_TYPE_I 11 /* DTS type 1 */
|
|
#define IEC61937_DATATYPE_DTS_TYPE_II 12 /* DTS type 2 */
|
|
#define IEC61937_DATATYPE_DTS_TYPE_III 13 /* DTS type 3 */
|
|
#define IEC61937_DATATYPE_DTS_TYPE_IV 17 /* DTS type 4 */
|
|
#define IEC61937_DATATYPE_EAC3 21 /* enhanced AC-3 */
|
|
#define IEC61937_DATATYPE_MAT 22 /* MAT(true HD) */
|
|
#define IEC61937_DATATYPE_DTSCD 0xff /* DTS CD */
|
|
|
|
typedef enum {
|
|
IEC61937_PARSER_STREAM_PCM = EXT_AUDIO_FORMAT_PCM,
|
|
IEC61937_PARSER_STREAM_DD = EXT_AUDIO_FORMAT_AC3,
|
|
IEC61937_PARSER_STREAM_DDP = EXT_AUDIO_FORMAT_EAC3,
|
|
IEC61937_PARSER_STREAM_DTS = EXT_AUDIO_FORMAT_DTS,
|
|
IEC61937_PARSER_STREAM_DTSHD = EXT_AUDIO_FORMAT_DTS_HD,
|
|
IEC61937_PARSER_STREAM_MAT = EXT_AUDIO_FORMAT_MAT,
|
|
IEC61937_PARSER_STREAM_UNKNOWN = EXT_AUDIO_FORMAT_STREAM,
|
|
IEC61937_PARSER_STREAM_TYPE_MAX = EXT_AUDIO_FORMAT_CXT,
|
|
} iec61937_parser_stream_type;
|
|
|
|
typedef struct {
|
|
td_u8 *data;
|
|
td_u32 size;
|
|
} iec61937_parser_stream_buf;
|
|
|
|
typedef struct {
|
|
td_u8 *buffer;
|
|
td_u32 alloc_len;
|
|
td_u32 free_len;
|
|
td_u32 filled_len;
|
|
td_u32 burst_len;
|
|
td_u32 total_discard_len;
|
|
td_bool frame_is_ready;
|
|
td_bool big_endian;
|
|
td_u32 first_empty_time;
|
|
td_u32 frame_len;
|
|
td_u8 *frame_buf;
|
|
td_u32 channel;
|
|
td_u32 bit_depth;
|
|
iec61937_parser_stream_type stream_type;
|
|
} iec61937_parser_state;
|
|
|
|
td_s32 iec61937_parser_create(ext_parser_handle *parser);
|
|
td_void iec61937_parser_destroy(ext_parser_handle parser);
|
|
td_s32 iec61937_parser_get_buf(ext_parser_handle parser,
|
|
td_u32 request_size, iec61937_parser_stream_buf *stream);
|
|
td_s32 iec61937_parser_put_buf(ext_parser_handle parser, iec61937_parser_stream_buf *stream);
|
|
td_s32 iec61937_parser_acquire_frame(ext_parser_handle parser, td_void *dst_buf, td_u32 *frame_len);
|
|
td_s32 iec61937_parser_release_frame(ext_parser_handle parser, td_u32 frame_len);
|
|
td_s32 iec61937_parser_get_stream_type(ext_parser_handle parser, iec61937_parser_stream_type *stream_type);
|
|
td_s32 iec61937_parser_get_burst_len(ext_parser_handle parser, td_u32 *burst_len);
|
|
td_bool iec61937_check_is_empty(ext_parser_handle parser);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cpluscplus */
|
|
|
|
#endif /* __IEC61937_PARSER_H__ */
|
|
|