1 // Copyright (c) 2018-2019 Intel Corporation 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in all 11 // copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 // SOFTWARE. 20 21 #ifndef __UMC_STRUCTURES_H__ 22 #define __UMC_STRUCTURES_H__ 23 24 #include <vm_types.h> 25 #include <vm_debug.h> 26 27 #define BSWAP16(x) \ 28 (uint16_t) ((x) >> 8 | (x) << 8) 29 30 #define BSWAP32(x) \ 31 (uint32_t)(((x) << 24) + \ 32 (((x)&0xff00) << 8) + \ 33 (((x) >> 8)&0xff00) + \ 34 ((uint32_t)(x) >> 24)) 35 36 #define BSWAP64(x) \ 37 (unsigned long long)(((x) << 56) + \ 38 (((x)&0xff00) << 40) + \ 39 (((x)&0xff0000) << 24) + \ 40 (((x)&0xff000000) << 8) + \ 41 (((x) >> 8)&0xff000000) + \ 42 (((x) >> 24)&0xff0000) + \ 43 (((x) >> 40)&0xff00) + \ 44 ((x) >> 56)) 45 46 #ifdef _BIG_ENDIAN_ 47 # define BIG_ENDIAN_SWAP16(x) BSWAP16(x) 48 # define BIG_ENDIAN_SWAP32(x) BSWAP32(x) 49 # define BIG_ENDIAN_SWAP64(x) BSWAP64(x) 50 # define LITTLE_ENDIAN_SWAP16(x) (x) 51 # define LITTLE_ENDIAN_SWAP32(x) (x) 52 # define LITTLE_ENDIAN_SWAP64(x) (x) 53 #else /* _BIG_ENDIAN_ */ 54 # define BIG_ENDIAN_SWAP16(x) (x) 55 # define BIG_ENDIAN_SWAP32(x) (x) 56 # define BIG_ENDIAN_SWAP64(x) (x) 57 # define LITTLE_ENDIAN_SWAP16(x) BSWAP16(x) 58 # define LITTLE_ENDIAN_SWAP32(x) BSWAP32(x) 59 # define LITTLE_ENDIAN_SWAP64(x) BSWAP64(x) 60 #endif /* _BIG_ENDIAN_ */ 61 62 /* macro to create FOURCC */ 63 #ifndef DO_FOURCC 64 #define DO_FOURCC(ch0, ch1, ch2, ch3) \ 65 ( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) | \ 66 ( (uint32_t)(uint8_t)(ch2) << 16 ) | ( (uint32_t)(uint8_t)(ch3) << 24 ) ) 67 #endif /* DO_FOURCC */ 68 69 /***************************************************************************/ 70 71 #define UMC_CHECK_STATUS(umcRes) { \ 72 if (umcRes != UMC_OK) { \ 73 vm_debug_trace1(VM_DEBUG_ERROR, VM_STRING("Result (UMC::Status) = %d\n"), (int)umcRes); \ 74 return umcRes; \ 75 } \ 76 } 77 78 #define UMC_CHECK(EXPRESSION, ERR_CODE) { \ 79 if (!(EXPRESSION)) { \ 80 vm_debug_trace2(VM_DEBUG_ERROR, VM_STRING("[%s] FAILED (%s)"), VM_STRING(#ERR_CODE), VM_STRING(#EXPRESSION)); \ 81 return ERR_CODE; \ 82 } \ 83 } 84 85 #define UMC_CHECK_PTR(PTR) \ 86 UMC_CHECK(PTR != NULL, UMC_ERR_NULL_PTR) 87 88 #define UMC_CALL(FUNC) { \ 89 Status _umcRes; \ 90 vm_debug_trace1(VM_DEBUG_CALL, VM_STRING("[CALL] %s\n"), #FUNC); \ 91 _umcRes = FUNC; \ 92 if (_umcRes == UMC_OK) { \ 93 vm_debug_trace1(VM_DEBUG_CALL, VM_STRING("[RETURN] %s\n"), #FUNC); \ 94 } else { \ 95 vm_debug_trace2(VM_DEBUG_ERROR, VM_STRING("[FAILED] %s, Status = %d\n"), #FUNC, (int)_umcRes); \ 96 } \ 97 UMC_CHECK_STATUS(_umcRes); \ 98 } 99 100 #define UMC_NEW(PTR, TYPE) { \ 101 UMC_DELETE(PTR); \ 102 vm_debug_trace3(VM_DEBUG_MEMORY, VM_STRING("[MEMORY] %s = new %s (%d bytes)"), VM_STRING(#PTR), VM_STRING(#TYPE), sizeof(TYPE)); \ 103 PTR = new TYPE; \ 104 UMC_CHECK(PTR != NULL, UMC_ERR_ALLOC); \ 105 } 106 107 #define UMC_NEW_ARR(PTR, TYPE, NUM) { \ 108 UMC_DELETE_ARR(PTR); \ 109 vm_debug_trace3(VM_DEBUG_MEMORY, VM_STRING("[MEMORY] %s = new %s[%d]"), VM_STRING(#PTR), VM_STRING(#TYPE), (int)NUM); \ 110 PTR = new TYPE[NUM]; \ 111 UMC_CHECK(PTR != NULL, UMC_ERR_ALLOC); \ 112 } 113 114 #define UMC_DELETE(PTR) { \ 115 if (PTR) { \ 116 vm_debug_trace1(VM_DEBUG_MEMORY, VM_STRING("[MEMORY] delete %s"), VM_STRING(#PTR)); \ 117 delete PTR; \ 118 PTR = NULL; \ 119 } \ 120 } 121 122 #define UMC_DELETE_ARR(PTR) { \ 123 if (PTR) { \ 124 vm_debug_trace1(VM_DEBUG_MEMORY, VM_STRING("[MEMORY] delete[] %s"), VM_STRING(#PTR)); \ 125 delete[] PTR; \ 126 PTR = NULL; \ 127 } \ 128 } 129 130 #define UMC_ARRAY_SIZE(ARR) (sizeof(ARR)/sizeof(ARR[0])) 131 #define UMC_SET_ZERO(VAR) memset(&(VAR), 0, sizeof(VAR)) 132 /***************************************************************************/ 133 134 #ifdef __cplusplus 135 136 namespace UMC 137 { 138 139 enum SystemStreamType 140 { 141 UNDEF_STREAM = 0x00000000, //unsupported stream type 142 AVI_STREAM = 0x00000001, //AVI RIFF 143 MP4_ATOM_STREAM = 0x00000010, //ISO/IEC 14496-14 stream 144 ASF_STREAM = 0x00000100, //ASF stream 145 146 H26x_PURE_VIDEO_STREAM = 0x00100000, 147 H261_PURE_VIDEO_STREAM = H26x_PURE_VIDEO_STREAM|0x00010000, 148 H263_PURE_VIDEO_STREAM = H26x_PURE_VIDEO_STREAM|0x00020000, 149 H264_PURE_VIDEO_STREAM = H26x_PURE_VIDEO_STREAM|0x00040000, 150 151 MPEGx_SYSTEM_STREAM = 0x00001000, //MPEG 1,2 - like system 152 153 MPEG1_SYSTEM_STREAM = MPEGx_SYSTEM_STREAM|0x00000100,//MPEG 1 system 154 MPEG2_SYSTEM_STREAM = MPEGx_SYSTEM_STREAM|0x00000200,//MPEG 2 system 155 MPEG4_SYSTEM_STREAM = MPEGx_SYSTEM_STREAM|0x00000400,//MPEG 4 system 156 157 MPEGx_PURE_VIDEO_STREAM = MPEGx_SYSTEM_STREAM|0x00000010,//MPEG 1,2 - like pure video data 158 MPEGx_PURE_AUDIO_STREAM = MPEGx_SYSTEM_STREAM|0x00000020,//MPEG 1,2 - like pure audio data 159 MPEGx_PES_PACKETS_STREAM= MPEGx_SYSTEM_STREAM|0x00000040,//MPEG 1,2 - like pes packets system 160 MPEGx_PROGRAMM_STREAM = MPEGx_SYSTEM_STREAM|0x00000080,//MPEG 1,2 - like program system 161 MPEGx_TRANSPORT_STREAM = MPEGx_SYSTEM_STREAM|0x000000c0,//MPEG 1,2 - like transport system 162 163 164 MPEG1_PURE_VIDEO_STREAM = MPEG1_SYSTEM_STREAM|MPEGx_PURE_VIDEO_STREAM, //MPEG1 pure video stream 165 MPEG1_PURE_AUDIO_STREAM = MPEG1_SYSTEM_STREAM|MPEGx_PURE_AUDIO_STREAM, //MPEG1 pure video stream 166 MPEG1_PES_PACKETS_STREAM= MPEG1_SYSTEM_STREAM|MPEGx_PES_PACKETS_STREAM,//MPEG1 pes packets stream 167 MPEG1_PROGRAMM_STREAM = MPEG1_SYSTEM_STREAM|MPEGx_PROGRAMM_STREAM, //MPEG1 program stream 168 169 MPEG2_PURE_VIDEO_STREAM = MPEG2_SYSTEM_STREAM|MPEGx_PURE_VIDEO_STREAM,//MPEG2 pure video stream 170 MPEG2_PURE_AUDIO_STREAM = MPEG2_SYSTEM_STREAM|MPEGx_PURE_AUDIO_STREAM,//MPEG2 pure audio stream 171 MPEG2_PES_PACKETS_STREAM= MPEG2_SYSTEM_STREAM|MPEGx_PES_PACKETS_STREAM,//MPEG2 pes packets stream 172 MPEG2_PROGRAMM_STREAM = MPEG2_SYSTEM_STREAM|MPEGx_PROGRAMM_STREAM, //MPEG2 program stream 173 MPEG2_TRANSPORT_STREAM = MPEG2_SYSTEM_STREAM|MPEGx_TRANSPORT_STREAM, //MPEG2 transport stream 174 MPEG2_TRANSPORT_STREAM_TTS = MPEG2_SYSTEM_STREAM|MPEGx_TRANSPORT_STREAM | 1, //MPEG2 transport stream with valid packet time stamps 175 MPEG2_TRANSPORT_STREAM_TTS0 = MPEG2_SYSTEM_STREAM|MPEGx_TRANSPORT_STREAM | 2, //MPEG2 transport stream with zero packet time stamps 176 177 MPEG4_PURE_VIDEO_STREAM = MPEG4_SYSTEM_STREAM|MPEGx_PURE_VIDEO_STREAM,//MPEG4 pure video stream 178 179 WEB_CAM_STREAM = 0x00100000, 180 ADIF_STREAM = 0x00200000, 181 ADTS_STREAM = 0x00400000, 182 STILL_IMAGE = 0x00800000, 183 VC1_PURE_VIDEO_STREAM = 0x01000000, 184 WAVE_STREAM = 0x02000000, 185 AVS_PURE_VIDEO_STREAM = 0x04000000, 186 FLV_STREAM = 0x08000000, 187 IVF_STREAM = 0x10000000, 188 MJPEG_PURE_VIDEO_STREAM = 0x20000000 189 }; 190 191 enum AudioStreamType 192 { 193 UNDEF_AUDIO = 0x00000000, 194 PCM_AUDIO = 0x00000001, 195 LPCM_AUDIO = 0x00000002, 196 AC3_AUDIO = 0x00000004, 197 ALAW_AUDIO = 0x00000006, 198 MULAW_AUDIO = 0x00000007, 199 TWINVQ_AUDIO = 0x00000008, 200 DTS_AUDIO = 0x00000016, 201 202 MPEG1_AUDIO = 0x00000100, 203 MPEG2_AUDIO = 0x00000200, 204 MPEG_AUDIO_LAYER1 = 0x00000010, 205 MPEG_AUDIO_LAYER2 = 0x00000020, 206 MPEG_AUDIO_LAYER3 = 0x00000040, 207 208 MP1L1_AUDIO = MPEG1_AUDIO|MPEG_AUDIO_LAYER1, 209 MP1L2_AUDIO = MPEG1_AUDIO|MPEG_AUDIO_LAYER2, 210 MP1L3_AUDIO = MPEG1_AUDIO|MPEG_AUDIO_LAYER3, 211 MP2L1_AUDIO = MPEG2_AUDIO|MPEG_AUDIO_LAYER1, 212 MP2L2_AUDIO = MPEG2_AUDIO|MPEG_AUDIO_LAYER2, 213 MP2L3_AUDIO = MPEG2_AUDIO|MPEG_AUDIO_LAYER3, 214 215 VORBIS_AUDIO = 0x00000400, 216 AAC_AUDIO = 0x00000800, 217 AAC_FMT_UNDEF = 0x00000000, /// Undefined stream format, the decoder have to identify by bitstream 218 AAC_FMT_RAW = 0x00000001, /// Raw input stream format, the first frame keeps init information 219 AAC_FMT_EX_GA = 0x00000010, /// GASpecificConfig header within the first frame. 220 AAC_MPEG4_STREAM = AAC_AUDIO | AAC_FMT_RAW | AAC_FMT_EX_GA, 221 222 AMR_NB_AUDIO = 0x00000777, //narrow band amr 223 AMR_WB_AUDIO = 0x00000778, //wide band amr 224 225 WMA_AUDIO = 0x00001000 // WMA, WMA Pro, WMA Losless 226 }; 227 228 enum TrickModesType 229 { 230 UMC_TRICK_MODES_NO = 0x00000000, 231 UMC_TRICK_MODES_FORWARD = 0x00000001, 232 UMC_TRICK_MODES_FAST = 0x00000002, 233 UMC_TRICK_MODES_FASTER = 0x00000004, 234 UMC_TRICK_MODES_SLOW = 0x00000020, 235 UMC_TRICK_MODES_SLOWER = 0x00000040, 236 UMC_TRICK_MODES_REVERSE = 0x00000200, 237 238 UMC_TRICK_MODES_FFW_FAST = UMC_TRICK_MODES_FAST | UMC_TRICK_MODES_FORWARD, 239 UMC_TRICK_MODES_FFW_FASTER = UMC_TRICK_MODES_FASTER | UMC_TRICK_MODES_FORWARD, 240 UMC_TRICK_MODES_SFW_SLOW = UMC_TRICK_MODES_SLOW | UMC_TRICK_MODES_FORWARD, 241 UMC_TRICK_MODES_SFW_SLOWER = UMC_TRICK_MODES_SLOWER | UMC_TRICK_MODES_FORWARD, 242 243 UMC_TRICK_MODES_FR_FAST = UMC_TRICK_MODES_FAST | UMC_TRICK_MODES_REVERSE, 244 UMC_TRICK_MODES_FR_FASTER = UMC_TRICK_MODES_FASTER | UMC_TRICK_MODES_REVERSE, 245 UMC_TRICK_MODES_SR_SLOW = UMC_TRICK_MODES_SLOW | UMC_TRICK_MODES_REVERSE, 246 UMC_TRICK_MODES_SR_SLOWER = UMC_TRICK_MODES_SLOWER | UMC_TRICK_MODES_REVERSE 247 }; 248 249 enum AudioStreamSubType 250 { 251 UNDEF_AUDIO_SUBTYPE = 0x00000000, 252 AAC_LC_PROFILE = 0x00000001, 253 AAC_LTP_PROFILE = 0x00000002, 254 AAC_MAIN_PROFILE = 0x00000004, 255 AAC_SSR_PROFILE = 0x00000008, 256 AAC_HE_PROFILE = 0x00000010, 257 AAC_ALS_PROFILE = 0x00000020 258 }; 259 260 enum VideoStreamType 261 { 262 UNDEF_VIDEO = 0x00000000, 263 UNCOMPRESSED_VIDEO = 0x00000001, 264 MPEG1_VIDEO = 0x00000011, 265 MPEG2_VIDEO = 0x00000012, 266 MPEG4_VIDEO = 0x00000014, 267 H261_VIDEO = 0x00000120, 268 H263_VIDEO = 0x00000140, 269 H264_VIDEO = 0x00000180, 270 DIGITAL_VIDEO_SD = 0x00001200, 271 DIGITAL_VIDEO_50 = 0x00001400, 272 DIGITAL_VIDEO_HD = 0x00001800, 273 DIGITAL_VIDEO_SL = 0x00002000, 274 WMV_VIDEO = 0x00010000, 275 MJPEG_VIDEO = 0x00020000, 276 YV12_VIDEO = 0x00040000, 277 VC1_VIDEO = 0x00050000, 278 AVS_VIDEO = 0x00060000, 279 VP8_VIDEO = 0x00070000, 280 VP9_VIDEO = 0x00080000, 281 HEVC_VIDEO = 0x00100000, 282 AV1_VIDEO = 0x00200000 283 }; 284 285 enum VideoRenderType 286 { 287 DEF_VIDEO_RENDER = 0, 288 DX_VIDEO_RENDER, 289 BLT_VIDEO_RENDER, 290 GDI_VIDEO_RENDER, 291 GX_VIDEO_RENDER, 292 SDL_VIDEO_RENDER, 293 FB_VIDEO_RENDER, 294 NULL_VIDEO_RENDER, 295 FW_VIDEO_RENDER, 296 MTWREG_VIDEO_RENDER, 297 OVL2_VIDEO_RENDER, 298 DXWCE_VIDEO_RENDER, 299 AGL_VIDEO_RENDER, 300 NO_VIDEO_RENDER, // no render 301 D3D_VIDEO_RENDER 302 }; 303 304 enum AudioRenderType 305 { 306 DEF_AUDIO_RENDER = 0, 307 DSOUND_AUDIO_RENDER, 308 WINMM_AUDIO_RENDER, 309 ALSA_AUDIO_RENDER, 310 OSS_AUDIO_RENDER, 311 NULL_AUDIO_RENDER, 312 FW_AUDIO_RENDER, 313 COREAUDIO_RENDER, 314 SDL_AUDIO_RENDER 315 }; 316 317 enum VideoStreamSubType 318 { 319 UNDEF_VIDEO_SUBTYPE = 0x00000000, 320 MPEG4_VIDEO_DIVX5 = 0x00000001, 321 MPEG4_VIDEO_QTIME = 0x00000002, 322 DIGITAL_VIDEO_TYPE_1 = 3, 323 DIGITAL_VIDEO_TYPE_2, 324 MPEG4_VIDEO_DIVX3, 325 MPEG4_VIDEO_DIVX4, 326 MPEG4_VIDEO_XVID, 327 AVC1_VIDEO, 328 H263_VIDEO_SORENSON, 329 VC1_VIDEO_RCV = 0x00110000, 330 VC1_VIDEO_VC1 = 0x00120000, 331 WVC1_VIDEO, 332 WMV3_VIDEO 333 }; 334 335 enum ColorFormat 336 { 337 NONE = -1, 338 YV12 = 0, // Planar Y, V, U (4:2:0) (note V,U order!) 339 NV12 , // Planar Y, merged U->V (4:2:0) 340 NV16 , // Planar Y, merged U->V (4:2:2) 341 IMC3 , // Planar Y, V, U (4:2:0) (pitchY = pitchU=pitchV) 342 YUY2 , // Composite Y->U->Y->V (4:2:2) 343 UYVY , // Composite U->Y->V->Y (4:2:2) 344 YUV411 , // Planar Y, U, V (4:1:1) 345 YUV420 , // Planar Y, U, V (4:2:0) 346 YUV422 , // Planar Y, U, V (4:2:2) 347 YUV444 , // Planar Y, U, V (4:4:4) 348 AYUV , // Packed A, Y, U, V (4:4:4:4) 8 bit 349 YUV_VC1 , // Planar Y, U, V (4:2:0), VC1 codec specific 350 Y411 , // Composite Y, U, V (4:1:1) 351 Y41P , // Composite Y, U, V (4:1:1) 352 RGB32 , // Composite B->G->R->A 353 RGB24 , // Composite B->G->R 354 RGB565 , // Composite B->G->R, 5 bit per B & R, 6 bit per G 355 RGB555 , // Composite B->G->R->A, 5 bit per component, 1 bit per A 356 RGB444 , // Composite B->G->R->A, 4 bit per component 357 GRAY , // Luminance component only. 358 YUV420A , // Planar Y, U, V, Alpha 359 YUV422A , // Planar Y, U, V, Alpha 360 YUV444A , // Planar Y, U, V, Alpha 361 YVU9 , // Planar Y, U, V 362 GRAYA , // Luminance with Alpha 363 P010 , // Planar YUV 4:2:0 10 bit 364 P016 , // Planar YUV 4:2:0 16 bit 365 P210 , // Planar YUV 4:2:2 10 bit 366 P216 , // Planar YUV 4:2:2 16 bit 367 Y210 , // Packed YUV 4:2:2 10-bit. 368 Y216 , // Packed YUV 4:2:2 16-bit. 369 Y410 , // Packed YUV 4:4:4 10-bit. 370 Y416 , // Packed YUV 4:4:4 16-bit. 371 }; 372 373 enum FrameType 374 { 375 NONE_PICTURE = 0, 376 I_PICTURE = 1, 377 P_PICTURE = 2, 378 B_PICTURE = 3, 379 D_PICTURE = 4, 380 VIDEO_FRAME = 0x7, 381 AUDIO_FRAME = 0x8 382 }; 383 384 enum InterlaceType 385 { 386 PROGRESSIVE = 0, 387 //FIELD_PICTURE = 1, 388 INTERLEAVED_TOP_FIELD_FIRST = 2, 389 INTERLEAVED_BOTTOM_FIELD_FIRST = 3 390 }; 391 392 enum // decoding flags 393 { 394 //receiving this flag decoder must output decompressed data 395 //in proper display order, otherwise it will output decompressed data 396 //in decoding order, application is responsible to reorder frames to 397 //before displaying 398 FLAG_VDEC_REORDER = 0x00000004, 399 400 //next flag describes endian related properties of input data 401 //when set, means that coded data should be accessed by 4-reading operations 402 //for little-endian systems it means that each 4 bytes are swapped 403 //i.e [0]<->[3], [1]<->[2] 404 //for big-endian systems swapping is not required 405 FLAG_VDEC_4BYTE_ACCESS = 0x00000100, 406 407 ////traditional, not UMC specific behavior 408 ////original byte order, headers before data, return bytes consumed 409 //FLAG_VDEC_COMPATIBLE = 0x00001000, 410 ////external memory is used for frame decoding 411 FLAG_VDEC_EXTERNAL_SURFACE_USE = 0x00002000, 412 413 // adjust time stamp to 29.97fps on 24fps progressively encoded sequences 414 // if telecining attributes are available in the bitstream 415 FLAG_VDEC_TELECINE_PTS = 0x01000000 416 }; 417 418 enum // encoding flags 419 { 420 // The encoder should reorder the incoming frames in the encoding order itself. 421 FLAG_VENC_REORDER = 0x00000004 422 }; 423 424 enum // video renderer flags 425 { 426 //render initialized with this flag will render decompressed data from decoder 427 //in proper display order 428 //see FLAG_VDEC_REORDER flag as pair for this 429 FLAG_VREN_REORDER = 0x00000001, 430 FLAG_VREN_CONVERT = 0x00000002, 431 FLAG_VREN_USECOLORKEY = 0x00000004 432 }; 433 434 enum AudioChannelConfig 435 { 436 CHANNEL_FRONT_LEFT = 0x1, 437 CHANNEL_FRONT_RIGHT = 0x2, 438 CHANNEL_FRONT_CENTER = 0x4, 439 CHANNEL_LOW_FREQUENCY = 0x8, 440 CHANNEL_BACK_LEFT = 0x10, 441 CHANNEL_BACK_RIGHT = 0x20, 442 CHANNEL_FRONT_LEFT_OF_CENTER = 0x40, 443 CHANNEL_FRONT_RIGHT_OF_CENTER = 0x80, 444 CHANNEL_BACK_CENTER = 0x100, 445 CHANNEL_SIDE_LEFT = 0x200, 446 CHANNEL_SIDE_RIGHT = 0x400, 447 CHANNEL_TOP_CENTER = 0x800, 448 CHANNEL_TOP_FRONT_LEFT = 0x1000, 449 CHANNEL_TOP_FRONT_CENTER = 0x2000, 450 CHANNEL_TOP_FRONT_RIGHT = 0x4000, 451 CHANNEL_TOP_BACK_LEFT = 0x8000, 452 CHANNEL_TOP_BACK_CENTER = 0x10000, 453 CHANNEL_TOP_BACK_RIGHT = 0x20000, 454 CHANNEL_RESERVED = 0x80000000 455 }; 456 457 enum // audio renderer flags 458 { 459 FLAG_AREN_VOID = 0x00000001 460 }; 461 462 enum // splitter flags 463 { 464 //invalid value 465 UNDEF_SPLITTER = 0x00000000, 466 //audio splitting required in any present in stream 467 AUDIO_SPLITTER = 0x00000001, 468 //video splitting required in any present in stream 469 VIDEO_SPLITTER = 0x00000002, 470 //example if setup VIDEO_SPLITTER && !set AUDIO_SPLITTER, splitter will ignore 471 //any audio elementary stream, only video data request will be valid 472 473 //audio and video splitting required if any present in stream 474 AV_SPLITTER = AUDIO_SPLITTER|VIDEO_SPLITTER, 475 476 //main video header (sequence header) is required to return from Init 477 //splitter function, application is responsible to pass it to decoder 478 //as a regular video data for properly decoding consequent data 479 FLAG_VSPL_VIDEO_HEADER_REQ = 0x00000010, 480 481 //the first video frame is required to return from Init 482 //splitter function, application is responsible to pass it to decoder 483 //as a regular video data for properly decoding consequent data. 484 //The first frame will follow main video header. This flag expands 485 //splitter behavior for FLAG_VSPL_VIDEO_HEADER_REQ case 486 FLAG_VSPL_VIDEO_FRAME_REQ = 0x00000020, 487 FLAG_VSPL_AUDIO_INFO_REQ = 0x00000040, 488 FLAG_VSPL_VIDEO_INFO_REQ = 0x00000080, 489 490 //next flag describes endian related properties of input data 491 //when set, means that coded data should be accessed by 4-reading operations 492 //for little-endian systems it means that each 4 bytes are swapped 493 //i.e [0]<->[3], [1]<->[2] 494 //for big-endian systems swapping is not required 495 FLAG_VSPL_4BYTE_ACCESS = 0x00000100, 496 497 ////traditional, not UMC specific behavior 498 ////original byte order, headers before data, return bytes consumed 499 //FLAG_VSPL_COMPATIBLE = 0x00001000, 500 501 //some splitters may have a behavior to run internal 502 //to prohibit asynchronous splitting use this flag 503 FLAG_VSPL_NO_INTERNAL_THREAD= 0x00002000, 504 // if reposition is not supported 505 506 FLAG_SPL_REPOSITION_DISABLED= 0x00004000 507 }; 508 509 enum // values to select video or audio output channels 510 { 511 SELECT_ANY_VIDEO_PID = 0x00000000, //ask for one of available video streams 512 SELECT_ANY_AUDIO_PID = 0x00000000, //ask for one of available audio streams 513 SELECT_ALL_AUDIO_PIDS = 0xffffffff, //ask for all of available audio streams 514 SELECT_ALL_VIDEO_PIDS = 0xffffffff //ask for all of available video streams 515 }; 516 517 enum 518 { 519 SINGLE_CLIENT = 0, // Connection oriented with single client per server 520 MULTIPLE_CLIENTS, // Connection oriented with multiple clients per server 521 BROADCAST // Connection less mode 522 }; 523 524 enum 525 { 526 MAXIMUM_PATH = 1024 527 }; 528 529 struct StreamInfo 530 { 531 }; 532 533 typedef struct sAudioStreamInfo : public StreamInfo 534 { sAudioStreamInfosAudioStreamInfo535 sAudioStreamInfo() 536 : channels(0), sample_frequency(0), bitrate(0), bitPerSample(0), duration(0.0), stream_type(UNDEF_AUDIO) 537 , stream_subtype(UNDEF_AUDIO_SUBTYPE), iProfile(0), iLevel(0), channel_mask(0), streamPID(0), is_protected(false), header(0) 538 { 539 } 540 541 int32_t channels; // (int32_t) number of audio channels 542 int32_t sample_frequency; // (int32_t) sample rate in Hz 543 uint32_t bitrate; // (uint32_t) bitstream in bps 544 uint32_t bitPerSample; // (uint32_t) 0 if compressed 545 546 double duration; // (double) duration of the stream 547 548 AudioStreamType stream_type; // (AudioStreamType) general type of stream 549 AudioStreamSubType stream_subtype; // (AudioStreamSubType) minor type of stream 550 int32_t iProfile; // profile 551 int32_t iLevel; // level 552 553 uint32_t channel_mask; // (uint32_t) channel mask 554 uint32_t streamPID; // (uint32_t) unique ID 555 556 bool is_protected; // audio is encrypted 557 uint32_t header; // (uint32_t) can carry audio header (4-bytes) 558 559 } AudioStreamInfo; 560 561 typedef struct sClipInfo 562 { 563 int32_t width; // (int32_t) width of media 564 int32_t height; // (int32_t) height of media 565 566 } ClipInfo; 567 568 typedef struct sVideoStreamInfo : public StreamInfo 569 { sVideoStreamInfosVideoStreamInfo570 sVideoStreamInfo() 571 : color_format(YV12), bitrate(0), aspect_ratio_width(0), aspect_ratio_height(0), framerate(0.0) 572 , duration(0.0), interlace_type(PROGRESSIVE), stream_type(UNDEF_VIDEO) 573 , stream_subtype(UNDEF_VIDEO_SUBTYPE), streamPID(0), profile(0), level(0) 574 { 575 clip_info.width = 0; 576 clip_info.height = 0; 577 disp_clip_info.width = 0; 578 disp_clip_info.height = 0; 579 } 580 581 ClipInfo clip_info; // (ClipInfo) size of video stream 582 ClipInfo disp_clip_info; 583 ColorFormat color_format; // (ColorFormat) color format of uncompressed video 584 uint32_t bitrate; // (uint32_t) bitrate of video 585 int32_t aspect_ratio_width; // (int32_t) pixel aspect ratio 586 int32_t aspect_ratio_height; // (int32_t) pixel aspect ratio 587 double framerate; // (double) frame rate of video 588 double duration; // (double) duration of media stream 589 InterlaceType interlace_type; // (InterlaceType) interlaced info 590 VideoStreamType stream_type; // (VideoStreamType) video stream type 591 VideoStreamSubType stream_subtype; // (VideoStreamSubType) video stream type 592 uint32_t streamPID; // (uint32_t) unique ID 593 int32_t profile; // (int32_t) profile 594 int32_t level; // (int32_t) level 595 } VideoStreamInfo; 596 597 typedef struct sSystemStreamInfo 598 { 599 double muxrate; // (double) stream bitrate 600 SystemStreamType stream_type; // (SystemStreamType) stream type 601 } SystemStreamInfo; 602 603 struct sRECT 604 { sRECTsRECT605 sRECT(): 606 left(0), 607 top(0), 608 right(0), 609 bottom(0) 610 {} 611 612 int16_t left; 613 int16_t top; 614 int16_t right; 615 int16_t bottom; 616 inline SwapBigEndiansRECT617 void SwapBigEndian() 618 { 619 left = BIG_ENDIAN_SWAP16(left); 620 top = BIG_ENDIAN_SWAP16(top); 621 right = BIG_ENDIAN_SWAP16(right); 622 bottom = BIG_ENDIAN_SWAP16(bottom); 623 } 624 }; 625 626 enum eUMC_Status 627 { 628 UMC_OK = VM_OK, //0, // no error 629 UMC_ERR_FAILED = VM_OPERATION_FAILED, //-999, 630 UMC_ERR_NOT_INITIALIZED = VM_NOT_INITIALIZED, //-998, 631 UMC_ERR_TIMEOUT = VM_TIMEOUT, //-987, 632 UMC_ERR_NOT_ENOUGH_DATA = VM_NOT_ENOUGH_DATA, //-996, // not enough input data 633 UMC_ERR_NULL_PTR = VM_NULL_PTR, // null pointer in input parameters 634 UMC_ERR_INIT =-899, // failed to initialize codec 635 UMC_ERR_SYNC =-897, // can't find sync word in buffer 636 UMC_ERR_NOT_ENOUGH_BUFFER =-896, // not enough buffer to put output data 637 UMC_ERR_END_OF_STREAM =-895, 638 UMC_ERR_OPEN_FAILED =-894, // failed to open file/device 639 UMC_ERR_ALLOC =-883, // failed to allocate memory 640 UMC_ERR_LOCK =-882, // failed to lock memory 641 UMC_ERR_INVALID_STREAM =-881, 642 UMC_ERR_UNSUPPORTED =-879, 643 UMC_ERR_NOT_IMPLEMENTED =-878, 644 UMC_ERR_INVALID_PARAMS =-876, 645 UMC_ERR_NEED_FORCE_OUTPUT =-875, 646 UMC_ERR_GPU_HANG =-874, 647 UMC_WRN_INVALID_STREAM = 1, 648 UMC_WRN_REPOSITION_INPROGRESS = 2, 649 UMC_WRN_INFO_NOT_READY = 3, 650 651 UMC_NTF_NEW_RESOLUTION = 7 652 }; 653 654 typedef int32_t Status; 655 #ifdef __cplusplus 656 extern "C" { 657 #endif 658 const vm_char* GetErrString(Status ErrCode); 659 const vm_char* GetStreamTypeString(SystemStreamType Code); 660 const vm_char* GetFormatTypeString(ColorFormat Code); 661 const vm_char* GetAudioTypeString(AudioStreamType Code); 662 const vm_char* GetVideoTypeString(VideoStreamType Code); 663 const vm_char* GetVideoRenderTypeString(VideoRenderType Code); 664 const vm_char* GetAudioRenderTypeString(AudioRenderType Code); 665 666 #ifdef __cplusplus 667 } // extern "C" 668 #endif 669 670 enum 671 { 672 DEFAULT_ALIGN_VALUE = 16 673 }; 674 675 enum 676 { 677 ERROR_FRAME_MINOR = 0x00000001, 678 ERROR_FRAME_MAJOR = 0x00000002, 679 ERROR_FRAME_REFERENCE_FRAME = 0x00000004, 680 ERROR_FRAME_DPB = 0x00000008, 681 ERROR_FRAME_RECOVERY = 0x00000010, // major artifacts at recovery point 682 ERROR_FRAME_TOP_FIELD_ABSENT = 0x00000020, 683 ERROR_FRAME_BOTTOM_FIELD_ABSENT = 0x00000040, 684 ERROR_FRAME_SHORT_TERM_STUCK = 0x00000100, // used to mark ST which potentially can get stuck in DPB due to frame gaps 685 ERROR_FRAME_DEVICE_FAILURE = 0x80000000 //if this bit is set, this means the error is [UMC::Status] code 686 }; 687 688 // template to align a pointer 689 template<class T> inline 690 T align_pointer(void *pv, size_t lAlignValue = DEFAULT_ALIGN_VALUE) 691 { 692 // some compilers complain to conversion to/from 693 // pointer types from/to integral types. 694 return (T) ((((uint8_t *) pv - (uint8_t *) 0) + (lAlignValue - 1)) & 695 ~(lAlignValue - 1)); 696 } 697 698 699 #ifndef DISALLOW_COPY_AND_ASSIGN 700 #define DISALLOW_COPY_AND_ASSIGN(className) \ 701 className(const className&); \ 702 void operator=(const className&) 703 #endif 704 705 } // namespace UMC 706 707 #endif /* __cplusplus */ 708 709 #endif /* __UMC_STRUCTURES_H__ */ 710