kopia lustrzana https://github.com/F5OEO/tstools
[JC] Now compiles under windows and my version of continuity counter checking added to tsreport
--HG-- extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%4087issue20
rodzic
a390c6f52c
commit
e4c53fd68c
10
Makefile.w32
10
Makefile.w32
|
@ -95,16 +95,19 @@ LIB_OBJS = \
|
||||||
$(OBJDIR)\audio.obj \
|
$(OBJDIR)\audio.obj \
|
||||||
$(OBJDIR)\bitdata.obj \
|
$(OBJDIR)\bitdata.obj \
|
||||||
$(OBJDIR)\es.obj \
|
$(OBJDIR)\es.obj \
|
||||||
|
$(OBJDIR)\ethernet.obj \
|
||||||
$(OBJDIR)\filter.obj \
|
$(OBJDIR)\filter.obj \
|
||||||
$(OBJDIR)\fmtx.obj \
|
$(OBJDIR)\fmtx.obj \
|
||||||
$(OBJDIR)\h222.obj \
|
$(OBJDIR)\h222.obj \
|
||||||
$(OBJDIR)\h262.obj \
|
$(OBJDIR)\h262.obj \
|
||||||
|
$(OBJDIR)\ipv4.obj \
|
||||||
$(OBJDIR)\l2audio.obj \
|
$(OBJDIR)\l2audio.obj \
|
||||||
$(OBJDIR)\misc.obj \
|
$(OBJDIR)\misc.obj \
|
||||||
$(OBJDIR)\nalunit.obj \
|
$(OBJDIR)\nalunit.obj \
|
||||||
$(OBJDIR)\ps.obj \
|
$(OBJDIR)\pcap.obj \
|
||||||
$(OBJDIR)\pes.obj \
|
$(OBJDIR)\pes.obj \
|
||||||
$(OBJDIR)\pidint.obj \
|
$(OBJDIR)\pidint.obj \
|
||||||
|
$(OBJDIR)\ps.obj \
|
||||||
$(OBJDIR)\reverse.obj \
|
$(OBJDIR)\reverse.obj \
|
||||||
$(OBJDIR)\ts.obj \
|
$(OBJDIR)\ts.obj \
|
||||||
$(OBJDIR)\tswrite.obj
|
$(OBJDIR)\tswrite.obj
|
||||||
|
@ -118,7 +121,7 @@ PROG_OBJS = \
|
||||||
$(OBJDIR)/esreport.obj \
|
$(OBJDIR)/esreport.obj \
|
||||||
$(OBJDIR)/esreverse.obj \
|
$(OBJDIR)/esreverse.obj \
|
||||||
$(OBJDIR)/m2ts2ts.obj \
|
$(OBJDIR)/m2ts2ts.obj \
|
||||||
$(OBJDIR)/pcapreport.obj \
|
$(OBJDIR)/pcapreport.obj \
|
||||||
$(OBJDIR)/ps2ts.obj \
|
$(OBJDIR)/ps2ts.obj \
|
||||||
$(OBJDIR)/psdots.obj \
|
$(OBJDIR)/psdots.obj \
|
||||||
$(OBJDIR)/psreport.obj \
|
$(OBJDIR)/psreport.obj \
|
||||||
|
@ -169,6 +172,9 @@ $(EXEDIR)\m2ts2ts.exe: $(OBJDIR)\m2ts2ts.obj $(LIBFILE)
|
||||||
$(EXEDIR)\stream_type.exe: $(OBJDIR)\stream_type.obj $(LIBFILE)
|
$(EXEDIR)\stream_type.exe: $(OBJDIR)\stream_type.obj $(LIBFILE)
|
||||||
link /out:$@ $(LOPT) $** wsock32.lib
|
link /out:$@ $(LOPT) $** wsock32.lib
|
||||||
|
|
||||||
|
$(EXEDIR)\pcapreport.exe: $(OBJDIR)\pcapreport.obj $(LIBFILE)
|
||||||
|
link /out:$@ $(LOPT) $** wsock32.lib
|
||||||
|
|
||||||
$(EXEDIR)\psreport.exe: $(OBJDIR)\psreport.obj $(LIBFILE)
|
$(EXEDIR)\psreport.exe: $(OBJDIR)\psreport.obj $(LIBFILE)
|
||||||
link /out:$@ $(LOPT) $** wsock32.lib
|
link /out:$@ $(LOPT) $** wsock32.lib
|
||||||
|
|
||||||
|
|
21
compat.h
21
compat.h
|
@ -39,17 +39,21 @@
|
||||||
// Kill deprecation warnings
|
// Kill deprecation warnings
|
||||||
#pragma warning( 4: 4996 )
|
#pragma warning( 4: 4996 )
|
||||||
|
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
// Windows doesn't seem to supply <stdint.h>, so we shall have to try
|
// Windows doesn't seem to supply <stdint.h>, so we shall have to try
|
||||||
// for values we hope work
|
// for values we hope work
|
||||||
typedef unsigned char byte;
|
typedef __int8 int8_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef __int16 int16_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef __int32 int32_t;
|
||||||
typedef unsigned long uint32_t;
|
typedef __int64 int64_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
|
|
||||||
typedef short int16_t;
|
typedef unsigned __int8 uint8_t;
|
||||||
typedef long int32_t;
|
typedef unsigned __int16 uint16_t;
|
||||||
typedef __int64 int64_t;
|
typedef unsigned __int32 uint32_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
|
typedef uint8_t byte;
|
||||||
|
|
||||||
// On BSD, lseek takes a 64-bit off_t value
|
// On BSD, lseek takes a 64-bit off_t value
|
||||||
// On Linux, if the system supports long files, it does the same
|
// On Linux, if the system supports long files, it does the same
|
||||||
|
@ -94,6 +98,7 @@ typedef __int64 offset_t;
|
||||||
// Other than on Windows, using the C99 integer definitions is what people
|
// Other than on Windows, using the C99 integer definitions is what people
|
||||||
// expect, so do so
|
// expect, so do so
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
// Keep "byte" for historical/affectionate reasons
|
// Keep "byte" for historical/affectionate reasons
|
||||||
typedef uint8_t byte;
|
typedef uint8_t byte;
|
||||||
|
|
28
esdots.c
28
esdots.c
|
@ -390,6 +390,20 @@ static int dots_by_access_unit(ES_p es,
|
||||||
int show_gop_time)
|
int show_gop_time)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int err = 0;
|
||||||
|
int access_unit_count = 0;
|
||||||
|
access_unit_context_p context;
|
||||||
|
|
||||||
|
int gop_start_found = FALSE;
|
||||||
|
int k_frame = 0;
|
||||||
|
int size_gop;
|
||||||
|
int size_gop_max = 0;
|
||||||
|
int size_gop_min = 100000;
|
||||||
|
int gops = 0;
|
||||||
|
int size_gop_tot = 0;
|
||||||
|
int is_first_k_frame = TRUE;
|
||||||
|
char char_nal_type = 'a';
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("\n"
|
printf("\n"
|
||||||
"Each character represents a single access unit\n"
|
"Each character represents a single access unit\n"
|
||||||
|
@ -408,20 +422,6 @@ static int dots_by_access_unit(ES_p es,
|
||||||
" # means an EOS (end-of-stream) NAL unit.\n"
|
" # means an EOS (end-of-stream) NAL unit.\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
int err = 0;
|
|
||||||
int access_unit_count = 0;
|
|
||||||
access_unit_context_p context;
|
|
||||||
|
|
||||||
int gop_start_found = FALSE;
|
|
||||||
int k_frame = 0;
|
|
||||||
int size_gop;
|
|
||||||
int size_gop_max = 0;
|
|
||||||
int size_gop_min = 100000;
|
|
||||||
int gops = 0;
|
|
||||||
int size_gop_tot = 0;
|
|
||||||
int is_first_k_frame = TRUE;
|
|
||||||
char char_nal_type = 'a';
|
|
||||||
|
|
||||||
err = build_access_unit_context(es,&context);
|
err = build_access_unit_context(es,&context);
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include "compat.h"
|
||||||
|
|
||||||
#include "pcap.h"
|
#include "pcap.h"
|
||||||
|
|
||||||
|
|
2
ipv4.h
2
ipv4.h
|
@ -30,7 +30,7 @@
|
||||||
#ifndef _ipv4_h
|
#ifndef _ipv4_h
|
||||||
#define _ipv4_h
|
#define _ipv4_h
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "compat.h"
|
||||||
|
|
||||||
/*! This is all held in host byte order (including the
|
/*! This is all held in host byte order (including the
|
||||||
* IP addresses! You have been warned .. )
|
* IP addresses! You have been warned .. )
|
||||||
|
|
|
@ -210,7 +210,7 @@ static int extract_packets(int input, FILE * output,
|
||||||
(unsigned int)(packet_buffer->next));
|
(unsigned int)(packet_buffer->next));
|
||||||
reorder_buffer_entries++;
|
reorder_buffer_entries++;
|
||||||
|
|
||||||
if (reorder_buffer_entries > reorder_buffer_size)
|
if (reorder_buffer_entries > (int)reorder_buffer_size)
|
||||||
{
|
{
|
||||||
// Write out the head of the reorder buffer
|
// Write out the head of the reorder buffer
|
||||||
printf("### queue head @ 0x%08x, next=0x%08x\n",
|
printf("### queue head @ 0x%08x, next=0x%08x\n",
|
||||||
|
|
|
@ -30,9 +30,12 @@
|
||||||
|
|
||||||
#include "misc_defns.h"
|
#include "misc_defns.h"
|
||||||
#include "es_defns.h"
|
#include "es_defns.h"
|
||||||
|
#ifndef _WIN32
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include "compat.h"
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
|
3
pcap.h
3
pcap.h
|
@ -34,8 +34,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include "compat.h"
|
||||||
|
|
||||||
|
|
||||||
//! Out of memory.
|
//! Out of memory.
|
||||||
#define PCAP_ERR_OUT_OF_MEMORY (-8)
|
#define PCAP_ERR_OUT_OF_MEMORY (-8)
|
||||||
|
|
|
@ -24,13 +24,12 @@
|
||||||
* ***** END LICENSE BLOCK *****
|
* ***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define TS_PACKET_SIZE 188
|
#define TS_PACKET_SIZE 188
|
||||||
|
@ -43,6 +42,8 @@ static uint8_t *create_out_packet(char *in_data,int in_len,uint16_t pid)
|
||||||
{
|
{
|
||||||
uint8_t *out_packet = malloc(TS_PACKET_SIZE);
|
uint8_t *out_packet = malloc(TS_PACKET_SIZE);
|
||||||
uint8_t *ptr = out_packet;
|
uint8_t *ptr = out_packet;
|
||||||
|
uint16_t flags;
|
||||||
|
uint16_t flags_pid;
|
||||||
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -53,7 +54,7 @@ static uint8_t *create_out_packet(char *in_data,int in_len,uint16_t pid)
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
/* Transport Error Indicator */
|
/* Transport Error Indicator */
|
||||||
uint16_t flags = 0<<15;
|
flags = 0<<15;
|
||||||
|
|
||||||
/* Payload Unit Start Indicator */
|
/* Payload Unit Start Indicator */
|
||||||
flags = flags | 0<<14;
|
flags = flags | 0<<14;
|
||||||
|
@ -61,7 +62,7 @@ static uint8_t *create_out_packet(char *in_data,int in_len,uint16_t pid)
|
||||||
/* Transport Priority */
|
/* Transport Priority */
|
||||||
flags = flags | 0<<13;
|
flags = flags | 0<<13;
|
||||||
|
|
||||||
uint16_t flags_pid = flags | pid;
|
flags_pid = flags | pid;
|
||||||
TO_BE16(flags_pid,ptr);
|
TO_BE16(flags_pid,ptr);
|
||||||
ptr+=2;
|
ptr+=2;
|
||||||
|
|
||||||
|
@ -76,16 +77,18 @@ static uint8_t *create_out_packet(char *in_data,int in_len,uint16_t pid)
|
||||||
|
|
||||||
assert((ptr-TS_PACKET_SIZE) == out_packet);
|
assert((ptr-TS_PACKET_SIZE) == out_packet);
|
||||||
|
|
||||||
int i;
|
|
||||||
ptr = out_packet;
|
|
||||||
DBG_INFO(("Packet to be written is:\n"));
|
|
||||||
for (i=0;i<TS_PACKET_SIZE;i++)
|
|
||||||
{
|
{
|
||||||
if (!(i%16)) DBG_INFO(("\n"));
|
int i;
|
||||||
|
ptr = out_packet;
|
||||||
|
DBG_INFO(("Packet to be written is:\n"));
|
||||||
|
for (i=0;i<TS_PACKET_SIZE;i++)
|
||||||
|
{
|
||||||
|
if (!(i%16)) DBG_INFO(("\n"));
|
||||||
|
|
||||||
DBG_INFO(("%02x ",ptr[i]));
|
DBG_INFO(("%02x ",ptr[i]));
|
||||||
|
}
|
||||||
|
DBG_INFO(("\n\n"));
|
||||||
}
|
}
|
||||||
DBG_INFO(("\n\n"));
|
|
||||||
|
|
||||||
return out_packet;
|
return out_packet;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +145,7 @@ static off_t get_file_size(int file)
|
||||||
|
|
||||||
static int num_char_in_string(char *string,char c)
|
static int num_char_in_string(char *string,char c)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
int a=0;
|
int a=0;
|
||||||
|
|
||||||
for (i=0; i<strlen(string);i++)
|
for (i=0; i<strlen(string);i++)
|
||||||
|
@ -259,6 +262,9 @@ int main(int argc, char **argv)
|
||||||
if (!strcmp("-p",argv[argno]))
|
if (!strcmp("-p",argv[argno]))
|
||||||
{
|
{
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
char * position_string;
|
||||||
|
int pos_index;
|
||||||
|
|
||||||
++argno;
|
++argno;
|
||||||
|
|
||||||
free(positions);
|
free(positions);
|
||||||
|
@ -271,8 +277,8 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char * position_string = strtok(argv[argno],":");
|
position_string = strtok(argv[argno],":");
|
||||||
int pos_index=0;
|
pos_index=0;
|
||||||
DBG_INFO(("Adding new packets at\n"));
|
DBG_INFO(("Adding new packets at\n"));
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
54
tsreport.c
54
tsreport.c
|
@ -81,6 +81,8 @@ struct stream_data {
|
||||||
int stream_type;
|
int stream_type;
|
||||||
int had_a_pts;
|
int had_a_pts;
|
||||||
int had_a_dts;
|
int had_a_dts;
|
||||||
|
int last_cc;
|
||||||
|
int cc_dup_count;
|
||||||
|
|
||||||
uint64_t first_pts;
|
uint64_t first_pts;
|
||||||
uint64_t first_dts;
|
uint64_t first_dts;
|
||||||
|
@ -93,6 +95,8 @@ struct stream_data {
|
||||||
int err_pts_lt_dts;
|
int err_pts_lt_dts;
|
||||||
int err_dts_lt_prev_dts;
|
int err_dts_lt_prev_dts;
|
||||||
int err_dts_lt_pcr;
|
int err_dts_lt_pcr;
|
||||||
|
int err_cc_error;
|
||||||
|
int err_cc_dup_error;
|
||||||
|
|
||||||
struct diff_from_pcr pcr_pts_diff;
|
struct diff_from_pcr pcr_pts_diff;
|
||||||
struct diff_from_pcr pcr_dts_diff;
|
struct diff_from_pcr pcr_dts_diff;
|
||||||
|
@ -173,6 +177,7 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
||||||
stats[ii].pcr_dts_diff.min = LONG_MAX;
|
stats[ii].pcr_dts_diff.min = LONG_MAX;
|
||||||
stats[ii].pcr_pts_diff.max = LONG_MIN;
|
stats[ii].pcr_pts_diff.max = LONG_MIN;
|
||||||
stats[ii].pcr_dts_diff.max = LONG_MIN;
|
stats[ii].pcr_dts_diff.max = LONG_MIN;
|
||||||
|
stats[ii].last_cc = -1;
|
||||||
}
|
}
|
||||||
predict.min_pcr_error = LONG_MAX;
|
predict.min_pcr_error = LONG_MAX;
|
||||||
predict.max_pcr_error = LONG_MIN;
|
predict.max_pcr_error = LONG_MIN;
|
||||||
|
@ -240,8 +245,6 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
||||||
int adapt_len, payload_len;
|
int adapt_len, payload_len;
|
||||||
int got_pcr = FALSE;
|
int got_pcr = FALSE;
|
||||||
uint64_t acc_pcr = 0; // The accurate PCR per TS packet
|
uint64_t acc_pcr = 0; // The accurate PCR per TS packet
|
||||||
int continuity_counter; //lorenzo
|
|
||||||
static int prev_continuity_counter = 16;
|
|
||||||
|
|
||||||
if (max > 0 && count >= (uint32_t)max)
|
if (max > 0 && count >= (uint32_t)max)
|
||||||
{
|
{
|
||||||
|
@ -352,26 +355,41 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
||||||
|
|
||||||
index = pid_index(stats,num_streams,pid);
|
index = pid_index(stats,num_streams,pid);
|
||||||
|
|
||||||
//lorenzo - start
|
if (index != -1)
|
||||||
if (continuity_cnt_pid == pid)
|
|
||||||
{
|
{
|
||||||
continuity_counter = (int)(packet[3] & 0xF);
|
// Do continuity counter checking
|
||||||
if (continuity_counter == 15)
|
int cc = packet[3] & 15;
|
||||||
fprintf(file_cnt, "%d \n", continuity_counter);
|
if (stats[index].last_cc > 0)
|
||||||
else
|
|
||||||
fprintf(file_cnt, "%d ", continuity_counter);
|
|
||||||
|
|
||||||
if (prev_continuity_counter != 16 )
|
|
||||||
{
|
{
|
||||||
if ( ((prev_continuity_counter+1)%16) != continuity_counter )
|
// We are allowed 1 dup packet
|
||||||
|
// *** Could check that it actually is a dup...
|
||||||
|
if (stats[index].last_cc == cc)
|
||||||
{
|
{
|
||||||
printf("- Discontinuity in continuity_counter at " OFFSET_T_FORMAT "\n",posn);
|
if (stats[index].cc_dup_count++ != 0)
|
||||||
fprintf(file_cnt, " [Discontinuity] ");
|
{
|
||||||
|
if (stats[index].err_cc_dup_error++ == 0)
|
||||||
|
{
|
||||||
|
printf("### PID(%d): Continuity Counter >1 duplicate %d at " OFFSET_T_FORMAT "\n",
|
||||||
|
stats[index].pid, cc, posn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise CC must go up by 1 mod 16
|
||||||
|
stats[index].cc_dup_count = 0;
|
||||||
|
if (((stats[index].last_cc + 1) & 15) != cc)
|
||||||
|
{
|
||||||
|
if (stats[index].err_cc_error++ == 0)
|
||||||
|
{
|
||||||
|
printf("### PID(%d): Continuity Counter discontinuity %d->%d at " OFFSET_T_FORMAT "\n",
|
||||||
|
stats[index].pid, stats[index].last_cc, cc, posn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev_continuity_counter = continuity_counter;
|
stats[index].last_cc = cc;
|
||||||
}
|
}
|
||||||
//lorenzo - end
|
|
||||||
|
|
||||||
if (index != -1 && payload && payload_unit_start_indicator)
|
if (index != -1 && payload && payload_unit_start_indicator)
|
||||||
{
|
{
|
||||||
|
@ -616,6 +634,10 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
||||||
fmtx_timestamp(stats[ii].first_dts, tfmt_abs),
|
fmtx_timestamp(stats[ii].first_dts, tfmt_abs),
|
||||||
fmtx_timestamp(stats[ii].dts, tfmt_abs));
|
fmtx_timestamp(stats[ii].dts, tfmt_abs));
|
||||||
|
|
||||||
|
if (stats[ii].err_cc_error != 0)
|
||||||
|
printf(" ### CC error * %d\n", stats[ii].err_cc_error);
|
||||||
|
if (stats[ii].err_cc_dup_error != 0)
|
||||||
|
printf(" ### CC duplicate error * %d\n", stats[ii].err_cc_dup_error);
|
||||||
if (stats[ii].err_pts_lt_dts != 0)
|
if (stats[ii].err_pts_lt_dts != 0)
|
||||||
printf(" ### PTS < DTS * %d\n", stats[ii].err_pts_lt_dts);
|
printf(" ### PTS < DTS * %d\n", stats[ii].err_pts_lt_dts);
|
||||||
if (stats[ii].err_dts_lt_prev_dts != 0)
|
if (stats[ii].err_dts_lt_prev_dts != 0)
|
||||||
|
|
Ładowanie…
Reference in New Issue