MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / decode_element_descriptors

Function decode_element_descriptors

libhb/stream.c:2640–2737  ·  view source on GitHub ↗

extract what useful information we can from the elementary stream descriptor list at 'dp' and add it to the stream at 'esindx'. Descriptors with info we don't currently use are ignored. The descriptor list & descriptor item formats are defined in ISO 13818-1 (2000E) section 2.6 (pg. 62).

Source from the content-addressed store, hash-verified

2638// The descriptor list & descriptor item formats are defined in
2639// ISO 13818-1 (2000E) section 2.6 (pg. 62).
2640static void decode_element_descriptors(
2641 hb_stream_t *stream,
2642 int pes_idx,
2643 bitbuf_t *bb)
2644{
2645 int ii;
2646
2647 while( bits_bytes_left( bb ) > 2 )
2648 {
2649 uint8_t tag = bits_get(bb, 8);
2650 uint8_t len = bits_get(bb, 8);
2651 switch ( tag )
2652 {
2653 case 5: // Registration descriptor
2654 stream->pes.list[pes_idx].format_id = bits_get(bb, 32);
2655 bits_skip(bb, 8 * (len - 4));
2656 break;
2657
2658 case 10: // ISO_639_language descriptor
2659 {
2660 char code[3];
2661 for (ii = 0; ii < 3; ii++)
2662 {
2663 code[ii] = bits_get(bb, 8);
2664 }
2665 stream->pes.list[pes_idx].lang_code =
2666 lang_to_code(lang_for_code2(code));
2667 bits_skip(bb, 8 * (len - 3));
2668 } break;
2669
2670 case 0x56: // DVB Teletext descriptor
2671 {
2672 // We don't currently process teletext from
2673 // TS or PS streams. Set stream 'kind' to N
2674 stream->pes.list[pes_idx].stream_type = 0x00;
2675 stream->pes.list[pes_idx].stream_kind = N;
2676 strncpy(stream->pes.list[pes_idx].codec_name,
2677 "DVB Teletext", 80);
2678 bits_skip(bb, 8 * len);
2679 } break;
2680
2681 case 0x59: // DVB Subtitleing descriptor
2682 {
2683 int lang_count = len / 8;
2684
2685 stream->pes.list[pes_idx].stream_type = 0x00;
2686 stream->pes.list[pes_idx].stream_kind = S;
2687 stream->pes.list[pes_idx].codec = WORK_DECAVSUB;
2688 stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DVB_SUBTITLE;
2689 strncpy(stream->pes.list[pes_idx].codec_name,
2690 "DVB Subtitling", 80);
2691 if (lang_count > 0)
2692 {
2693 uint8_t * extradata = malloc(5);
2694 char code[3];
2695
2696 stream->pes.list[pes_idx].extradata = extradata;
2697 stream->pes.list[pes_idx].extradata_size = 5;

Callers 2

decode_program_mapFunction · 0.85
decode_ps_mapFunction · 0.85

Calls 6

bits_bytes_leftFunction · 0.85
bits_getFunction · 0.85
bits_skipFunction · 0.85
lang_to_codeFunction · 0.85
lang_for_code2Function · 0.85
update_pes_kindFunction · 0.85

Tested by

no test coverage detected