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

📄 multplex.cpp

📁 传输流分析
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        if (which_streams & STREAMS_AUDIO1) {                sprintf(tmpStr, "    Audio stream 2 data rate : %d bytes/sec (%u bits/sec)", audio1_rate, audio1_rate << 3);                DisplayInfo(tmpStr);        }        if (!user_mux_rate) {                sprintf(tmpStr, "    Overhead data rate : %d bytes/sec (%u bits/sec)", (unsigned int) dmux_rate - data_rate, ((unsigned int)dmux_rate - data_rate) << 3);                DisplayInfo(tmpStr);        }        sprintf(tmpStr, "    Total data rate : %d bytes/sec (%u bits/sec)", (unsigned int) dmux_rate, (unsigned int)dmux_rate << 3);        DisplayInfo(tmpStr);        DisplayInfo(" ");        sprintf(tmpStr, "  Multiplexing file %s", programFilename);        DisplayInfo(tmpStr);        if (OutputStats)                status_header(programFilename);        rearm_sys_header = FALSE;        second_data_packet = FALSE;        total_counter = audio_total + audio1_total + video_total;        oldPercent = -1;        while ((video_au.length + audio_au.length + audio1_au.length) > 0) {                if ((start_new_file || restart_output) &&                                (audio_restart_output || !audio_au.length) &&                                (audio1_restart_output || !audio1_au.length)) {                        if (start_new_file) {                                if (!end_program_stream(clock_cycles + clock_inc + extra_clock_cycles, vpacket_data_size,                                                        mux_rate, video_info, audio_underflows, audio1_underflows,                                                        nsec_a, nsec_a1, nsec_v, nsec_p, outputFile, &video_buffer,                                                        &audio_buffer, &audio1_buffer, FALSE))                                        goto exit1;                                if (!open_next_file())                                        goto exit1;                                bytes_output = (uint)(sector_size * sectors_per_sec *                                                      sectors_delay / 1000);                                DisplayInfo(" ");                                sprintf(tmpStr, "  Multiplexing file %s", programFilename);                                DisplayInfo(tmpStr);                                if (OutputStats)                                        status_header(programFilename);                        } else                                output_on = 1;                        if (reset_clocks) {                                clock_cycles = delay;                                extra_clock_cycles = 0.0;                                if (which_streams & STREAMS_AUDIO) {                                        audio_PTS = get_timecode(&audio_au.PTS);                                        audio_delay = (audio_PTS - start_video_PTS) - (audio_PTS - first_audio_PTS - org_audio_delay);                                        audio_PTS += audio_delay;                                        make_timecode(audio_delay, &SCR_audio_delay);                                        make_timecode(audio_PTS, &audio_au.PTS);                                }                                if (which_streams & STREAMS_AUDIO1) {                                        audio1_PTS = get_timecode(&audio1_au.PTS);                                        audio1_delay = (audio1_PTS - start_video_PTS) - (audio1_PTS - first_audio1_PTS - org_audio1_delay);                                        audio1_PTS += audio1_delay;                                        make_timecode(audio1_delay, &SCR_audio1_delay);                                        make_timecode(audio1_PTS, &audio1_au.PTS);                                }                                video_DTS = get_timecode(&video_au.DTS);                                video_PTS = get_timecode(&video_au.PTS);                                video_delay = -(video_DTS - first_video_DTS - org_video_delay);                                video_DTS += video_delay;                                video_PTS += video_delay;                                make_timecode(video_delay, &SCR_video_delay);                                make_timecode(video_DTS, &video_au.DTS);                                make_timecode(video_PTS, &video_au.PTS);                                buffer_empty(&video_buffer);                                buffer_empty(&audio_buffer);                                buffer_empty(&audio1_buffer);                        } else {                                add_to_timecode(&SCR_video_delay, &video_au.DTS);                                add_to_timecode(&SCR_video_delay, &video_au.PTS);                                add_to_timecode(&SCR_audio_delay, &audio_au.PTS);                                add_to_timecode(&SCR_audio1_delay, &audio1_au.PTS);                                clock_cycles += clock_inc;                        }                        vcd_sys_header = 0;                        video_underflows = 0;                        audio_underflows = 0;                        audio1_underflows = 0;                        first_audio = 1;                        first_audio1 = 1;                        current_sector = 0;                        rearm_sys_header = FALSE;                        second_data_packet = FALSE;                        nsec_a = 0;                        nsec_a1 = 0;                        nsec_v = 0;                        nsec_p = 0;                        output_sys_header = TRUE;                        audio_PSTD = TRUE;                        audio1_PSTD = TRUE;                        video_PSTD = TRUE;                        write_pack = packets_per_pack;                        do_broken_link = set_broken_link;                        if (((video_au.flags & SEQHDR_FLAG) == 0) && (video_info->sh_length)) {                                video_au.length += video_info->sh_length;                                video_au.pict_hdr_offset += video_info->sh_length;                                do_sequence_header = 1;                        }                        start_new_file = 0;                        restart_output = 0;                        audio_restart_output = 0;                        audio1_restart_output = 0;                }                if (AbortMPEG)                        goto exit1;                i = video_counter + audio_counter + audio1_counter;                percent = (int)(floor(((double) (i)) / ((double) total_counter) * 100.0));                if (percent != oldPercent) {                        sprintf(tmpStr, "Multiplexing: %d%% - %d of %d  A/V units.", percent, (int)i, (int)total_counter);                        DisplayProgress(tmpStr, percent);                        oldPercent = percent;                }                if (mplex_type == MPEG_VCD)                        second_data_packet = (current_sector == 3);                if (mplex_type == MPEG_DVD) {                        if (video_au.type != IFRAME)                                rearm_sys_header = TRUE;                }                if (write_pack-- == packets_per_pack)                        marker_pack = TRUE;                else                        marker_pack = FALSE;                if (write_pack == 0)                        write_pack = packets_per_pack;                if (current_sector) {                        clock_cycles += clock_inc;                        if (VBR_multiplex) {                                if (extra_clock_cycles > 0.0) {                                        k = (int)floor(extra_clock_cycles / clock_inc) - 1;                                        if (k > 0)                                                extra_clock_cycles = (double)k * clock_inc;                                        else                                                extra_clock_cycles = 0.0;                                }                        }                }                audio_PTS = get_timecode(&audio_au.PTS);                if (!audio_frame_start)                        audio_PTS += audio_frame_clocks;                audio1_PTS = get_timecode(&audio1_au.PTS);                if (!audio1_frame_start)                        audio1_PTS += audio1_frame_clocks;                video_DTS = get_timecode(&video_au.DTS);                if (VBR_multiplex) {                        if (extra_clock_cycles > 0.0) {                                temp_cycles = extra_clock_cycles;                                switch (which_streams) {                                case STREAMS_V_A:                                        if (audio_au.length)                                                if (clock_cycles + temp_cycles > audio_PTS - CLOCK_TICKS_100MS) {                                                        while (clock_cycles + temp_cycles > audio_PTS - CLOCK_TICKS_100MS)                                                                temp_cycles -= clock_inc;                                                        temp_cycles += clock_inc;                                                }                                        break;                                case STREAMS_V_A1:                                        if (audio1_au.length)                                                if (clock_cycles + temp_cycles > audio1_PTS - CLOCK_TICKS_100MS) {                                                        while (clock_cycles + temp_cycles > audio1_PTS - CLOCK_TICKS_100MS)                                                                temp_cycles -= clock_inc;                                                        temp_cycles += clock_inc;                                                }                                        break;                                case STREAMS_V_A_A1:                                        if (audio_au.length)                                                if (clock_cycles + temp_cycles > audio_PTS - CLOCK_TICKS_100MS) {                                                        while (clock_cycles + temp_cycles > audio_PTS - CLOCK_TICKS_100MS)                                                                temp_cycles -= clock_inc;                                                        temp_cycles += clock_inc;                                                }                                        if (audio1_au.length)                                                if (clock_cycles + temp_cycles > audio1_PTS - CLOCK_TICKS_100MS) {                                                        while (clock_cycles + temp_cycles > audio1_PTS - CLOCK_TICKS_100MS)                                                                temp_cycles -= clock_inc;                                                        temp_cycles += clock_inc;                                                }                                        break;                                }                                if (temp_cycles > 0.0) {                                        clock_cycles += temp_cycles;                                        extra_clock_cycles -= temp_cycles;                                } else                                        extra_clock_cycles = 0.0;                        }                }                audio_next_clock_cycles = clock_cycles;                audio1_next_clock_cycles = clock_cycles;                video_next_clock_cycles = clock_cycles;                audio_state = 0;                audio1_state = 0;                video_state = 0;                if (start_new_file || restart_output || stop_output) {                        make_timecode(clock_cycles + CLOCK_TICKS_100MS, &current_SCR);                        if (which_streams & STREAMS_AUDIO)                                buffer_clean(&audio_buffer, &current_SCR);                        if (which_streams & STREAMS_AUDIO1)                                buffer_clean(&audio1_buffer, &current_SCR);                        if (which_streams & STREAMS_VIDEO)                                buffer_clean(&video_buffer, &current_SCR);                        make_timecode(clock_cycles, &current_SCR);                        if ((which_streams & STREAMS_AUDIO) && (audio_au.length) &&                                        (!audio_restart_output) &&                                        (buffer_space(&audio_buffer) >= (int)apacket_data_size))                                audio_state = 1;                        if ((which_streams & STREAMS_AUDIO1) && (audio1_au.length) &&                                        (!audio1_restart_output) &&                                        (buffer_space(&audio1_buffer) >= (int)apacket_data_size))                                audio1_state = 1;                } else {                        make_timecode(clock_cycles, &current_SCR);                        if (which_streams & STREAMS_AUDIO)                                buffer_clean(&audio_buffer, &current_SCR);                        if (which_streams & STREAMS_AUDIO1)                                buffer_clean(&audio1_buffer, &current_SCR);                        if (which_streams & STREAMS_VIDEO)                                buffer_clean(&video_buffer, &current_SCR);                        if ((buffer_space(&video_buffer) >= (int)vpacket_data_size) &&                                        (video_au.length > 0) &&                                        (video_DTS - video_next_clock_cycles < CLOCK_TICKS_1000MS))                                video_state = 1;                        if ((which_streams & STREAMS_AUDIO) && (audio_au.length) &&                                        (buffer_space(&audio_buffer) >= (int)apacket_data_size) &&                                        ((audio_PTS - audio_next_clock_cycles < CLOCK_TICKS_100MS) ||                                         ((audio_next_clock_cycles > CLOCK_TICKS_100MS) && (first_audio)))) {                                first_audio = 0;                                audio_state = 1;                        }                        if ((which_streams & STREAMS_AUDIO1) && (audio1_au.length) &&                                        (buffer_space(&audio1_buffer) >= (int)apacket_data_size) &&                                        ((audio1_PTS - audio1_next_clock_cycles < CLOCK_TICKS_100MS) ||                                         ((audio1_next_clock_cycles > CLOCK_TICKS_100MS) && (first_audio1)))) {                                first_audio1 = 0;                                audio1_state = 1;                        }                }                if ((!always_sys_header) && (output_sys_header)) {                        if (mplex_type == MPEG_DVD) {                                /* write out private stream 2 packet with the one and only system header */

⌨️ 快捷键说明

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