--- multiplexer/global.h 2001/04/09 15:26:03 1.6 +++ multiplexer/global.h 2001/04/09 15:51:29 1.7 @@ -75,6 +75,9 @@ #define byte __u8 #define t_msec __s32 +/* ISO 13818 clock reference 90kHz (33 bit) with 27MHz extension (9 bit). + * ba33 holds the high bit of base. + */ typedef struct { __u32 base; __u16 ext; @@ -82,11 +85,20 @@ typedef struct { boolean valid; } clockref; +/* For conversion purposes, this pair of values holds a partial clock + * reference and an internal value in milliseconds. This is to eliminate + * wrapping faults without producing conversion inaccuracies. + */ typedef struct { __u32 base; t_msec msec; } conversion_base; +/* On reference to a controlled data buffer, this one holds the control + * information, mainly: index into the data buffer, length of the referenced + * data block. In a controlled data buffer, a data block is never split to + * wrap at the end of the buffer. The other fields are usage dependend. + */ typedef struct { int index; int length; @@ -98,6 +110,7 @@ typedef struct { byte scramble; } ctrl_buffer; +/* Control buffer */ typedef struct { ctrl_buffer *ptr; int in; @@ -105,6 +118,7 @@ typedef struct { int mask; } refr_ctrl; +/* Data buffer */ typedef struct { byte *ptr; int in; @@ -112,8 +126,10 @@ typedef struct { int mask; } refr_data; +/* Test on buffer emptiness */ #define list_empty(refr) ((refr).out == (refr).in) +/* Create a new buffer, return TRUE on success, FALSE otherwise */ #define list_create(refr,size) \ ((((size) & ((size)-1)) || (size < 2)) ? \ warn (LERR,"List Create",EGLO,1,1,size), FALSE : \ @@ -121,40 +137,52 @@ typedef struct { warn (LERR,"List Create",EGLO,1,2,size), FALSE : \ ((refr).mask = (size)-1, (refr).in = (refr).out = 0, TRUE)) +/* Release a buffer no longer used */ #define list_release(refr) \ ((refr).mask = 0, free((refr).ptr), (refr).ptr = NULL) +/* Compute number of free elements in buffer */ #define list_free(refr) \ (((refr).out - (refr).in - 1) & (refr).mask) +/* Compute number of free elements up to the wrapping point, if the + latter is included in the free part of the buffer */ #define list_freeinend(refr) \ ((refr).mask + 1 - (refr).in) +/* Compute number of used elements in buffer (i.e. its current size) */ #define list_size(refr) \ (((refr).in - (refr).out) & (refr).mask) +/* Test on buffer fullness */ #define list_full(refr) \ (list_free(refr) == 0) +/* Test on buffer half-fullness (as trigger criterium) */ #define list_halffull(refr) \ (list_size(refr) > ((refr).mask >> 1)) +/* Increment an index variable that points in to a buffer by a given value */ #define list_incr(var,refr,incr) \ ((var) = (((var) + (incr)) & (refr).mask)) +/* Check a data byte against a mask */ #define marker_check(data,val,mask) \ (((data & mask) != val) ? \ warn(LWAR,"Marker bit",EGLO,2,data,mask), TRUE : FALSE) +/* Check whether a given bit is set in a data byte */ #define marker_bit(data,bit) \ marker_check(data,1<u)+sizeof(((typ*)0)->u.fld))) +/* Reference descriptors as these are parsed from PSI */ typedef struct { int programnumber; short sourceid; @@ -162,6 +190,7 @@ typedef struct { byte *elemdnew[NUMBER_ELEMD]; } mapreference; +/* Source TS PMT list */ typedef struct pmtdescr { struct pmtdescr *next; short pat_section; @@ -176,10 +205,12 @@ typedef struct pmtdescr { byte elemdescr[MAX_PSI_SIZE]; } pmt_descr; +/* Automatic stream usage requests as stated via command */ typedef struct { int sprg, tprg, ssid, tsid; } tsauto_descr; +/* Supported input file types */ typedef enum { ct_none, ct_packetized, @@ -188,6 +219,7 @@ typedef enum { ct_unknown } content_type; +/* Source file */ typedef struct { refr_data data; int handle; @@ -248,6 +280,7 @@ typedef struct { } u; } file_descr; +/* Target program */ typedef struct { int program_number; short pcr_pid; @@ -260,6 +293,7 @@ typedef struct { struct streamdescr *stream[MAX_STRPERPRG]; } prog_descr; +/* Single data or map stream */ typedef struct streamdescr { refr_ctrl ctrl; refr_data data;