| 2490 | } |
| 2491 | |
| 2492 | static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end) |
| 2493 | { |
| 2494 | const uint8_t **pp = &p; |
| 2495 | const uint8_t *desc_list_end; |
| 2496 | const uint8_t *desc_end; |
| 2497 | int desc_list_len; |
| 2498 | int desc_len, desc_tag; |
| 2499 | |
| 2500 | desc_list_len = get16(pp, p_end); |
| 2501 | if (desc_list_len < 0) |
| 2502 | return -1; |
| 2503 | desc_list_len &= 0xfff; |
| 2504 | desc_list_end = p + desc_list_len; |
| 2505 | if (desc_list_end > p_end) |
| 2506 | return -1; |
| 2507 | |
| 2508 | while (1) { |
| 2509 | desc_tag = get8(pp, desc_list_end); |
| 2510 | if (desc_tag < 0) |
| 2511 | return -1; |
| 2512 | desc_len = get8(pp, desc_list_end); |
| 2513 | if (desc_len < 0) |
| 2514 | return -1; |
| 2515 | desc_end = *pp + desc_len; |
| 2516 | if (desc_end > desc_list_end) |
| 2517 | return -1; |
| 2518 | |
| 2519 | if (desc_tag == STREAM_IDENTIFIER_DESCRIPTOR) { |
| 2520 | return get8(pp, desc_end); |
| 2521 | } |
| 2522 | *pp = desc_end; |
| 2523 | } |
| 2524 | |
| 2525 | return -1; |
| 2526 | } |
| 2527 | |
| 2528 | static int is_pes_stream(int stream_type, uint32_t prog_reg_desc) |
| 2529 | { |