wut  v1.7.0
Wii U Toolchain
stream.h
Go to the documentation of this file.
1 #pragma once
2 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
14 typedef struct H264DecodeResult H264DecodeResult;
15 typedef struct H264DecodeOutput H264DecodeOutput;
16 
17 typedef void (*H264DECFptrOutputFn)(H264DecodeOutput *output);
18 
20 typedef enum H264Error
21 {
24 
27 
30 
33 
35  H264_ERROR_GENERIC = 0x1000000,
36 
39 
43 
48 
49 struct WUT_PACKED H264DecodedVuiParameters
50 {
53  int16_t sar_width;
54  int16_t sar_height;
58  uint8_t video_format;
68  WUT_PADDING_BYTES(1);
70  uint32_t time_scale;
78  WUT_PADDING_BYTES(1);
85 };
86 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x00, aspect_ratio_info_present_flag);
87 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x01, aspect_ratio_idc);
88 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x02, sar_width);
89 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x04, sar_height);
90 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x06, overscan_info_present_flag);
91 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x07, overscan_appropriate_flag);
92 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x08, video_signal_type_present_flag);
93 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x09, video_format);
94 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0A, video_full_range_flag);
95 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0B, colour_description_present_flag);
96 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0C, colour_primaries);
97 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0D, transfer_characteristics);
98 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0E, matrix_coefficients);
99 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x0F, chroma_loc_info_present_flag);
100 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x10, chroma_sample_loc_type_top_field);
101 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x11, chroma_sample_loc_type_bottom_field);
102 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x12, timing_info_present_flag);
103 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x14, num_units_in_tick);
104 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x18, time_scale);
105 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x1C, fixed_frame_rate_flag);
106 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x1D, nal_hrd_parameters_present_flag);
107 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x1E, vcl_hrd_parameters_present_flag);
108 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x1F, low_delay_hrd_flag);
109 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x20, pic_struct_present_flag);
110 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x21, bitstream_restriction_flag);
111 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x22, motion_vectors_over_pic_boundaries_flag);
112 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x24, max_bytes_per_pic_denom);
113 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x26, max_bits_per_mb_denom);
114 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x28, log2_max_mv_length_horizontal);
115 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x2A, log2_max_mv_length_vertical);
116 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x2C, num_reorder_frames);
117 WUT_CHECK_OFFSET(H264DecodedVuiParameters, 0x2E, max_dec_frame_buffering);
118 WUT_CHECK_SIZE(H264DecodedVuiParameters, 0x30);
119 
120 struct WUT_PACKED H264DecodeResult
121 {
122  int32_t status;
123  WUT_PADDING_BYTES(4);
124  double timestamp;
125  int32_t width;
126  int32_t height;
127  int32_t nextLine;
128  uint8_t cropEnableFlag;
129  WUT_PADDING_BYTES(3);
130  int32_t cropTop;
131  int32_t cropBottom;
132  int32_t cropLeft;
133  int32_t cropRight;
135  WUT_PADDING_BYTES(3);
136  int32_t panScanTop;
137  int32_t panScanBottom;
138  int32_t panScanLeft;
139  int32_t panScanRight;
140  void *framebuffer;
142  WUT_PADDING_BYTES(3);
144  WUT_UNKNOWN_BYTES(40);
145 };
146 WUT_CHECK_OFFSET(H264DecodeResult, 0x00, status);
147 WUT_CHECK_OFFSET(H264DecodeResult, 0x08, timestamp);
148 WUT_CHECK_OFFSET(H264DecodeResult, 0x10, width);
149 WUT_CHECK_OFFSET(H264DecodeResult, 0x14, height);
150 WUT_CHECK_OFFSET(H264DecodeResult, 0x18, nextLine);
151 WUT_CHECK_OFFSET(H264DecodeResult, 0x1C, cropEnableFlag);
152 WUT_CHECK_OFFSET(H264DecodeResult, 0x20, cropTop);
153 WUT_CHECK_OFFSET(H264DecodeResult, 0x24, cropBottom);
154 WUT_CHECK_OFFSET(H264DecodeResult, 0x28, cropLeft);
155 WUT_CHECK_OFFSET(H264DecodeResult, 0x2C, cropRight);
156 WUT_CHECK_OFFSET(H264DecodeResult, 0x30, panScanEnableFlag);
157 WUT_CHECK_OFFSET(H264DecodeResult, 0x34, panScanTop);
158 WUT_CHECK_OFFSET(H264DecodeResult, 0x38, panScanBottom);
159 WUT_CHECK_OFFSET(H264DecodeResult, 0x3C, panScanLeft);
160 WUT_CHECK_OFFSET(H264DecodeResult, 0x40, panScanRight);
161 WUT_CHECK_OFFSET(H264DecodeResult, 0x44, framebuffer);
162 WUT_CHECK_OFFSET(H264DecodeResult, 0x48, vui_parameters_present_flag);
163 WUT_CHECK_OFFSET(H264DecodeResult, 0x4C, vui_parameters);
164 WUT_CHECK_SIZE(H264DecodeResult, 0x78);
165 
166 struct WUT_PACKED H264DecodeOutput
167 {
169  int32_t frameCount;
170 
173 
175  void *userMemory;
176 };
177 WUT_CHECK_OFFSET(H264DecodeOutput, 0x00, frameCount);
178 WUT_CHECK_OFFSET(H264DecodeOutput, 0x04, decodeResults);
179 WUT_CHECK_OFFSET(H264DecodeOutput, 0x08, userMemory);
180 WUT_CHECK_SIZE(H264DecodeOutput, 0x0C);
181 
182 
186 H264Error
188  const uint8_t *buffer,
189  int32_t bufferLength,
190  int32_t offset,
191  int32_t *outLength);
192 
193 
197 H264Error
198 H264DECCheckSkipableFrame(const uint8_t *buffer,
199  int32_t bufferLength,
200  BOOL *outSkippable);
201 
202 
206 H264Error
207 H264DECFindDecstartpoint(const uint8_t *buffer,
208  int32_t bufferLength,
209  int32_t *outOffset);
210 
211 
220 int32_t
221 H264DECFindIdrpoint(const uint8_t *buffer,
222  int32_t bufferLength,
223  int32_t *outOffset);
224 
225 
229 H264Error
230 H264DECGetImageSize(const uint8_t *buffer,
231  int32_t bufferLength,
232  int32_t offset,
233  int32_t *outWidth,
234  int32_t *outHeight);
235 
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
int16_t max_bits_per_mb_denom
Definition: stream.h:80
uint8_t chroma_sample_loc_type_top_field
Definition: stream.h:65
int16_t log2_max_mv_length_horizontal
Definition: stream.h:81
uint8_t overscan_appropriate_flag
Definition: stream.h:56
uint32_t num_units_in_tick
Definition: stream.h:68
uint8_t chroma_sample_loc_type_bottom_field
Definition: stream.h:66
double timestamp
Definition: stream.h:123
int32_t status
Definition: stream.h:122
int32_t width
Definition: stream.h:125
int16_t num_reorder_frames
Definition: stream.h:83
int32_t panScanRight
Definition: stream.h:139
int32_t cropRight
Definition: stream.h:133
uint8_t vcl_hrd_parameters_present_flag
Definition: stream.h:73
int32_t height
Definition: stream.h:126
int32_t cropBottom
Definition: stream.h:131
uint8_t motion_vectors_over_pic_boundaries_flag
Definition: stream.h:77
int16_t max_bytes_per_pic_denom
Definition: stream.h:78
int16_t log2_max_mv_length_vertical
Definition: stream.h:82
uint8_t vui_parameters_present_flag
Definition: stream.h:141
uint8_t aspect_ratio_idc
Definition: stream.h:52
uint8_t aspect_ratio_info_present_flag
Definition: stream.h:51
uint8_t low_delay_hrd_flag
Definition: stream.h:74
uint8_t pic_struct_present_flag
Definition: stream.h:75
int32_t panScanTop
Definition: stream.h:135
H264DecodeResult ** decodeResults
Frames.
Definition: stream.h:172
void * userMemory
User memory pointer passed into SetParam.
Definition: stream.h:175
H264DecodedVuiParameters * vui_parameters
Definition: stream.h:142
uint8_t video_full_range_flag
Definition: stream.h:59
int32_t cropLeft
Definition: stream.h:132
uint8_t overscan_info_present_flag
Definition: stream.h:55
int32_t nextLine
Definition: stream.h:127
uint8_t cropEnableFlag
Definition: stream.h:128
uint8_t bitstream_restriction_flag
Definition: stream.h:76
int32_t panScanLeft
Definition: stream.h:138
uint8_t chroma_loc_info_present_flag
Definition: stream.h:64
void * framebuffer
Definition: stream.h:140
uint8_t timing_info_present_flag
Definition: stream.h:67
uint8_t transfer_characteristics
Definition: stream.h:62
uint8_t panScanEnableFlag
Definition: stream.h:134
uint8_t fixed_frame_rate_flag
Definition: stream.h:71
uint8_t colour_description_present_flag
Definition: stream.h:60
int32_t frameCount
Number of frames output.
Definition: stream.h:169
uint8_t colour_primaries
Definition: stream.h:61
int16_t max_dec_frame_buffering
Definition: stream.h:84
uint8_t nal_hrd_parameters_present_flag
Definition: stream.h:72
uint8_t matrix_coefficients
Definition: stream.h:63
uint8_t video_signal_type_present_flag
Definition: stream.h:57
int32_t cropTop
Definition: stream.h:129
int32_t panScanBottom
Definition: stream.h:137
void(* H264DECFptrOutputFn)(H264DecodeOutput *output)
Definition: stream.h:17
H264Error H264DECGetImageSize(const uint8_t *buffer, int32_t bufferLength, int32_t offset, int32_t *outWidth, int32_t *outHeight)
Parse the H264 stream and read the width & height from the first found SPS.
H264Error H264DECCheckSkipableFrame(const uint8_t *buffer, int32_t bufferLength, BOOL *outSkippable)
Check if the next NALU can be skipped without breaking decoding.
H264Error H264DECFindDecstartpoint(const uint8_t *buffer, int32_t bufferLength, int32_t *outOffset)
Find the first SPS in the stream.
H264Error H264DECCheckDecunitLength(void *memory, const uint8_t *buffer, int32_t bufferLength, int32_t offset, int32_t *outLength)
Check that the stream contains sufficient data to decode an entire frame.
int32_t H264DECFindIdrpoint(const uint8_t *buffer, int32_t bufferLength, int32_t *outOffset)
Find the first "IDR point" in the stream.
H264Error
h264 library errors.
Definition: stream.h:21
@ H264_ERROR_GENERIC
Generic h264 error.
Definition: stream.h:35
@ H264_ERROR_INVALID_SLICEHEADER
Invalid slice header.
Definition: stream.h:32
@ H264_ERROR_OUT_OF_MEMORY
The amount of memory provided to the h264 library is insufficient.
Definition: stream.h:42
@ H264_ERROR_INVALID_PARAMETER
Invalid parameters passed.
Definition: stream.h:38
@ H264_ERROR_OK
No errors.
Definition: stream.h:23
@ H264_ERROR_INVALID_SPS
Invalid sequence parameter set.
Definition: stream.h:29
@ H264_ERROR_INVALID_PPS
Invalid picture parameter set.
Definition: stream.h:26
@ H264_ERROR_INVALID_PROFILE
Invalid h264 stream profile.
Definition: stream.h:46
int32_t BOOL
Definition: wut_types.h:7