From 3ab74526ffcb8024cd99c2d610db0a207345b316 Mon Sep 17 00:00:00 2001 From: tibs Date: Sat, 18 Oct 2008 15:04:34 +0000 Subject: [PATCH] Bug 14602: move to using types for integers. --HG-- extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%4069 --- accessunit.c | 22 ++--- accessunit_defns.h | 6 +- accessunit_fns.h | 16 ++-- audio_defns.h | 2 +- avs.c | 16 ++-- avs_defns.h | 2 +- avs_fns.h | 14 ++-- bitdata.c | 12 +-- bitdata_fns.h | 6 +- compat.h | 36 ++++---- es.c | 22 ++--- es2ts.c | 10 +-- es_defns.h | 10 +-- es_fns.h | 8 +- esmerge.c | 32 ++++---- esreport.c | 56 ++++++------- esreverse.c | 10 +-- fmtx.c | 10 +-- fmtx.h | 2 +- h222_defns.h | 4 +- h262.c | 4 +- h262_defns.h | 4 +- h262_fns.h | 2 +- l2audio.c | 2 +- m2ts2ts.c | 10 +-- misc.c | 8 +- misc_fns.h | 4 +- nalunit.c | 64 +++++++-------- nalunit_defns.h | 36 ++++---- nalunit_fns.h | 8 +- pcapreport.c | 20 ++--- pes.c | 82 +++++++++---------- pes_defns.h | 28 +++---- pes_fns.h | 38 ++++----- pidint.c | 40 ++++----- pidint_defns.h | 18 ++-- pidint_fns.h | 28 +++---- ps.c | 72 ++++++++-------- ps2ts.c | 8 +- ps_defns.h | 10 +-- ps_fns.h | 12 +-- reverse.c | 96 +++++++++++----------- reverse_defns.h | 12 +-- reverse_fns.h | 22 ++--- test_pes.c | 6 +- ts.c | 200 ++++++++++++++++++++++----------------------- ts2es.c | 10 +-- ts2ps.c | 12 +-- ts_fns.h | 106 ++++++++++++------------ tsinfo.c | 4 +- tsplay.c | 66 +++++++-------- tsreport.c | 88 ++++++++++---------- tsserve.c | 16 ++-- tswrite.c | 72 ++++++++-------- tswrite_defns.h | 8 +- tswrite_fns.h | 4 +- yuv2/Makefile | 2 +- 57 files changed, 755 insertions(+), 763 deletions(-) diff --git a/accessunit.c b/accessunit.c index 628a44f..fad2a58 100644 --- a/accessunit.c +++ b/accessunit.c @@ -45,7 +45,7 @@ * Returns 0 if it succeeds, 1 if some error occurs. */ static inline int build_access_unit(access_unit_p *acc_unit, - u_int32 index) + uint32_t index) { int err; @@ -167,7 +167,7 @@ static inline int num_slices(access_unit_p access_unit) */ extern int get_access_unit_bounds(access_unit_p access_unit, ES_offset *start, - u_int32 *length) + uint32_t *length) { int ii; if (access_unit->primary_start == NULL) @@ -467,7 +467,7 @@ extern int write_access_unit_as_ES(access_unit_p access_unit, */ static int write_access_unit_trailer_as_TS(access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid) + uint32_t video_pid) { int err; @@ -519,7 +519,7 @@ static int write_access_unit_trailer_as_TS(access_unit_context_p context, extern int write_access_unit_as_TS(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid) + uint32_t video_pid) { int ii, err; @@ -566,11 +566,11 @@ extern int write_access_unit_as_TS(access_unit_p access_unit, extern int write_access_unit_as_TS_with_pts_dts(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid, + uint32_t video_pid, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts) + uint64_t dts) { int ii, err; @@ -621,9 +621,9 @@ extern int write_access_unit_as_TS_with_pts_dts(access_unit_p access_un extern int write_access_unit_as_TS_with_PCR(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid, - u_int64 pcr_base, - u_int32 pcr_extn) + uint32_t video_pid, + uint64_t pcr_base, + uint32_t pcr_extn) { int ii, err; @@ -890,7 +890,7 @@ static int maybe_remember_access_unit(reverse_data_p reverse_data, all_slices_I(access_unit))) { ES_offset start_posn = {0,0}; - u_int32 num_bytes = 0; + uint32_t num_bytes = 0; int err = get_access_unit_bounds(access_unit,&start_posn,&num_bytes); if (err) { diff --git a/accessunit_defns.h b/accessunit_defns.h index 2276b4b..d52c4b2 100644 --- a/accessunit_defns.h +++ b/accessunit_defns.h @@ -42,7 +42,7 @@ typedef struct access_unit_context *access_unit_context_p; // A single access unit struct access_unit { - u_int32 index; // The (notional) index of this unit in the stream + uint32_t index; // The (notional) index of this unit in the stream // (i.e., from the context's access_unit_index) int started_primary_picture; // True if we have, indeed, done so nal_unit_p primary_start; // First NAL unit of our primary picture @@ -64,7 +64,7 @@ struct access_unit // so these could actually just be derived from the `primary_start`, // but it's slightly easier to have them more available, and saves // the need to check if `primary_start` is defined before using them). - u_int32 frame_num; + uint32_t frame_num; byte field_pic_flag; // frame or field? byte bottom_field_flag; // for a field (only), bottom or top? // (After merging two field access units into a single frame, @@ -99,7 +99,7 @@ struct access_unit_context // (re)set this to a sensible value. // The index of the first access unit read is 1, and this value is // incremented by each call of `get_next_access_unit` - u_int32 access_unit_index; // The index of the last access unit read + uint32_t access_unit_index; // The index of the last access unit read // If we are collecting reversing information, then we keep a reference // to the reverse data here diff --git a/accessunit_fns.h b/accessunit_fns.h index 1b8fc3a..2bff871 100644 --- a/accessunit_fns.h +++ b/accessunit_fns.h @@ -97,7 +97,7 @@ extern void report_access_unit(FILE *stream, */ extern int get_access_unit_bounds(access_unit_p access_unit, ES_offset *start, - u_int32 *length); + uint32_t *length); /* * Are all slices in this access unit I slices? @@ -154,7 +154,7 @@ extern int write_access_unit_as_ES(access_unit_p access_unit, extern int write_access_unit_as_TS(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid); + uint32_t video_pid); /* * Write out an access unit as TS, with PTS timing in the first PES packet * (and PCR timing in the first TS of the frame). @@ -175,11 +175,11 @@ extern int write_access_unit_as_TS(access_unit_p access_unit, extern int write_access_unit_as_TS_with_pts_dts(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid, + uint32_t video_pid, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts); + uint64_t dts); /* * Write out an access unit as TS, with PCR timing in the first TS of the * frame. @@ -200,9 +200,9 @@ extern int write_access_unit_as_TS_with_pts_dts(access_unit_p access_un extern int write_access_unit_as_TS_with_PCR(access_unit_p access_unit, access_unit_context_p context, TS_writer_p tswriter, - u_int32 video_pid, - u_int64 pcr_base, - u_int32 pcr_extn); + uint32_t video_pid, + uint64_t pcr_base, + uint32_t pcr_extn); /* * Retrieve the next access unit from the given elementary stream. * diff --git a/audio_defns.h b/audio_defns.h index e6f5eee..fba49a7 100644 --- a/audio_defns.h +++ b/audio_defns.h @@ -35,7 +35,7 @@ struct audio_frame { byte *data; // The frame data, including the syncword at the start - u_int32 data_len; + uint32_t data_len; }; typedef struct audio_frame *audio_frame_p; #define SIZEOF_AUDIO_FRAME sizeof(struct audio_frame) diff --git a/avs.c b/avs.c index 853ae8f..7d14476 100644 --- a/avs.c +++ b/avs.c @@ -344,7 +344,7 @@ static int maybe_remember_this_frame(avs_context_p avs, { int err; ES_offset start_posn = {0,0}; - u_int32 num_bytes = 0; + uint32_t num_bytes = 0; if (this_frame->is_frame) { if (this_frame->picture_coding_type == AVS_I_PICTURE_CODING) @@ -663,7 +663,7 @@ extern int get_next_avs_frame(avs_context_p context, */ extern int write_avs_frame_as_TS(TS_writer_p tswriter, avs_frame_p frame, - u_int32 pid) + uint32_t pid) { int ii; ES_unit_list_p list; @@ -708,11 +708,11 @@ extern int write_avs_frame_as_TS(TS_writer_p tswriter, */ extern int write_avs_frame_as_TS_with_pts_dts(avs_frame_p frame, TS_writer_p tswriter, - u_int32 video_pid, + uint32_t video_pid, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts) + uint64_t dts) { int ii; ES_unit_list_p list; @@ -762,9 +762,9 @@ extern int write_avs_frame_as_TS_with_pts_dts(avs_frame_p frame, */ extern int write_avs_frame_as_TS_with_PCR(avs_frame_p frame, TS_writer_p tswriter, - u_int32 video_pid, - u_int64 pcr_base, - u_int32 pcr_extn) + uint32_t video_pid, + uint64_t pcr_base, + uint32_t pcr_extn) { int ii; ES_unit_list_p list; diff --git a/avs_defns.h b/avs_defns.h index ad2da3b..c9d65e9 100644 --- a/avs_defns.h +++ b/avs_defns.h @@ -113,7 +113,7 @@ struct avs_context // The index of the first frame read is 1, and this value is // incremented by each call of `get_next_avs_frame` (note that // for this purpose, sequence headers are *not* considered frames) - u_int32 frame_index; // The index of the last frame read + uint32_t frame_index; // The index of the last frame read // We detect the end of an AVS frame (or sequence header) by // reading the first item that cannot be part of it. We then need diff --git a/avs_fns.h b/avs_fns.h index e28012b..c992339 100644 --- a/avs_fns.h +++ b/avs_fns.h @@ -131,7 +131,7 @@ extern int get_next_avs_frame(avs_context_p context, */ extern int write_avs_frame_as_TS(TS_writer_p tswriter, avs_frame_p frame, - u_int32 pid); + uint32_t pid); /* * Write out an AVS frame as TS, with PTS timing in the first PES packet * (and PCR timing in the first TS of the frame). @@ -151,11 +151,11 @@ extern int write_avs_frame_as_TS(TS_writer_p tswriter, */ extern int write_avs_frame_as_TS_with_pts_dts(avs_frame_p frame, TS_writer_p tswriter, - u_int32 video_pid, + uint32_t video_pid, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts); + uint64_t dts); /* * Write out an AVS frame as TS, with PCR timing in the first TS of the * frame. @@ -169,9 +169,9 @@ extern int write_avs_frame_as_TS_with_pts_dts(avs_frame_p frame, */ extern int write_avs_frame_as_TS_with_PCR(avs_frame_p frame, TS_writer_p tswriter, - u_int32 video_pid, - u_int64 pcr_base, - u_int32 pcr_extn); + uint32_t video_pid, + uint64_t pcr_base, + uint32_t pcr_extn); /* * Write out a frame (as stored in an ES unit list) as ES * diff --git a/bitdata.c b/bitdata.c index ad8576b..272ee2c 100644 --- a/bitdata.c +++ b/bitdata.c @@ -138,10 +138,10 @@ extern int read_bit(bitdata_p bitdata, */ extern int read_bits(bitdata_p bitdata, int count, - u_int32 *bits) + uint32_t *bits) { int index = 0; - u_int32 result = 0; + uint32_t result = 0; assert((count >=0 && count <= 32)); @@ -208,9 +208,9 @@ extern int count_zero_bits(bitdata_p bitdata) * Returns 0 if all went well, 1 if there were not enough bits in the data. */ extern int read_exp_golomb(bitdata_p bitdata, - u_int32 *result) + uint32_t *result) { - u_int32 next = 0; + uint32_t next = 0; int leading_zero_bits = count_zero_bits(bitdata); int err = read_bits(bitdata,leading_zero_bits,&next); if (err) @@ -232,9 +232,9 @@ extern int read_exp_golomb(bitdata_p bitdata, * Returns 0 if all went well, 1 if there were not enough bits in the data. */ extern int read_signed_exp_golomb(bitdata_p bitdata, - int32 *result) + int32_t *result) { - u_int32 val = 0; + uint32_t val = 0; int err = read_exp_golomb(bitdata,&val); if (err) { diff --git a/bitdata_fns.h b/bitdata_fns.h index 5579c46..e84c901 100644 --- a/bitdata_fns.h +++ b/bitdata_fns.h @@ -71,7 +71,7 @@ extern int read_bit(bitdata_p bitdata, */ extern int read_bits(bitdata_p bitdata, int count, - u_int32 *bits); + uint32_t *bits); /* * Reads `count` bits from the data, into a byte. @@ -100,7 +100,7 @@ extern int count_zero_bits(bitdata_p bitdata); * Returns 0 if all went well, 1 if there were not enough bits in the data. */ extern int read_exp_golomb(bitdata_p bitdata, - u_int32 *result); + uint32_t *result); /* * Read and decode a signed Exp-Golomb code. @@ -110,7 +110,7 @@ extern int read_exp_golomb(bitdata_p bitdata, * Returns 0 if all went well, 1 if there were not enough bits in the data. */ extern int read_signed_exp_golomb(bitdata_p bitdata, - int32 *result); + int32_t *result); #endif // _bitdata_fns diff --git a/compat.h b/compat.h index 929e84b..8400e9c 100644 --- a/compat.h +++ b/compat.h @@ -39,17 +39,17 @@ // Kill deprecation warnings #pragma warning( 4: 4996 ) - -// I can't find a sensible location that defines "guaranteed" quantities -// for these, so we'll have to be old-fashioned +// Windows doesn't seem to supply , so we shall have to try +// for values we hope work typedef unsigned char byte; -typedef unsigned short u_int16; -typedef unsigned long u_int32; -typedef unsigned __int64 u_int64; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +typedef unsigned __int64 uint64_t; -typedef short int16; -typedef long int32; -typedef __int64 int64; +typedef short int16_t; +typedef long int32_t; +typedef __int64 int64_t; // On BSD, lseek takes a 64-bit off_t value // On Linux, if the system supports long files, it does the same @@ -91,20 +91,12 @@ typedef __int64 offset_t; #define snprintf _snprintf #else // _WIN32 -#include // Posix standard primitive system data types +// Other than on Windows, using the C99 integer definitions is what people +// expect, so do so +#include -// C99 also defines equivalent types in , but the unsigned types -// are spelt uint8_t, etc., instead of u_int8_t. Given the need to support -// older compilers, go with the Posix standard. - -typedef u_int8_t byte; -typedef u_int16_t u_int16; -typedef u_int32_t u_int32; -typedef u_int64_t u_int64; - -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; +// Keep "byte" for historical/affectionate reasons +typedef uint8_t byte; // lseek on BSD/Linux uses an off_t quantity to specify the required // position. Where 64 bit file positions are supported, this is a 64 bit diff --git a/es.c b/es.c index 0c9bcdd..8230aa2 100644 --- a/es.c +++ b/es.c @@ -342,7 +342,7 @@ extern int build_ES_unit(ES_unit_p *unit) */ extern int build_ES_unit_from_data(ES_unit_p *unit, byte *data, - u_int32 data_len) + uint32_t data_len) { ES_unit_p new = malloc(SIZEOF_ES_UNIT); if (new == NULL) @@ -898,13 +898,13 @@ extern int seek_ES(ES_p es, */ static int read_bytes_from_PES(ES_p es, byte *data, - u_int32 num_bytes) + uint32_t num_bytes) { - int err; - int offset = 0; - int num_bytes_wanted = num_bytes; - int32 from = es->posn_of_next_byte.inpacket; - int32 num_bytes_left = es->reader->packet->es_data_len - from; + int err; + int offset = 0; + int num_bytes_wanted = num_bytes; + int32_t from = es->posn_of_next_byte.inpacket; + int32_t num_bytes_left = es->reader->packet->es_data_len - from; for (;;) { @@ -965,8 +965,8 @@ static int read_bytes_from_PES(ES_p es, */ extern int read_ES_data(ES_p es, ES_offset start_posn, - u_int32 num_bytes, - u_int32 *data_len, + uint32_t num_bytes, + uint32_t *data_len, byte **data) { int err; @@ -1038,7 +1038,7 @@ extern int get_end_of_underlying_PES_packet(ES_p es, byte **data, int *data_len) { - int32 offset; + int32_t offset; if (es->reading_ES) { @@ -1264,7 +1264,7 @@ extern void report_ES_unit_list(FILE *stream, */ extern int get_ES_unit_list_bounds(ES_unit_list_p list, ES_offset *start, - u_int32 *length) + uint32_t *length) { int ii; if (list->array == NULL || list->length == 0) diff --git a/es2ts.c b/es2ts.c index 8d70670..aaad0c9 100644 --- a/es2ts.c +++ b/es2ts.c @@ -53,7 +53,7 @@ */ static int write_ES_unit_as_TS(TS_writer_p output, ES_unit_p unit, - u_int32 video_pid) + uint32_t video_pid) { int err = write_ES_as_TS_PES_packet(output,unit->data,unit->data_len, video_pid,DEFAULT_VIDEO_STREAM_ID); @@ -68,8 +68,8 @@ static int write_ES_unit_as_TS(TS_writer_p output, static int transfer_data(ES_p es, TS_writer_p output, - u_int32 pmt_pid, - u_int32 video_pid, + uint32_t pmt_pid, + uint32_t video_pid, byte stream_type, int max, int verbose, @@ -204,8 +204,8 @@ int main(int argc, char **argv) int verbose = FALSE; int quiet = FALSE; int max = 0; - u_int32 video_pid = 0x68; - u_int32 pmt_pid = 0x66; + uint32_t video_pid = 0x68; + uint32_t pmt_pid = 0x66; int err = 0; int err2; int ii = 1; diff --git a/es_defns.h b/es_defns.h index 685ebef..eba3e0f 100644 --- a/es_defns.h +++ b/es_defns.h @@ -41,7 +41,7 @@ struct _ES_offset { offset_t infile; // as used by lseek - int32 inpacket; + int32_t inpacket; }; typedef struct _ES_offset ES_offset; typedef struct _ES_offset *ES_offset_p; @@ -64,7 +64,7 @@ struct elementary_stream // And maintain a buffer of "read ahead" bytes byte read_ahead[ES_READ_AHEAD_SIZE]; offset_t read_ahead_posn; // location of this data in the file - int32 read_ahead_len; // actual number of bytes in the buffer + int32_t read_ahead_len; // actual number of bytes in the buffer // And the next byte to be read is specified by its offset in said // data stream. For "bare" ES data, the `infile` value is used to @@ -84,7 +84,7 @@ struct elementary_stream byte *data_ptr; // And which byte we're interested in offset_t last_packet_posn; // Where the last PES packet was in the file - int32 last_packet_es_data_len; // And its number of ES bytes + int32_t last_packet_es_data_len; // And its number of ES bytes // Regardless, our triple byte memory is the same byte cur_byte; // The current (last read) byte @@ -111,8 +111,8 @@ struct ES_unit { ES_offset start_posn; // The start of the current data unit byte *data; // Its data, including the leading 00 00 01 - u_int32 data_len; // Its length - u_int32 data_size; // The total buffer size + uint32_t data_len; // Its length + uint32_t data_size; // The total buffer size byte start_code; // The byte after the 00 00 01 prefix diff --git a/es_fns.h b/es_fns.h index 057eb6d..0892b64 100644 --- a/es_fns.h +++ b/es_fns.h @@ -164,7 +164,7 @@ extern int build_ES_unit(ES_unit_p *unit); */ extern int build_ES_unit_from_data(ES_unit_p *unit, byte *data, - u_int32 data_len); + uint32_t data_len); /* * Tidy up and free an ES unit datastructure after we've finished with it. @@ -292,8 +292,8 @@ extern int seek_ES(ES_p es, */ extern int read_ES_data(ES_p es, ES_offset start_posn, - u_int32 num_bytes, - u_int32 *data_len, + uint32_t num_bytes, + uint32_t *data_len, byte **data); @@ -355,7 +355,7 @@ extern void report_ES_unit_list(FILE *stream, */ extern int get_ES_unit_list_bounds(ES_unit_list_p list, ES_offset *start, - u_int32 *length); + uint32_t *length); /* * Compare two ES unit lists. The comparison does not include the start * position of the unit data, but just the actual data - i.e., two unit lists diff --git a/esmerge.c b/esmerge.c index 45cacbe..5eb07f2 100644 --- a/esmerge.c +++ b/esmerge.c @@ -64,11 +64,11 @@ #if TEST_PTS_DTS #include "pes_fns.h" -static int check(u_int64 value) +static int check(uint64_t value) { int err; byte data[5]; - u_int64 result; + uint64_t result; encode_pts_dts(data,2,value); err = decode_pts_dts(data,2,&result); @@ -140,16 +140,16 @@ static int merge_with_avs(avs_context_p video_context, { int ii; int err; - u_int32 prog_pids[2]; + uint32_t prog_pids[2]; byte prog_type[2]; int video_frame_count = 0; int audio_frame_count = 0; - u_int32 video_pts_increment = (u_int32)(90000.0 / video_frame_rate); - u_int32 audio_pts_increment = (90000 * audio_samples_per_frame) / audio_sample_rate; - u_int64 video_pts = 0; - u_int64 audio_pts = 0; + uint32_t video_pts_increment = (uint32_t)(90000.0 / video_frame_rate); + uint32_t audio_pts_increment = (90000 * audio_samples_per_frame) / audio_sample_rate; + uint64_t video_pts = 0; + uint64_t audio_pts = 0; // The "actual" times are just for information, so we aren't too worried // about accuracy - thus floating point should be OK. @@ -342,8 +342,8 @@ static int merge_with_avs(avs_context_p video_context, if (!quiet) { - u_int32 video_elapsed = (u_int32)((double)(100*video_frame_count)/video_frame_rate); - u_int32 audio_elapsed = 100*audio_frame_count* + uint32_t video_elapsed = (uint32_t)((double)(100*video_frame_count)/video_frame_rate); + uint32_t audio_elapsed = 100*audio_frame_count* audio_samples_per_frame/audio_sample_rate; printf("Read %d video frame%s, %.2fs elapsed (%dm %.2fs)\n", video_frame_count,(video_frame_count==1?"":"s"), @@ -376,16 +376,16 @@ static int merge_with_h264(access_unit_context_p video_context, { int ii; int err; - u_int32 prog_pids[2]; + uint32_t prog_pids[2]; byte prog_type[2]; int video_frame_count = 0; int audio_frame_count = 0; - u_int32 video_pts_increment = 90000 / video_frame_rate; - u_int32 audio_pts_increment = (90000 * audio_samples_per_frame) / audio_sample_rate; - u_int64 video_pts = 0; - u_int64 audio_pts = 0; + uint32_t video_pts_increment = 90000 / video_frame_rate; + uint32_t audio_pts_increment = (90000 * audio_samples_per_frame) / audio_sample_rate; + uint64_t video_pts = 0; + uint64_t audio_pts = 0; // The "actual" times are just for information, so we aren't too worried // about accuracy - thus floating point should be OK. @@ -566,8 +566,8 @@ static int merge_with_h264(access_unit_context_p video_context, if (!quiet) { - u_int32 video_elapsed = 100*video_frame_count/video_frame_rate; - u_int32 audio_elapsed = 100*audio_frame_count* + uint32_t video_elapsed = 100*video_frame_count/video_frame_rate; + uint32_t audio_elapsed = 100*audio_frame_count* audio_samples_per_frame/audio_sample_rate; printf("Read %d video frame%s, %.2fs elapsed (%dm %.2fs)\n", video_frame_count,(video_frame_count==1?"":"s"), diff --git a/esreport.c b/esreport.c index 5862e0f..af75200 100644 --- a/esreport.c +++ b/esreport.c @@ -74,22 +74,22 @@ static void report_avs_frames(ES_p es, int num_sequence_headers = 0; int num_sequence_ends = 0; - u_int32 min_frame_size = 1000000; - u_int32 max_frame_size = 0; - u_int32 sum_frame_size = 0; + uint32_t min_frame_size = 1000000; + uint32_t max_frame_size = 0; + uint32_t sum_frame_size = 0; // I, P, B = 0, 1, 2 (we "make up" picture coding type 0 for I frames) - u_int32 min_x_frame_size[3] = {1000000,1000000,1000000}; - u_int32 max_x_frame_size[3] = {0,0,0}; - u_int32 sum_x_frame_size[3] = {0,0,0}; + uint32_t min_x_frame_size[3] = {1000000,1000000,1000000}; + uint32_t max_x_frame_size[3] = {0,0,0}; + uint32_t sum_x_frame_size[3] = {0,0,0}; int num_x_frames[3] = {0,0,0}; - u_int32 min_seq_hdr_size = 1000000; - u_int32 max_seq_hdr_size = 0; - u_int32 sum_seq_hdr_size = 0; + uint32_t min_seq_hdr_size = 1000000; + uint32_t max_seq_hdr_size = 0; + uint32_t sum_seq_hdr_size = 0; ES_offset start; - u_int32 length; + uint32_t length; avs_context_p avs; @@ -357,23 +357,23 @@ static void report_h262_frames(ES_p es, int num_sequence_headers = 0; int num_sequence_ends = 0; - u_int32 min_frame_size = 1000000; - u_int32 max_frame_size = 0; - u_int32 sum_frame_size = 0; + uint32_t min_frame_size = 1000000; + uint32_t max_frame_size = 0; + uint32_t sum_frame_size = 0; // I=1, P=2, B=3, D=4 -- so subtract one before using the picture coding type // as an index into the arrays... - u_int32 min_x_frame_size[4] = {1000000,1000000,1000000,1000000}; - u_int32 max_x_frame_size[4] = {0,0,0,0}; - u_int32 sum_x_frame_size[4] = {0,0,0,0}; + uint32_t min_x_frame_size[4] = {1000000,1000000,1000000,1000000}; + uint32_t max_x_frame_size[4] = {0,0,0,0}; + uint32_t sum_x_frame_size[4] = {0,0,0,0}; int num_x_frames[4] = {0,0,0,0}; - u_int32 min_seq_hdr_size = 1000000; - u_int32 max_seq_hdr_size = 0; - u_int32 sum_seq_hdr_size = 0; + uint32_t min_seq_hdr_size = 1000000; + uint32_t max_seq_hdr_size = 0; + uint32_t sum_seq_hdr_size = 0; ES_offset start; - u_int32 length; + uint32_t length; h262_context_p h262; @@ -726,7 +726,7 @@ static void find_h264_fields(ES_p es, int num_fields = 0; int num_frames = 0; access_unit_context_p context; - u_int32 num_with_PTS = 0; + uint32_t num_with_PTS = 0; err = build_access_unit_context(es,&context); if (err) return; @@ -789,11 +789,11 @@ static void report_h264_frames(ES_p es, int access_unit_count = 0; access_unit_context_p context; - u_int32 min_frame_size = 1000000; - u_int32 max_frame_size = 0; - u_int32 sum_frame_size = 0; + uint32_t min_frame_size = 1000000; + uint32_t max_frame_size = 0; + uint32_t sum_frame_size = 0; - u_int32 num_with_PTS = 0; + uint32_t num_with_PTS = 0; #define I_NON_REF 0 #define I_REF_IDR 1 @@ -803,11 +803,11 @@ static void report_h264_frames(ES_p es, #define I_SLICE_P 1 #define I_SLICE_B 2 #define I_SLICE_MIX 3 - u_int32 slice_types[3][4] = {{0},{0}}; - u_int32 slice_categories[4] = {0}; + uint32_t slice_types[3][4] = {{0},{0}}; + uint32_t slice_categories[4] = {0}; ES_offset start; - u_int32 length; + uint32_t length; err = build_access_unit_context(es,&context); if (err) return; diff --git a/esreverse.c b/esreverse.c index 55d883f..2a7dca6 100644 --- a/esreverse.c +++ b/esreverse.c @@ -69,7 +69,7 @@ extern int write_packet_data(WRITER output, int as_TS, byte data[], int data_len, - u_int32 pid, + uint32_t pid, byte stream_id); /* @@ -171,7 +171,7 @@ static int reverse_h262(ES_p es, if (!err && !quiet) { - u_int32 final_index = reverse_data->index[reverse_data->first_written]; + uint32_t final_index = reverse_data->index[reverse_data->first_written]; printf("\n"); printf("Summary\n"); printf("=======\n"); @@ -212,7 +212,7 @@ static int output_parameter_sets(WRITER output, for (ii = 0; ii < seq_param_dict->length; ii++) { ES_offset posn = seq_param_dict->posns[ii]; - u_int32 length = seq_param_dict->data_lens[ii]; + uint32_t length = seq_param_dict->data_lens[ii]; byte *data = NULL; if (!quiet) printf("Writing out sequence parameter set %d\n", @@ -240,7 +240,7 @@ static int output_parameter_sets(WRITER output, for (ii = 0; ii < pic_param_dict->length; ii++) { ES_offset posn = pic_param_dict->posns[ii]; - u_int32 length = pic_param_dict->data_lens[ii]; + uint32_t length = pic_param_dict->data_lens[ii]; byte *data = NULL; if (!quiet) printf("Writing out picture parameter set %d\n", @@ -360,7 +360,7 @@ static int reverse_access_units(ES_p es, -1,0,reverse_data); if (!err && !quiet) { - u_int32 final_index = reverse_data->index[reverse_data->first_written]; + uint32_t final_index = reverse_data->index[reverse_data->first_written]; printf("\n"); printf("Summary\n"); printf("=======\n"); diff --git a/fmtx.c b/fmtx.c index c57ee55..15ad67a 100644 --- a/fmtx.c +++ b/fmtx.c @@ -46,15 +46,15 @@ TCHAR *fmtx_alloc() return fmtx_buffers[n]; } -int frac_27MHz(int64 n) +int frac_27MHz(int64_t n) { return (int)((n < 0 ? -n : n) % 300LL); } -const TCHAR *fmtx_timestamp(int64 n, unsigned int flags) +const TCHAR *fmtx_timestamp(int64_t n, unsigned int flags) { TCHAR *buf = fmtx_alloc(); - int64 n27 = n * ((flags & FMTX_TS_N_27MHz) != 0 ? 1LL : 300LL); + int64_t n27 = n * ((flags & FMTX_TS_N_27MHz) != 0 ? 1LL : 300LL); switch (flags & FMTX_TS_DISPLAY_MASK) { @@ -69,7 +69,7 @@ const TCHAR *fmtx_timestamp(int64 n, unsigned int flags) case FMTX_TS_DISPLAY_90kHz_32BIT: { - int64 n90 = n27 / 300LL; + int64_t n90 = n27 / 300LL; TCHAR * p = buf; if (n90 < 0) *p++ = _T('-'); @@ -85,7 +85,7 @@ const TCHAR *fmtx_timestamp(int64 n, unsigned int flags) case FMTX_TS_DISPLAY_HMS: { unsigned int h, m, s, f; - int64 a27 = n27 < 0 ? -n27 : n27; + int64_t a27 = n27 < 0 ? -n27 : n27; a27 /= I64K(27); //us f = (unsigned int)(a27 % I64K(1000000)); a27 /= I64K(1000000); diff --git a/fmtx.h b/fmtx.h index 008db6d..8ee0cb4 100644 --- a/fmtx.h +++ b/fmtx.h @@ -54,7 +54,7 @@ typedef char TCHAR; #define FMTX_TS_DISPLAY_ms 0x30 #define FMTX_TS_DISPLAY_HMS 0x40 -const TCHAR * fmtx_timestamp(int64 n, unsigned int flags); +const TCHAR * fmtx_timestamp(int64_t n, unsigned int flags); int fmtx_str_to_timestamp_flags(const TCHAR * arg_str); // Local Variables: diff --git a/h222_defns.h b/h222_defns.h index 1582765..ae1676b 100644 --- a/h222_defns.h +++ b/h222_defns.h @@ -228,8 +228,8 @@ // Timing info (used in reporting on packets). Initialise to all zeroes... struct timing { - u_int64 first_pcr; - u_int64 last_pcr; + uint64_t first_pcr; + uint64_t last_pcr; int first_pcr_packet; int last_pcr_packet; int had_first_pcr; // FALSE until we've started diff --git a/h262.c b/h262.c index 26415b8..fd1cc3a 100644 --- a/h262.c +++ b/h262.c @@ -551,7 +551,7 @@ static int maybe_remember_this_picture(h262_context_p h262, { int err; ES_offset start_posn = {0,0}; - u_int32 num_bytes = 0; + uint32_t num_bytes = 0; if (this_picture->is_picture) { if (this_picture->picture_coding_type == 1) @@ -1081,7 +1081,7 @@ extern int get_next_h262_frame(h262_context_p context, */ extern int write_h262_picture_as_TS(TS_writer_p tswriter, h262_picture_p picture, - u_int32 pid) + uint32_t pid) { int ii; ES_unit_list_p list; diff --git a/h262_defns.h b/h262_defns.h index 1713c25..4779126 100644 --- a/h262_defns.h +++ b/h262_defns.h @@ -71,7 +71,7 @@ struct _h262_picture // field "picture". byte picture_coding_type; // I, P or B byte picture_structure; // top/bottom field or frame - u_int16 temporal_reference; // presentation order within a group + uint16_t temporal_reference; // presentation order within a group byte afd; // its "Active Format Description" value // (NB: with 0xF0 bits set at top of byte) byte is_real_afd; // was it a *real* AFD? @@ -200,7 +200,7 @@ struct h262_context // The index of the first picture read is 1, and this value is // incremented by each call of `get_next_h262_picture` (note that // for this purpose, sequence headers are *not* considered pictures) - u_int32 picture_index; // The index of the last picture read + uint32_t picture_index; // The index of the last picture read // We detect the end of an H.262 picture (or sequence header) by // reading the first item that cannot be part of it. We then need diff --git a/h262_fns.h b/h262_fns.h index 957b8d1..db027ab 100644 --- a/h262_fns.h +++ b/h262_fns.h @@ -210,7 +210,7 @@ extern int get_next_h262_frame(h262_context_p context, */ extern int write_h262_picture_as_TS(TS_writer_p tswriter, h262_picture_p picture, - u_int32 pid); + uint32_t pid); /* * Write out a picture (as stored in an ES unit list) as ES * diff --git a/l2audio.c b/l2audio.c index a729afe..fecc5a7 100644 --- a/l2audio.c +++ b/l2audio.c @@ -134,7 +134,7 @@ const unsigned int aud_frame_rate_n[16] = * Returns the frame length deduced therefrom, or -1 if it finds something * wrong with the header data. */ -static int peek_frame_header(const u_int32 header) +static int peek_frame_header(const uint32_t header) { unsigned int version, layer, padding; // byte protected, private; diff --git a/m2ts2ts.c b/m2ts2ts.c index 4cc8458..f4285dc 100644 --- a/m2ts2ts.c +++ b/m2ts2ts.c @@ -50,7 +50,7 @@ struct _m2ts_packet_buffer { struct _m2ts_packet_buffer * next; struct _m2ts_packet_buffer * prev; - u_int32 timestamp; + uint32_t timestamp; byte * ts_packet; byte m2ts_packet[M2TS_PACKET_SIZE]; }; @@ -67,10 +67,10 @@ typedef struct _m2ts_packet_buffer *m2ts_packet_buffer_p; static void parse_m2ts_packet(m2ts_packet_buffer_p packet_buffer) { packet_buffer->timestamp = - (((u_int32)(packet_buffer->m2ts_packet[0])) << 24) | - (((u_int32)(packet_buffer->m2ts_packet[1])) << 16) | - (((u_int32)(packet_buffer->m2ts_packet[2])) << 8) | - ((u_int32)(packet_buffer->m2ts_packet[3])); + (((uint32_t)(packet_buffer->m2ts_packet[0])) << 24) | + (((uint32_t)(packet_buffer->m2ts_packet[1])) << 16) | + (((uint32_t)(packet_buffer->m2ts_packet[2])) << 8) | + ((uint32_t)(packet_buffer->m2ts_packet[3])); packet_buffer->ts_packet = packet_buffer->m2ts_packet + 4; packet_buffer->next = NULL; packet_buffer->prev = NULL; diff --git a/misc.c b/misc.c index 7f591ca..13ebc0b 100644 --- a/misc.c +++ b/misc.c @@ -61,7 +61,7 @@ // CRC calculation // ============================================================ -static u_int32 crc_table[256]; +static uint32_t crc_table[256]; /* * Populate the (internal) CRC table. May safely be called more than once. @@ -70,7 +70,7 @@ static void make_crc_table() { int i, j; int already_done = 0; - u_int32 crc; + uint32_t crc; if (already_done) return; @@ -101,7 +101,7 @@ static void make_crc_table() * else return value from previous call (not sure if that * needs complementing before being passed back in). */ -extern u_int32 crc32_block(u_int32 crc, byte *pData, int blk_len) +extern uint32_t crc32_block(uint32_t crc, byte *pData, int blk_len) { static int table_made = FALSE; int i, j; @@ -578,7 +578,7 @@ extern int unsigned_value(char *prefix, char *cmd, char *arg, int base, - u_int32 *value) + uint32_t *value) { char *ptr; unsigned long val; diff --git a/misc_fns.h b/misc_fns.h index 10f2325..bce9f06 100644 --- a/misc_fns.h +++ b/misc_fns.h @@ -47,7 +47,7 @@ * else return value from previous call (not sure if that * needs complementing before being passed back in). */ -extern u_int32 crc32_block(u_int32 crc, byte *pData, int blk_len); +extern uint32_t crc32_block(uint32_t crc, byte *pData, int blk_len); /* * Print out the bottom N bits from a byte on the given stream @@ -263,7 +263,7 @@ extern int unsigned_value(char *prefix, char *cmd, char *arg, int base, - u_int32 *value); + uint32_t *value); /* * Read in an integer value, checking for extraneous characters. * diff --git a/nalunit.c b/nalunit.c index 5792696..fa2f9f5 100644 --- a/nalunit.c +++ b/nalunit.c @@ -325,7 +325,7 @@ static int read_slice_data(nal_unit_p nal, { int err; bitdata_p bd = nal->bit_data; - u_int32 temp; + uint32_t temp; nal_slice_data_p data = &(nal->u.slice); nal_seq_param_data_p seq_param_data = NULL; nal_pic_param_data_p pic_param_data = NULL; @@ -488,15 +488,15 @@ static int read_pic_param_set_data(nal_unit_p nal, int err; bitdata_p bd = nal->bit_data; nal_pic_param_data_p data = &(nal->u.pic); - u_int32 temp; + uint32_t temp; // Values that don't get saved into our NAL unit - u_int32 num_ref_idx_10_active; - u_int32 num_ref_idx_11_active; + uint32_t num_ref_idx_10_active; + uint32_t num_ref_idx_11_active; byte weighted_pred_flag; - u_int32 weighted_bipred_idc; - int32 pic_init_qp; - int32 pic_init_qs; - int32 chroma_qp_index_offset; + uint32_t weighted_bipred_idc; + int32_t pic_init_qp; + int32_t pic_init_qs; + int32_t chroma_qp_index_offset; byte deblocking_filter_control_present_flag; byte constrained_intra_pred_flag; @@ -562,7 +562,7 @@ static int read_pic_param_set_data(nal_unit_p nal, unsigned int igroup; for (igroup=0; igroup < data->num_slice_groups; igroup++) { - u_int32 ignint; + uint32_t ignint; err = read_exp_golomb(bd,&ignint); // run_length_minus1[igroup] CHECK("run_length_minus1[x]"); } @@ -573,7 +573,7 @@ static int read_pic_param_set_data(nal_unit_p nal, unsigned int igroup; for (igroup=0; igroup < (data->num_slice_groups - 1); igroup++) { - u_int32 ignint; + uint32_t ignint; err = read_exp_golomb(bd,&ignint); // top_left[igroup] CHECK("top_left[x]"); err = read_exp_golomb(bd,&ignint); // bottom_right[igroup] @@ -585,7 +585,7 @@ static int read_pic_param_set_data(nal_unit_p nal, data->slice_group_map_type == 5) { byte ignbyte; - u_int32 ignint; + uint32_t ignint; err = read_bit(bd,&ignbyte); // slice_group_change_direction_flag CHECK("slice_group_change_direction_flag"); err = read_exp_golomb(bd,&ignint); // slice_group_change_rate_minus1 @@ -593,7 +593,7 @@ static int read_pic_param_set_data(nal_unit_p nal, } else if (data->slice_group_map_type == 6) { - u_int32 pic_size_in_map_units; + uint32_t pic_size_in_map_units; unsigned int ii; int size; err = read_exp_golomb(bd,&pic_size_in_map_units); // minus 1 @@ -605,7 +605,7 @@ static int read_pic_param_set_data(nal_unit_p nal, // Again, notice the range for (ii=0; ii < pic_size_in_map_units; ii++) { - u_int32 ignint; + uint32_t ignint; err = read_bits(bd,size,&ignint); // slice_group_id[ii] CHECK("slice_group_id[x]"); } @@ -680,13 +680,13 @@ static int read_seq_param_set_data(nal_unit_p nal, int err; bitdata_p bd = nal->bit_data; nal_seq_param_data_p data = &(nal->u.seq); - u_int32 temp; + uint32_t temp; // Values that don't get saved into our NAL unit byte reserved_zero_5bits; - u_int32 num_ref_frames; + uint32_t num_ref_frames; byte gaps_in_frame_num_value_allowed_flag; - u_int32 pic_width_in_mbs; - u_int32 pic_height_in_map_units; + uint32_t pic_width_in_mbs; + uint32_t pic_height_in_map_units; #undef CHECK #define CHECK(name) \ @@ -769,9 +769,9 @@ static int read_seq_param_set_data(nal_unit_p nal, else if (data->pic_order_cnt_type == 1) { unsigned int ii; - int32 offset_for_non_ref_pic; - int32 offset_for_top_to_bottom_field; - u_int32 num_ref_frames_in_pic_order_cnt_cycle; + int32_t offset_for_non_ref_pic; + int32_t offset_for_top_to_bottom_field; + uint32_t num_ref_frames_in_pic_order_cnt_cycle; err = read_bit(bd,&data->delta_pic_order_always_zero_flag); CHECK("delta_pic_order_always_zero_flag"); @@ -788,7 +788,7 @@ static int read_seq_param_set_data(nal_unit_p nal, // shall be in the range 0..255 for (ii=0; ii < num_ref_frames_in_pic_order_cnt_cycle; ii++) { - int32 offset_for_ref_frame_XX; + int32_t offset_for_ref_frame_XX; err = read_signed_exp_golomb(bd,&offset_for_ref_frame_XX); // XX = [ii] CHECK("offset_for_ref_frame_X"); } @@ -835,7 +835,7 @@ static int read_SEI_recovery_point(nal_unit_p nal, int err; bitdata_p bd = nal->bit_data; nal_SEI_recovery_data_p data = &(nal->u.sei_recovery); - u_int32 temp; + uint32_t temp; #undef CHECK #define CHECK(name) \ @@ -875,7 +875,7 @@ static int read_SEI(nal_unit_p nal, int SEI_payloadType = 0; int SEI_payloadSize = 0; // in byte bitdata_p bd = nal->bit_data; - u_int32 temp = 0; + uint32_t temp = 0; #undef CHECK #define CHECK(name) \ @@ -1525,7 +1525,7 @@ extern int write_NAL_unit_as_ES(FILE *output, */ extern int write_NAL_unit_as_TS(TS_writer_p tswriter, nal_unit_p nal, - u_int32 video_pid) + uint32_t video_pid) { // Note that we write out *all* of the data for this NAL unit, // i.e., including its 00 00 01 prefix. Also note that we write @@ -1564,7 +1564,7 @@ extern int build_param_dict(param_dict_p *param_dict) new->last_id = -1; new->last_index = -1; - new->ids = malloc(sizeof(u_int32)*NAL_PIC_PARAM_START_SIZE); + new->ids = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE); if (new->ids == NULL) { fprintf(stderr,"### Unable to allocate array within 'dictionary'" @@ -1594,7 +1594,7 @@ extern int build_param_dict(param_dict_p *param_dict) return 1; } - new->data_lens = malloc(sizeof(u_int32)*NAL_PIC_PARAM_START_SIZE); + new->data_lens = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE); if (new->data_lens == NULL) { fprintf(stderr,"### Unable to allocate array within 'dictionary'" @@ -1653,7 +1653,7 @@ extern void free_param_dict(param_dict_p *param_dict) * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_param_data(param_dict_p param_dict, - u_int32 param_id, + uint32_t param_id, nal_unit_p nal) { int ii; @@ -1679,7 +1679,7 @@ extern int remember_param_data(param_dict_p param_dict, if (param_dict->length == param_dict->size) { int newsize = param_dict->size + NAL_PIC_PARAM_INCREMENT; - param_dict->ids = realloc(param_dict->ids,newsize*sizeof(u_int32)); + param_dict->ids = realloc(param_dict->ids,newsize*sizeof(uint32_t)); if (param_dict->ids == NULL) { fprintf(stderr,"### Unable to extend parameter set dictionary array\n"); @@ -1699,7 +1699,7 @@ extern int remember_param_data(param_dict_p param_dict, return 1; } param_dict->data_lens = realloc(param_dict->params, - newsize*sizeof(u_int32)); + newsize*sizeof(uint32_t)); if (param_dict->data_lens == NULL) { fprintf(stderr,"### Unable to extend parameter set dictionary array\n"); @@ -1733,7 +1733,7 @@ extern int remember_param_data(param_dict_p param_dict, * Returns 0 if it succeeds, 1 if the id is not present. */ static inline int lookup_param_data(param_dict_p param_dict, - u_int32 param_id, + uint32_t param_id, nal_innards_p *param_data) { int ii; @@ -1766,7 +1766,7 @@ static inline int lookup_param_data(param_dict_p param_dict, * Returns 0 if it succeeds, 1 if the id is not recognised. */ extern int get_pic_param_data(param_dict_p pic_param_dict, - u_int32 pic_param_id, + uint32_t pic_param_id, nal_pic_param_data_p *pic_param_data) { nal_innards_p innards; @@ -1797,7 +1797,7 @@ extern int get_pic_param_data(param_dict_p pic_param_dict, * Returns 0 if it succeeds, 1 if the id is not recognised. */ extern int get_seq_param_data(param_dict_p seq_param_dict, - u_int32 seq_param_id, + uint32_t seq_param_id, nal_seq_param_data_p *seq_param_data) { nal_innards_p innards; diff --git a/nalunit_defns.h b/nalunit_defns.h index 2a06bf2..08b6379 100644 --- a/nalunit_defns.h +++ b/nalunit_defns.h @@ -94,20 +94,20 @@ enum NAL_UNIT_TYPE // Data for a slice NAL unit struct nal_slice_data { - u_int32 seq_param_set_pic_order_cnt_type; // from the seq param set - u_int32 first_mb_in_slice; - u_int32 slice_type; - u_int32 pic_parameter_set_id; - u_int32 frame_num; + uint32_t seq_param_set_pic_order_cnt_type; // from the seq param set + uint32_t first_mb_in_slice; + uint32_t slice_type; + uint32_t pic_parameter_set_id; + uint32_t frame_num; // From here onwards, the fields are not necessarily all present byte field_pic_flag; // frame or field? 0 if absent byte bottom_field_flag; // 0 if absent int bottom_field_flag_present; - u_int32 idr_pic_id; - u_int32 pic_order_cnt_lsb; - int32 delta_pic_order_cnt_bottom; - int32 delta_pic_order_cnt[2]; - u_int32 redundant_pic_cnt; + uint32_t idr_pic_id; + uint32_t pic_order_cnt_lsb; + int32_t delta_pic_order_cnt_bottom; + int32_t delta_pic_order_cnt[2]; + uint32_t redundant_pic_cnt; int redundant_pic_cnt_present; }; typedef struct nal_slice_data *nal_slice_data_p; @@ -122,10 +122,10 @@ struct nal_seq_param_data byte constraint_set1_flag; byte constraint_set2_flag; byte level_idc; - u_int32 seq_parameter_set_id; // our own id (0..31) - u_int32 log2_max_frame_num; - u_int32 pic_order_cnt_type; - u_int32 log2_max_pic_order_cnt_lsb; + uint32_t seq_parameter_set_id; // our own id (0..31) + uint32_t log2_max_frame_num; + uint32_t pic_order_cnt_type; + uint32_t log2_max_pic_order_cnt_lsb; byte delta_pic_order_always_zero_flag; byte frame_mbs_only_flag; }; @@ -140,8 +140,8 @@ struct nal_pic_param_data int seq_parameter_set_id; // we use this byte entropy_coding_mode_flag; byte pic_order_present_flag; // we use this - u_int32 num_slice_groups; - u_int32 slice_group_map_type; + uint32_t num_slice_groups; + uint32_t slice_group_map_type; // lots of ignored things byte redundant_pic_cnt_present_flag; // this is mildly interesting }; @@ -158,7 +158,7 @@ struct nal_SEI_recovery_data int recovery_frame_cnt; byte exact_match_flag; byte broken_link_flag; - u_int32 changing_slice_group_idc; + uint32_t changing_slice_group_idc; }; typedef struct nal_SEI_recovery_data *nal_SEI_recovery_data_p; #define SIZEOF_NAL_SEI_RECOVERY_DATA sizeof(struct nal_SEI_recovery_data) @@ -187,7 +187,7 @@ struct param_dict int *ids; // The ids for... union nal_innards *params; // ...the data ES_offset *posns; // Where each was read from... - u_int32 *data_lens; // ...and its size + uint32_t *data_lens; // ...and its size int size, length; // of the arrays and their content }; typedef struct param_dict *param_dict_p; diff --git a/nalunit_fns.h b/nalunit_fns.h index 6f7e36a..97358ea 100644 --- a/nalunit_fns.h +++ b/nalunit_fns.h @@ -121,7 +121,7 @@ extern int write_NAL_unit_as_ES(FILE *output, */ extern int write_NAL_unit_as_TS(TS_writer_p tswriter, nal_unit_p nal, - u_int32 video_pid); + uint32_t video_pid); /* * Create a new "dictionary" for remembering picture or sequence @@ -158,7 +158,7 @@ extern void free_param_dict(param_dict_p *param_dict); * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_param_data(param_dict_p param_dict, - u_int32 param_id, + uint32_t param_id, nal_unit_p nal); /* @@ -177,7 +177,7 @@ extern int remember_param_data(param_dict_p param_dict, * Returns 0 if it succeeds, 1 if the id is not recognised. */ extern int get_pic_param_data(param_dict_p pic_param_dict, - u_int32 pic_param_id, + uint32_t pic_param_id, nal_pic_param_data_p *pic_param_data); /* @@ -196,7 +196,7 @@ extern int get_pic_param_data(param_dict_p pic_param_dict, * Returns 0 if it succeeds, 1 if the id is not recognised. */ extern int get_seq_param_data(param_dict_p seq_param_dict, - u_int32 seq_param_id, + uint32_t seq_param_id, nal_seq_param_data_p *seq_param_data); /* diff --git a/pcapreport.c b/pcapreport.c index eb6e681..19d8ee5 100644 --- a/pcapreport.c +++ b/pcapreport.c @@ -64,20 +64,20 @@ typedef struct pcapreport_ctx_struct pcap_hdr_t pcap_hdr; char *output_name; FILE *output_file; - u_int32 output_dest_addr; - u_int32 output_dest_port; + uint32_t output_dest_addr; + uint32_t output_dest_port; TS_reader_p ts_r; // The temporary read buffer used by our ts reader. byte *tmp_buf; - u_int32 tmp_len; + uint32_t tmp_len; // ts packet counter for error reporting. - u_int32 ts_counter; + uint32_t ts_counter; // packet counter. - u_int32 pkt_counter; + uint32_t pkt_counter; // Last continuity counter. int last_cc; @@ -137,7 +137,7 @@ static int digest_times(pcapreport_ctx_t *ctx, ipv4_header_t *ipv4_header, ipv4_udp_header_t *udp_header, const byte *data, - const u_int32 len) + const uint32_t len) { int rv; @@ -176,7 +176,7 @@ static int digest_times(pcapreport_ctx_t *ctx, // Right. Split it .. { - u_int32 pid; + uint32_t pid; int pusi; byte *adapt; int adapt_len; @@ -304,7 +304,7 @@ static int digest_times(pcapreport_ctx_t *ctx, static int write_out_packet(pcapreport_ctx_t *ctx, const byte *data, - const u_int32 len) + const uint32_t len) { int rv; @@ -519,7 +519,7 @@ int main(int argc, char **argv) { pcaprec_hdr_t rec_hdr; byte *data = NULL; - u_int32 len = 0; + uint32_t len = 0; int sent_to_output = 0; err = pcap_read_next(ctx.pcreader, &rec_hdr, &data, &len); @@ -547,7 +547,7 @@ int main(int argc, char **argv) { ethernet_packet_t epkt; - u_int32 out_st, out_len; + uint32_t out_st, out_len; int rv; ipv4_header_t ipv4_hdr; ipv4_udp_header_t udp_hdr; diff --git a/pes.c b/pes.c index e75bbea..be66d5e 100644 --- a/pes.c +++ b/pes.c @@ -247,7 +247,7 @@ static int init_peslist(peslist_p list) fprintf(stderr,"### Unable to allocate PES array in PID/PES data array"); return 1; } - list->pid = malloc(sizeof(u_int32)*PESLIST_START_SIZE); + list->pid = malloc(sizeof(uint32_t)*PESLIST_START_SIZE); if (list->pid == NULL) { free(list->data); @@ -323,7 +323,7 @@ static void free_peslist(peslist_p *peslist) * Returns its index (0 or more) if the PID is in the list, -1 if it is not. */ static inline int pid_index_in_peslist(peslist_p list, - u_int32 pid) + uint32_t pid) { int ii; if (list == NULL) @@ -344,7 +344,7 @@ static inline int pid_index_in_peslist(peslist_p list, * Returns TRUE if the PID is in the list, FALSE if it is not. */ static inline int pid_in_peslist(peslist_p list, - u_int32 pid) + uint32_t pid) { return pid_index_in_peslist(list,pid) != -1; } @@ -358,7 +358,7 @@ static inline int pid_in_peslist(peslist_p list, * Returns 0 if it succeeds, 1 if some error occurs. */ static int start_packet_in_peslist(PES_reader_p reader, - u_int32 pid, + uint32_t pid, int is_video, PES_packet_data_p *data) { @@ -413,7 +413,7 @@ static int start_packet_in_peslist(PES_reader_p reader, free_PES_packet_data(data); return 1; } - list->pid = realloc(list->pid,newsize*sizeof(u_int32)); + list->pid = realloc(list->pid,newsize*sizeof(uint32_t)); if (list->pid == NULL) { fprintf(stderr,"### Unable to extend PID/PES data array\n"); @@ -436,7 +436,7 @@ static int start_packet_in_peslist(PES_reader_p reader, * Returns 0 if it succeeds, 1 if some error occurs. */ static inline int find_packet_in_peslist(peslist_p list, - u_int32 pid, + uint32_t pid, PES_packet_data_p *data) { int index = pid_index_in_peslist(list,pid); @@ -455,7 +455,7 @@ static inline int find_packet_in_peslist(peslist_p list, * Returns 0 if it succeeds, 1 if some error occurs. */ static int clear_packet_in_peslist(peslist_p list, - u_int32 pid) + uint32_t pid) { int index; @@ -846,7 +846,7 @@ static int refine_TS_program_info(PES_reader_p reader, * Returns 0 if all goes well, 1 if something goes wrong. */ static int extract_and_refine_TS_program_info(PES_reader_p reader, - u_int32 pmt_pid, + uint32_t pmt_pid, byte pmt_data[], int pmt_data_len) { @@ -1065,7 +1065,7 @@ static int determine_TS_program_info(PES_reader_p reader) * Returns 0 if all went well, 1 if something went wrong */ static int start_new_PES_packet(PES_reader_p reader, - u_int32 pid, + uint32_t pid, byte payload[], int payload_len, PES_packet_data_p *finished) @@ -1220,7 +1220,7 @@ static int start_new_PES_packet(PES_reader_p reader, * Returns 0 if all went well, 1 if something went wrong */ static int continue_PES_packet(PES_reader_p reader, - u_int32 pid, + uint32_t pid, byte payload[], int payload_len, PES_packet_data_p *finished) @@ -1375,7 +1375,7 @@ static int read_next_PES_packet_from_TS(PES_reader_p reader, byte *payload; int payload_len; - u_int32 pid; + uint32_t pid; // Remember the position of the packet we're going to read reader->posn = reader->tsreader->posn; @@ -1793,7 +1793,7 @@ extern int build_PS_PES_reader(PS_reader_p ps, extern int build_TS_PES_reader(TS_reader_p tsreader, int give_info, int give_warnings, - u_int16 program_number, + uint16_t program_number, PES_reader_p *reader) { int err; @@ -1839,7 +1839,7 @@ extern int build_PES_reader(int input, int is_TS, int give_info, int give_warnings, - u_int16 program_number, + uint16_t program_number, PES_reader_p *reader) { int err; @@ -1903,7 +1903,7 @@ extern int build_PES_reader(int input, * Returns 0 if all goes well, 1 if something goes wrong. */ extern int open_PES_reader_for_TS(char *filename, - u_int16 program_number, + uint16_t program_number, int give_info, int give_warnings, PES_reader_p *reader) @@ -2103,11 +2103,11 @@ extern void set_PES_reader_audio_private1(PES_reader_p reader) * be the same as the `video_pid` */ extern void set_PES_reader_program_data(PES_reader_p reader, - u_int16 program_number, - u_int32 pmt_pid, - u_int32 video_pid, - u_int32 audio_pid, - u_int32 pcr_pid) + uint16_t program_number, + uint32_t pmt_pid, + uint32_t video_pid, + uint32_t audio_pid, + uint32_t pcr_pid) { if (program_number == 0) program_number = 1; @@ -2329,7 +2329,7 @@ extern int read_next_PES_packet(PES_reader_p reader) !reader->dont_write_current_packet) { // Aha - we need to output the previous PES packet - u_int32 pid; + uint32_t pid; byte stream_id; if (reader->program_index == 0) { @@ -2604,9 +2604,9 @@ extern int read_next_PES_ES_packet(PES_reader_p reader) */ extern int decode_pts_dts(byte data[], int required_guard, - u_int64 *value) + uint64_t *value) { - u_int64 pts1,pts2,pts3; + uint64_t pts1,pts2,pts3; int marker; char *what; int guard = (data[0] & 0xF0) >> 4; @@ -2672,7 +2672,7 @@ extern int decode_pts_dts(byte data[], */ extern void encode_pts_dts(byte data[], int guard_bits, - u_int64 value) + uint64_t value) { int pts1,pts2,pts3; @@ -2681,7 +2681,7 @@ extern void encode_pts_dts(byte data[], if (value > MAX_PTS_VALUE) { char *what; - u_int64 temp = value; + uint64_t temp = value; while (temp > MAX_PTS_VALUE) temp -= MAX_PTS_VALUE; switch (guard_bits) @@ -2811,7 +2811,7 @@ extern int report_PES_data_array(char *prefix, byte *bytes; int err; - u_int64 pts, dts; + uint64_t pts, dts; int got_pts = FALSE; // pessimistic int got_dts = FALSE; // pessimistic @@ -3033,7 +3033,7 @@ extern void report_PES_data_array2(int stream_type, int err; int with_pts = FALSE; int with_dts = FALSE; - u_int64 pts, dts; + uint64_t pts, dts; int PES_packet_length; byte *data = NULL; int data_len = 0; @@ -3231,9 +3231,9 @@ extern void report_PES_data_array2(int stream_type, * Returns 0 if all went well, 1 if an error occurs. */ extern int find_PTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_pts, - u_int64 *pts) + uint64_t *pts) { byte stream_id; int packet_length; @@ -3324,9 +3324,9 @@ extern int find_PTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_DTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_dts, - u_int64 *dts) + uint64_t *dts) { byte stream_id; int packet_length; @@ -3418,11 +3418,11 @@ extern int find_DTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_PTS_DTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_pts, - u_int64 *pts, + uint64_t *pts, int *got_dts, - u_int64 *dts) + uint64_t *dts) { byte stream_id; int packet_length; @@ -3534,9 +3534,9 @@ extern int find_PTS_DTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_ESCR_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_escr, - u_int64 *escr) + uint64_t *escr) { byte stream_id; int packet_length; @@ -3582,8 +3582,8 @@ extern int find_ESCR_in_PES(byte data[], *got_escr = (bytes[1] & 0x20) == 0x20; if (*got_escr) { - u_int64 ESCR_base; - u_int32 ESCR_extn; + uint64_t ESCR_base; + uint32_t ESCR_extn; int PTS_DTS_flags = (bytes[1] & 0xC0) >> 6; int offset; if (PTS_DTS_flags == 2) @@ -3597,8 +3597,8 @@ extern int find_ESCR_in_PES(byte data[], (bytes[offset+3] << 5) | (bytes[offset+2] << 13) | (bytes[offset+1] << 20) | - ((((u_int64)bytes[offset]) & 0x03) << 28) | - ((((u_int64)bytes[offset]) & 0x38) << 27); + ((((uint64_t)bytes[offset]) & 0x03) << 28) | + ((((uint64_t)bytes[offset]) & 0x38) << 27); ESCR_extn = (bytes[offset+5] >> 1) | (bytes[offset+4] << 7); @@ -3709,10 +3709,10 @@ extern int write_program_data(PES_reader_p reader, { // We know we support at most two program streams for output int num_progs = 0; - u_int32 prog_pids[2]; + uint32_t prog_pids[2]; byte prog_type[2]; int err; - u_int32 pcr_pid; + uint32_t pcr_pid; // If we are writing out TS data as a side effect of reading TS when // assembling our PES packets, we should not write out any program diff --git a/pes_defns.h b/pes_defns.h index 122d8c4..fd6d67b 100644 --- a/pes_defns.h +++ b/pes_defns.h @@ -40,8 +40,8 @@ struct PES_packet_data { byte *data; // The actual packet data - int32 data_len; // The length of the `data` array [1] - int32 length; // Its length + int32_t data_len; // The length of the `data` array [1] + int32_t length; // Its length offset_t posn; // The offset of its start in the file [2] int is_video; // Is this video data? (as opposed to audio) @@ -49,7 +49,7 @@ struct PES_packet_data // "payload" (i.e., the ES data) as if it were a separate array. This // is, of course, just an offset into `data` byte *es_data; - int32 es_data_len; + int32_t es_data_len; // The PES packet *does* tell us if its data starts with an ES packet // (i.e., if the 00 00 01 bytes come as the first bytes in the data), // so that's worth remembering @@ -72,7 +72,7 @@ typedef struct PES_packet_data *PES_packet_data_p; // An expandable list of PID vs. PES packet data struct peslist { - u_int32 *pid; // An array of the PIDs + uint32_t *pid; // An array of the PIDs PES_packet_data_p *data; // An array of the corresponding PES data int length; // How many there are int size; // How big the arrays are @@ -121,11 +121,11 @@ struct PES_reader int got_program_data; // Do we know our program data yet? pmt_p program_map; // The content of the (current/last) PMT // And from that, we can work out our video and audio (if any) pids, etc. - u_int32 video_pid; // Zero if not yet known - u_int32 audio_pid; // Ditto - u_int32 pcr_pid; // A copy of the value from the PMT - u_int16 program_number; // Which program are we reading? (0=first) - u_int32 pmt_pid; // What's the PMT PID? + uint32_t video_pid; // Zero if not yet known + uint32_t audio_pid; // Ditto + uint32_t pcr_pid; // A copy of the value from the PMT + uint16_t program_number; // Which program are we reading? (0=first) + uint32_t pmt_pid; // What's the PMT PID? // PMTs may be split over several TS packets, so we need a buffer // to build them in @@ -143,11 +143,11 @@ struct PES_reader // and use the values given by the user instead. int override_program_data; // Regardless, the following are the values to use when writing TS data out: - u_int32 output_video_pid; - u_int32 output_audio_pid; - u_int32 output_pcr_pid; - u_int16 output_program_number; - u_int32 output_pmt_pid; + uint32_t output_video_pid; + uint32_t output_audio_pid; + uint32_t output_pcr_pid; + uint16_t output_program_number; + uint32_t output_pmt_pid; // If we're reading Dolby (AC-3) audio, then there are two choices for the // stream type. DVB uses stream type 0x06, and ATSC uses stream type 0x81. diff --git a/pes_fns.h b/pes_fns.h index cac93a7..095d1f0 100644 --- a/pes_fns.h +++ b/pes_fns.h @@ -88,7 +88,7 @@ extern int build_PS_PES_reader(PS_reader_p ps, extern int build_TS_PES_reader(TS_reader_p tsreader, int give_info, int give_warnings, - u_int16 program_number, + uint16_t program_number, PES_reader_p *reader); /* * Build a PES reader datastructure @@ -110,7 +110,7 @@ extern int build_PES_reader(int input, int is_TS, int give_info, int give_warnings, - u_int16 program_number, + uint16_t program_number, PES_reader_p *reader); /* * Open a Transport Stream file for PES packet reading @@ -130,7 +130,7 @@ extern int build_PES_reader(int input, * Returns 0 if all goes well, 1 if something goes wrong. */ extern int open_PES_reader_for_TS(char *filename, - u_int16 program_number, + uint16_t program_number, int give_info, int give_warnings, PES_reader_p *reader); @@ -236,11 +236,11 @@ extern void set_PES_reader_audio_private1(PES_reader_p reader); * be the same as the `video_pid` */ extern void set_PES_reader_program_data(PES_reader_p reader, - u_int16 program_number, - u_int32 pmt_pid, - u_int32 video_pid, - u_int32 audio_pid, - u_int32 pcr_pid); + uint16_t program_number, + uint32_t pmt_pid, + uint32_t video_pid, + uint32_t audio_pid, + uint32_t pcr_pid); /* * Tell the PES reader that the PS data it is reading is MPEG-4/AVC, * as opposed to MPEG-1/MPEG-2. @@ -351,9 +351,9 @@ extern int read_next_PES_ES_packet(PES_reader_p reader); * Returns 0 if all went well, 1 if an error occurs. */ extern int find_PTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_pts, - u_int64 *pts); + uint64_t *pts); /* * If the given PES packet data contains a DTS field, return it * @@ -365,9 +365,9 @@ extern int find_PTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_DTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_dts, - u_int64 *dts); + uint64_t *dts); /* * If the given PES packet data contains a PTS and/or DTS field, return it * @@ -381,11 +381,11 @@ extern int find_DTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_PTS_DTS_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_pts, - u_int64 *pts, + uint64_t *pts, int *got_dts, - u_int64 *dts); + uint64_t *dts); /* * If the given PES packet data contains an ESCR field, return it * @@ -397,9 +397,9 @@ extern int find_PTS_DTS_in_PES(byte data[], * Returns 0 if all went well, 1 if an error occurs. */ extern int find_ESCR_in_PES(byte data[], - int32 data_len, + int32_t data_len, int *got_escr, - u_int64 *escr); + uint64_t *escr); /* * Decode a PTS or DTS value. * @@ -412,7 +412,7 @@ extern int find_ESCR_in_PES(byte data[], */ extern int decode_pts_dts(byte data[], int required_guard, - u_int64 *value); + uint64_t *value); /* * Encode a PTS or DTS. * @@ -423,7 +423,7 @@ extern int decode_pts_dts(byte data[], */ extern void encode_pts_dts(byte data[], int guard_bits, - u_int64 value); + uint64_t value); /* * Does the given PES packet contain a PTS? * diff --git a/pidint.c b/pidint.c index 7b9bbdd..a7ac51e 100644 --- a/pidint.c +++ b/pidint.c @@ -52,7 +52,7 @@ extern int init_pidint_list(pidint_list_p list) fprintf(stderr,"### Unable to allocate array in program list datastructure\n"); return 1; } - list->pid = malloc(sizeof(u_int32)*PIDINT_LIST_START_SIZE); + list->pid = malloc(sizeof(uint32_t)*PIDINT_LIST_START_SIZE); if (list->pid == NULL) { free(list->number); @@ -90,7 +90,7 @@ extern int build_pidint_list(pidint_list_p *list) * Returns 0 if it succeeds, 1 if some error occurs. */ extern int append_to_pidint_list(pidint_list_p list, - u_int32 pid, + uint32_t pid, int program) { if (list == NULL) @@ -108,7 +108,7 @@ extern int append_to_pidint_list(pidint_list_p list, fprintf(stderr,"### Unable to extend pid/int list array\n"); return 1; } - list->pid = realloc(list->pid,newsize*sizeof(u_int32)); + list->pid = realloc(list->pid,newsize*sizeof(uint32_t)); if (list->pid == NULL) { fprintf(stderr,"### Unable to extend pid/int list array\n"); @@ -128,7 +128,7 @@ extern int append_to_pidint_list(pidint_list_p list, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remove_from_pidint_list(pidint_list_p list, - u_int32 pid) + uint32_t pid) { int index; int ii; @@ -220,7 +220,7 @@ extern void report_pidint_list(pidint_list_p list, * Returns its index (0 or more) if the PID is in the list, -1 if it is not. */ extern int pid_index_in_pidint_list(pidint_list_p list, - u_int32 pid) + uint32_t pid) { int ii; if (list == NULL) @@ -239,7 +239,7 @@ extern int pid_index_in_pidint_list(pidint_list_p list, * Returns 0 if the PID is in the list, -1 if it is not. */ extern int pid_int_in_pidint_list(pidint_list_p list, - u_int32 pid, + uint32_t pid, int *number) { int ii; @@ -266,7 +266,7 @@ extern int pid_int_in_pidint_list(pidint_list_p list, * Returns TRUE if the PID is in the list, FALSE if it is not. */ extern int pid_in_pidint_list(pidint_list_p list, - u_int32 pid) + uint32_t pid) { return pid_index_in_pidint_list(list,pid) != -1; } @@ -294,8 +294,8 @@ extern int same_pidint_list(pidint_list_p list1, return FALSE; for (ii = 0; ii < list1->length; ii++) { - u_int32 pid = list1->pid[ii]; - int idx = pid_index_in_pidint_list(list2,pid); + uint32_t pid = list1->pid[ii]; + int idx = pid_index_in_pidint_list(list2,pid); if (idx == -1) return FALSE; else if (list1->number[ii] != list2->number[idx]) @@ -365,8 +365,8 @@ static int init_pmt_streams(pmt_p pmt) * Returns (a pointer to) the new PMT datastructure, or NULL if some error * occurs. */ -extern pmt_p build_pmt(u_int16 program_number, byte version_number, - u_int32 PCR_pid) +extern pmt_p build_pmt(uint16_t program_number, byte version_number, + uint32_t PCR_pid) { pmt_p new; @@ -417,7 +417,7 @@ extern pmt_p build_pmt(u_int16 program_number, byte version_number, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int set_pmt_program_info(pmt_p pmt, - u_int16 program_info_length, + uint16_t program_info_length, byte *program_info) { if (program_info_length > PMT_MAX_INFO_LENGTH) @@ -458,9 +458,9 @@ extern int set_pmt_program_info(pmt_p pmt, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int add_stream_to_pmt(pmt_p pmt, - u_int32 elementary_PID, + uint32_t elementary_PID, byte stream_type, - u_int16 ES_info_length, + uint16_t ES_info_length, byte *ES_info) { if (pmt == NULL) @@ -533,7 +533,7 @@ static void free_pmt_stream(pmt_stream_p stream) * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remove_stream_from_pmt(pmt_p pmt, - u_int32 pid) + uint32_t pid) { int index; int ii; @@ -596,7 +596,7 @@ extern void free_pmt(pmt_p *pmt) * Returns its index (0 or more) if the PID is in the list, -1 if it is not. */ extern int pid_index_in_pmt(pmt_p pmt, - u_int32 pid) + uint32_t pid) { int ii; if (pmt == NULL) @@ -616,7 +616,7 @@ extern int pid_index_in_pmt(pmt_p pmt, * NULL if it is not. */ extern pmt_stream_p pid_stream_in_pmt(pmt_p pmt, - u_int32 pid) + uint32_t pid) { int ii; if (pmt == NULL) @@ -637,7 +637,7 @@ extern pmt_stream_p pid_stream_in_pmt(pmt_p pmt, * Returns TRUE if the PID is in the PMT's stream list, FALSE if it is not. */ extern int pid_in_pmt(pmt_p pmt, - u_int32 pid) + uint32_t pid) { return pid_index_in_pmt(pmt,pid) != -1; } @@ -700,8 +700,8 @@ extern int same_pmt(pmt_p pmt1, for (ii = 0; ii < pmt1->num_streams; ii++) { - u_int32 pid = pmt1->streams[ii].elementary_PID; - int idx = pid_index_in_pmt(pmt2,pid); + uint32_t pid = pmt1->streams[ii].elementary_PID; + int idx = pid_index_in_pmt(pmt2,pid); if (idx == -1) return FALSE; else if (!same_pmt_stream(&pmt1->streams[ii],&pmt2->streams[idx])) diff --git a/pidint_defns.h b/pidint_defns.h index 45987ec..8c42408 100644 --- a/pidint_defns.h +++ b/pidint_defns.h @@ -41,10 +41,10 @@ // An expandable list of PID vs. integer struct pidint_list { - int *number; // The integers - u_int32 *pid; // The corresponding PIDs - int length; // How many there are - int size; // How big the arrays are + int *number; // The integers + uint32_t *pid; // The corresponding PIDs + int length; // How many there are + int size; // How big the arrays are }; typedef struct pidint_list *pidint_list_p; #define SIZEOF_PIDINT_LIST sizeof(struct pidint_list) @@ -58,8 +58,8 @@ typedef struct pidint_list *pidint_list_p; struct _pmt_stream { byte stream_type; - u_int32 elementary_PID; - u_int16 ES_info_length; + uint32_t elementary_PID; + uint16_t ES_info_length; byte *ES_info; // the descriptor data therefor }; typedef struct _pmt_stream *pmt_stream_p; @@ -67,10 +67,10 @@ typedef struct _pmt_stream *pmt_stream_p; struct _pmt { - u_int16 program_number; + uint16_t program_number; byte version_number; // perhaps not strictly necessary - u_int32 PCR_pid; - u_int16 program_info_length; + uint32_t PCR_pid; + uint16_t program_info_length; byte *program_info; // the descriptor data therefor int streams_size; // the size of the `streams` array int num_streams; // the number of streams we know about diff --git a/pidint_fns.h b/pidint_fns.h index a1d5957..4b8d253 100644 --- a/pidint_fns.h +++ b/pidint_fns.h @@ -50,7 +50,7 @@ extern int build_pidint_list(pidint_list_p *list); * Returns 0 if it succeeds, 1 if some error occurs. */ extern int append_to_pidint_list(pidint_list_p list, - u_int32 pid, + uint32_t pid, int program); /* * Remove a pid/integer pair from the list @@ -58,7 +58,7 @@ extern int append_to_pidint_list(pidint_list_p list, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remove_from_pidint_list(pidint_list_p list, - u_int32 pid); + uint32_t pid); /* * Tidy up and free a pid/int list datastructure after we've finished with it * @@ -80,7 +80,7 @@ extern void report_pidint_list(pidint_list_p list, * Returns 0 if the PID is in the list, -1 if it is not. */ extern int pid_int_in_pidint_list(pidint_list_p list, - u_int32 pid, + uint32_t pid, int *number); /* * Lookup a PID to find its index in a pid/int list. @@ -92,7 +92,7 @@ extern int pid_int_in_pidint_list(pidint_list_p list, * Returns its index (0 or more) if the PID is in the list, -1 if it is not. */ extern int pid_index_in_pidint_list(pidint_list_p list, - u_int32 pid); + uint32_t pid); /* * Lookup a PID to see if it is in a pid/int list. * @@ -103,7 +103,7 @@ extern int pid_index_in_pidint_list(pidint_list_p list, * Returns TRUE if the PID is in the list, FALSE if it is not. */ extern int pid_in_pidint_list(pidint_list_p list, - u_int32 pid); + uint32_t pid); /* * Check if two pid/int lists have the same content. * @@ -143,8 +143,8 @@ extern void report_stream_list(pidint_list_p list, * Returns (a pointer to) the new PMT datastructure, or NULL if some error * occurs. */ -extern pmt_p build_pmt(u_int16 program_number, byte version_number, - u_int32 PCR_pid); +extern pmt_p build_pmt(uint16_t program_number, byte version_number, + uint32_t PCR_pid); /* * Set the descriptor data on a PMT. Specifically, 'program info', * the descriptor data in the PMT "as a whole". @@ -156,7 +156,7 @@ extern pmt_p build_pmt(u_int16 program_number, byte version_number, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int set_pmt_program_info(pmt_p pmt, - u_int16 program_info_length, + uint16_t program_info_length, byte *program_info); /* * Add a program stream to a PMT datastructure @@ -166,9 +166,9 @@ extern int set_pmt_program_info(pmt_p pmt, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int add_stream_to_pmt(pmt_p pmt, - u_int32 elementary_PID, + uint32_t elementary_PID, byte stream_type, - u_int16 ES_info_length, + uint16_t ES_info_length, byte *ES_info); /* * Remove a program stream from a PMT. @@ -176,7 +176,7 @@ extern int add_stream_to_pmt(pmt_p pmt, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remove_stream_from_pmt(pmt_p pmt, - u_int32 pid); + uint32_t pid); /* * Tidy up and free a PMT datastructure after we've finished with it * @@ -193,7 +193,7 @@ extern void free_pmt(pmt_p *pmt); * Returns its index (0 or more) if the PID is in the list, -1 if it is not. */ extern int pid_index_in_pmt(pmt_p pmt, - u_int32 pid); + uint32_t pid); /* * Lookup a PID to find the corresponding program stream information. * @@ -201,7 +201,7 @@ extern int pid_index_in_pmt(pmt_p pmt, * NULL if it is not. */ extern pmt_stream_p pid_stream_in_pmt(pmt_p pmt, - u_int32 pid); + uint32_t pid); /* * Lookup a PID to see if it is in a PMT datastructure. * @@ -210,7 +210,7 @@ extern pmt_stream_p pid_stream_in_pmt(pmt_p pmt, * Returns TRUE if the PID is in the PMT's stream list, FALSE if it is not. */ extern int pid_in_pmt(pmt_p pmt, - u_int32 pid); + uint32_t pid); /* * Check if two PMT datastructures have the same content. * diff --git a/ps.c b/ps.c index 9275815..e88caca 100644 --- a/ps.c +++ b/ps.c @@ -67,12 +67,12 @@ struct program_data { // Information supplied by the user - u_int32 transport_stream_id; - u_int32 program_number; - u_int32 pmt_pid; // PID to use for the PMT - u_int32 pcr_pid; // PID to use for the PCR - u_int32 video_pid; // PID to use for our single stream of video - u_int32 audio_pid; // PID to use for our single stream of audio + uint32_t transport_stream_id; + uint32_t program_number; + uint32_t pmt_pid; // PID to use for the PMT + uint32_t pcr_pid; // PID to use for the PCR + uint32_t video_pid; // PID to use for our single stream of video + uint32_t audio_pid; // PID to use for our single stream of audio int video_stream; // Which stream id our video is (-1 means use first) int audio_stream; // Which stream id our audio is (-1 means use first) int want_ac3; // True means audio_stream is private_1/AC3 substream @@ -512,7 +512,7 @@ extern void print_stream_id(FILE *stream, */ extern int find_PS_packet_start(PS_reader_p ps, int verbose, - u_int32 max, + uint32_t max, offset_t *posn, byte *stream_id) { @@ -520,7 +520,7 @@ extern int find_PS_packet_start(PS_reader_p ps, byte prev1 = 0xff; byte prev2 = 0xff; byte prev3 = 0xff; - u_int32 count = 0; + uint32_t count = 0; *stream_id = 0; for (;;) @@ -589,7 +589,7 @@ extern int find_PS_packet_start(PS_reader_p ps, */ extern int find_PS_pack_header_start(PS_reader_p ps, int verbose, - u_int32 max, + uint32_t max, offset_t *posn) { int err; @@ -750,15 +750,15 @@ extern int read_PS_pack_header_body(PS_reader_p ps, #endif hdr->pack_stuffing_length = 0; // since it doesn't exist hdr->scr = - (((u_int64)(hdr->data[0] & 0x09)) << 29) | - (((u_int64) hdr->data[1] ) << 22) | - (((u_int64)(hdr->data[2] & 0xFE)) << 14) | - (((u_int64) hdr->data[3] ) << 7) | - (((u_int64)(hdr->data[4] & 0xFE)) >> 1); + (((uint64_t)(hdr->data[0] & 0x09)) << 29) | + (((uint64_t) hdr->data[1] ) << 22) | + (((uint64_t)(hdr->data[2] & 0xFE)) << 14) | + (((uint64_t) hdr->data[3] ) << 7) | + (((uint64_t)(hdr->data[4] & 0xFE)) >> 1); hdr->program_mux_rate = - (((u_int32)(hdr->data[5] & 0x7F)) << 15) | - (((u_int32) hdr->data[6] ) << 7) | - (((u_int32)(hdr->data[7] & 0xFE)) >> 1); + (((uint32_t)(hdr->data[5] & 0x7F)) << 15) | + (((uint32_t) hdr->data[6] ) << 7) | + (((uint32_t)(hdr->data[7] & 0xFE)) >> 1); // In MPEG-1, SCR = NINT(SysClockFreq * t[i]) % 2**33 // where SysClockFreq = 90,000 Hz // @@ -787,21 +787,21 @@ extern int read_PS_pack_header_body(PS_reader_p ps, print_data(stdout,"Pack header",hdr->data,10,10); #endif hdr->scr_base = - (((u_int64)(hdr->data[0] & 0x38)) << 27) | - (((u_int64)(hdr->data[0] & 0x03)) << 28) | - (((u_int64) hdr->data[1] ) << 20) | - (((u_int64)(hdr->data[2] & 0xF8)) << 12) | - (((u_int64)(hdr->data[2] & 0x03)) << 13) | - (((u_int64) hdr->data[3] ) << 5) | - (((u_int64)(hdr->data[4] & 0xF8)) >> 3); + (((uint64_t)(hdr->data[0] & 0x38)) << 27) | + (((uint64_t)(hdr->data[0] & 0x03)) << 28) | + (((uint64_t) hdr->data[1] ) << 20) | + (((uint64_t)(hdr->data[2] & 0xF8)) << 12) | + (((uint64_t)(hdr->data[2] & 0x03)) << 13) | + (((uint64_t) hdr->data[3] ) << 5) | + (((uint64_t)(hdr->data[4] & 0xF8)) >> 3); hdr->scr_extn = - (((u_int32)(hdr->data[4] & 0x03)) << 7) | - (((u_int32) hdr->data[5] ) >> 1); + (((uint32_t)(hdr->data[4] & 0x03)) << 7) | + (((uint32_t) hdr->data[5] ) >> 1); hdr->scr = hdr->scr_base * 300 + hdr->scr_extn; hdr->program_mux_rate = - (((u_int32)hdr->data[6] << 14)) | - (((u_int32)hdr->data[7] << 6)) | - (((u_int32)hdr->data[8] >> 2)); + (((uint32_t)hdr->data[6] << 14)) | + (((uint32_t)hdr->data[7] << 6)) | + (((uint32_t)hdr->data[8] >> 2)); hdr->pack_stuffing_length = hdr->data[9] & 0x07; } @@ -1287,7 +1287,7 @@ static int write_DVD_AC3_data(TS_writer_p output, // If there is no PTS in this packet, do we need to split, even // if the offset is > 1? I'll assume not... int got_pts; - u_int64 pts; + uint64_t pts; int PES_packet_length = (packet->data[4] << 8) | packet->data[5]; int err = find_PTS_in_PES(packet->data,packet->data_len,&got_pts,&pts); @@ -1461,8 +1461,8 @@ static int write_audio(TS_writer_p output, if (!quiet) { #define MAX_IGNORED_NON_AC3 10 // report the first 10 substreams we're ignoring - static u_int32 ignored_non_AC3[MAX_IGNORED_NON_AC3] = {0}; - u_int32 lookfor = (what << 16) | substream_index; + static uint32_t ignored_non_AC3[MAX_IGNORED_NON_AC3] = {0}; + uint32_t lookfor = (what << 16) | substream_index; int ii; for (ii = 0; ii < MAX_IGNORED_NON_AC3; ii++) { @@ -1894,11 +1894,11 @@ extern int ps_to_ts(PS_reader_p ps, int audio_stream, int want_ac3_audio, int output_dolby_as_dvb, - u_int32 pmt_pid, - u_int32 pcr_pid, - u_int32 video_pid, + uint32_t pmt_pid, + uint32_t pcr_pid, + uint32_t video_pid, int keep_audio, - u_int32 audio_pid, + uint32_t audio_pid, int max, int verbose, int quiet) diff --git a/ps2ts.c b/ps2ts.c index 477c561..874fded 100644 --- a/ps2ts.c +++ b/ps2ts.c @@ -172,10 +172,10 @@ int main(int argc, char **argv) int verbose = FALSE; int quiet = FALSE; int max = 0; - u_int32 pmt_pid = 0x66; - u_int32 video_pid = 0x68; - u_int32 pcr_pid = video_pid; // Use PCRs from the video stream - u_int32 audio_pid = 0x67; + uint32_t pmt_pid = 0x66; + uint32_t video_pid = 0x68; + uint32_t pcr_pid = video_pid; // Use PCRs from the video stream + uint32_t audio_pid = 0x67; int keep_audio = TRUE; int repeat_program_every = 100; int pad_start = 8; diff --git a/ps_defns.h b/ps_defns.h index 7328bf6..5b1f049 100644 --- a/ps_defns.h +++ b/ps_defns.h @@ -46,7 +46,7 @@ struct ps_reader byte data[PS_READ_AHEAD_SIZE]; offset_t data_posn; // location of this data in the file - int32 data_len; // actual number of bytes in the buffer + int32_t data_len; // actual number of bytes in the buffer byte *data_end; // off the end of `data` byte *data_ptr; // which byte we're interested in (next) }; @@ -59,10 +59,10 @@ struct PS_pack_header { int id; // A number to identify this packet byte data[10]; // The data excluding the leading 00 00 01 BA - u_int64 scr; // Formed from scr_base and scr_ext - u_int64 scr_base; - u_int32 scr_extn; - u_int32 program_mux_rate; + uint64_t scr; // Formed from scr_base and scr_ext + uint64_t scr_base; + uint32_t scr_extn; + uint32_t program_mux_rate; int pack_stuffing_length; }; typedef struct PS_pack_header *PS_pack_header_p; diff --git a/ps_fns.h b/ps_fns.h index 13c888f..2854d18 100644 --- a/ps_fns.h +++ b/ps_fns.h @@ -164,7 +164,7 @@ extern void print_stream_id(FILE *stream, */ extern int find_PS_packet_start(PS_reader_p ps, int verbose, - u_int32 max, + uint32_t max, offset_t *posn, byte *stream_id); /* @@ -192,7 +192,7 @@ extern int find_PS_packet_start(PS_reader_p ps, */ extern int find_PS_pack_header_start(PS_reader_p ps, int verbose, - u_int32 max, + uint32_t max, offset_t *posn); /* * Read in (the rest of) a PS packet according to its length. @@ -339,11 +339,11 @@ extern int ps_to_ts(PS_reader_p ps, int audio_stream, int want_ac3_audio, int dolby_is_dvb, - u_int32 pmt_pid, - u_int32 pcr_pid, - u_int32 video_pid, + uint32_t pmt_pid, + uint32_t pcr_pid, + uint32_t video_pid, int keep_audio, - u_int32 audio_pid, + uint32_t audio_pid, int max, int verbose, int quiet); diff --git a/reverse.c b/reverse.c index e898017..144265f 100644 --- a/reverse.c +++ b/reverse.c @@ -111,7 +111,7 @@ extern int build_reverse_data(reverse_data_p *reverse_data, return 1; } - new->start_pkt = malloc(newsize*sizeof(int32)); + new->start_pkt = malloc(newsize*sizeof(int32_t)); if (new->start_pkt == NULL) { fprintf(stderr,"### Unable to allocate reverse data array (start_pkt)\n"); @@ -120,7 +120,7 @@ extern int build_reverse_data(reverse_data_p *reverse_data, return 1; } - new->index = malloc(newsize*sizeof(u_int32)); + new->index = malloc(newsize*sizeof(uint32_t)); if (new->index == NULL) { fprintf(stderr,"### Unable to allocate reverse data array (index)\n"); @@ -129,7 +129,7 @@ extern int build_reverse_data(reverse_data_p *reverse_data, free(new); return 1; } - new->data_len = malloc(newsize*sizeof(int32)); + new->data_len = malloc(newsize*sizeof(int32_t)); if (new->data_len == NULL) { fprintf(stderr,"### Unable to allocate reverse data array (data_len)\n"); @@ -200,7 +200,7 @@ extern int build_reverse_data(reverse_data_p *reverse_data, * DEFAULT_VIDEO_STREAM_ID) are not correct. */ extern void set_reverse_pid(reverse_data_p reverse_data, - u_int32 pid, + uint32_t pid, byte stream_id) { reverse_data->pid = pid; @@ -288,7 +288,7 @@ extern void free_reverse_data(reverse_data_p *reverse_data) */ static inline int cmp_offsets(ES_offset offset1, offset_t file_posn2, - int32 pkt_posn2) + int32_t pkt_posn2) { if (offset1.infile < file_posn2) return -1; @@ -303,9 +303,9 @@ static inline int cmp_offsets(ES_offset offset1, } static void debug_reverse_data_problem(reverse_data_p reverse_data, - u_int32 index, + uint32_t index, ES_offset start_posn, - u_int32 idx) + uint32_t idx) { FILE *tempfile; char *tempfilename = "tsserve_reverse_problem.txt"; @@ -373,14 +373,14 @@ static void debug_reverse_data_problem(reverse_data_p reverse_data, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_reverse_h262_data(reverse_data_p reverse_data, - u_int32 index, + uint32_t index, ES_offset start_posn, - u_int32 length, + uint32_t length, byte seq_offset, byte afd) { if (reverse_data->length > 0 && - (reverse_data->last_posn_added + 1) < (u_int32)reverse_data->length) + (reverse_data->last_posn_added + 1) < (uint32_t)reverse_data->length) { // We're repeating an entry we previously added - check it hasn't // changed (since the only obvious way for this to have happened @@ -416,7 +416,7 @@ extern int remember_reverse_h262_data(reverse_data_p reverse_data, { int newsize = reverse_data->size + REVERSE_ARRAY_INCREMENT_SIZE; reverse_data->index = realloc(reverse_data->index, - newsize*sizeof(u_int32)); + newsize*sizeof(uint32_t)); if (reverse_data->index == NULL) { fprintf(stderr,"### Unable to extend reverse data array (index)\n"); @@ -430,14 +430,14 @@ extern int remember_reverse_h262_data(reverse_data_p reverse_data, return 1; } reverse_data->start_pkt = realloc(reverse_data->start_pkt, - newsize*sizeof(int32)); + newsize*sizeof(int32_t)); if (reverse_data->start_pkt == NULL) { fprintf(stderr,"### Unable to extend reverse data array (start_pkt)\n"); return 1; } reverse_data->data_len = realloc(reverse_data->data_len, - newsize*sizeof(int32)); + newsize*sizeof(int32_t)); if (reverse_data->data_len == NULL) { fprintf(stderr,"### Unable to extend reverse data array (length)\n"); @@ -502,12 +502,12 @@ extern int remember_reverse_h262_data(reverse_data_p reverse_data, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_reverse_h264_data(reverse_data_p reverse_data, - u_int32 index, + uint32_t index, ES_offset start_posn, - u_int32 length) + uint32_t length) { if (reverse_data->length > 0 && - (reverse_data->last_posn_added + 1) < (u_int32)reverse_data->length) + (reverse_data->last_posn_added + 1) < (uint32_t)reverse_data->length) { // We're repeating an entry we previously added - check it hasn't // changed (since the only obvious way for this to have happened @@ -543,7 +543,7 @@ extern int remember_reverse_h264_data(reverse_data_p reverse_data, { int newsize = reverse_data->size + REVERSE_ARRAY_INCREMENT_SIZE; reverse_data->index = realloc(reverse_data->index, - newsize*sizeof(u_int32)); + newsize*sizeof(uint32_t)); if (reverse_data->index == NULL) { fprintf(stderr,"### Unable to extend reverse data array (index)\n"); @@ -557,14 +557,14 @@ extern int remember_reverse_h264_data(reverse_data_p reverse_data, return 1; } reverse_data->start_pkt = realloc(reverse_data->start_pkt, - newsize*sizeof(int32)); + newsize*sizeof(int32_t)); if (reverse_data->start_pkt == NULL) { fprintf(stderr,"### Unable to extend reverse data array (start_pkt)\n"); return 1; } reverse_data->data_len = realloc(reverse_data->data_len, - newsize*sizeof(int32)); + newsize*sizeof(int32_t)); if (reverse_data->data_len == NULL) { fprintf(stderr,"### Unable to extend reverse data array (length)\n"); @@ -617,9 +617,9 @@ extern int remember_reverse_h264_data(reverse_data_p reverse_data, */ extern int get_reverse_data(reverse_data_p reverse_data, int which, - u_int32 *index, + uint32_t *index, ES_offset *start_posn, - u_int32 *length, + uint32_t *length, byte *seq_offset, byte *afd) { @@ -797,7 +797,7 @@ extern int write_packet_data(WRITER output, int as_TS, byte data[], int data_len, - u_int32 pid, + uint32_t pid, byte stream_id) { int err; @@ -838,7 +838,7 @@ extern int write_packet_data(WRITER output, static int write_picture_data(WRITER output, int as_TS, h262_picture_p picture, - u_int32 pid) + uint32_t pid) { int err; if (as_TS) @@ -928,12 +928,12 @@ static int output_sequence_header(ES_p es, WRITER output, int as_TS, int verbose, - u_int16 seq_index, + uint16_t seq_index, reverse_data_p reverse_data) { int err; ES_offset seq_posn; - u_int32 seq_len; + uint32_t seq_len; byte *seq_data = NULL; err = get_reverse_data(reverse_data,seq_index,NULL,&seq_posn,&seq_len, NULL,NULL); @@ -993,20 +993,20 @@ static int output_from_reverse_data(ES_p es, int as_TS, int verbose, int quiet, - u_int32 offset, + uint32_t offset, reverse_data_p reverse_data) { int with_sequence_headers = (!reverse_data->is_h264 && reverse_data->output_sequence_headers); - u_int32 which = reverse_data->length - 1; // the maximum picture index + uint32_t which = reverse_data->length - 1; // the maximum picture index int is_h262 = !reverse_data->is_h264; int err; - u_int32 index; + uint32_t index; ES_offset start_posn; - u_int32 num_bytes; + uint32_t num_bytes; byte seq_offset; byte afd; - u_int32 uu; + uint32_t uu; if (verbose) printf("\nGOING BACK: offset %u, max pic index %u\n",offset,which); @@ -1048,7 +1048,7 @@ static int output_from_reverse_data(ES_p es, if (with_sequence_headers) { // Make sure we've output its sequence header - err = output_sequence_header(es,output,as_TS,verbose,(u_int16)(which - seq_offset), + err = output_sequence_header(es,output,as_TS,verbose,(uint16_t)(which - seq_offset), reverse_data); if (err) { @@ -1082,7 +1082,7 @@ static int output_from_reverse_data(ES_p es, else { byte *data = NULL; - u_int32 data_len = 0; + uint32_t data_len = 0; err = read_ES_data(es,start_posn,num_bytes,&data_len,&data); if (err) { @@ -1143,7 +1143,7 @@ extern int output_from_reverse_data_as_TS(ES_p es, TS_writer_p tswriter, int verbose, int quiet, - u_int32 offset, + uint32_t offset, reverse_data_p reverse_data) { WRITER writer; @@ -1178,7 +1178,7 @@ extern int output_from_reverse_data_as_ES(ES_p es, FILE *output, int verbose, int quiet, - u_int32 offset, + uint32_t offset, reverse_data_p reverse_data) { WRITER writer; @@ -1218,25 +1218,25 @@ static int output_in_reverse(ES_p es, int frequency, int verbose, int quiet, - int32 start_with, + int32_t start_with, int max, reverse_data_p reverse_data) { int ii; int with_sequence_headers = reverse_data->output_sequence_headers; byte *data = NULL; // picture data, as a "chunk" - u_int32 data_len = 0; // the current size of `data` + uint32_t data_len = 0; // the current size of `data` h262_picture_p picture = NULL; // H.262 picture data as a "picture" - u_int32 last_seq_index = reverse_data->length; // impossible value + uint32_t last_seq_index = reverse_data->length; // impossible value int max_pic_index = reverse_data->length-1; int first_actual_picture_index = 0; // the first *actual* picture int is_h262 = !reverse_data->is_h264; - u_int32 start_index; - u_int32 final_index; - u_int32 last_index; + uint32_t start_index; + uint32_t final_index; + uint32_t last_index; - u_int32 last_num_bytes = 0; // Number of bytes of last picture written + uint32_t last_num_bytes = 0; // Number of bytes of last picture written reverse_data->pictures_written = 0; reverse_data->pictures_kept = 0; @@ -1271,7 +1271,7 @@ static int output_in_reverse(ES_p es, start_index --; // If that means there's nothing to output, then so be it - if (start_index < (u_int32)first_actual_picture_index) + if (start_index < (uint32_t)first_actual_picture_index) return 0; // Remember the index of the latest picture we're interested in @@ -1300,12 +1300,12 @@ static int output_in_reverse(ES_p es, { int err; int keep = FALSE; - u_int32 index; + uint32_t index; ES_offset start_posn; - u_int32 num_bytes; + uint32_t num_bytes; byte seq_offset; byte afd; - u_int32 seq_index; + uint32_t seq_index; if (as_TS && tswrite_command_changed(output.ts_output)) { @@ -1411,7 +1411,7 @@ static int output_in_reverse(ES_p es, seq_index = ii - seq_offset; if (seq_index != last_seq_index) { - err = output_sequence_header(es,output,as_TS,verbose,(u_int16)seq_index, + err = output_sequence_header(es,output,as_TS,verbose,(uint16_t)seq_index, reverse_data); if (err) { @@ -1540,7 +1540,7 @@ extern int output_in_reverse_as_TS(ES_p es, int frequency, int verbose, int quiet, - int32 start_with, + int32_t start_with, int max, reverse_data_p reverse_data) { @@ -1581,7 +1581,7 @@ extern int output_in_reverse_as_ES(ES_p es, int frequency, int verbose, int quiet, - int32 start_with, + int32_t start_with, int max, reverse_data_p reverse_data) { diff --git a/reverse_defns.h b/reverse_defns.h index 071086a..b30def9 100644 --- a/reverse_defns.h +++ b/reverse_defns.h @@ -56,12 +56,12 @@ struct reverse_data // for H.262 data, and FALSE for H.264 (MPEG-4/AVC) int length; // Number of items in our arrays int size; // How big our arrays are - u_int32 num_pictures; // How many pictures we have + uint32_t num_pictures; // How many pictures we have // Four useful arrays (although the last is not used for H.264 data) - u_int32 *index; // Which picture this is, counted from the start + uint32_t *index; // Which picture this is, counted from the start offset_t *start_file; // The start offset of an item in the input file - int32 *start_pkt; // and then within the PES packet (if needed) - int32 *data_len; // Its length in bytes + int32_t *start_pkt; // and then within the PES packet (if needed) + int32_t *data_len; // Its length in bytes byte *seq_offset; // For MPEG-2, the offset backwards in the arrays // to the nearest earlier sequence header, or 0 @@ -94,7 +94,7 @@ struct reverse_data // like the highwater mark for what we've played forwards since we last // started playing forwards again, but I can't think of anything startlingly // illustrative, so this name will stay for now.) - u_int32 last_posn_added; + uint32_t last_posn_added; // Do we want to output sequence headers or not, when reversing H.262? int output_sequence_headers; @@ -102,7 +102,7 @@ struct reverse_data // If we're outputting TS packets, we need to know the PID and stream id // to use. We *could* pass that down to each reverse call, but it's easier // to set it once and for all. - u_int32 pid; + uint32_t pid; byte stream_id; // When a function (output_in_reverse_as_XX) is called to output diff --git a/reverse_fns.h b/reverse_fns.h index ccb6e8f..3842480 100644 --- a/reverse_fns.h +++ b/reverse_fns.h @@ -58,7 +58,7 @@ extern int build_reverse_data(reverse_data_p *reverse_data, * DEFAULT_VIDEO_STREAM_ID) are not correct. */ extern void set_reverse_pid(reverse_data_p reverse_data, - u_int32 pid, + uint32_t pid, byte stream_id); /* * Add a reversing context to an H.262 context (and vice versa). @@ -104,9 +104,9 @@ extern void free_reverse_data(reverse_data_p *reverse_data); * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_reverse_h262_data(reverse_data_p reverse_data, - u_int32 index, + uint32_t index, ES_offset start_posn, - u_int32 length, + uint32_t length, byte seq_offset, byte afd); /* @@ -124,9 +124,9 @@ extern int remember_reverse_h262_data(reverse_data_p reverse_data, * Returns 0 if it succeeds, 1 if some error occurs. */ extern int remember_reverse_h264_data(reverse_data_p reverse_data, - u_int32 index, + uint32_t index, ES_offset start_posn, - u_int32 length); + uint32_t length); /* * Retrieve video sequence bounds for entry `which` * @@ -159,9 +159,9 @@ extern int remember_reverse_h264_data(reverse_data_p reverse_data, */ extern int get_reverse_data(reverse_data_p reverse_data, int which, - u_int32 *index, + uint32_t *index, ES_offset *start_posn, - u_int32 *length, + uint32_t *length, byte *seq_offset, byte *afd); @@ -231,7 +231,7 @@ extern int output_from_reverse_data_as_TS(ES_p es, TS_writer_p tswriter, int verbose, int quiet, - u_int32 offset, + uint32_t offset, reverse_data_p reverse_data); /* * Output the last picture (or an earlier one) from the reverse arrays. @@ -259,7 +259,7 @@ extern int output_from_reverse_data_as_ES(ES_p es, FILE *output, int verbose, int quiet, - u_int32 offset, + uint32_t offset, reverse_data_p reverse_data); /* * Output the H.262 pictures or H.264 access units we remembered earlier - but @@ -292,7 +292,7 @@ extern int output_in_reverse_as_TS(ES_p es, int frequency, int verbose, int quiet, - int32 start_with, + int32_t start_with, int max, reverse_data_p reverse_data); /* @@ -326,7 +326,7 @@ extern int output_in_reverse_as_ES(ES_p es, int frequency, int verbose, int quiet, - int32 start_with, + int32_t start_with, int max, reverse_data_p reverse_data); diff --git a/test_pes.c b/test_pes.c index 57eb665..687007a 100644 --- a/test_pes.c +++ b/test_pes.c @@ -50,10 +50,10 @@ static int write_program_data_A(PES_reader_p reader, { // We know we support at most two program streams for output int num_progs = 0; - u_int32 prog_pids[2]; + uint32_t prog_pids[2]; byte prog_type[2]; int err; - u_int32 pcr_pid, pmt_pid; + uint32_t pcr_pid, pmt_pid; if (reader->is_TS) { @@ -204,7 +204,7 @@ static int test1(PES_reader_p reader, int ii; int err; byte *old_data; - u_int32 old_data_len; + uint32_t old_data_len; if (verbose) printf("-------------------------- Test 1 --------------------------\n"); diff --git a/ts.c b/ts.c index 7662c7d..13d7e79 100644 --- a/ts.c +++ b/ts.c @@ -68,9 +68,9 @@ static int continuity_counter[0x1fff+1] = {0}; /* * Return the next value of continuity_counter for the given pid */ -static inline int next_continuity_count(u_int32 pid) +static inline int next_continuity_count(uint32_t pid) { - u_int32 next = (continuity_counter[pid] + 1) & 0x0f; + uint32_t next = (continuity_counter[pid] + 1) & 0x0f; continuity_counter[pid] = next; return next; } @@ -98,12 +98,12 @@ static inline int next_continuity_count(u_int32 pid) * we're not yet outputting any timing information (PTS/DTS), and so * can get away with a minimal PES header). */ -extern void PES_header(u_int32 data_len, +extern void PES_header(uint32_t data_len, byte stream_id, int with_PTS, - u_int64 pts, + uint64_t pts, int with_DTS, - u_int64 dts, + uint64_t dts, byte *PES_hdr, int *PES_hdr_len) { @@ -229,9 +229,9 @@ static int write_TS_packet_parts(TS_writer_p output, int pes_hdr_len, byte data[], int data_len, - u_int32 pid, + uint32_t pid, int got_pcr, - u_int64 pcr) + uint64_t pcr) { int err; int total_len = TS_hdr_len + pes_hdr_len + data_len; @@ -289,23 +289,23 @@ static int write_some_TS_PES_packet(TS_writer_p output, byte *pes_hdr, int pes_hdr_len, byte *data, - u_int32 data_len, + uint32_t data_len, int start, int set_pusi, - u_int32 pid, + uint32_t pid, byte stream_id, int got_PCR, - u_int64 PCR_base, - u_int32 PCR_extn) + uint64_t PCR_base, + uint32_t PCR_extn) { #define DEBUG_THIS 0 byte TS_packet[TS_PACKET_SIZE]; int TS_hdr_len; - u_int32 controls = 0; - u_int32 pes_data_len = 0; + uint32_t controls = 0; + uint32_t pes_data_len = 0; int err; int got_adaptation_field = FALSE; - u_int32 space_left; // Bytes available for payload, after the TS header + uint32_t space_left; // Bytes available for payload, after the TS header if (pid < 0x0010 || pid > 0x1ffe) { @@ -483,8 +483,8 @@ static int write_some_TS_PES_packet(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id) { byte pes_hdr[TS_PACKET_SIZE]; // better be more than long enough! @@ -536,13 +536,13 @@ extern int write_ES_as_TS_PES_packet(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet_with_pts_dts(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts) + uint64_t dts) { byte pes_hdr[TS_PACKET_SIZE]; // better be more than long enough! int pes_hdr_len = 0; @@ -579,11 +579,11 @@ extern int write_ES_as_TS_PES_packet_with_pts_dts(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet_with_pcr(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, - u_int64 pcr_base, - u_int32 pcr_extn) + uint64_t pcr_base, + uint32_t pcr_extn) { byte pes_hdr[TS_PACKET_SIZE]; // better be more than long enough! int pes_hdr_len = 0; @@ -621,12 +621,12 @@ extern int write_ES_as_TS_PES_packet_with_pcr(TS_writer_p output, */ extern int write_PES_as_TS_PES_packet(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, int got_pcr, - u_int64 pcr_base, - u_int32 pcr_extn) + uint64_t pcr_base, + uint32_t pcr_extn) { // Should we write MPEG-1 packet data out as ES (wrapped in MPEG-2 PES in TS), // rather than writing the packets out directly in TS? (that latter doesn't @@ -655,7 +655,7 @@ extern int write_PES_as_TS_PES_packet(TS_writer_p output, { // Write MPEG-1 data out as ES in (MPEG-2) PES int got_pts, got_dts; - u_int64 pts, dts; + uint64_t pts, dts; int offset = calc_mpeg1_pes_offset(data,data_len); int err = find_PTS_DTS_in_PES(data,data_len, &got_pts,&pts,&got_dts,&dts); @@ -689,12 +689,12 @@ extern int write_PES_as_TS_PES_packet(TS_writer_p output, * * Returns 0 if it worked, 1 if something went wrong. */ -static int TS_program_packet_hdr(u_int32 pid, +static int TS_program_packet_hdr(uint32_t pid, int data_len, byte TS_hdr[TS_PACKET_SIZE], int *TS_hdr_len) { - u_int32 controls = 0; + uint32_t controls = 0; int pointer, ii; if (data_len > (TS_PACKET_SIZE - 5)) // i.e., 183 @@ -745,10 +745,10 @@ static int TS_program_packet_hdr(u_int32 pid, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_TS_program_data(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid, - u_int32 pid, + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid, + uint32_t pid, byte stream_type) { int err; @@ -765,7 +765,7 @@ extern int write_TS_program_data(TS_writer_p output, return 1; } - pmt = build_pmt((u_int16)program_number,0,pid); // Use program stream PID as PCR PID + pmt = build_pmt((uint16_t)program_number,0,pid); // Use program stream PID as PCR PID if (pmt == NULL) { free_pidint_list(&prog_list); @@ -809,12 +809,12 @@ extern int write_TS_program_data(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_TS_program_data2(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid, - u_int32 pcr_pid, + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid, + uint32_t pcr_pid, int num_progs, - u_int32 prog_pid[], + uint32_t prog_pid[], byte prog_type[]) { int err; @@ -832,7 +832,7 @@ extern int write_TS_program_data2(TS_writer_p output, return 1; } - pmt = build_pmt((u_int16)program_number,0,pcr_pid); + pmt = build_pmt((uint16_t)program_number,0,pcr_pid); if (pmt == NULL) { free_pidint_list(&prog_list); @@ -872,7 +872,7 @@ extern int write_TS_program_data2(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pat(TS_writer_p output, - u_int32 transport_stream_id, + uint32_t transport_stream_id, pidint_list_p prog_list) { int ii; @@ -882,7 +882,7 @@ extern int write_pat(TS_writer_p output, int err; int section_length; int offset, data_length; - u_int32 crc32; + uint32_t crc32; #if DEBUG_WRITE_PACKETS printf("|| PAT pid 0\n"); @@ -968,7 +968,7 @@ extern int write_pat(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pmt(TS_writer_p output, - u_int32 pmt_pid, + uint32_t pmt_pid, pmt_p pmt) { int ii; @@ -978,7 +978,7 @@ extern int write_pmt(TS_writer_p output, int err; int section_length; int offset, data_length; - u_int32 crc32; + uint32_t crc32; #if DEBUG_WRITE_PACKETS printf("|| PMT pid %x (%d)\n",pmt_pid,pmt_pid); @@ -1028,8 +1028,8 @@ extern int write_pmt(TS_writer_p output, for (ii=0; ii < pmt->num_streams; ii++) { - u_int32 pid = pmt->streams[ii].elementary_PID; - u_int16 len = pmt->streams[ii].ES_info_length; + uint32_t pid = pmt->streams[ii].elementary_PID; + uint16_t len = pmt->streams[ii].ES_info_length; data[offset+0] = pmt->streams[ii].stream_type; data[offset+1] = (byte) (0xE0 | ((pid & 0x1F00) >> 8)); data[offset+2] = (byte) (pid & 0x00FF); @@ -1090,9 +1090,9 @@ extern int write_pmt(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pat_and_pmt(TS_writer_p output, - u_int32 transport_stream_id, + uint32_t transport_stream_id, pidint_list_p prog_list, - u_int32 pmt_pid, + uint32_t pmt_pid, pmt_p pmt) { int err; @@ -1114,9 +1114,9 @@ extern int write_pat_and_pmt(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_single_program_pat(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid) + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid) { int err; pidint_list_p prog_list; @@ -1178,7 +1178,7 @@ extern int write_TS_null_packet(TS_writer_p output) // Reading a Transport Stream // ============================================================ -static u_int64 TWENTY_SEVEN_MHZ = 27000000; +static uint64_t TWENTY_SEVEN_MHZ = 27000000; // ------------------------------------------------------------ @@ -1503,21 +1503,21 @@ extern int read_next_TS_packet(TS_reader_p tsreader, static byte TS_buffer[PCR_READ_AHEAD_SIZE][TS_PACKET_SIZE]; // For convenience (since we'll already have calculated this once), // remember each packets PID -static u_int32 TS_buffer_pids[PCR_READ_AHEAD_SIZE]; +static uint32_t TS_buffer_pids[PCR_READ_AHEAD_SIZE]; // And the PCR PID we're looking for (we have to assume that's fairly // static, or we couldn't do read-aheads and interpolations) -static u_int32 TS_buffer_pcr_pid = 0; +static uint32_t TS_buffer_pcr_pid = 0; // The number of TS entries we've got therein, the *last* of which // has a PCR static int TS_buffer_len = 0; // Which TS packet we should read next... static int TS_buffer_next = 0; // The PCR of that last entry -static u_int64 TS_buffer_end_pcr = 0; +static uint64_t TS_buffer_end_pcr = 0; // And the PCR of the *previous* last entry -static u_int64 TS_buffer_prev_pcr = 0; +static uint64_t TS_buffer_prev_pcr = 0; // From which, we can deduce the time per packet -static u_int64 TS_buffer_time_per_TS = 0; +static uint64_t TS_buffer_time_per_TS = 0; // For diagnostic purposes, the sequence number of TS_buffer[0] // (and thus, of the overall read-ahead buffer) in the overall file static int TS_buffer_posn = 0; @@ -1543,9 +1543,9 @@ static int fill_TS_packet_buffer(TS_reader_p tsreader) for (ii=0; ii 0 && (*count) >= (u_int32)max) + if (max > 0 && (*count) >= (uint32_t)max) { if (loop) { @@ -1875,7 +1875,7 @@ extern int read_buffered_TS_packet(TS_reader_p tsreader, extern void get_PCR_from_adaptation_field(byte adapt[], int adapt_len, int *got_pcr, - u_int64 *pcr) + uint64_t *pcr) { if (adapt_len == 0 || adapt == NULL) *got_pcr = FALSE; @@ -1887,7 +1887,7 @@ extern void get_PCR_from_adaptation_field(byte adapt[], // it tends to get shifted as a signed integer, and sign-extended, // before it gets turned unsigned (which is probably the "correct" // behaviour according to the standard. oh well). - *pcr = ((u_int64)adapt[1] << 25) | (adapt[2] << 17) | (adapt[3] << 9) | + *pcr = ((uint64_t)adapt[1] << 25) | (adapt[2] << 17) | (adapt[3] << 9) | (adapt[4] << 1) | (adapt[5] >> 7); // Plus the program clock reference extension *pcr = ((*pcr) * 300) + ((adapt[5] & 1) << 8) + adapt[6]; @@ -1909,7 +1909,7 @@ extern void report_adaptation_field(byte adapt[], int adapt_len) { int got_pcr; - u_int64 pcr; + uint64_t pcr; if (adapt_len == 0 || adapt == NULL) return; @@ -1954,7 +1954,7 @@ extern void report_adaptation_timing(timing_p times, int packet_count) { int got_pcr; - u_int64 pcr; + uint64_t pcr; if (adapt_len == 0 || adapt == NULL || times == NULL) return; @@ -2041,8 +2041,8 @@ extern int extract_prog_list_from_pat(int verbose, int current_next_indicator; int section_number; int last_section_number; - u_int32 crc = 0; - u_int32 check_crc; + uint32_t crc = 0; + uint32_t check_crc; byte *program_data; int program_data_len; int err; @@ -2142,7 +2142,7 @@ extern int extract_prog_list_from_pat(int verbose, while (program_data_len > 0) { int program_number = (program_data[0] << 8) | program_data[1]; - u_int32 pid = ((program_data[2] & 0x1F) << 8) | program_data[3]; + uint32_t pid = ((program_data[2] & 0x1F) << 8) | program_data[3]; // A program_number of 0 indicates the network ID, so ignore it and // don't append to the program list - rrw 2004-10-13 @@ -2233,7 +2233,7 @@ extern int print_descriptors(FILE *stream, { switch (tag) { - u_int32 temp_u; + uint32_t temp_u; case 5: fprintf(stream,"Registration "); if (this_length >= 4) @@ -2405,7 +2405,7 @@ extern int print_descriptors(FILE *stream, extern int build_psi_data(int verbose, byte payload[MAX_TS_PAYLOAD_SIZE], int payload_len, - u_int32 pid, + uint32_t pid, byte **data, int *data_len, int *data_used) @@ -2515,21 +2515,21 @@ extern int build_psi_data(int verbose, extern int extract_pmt(int verbose, byte data[], int data_len, - u_int32 pid, + uint32_t pid, pmt_p *pmt) { int table_id; int section_syntax_indicator,zero_bit,reserved; - u_int16 program_number; - u_int32 pcr_pid; + uint16_t program_number; + uint32_t pcr_pid; int section_length; int version_number; int current_next_indicator; int section_number; int last_section_number; int program_info_length; - u_int32 crc = 0; - u_int32 check_crc; + uint32_t crc = 0; + uint32_t check_crc; byte *stream_data; int stream_data_len; int err; @@ -2693,7 +2693,7 @@ extern int extract_pmt(int verbose, while (stream_data_len > 0) { int stream_type = stream_data[0]; - u_int32 pid = ((stream_data[1] & 0x1F) << 8) | stream_data[2]; + uint32_t pid = ((stream_data[1] & 0x1F) << 8) | stream_data[2]; int ES_info_length = ((stream_data[3] & 0x0F) << 8) | stream_data[4]; if (verbose) { @@ -2734,9 +2734,9 @@ extern int extract_pmt(int verbose, extern int extract_stream_list_from_pmt(int verbose, byte payload[MAX_TS_PAYLOAD_SIZE], int payload_len, - u_int32 pid, + uint32_t pid, int *program_number, - u_int32 *pcr_pid, + uint32_t *pcr_pid, pidint_list_p *stream_list) { byte *data; @@ -2750,8 +2750,8 @@ extern int extract_stream_list_from_pmt(int verbose, int section_number; int last_section_number; int program_info_length; - u_int32 crc = 0; - u_int32 check_crc; + uint32_t crc = 0; + uint32_t check_crc; byte *stream_data; int stream_data_len; int err; @@ -2914,7 +2914,7 @@ extern int extract_stream_list_from_pmt(int verbose, while (stream_data_len > 0) { int stream_type = stream_data[0]; - u_int32 pid = ((stream_data[1] & 0x1F) << 8) | stream_data[2]; + uint32_t pid = ((stream_data[1] & 0x1F) << 8) | stream_data[2]; int ES_info_length = ((stream_data[3] & 0x0F) << 8) | stream_data[4]; if (verbose) { @@ -2957,7 +2957,7 @@ extern int extract_stream_list_from_pmt(int verbose, * Returns 0 if all went well, 1 if something went wrong. */ extern int split_TS_packet(byte buf[TS_PACKET_SIZE], - u_int32 *pid, + uint32_t *pid, int *payload_unit_start_indicator, byte *adapt[], int *adapt_len, @@ -3061,7 +3061,7 @@ extern int split_TS_packet(byte buf[TS_PACKET_SIZE], * went wrong. */ extern int get_next_TS_packet(TS_reader_p tsreader, - u_int32 *pid, + uint32_t *pid, int *payload_unit_start_indicator, byte *adapt[], int *adapt_len, @@ -3115,7 +3115,7 @@ extern int find_pat(TS_reader_p tsreader, for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt, *payload; int adapt_len, payload_len; @@ -3203,7 +3203,7 @@ extern int find_pat(TS_reader_p tsreader, * 1 if something else went wrong. */ extern int find_next_pmt(TS_reader_p tsreader, - u_int32 pmt_pid, + uint32_t pmt_pid, int max, int verbose, int quiet, @@ -3221,7 +3221,7 @@ extern int find_next_pmt(TS_reader_p tsreader, for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt, *payload; int adapt_len, payload_len; @@ -3326,7 +3326,7 @@ extern int find_pmt(TS_reader_p tsreader, { int err; pidint_list_p prog_list = NULL; - u_int32 pmt_pid; + uint32_t pmt_pid; int sofar; *pmt = NULL; diff --git a/ts2es.c b/ts2es.c index 3632ab1..bed97a8 100644 --- a/ts2es.c +++ b/ts2es.c @@ -148,7 +148,7 @@ static int extract_av_via_pes(char *input_name, */ static int extract_pid_packets(TS_reader_p tsreader, FILE *output, - u_int32 pid_wanted, + uint32_t pid_wanted, int max, int verbose, int quiet) @@ -164,7 +164,7 @@ static int extract_pid_packets(TS_reader_p tsreader, for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt, *payload; int adapt_len, payload_len; @@ -305,7 +305,7 @@ static int extract_av(int input, int err, ii; int max_to_read = max; int total_num_read = 0; - u_int32 pid = 0; + uint32_t pid = 0; TS_reader_p tsreader = NULL; pmt_p pmt = NULL; @@ -389,7 +389,7 @@ static int extract_av(int input, */ static int extract_pid(int input, FILE *output, - u_int32 pid_wanted, + uint32_t pid_wanted, int max, int verbose, int quiet) @@ -460,7 +460,7 @@ int main(int argc, char **argv) int input = -1; // Our input file descriptor FILE *output = NULL; // The stream we're writing to (if any) int max = 0; // The maximum number of TS packets to read (or 0) - u_int32 pid = 0; // The PID of the (single) stream to extract + uint32_t pid = 0; // The PID of the (single) stream to extract int quiet = FALSE; // True => be as quiet as possible int verbose = FALSE; // True => output diagnostic/progress messages int use_pes = FALSE; diff --git a/ts2ps.c b/ts2ps.c index 9991941..0ad9b23 100644 --- a/ts2ps.c +++ b/ts2ps.c @@ -97,14 +97,14 @@ static int write_pack_header(FILE *output) */ static int write_PES_packet(FILE *output, byte *data, - u_int16 data_len, + uint16_t data_len, byte stream_id) { static byte header[] = {0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, // replace 3 bytes 0x80, 0x00, 0x00}; // flags and header data len size_t count; - u_int16 PES_packet_length = data_len + 3; // + 3 for the flags, etc. + uint16_t PES_packet_length = data_len + 3; // + 3 for the flags, etc. header[3] = stream_id; header[4] = (PES_packet_length & 0xFF00) >> 8; @@ -133,7 +133,7 @@ static int write_PES_packet(FILE *output, */ static int extract_data(int input, FILE *output, - u_int16 program_number, + uint16_t program_number, int max, int verbose, int quiet) @@ -176,8 +176,8 @@ static int extract_data(int input, if (reader->packet->data[4] == 0 && reader->packet->data[5] == 0) { - int32 PES_packet_length = reader->packet->data_len - 6; - byte *start = reader->packet->data; + int32_t PES_packet_length = reader->packet->data_len - 6; + byte *start = reader->packet->data; // Our maximum length is determined by the maximum length we can // indicate in the two bytes of the PES_packet_length. When we're // *writing* data, we also have to allow for writing the two flag @@ -311,7 +311,7 @@ int main(int argc, char **argv) int max = 0; // The maximum number of TS packets to read (or 0) int quiet = FALSE; // True => be as quiet as possible int verbose = FALSE; // True => output diagnostic/progress messages - u_int16 program_number = 0; + uint16_t program_number = 0; int err = 0; int ii = 1; diff --git a/ts_fns.h b/ts_fns.h index c0e5fbc..d996e2f 100644 --- a/ts_fns.h +++ b/ts_fns.h @@ -59,10 +59,10 @@ * Returns 0 if it worked, 1 if something went wrong. */ extern int write_TS_program_data(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid, - u_int32 pid, + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid, + uint32_t pid, byte stream_type); /* @@ -82,12 +82,12 @@ extern int write_TS_program_data(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_TS_program_data2(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid, - u_int32 pcr_pid, + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid, + uint32_t pcr_pid, int num_progs, - u_int32 prog_pid[], + uint32_t prog_pid[], byte prog_type[]); /* @@ -100,7 +100,7 @@ extern int write_TS_program_data2(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pat(TS_writer_p output, - u_int32 transport_stream_id, + uint32_t transport_stream_id, pidint_list_p prog_list); /* * Write out a Transport Stream PMT, given a PMT datastructure @@ -112,7 +112,7 @@ extern int write_pat(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pmt(TS_writer_p output, - u_int32 pmt_pid, + uint32_t pmt_pid, pmt_p pmt); /* * Write out a Transport Stream PAT and PMT, given the appropriate @@ -127,9 +127,9 @@ extern int write_pmt(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_pat_and_pmt(TS_writer_p output, - u_int32 transport_stream_id, + uint32_t transport_stream_id, pidint_list_p prog_list, - u_int32 pmt_pid, + uint32_t pmt_pid, pmt_p pmt); /* * Write out a Transport Stream PAT, for a single program. @@ -142,9 +142,9 @@ extern int write_pat_and_pmt(TS_writer_p output, * Returns 0 if it worked, 1 if something went wrong. */ extern int write_single_program_pat(TS_writer_p output, - u_int32 transport_stream_id, - u_int32 program_number, - u_int32 pmt_pid); + uint32_t transport_stream_id, + uint32_t program_number, + uint32_t pmt_pid); /* * Write out our ES data as a Transport Stream PES packet. * @@ -165,8 +165,8 @@ extern int write_single_program_pat(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id); /* * Write out our ES data as a Transport Stream PES packet, with PTS and/or DTS @@ -203,13 +203,13 @@ extern int write_ES_as_TS_PES_packet(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet_with_pts_dts(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, int got_pts, - u_int64 pts, + uint64_t pts, int got_dts, - u_int64 dts); + uint64_t dts); /* * Write out our ES data as a Transport Stream PES packet, with PCR. * @@ -231,11 +231,11 @@ extern int write_ES_as_TS_PES_packet_with_pts_dts(TS_writer_p output, */ extern int write_ES_as_TS_PES_packet_with_pcr(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, - u_int64 pcr_base, - u_int32 pcr_extn); + uint64_t pcr_base, + uint32_t pcr_extn); /* * Write out a PES packet's data as a Transport Stream PES packet. * @@ -258,12 +258,12 @@ extern int write_ES_as_TS_PES_packet_with_pcr(TS_writer_p output, */ extern int write_PES_as_TS_PES_packet(TS_writer_p output, byte data[], - u_int32 data_len, - u_int32 pid, + uint32_t data_len, + uint32_t pid, byte stream_id, int got_pcr, - u_int64 pcr_base, - u_int32 pcr_extn); + uint64_t pcr_base, + uint32_t pcr_extn); /* * Write out a Transport Stream Null packet. * @@ -408,12 +408,12 @@ extern int read_next_TS_packet(TS_reader_p tsreader, * Returns 0 if all went well, 1 if something went wrong, EOF if EOF was read. */ extern int read_first_TS_packet_from_buffer(TS_reader_p tsreader, - u_int32 pcr_pid, - u_int32 start_count, + uint32_t pcr_pid, + uint32_t start_count, byte *data[TS_PACKET_SIZE], - u_int32 *pid, - u_int64 *pcr, - u_int32 *count); + uint32_t *pid, + uint64_t *pcr, + uint32_t *count); /* Retrieve the next TS packet from the PCR read-ahead buffer, * complete with its calculated PCR time. * @@ -430,15 +430,15 @@ extern int read_first_TS_packet_from_buffer(TS_reader_p tsreader, */ extern int read_next_TS_packet_from_buffer(TS_reader_p tsreader, byte *data[TS_PACKET_SIZE], - u_int32 *pid, - u_int64 *pcr); + uint32_t *pid, + uint64_t *pcr); /* Let the "looping" buffered TS packet reader know what its PCR PID is * * Call this before the first call of read_buffered_TS_packet(). * * - `pcr_pid` is the PID within which we should look for PCR entries */ -extern void prime_read_buffered_TS_packet(u_int32 pcr_pid); +extern void prime_read_buffered_TS_packet(uint32_t pcr_pid); /* * Read the next TS packet, coping with looping, etc. * @@ -466,14 +466,14 @@ extern void prime_read_buffered_TS_packet(u_int32 pcr_pid); * false and either EOF was read, or `max` TS packets were read. */ extern int read_buffered_TS_packet(TS_reader_p tsreader, - u_int32 *count, + uint32_t *count, byte *data[TS_PACKET_SIZE], - u_int32 *pid, - u_int64 *pcr, + uint32_t *pid, + uint64_t *pcr, int max, int loop, offset_t start_posn, - u_int32 start_count, + uint32_t start_count, int quiet); // ------------------------------------------------------------ @@ -487,10 +487,10 @@ extern int read_buffered_TS_packet(TS_reader_p tsreader, * - `got_PCR` is TRUE if the adaptation field contains a PCR * - `pcr` is then the PCR value itself */ -extern void get_PCR_from_adaptation_field(byte adapt[], - int adapt_len, - int *got_pcr, - u_int64 *pcr); +extern void get_PCR_from_adaptation_field(byte adapt[], + int adapt_len, + int *got_pcr, + uint64_t *pcr); /* * Report on the contents of this TS packet's adaptation field * @@ -587,9 +587,9 @@ extern int extract_prog_list_from_pat(int verbose, extern int extract_stream_list_from_pmt(int verbose, byte payload[MAX_TS_PAYLOAD_SIZE], int payload_len, - u_int32 pid, + uint32_t pid, int *program_number, - u_int32 *pcr_pid, + uint32_t *pcr_pid, pidint_list_p *stream_list); /* * Given a TS packet, extract the (next bit of) a PAT/PMT's data. @@ -622,7 +622,7 @@ extern int extract_stream_list_from_pmt(int verbose, extern int build_psi_data(int verbose, byte payload[MAX_TS_PAYLOAD_SIZE], int payload_len, - u_int32 pid, + uint32_t pid, byte **data, int *data_len, int *data_used); @@ -641,7 +641,7 @@ extern int build_psi_data(int verbose, extern int extract_pmt(int verbose, byte data[], int data_len, - u_int32 pid, + uint32_t pid, pmt_p *pmt); /* * Split a TS packet into its main parts @@ -664,7 +664,7 @@ extern int extract_pmt(int verbose, * Returns 0 if all went well, 1 if something went wrong. */ extern int split_TS_packet(byte buf[TS_PACKET_SIZE], - u_int32 *pid, + uint32_t *pid, int *payload_unit_start_indicator, byte *adapt[], int *adapt_len, @@ -698,7 +698,7 @@ extern int split_TS_packet(byte buf[TS_PACKET_SIZE], * went wrong. */ extern int get_next_TS_packet(TS_reader_p tsreader, - u_int32 *pid, + uint32_t *pid, int *payload_unit_start_indicator, byte *adapt[], int *adapt_len, @@ -740,7 +740,7 @@ extern int find_pat(TS_reader_p tsreader, * 1 if something else went wrong. */ extern int find_next_pmt(TS_reader_p tsreader, - u_int32 pmt_pid, + uint32_t pmt_pid, int max, int verbose,int quiet, int *num_read, diff --git a/tsinfo.c b/tsinfo.c index 6db11d6..70ca9c6 100644 --- a/tsinfo.c +++ b/tsinfo.c @@ -67,7 +67,7 @@ static int report_streams(TS_reader_p tsreader, pmt_p this_pmt = NULL; pmt_p last_pmt = NULL; - u_int32 pmt_pid = 0; // which will get "masked" by the PAT pid + uint32_t pmt_pid = 0; // which will get "masked" by the PAT pid byte *pat_data = NULL; int pat_data_len = 0; @@ -84,7 +84,7 @@ static int report_streams(TS_reader_p tsreader, for (ii=0; ii 0 && (*count) >= (u_int32)max) + if (max > 0 && (*count) >= (uint32_t)max) { if (loop) { @@ -169,15 +169,15 @@ static int read_TS_packet(TS_reader_p tsreader, */ static int find_PCR_PID(TS_reader_p tsreader, TS_writer_p tswriter, - u_int32 *pcr_pid, - u_int32 *num_read, + uint32_t *pcr_pid, + uint32_t *num_read, int max, int quiet) { int err; int count = 0; byte *data; - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt; int adapt_len; @@ -187,7 +187,7 @@ static int find_PCR_PID(TS_reader_p tsreader, pidint_list_p prog_list = NULL; pmt_p pmt = NULL; - u_int32 pmt_pid = 0; // safe initial value + uint32_t pmt_pid = 0; // safe initial value byte *pat_data = NULL; int pat_data_len = 0; @@ -375,7 +375,7 @@ static int find_PCR_PID(TS_reader_p tsreader, */ static int play_buffered_TS_packets(TS_reader_p tsreader, TS_writer_p tswriter, - u_int32 pid_to_ignore, + uint32_t pid_to_ignore, int max, int loop, int quiet, @@ -383,9 +383,9 @@ static int play_buffered_TS_packets(TS_reader_p tsreader, { int err; int total = 0; - u_int32 count = 0; - u_int32 pcr_pid; - u_int32 start_count = 0; // which TS packet to loop from + uint32_t count = 0; + uint32_t pcr_pid; + uint32_t start_count = 0; // which TS packet to loop from offset_t start_posn = 0; // These are only used in the loop below, but the compiler grumbles if @@ -395,8 +395,8 @@ static int play_buffered_TS_packets(TS_reader_p tsreader, // *will* be set by the function, so I don't want them reinitialised // every time round the loop. So hoist them back up to here... byte *data = NULL; - u_int32 pid = 0; - u_int64 pcr = 0; + uint32_t pid = 0; + uint64_t pcr = 0; // Before we can use PCRs for timing, we need to read a PMT which tells us // what our video stream is (so we can get our PCRs therefrom). @@ -429,7 +429,7 @@ static int play_buffered_TS_packets(TS_reader_p tsreader, if (tsreader->file != STDIN_FILENO) { fprintf(stderr,"### Last TS packet read was at " LLU_FORMAT "\n", - (u_int64)count * TS_PACKET_SIZE); + (uint64_t)count * TS_PACKET_SIZE); } return 1; } @@ -481,7 +481,7 @@ static int play_buffered_TS_packets(TS_reader_p tsreader, */ static int play_TS_packets(TS_reader_p tsreader, TS_writer_p tswriter, - u_int32 pid_to_ignore, + uint32_t pid_to_ignore, int max, int loop, int quiet, @@ -489,11 +489,11 @@ static int play_TS_packets(TS_reader_p tsreader, { int err; int total = 0; - u_int32 count = 0; + uint32_t count = 0; int pcrs_used = 0; int pcrs_ignored = 0; - u_int32 pcr_pid; - u_int32 start_count = 0; // which TS packet to loop from + uint32_t pcr_pid; + uint32_t start_count = 0; // which TS packet to loop from offset_t start_posn = 0; // Before we can use PCRs for timing, we need to read a PMT which tells us @@ -518,9 +518,9 @@ static int play_TS_packets(TS_reader_p tsreader, for (;;) { byte *data; - u_int32 pid; + uint32_t pid; int got_pcr; - u_int64 pcr; + uint64_t pcr; err = read_TS_packet(tsreader,&count,&data,&pid,&got_pcr,&pcr, max,loop,start_posn,start_count,quiet); @@ -531,7 +531,7 @@ static int play_TS_packets(TS_reader_p tsreader, if (tsreader->file != STDIN_FILENO) { fprintf(stderr,"### Last TS packet read was at " LLU_FORMAT "\n", - (u_int64)count * TS_PACKET_SIZE); + (uint64_t)count * TS_PACKET_SIZE); } return 1; } @@ -611,7 +611,7 @@ static int play_TS_packets(TS_reader_p tsreader, */ static int play_TS_stream(int input, TS_writer_p tswriter, - u_int32 pid_to_ignore, + uint32_t pid_to_ignore, int scan_for_PCRs, int max, int loop, @@ -696,11 +696,11 @@ static int play_PS_stream(int input, int audio_stream, int want_ac3_audio, int want_dolby_as_dvb, - u_int32 pmt_pid, - u_int32 pcr_pid, - u_int32 video_pid, + uint32_t pmt_pid, + uint32_t pcr_pid, + uint32_t video_pid, int keep_audio, - u_int32 audio_pid, + uint32_t audio_pid, int max, int loop, int verbose, @@ -1063,13 +1063,13 @@ int main(int argc, char **argv) char *multicast_if = NULL; // IP address of multicast i/f int scan_for_PCRs = TRUE; - u_int32 pid_to_ignore = 0; + uint32_t pid_to_ignore = 0; // Program Stream specific options - u_int32 pmt_pid = 0x66; - u_int32 video_pid = 0x68; - u_int32 pcr_pid = video_pid; // Use PCRs from the video stream - u_int32 audio_pid = 0x67; + uint32_t pmt_pid = 0x66; + uint32_t video_pid = 0x68; + uint32_t pcr_pid = video_pid; // Use PCRs from the video stream + uint32_t audio_pid = 0x67; int repeat_program_every = 100; int pad_start = 8; int input_is_dvd = TRUE; diff --git a/tsreport.c b/tsreport.c index 73efccf..2620b6d 100644 --- a/tsreport.c +++ b/tsreport.c @@ -52,10 +52,10 @@ static int tfmt_diff = FMTX_TS_DISPLAY_90kHz_RAW; static int tfmt_abs = FMTX_TS_DISPLAY_90kHz_RAW; -static u_int64 -estimate_pcr(offset_t posn, u_int64 ppcr_pos, u_int64 ppcr_val, double pcr_rate) +static uint64_t +estimate_pcr(offset_t posn, uint64_t ppcr_pos, uint64_t ppcr_val, double pcr_rate) { - return (u_int64)(ppcr_val + (27000000.0 * (double)(posn - ppcr_pos))/pcr_rate); + return (uint64_t)(ppcr_val + (27000000.0 * (double)(posn - ppcr_pos))/pcr_rate); } /* ============================================================================ @@ -63,29 +63,29 @@ estimate_pcr(offset_t posn, u_int64 ppcr_pos, u_int64 ppcr_val, double pcr_rate) */ struct diff_from_pcr { - int64 min; // minimum (absolute) difference - u_int64 min_at; // at what PTS the minimum occurred + int64_t min; // minimum (absolute) difference + uint64_t min_at; // at what PTS the minimum occurred offset_t min_posn; // at what position in the file - int64 max; // and ditto for the maximum (abs) difference - u_int64 max_at; + int64_t max; // and ditto for the maximum (abs) difference + uint64_t max_at; offset_t max_posn; - int64 sum; // the sum of all of the differences + int64_t sum; // the sum of all of the differences unsigned int num; // the number of TS records compared }; struct stream_data { - u_int32 pid; + uint32_t pid; int stream_type; int had_a_pts; int had_a_dts; - u_int64 first_pts; - u_int64 first_dts; + uint64_t first_pts; + uint64_t first_dts; // Keep these in our datastructure so we can easily report the last // PTS/DTS in the file, when we're finishing up - u_int64 pts; - u_int64 dts; + uint64_t pts; + uint64_t dts; int err_pts_lt_dts; int err_dts_lt_prev_dts; @@ -99,7 +99,7 @@ struct stream_data { static int pid_index(struct stream_data *data, int num_streams, - u_int32 pid) + uint32_t pid) { int ii; for (ii=0; iinum_streams; ii++) { - u_int32 pid = pmt->streams[ii].elementary_PID; + uint32_t pid = pmt->streams[ii].elementary_PID; if (ii >= MAX_NUM_STREAMS) { printf("!!! Found more than %d streams -- just reporting on the first %d found\n", @@ -218,15 +218,15 @@ static int report_buffering_stats(TS_reader_p tsreader, start_posn = posn = tsreader->posn - TS_PACKET_SIZE; for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *packet; byte *adapt, *payload; int adapt_len, payload_len; int got_pcr = FALSE; - u_int64 acc_pcr = 0; // The accurate PCR per TS packet + uint64_t acc_pcr = 0; // The accurate PCR per TS packet - if (max > 0 && count >= (u_int32)max) + if (max > 0 && count >= (uint32_t)max) { printf("Stopping after %d packets (PMT was at %d)\n",max,pmt_at); break; @@ -270,7 +270,7 @@ static int report_buffering_stats(TS_reader_p tsreader, // If we actually had a PCR, then we need to remember it if (pid == pcr_pid) { - u_int64 adapt_pcr; + uint64_t adapt_pcr; // Do I need to check that this is the same PCR I got earlier? // I certainly hope not... get_PCR_from_adaptation_field(adapt,adapt_len,&got_pcr,&adapt_pcr); @@ -280,9 +280,9 @@ static int report_buffering_stats(TS_reader_p tsreader, { // OK, so what we have predicted this PCR would be, // given the previous two PCRs and a linear rate? - u_int64 guess_pcr = estimate_pcr(posn,predict.prev_pcr_posn, + uint64_t guess_pcr = estimate_pcr(posn,predict.prev_pcr_posn, predict.prev_pcr,predict.pcr_rate); - int64 delta = adapt_pcr - guess_pcr; + int64_t delta = adapt_pcr - guess_pcr; if (delta < predict.min_pcr_error) predict.min_pcr_error = delta; if (delta > predict.max_pcr_error) @@ -295,7 +295,7 @@ static int report_buffering_stats(TS_reader_p tsreader, fmtx_timestamp(adapt_pcr, tfmt_abs | FMTX_TS_N_27MHz)); if (file) fprintf(file,LLU_FORMAT ",read," LLU_FORMAT ",,,,\n", - posn,(adapt_pcr / (int64)300) & report_mask); + posn,(adapt_pcr / (int64_t)300) & report_mask); if (predict.had_a_pcr) { @@ -309,7 +309,7 @@ static int report_buffering_stats(TS_reader_p tsreader, } else { - u_int64 delta_pcr = adapt_pcr - predict.prev_pcr; + uint64_t delta_pcr = adapt_pcr - predict.prev_pcr; int delta_bytes = (int)(posn - predict.prev_pcr_posn); predict.pcr_rate = ((double)delta_bytes * 27.0 / (double)delta_pcr) * 1000000.0; predict.know_pcr_rate = TRUE; @@ -340,9 +340,9 @@ static int report_buffering_stats(TS_reader_p tsreader, // We are the start of a PES packet // We'll assume "enough" of the PES packet is in this TS int got_pts, got_dts; - const u_int64 last_dts = stats[index].dts; - u_int64 pcr_time_now_div300 = 0; - int64 difference; + const uint64_t last_dts = stats[index].dts; + uint64_t pcr_time_now_div300 = 0; + int64_t difference; err = find_PTS_DTS_in_PES(payload,payload_len, &got_pts,&stats[index].pts,&got_dts,&stats[index].dts); if (err) @@ -416,7 +416,7 @@ static int report_buffering_stats(TS_reader_p tsreader, { // At the moment, we only report any ESCR to the file int got_escr = FALSE; - u_int64 escr; + uint64_t escr; (void) find_ESCR_in_PES(payload,payload_len,&got_escr,&escr); fprintf(file,OFFSET_T_FORMAT ",%s," LLU_FORMAT ",%d,%s,", @@ -540,7 +540,7 @@ static int report_buffering_stats(TS_reader_p tsreader, fmtx_timestamp(stats[ii].pcr_pts_diff.max - stats[ii].pcr_pts_diff.min, tfmt_diff)); printf(" Mean difference (of %u) is %s\n", stats[ii].pcr_pts_diff.num, - fmtx_timestamp((int64)(stats[ii].pcr_pts_diff.sum/(double)stats[ii].pcr_pts_diff.num), tfmt_diff)); + fmtx_timestamp((int64_t)(stats[ii].pcr_pts_diff.sum/(double)stats[ii].pcr_pts_diff.num), tfmt_diff)); } if (stats[ii].pcr_dts_diff.num > 0 && stats[ii].pts_ne_dts) @@ -557,7 +557,7 @@ static int report_buffering_stats(TS_reader_p tsreader, fmtx_timestamp(stats[ii].pcr_dts_diff.max - stats[ii].pcr_dts_diff.min, tfmt_diff)); printf(" Mean difference (of %u) is %s\n", stats[ii].pcr_dts_diff.num, - fmtx_timestamp((int64)(stats[ii].pcr_dts_diff.sum/(double)stats[ii].pcr_dts_diff.num), tfmt_diff)); + fmtx_timestamp((int64_t)(stats[ii].pcr_dts_diff.sum/(double)stats[ii].pcr_dts_diff.num), tfmt_diff)); } printf(" First PCR %8s, last %8s\n", @@ -604,7 +604,7 @@ static int report_ts(TS_reader_p tsreader, int pat_data_len = 0; int pat_data_used = 0; - u_int32 unfinished_pmt_pid = 0; + uint32_t unfinished_pmt_pid = 0; byte *pmt_data = NULL; int pmt_data_len = 0; int pmt_data_used = 0; @@ -614,7 +614,7 @@ static int report_ts(TS_reader_p tsreader, for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt, *payload; int adapt_len, payload_len; @@ -863,7 +863,7 @@ static int report_ts(TS_reader_p tsreader, static int report_single_pid(TS_reader_p tsreader, int max, int quiet, - u_int32 just_pid) + uint32_t just_pid) { int err; int count = 0; @@ -871,7 +871,7 @@ static int report_single_pid(TS_reader_p tsreader, for (;;) { - u_int32 pid; + uint32_t pid; int payload_unit_start_indicator; byte *adapt, *payload; int adapt_len, payload_len; @@ -997,10 +997,10 @@ int main(int argc, char **argv) int report_buffering = FALSE; int show_data = FALSE; char *output_name = NULL; - u_int64 report_mask = ~0; // report as many bits as we get + uint64_t report_mask = ~0; // report as many bits as we get int select_pid = FALSE; - u_int32 just_pid = 0; + uint32_t just_pid = 0; int err = 0; int ii = 1; @@ -1073,7 +1073,7 @@ int main(int argc, char **argv) else if (!strcmp("-justpid",argv[ii])) { CHECKARG("tsreport",ii); - err = int_value("tsreport",argv[ii],argv[ii+1],TRUE,0,(int32*)&just_pid); + err = int_value("tsreport",argv[ii],argv[ii+1],TRUE,0,(int32_t*)&just_pid); if (err) return 1; select_pid = TRUE; ii++; diff --git a/tsserve.c b/tsserve.c index 2d6b506..d435a75 100644 --- a/tsserve.c +++ b/tsserve.c @@ -115,10 +115,10 @@ struct tsserve_context int drop_number; // how many packets to drop // Program Stream specific options - u_int32 pmt_pid; - u_int32 audio_pid; - u_int32 video_pid; - u_int32 pcr_pid; + uint32_t pmt_pid; + uint32_t audio_pid; + uint32_t video_pid; + uint32_t pcr_pid; int want_h262; int dolby_is_dvb; int force_stream_type; @@ -1066,12 +1066,12 @@ static int back_to_normal(stream_context stream, // Said last item started in the previous PES packet // - we need to output the part of it that is in that previous packet // Given the next byte to be read (from this PES packet) - int32 curposn = es->posn_of_next_byte.inpacket; + int32_t curposn = es->posn_of_next_byte.inpacket; // we can work out how much of the item was in the previous packet // (sanity check - if the next byte to read was 1, then we've read one // byte from the current packet, and the following should indeed be right // - look at pes.c:read_PES_ES_byte and es.c:next_triple_byte for details) - int32 length_wanted; + int32_t length_wanted; if (stream.is_h262) { @@ -1117,8 +1117,8 @@ static int back_to_normal(stream_context stream, else { // Said last item starts part way through this PES packet - int32 start_offset = item_start.inpacket; - int32 length_wanted = reader->packet->es_data_len - start_offset; + int32_t start_offset = item_start.inpacket; + int32_t length_wanted = reader->packet->es_data_len - start_offset; if (extra_info) { printf(".. so output %d bytes at end of PES packet\n",length_wanted); diff --git a/tswrite.c b/tswrite.c index 987ccca..fc9e510 100644 --- a/tswrite.c +++ b/tswrite.c @@ -542,33 +542,33 @@ static int set_buffer_item_time_pcr(buffered_TS_output_p writer) int ii; circular_buffer_p circular = writer->buffer; - static int32 available_bytes = 0; - static double available_time = 0; + static int32_t available_bytes = 0; + static double available_time = 0; - static int last_pcr_index = -1; - static u_int64 last_pcr; - static double pcr_rate = 0; - static u_int32 last_timestamp_near_PCR = 0; + static int last_pcr_index = -1; + static uint64_t last_pcr; + static double pcr_rate = 0; + static uint32_t last_timestamp_near_PCR = 0; - static u_int32 last_timestamp = 0; + static uint32_t last_timestamp = 0; static int had_first_pcr = FALSE; // Did we *have* a previous PCR? static int had_second_pcr = FALSE; // And the second PCR is special, too // Remember our initial "priming" so we can replace it with a better // estimate later on - static double initial_prime_time = 0; - static int32 initial_prime_bytes = 0; + static double initial_prime_time = 0; + static int32_t initial_prime_bytes = 0; // Some simple statistics - static int64 total_available_bytes = 0; - static double total_available_time = 0.0; - static int num_availables = 0; + static int64_t total_available_bytes = 0; + static double total_available_time = 0.0; + static int num_availables = 0; - int found_pcr = FALSE; - int num_bytes; - double num_microseconds; - u_int32 timestamp; + int found_pcr = FALSE; + int num_bytes; + double num_microseconds; + uint32_t timestamp; // A silly rate just means we haven't started yet... if (pcr_rate < 1.0) @@ -615,7 +615,7 @@ static int set_buffer_item_time_pcr(buffered_TS_output_p writer) // Output our bytes using the prevailing conditions num_bytes = TS_PACKET_SIZE*writer->num_packets; num_microseconds = ((double)num_bytes / available_bytes) * available_time; - timestamp = (u_int32) (last_timestamp + num_microseconds); + timestamp = (uint32_t) (last_timestamp + num_microseconds); available_bytes -= num_bytes; available_time -= num_microseconds; @@ -652,7 +652,7 @@ static int set_buffer_item_time_pcr(buffered_TS_output_p writer) else { // This is our second or later PCR - we can calculate interesting things - u_int64 delta_pcr = writer->packet[ii].pcr - last_pcr; + uint64_t delta_pcr = writer->packet[ii].pcr - last_pcr; int delta_bytes = (writer->packet[ii].index-last_pcr_index)*TS_PACKET_SIZE; int extra_bytes; double extra_time; @@ -722,10 +722,10 @@ static int set_buffer_item_time_pcr(buffered_TS_output_p writer) */ static int set_buffer_item_time_plain(buffered_TS_output_p writer) { - static u_int32 last_time = 0; // The last circular buffer time stamp + static uint32_t last_time = 0; // The last circular buffer time stamp circular_buffer_p circular = writer->buffer; int num_bytes = writer->num_packets * TS_PACKET_SIZE;// Bytes since last time - u_int32 elapsed_time = (u_int32) (num_bytes * 1000000.0 / writer->rate); + uint32_t elapsed_time = (uint32_t) (num_bytes * 1000000.0 / writer->rate); last_time += elapsed_time; circular->item[writer->which].time = last_time; return 0; @@ -876,9 +876,9 @@ static int write_EOF_to_buffered_TS_output(buffered_TS_output_p writer) static int write_to_buffered_TS_output(buffered_TS_output_p writer, byte packet[TS_PACKET_SIZE], int count, - u_int32 pid, + uint32_t pid, int got_pcr, - u_int64 pcr) + uint64_t pcr) { int err; circular_buffer_p circular = writer->buffer; @@ -911,9 +911,9 @@ static int write_to_buffered_TS_output(buffered_TS_output_p writer, { #if 0 printf("@@ PCR %10" LLU_FORMAT_STUMP " * %g",pcr,writer->pcr_scale); - printf(" => %10" LLU_FORMAT_STUMP "\n", (u_int64)(pcr*writer->pcr_scale)); + printf(" => %10" LLU_FORMAT_STUMP "\n", (uint64_t)(pcr*writer->pcr_scale)); #endif - pcr = (u_int64)((double)pcr * writer->pcr_scale); + pcr = (uint64_t)((double)pcr * writer->pcr_scale); } else pcr = 0; @@ -954,7 +954,7 @@ static void wait_microseconds(int microseconds) #else // _WIN32 struct timespec time = {0}; struct timespec remaining; - u_int32 nanoseconds = microseconds * 1000; + uint32_t nanoseconds = microseconds * 1000; int err = 0; time.tv_sec = 0; @@ -1568,11 +1568,11 @@ static int received_EOF(circular_buffer_p circular) /* * Calculate a value to perturb time by. Returns a number of microseconds. */ -static int32 perturb_time_by(void) +static int32_t perturb_time_by(void) { static int first_time = TRUE; unsigned double_range; - int32 result; + int32_t result; if (first_time) { @@ -1630,9 +1630,9 @@ static int write_from_circular(SOCKET output, // (in microseconds since some arbitrary start time) at which it would // like it to be displayed. For a constant rate bitstream, these "ticks" // will be evenly spaced. - u_int32 this_packet_time; // time stamp for this packet - static u_int32 last_packet_time = 0; // time stamp for last packet - int32 packet_time_gap; // the difference between the two, in microseconds + uint32_t this_packet_time; // time stamp for this packet + static uint32_t last_packet_time = 0; // time stamp for last packet + int32_t packet_time_gap; // the difference between the two, in microseconds // Monitor time as seen by us // We have to deduce both an arbitrary start time from which to measure @@ -1641,10 +1641,10 @@ static int write_from_circular(SOCKET output, // as near to the correct tick as possible. struct timeval now; static struct timeval start = {0,0}; // our arbitrary start time - u_int32 our_time_now; // our time, relative to our start time - static int32 delta_start; // difference between our time and the parent's - u_int32 adjusted_now; // our time, adjusted by delta_start - int32 waitfor; // how long we think we need to wait to adjust + uint32_t our_time_now; // our time, relative to our start time + static int32_t delta_start; // difference between our time and the parent's + uint32_t adjusted_now; // our time, adjusted by delta_start + int32_t waitfor; // how long we think we need to wait to adjust // How many items have we sent without *any* delay? // (not used if maxnowait is off) @@ -2595,9 +2595,9 @@ extern int tswrite_close(TS_writer_p tswriter, */ extern int tswrite_write(TS_writer_p tswriter, byte packet[TS_PACKET_SIZE], - u_int32 pid, + uint32_t pid, int got_pcr, - u_int64 pcr) + uint64_t pcr) { int err; diff --git a/tswrite_defns.h b/tswrite_defns.h index 29c28a7..bc154c7 100644 --- a/tswrite_defns.h +++ b/tswrite_defns.h @@ -81,7 +81,7 @@ typedef int SOCKET; // for compatibility with Windows // struct circular_buffer_item { - u_int32 time; // when we would like this data output + uint32_t time; // when we would like this data output int discontinuity; // TRUE if our timeline has "broken" int length; // number of bytes of data in the array }; @@ -132,9 +132,9 @@ typedef struct circular_buffer *circular_buffer_p; struct TS_packet_info { int index; - u_int32 pid; // do we need the PIDs? + uint32_t pid; // do we need the PIDs? int got_pcr; - u_int64 pcr; + uint64_t pcr; }; typedef struct TS_packet_info *TS_packet_info_p; #define SIZEOF_TS_PACKET_INFO sizeof(struct TS_packet_info); @@ -160,7 +160,7 @@ struct buffered_TS_output struct TS_packet_info packet[MAX_TS_PACKETS_IN_ITEM]; // `rate` is the rate (in bytes per second) we would like to output data at - u_int32 rate; + uint32_t rate; // `pcr_scale` is a multiplier for PCRs - each PCR found gets its value // multiplied by this diff --git a/tswrite_fns.h b/tswrite_fns.h index 6568012..b5c05b1 100644 --- a/tswrite_fns.h +++ b/tswrite_fns.h @@ -284,9 +284,9 @@ extern int wait_for_command(TS_writer_p tswriter); */ extern int tswrite_write(TS_writer_p tswriter, byte packet[TS_PACKET_SIZE], - u_int32 pid, + uint32_t pid, int got_pcr, - u_int64 pcr); + uint64_t pcr); /* * Write a usage string (to standard output) describing the tuning diff --git a/yuv2/Makefile b/yuv2/Makefile index 69c5c7b..2796f0e 100644 --- a/yuv2/Makefile +++ b/yuv2/Makefile @@ -18,7 +18,7 @@ LOCATED_SRC=$(SRC_FILES:%.java=$(SRC_DIR)/%.java) all: if [ ! -d obj ]; then mkdir obj; fi - $$JAVA_HOME/bin/javac -cp $$SWTDIR/swt.jar -d obj -s bin $(LOCATED_SRC) + $$JAVA_HOME/bin/javac -cp $$SWTDIR/swt.jar -d obj -sourcepath bin $(LOCATED_SRC) (cd obj; $$JAVA_HOME/bin/jar -xf $$SWTDIR/swt.jar) (cd obj; $$JAVA_HOME/bin/jar -cmf ../src/Manifest-Extras.txt ../yuv2.jar *)