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

📄 logic

📁 linux下将各类格式图片转换工具
💻
字号:
This file describes (a little) how the program works.PARALLEL MODE-------------In parallel mode, two processes run on the machine where you invokePpmtompeg: the master server and the combine server.  Sometimes, there'sa third process called a decode server, but I don't know what that's foryet.Other processes, which are typically on separate machines, one permachine, are called encoder processes.  The code normally calls these"child" processes and the documentation normally calls them "slave"processes.  We really should fix that.The master server's job is to feed work assignments to the encoderprocesses.  A work assignment is a set of frames to encode.The combine server's job is to take the encoded output from the encoderprocesses and combine them into a single MPEG movie.The master process is the first process that exists.  The first thingit does is create the combine server.  Then it creates the encoderprocesses.  It creates each encoder process with an initialassignment.  The master process then waits in a loop for an encoderprocess to report that it has finished its assignment and gives a newassignment to it.The master process and the combine process both have a listening TCPport.  They choose an available port number.  When the master servercreates the combine server, it passes the master server's TCP listenport number to the combine server.  It then waits to hear from thecombine process what TCP listen port it has chosen.  The combineserver connects to the master server's listen port and tells it.  Themaster server then passes to each encode server, as it creates it,the TCP listen ports of both the master server and the combine server.When the combine server has processed all the frames, it shuts down.It connects to the master server TCP listen port and tells the masterserver it is shutting down.When an encoder server finishes a frame, it connects to the combineserver's TCP listen port and tells the combine server that the frameis ready.When an encoder server finishes an assignment, it connects to the masterserver TCP listen port and tells the master it is done, and receives overthe same connetion its next assignment.  If there is no more work to do,the master server instead tells the encoder server just to terminate.When the master server has told every encoder server to terminate, itwaits for the combine server to say that it has terminated.  The masterserver then terminates.To create the combine server, the master server forks and execs'ppmtompeg' with the -output_server option.To create an encoder server, the master server invokes Ssh (or somethinglike it) and tells the remote shell to execute 'ppmtompeg' with the-child option.The various processes communicate frame data via a shared filesystem(e.g. NFS).  An encoder server grabs the input frames from the sharedfilesystem and writes the encoded frames to it.  The combine servergrabs the encoded frames from it and writes the MPEG movie file to it.The encoded frames go in individual files.  The combine server deleteseach file after it has copied it to the MPEG movie file.  Use theKEEP_TEMP_FILES parameter file statement to keep them around for debugging.There's also an alternative "remote I/O" method of communication thatdoesn't require a shared filesystem.  I haven't studied that.The master server and combine server code are in parallel.c.  Theencoder server code is roughly the same as what the single encoderprocess executes when you aren't running in parallel mode.THE ENCODING PROCEDURE----------------------Encoding is done by ppmtompeg.c, which calls GenMPEGStream in mpeg.c todo most of the work.The encoder goes through the input frames in movie sequence.  But theframes don't go into an MPEG stream in movie sequence.  A B frame notonly can't be encoded without the subsequent I or P frame (referenceframe); it can't be decoded without it either.  So in the MPEG stream,B frames come immediately after the reference frame which comesimmediately after the B frames in the actual movie.When the input is from a sequential stream (the only way that's possibletoday is with Standard Input), the encoder saves up B frame input untilafter it has encoded and output the post reference frame.  It doesthis by chaining the input frames to the pre reference frame.  We reallyshould clean this up so that a single module handles input of all kindsand presents only a sequential stream to the encoder.  The encoder shouldnot have special cases for the different types of input.  That inputmodule would let the encoder ask from Frame N even if the input issequential.  The input module would buffer frames from the sequentialinput as necessary.In parallel mode, the combine server takes encoded frames from theencoder servers as it comes.  It can be in any order.  The combineserver knows which frames go where in the output stream and outputs themin the proper order.  This is important for two reasons.  First, theencoder servers don't finish assignments in the same order in which theyget them.  Second, when an encoder server gets an assignment that endswith a B frame, the combine server has to wait for the encoder serverthat has the next assignment to produce the post reference frame beforethe combine server can do anything with that trailing B frame.genMPEGStream() encodes a frame at a time, but it inserts a streamheader and GOP headers where they belong.  genMPEGStream() operates inthree modes: Whole Stream, GOP, and Just Frames.  In Whole Streammode, it inserts all the required headers.  In GOP mode, it insertsGOP headers but not the stream header.  In Just Frames mode, itinserts no headers at all.  In parallel mode, genMPEGStream generatesone frame per file, and only Just Frames mode makes any sense.  Wereally should fix this up so that the encoder always works in JustFrames mode and a GOP builder module takes the encoder's output andsplices it with GOP headers and a stream builder module takes the GOPbuilder's output and adds it to a stream header.  In parallel mode,the combine server would run the GOP builder and stream buildermodules.

⌨️ 快捷键说明

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