www.pudn.com > avi 到 mpeg 的转换程序及源代码.zip > MPLEX.C


/************************************************************************* 
*  MPEG SYSTEMS MULTIPLEXER                                              * 
*  Erzeugen einer MPEG/SYSTEMS                           		 * 
*  MULTIPLEXED VIDEO/AUDIO DATEI					 * 
*  aus zwei MPEG Basis Streams						 * 
*  Christoph Moar							 * 
*  SIEMENS ZFE ST SN 11 / T SN 6					 * 
*  (C) 1994 1995    							 * 
************************************************************************** 
*  Generating a MPEG/SYSTEMS						 * 
*  MULTIPLEXED VIDEO/AUDIO STREAM					 * 
*  from two MPEG source streams						 * 
*  Christoph Moar							 * 
*  SIEMENS CORPORATE RESEARCH AND DEVELOPMENT ST SN 11 / T SN 6		 * 
*  (C) 1994 1995							 * 
************************************************************************** 
*  Einschraenkungen vorhanden. Unterstuetzt nicht gesamten MPEG/SYSTEMS  * 
*  Standard. Haelt sich i.d.R. an den CSPF-Werten, zusaetzlich (noch)    * 
*  nur fuer ein Audio- und/oder ein Video- Stream. Evtl. erweiterbar.    * 
************************************************************************** 
*  Restrictions apply. Will not support the whole MPEG/SYSTEM Standard.  * 
*  Basically, will generate Constrained System Parameter Files.		 * 
*  Mixes only one audio and/or one video stream. Might be expanded.	 * 
*************************************************************************/ 
 
/************************************************************************* 
*  mplex - MPEG/SYSTEMS multiplexer					 * 
*  Copyright (C) 1994 1995 Christoph Moar				 * 
*  Siemens ZFE ST SN 11 / T SN 6					 * 
*									 * 
*  moar@informatik.tu-muenchen.de 					 * 
*       (Christoph Moar)			 			 * 
*  klee@heaven.zfe.siemens.de						 * 
*       (Christian Kleegrewe, Siemens only requests)			 * 
*									 * 
*  This program is free software; you can redistribute it and/or modify	 * 
*  it under the terms of the GNU General Public License as published by	 *	 
*  the Free Software Foundation; either version 2 of the License, or	 * 
*  (at your option) any later version.					 * 
*									 * 
*  This program is distributed in the hope that it will be useful,	 * 
*  but WITHOUT ANY WARRANTY; without even the implied warranty of	 * 
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	 * 
*  GNU General Public License for more details.				 * 
*									 * 
*  You should have received a copy of the GNU General Public License	 * 
*  along with this program; if not, write to the Free Software		 * 
*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		 * 
*************************************************************************/ 
 
/************************************************************************* 
*  Notwendige Systemmittel:						 * 
*  Festplattenspeicher fuer Quell- und Zielstreams, pro Minute 		 * 
*  MPEG/SYSTEMS Stream noch zusaetzlich 50-100 kByte tmp Plattenspeicher * 
************************************************************************** 
*  Necessary resources:							 * 
*  Hard Disk space for source and destination streams, per Minute	 * 
*  MPEG/SYSTEM stream an additional 50-100 kByte tmp Diskspace		 * 
*************************************************************************/ 
 
/* 
 * 4/4/97 - John Schlichther 
 * 
 * extensively altered to create avi2mpg1 - avi to mpeg-1 encoder 
 * 
 * Since avi file, and the avi subsystem are platform dependant, cross 
 * platform compatibility removed, many optional features disabled or 
 * removed, code generally trimmed to a minimum. 
 * 
 */ 
#include "mplex.h" 
 
extern unsigned int audio_time_out; 
extern unsigned int video_time_out; 
extern unsigned int audio_end_early; 
extern unsigned int video_end_early; 
 
/************************************************************************* 
    Main 
*************************************************************************/ 
 
#ifdef TIMER 
    long total_sec = 0; 
    long total_usec = 0; 
    long global_sec = 0; 
    long global_usec = 0; 
    struct timeval  tp_start; 
    struct timeval  tp_end; 
    struct timeval  tp_global_start; 
    struct timeval  tp_global_end; 
#endif 
 
int mplex (vfile, afile, mfile) 
 
char *vfile, *afile, *mfile; 
{ 
    char 	*audio_file = NULL; 
    char        *video_file = NULL; 
    char        *multi_file = NULL;	 
 
    char	*video_units = NULL; 
    char	*audio_units = NULL; 
 
    Video_struc video_info; 
    Audio_struc audio_info; 
    unsigned int audio_bytes, video_bytes; 
    unsigned int which_streams=0; 
    double	startup_delay=0; 
 
	audio_time_out = 0; 
	video_time_out = 0; 
	audio_end_early = 0; 
	video_end_early = 0; 
 
    check_files (vfile, afile, mfile, &audio_file, &video_file, &multi_file, 
		 &audio_bytes, &video_bytes, &which_streams); 
 
    empty_video_struc (&video_info); 
    empty_audio_struc (&audio_info); 
     
    if (which_streams & STREAMS_VIDEO) { 
	video_units=tempnam ("./","tmp_v"); 
	get_info_video (video_file, video_units, &video_info, &startup_delay, 
			video_bytes); 
    } 
 
    if (which_streams & STREAMS_AUDIO) { 
	audio_units=tempnam ("./","tmp_a"); 
	get_info_audio (audio_file, audio_units, &audio_info, &startup_delay, 
			audio_bytes); 
    } 
 
    outputstream (video_file, video_units, &video_info, 
		  audio_file, audio_units, &audio_info, multi_file, which_streams ); 
 
    return (0);	 
}