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)\bitdata.obj \
|
||||
$(OBJDIR)\es.obj \
|
||||
$(OBJDIR)\ethernet.obj \
|
||||
$(OBJDIR)\filter.obj \
|
||||
$(OBJDIR)\fmtx.obj \
|
||||
$(OBJDIR)\h222.obj \
|
||||
$(OBJDIR)\h262.obj \
|
||||
$(OBJDIR)\ipv4.obj \
|
||||
$(OBJDIR)\l2audio.obj \
|
||||
$(OBJDIR)\misc.obj \
|
||||
$(OBJDIR)\nalunit.obj \
|
||||
$(OBJDIR)\ps.obj \
|
||||
$(OBJDIR)\pcap.obj \
|
||||
$(OBJDIR)\pes.obj \
|
||||
$(OBJDIR)\pidint.obj \
|
||||
$(OBJDIR)\ps.obj \
|
||||
$(OBJDIR)\reverse.obj \
|
||||
$(OBJDIR)\ts.obj \
|
||||
$(OBJDIR)\tswrite.obj
|
||||
|
@ -118,7 +121,7 @@ PROG_OBJS = \
|
|||
$(OBJDIR)/esreport.obj \
|
||||
$(OBJDIR)/esreverse.obj \
|
||||
$(OBJDIR)/m2ts2ts.obj \
|
||||
$(OBJDIR)/pcapreport.obj \
|
||||
$(OBJDIR)/pcapreport.obj \
|
||||
$(OBJDIR)/ps2ts.obj \
|
||||
$(OBJDIR)/psdots.obj \
|
||||
$(OBJDIR)/psreport.obj \
|
||||
|
@ -169,6 +172,9 @@ $(EXEDIR)\m2ts2ts.exe: $(OBJDIR)\m2ts2ts.obj $(LIBFILE)
|
|||
$(EXEDIR)\stream_type.exe: $(OBJDIR)\stream_type.obj $(LIBFILE)
|
||||
link /out:$@ $(LOPT) $** wsock32.lib
|
||||
|
||||
$(EXEDIR)\pcapreport.exe: $(OBJDIR)\pcapreport.obj $(LIBFILE)
|
||||
link /out:$@ $(LOPT) $** wsock32.lib
|
||||
|
||||
$(EXEDIR)\psreport.exe: $(OBJDIR)\psreport.obj $(LIBFILE)
|
||||
link /out:$@ $(LOPT) $** wsock32.lib
|
||||
|
||||
|
|
21
compat.h
21
compat.h
|
@ -39,17 +39,21 @@
|
|||
// Kill deprecation warnings
|
||||
#pragma warning( 4: 4996 )
|
||||
|
||||
#include <io.h>
|
||||
|
||||
// Windows doesn't seem to supply <stdint.h>, so we shall have to try
|
||||
// for values we hope work
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
|
||||
typedef short int16_t;
|
||||
typedef long int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_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 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
|
||||
// expect, so do so
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Keep "byte" for historical/affectionate reasons
|
||||
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 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)
|
||||
printf("\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"
|
||||
"\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);
|
||||
if (err) return err;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "compat.h"
|
||||
|
||||
#include "pcap.h"
|
||||
|
||||
|
|
2
ipv4.h
2
ipv4.h
|
@ -30,7 +30,7 @@
|
|||
#ifndef _ipv4_h
|
||||
#define _ipv4_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include "compat.h"
|
||||
|
||||
/*! This is all held in host byte order (including the
|
||||
* IP addresses! You have been warned .. )
|
||||
|
|
|
@ -210,7 +210,7 @@ static int extract_packets(int input, FILE * output,
|
|||
(unsigned int)(packet_buffer->next));
|
||||
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
|
||||
printf("### queue head @ 0x%08x, next=0x%08x\n",
|
||||
|
|
|
@ -30,9 +30,12 @@
|
|||
|
||||
#include "misc_defns.h"
|
||||
#include "es_defns.h"
|
||||
#ifndef _WIN32
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "compat.h"
|
||||
#include <winsock2.h>
|
||||
#endif // _WIN32
|
||||
|
||||
|
|
3
pcap.h
3
pcap.h
|
@ -34,8 +34,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
//! Out of memory.
|
||||
#define PCAP_ERR_OUT_OF_MEMORY (-8)
|
||||
|
|
|
@ -24,13 +24,12 @@
|
|||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "compat.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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 *ptr = out_packet;
|
||||
uint16_t flags;
|
||||
uint16_t flags_pid;
|
||||
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
@ -53,7 +54,7 @@ static uint8_t *create_out_packet(char *in_data,int in_len,uint16_t pid)
|
|||
ptr++;
|
||||
|
||||
/* Transport Error Indicator */
|
||||
uint16_t flags = 0<<15;
|
||||
flags = 0<<15;
|
||||
|
||||
/* Payload Unit Start Indicator */
|
||||
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 */
|
||||
flags = flags | 0<<13;
|
||||
|
||||
uint16_t flags_pid = flags | pid;
|
||||
flags_pid = flags | pid;
|
||||
TO_BE16(flags_pid,ptr);
|
||||
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);
|
||||
|
||||
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]));
|
||||
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(("\n\n"));
|
||||
}
|
||||
DBG_INFO(("\n\n"));
|
||||
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
int a=0;
|
||||
|
||||
for (i=0; i<strlen(string);i++)
|
||||
|
@ -259,6 +262,9 @@ int main(int argc, char **argv)
|
|||
if (!strcmp("-p",argv[argno]))
|
||||
{
|
||||
char *endptr;
|
||||
char * position_string;
|
||||
int pos_index;
|
||||
|
||||
++argno;
|
||||
|
||||
free(positions);
|
||||
|
@ -271,8 +277,8 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
char * position_string = strtok(argv[argno],":");
|
||||
int pos_index=0;
|
||||
position_string = strtok(argv[argno],":");
|
||||
pos_index=0;
|
||||
DBG_INFO(("Adding new packets at\n"));
|
||||
while(1)
|
||||
{
|
||||
|
|
56
tsreport.c
56
tsreport.c
|
@ -81,6 +81,8 @@ struct stream_data {
|
|||
int stream_type;
|
||||
int had_a_pts;
|
||||
int had_a_dts;
|
||||
int last_cc;
|
||||
int cc_dup_count;
|
||||
|
||||
uint64_t first_pts;
|
||||
uint64_t first_dts;
|
||||
|
@ -93,6 +95,8 @@ struct stream_data {
|
|||
int err_pts_lt_dts;
|
||||
int err_dts_lt_prev_dts;
|
||||
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_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_pts_diff.max = LONG_MIN;
|
||||
stats[ii].pcr_dts_diff.max = LONG_MIN;
|
||||
stats[ii].last_cc = -1;
|
||||
}
|
||||
predict.min_pcr_error = LONG_MAX;
|
||||
predict.max_pcr_error = LONG_MIN;
|
||||
|
@ -240,9 +245,7 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
|||
int adapt_len, payload_len;
|
||||
int got_pcr = FALSE;
|
||||
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)
|
||||
{
|
||||
printf("Stopping after %d packets (PMT was at %d)\n",max,pmt_at);
|
||||
|
@ -352,26 +355,41 @@ static int report_buffering_stats(TS_reader_p tsreader,
|
|||
|
||||
index = pid_index(stats,num_streams,pid);
|
||||
|
||||
//lorenzo - start
|
||||
if (continuity_cnt_pid == pid)
|
||||
if (index != -1)
|
||||
{
|
||||
continuity_counter = (int)(packet[3] & 0xF);
|
||||
if (continuity_counter == 15)
|
||||
fprintf(file_cnt, "%d \n", continuity_counter);
|
||||
else
|
||||
fprintf(file_cnt, "%d ", continuity_counter);
|
||||
|
||||
if (prev_continuity_counter != 16 )
|
||||
// Do continuity counter checking
|
||||
int cc = packet[3] & 15;
|
||||
if (stats[index].last_cc > 0)
|
||||
{
|
||||
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);
|
||||
fprintf(file_cnt, " [Discontinuity] ");
|
||||
if (stats[index].cc_dup_count++ != 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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].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)
|
||||
printf(" ### PTS < DTS * %d\n", stats[ii].err_pts_lt_dts);
|
||||
if (stats[ii].err_dts_lt_prev_dts != 0)
|
||||
|
|
Ładowanie…
Reference in New Issue