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

📄 multplex.cpp

📁 传输流分析
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                                if (!output_private2(&current_SCR, mux_rate))                                        goto exit1;                        } else {                                if ((mplex_type == MPEG_VCD) && (current_sector == 1))                                        i = apacket_data_size;                                else                                        i = vpacket_data_size;                                /* write out padding packet with the one and only system header */                                if (!output_padding(&current_SCR, &pack, &sys_header, mux_rate,                                                    i - SYS_HEADER_SIZE, marker_pack, which_streams))                                        goto exit1;                        }                        /* status info */                        if (OutputStats && output_on)                                status_info(nsec_a, nsec_a1, nsec_v, ++nsec_p, bytes_output,                                            buffer_space(&video_buffer),                                            buffer_space(&audio_buffer),                                            buffer_space(&audio1_buffer));                        write_pack = packets_per_pack;                } else                        /* CASE: Video Buffer OK, Video Data ready		*/                        /*       Audio Data will arrive on time			*/                        if (video_state && !audio_state && !audio1_state && !second_data_packet) {                                if (rearm_sys_header && picture_start && (video_au.type == IFRAME)) {                                        rearm_sys_header = FALSE;                                        if (put_private2) {                                                /* write out private stream 2 packet with the one and only system header */                                                if (!output_private2(&current_SCR, mux_rate))                                                        goto exit1;                                        } else {                                                /* write out padding packet with the one and only system header */                                                if (!output_padding(&current_SCR, &pack, &sys_header, mux_rate,                                                                    vpacket_data_size - SYS_HEADER_SIZE,                                                                    marker_pack, which_streams))                                                        goto exit1;                                        }                                        /* status info */                                        if (OutputStats && output_on)                                                status_info(nsec_a, nsec_a1, nsec_v, ++nsec_p, bytes_output,                                                            buffer_space(&video_buffer),                                                            buffer_space(&audio_buffer),                                                            buffer_space(&audio1_buffer));                                        write_pack = packets_per_pack;                                } else {                                        /* write out video packet */                                        if (!output_video(&current_SCR, &SCR_video_delay, vunits_info,                                                          istream_v, &pack, &sys_header,                                                          &video_buffer, &video_au, &picture_start,                                                          mux_rate, vpacket_data_size,                                                          marker_pack, which_streams,                                                          video_info->sh_length, &video_info->seq_hdr[0]))                                                goto exit1;                                        if (mplex_type != MPEG_VCD) // && (mplex_type != MPEG_SVCD))                                                video_PSTD = FALSE;                                        /* status info */                                        if (OutputStats && output_on)                                                status_info(nsec_a, nsec_a1, ++nsec_v, nsec_p, bytes_output,                                                            buffer_space(&video_buffer),                                                            buffer_space(&audio_buffer),                                                            buffer_space(&audio1_buffer));                                }                        }                /* CASE: Audio Buffer OK, Audio Data ready		*/                /*	 Video Data will arrive on time			*/                        else                                if ((audio_state || second_data_packet) && !audio1_state) {                                        /* write out audio packet */                                        if (!output_audio(&current_SCR, &SCR_audio_delay, aunits_info,                                                          istream_a, &pack, &sys_header,                                                          &audio_buffer, &audio_au, &audio_frame_start,                                                          &audio_counter, &audio_underflows, audio_PSTD,                                                          audio_id, audio_subid,                                                          audio_buffer_scale, audio_buffer_size1, mux_rate,                                                          apacket_data_size, marker_pack, which_streams, &audio_restart_output))                                                goto exit1;                                        if (mplex_type != MPEG_VCD) // && (mplex_type != MPEG_SVCD))                                                audio_PSTD = FALSE;                                        /* status info */                                        if (OutputStats && output_on)                                                status_info(++nsec_a, nsec_a1, nsec_v, nsec_p, bytes_output,                                                            buffer_space(&video_buffer),                                                            buffer_space(&audio_buffer),                                                            buffer_space(&audio1_buffer));                                }                /* CASE: Audio1 Buffer OK, Audio1 Data ready		*/                /*	 Video Data will arrive on time			*/                                else                                        if (audio1_state) {                                                /* write out audio packet */                                                if (!output_audio(&current_SCR, &SCR_audio1_delay, aunits1_info,                                                                  istream_a1, &pack, &sys_header,                                                                  &audio1_buffer, &audio1_au, &audio1_frame_start,                                                                  &audio1_counter, &audio1_underflows, audio1_PSTD,                                                                  audio1_id, audio1_subid,                                                                  audio1_buffer_scale, audio1_buffer_size1, mux_rate,                                                                  apacket_data_size, marker_pack, which_streams, &audio1_restart_output))                                                        goto exit1;                                                if (mplex_type != MPEG_VCD) // && (mplex_type != MPEG_SVCD))                                                        audio1_PSTD = FALSE;                                                /* status info */                                                if (OutputStats && output_on)                                                        status_info(nsec_a, ++nsec_a1, nsec_v, nsec_p, bytes_output,                                                                    buffer_space(&video_buffer),                                                                    buffer_space(&audio_buffer),                                                                    buffer_space(&audio1_buffer));                                        }                /* CASE: Audio Buffer NOT OK				*/                /*	 Video Buffer NOT OK				*/                                        else {                                                if (!VBR_multiplex) {                                                        /* write out padding packet */                                                        if (!output_padding(&current_SCR, &pack, &sys_header, mux_rate,                                                                            vpacket_data_size, marker_pack, which_streams))                                                                goto exit1;                                                }                                                /* status info */                                                if (OutputStats && output_on)                                                        status_info(nsec_a, nsec_a1, nsec_v, ++nsec_p, bytes_output,                                                                    buffer_space(&video_buffer),                                                                    buffer_space(&audio_buffer),                                                                    buffer_space(&audio1_buffer));                                        }                current_sector++;                if (stop_output &                                (!(which_streams & STREAMS_AUDIO) || audio_restart_output) &&                                (!(which_streams & STREAMS_AUDIO1) || audio1_restart_output))                        audio_au.length = audio1_au.length = video_au.length = 0;        }        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, TRUE))                goto exit1;        sprintf(tmpStr, "Multiplexing: 100%% - %d of %d  A/V units.", (int)total_counter, (int)total_counter);        DisplayProgress(tmpStr, 100);        exiterror = FALSE;exit1:        buffer_empty(&video_buffer);        buffer_empty(&audio_buffer);        buffer_empty(&audio1_buffer);        /* close all In- and Outputfiles				*/        if (!outputFile || fileCount > 1)                if (programFile)                        close(programFile);        if ((which_streams & STREAMS_AUDIO) && (aunits_info))                fclose (aunits_info);        if ((which_streams & STREAMS_AUDIO1) && (aunits1_info))                fclose (aunits1_info);        if ((which_streams & STREAMS_VIDEO) && (vunits_info))                fclose (vunits_info);        if ((which_streams & STREAMS_AUDIO) && (istream_a))                fclose (istream_a);        if ((which_streams & STREAMS_AUDIO1) && (istream_a1))                fclose (istream_a1);        if ((which_streams & STREAMS_VIDEO) && (istream_v))                fclose (istream_v);        /* delete tmp files	*/        if (mux_SVCD_scan_offsets && svcd_info) {                fclose(svcd_info);                unlink (svcd_name);        }        if (which_streams & STREAMS_VIDEO)                unlink (video_units);        if (which_streams & STREAMS_AUDIO)                unlink (audio_units);        return !exiterror;}static int open_next_file(){        char tmpStr[MAXPATH];        pFileNumPtr[1] += 1;        if (pFileNumPtr[1] > '9') {                pFileNumPtr[0] += 1;                pFileNumPtr[1] = '0';        }        programFile = open(programFilename, O_WRONLY| O_CREAT| O_TRUNC,                           S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);        if (programFile <= 0) {                sprintf(tmpStr, "Unable to open program file %s: %s.",                        programFilename, strerrno());                DisplayError(tmpStr);                return 0;        }        if (mux_SVCD_scan_offsets) {                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);                        return 0;                }        }        fileCount++;        return 1;}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){        unsigned long i, j;        unsigned char* index;        Timecode_struc current_SCR;        char tmpStr[MAXPATH];        if (write_pec && (last_file || write_end_codes)) {                /* write out END CODE	*/                index = sector.buf;                if ((mplex_type == MPEG_VCD) ||                                (mplex_type > MPEG_MPEG2)) {                        make_timecode(clock_cycles, &current_SCR);                        *(index++) = (unsigned char)((PACK_START)>>24);                        *(index++) = (unsigned char)((PACK_START & 0x00ff0000)>>16);                        *(index++) = (unsigned char)((PACK_START & 0x0000ff00)>>8);                        *(index++) = (unsigned char)(PACK_START & 0x000000ff);                        if (mplex_type > MPEG_VCD) {                                buffer_timecode(&current_SCR, MPEG2_MARKER_SCR, &index);                                *(index++) = (unsigned char)(mux_rate >> 14);                                *(index++) = (unsigned char)(0xff & (mux_rate >> 6));                                *(index++) = (unsigned char)(0x03 | ((mux_rate & 0x3f) << 2));                                *(index++) = (RESERVED_BYTE << 3) & 0xFF;                        } else {                                buffer_timecode(&current_SCR, MPEG1_MARKER_SCR, &index);                                *(index++) = (unsigned char)(0x80 | (mux_rate >> 15));                                *(index++) = (unsigned char)(0xff & (mux_rate >> 7));                                *(index++) = (unsigned char)(0x01 | ((mux_rate & 0x7f) << 1));                        }                        *(index++) = (unsigned char)(PACKET_START) >> 16;                        *(index++) = (unsigned char)(PACKET_START & 0x00ffff) >> 8;                        *(index++) = (unsigned char)(PACKET_START & 0x0000ff);                        *(index++) = PADDING_STR;                        if (mplex_type > MPEG_VCD)                                i = packet_data_size + MPEG2_AFTER_PACKET_LENGTH - 4;                        else                                i = packet_data_size + MPEG1_AFTER_PACKET_LENGTH - 4;                        *(index++) = (unsigned char)(i >> 8);                        *(index++) = (unsigned char)(i & 0xff);                        if (mplex_type < MPEG_MPEG2) {                                *(index++) = 0x0F;

⌨️ 快捷键说明

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