diff --git a/mythtv/libs/libmythtv/mpeg/H264Parser.cpp b/mythtv/libs/libmythtv/mpeg/H264Parser.cpp
old mode 100644
new mode 100755
index ac805e7..cabdfc5
a
|
b
|
static const float eps = 1E-5; |
92 | 92 | |
93 | 93 | H264Parser::H264Parser(void) |
94 | 94 | { |
| 95 | rbsp_buffer = NULL; |
| 96 | rbsp_buffer_size = 0; |
95 | 97 | Reset(); |
96 | 98 | I_is_keyframe = true; |
97 | 99 | memset(&gb, 0, sizeof(gb)); |
… |
… |
bool H264Parser::new_AU(void) |
183 | 185 | one or more of the following ways. |
184 | 186 | |
185 | 187 | - frame_num differs in value. The value of frame_num used to |
186 | | test this condition is the value of frame_num that appears in |
187 | | the syntax of the slice header, regardless of whether that value |
188 | | is inferred to have been equal to 0 for subsequent use in the |
189 | | decoding process due to the presence of |
190 | | memory_management_control_operation equal to 5. |
| 188 | test this condition is the value of frame_num that appears in |
| 189 | the syntax of the slice header, regardless of whether that value |
| 190 | is inferred to have been equal to 0 for subsequent use in the |
| 191 | decoding process due to the presence of |
| 192 | memory_management_control_operation equal to 5. |
191 | 193 | Note: If the current picture is an IDR picture FrameNum and |
192 | 194 | PrevRefFrameNum are set equal to 0. |
193 | 195 | - pic_parameter_set_id differs in value. |
194 | 196 | - field_pic_flag differs in value. |
195 | 197 | - bottom_field_flag is present in both and differs in value. |
196 | | - nal_ref_idc differs in value with one of the nal_ref_idc values |
197 | | being equal to 0. |
| 198 | - nal_ref_idc differs in value with one of the nal_ref_idc |
| 199 | values being equal to 0. |
198 | 200 | - pic_order_cnt_type is equal to 0 for both and either |
199 | | pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom |
200 | | differs in value. |
| 201 | pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom |
| 202 | differs in value. |
201 | 203 | - pic_order_cnt_type is equal to 1 for both and either |
202 | | delta_pic_order_cnt[0] differs in value, or |
203 | | delta_pic_order_cnt[1] differs in value. |
| 204 | delta_pic_order_cnt[0] differs in value, or |
| 205 | delta_pic_order_cnt[1] differs in value. |
204 | 206 | - nal_unit_type differs in value with one of the nal_unit_type values |
205 | | being equal to 5. |
| 207 | being equal to 5. |
206 | 208 | - nal_unit_type is equal to 5 for both and idr_pic_id differs in |
207 | | value. |
| 209 | value. |
208 | 210 | |
209 | 211 | NOTE â Some of the VCL NAL units in redundant coded pictures or some |
210 | 212 | non-VCL NAL units (e.g. an access unit delimiter NAL unit) may also |
… |
… |
bool H264Parser::new_AU(void) |
230 | 232 | else if ((bottom_field_flag != -1 && prev_bottom_field_flag != -1) && |
231 | 233 | bottom_field_flag != prev_bottom_field_flag) |
232 | 234 | result = true; |
| 235 | else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) && |
| 236 | nal_ref_idc != prev_nal_ref_idc) |
| 237 | result = true; |
233 | 238 | else if ((pic_order_cnt_type == 0 && prev_pic_order_cnt_type == 0) && |
234 | 239 | (pic_order_cnt_lsb != prev_pic_order_cnt_lsb || |
235 | 240 | delta_pic_order_cnt_bottom != |
… |
… |
bool H264Parser::new_AU(void) |
253 | 258 | prev_pic_parameter_set_id = pic_parameter_set_id; |
254 | 259 | prev_field_pic_flag = field_pic_flag; |
255 | 260 | prev_bottom_field_flag = bottom_field_flag; |
| 261 | prev_nal_ref_idc = nal_ref_idc; |
256 | 262 | prev_pic_order_cnt_lsb = pic_order_cnt_lsb; |
257 | 263 | prev_delta_pic_order_cnt_bottom = delta_pic_order_cnt_bottom; |
258 | 264 | prev_delta_pic_order_cnt[0] = delta_pic_order_cnt[0]; |
… |
… |
bool H264Parser::new_AU(void) |
263 | 269 | return result; |
264 | 270 | } |
265 | 271 | |
| 272 | uint32_t H264Parser::load_rbsp(const uint8_t *byteP, uint32_t byte_count) |
| 273 | { |
| 274 | uint32_t rbsp_index = 0; |
| 275 | uint32_t consecutive_zeros = 0; |
| 276 | |
| 277 | if(rbsp_buffer_size < byte_count) |
| 278 | { |
| 279 | delete [] rbsp_buffer; |
| 280 | rbsp_buffer_size = 0; |
| 281 | |
| 282 | rbsp_buffer = new uint8_t[byte_count]; |
| 283 | if(rbsp_buffer == NULL) |
| 284 | return 0; |
| 285 | |
| 286 | rbsp_buffer_size = byte_count; |
| 287 | } |
| 288 | |
| 289 | /* From rbsp while we have data and we don't run into a |
| 290 | * new start code */ |
| 291 | while(byte_count && (consecutive_zeros < 2 || *byteP != 0x01)) |
| 292 | { |
| 293 | /* Copy the byte into the rbsp, unless it |
| 294 | * is the 0x03 in a 0x000003 */ |
| 295 | if(consecutive_zeros < 2 || *byteP != 0x03) |
| 296 | rbsp_buffer[rbsp_index++] = *byteP; |
| 297 | |
| 298 | if(*byteP == 0) |
| 299 | consecutive_zeros += 1; |
| 300 | else |
| 301 | consecutive_zeros = 0; |
| 302 | |
| 303 | byteP += 1; |
| 304 | byte_count -= 1; |
| 305 | } |
| 306 | |
| 307 | return rbsp_index; |
| 308 | } |
| 309 | |
266 | 310 | uint32_t H264Parser::addBytes(const uint8_t *bytes, |
267 | 311 | const uint32_t byte_count, |
268 | 312 | const uint64_t stream_offset) |
… |
… |
uint32_t H264Parser::addBytes(const uint8_t *bytes, |
306 | 350 | if (nal_unit_type == SPS || nal_unit_type == PPS || |
307 | 351 | nal_unit_type == SEI || NALisSlice(nal_unit_type)) |
308 | 352 | { |
| 353 | uint32_t rbsp_size; |
| 354 | |
| 355 | rbsp_size = load_rbsp(byteP, endP - byteP); |
| 356 | |
309 | 357 | /* |
310 | 358 | bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE |
311 | 359 | bytes larger then the actual read bits |
312 | 360 | */ |
313 | | if (byteP + 1 + FF_INPUT_BUFFER_PADDING_SIZE < endP) |
| 361 | if (FF_INPUT_BUFFER_PADDING_SIZE <= rbsp_size) |
314 | 362 | { |
315 | | init_get_bits(&gb, byteP, 8 * (endP - byteP)); |
| 363 | init_get_bits(&gb, rbsp_buffer, 8 * rbsp_size); |
316 | 364 | |
317 | 365 | if (nal_unit_type == SEI) |
318 | 366 | { |
… |
… |
uint32_t H264Parser::addBytes(const uint8_t *bytes, |
335 | 383 | if (new_AU()) |
336 | 384 | set_AU_pending(stream_offset); |
337 | 385 | } |
338 | | |
339 | | byteP += (get_bits_count(&gb) / 8); |
340 | 386 | } |
341 | 387 | } |
342 | 388 | else if (!AU_pending) |
… |
… |
uint32_t H264Parser::addBytes(const uint8_t *bytes, |
348 | 394 | AU_pending = true; |
349 | 395 | AU_offset = stream_offset; |
350 | 396 | } |
351 | | else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) && |
352 | | nal_ref_idc != prev_nal_ref_idc) |
353 | | { |
354 | | AU_pending = true; |
355 | | AU_offset = stream_offset; |
356 | | } |
357 | 397 | } |
358 | 398 | |
359 | 399 | if (AU_pending && NALisSlice(nal_unit_type)) |
… |
… |
uint32_t H264Parser::addBytes(const uint8_t *bytes, |
378 | 418 | else |
379 | 419 | on_frame = on_key_frame = false; |
380 | 420 | |
381 | | prev_nal_ref_idc = nal_ref_idc; |
382 | | |
383 | 421 | return byteP - bytes; |
384 | 422 | } |
385 | 423 | } |
… |
… |
void H264Parser::decode_SPS(GetBitContext * gb) |
600 | 638 | { |
601 | 639 | for (int idx = 0; idx < ((chroma_format_idc != 3) ? 8 : 12); ++idx) |
602 | 640 | { |
603 | | get_bits1(gb); // scaling_list |
| 641 | if(get_bits1(gb)) // Scaling list presnent |
| 642 | { |
| 643 | int sl_n = ((idx < 6) ? 16 : 64); |
| 644 | for(int sl_i = 0; sl_i < sl_n; sl_i++) |
| 645 | { |
| 646 | get_se_golomb(gb); |
| 647 | } |
| 648 | } |
604 | 649 | } |
605 | 650 | } |
606 | 651 | } |
… |
… |
void H264Parser::vui_parameters(GetBitContext * gb) |
1015 | 1060 | |
1016 | 1061 | uint H264Parser::frameRate(void) const |
1017 | 1062 | { |
1018 | | uint64_t num; |
| 1063 | uint64_t num; |
1019 | 1064 | uint64_t fps; |
1020 | 1065 | |
1021 | 1066 | num = 500 * (uint64_t)timeScale; /* 1000 * 0.5 */ |
diff --git a/mythtv/libs/libmythtv/mpeg/H264Parser.h b/mythtv/libs/libmythtv/mpeg/H264Parser.h
index 2117a96..d737741 100644
a
|
b
|
class H264Parser { |
101 | 101 | }; |
102 | 102 | |
103 | 103 | H264Parser(void); |
104 | | ~H264Parser(void) {;} |
| 104 | ~H264Parser(void) {delete [] rbsp_buffer;} |
105 | 105 | |
106 | 106 | uint32_t addBytes(const uint8_t *bytes, |
107 | 107 | const uint32_t byte_count, |
… |
… |
class H264Parser { |
168 | 168 | } |
169 | 169 | |
170 | 170 | bool new_AU(void); |
| 171 | uint32_t load_rbsp(const uint8_t *byteP, uint32_t byte_count); |
171 | 172 | bool decode_Header(GetBitContext *gb); |
172 | 173 | void decode_SPS(GetBitContext *gb); |
173 | 174 | void decode_PPS(GetBitContext * gb); |
… |
… |
class H264Parser { |
181 | 182 | bool I_is_keyframe; |
182 | 183 | |
183 | 184 | uint32_t sync_accumulator; |
| 185 | uint8_t *rbsp_buffer; |
| 186 | uint32_t rbsp_buffer_size; |
184 | 187 | GetBitContext gb; |
185 | 188 | |
186 | 189 | int prev_frame_num, frame_num; |