summaryrefslogtreecommitdiff
path: root/src/iso11172-1.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 14:24:34 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 14:24:34 +0200
commit0ff825e0e6fe5fc7238e3964d24779a07cb53518 (patch)
tree7b47a9fe58a09e12ed99fdfacc84fff198ce5ce1 /src/iso11172-1.h
parent29ae5ac36d4ffc520232ff393b2455130ec0227e (diff)
Split miav server and client apart. Port client to Qt4. Replace libraw1994 with libiec61883. Add unit tests for multiplexer and fix some bugs in it.
Diffstat (limited to 'src/iso11172-1.h')
-rw-r--r--src/iso11172-1.h96
1 files changed, 53 insertions, 43 deletions
diff --git a/src/iso11172-1.h b/src/iso11172-1.h
index a011383..09588d1 100644
--- a/src/iso11172-1.h
+++ b/src/iso11172-1.h
@@ -29,11 +29,11 @@
* This file contains symbols used to create an ISO11172-1 compatible multiplexed
* MPEG stream.
*/
-
-#include "config.h"
#ifndef __MIAV_ISO11172_1_H__
#define __MIAV_ISO11172_1_H__
+#include <stdint.h>
+
#define CLOCK_90KHZ 90000
namespace ISO11172_1 {
@@ -43,61 +43,63 @@ namespace ISO11172_1 {
// 64 bits (8 bytes)
typedef union {
struct {
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
- unsigned long long int stuffing_byte:8;
- unsigned long long int packet_length:16;
+ uint64_t marker_bit3:1;
+ uint64_t system_clock_reference3:15;
+ uint64_t marker_bit2:1;
+ uint64_t system_clock_reference2:15;
+ uint64_t marker_bit1:1;
+ uint64_t system_clock_reference1:3;
+ uint64_t padding:4;
+ uint64_t stuffing_byte:8;
+ uint64_t packet_length:16;
} bits;
- unsigned long long int ulli;
+ uint64_t ulli;
} packet_header;
- typedef union {
+#define MASK3 0x7
+#define MASK15 0x7FFF
+#define TIMECODE32_30(x) ((x >> 30) & MASK3 )
+#define TIMECODE29_15(x) ((x >> 15) & MASK15)
+#define TIMECODE14_0(x) ((x >> 0) & MASK15)
+
+ typedef union { // <============ you are here...
struct {
- unsigned long long int marker_bit5:1;
- unsigned long long int mux_rate:22;
- unsigned long long int marker_bit4:1;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
+ uint64_t marker_bit5:1;
+ uint64_t mux_rate:22;
+ uint64_t marker_bit4:1;
+ uint64_t marker_bit3:1;
+ uint64_t system_clock_reference3:15;
+ uint64_t marker_bit2:1;
+ uint64_t system_clock_reference2:15;
+ uint64_t marker_bit1:1;
+ uint64_t system_clock_reference1:3;
+ uint64_t padding:4;
} bits;
- unsigned long long int ulli;
+ uint64_t ulli;
} pack_header;
typedef union {
struct {
- unsigned long long int reserved_byte:8;
- unsigned long long int video_bound:5;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_video_clock_flag:1;
- unsigned long long int system_audio_clock_flag:1;
- unsigned long long int CSPS_flag:1;
- unsigned long long int fixed_flag:1;
- unsigned long long int audio_bound:6;
- unsigned long long int marker_bit2:1;
- unsigned long long int rate_bound:22;
- unsigned long long int marker_bit1:1;
- unsigned long long int header_length:16;
+ uint32_t reserved_byte:8;
+ uint32_t video_bound:5;
+ uint32_t marker_bit:1;
+ uint32_t system_video_clock_flag:1;
+ uint32_t system_audio_clock_flag:1;
+ uint32_t CSPS_flag:1;
+ uint32_t fixed_flag:1;
+ uint32_t audio_bound:6;
} bits;
- unsigned long long int ulli;
+ uint32_t ulli;
} system_header;
typedef union {
struct {
- unsigned long int STD_buffer_size_bound:13;
- unsigned long int STD_buffer_bound_scale:1;
- unsigned long int market_bits:2;
- unsigned long int stream_id:8;
+ uint32_t STD_buffer_size_bound:13;
+ uint32_t STD_buffer_bound_scale:1;
+ uint32_t market_bits:2;
+ uint32_t stream_id:8;
} bits;
- unsigned long int uli;
+ uint32_t uli;
} stream_description;
////////////////////////////////////////////////////
@@ -145,9 +147,17 @@ namespace ISO11172_1 {
}
/**
- * Calculates Rmux according to subclause A.5.4
+ * Calculates Rmux according to subclause A.6.4
* mux stands for multiplexing and R for Rate,
* so Rmux is the rate of the multiplexing.
+ * IMPORTANT: The formula is wrong...
+ * See
+ * https://www.iso.org/obp/ui/#iso:std:iso-iec:11172:-1:ed-1:v1:cor:2:v1:en
+ * for the correct formula:
+ * Rmux = (video_data_rate + audio_data_rate) *
+ * packet_header_size + pack_header_size / packets_per_pack
+ * ( 1 + ---------------------------------------------------------- )
+ * packet_data_size
*/
inline unsigned int Rmux(unsigned int video_data_rate,
unsigned int audio_data_rate,