blob: 6d9c0d97f6ed18a7d70f4f40102ec08a21424550
1 | /* ***** BEGIN LICENSE BLOCK ***** |
2 | * Source last modified: $Id: rv_decode.h,v 1.1.1.1.2.2 2005/05/04 18:20:57 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 RV_DECODE_H__ |
39 | #define RV_DECODE_H__ |
40 | |
41 | /* Simple unified decoder frontend for RealVideo */ |
42 | |
43 | #include "helix_types.h" |
44 | #include "helix_result.h" |
45 | #include "rm_memory.h" |
46 | #include "rm_error.h" |
47 | #include "rv_format_info.h" |
48 | #include "rv_decode_message.h" |
49 | #include "rv_backend.h" |
50 | #include "rv_backend_types.h" |
51 | |
52 | #ifdef __cplusplus |
53 | extern "C" { |
54 | #endif |
55 | |
56 | /* The rv_decode struct contains the RealVideo decoder frontend |
57 | * state variables and backend instance pointer. */ |
58 | |
59 | typedef struct rv_decode_struct { |
60 | rm_error_func_ptr fpError; |
61 | /* User defined error function. */ |
62 | |
63 | void* pUserError; |
64 | /* User defined parameter for error function. */ |
65 | |
66 | rm_malloc_func_ptr fpMalloc; |
67 | /* User defined malloc function. */ |
68 | |
69 | rm_free_func_ptr fpFree; |
70 | /* User defined free function. */ |
71 | |
72 | void* pUserMem; |
73 | /* User defined parameter for malloc and free functions. */ |
74 | |
75 | UINT32 ulSPOExtra; |
76 | /* The SPO Extra bits. Opaque data appended to bitstream header. */ |
77 | |
78 | UINT32 ulStreamVersion; |
79 | /* The stream version. Opaque data following the SPO Extra bits. */ |
80 | |
81 | UINT32 ulMajorBitstreamVersion; |
82 | /* The major bitstream version. Indicates RV7, RV8, RV9, etc. */ |
83 | |
84 | UINT32 ulMinorBitstreamVersion; |
85 | /* The minor bitstream version. Indicates minor revision or RAW. */ |
86 | |
87 | UINT32 ulNumResampledImageSizes; |
88 | /* The number of RPR sizes. Optional RV7 and RV8 opaque data. */ |
89 | |
90 | UINT32 ulEncodeSize; |
91 | /* The maximum encoded frame dimensions. Optional RV9 opaque data.*/ |
92 | |
93 | UINT32 ulLargestPels; |
94 | /* The maximum encoded frame width. */ |
95 | |
96 | UINT32 ulLargestLines; |
97 | /* The maximum encoded frame height. */ |
98 | |
99 | UINT32 pDimensions[2 * (8 + 1)]; |
100 | /* Table of encoded dimensions, including RPR sizes. */ |
101 | |
102 | UINT32 ulOutSize; |
103 | /* The maximum size of the output frame in bytes. */ |
104 | |
105 | UINT32 ulECCMask; |
106 | /* Mask for identifying ECC packets. */ |
107 | |
108 | UINT32 bInputFrameIsReference; |
109 | /* Identifies whether input frame is a key frame or not. */ |
110 | |
111 | UINT32 ulInputFrameQuant; |
112 | /* The input frame quantization parameter. */ |
113 | |
114 | rv_format_info *pBitstreamHeader; |
115 | /* The bitstream header. */ |
116 | |
117 | rv_frame *pInputFrame; |
118 | /* Pointer to the input frame struct. */ |
119 | |
120 | void *pDecodeState; |
121 | /* Pointer to decoder backend state. */ |
122 | |
123 | rv_backend *pDecode; |
124 | /* Decoder backend function pointers. */ |
125 | |
126 | rv_backend_init_params pInitParams; |
127 | /* Initialization parameters for the decoder backend. */ |
128 | |
129 | rv_backend_in_params pInputParams; |
130 | /* The decoder backend input parameter struct. */ |
131 | |
132 | rv_backend_out_params pOutputParams; |
133 | /* The decoder backend output parameter struct. */ |
134 | |
135 | } rv_decode; |
136 | |
137 | /* rv_decode_create() |
138 | * Creates RV decoder frontend struct, copies memory utilities. |
139 | * Returns struct pointer on success, NULL on failure. */ |
140 | rv_decode* rv_decode_create(void* pUserError, rm_error_func_ptr fpError); |
141 | |
142 | rv_decode* rv_decode_create2(void* pUserError, rm_error_func_ptr fpError, |
143 | void* pUserMem, rm_malloc_func_ptr fpMalloc, |
144 | rm_free_func_ptr fpFree); |
145 | |
146 | /* rv_decode_destroy() |
147 | * Deletes decoder backend instance, followed by frontend. */ |
148 | void rv_decode_destroy(rv_decode* pFrontEnd); |
149 | |
150 | /* rv_decode_init() |
151 | * Reads bitstream header, selects and initializes decoder backend. |
152 | * Returns zero on success, negative result indicates failure. */ |
153 | HX_RESULT rv_decode_init(rv_decode* pFrontEnd, rv_format_info* pHeader); |
154 | |
155 | /* rv_decode_stream_input() |
156 | * Reads frame header and fills decoder input parameters struct. If there |
157 | * is packet loss and ECC packets exist, error correction is attempted. |
158 | * Returns zero on success, negative result indicates failure. */ |
159 | HX_RESULT rv_decode_stream_input(rv_decode* pFrontEnd, rv_frame* pFrame); |
160 | |
161 | /* rv_decode_stream_decode() |
162 | * Calls decoder backend to decode issued frame and produce an output frame. |
163 | * Returns zero on success, negative result indicates failure. */ |
164 | HX_RESULT rv_decode_stream_decode(rv_decode* pFrontEnd, UINT8* pOutput); |
165 | |
166 | /* rv_decode_stream_flush() |
167 | * Flushes the latency frame from the decoder backend after the last frame |
168 | * is delivered and decoded before a pause or the end-of-file. |
169 | * Returns zero on success, negative result indicates failure. */ |
170 | HX_RESULT rv_decode_stream_flush(rv_decode* pFrontEnd, UINT8* pOutput); |
171 | |
172 | /* rv_decode_custom_message() |
173 | * Sends a custom message to the decoder backend. |
174 | * Returns zero on success, negative result indicates failure. */ |
175 | HX_RESULT rv_decode_custom_message(rv_decode* pFrontEnd, RV_Custom_Message_ID *pMsg_id); |
176 | |
177 | |
178 | /**************** Accessor Functions *******************/ |
179 | /* rv_decode_max_output_size() |
180 | * Returns maximum size of YUV 4:2:0 output buffer in bytes. */ |
181 | UINT32 rv_decode_max_output_size(rv_decode* pFrontEnd); |
182 | |
183 | /* rv_decode_get_output_size() |
184 | * Returns size of most recent YUV 4:2:0 output buffer in bytes. */ |
185 | UINT32 rv_decode_get_output_size(rv_decode* pFrontEnd); |
186 | |
187 | /* rv_decode_get_output_dimensions() |
188 | * Returns width and height of most recent YUV output buffer. */ |
189 | HX_RESULT rv_decode_get_output_dimensions(rv_decode* pFrontEnd, UINT32* pWidth, |
190 | UINT32* pHeight); |
191 | |
192 | /* rv_decode_frame_valid() |
193 | * Checks decoder output parameters to see there is a valid output frame. |
194 | * Returns non-zero value if a valid output frame exists, else zero. */ |
195 | UINT32 rv_decode_frame_valid(rv_decode* pFrontEnd); |
196 | |
197 | /* rv_decode_more_frames() |
198 | * Checks decoder output parameters to see if more output frames can be |
199 | * produced without additional input frames. |
200 | * Returns non-zero value if more frames can be |
201 | * produced without additional input, else zero. */ |
202 | UINT32 rv_decode_more_frames(rv_decode* pFrontEnd); |
203 | |
204 | #ifdef __cplusplus |
205 | } |
206 | #endif |
207 | |
208 | #endif /* RV_DECODE_H__ */ |
209 |