summaryrefslogtreecommitdiff
path: root/audio_codec/libraac/ra_depack_internal.h (plain)
blob: e9d155ce239043aa05dcfdb5bd02c419003409d3
1/* ***** BEGIN LICENSE BLOCK *****
2 * Source last modified: $Id: ra_depack_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
3 *
4 * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
5 * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
6 * All Rights Reserved.
7 *
8 * The contents of this file, and the files included with this file,
9 * are subject to the current version of the Real Format Source Code
10 * Porting and Optimization License, available at
11 * https://helixcommunity.org/2005/license/realformatsource (unless
12 * RealNetworks otherwise expressly agrees in writing that you are
13 * subject to a different license). You may also obtain the license
14 * terms directly from RealNetworks. You may not use this file except
15 * in compliance with the Real Format Source Code Porting and
16 * Optimization License. There are no redistribution rights for the
17 * source code of this file. Please see the Real Format Source Code
18 * Porting and Optimization License for the rights, obligations and
19 * limitations governing use of the contents of the file.
20 *
21 * RealNetworks is the developer of the Original Code and owns the
22 * copyrights in the portions it created.
23 *
24 * This file, and the files included with this file, is distributed and
25 * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
26 * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
27 * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
29 * OR NON-INFRINGEMENT.
30 *
31 * Technology Compatibility Kit Test Suite(s) Location:
32 * https://rarvcode-tck.helixcommunity.org
33 *
34 * Contributor(s):
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef RA_DEPACK_INTERNAL_H
39#define RA_DEPACK_INTERNAL_H
40
41#include "../include/helix_types.h"
42#include "../include/helix_result.h"
43#include "../include/rm_memory.h"
44#include "../include/rm_error.h"
45#include "../include/ra_depack.h"
46#include "../include/stream_hdr_structs.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52 /*
53 * Internal substream header struct
54 */
55 typedef struct ra_substream_hdr_struct {
56 UINT16 usRAFormatVersion; /* 3, 4, or 5 */
57 UINT16 usRAFormatRevision; /* should be 0 */
58 UINT16 usHeaderBytes; /* size of raheader info */
59 UINT16 usFlavorIndex; /* compression type */
60 UINT32 ulGranularity; /* size of one block of encoded data */
61 UINT32 ulTotalBytes; /* total bytes of ra data */
62 UINT32 ulBytesPerMin; /* data rate of encoded and interleaved data */
63 UINT32 ulBytesPerMin2; /* data rate of interleaved or non-interleaved data */
64 UINT32 ulInterleaveFactor; /* number of blocks per superblock */
65 UINT32 ulInterleaveBlockSize; /* size of each interleave block */
66 UINT32 ulCodecFrameSize; /* size of each audio frame */
67 UINT32 ulUserData; /* extra field for user data */
68 UINT32 ulSampleRate; /* sample rate of decoded audio */
69 UINT32 ulActualSampleRate; /* sample rate of decoded audio */
70 UINT32 ulSampleSize; /* bits per sample in decoded audio */
71 UINT32 ulChannels; /* number of audio channels in decoded audio */
72 UINT32 ulInterleaverID; /* interleaver 4cc */
73 UINT32 ulCodecID; /* codec 4cc */
74 BYTE bIsInterleaved; /* 1 if file has been interleaved */
75 BYTE bCopyByte; /* copy enable byte, if 1 allow copies (SelectiveRecord) */
76 BYTE ucStreamType; /* i.e. LIVE_STREAM, FILE_STREAM */
77 BYTE ucScatterType; /* the interleave pattern type 0==cyclic,1==pattern */
78 UINT32 ulNumCodecFrames; /* number of codec frames in a superblock */
79 UINT32* pulInterleavePattern; /* the pattern of interleave if not cyclic */
80 UINT32 ulOpaqueDataSize; /* size of the codec specific data */
81 BYTE* pOpaqueData; /* codec specific data */
82 HXDOUBLE dBlockDuration; /* Duration in ms of audio "block" */
83 UINT32 ulLastSentEndTime; /* Ending time of last sent audio frame */
84 BYTE* pFragBuffer; /* Intermediate buffer for reconstructing VBR packets */
85 UINT32 ulFragBufferSize; /* Size of intermediate buffer */
86 UINT32 ulFragBufferAUSize; /* Size of AU being reconstructed */
87 UINT32 ulFragBufferOffset; /* Current offset within AU */
88 UINT32 ulFragBufferTime; /* Timestamp of AU being reconstructed */
89 UINT32 ulSuperBlockSize; /* ulInterleaveBlockSize * ulInterleaveFactor */
90 UINT32 ulSuperBlockTime; /* dBlockDuration * ulInterleaveFactor */
91 UINT32 ulKeyTime; /* Timestamp of keyframe packet */
92 BYTE* pIBuffer; /* Buffer holding interleaved blocks */
93 BYTE* pDBuffer; /* Buffer holding de-interleaved blocks */
94 UINT32* pIPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
95 UINT32* pDPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
96 UINT32 ulBlockCount; /* number of blocks currently in superblock */
97 UINT32* pulGENRPattern; /* Interleave pattern for GENR interleaver */
98 UINT32* pulGENRBlockNum;
99 UINT32* pulGENRBlockOffset;
100 rm_packet lastPacket;
101 HX_BITFIELD bIsVBR : 1;
102 HX_BITFIELD bSeeked : 1;
103 HX_BITFIELD bLossOccurred : 1;
104 HX_BITFIELD bHasKeyTime : 1; /* Do we have a time for the key slot? */
105 HX_BITFIELD bHasFrag : 1;
106 HX_BITFIELD bAdjustTimestamps : 1;
107 HX_BITFIELD bKnowIfAdjustNeeded : 1;
108 HX_BITFIELD bHasLastPacket : 1;
109 } ra_substream_hdr;
110
111 /*
112 * Internal ra_depack struct
113 */
114 typedef struct ra_depack_internal_struct {
115 void* pAvail;
116 ra_block_avail_func_ptr fpAvail;
117 rm_error_func_ptr fpError;
118 void* pUserError;
119 rm_malloc_func_ptr fpMalloc;
120 rm_free_func_ptr fpFree;
121 void* pUserMem;
122 rm_rule_map rule2Flag;
123 rm_multistream_hdr multiStreamHdr;
124 ra_substream_hdr* pSubStreamHdr;
125 UINT32 ulTrackStartTime;
126 UINT32 ulTrackEndTime;
127 UINT32 ulEndTime;
128 UINT32 ulStreamDuration;
129 HX_BITFIELD bForceTrackStartTime : 1;
130 HX_BITFIELD bForceTrackEndTime : 1;
131 HX_BITFIELD bStreamSwitchable : 1;
132 HX_BITFIELD bAllVBR : 1;
133 HX_BITFIELD bAllNonVBR : 1;
134 HX_BITFIELD bHasEndTime : 1;
135 } ra_depack_internal;
136
137 /*
138 * Internal ra_depack functions
139 */
140 void* ra_depacki_malloc(ra_depack_internal* pInt, UINT32 ulSize);
141 void ra_depacki_free(ra_depack_internal* pInt, void* pMem);
142 HX_RESULT ra_depacki_init(ra_depack_internal* pInt, rm_stream_header* hdr);
143 HX_RESULT ra_depacki_unpack_rule_map(ra_depack_internal* pInt,
144 rm_rule_map* pMap,
145 BYTE** ppBuf,
146 UINT32* pulLen);
147 HX_RESULT ra_depacki_unpack_multistream_hdr(ra_depack_internal* pInt,
148 BYTE** ppBuf,
149 UINT32* pulLen);
150 HX_RESULT ra_depacki_unpack_opaque_data(ra_depack_internal* pInt,
151 BYTE* pBuf,
152 UINT32 ulLen);
153 void ra_depacki_cleanup_substream_hdr(ra_depack_internal* pInt,
154 ra_substream_hdr* hdr);
155 void ra_depacki_cleanup_substream_hdr_array(ra_depack_internal* pInt);
156 HX_RESULT ra_depacki_unpack_substream_hdr(ra_depack_internal* pInt,
157 BYTE* pBuf,
158 UINT32 ulLen,
159 ra_substream_hdr* pHdr);
160 HX_RESULT ra_depacki_unpack_raformat3(ra_depack_internal* pInt,
161 BYTE* pBuf,
162 UINT32 ulLen,
163 ra_substream_hdr* pHdr);
164 HX_RESULT ra_depacki_unpack_raformat4(ra_depack_internal* pInt,
165 BYTE* pBuf,
166 UINT32 ulLen,
167 ra_substream_hdr* pHdr);
168 HX_RESULT ra_depacki_unpack_raformat5(ra_depack_internal* pInt,
169 BYTE* pBuf,
170 UINT32 ulLen,
171 ra_substream_hdr* pHdr);
172 HX_RESULT ra_depacki_get_format_info(ra_depack_internal* pInt,
173 UINT32 ulSubStream,
174 ra_format_info* pInfo);
175 void ra_depacki_cleanup_format_info(ra_depack_internal* pInt,
176 ra_format_info* pInfo);
177 UINT32 ra_depacki_rule_to_flags(ra_depack_internal* pInt, UINT32 ulRule);
178 HXBOOL ra_depacki_is_keyframe_rule(ra_depack_internal* pInt, UINT32 ulRule);
179 UINT32 ra_depacki_rule_to_substream(ra_depack_internal* pInt, UINT32 ulRule);
180 HX_RESULT ra_depacki_add_packet(ra_depack_internal* pInt,
181 rm_packet* pPacket);
182 HX_RESULT ra_depacki_add_vbr_packet(ra_depack_internal* pInt,
183 UINT32 ulSubStream,
184 rm_packet* pPacket);
185 HX_RESULT ra_depacki_add_non_vbr_packet(ra_depack_internal* pInt,
186 UINT32 ulSubStream,
187 rm_packet* pPacket);
188 HX_RESULT ra_depacki_parse_vbr_packet(ra_depack_internal* pInt,
189 rm_packet* pPacket,
190 UINT32* pulNumAU,
191 HXBOOL* pbFragmented,
192 UINT32* pulAUSize,
193 UINT32* pulAUFragSize);
194 HX_RESULT ra_depacki_generate_and_send_loss(ra_depack_internal* pInt,
195 UINT32 ulSubStream,
196 UINT32 ulFirstStartTime,
197 UINT32 ulLastEndTime);
198 HX_RESULT ra_depacki_send_block(ra_depack_internal* pInt,
199 UINT32 ulSubStream,
200 BYTE* pBuf,
201 UINT32 ulLen,
202 UINT32 ulTime,
203 UINT32 ulFlags);
204 HX_RESULT ra_depacki_handle_frag_packet(ra_depack_internal* pInt,
205 UINT32 ulSubStream,
206 rm_packet* pPacket,
207 UINT32 ulAUSize,
208 UINT32 ulAUFragSize);
209 HX_RESULT ra_depacki_handle_nonfrag_packet(ra_depack_internal* pInt,
210 UINT32 ulSubStream,
211 rm_packet* pPacket,
212 UINT32 ulNumAU);
213 HX_RESULT ra_depacki_init_frag_buffer(ra_depack_internal* pInt,
214 ra_substream_hdr* pHdr);
215 HX_RESULT ra_depacki_resize_frag_buffer(ra_depack_internal* pInt,
216 ra_substream_hdr* pHdr,
217 UINT32 ulNewSize);
218 void ra_depacki_clear_frag_buffer(ra_depack_internal* pInt,
219 ra_substream_hdr* hdr);
220 HX_RESULT ra_depacki_seek(ra_depack_internal* pInt, UINT32 ulTime);
221 HX_RESULT ra_depacki_deinterleave_send(ra_depack_internal* pInt, UINT32 ulSubStream);
222 HX_RESULT ra_depacki_deinterleave(ra_depack_internal* pInt, UINT32 ulSubStream);
223 HX_RESULT ra_depacki_deinterleave_sipr(ra_depack_internal* pInt, UINT32 ulSubStream);
224 HX_RESULT ra_depacki_init_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
225 HX_RESULT ra_depacki_deinterleave_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
226 HX_RESULT ra_depacki_deinterleave_no(ra_depack_internal* pInt, UINT32 ulSubStream);
227
228#ifdef __cplusplus
229}
230#endif
231
232#endif /* #ifndef RA_DEPACK_INTERNAL_H */
233