Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2015 The Android Open Source Project |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ***************************************************************************** |
| 18 | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | ****************************************************************************** |
| 23 | * @file |
| 24 | * ih264e_encode_header.h |
| 25 | * |
| 26 | * @brief |
| 27 | * This file contains structures and interface prototypes for h264 bitstream |
| 28 | * header encoding |
| 29 | * |
| 30 | * @author |
| 31 | * ittiam |
| 32 | * |
| 33 | * @remarks |
| 34 | * None |
| 35 | * |
| 36 | ******************************************************************************* |
| 37 | */ |
| 38 | |
| 39 | #ifndef IH264E_ENCODE_HEADER_H_ |
| 40 | #define IH264E_ENCODE_HEADER_H_ |
| 41 | |
| 42 | /*****************************************************************************/ |
| 43 | /* Function Macros */ |
| 44 | /*****************************************************************************/ |
| 45 | |
| 46 | /** |
| 47 | ****************************************************************************** |
| 48 | * @brief Macro to put a code with specified number of bits into the |
| 49 | * bitstream |
| 50 | ****************************************************************************** |
| 51 | */ |
| 52 | #define PUT_BITS(ps_bitstrm, code_val, code_len, ret_val, syntax_string) \ |
| 53 | ENTROPY_TRACE(syntax_string, code_val);\ |
| 54 | ret_val |= ih264e_put_bits((ps_bitstrm), (code_val), (code_len)) |
| 55 | |
| 56 | /** |
| 57 | ****************************************************************************** |
| 58 | * @brief Macro to put a code with specified number of bits into the |
| 59 | * bitstream using 0th order exponential Golomb encoding for |
| 60 | * signed numbers |
| 61 | ****************************************************************************** |
| 62 | */ |
| 63 | #define PUT_BITS_UEV(ps_bitstrm, code_val, ret_val, syntax_string) \ |
| 64 | ENTROPY_TRACE(syntax_string, code_val);\ |
| 65 | ret_val |= ih264e_put_uev((ps_bitstrm), (code_val)) |
| 66 | |
| 67 | /** |
| 68 | ****************************************************************************** |
| 69 | * @brief Macro to put a code with specified number of bits into the |
| 70 | * bitstream using 0th order exponential Golomb encoding for |
| 71 | * signed numbers |
| 72 | ****************************************************************************** |
| 73 | */ |
| 74 | #define PUT_BITS_SEV(ps_bitstrm, code_val, ret_val, syntax_string) \ |
| 75 | ENTROPY_TRACE(syntax_string, code_val);\ |
| 76 | ret_val |= ih264e_put_sev((ps_bitstrm), (code_val)) |
| 77 | |
| 78 | |
| 79 | /*****************************************************************************/ |
| 80 | /* Extern Function Declarations */ |
| 81 | /*****************************************************************************/ |
| 82 | |
| 83 | /** |
| 84 | ****************************************************************************** |
| 85 | * |
| 86 | * @brief Generates SPS (Sequence Parameter Set) |
| 87 | * |
| 88 | * @par Description |
| 89 | * This function generates Sequence Parameter Set header as per the spec |
| 90 | * |
| 91 | * @param[in] ps_bitstrm |
| 92 | * pointer to bitstream context (handle) |
| 93 | * |
| 94 | * @param[in] ps_sps |
| 95 | * pointer to structure containing SPS data |
| 96 | * |
| 97 | * @return success or failure error code |
| 98 | * |
| 99 | ****************************************************************************** |
| 100 | */ |
| 101 | WORD32 ih264e_generate_sps |
| 102 | ( |
| 103 | bitstrm_t *ps_bitstrm, |
Hamsalekha S | 4202606 | 2015-07-30 16:20:35 +0530 | [diff] [blame] | 104 | sps_t *ps_sps, |
| 105 | vui_t *ps_vui |
Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 106 | ); |
| 107 | |
| 108 | /** |
| 109 | ****************************************************************************** |
| 110 | * |
| 111 | * @brief Generates PPS (Picture Parameter Set) |
| 112 | * |
| 113 | * @par Description |
| 114 | * Generate Picture Parameter Set as per Section 7.3.2.2 |
| 115 | * |
| 116 | * @param[in] ps_bitstrm |
| 117 | * pointer to bitstream context (handle) |
| 118 | * |
| 119 | * @param[in] ps_pps |
| 120 | * pointer to structure containing PPS data |
| 121 | * |
| 122 | * @return success or failure error code |
| 123 | * |
| 124 | ****************************************************************************** |
| 125 | */ |
| 126 | WORD32 ih264e_generate_pps |
| 127 | ( |
| 128 | bitstrm_t *ps_bitstrm, |
| 129 | pps_t *ps_pps, |
| 130 | sps_t *ps_sps |
| 131 | ); |
| 132 | |
| 133 | /** |
| 134 | ****************************************************************************** |
| 135 | * |
| 136 | * @brief Generates Slice Header |
| 137 | * |
| 138 | * @par Description |
| 139 | * Generate Slice Header as per Section 7.3.5.1 |
| 140 | * |
| 141 | * @param[inout] ps_bitstrm |
| 142 | * pointer to bitstream context for generating slice header |
| 143 | * |
| 144 | * @param[in] ps_slice_hdr |
| 145 | * pointer to slice header params |
| 146 | * |
| 147 | * @param[in] ps_pps |
| 148 | * pointer to pps params referred by slice |
| 149 | * |
| 150 | * @param[in] ps_sps |
| 151 | * pointer to sps params referred by slice |
| 152 | * |
| 153 | * @param[out] ps_dup_bit_strm_ent_offset |
| 154 | * Bitstream struct to store bitstream state |
| 155 | * |
| 156 | * @param[out] pu4_first_slice_start_offset |
| 157 | * first slice offset is returned |
| 158 | * |
| 159 | * @return success or failure error code |
| 160 | * |
| 161 | ****************************************************************************** |
| 162 | */ |
| 163 | WORD32 ih264e_generate_slice_header |
| 164 | ( |
| 165 | bitstrm_t *ps_bitstrm, |
| 166 | slice_header_t *ps_slice_hdr, |
| 167 | pps_t *ps_pps, |
| 168 | sps_t *ps_sps |
| 169 | ); |
| 170 | |
| 171 | /** |
| 172 | ****************************************************************************** |
| 173 | * |
| 174 | * @brief Populates sps structure |
| 175 | * |
| 176 | * @par Description |
| 177 | * Populates sps structure for its use in header generation |
| 178 | * |
| 179 | * @param[in] ps_codec |
| 180 | * pointer to encoder context |
| 181 | * |
| 182 | * @param[out] ps_sps |
| 183 | * pointer to sps params that needs to be populated |
| 184 | * |
| 185 | * @return success or failure error code |
| 186 | * |
| 187 | ****************************************************************************** |
| 188 | */ |
| 189 | IH264E_ERROR_T ih264e_populate_sps |
| 190 | ( |
| 191 | codec_t *ps_codec, |
| 192 | sps_t *ps_sps |
| 193 | ); |
| 194 | |
| 195 | /** |
| 196 | ****************************************************************************** |
| 197 | * |
| 198 | * @brief Populates pps structure |
| 199 | * |
| 200 | * @par Description |
| 201 | * Populates pps structure for its use in header generation |
| 202 | * |
| 203 | * @param[in] ps_codec |
| 204 | * pointer to encoder context |
| 205 | * |
| 206 | * @param[out] ps_pps |
| 207 | * pointer to pps params that needs to be populated |
| 208 | * |
| 209 | * @return success or failure error code |
| 210 | * |
| 211 | ****************************************************************************** |
| 212 | */ |
| 213 | IH264E_ERROR_T ih264e_populate_pps |
| 214 | ( |
| 215 | codec_t *ps_codec, |
| 216 | pps_t *ps_pps |
| 217 | ); |
| 218 | |
| 219 | |
| 220 | /** |
| 221 | ****************************************************************************** |
| 222 | * |
| 223 | * @brief Populates slice header structure |
| 224 | * |
| 225 | * @par Description |
| 226 | * Populates slice header structure for its use in header generation |
| 227 | * |
| 228 | * @param[in] ps_proc |
| 229 | * pointer to proc context |
| 230 | * |
| 231 | * @param[out] ps_slice_hdr |
| 232 | * pointer to slice header structure that needs to be populated |
| 233 | * |
| 234 | * @param[in] ps_pps |
| 235 | * pointer to pps params structure referred by the slice |
| 236 | * |
| 237 | * @param[in] ps_sps |
| 238 | * pointer to sps params referred by the pps |
| 239 | * |
| 240 | * @return success or failure error code |
| 241 | * |
| 242 | ****************************************************************************** |
| 243 | */ |
| 244 | WORD32 ih264e_populate_slice_header |
| 245 | ( |
| 246 | process_ctxt_t *ps_proc, |
| 247 | slice_header_t *ps_slice_hdr, |
| 248 | pps_t *ps_pps, |
| 249 | sps_t *ps_sps |
| 250 | ); |
| 251 | |
| 252 | |
| 253 | /** |
| 254 | ****************************************************************************** |
| 255 | * |
| 256 | * @brief inserts FILLER Nal Unit. |
| 257 | * |
| 258 | * @par Description |
| 259 | * In constant bit rate rc mode, when the bits generated by the codec is |
| 260 | * underflowing the target bit rate, the encoder library inserts filler nal unit. |
| 261 | * |
| 262 | * @param[in] ps_bitstrm |
| 263 | * pointer to bitstream context (handle) |
| 264 | * |
| 265 | * @param[in] insert_fill_bytes |
| 266 | * Number of fill bytes to be inserted |
| 267 | * |
| 268 | * @return success or failure error code |
| 269 | * |
| 270 | ****************************************************************************** |
| 271 | */ |
| 272 | IH264E_ERROR_T ih264e_add_filler_nal_unit |
| 273 | ( |
| 274 | bitstrm_t *ps_bitstrm, |
| 275 | WORD32 insert_fill_bytes |
| 276 | ); |
| 277 | |
| 278 | |
| 279 | #endif //IH264E_ENCODE_HEADER_H_ |