| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: budp_seiparse.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/2 $ |
|---|
| 12 | * $brcm_Date: 10/6/10 5:23p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/udp/budp_seiparse.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/2 10/6/10 5:23p darnstein |
|---|
| 21 | * SW7405-4817: fix a comment. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/1 9/22/10 6:44p darnstein |
|---|
| 24 | * SW7405-4817: Interface file for SEI parsing, including 3D SEI message. |
|---|
| 25 | * |
|---|
| 26 | ***************************************************************************/ |
|---|
| 27 | |
|---|
| 28 | /*= Module Overview ********************************************************* |
|---|
| 29 | <verbatim> |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | Overview |
|---|
| 33 | BUDPSEIparse module provides parsing of SEI messages from AVC |
|---|
| 34 | bitstreams. Currently, this software is limited to parsing |
|---|
| 35 | user_data_3d_structure() messages. |
|---|
| 36 | |
|---|
| 37 | In general, this software accepts a buffer of data that contains |
|---|
| 38 | the SEI messages. It parses out the data, and returns it in a |
|---|
| 39 | data structure |
|---|
| 40 | </verbatim> |
|---|
| 41 | ***************************************************************************/ |
|---|
| 42 | |
|---|
| 43 | #ifndef BUDPSEIPARSE_H__ |
|---|
| 44 | #define BUDPSEIPARSE_H__ |
|---|
| 45 | |
|---|
| 46 | #include "bstd.h" |
|---|
| 47 | #include "bavc.h" |
|---|
| 48 | #include "berr.h" |
|---|
| 49 | #include "bavc.h" |
|---|
| 50 | #include "budp.h" |
|---|
| 51 | |
|---|
| 52 | #ifdef __cplusplus |
|---|
| 53 | extern "C" { |
|---|
| 54 | #endif |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | /***************************************************************************** |
|---|
| 58 | * Structures |
|---|
| 59 | *****************************************************************************/ |
|---|
| 60 | |
|---|
| 61 | /*************************************************************************** |
|---|
| 62 | Summary: |
|---|
| 63 | This structure describes a single user_data_3d_structure(). |
|---|
| 64 | |
|---|
| 65 | Description: |
|---|
| 66 | BUDP_SEIparse_3ddata is a data structure that models |
|---|
| 67 | user_data_3d_structure() syntax within SEI messages. |
|---|
| 68 | ***************************************************************************/ |
|---|
| 69 | typedef struct { |
|---|
| 70 | uint32_t frame_packing_arrangement_id; |
|---|
| 71 | bool frame_packing_arrangement_cancel_flag; |
|---|
| 72 | uint8_t frame_packing_arrangement_type; |
|---|
| 73 | bool quincunx_sampling_flag; |
|---|
| 74 | uint8_t content_interpretation_type; |
|---|
| 75 | bool spatial_flipping_flag; |
|---|
| 76 | bool frame0_flipped_flag; |
|---|
| 77 | bool field_views_flag; |
|---|
| 78 | bool current_frame_is_frame0_flag; |
|---|
| 79 | bool frame0_self_contained_flag; |
|---|
| 80 | bool frame1_self_contained_flag; |
|---|
| 81 | uint8 frame0_grid_position_x; |
|---|
| 82 | uint8 frame0_grid_position_y; |
|---|
| 83 | uint8 frame1_grid_position_x; |
|---|
| 84 | uint8 frame1_grid_position_y; |
|---|
| 85 | uint32_t frame_packing_arrangement_repetition_period; |
|---|
| 86 | bool frame_packing_arrangement_extension_flag; |
|---|
| 87 | } |
|---|
| 88 | BUDP_SEIparse_3ddata; |
|---|
| 89 | |
|---|
| 90 | /***************************************************************************** |
|---|
| 91 | * Public API |
|---|
| 92 | *****************************************************************************/ |
|---|
| 93 | |
|---|
| 94 | /***************************************************************************** |
|---|
| 95 | Summary: |
|---|
| 96 | Parses SEI messages from userdata. |
|---|
| 97 | |
|---|
| 98 | Description: |
|---|
| 99 | This function accepts a "packet" of SEI data and searches it for |
|---|
| 100 | recognized SEI messages. Currently, it only recognizes |
|---|
| 101 | 3d_frame_packing_data(). |
|---|
| 102 | |
|---|
| 103 | In order to avoid having an output array of indefinite |
|---|
| 104 | length, this function will only parse at most one "packet" |
|---|
| 105 | of data from its input. A "packet" is defined as the |
|---|
| 106 | userdata that lies between two successive userdata start |
|---|
| 107 | codes (0x00000106). Therefore, several calls to this |
|---|
| 108 | function may be necessary to parse out all the data. |
|---|
| 109 | Parsing will be complete when the function returns a |
|---|
| 110 | *pBytesParsed argument such that (offset + *pBytesParsed == |
|---|
| 111 | pUserdata_info->ui32UserDataBufSize). |
|---|
| 112 | |
|---|
| 113 | The typical usage of this function is as follows: |
|---|
| 114 | |
|---|
| 115 | size_t offset = 0; |
|---|
| 116 | while (offset < info->ui32UserDataBufSize) |
|---|
| 117 | { |
|---|
| 118 | eStatus = |
|---|
| 119 | BUDP_SEIparse (info, offset, &bytesParsed, msgdata); |
|---|
| 120 | if (eStatus == BERR_SUCCESS) |
|---|
| 121 | { |
|---|
| 122 | // Process (*msgdata) as a 3d_frame_packing_data() item |
|---|
| 123 | } |
|---|
| 124 | else if (eStatus == BERR_BUDP_NO_DATA) |
|---|
| 125 | { |
|---|
| 126 | // Just keep looping, there may be more data to process. |
|---|
| 127 | } |
|---|
| 128 | else |
|---|
| 129 | { |
|---|
| 130 | // A real error, get out quick. |
|---|
| 131 | return eStatus; |
|---|
| 132 | } |
|---|
| 133 | offset += bytesParsed; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | Returns: |
|---|
| 137 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 138 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 139 | possibly NULL. |
|---|
| 140 | BERR_BUDP_NO_DATA - No SEI messages were found. As the above |
|---|
| 141 | programming example shows, this is not really |
|---|
| 142 | an error. |
|---|
| 143 | BERR_BUDP_PARSE_ERROR - SEI message(s) were detected, but could not |
|---|
| 144 | be successfully parsed. |
|---|
| 145 | |
|---|
| 146 | See Also: |
|---|
| 147 | *****************************************************************************/ |
|---|
| 148 | BERR_Code BUDP_SEIparse ( |
|---|
| 149 | const BAVC_USERDATA_info* |
|---|
| 150 | pUserdata_info, /* [in] The MPEG userdata to be parsed. */ |
|---|
| 151 | size_t offset, /* [in] Parsing will start at this offset in the |
|---|
| 152 | input buffer |
|---|
| 153 | userdata_info->pUserDataBuffer. */ |
|---|
| 154 | size_t* pBytesParsed, /* [out] The number of bytes parsed from the |
|---|
| 155 | input buffer |
|---|
| 156 | userdata_info->pUserDataBuffer. */ |
|---|
| 157 | BUDP_SEIparse_3ddata* |
|---|
| 158 | p3ddata /* [out] A single instance of extracted |
|---|
| 159 | user_data_3d_structure() data. */ |
|---|
| 160 | ); |
|---|
| 161 | |
|---|
| 162 | #ifdef __cplusplus |
|---|
| 163 | } |
|---|
| 164 | #endif |
|---|
| 165 | |
|---|
| 166 | #endif /* BUDPSEIPARSE_H__ */ |
|---|