| 537 | { |
| 538 | |
| 539 | std::tuple<size_t, std::string> dvb::parseDVBSubtitleSegment(ByteVector & data, |
| 540 | std::shared_ptr<TreeItem> parent) |
| 541 | { |
| 542 | // Use the given tree item. If it is not set, use the nalUnitMode (if active). |
| 543 | // We don't set data (a name) for this item yet. |
| 544 | // We want to parse the item and then set a good description. |
| 545 | QString specificDescription; |
| 546 | if (!parent) |
| 547 | return {}; |
| 548 | |
| 549 | // Create a sub byte parser to access the bits |
| 550 | SubByteReaderLogging reader(data, parent, "subtitling_segment()"); |
| 551 | if (data.size() < 6) |
| 552 | throw std::logic_error("The subtitling_segment header must have at least six byte"); |
| 553 | |
| 554 | reader.readBits("sync_byte", 8, Options().withCheckEqualTo(15)); |
| 555 | |
| 556 | unsigned segment_type; |
| 557 | std::string segment_type_name; |
| 558 | { |
| 559 | Options opt; |
| 560 | for (int i = 0; i < 16; i++) |
| 561 | opt.meaningMap[i] = "reserved for future use"; |
| 562 | opt.meaningMap[16] = "page composition segment"; |
| 563 | opt.meaningMap[17] = "region composition segment"; |
| 564 | opt.meaningMap[18] = "CLUT definition segment"; |
| 565 | opt.meaningMap[19] = "object data segment"; |
| 566 | opt.meaningMap[20] = "display definition segment"; |
| 567 | opt.meaningMap[21] = "disparity signalling segment"; |
| 568 | opt.meaningMap[22] = "alternative_CLUT_segment"; |
| 569 | for (int i = 23; i <= 127; i++) |
| 570 | opt.meaningMap[i] = "reserved for future use"; |
| 571 | opt.meaningMap[128] = "end of display set segment"; |
| 572 | for (int i = 129; i < 254; i++) |
| 573 | opt.meaningMap[i] = "private data"; |
| 574 | opt.meaningMap[255] = "stuffing"; |
| 575 | |
| 576 | segment_type = reader.readBits("segment_type", 8, opt); |
| 577 | segment_type_name = opt.meaningMap[segment_type]; |
| 578 | } |
| 579 | |
| 580 | reader.readBits("page_id", 16); |
| 581 | |
| 582 | auto minSegmentLength = int64_t(data.size() - 6); |
| 583 | auto segment_length = |
| 584 | reader.readBits("segment_length", 16, Options().withCheckGreater(minSegmentLength)); |
| 585 | |
| 586 | if (segment_type == 0x10) |
| 587 | parsePageCompositionSegment(reader, segment_length); |
| 588 | else if (segment_type == 0x11) |
| 589 | parseRegionCompositionSegment(reader, segment_length); |
| 590 | else if (segment_type == 0x12) |
| 591 | parseCLUTDefinitionSegment(reader, segment_length); |
| 592 | else if (segment_type == 0x13) |
| 593 | parseObjectDataSegment(reader, segment_length); |
| 594 | else if (segment_type == 0x14) |
| 595 | parseDisplayDefinitionSegment(reader); |
| 596 | else if (segment_type == 0x15) |
nothing calls this directly
no test coverage detected