summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/iso11172-1.h36
-rw-r--r--src/iso11172-2.h20
-rw-r--r--src/iso11172-3.h26
-rw-r--r--src/multiplexer.cc44
-rw-r--r--src/multiplexer.h16
5 files changed, 65 insertions, 77 deletions
diff --git a/src/iso11172-1.h b/src/iso11172-1.h
index 09588d1..e1121ab 100644
--- a/src/iso11172-1.h
+++ b/src/iso11172-1.h
@@ -133,16 +133,16 @@ namespace ISO11172_1 {
/**
* SCR stands for System Clock Reference
*/
- inline unsigned int SCR(unsigned int previous_SCR,
- unsigned int pack_header_size,
- unsigned int packets_per_pack,
- unsigned int packet_data_size,
- unsigned int Rmux)
+ inline uint32_t SCR(uint32_t previous_SCR,
+ uint32_t pack_header_size,
+ uint32_t packets_per_pack,
+ uint32_t packet_data_size,
+ uint32_t Rmux)
{
// To prevent a crash when doing division.
if(Rmux == 0) Rmux = 1;
- return previous_SCR + (unsigned int)((double)(pack_header_size +
- (packets_per_pack * packet_data_size)) *
+ return previous_SCR + (uint32_t)((double)(pack_header_size +
+ (packets_per_pack * packet_data_size)) *
(double)CLOCK_90KHZ / (double)Rmux);
}
@@ -159,22 +159,22 @@ namespace ISO11172_1 {
* ( 1 + ---------------------------------------------------------- )
* packet_data_size
*/
- inline unsigned int Rmux(unsigned int video_data_rate,
- unsigned int audio_data_rate,
- unsigned int packet_header_size,
- unsigned int pack_header_size,
- unsigned int packets_per_pack,
- unsigned int packet_data_size)
+ inline uint32_t Rmux(uint32_t video_data_rate,
+ uint32_t audio_data_rate,
+ uint32_t packet_header_size,
+ uint32_t pack_header_size,
+ uint32_t packets_per_pack,
+ uint32_t packet_data_size)
{
// To prevent a crash when doing division.
if(packets_per_pack == 0) packets_per_pack = 1;
if(packet_data_size == 0) packet_data_size = 1;
- return (unsigned int)(
- ((double)video_data_rate + (double)audio_data_rate) *
- (1.0 + ((double)packet_header_size + (double)pack_header_size / (double)packets_per_pack)
- / (double)packet_data_size)
- );
+ return (uint32_t)(
+ ((double)video_data_rate + (double)audio_data_rate) *
+ (1.0 + ((double)packet_header_size + (double)pack_header_size / (double)packets_per_pack)
+ / (double)packet_data_size)
+ );
}
diff --git a/src/iso11172-2.h b/src/iso11172-2.h
index f2e2fa3..153d651 100644
--- a/src/iso11172-2.h
+++ b/src/iso11172-2.h
@@ -33,19 +33,19 @@ namespace ISO11172_2 {
// Types
////////////////////////////////////////////////////
typedef struct {
- unsigned long int picture_rate:4;
- unsigned long int pel_aspect_ratio:4;
- unsigned long int vertical_size:12;
- unsigned long int horizontal_size:12;
+ uint32_t picture_rate:4;
+ uint32_t pel_aspect_ratio:4;
+ uint32_t vertical_size:12;
+ uint32_t horizontal_size:12;
} sequence_header_1;
typedef struct {
- unsigned long int load_non_intra_quantizer_flag:1;
- unsigned long int load_intra_quantizer_flag:1;
- unsigned long int constrained_parameter_flag:1;
- unsigned long int vbv_buffer_size:10;
- unsigned long int marker_bit:1;
- unsigned long int bitrate:18;
+ uint32_t load_non_intra_quantizer_flag:1;
+ uint32_t load_intra_quantizer_flag:1;
+ uint32_t constrained_parameter_flag:1;
+ uint32_t vbv_buffer_size:10;
+ uint32_t marker_bit:1;
+ uint32_t bitrate:18;
} sequence_header_2;
////////////////////////////////////////////////////
diff --git a/src/iso11172-3.h b/src/iso11172-3.h
index d3eda79..4b63433 100644
--- a/src/iso11172-3.h
+++ b/src/iso11172-3.h
@@ -33,19 +33,19 @@ namespace ISO11172_3 {
// Types
////////////////////////////////////////////////////
typedef struct {
- unsigned long int emphasis:2;
- unsigned long int original_home:1;
- unsigned long int copyright:1;
- unsigned long int mode_extension:2;
- unsigned long int mode:2;
- unsigned long int private_bit:1;
- unsigned long int padding_bit:1;
- unsigned long int sampling_frequency:2;
- unsigned long int bitrate_index:4;
- unsigned long int protection_bit:1;
- unsigned long int layer:2;
- unsigned long int ID:1;
- unsigned long int syncword:12;
+ uint32_t emphasis:2;
+ uint32_t original_home:1;
+ uint32_t copyright:1;
+ uint32_t mode_extension:2;
+ uint32_t mode:2;
+ uint32_t private_bit:1;
+ uint32_t padding_bit:1;
+ uint32_t sampling_frequency:2;
+ uint32_t bitrate_index:4;
+ uint32_t protection_bit:1;
+ uint32_t layer:2;
+ uint32_t ID:1;
+ uint32_t syncword:12;
} header;
////////////////////////////////////////////////////
diff --git a/src/multiplexer.cc b/src/multiplexer.cc
index d4526bc..3d889e2 100644
--- a/src/multiplexer.cc
+++ b/src/multiplexer.cc
@@ -132,14 +132,14 @@ int Multiplexer::Write(int64_t val)
return Write((uint64_t)val);
}
-int Multiplexer::Write(long int val)
+int Multiplexer::Write(int32_t val)
{
val = htonl(val);
return Write((char*)&val, sizeof(val));
}
-int Multiplexer::Write(unsigned long int val)
+int Multiplexer::Write(uint32_t val)
{
val = htonl(val);
@@ -153,28 +153,14 @@ int Multiplexer::Write24(uint32_t val)
return Write((char*)&val, 3 /*24 bit*/);
}
-int Multiplexer::Write(int val)
-{
- val = htonl(val);
-
- return Write((char*)&val, sizeof(val));
-}
-
-int Multiplexer::Write(unsigned int val)
-{
- val = htonl(val);
-
- return Write((char*)&val, sizeof(val));
-}
-
-int Multiplexer::Write(short int val)
+int Multiplexer::Write(int16_t val)
{
val = htons(val);
return Write((char*)&val, sizeof(val));
}
-int Multiplexer::Write(unsigned short int val)
+int Multiplexer::Write(uint16_t val)
{
val = htons(val);
@@ -198,7 +184,7 @@ Frame *Multiplexer::getFrame(StreamType type)
int Multiplexer::read_stream(char *buf, unsigned int size, StreamType type)
{
- unsigned int copied = 0;
+ uint32_t copied = 0;
while( copied < size ) {
@@ -220,7 +206,7 @@ int Multiplexer::read_stream(char *buf, unsigned int size, StreamType type)
// If a frame exists in the buffer copy it to the output buffer
// (No frame ocurres when *running is set to false)
if( frame[type] ) {
- unsigned int doread = (size - copied) < (frame[type]->size - read[type]) ?
+ uint32_t doread = (size - copied) < (frame[type]->size - read[type]) ?
size - copied : (frame[type]->size - read[type]);
//info->info("Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size);
@@ -241,7 +227,7 @@ bool Multiplexer::packet(StreamType type)
// Write data
// info->info("\t\t[%sPacket]", type==TYPE_AUDIO?"Audio\0":"Video\0");
- unsigned short int framesize = read_stream(buf, PACKET_SIZE, type);
+ uint16_t framesize = read_stream(buf, PACKET_SIZE, type);
Write((void*)ISO11172_1::packet_start_code_prefix, SIZEOF(ISO11172_1::packet_start_code_prefix));
switch(type) {
@@ -398,8 +384,8 @@ void Multiplexer::pack_header()
);
*/
- unsigned int video_data_rate;
- unsigned int audio_data_rate;
+ uint32_t video_data_rate;
+ uint32_t audio_data_rate;
if(frame[TYPE_AUDIO]) audio_data_rate = frame[TYPE_AUDIO]->bitrate;
else audio_data_rate = 112000;
@@ -407,12 +393,12 @@ void Multiplexer::pack_header()
if(frame[TYPE_VIDEO]) video_data_rate = frame[TYPE_VIDEO]->bitrate;
else video_data_rate = 1100000;
- unsigned int Rmux = ISO11172_1::Rmux(video_data_rate,
- audio_data_rate,
- 20, // packet_header_size,
- 12, // pack_header_size,
- PACKETS_PER_PACK, // packets_per_pack,
- PACKET_SIZE);// packet_data_size)
+ uint32_t Rmux = ISO11172_1::Rmux(video_data_rate,
+ audio_data_rate,
+ 20, // packet_header_size,
+ 12, // pack_header_size,
+ PACKETS_PER_PACK, // packets_per_pack,
+ PACKET_SIZE);// packet_data_size)
header.bits.mux_rate = Rmux;
//0x1B82;
diff --git a/src/multiplexer.h b/src/multiplexer.h
index 1d315fd..9b2aed1 100644
--- a/src/multiplexer.h
+++ b/src/multiplexer.h
@@ -81,15 +81,17 @@ protected:
int Write(char* data, int size);
int Write(uint64_t val);
int Write(int64_t val);
- int Write(long int val);
- int Write(unsigned long int val);
+ int Write(int32_t val);
+ int Write(uint32_t val);
int Write24(uint32_t val);
+ /*
int Write(int val);
int Write(unsigned int val);
- int Write(short int val);
- int Write(unsigned short int val);
+ */
+ int Write(int16_t val);
+ int Write(uint16_t val);
- unsigned long long int SCR;
+ uint64_t SCR;
double written[NUM_TYPES];
@@ -112,8 +114,8 @@ protected:
ISO11172_2::sequence_header_2 *header2);
*/
// Frequency variables
- unsigned int write_system_header;
- unsigned int write_audio_packet;
+ uint32_t write_system_header;
+ uint32_t write_audio_packet;
Frame *getFrame(StreamType type);
int read_stream(char *buf, unsigned int size, StreamType type);