Exemplo n.º 1
0
void DTSStream::Init ( const int _stream_num)

{
    stream_num = _stream_num;
	MuxStream::Init( PRIVATE_STR_1, 
					 1,  // Buffer scale
					 default_buffer_size,
					 false,
					 muxinto.buffers_in_audio,
					 muxinto.always_buffers_in_audio
		);
    mjpeg_info ("Scanning for header info: dts Audio stream %02x (%s)",
                stream_num,
                bs.StreamName()
                );

	AU_start = bs.bitcount();
    if (bs.GetBits(32)==DTS_SYNCWORD)
    {
		num_syncword++;
        bs.GetBits(6);         // additional sync
        bs.GetBits(1);         // CRC
        bs.GetBits(7);         // pcm samples
        framesize = bs.GetBits(14) + 1;        // frame size

        bs.GetBits(6);         // audio channels
        frequency = bs.GetBits(4);  // sample rate code
        bit_rate = dts_bitrate_index[bs.GetBits(5)];
        bs.GetBits(5);              // misc.

        header_skip = 10;        // Initially skipped past 10 bytes of header 

		num_frames++;
        access_unit.start = AU_start;
		access_unit.length = framesize;
        mjpeg_info( "dts frame size = %d", framesize );
		samples_per_second = dts_frequency[frequency];

		/* Presentation time-stamping  */
		access_unit.PTS = static_cast<clockticks>(decoding_order) * 
			static_cast<clockticks>(DTS_PACKET_SAMPLES) * 
			static_cast<clockticks>(CLOCKS)	/ samples_per_second;
		access_unit.DTS = access_unit.PTS;
		access_unit.dorder = decoding_order;
		++decoding_order;
		aunits.Append( access_unit );

    } else
    {
		mjpeg_error ( "Invalid dts Audio stream header.");
		exit (1);
    }
	OutputHdrInfo();
}
Exemplo n.º 2
0
void LPCMStream::Init ( const int _stream_num)

{
    stream_num = _stream_num;
    header_skip = 0;
	MuxStream::Init( PRIVATE_STR_1, 
					 1,  // Buffer scale
					 default_buffer_size,
					 false,
					 muxinto.buffers_in_audio,
					 muxinto.always_buffers_in_audio
		);

    // This seems to be necessary not only for some software players but
    // for some standalone players too.   Yuck... shades of the VCD audio
    // sectors.
    min_pes_header_len = 10;
    mjpeg_info ("Scanning for header info: LPCM Audio stream %02x (%s)",
                stream_num,
                bs.StreamName()
                );

    
	AU_start = bs.bitcount();

    // This is a dummy debug version that simply assumes 48kHz
    // two channel 16 bit sample LPCM
    
    samples_per_second = parms->SamplesPerSec();
    channels = parms->Channels();
    bits_per_sample = parms->BitsPerSample();
    bytes_per_frame = 
        samples_per_second * channels * bits_per_sample / 8
        * ticks_per_frame_90kHz
        / 90000;
    frame_index = 0;
    dynamic_range_code = 0x80;

    /* Presentation/decoding time-stamping  */
    access_unit.start = AU_start;
    access_unit.length = bytes_per_frame;
    access_unit.PTS = static_cast<clockticks>(decoding_order) * 
        (CLOCKS_per_90Kth_sec * ticks_per_frame_90kHz);
    access_unit.DTS = access_unit.PTS;
    access_unit.dorder = decoding_order;
    decoding_order++;
    aunits.Append( access_unit );
    
	OutputHdrInfo();
}
Exemplo n.º 3
0
void MPAStream::Init ( const int stream_num )

{
	int padding_bit;

	MuxStream::Init( AUDIO_STR_0 + stream_num, 
					 0,  // Buffer scale
					 muxinto.audio_buffer_size,
					 muxinto.vcd_zero_stuffing,
					 muxinto.buffers_in_audio,
					 muxinto.always_buffers_in_audio
		);
    mjpeg_info ("Scanning for header info: Audio stream %02x (%s)",
                AUDIO_STR_0 + stream_num,
                bs.StreamName()
                );

	/* A.Stevens 2000 - update to be compatible up to  MPEG2.5
	 */
    AU_start = bs.bitcount();
    if (bs.GetBits(11)==AUDIO_SYNCWORD)
    {
		num_syncword++;
		version_id = bs.GetBits( 2);
		layer 		= 3-bs.GetBits( 2); /* 0..2 not 1..3!! */
		protection 		= bs.Get1Bit();
		bit_rate_code	= bs.GetBits( 4);
		frequency 		= bs.GetBits( 2);
		padding_bit     = bs.Get1Bit();
		bs.Get1Bit();
		mode 		= bs.GetBits( 2);
		mode_extension 	= bs.GetBits( 2);
		copyright 		= bs.Get1Bit();
		original_copy 	= bs.Get1Bit ();
		emphasis		= bs.GetBits( 2);

		framesize =
			mpa_bitrates_kbps[version_id][layer][bit_rate_code]  * 
			mpa_slots[layer] *1000 /
			mpa_freq_table[version_id][frequency];

		size_frames[0] = framesize * ( layer == 0 ? 4 : 1);
		size_frames[1] = (framesize+1) * ( layer == 0 ? 4 : 1);
		num_frames[padding_bit]++;
        access_unit.start  = AU_start;
		access_unit.length = size_frames[padding_bit];
	  
		samples_per_second = mpa_freq_table[version_id][frequency];

		/* Presentation time-stamping  */
		access_unit.PTS = static_cast<clockticks>(decoding_order) * 
			static_cast<clockticks>(mpa_samples [layer]) * 
			static_cast<clockticks>(CLOCKS)	/ samples_per_second;
		access_unit.DTS = access_unit.PTS;
		access_unit.dorder = decoding_order;
		++decoding_order;
		aunits.Append( access_unit );

    } else
    {
		mjpeg_error_exit1 ( "Invalid MPEG Audio stream header.");
		// exit (1);
    }


	OutputHdrInfo();
}