⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multplex.cpp

📁 传输流分析
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include <sys/types.h>#include <unistd.h>#include "main.h"#include "consts1.h"/******************************************************************	Main multiplex iteration.	Opens and closes all needed files and manages the correct	call to the respective Video- and Audio- packet routines.	The basic multiplexing is done here. Buffer capacity and	Timestamp checking is also done here, decision is taken	wether we should genereate a Video-, Audio- or Padding-	packet.******************************************************************/#define CLOCK_TICKS_100MS   2700000.0#define CLOCK_TICKS_250MS   6750000.0#define CLOCK_TICKS_500MS  13500000.0#define CLOCK_TICKS_1000MS 27000000.0static unsigned int bytes_output;static int fileCount;static char programFilename[MAXPATH], *pFileNumPtr;static HANDLE programFile;static Sector_struc sector;static double extra_clock_cycles;static int output_sys_header;static unsigned int vcd_sys_header;static unsigned long video_buffer_size;static unsigned char audio_id, audio1_id;static unsigned char audio_buffer_scale, audio1_buffer_scale;static unsigned int audio_buffer_size1, audio1_buffer_size1;static unsigned char video_PSTD;static unsigned int video_counter;static unsigned int video_underflows;/* the following is used to generate SVCD scan info */static unsigned int current_sector;static FILE *svcd_info;static char *svcd_name;static unsigned int max_file_size_GOP, start_time, stop_time;static char start_new_file;static char restart_output;static char stop_output;static char output_on;static char do_broken_link;static char do_sequence_header;static double start_video_PTS;static int embed_svcd_scan_info(Video_struc *video_info);static int open_next_file();static int end_program_stream(double clock_cycles, unsigned long packet_data_size,                              unsigned int mux_rate, Video_struc *video_info,                              unsigned int audio_underflows, unsigned int audio1_underflows,                              unsigned int nsec_a, unsigned int nsec_a1,                              unsigned int nsec_v, unsigned int nsec_p,                              HANDLE outputFile, Buffer_struc *video_buffer,                              Buffer_struc *audio_buffer, Buffer_struc *audio1_buffer,                              int last_file);int outputstream (        HANDLE          outputFile,        char 		*video_units,        Video_struc 	*video_info,        char 		*audio_units,        Audio_struc 	*audio_info,        char 		*audio1_units,        Audio_struc 	*audio1_info,        unsigned int video_total,        unsigned int audio_total,        unsigned int audio1_total,        unsigned int    which_streams){        FILE *istream_v;			/* Inputstream Video	*/        FILE *istream_a;			/* Inputstream Audio	*/        FILE *istream_a1;                     /* Second audio stream  */        FILE *vunits_info;			/* Input Video Units	*/        FILE *aunits_info;			/* Input Audio Units	*/        FILE *aunits1_info;                   /* Input Audio1 units   */        Vaunit_struc video_au;		/* Video Access Unit	*/        Aaunit_struc audio_au;		/* Audio Access Unit	*/        Aaunit_struc audio1_au;               /* Audio1 Access Unit   */        unsigned int data_rate=0;		/* AudioVideo Byterate	*/        unsigned int video_rate=0;        unsigned int audio_rate=0;        unsigned int audio1_rate = 0;        double delay,audio_delay,audio1_delay,video_delay;        double clock_cycles, temp_cycles;        double audio_next_clock_cycles;        double audio1_next_clock_cycles;        double video_next_clock_cycles;        double dmux_rate;        unsigned int mux_rate;        unsigned char picture_start;        unsigned char audio_frame_start;        unsigned char audio1_frame_start;        unsigned int audio_state, audio1_state, video_state;        unsigned int nsec_a=0;        unsigned int nsec_a1=0;        unsigned int nsec_v=0;        unsigned int nsec_p=0;        Timecode_struc SCR_audio_delay;        Timecode_struc SCR_audio1_delay;        Timecode_struc SCR_video_delay;        Timecode_struc current_SCR;        double audio_PTS, audio1_PTS, video_DTS, video_PTS;        Buffer_struc video_buffer;        Buffer_struc audio_buffer;        Buffer_struc audio1_buffer;        Pack_struc 		pack;        Sys_header_struc 	sys_header;        unsigned int audio_buffer_size, audio1_buffer_size;        unsigned char audio_PSTD, audio1_PSTD;        unsigned int audio_counter, audio1_counter;        unsigned char audio_subid, audio1_subid;        unsigned int audio_underflows, audio1_underflows;        unsigned long min_packet_data;        unsigned long write_pack;        unsigned char marker_pack;        unsigned long vpacket_data_size, apacket_data_size;        unsigned long i, total_counter, rearm_sys_header;        int percent, oldPercent;        char tmpStr[256];        int exiterror = FALSE;        int second_data_packet;        double sectors_per_sec, clock_inc, clock_inc_2;        double audio_frame_clocks, audio1_frame_clocks;        double first_audio_PTS=0, first_audio1_PTS=0, first_video_PTS=0, first_video_DTS=0;        double org_video_delay=0, org_audio_delay=0, org_audio1_delay=0;        int first_audio, first_audio1, k;        char audio_restart_output, audio1_restart_output;        output_sys_header = TRUE;        audio_PSTD = TRUE;        audio1_PSTD = TRUE;        video_PSTD = TRUE;        istream_v = NULL;        istream_a = NULL;        istream_a1 = NULL;        vunits_info = NULL;        aunits_info = NULL;        aunits1_info = NULL;        programFile = 0;        exiterror = TRUE;        video_counter = 0;        audio_counter = 0;        audio1_counter = 0;        audio_buffer_scale = 0;        audio1_buffer_scale = 0;        vcd_sys_header = 0;        video_underflows = 0;        audio_underflows = 0;        audio1_underflows = 0;        audio_id = 0;        audio1_id = 0;        audio_subid = 0;        audio1_subid = 0;        first_audio = 1;        first_audio1 = 1;        start_new_file = 0;        restart_output = 0;        audio_restart_output = 0;        audio1_restart_output = 0;        start_video_PTS = 0;        output_on = 1;        do_broken_link = 0;        do_sequence_header = 0;        stop_output = 0;        memset(&video_buffer, 0, sizeof(video_buffer));        memset(&audio_buffer, 0, sizeof(audio_buffer));        memset(&audio1_buffer, 0, sizeof(audio1_buffer));        /* svcd stuff */        current_sector = 0;        svcd_info = NULL;        /* Open in- and outputstream				*/        if (which_streams & STREAMS_VIDEO) {                if ((istream_v = fopen (VideoFilename, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open video file %s: %s.",                                VideoFilename, strerrno());                        DisplayError(tmpStr);                        return FALSE;                }        }        if (which_streams & STREAMS_AUDIO) {                if ((istream_a = fopen(AudioFilename, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open audio file %s: %s.",                                AudioFilename, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        if (which_streams & STREAMS_AUDIO1) {                if ((istream_a1 = fopen(Audio1Filename, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open secondary audio file %s: %s.",                                Audio1Filename, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        if (which_streams & STREAMS_VIDEO) {                if ((vunits_info = fopen (video_units, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open video units file %s: %s.",                                video_units, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        if (which_streams & STREAMS_AUDIO) {                if ((aunits_info = fopen (audio_units, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open audio units file %s: %s.",                                audio_units, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        if (which_streams & STREAMS_AUDIO1) {                if ((aunits1_info = fopen (audio1_units, "rb")) == NULL) {                        sprintf(tmpStr, "Unable to open secondary audio units file %s: %s.",                                audio1_units, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        if (mux_SVCD_scan_offsets) {                svcd_name = tempnam("./","tmp_s");                if ((svcd_info = fopen(svcd_name, "wb")) == NULL) {                        sprintf(tmpStr, "Unable to open SVCD scan offsets temporary file %s: %s.", svcd_name, strerrno());                        DisplayError(tmpStr);                        goto exit1;                }        }        strcpy(programFilename, ProgramFilename);        //  strlwr(programFilename);        fileCount = 1;        pFileNumPtr = NULL;        if (max_file_size || !outputFile) {                if (max_file_size) {                        pFileNumPtr = strstr(programFilename, "00");                        if (!pFileNumPtr) {                                pFileNumPtr = strrchr(programFilename, '.');                                if (pFileNumPtr) {                                        pFileNumPtr[0] = '0';                                        pFileNumPtr[1] = '0';                                        pFileNumPtr[2] = 0;                                        pFileNumPtr = strrchr(ProgramFilename, '.');                                        strcat(programFilename, pFileNumPtr);                                } else                                        strcat(programFilename, "00");                                pFileNumPtr = strstr(programFilename, "00");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -