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

Function hb_ps_stream_find_streams

libhb/stream.c:3894–4075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3892}
3893
3894static void hb_ps_stream_find_streams(hb_stream_t *stream)
3895{
3896 int ii, jj;
3897 hb_buffer_t *buf = hb_buffer_init(HB_DVD_READ_BUFFER_SIZE);
3898
3899 fseeko( stream->file_handle, 0, SEEK_SET );
3900 // Scan beginning of file, then if no program stream map is found
3901 // seek to 20% and scan again since there's occasionally no
3902 // audio at the beginning (particularly for vobs).
3903 for ( ii = 0; ii < 2; ii++ )
3904 {
3905 for ( jj = 0; jj < MAX_PS_PROBE_SIZE; jj += buf->size )
3906 {
3907 int stream_type;
3908 int len;
3909
3910 hb_pes_info_t pes_info;
3911 buf->size = 0;
3912 len = hb_ps_read_packet( stream, buf );
3913 if ( len == 0 )
3914 {
3915 // Must have reached EOF
3916 break;
3917 }
3918 if ( !hb_parse_ps( stream, buf->data, buf->size, &pes_info ) )
3919 {
3920 hb_deep_log( 2, "hb_ps_stream_find_streams: Error parsing PS packet");
3921 continue;
3922 }
3923 if ( pes_info.stream_id == 0xba )
3924 {
3925 stream->ts_flags |= TS_HAS_PCR;
3926 }
3927 else if ( pes_info.stream_id == 0xbc )
3928 {
3929 // program stream map
3930 // Note that if there is a program map, any
3931 // extrapolation that is made below based on
3932 // stream id may be overridden by entry in the map.
3933 if ( decode_ps_map( stream, buf->data, buf->size ) )
3934 {
3935 hb_log("Found program stream map");
3936 // Normally, we could quit here since the program
3937 // stream map *should* map all streams. But once
3938 // again Tivo breaks things by not always creating
3939 // complete maps. So continue processing...
3940 }
3941 else
3942 {
3943 hb_error("Error parsing program stream map");
3944 }
3945 }
3946 else if ( ( pes_info.stream_id & 0xe0 ) == 0xc0 )
3947 {
3948 // MPeg audio (c0 - df)
3949 stream_type = 0x04;
3950 update_ps_streams( stream, pes_info.stream_id,
3951 pes_info.stream_id_ext, stream_type, -1 );

Callers 1

hb_ps_stream_initFunction · 0.85

Calls 13

hb_buffer_initFunction · 0.85
hb_ps_read_packetFunction · 0.85
hb_parse_psFunction · 0.85
hb_deep_logFunction · 0.85
decode_ps_mapFunction · 0.85
hb_logFunction · 0.85
hb_errorFunction · 0.85
update_ps_streamsFunction · 0.85
bits_initFunction · 0.85
bits_getFunction · 0.85
bits_skipFunction · 0.85
hb_stream_seekFunction · 0.85

Tested by

no test coverage detected