CA2071975C - Media pipeline system - Google Patents

Media pipeline system

Info

Publication number
CA2071975C
CA2071975C CA002071975A CA2071975A CA2071975C CA 2071975 C CA2071975 C CA 2071975C CA 002071975 A CA002071975 A CA 002071975A CA 2071975 A CA2071975 A CA 2071975A CA 2071975 C CA2071975 C CA 2071975C
Authority
CA
Canada
Prior art keywords
media data
buffer
audio
data
media
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
CA002071975A
Other languages
French (fr)
Other versions
CA2071975A1 (en
Inventor
Eric C. Peters
Stanley Rabinowitz
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Avid Technology Inc
Original Assignee
Avid Technology Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Avid Technology Inc filed Critical Avid Technology Inc
Publication of CA2071975A1 publication Critical patent/CA2071975A1/en
Application granted granted Critical
Publication of CA2071975C publication Critical patent/CA2071975C/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/23406Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving management of server-side video buffer
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11BINFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
    • G11B27/00Editing; Indexing; Addressing; Timing or synchronising; Monitoring; Measuring tape travel
    • G11B27/005Reproducing at a different information rate from the information rate of recording
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11BINFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
    • G11B27/00Editing; Indexing; Addressing; Timing or synchronising; Monitoring; Measuring tape travel
    • G11B27/02Editing, e.g. varying the order of information signals recorded on, or reproduced from, record carriers
    • G11B27/031Electronic editing of digitised analogue information signals, e.g. audio or video signals
    • G11B27/034Electronic editing of digitised analogue information signals, e.g. audio or video signals on discs
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11BINFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
    • G11B27/00Editing; Indexing; Addressing; Timing or synchronising; Monitoring; Measuring tape travel
    • G11B27/10Indexing; Addressing; Timing or synchronising; Measuring tape travel
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/236Assembling of a multiplex stream, e.g. transport stream, by combining a video stream with other content or additional data, e.g. inserting a URL [Uniform Resource Locator] into a video stream, multiplexing software data into a video stream; Remultiplexing of multiplex streams; Insertion of stuffing bits into the multiplex stream, e.g. to obtain a constant bit-rate; Assembling of a packetised elementary stream
    • H04N21/2368Multiplexing of audio and video streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/4302Content synchronisation processes, e.g. decoder synchronisation
    • H04N21/4307Synchronising the rendering of multiple content streams or additional data on devices, e.g. synchronisation of audio on a mobile phone with the video output on the TV screen
    • H04N21/43072Synchronising the rendering of multiple content streams or additional data on devices, e.g. synchronisation of audio on a mobile phone with the video output on the TV screen of multiple content streams on the same device
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/432Content retrieval operation from a local storage medium, e.g. hard-disk
    • H04N21/4325Content retrieval operation from a local storage medium, e.g. hard-disk by playing back content from the storage medium
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/434Disassembling of a multiplex stream, e.g. demultiplexing audio and video streams, extraction of additional data from a video stream; Remultiplexing of multiplex streams; Extraction or processing of SI; Disassembling of packetised elementary stream
    • H04N21/4341Demultiplexing of audio and video streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/439Processing of audio elementary streams
    • H04N21/4398Processing of audio elementary streams involving reformatting operations of audio signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/44004Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving video buffer management, e.g. video decoder buffer or video display buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/633Control signals issued by server directed to the network components or client
    • H04N21/6332Control signals issued by server directed to the network components or client directed to client
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/65Transmission of management data between client and server
    • H04N21/654Transmission by server directed to the client
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • H04N5/91Television signal processing therefor
    • H04N5/93Regeneration of the television signal or of selected parts thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • H04N5/91Television signal processing therefor
    • H04N5/93Regeneration of the television signal or of selected parts thereof
    • H04N5/937Regeneration of the television signal or of selected parts thereof by assembling picture element blocks in an intermediate store
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/79Processing of colour television signals in connection with recording
    • H04N9/80Transformation of the television signal for recording, e.g. modulation, frequency changing; Inverse transformation for playback
    • H04N9/802Transformation of the television signal for recording, e.g. modulation, frequency changing; Inverse transformation for playback involving processing of the sound signal

Abstract

The invention is a data pipeline system (10) which synchronizes the display of digitized audio and video data regardless of the speed at which the data was recorded on its linear medium (12). To do this, the video data is played at a constant speed, syn-chronized by the audio speed. Further, the invention uses a method of "staging" data in storage buffers, i.e., ring buffers (18), which encorages efficient use of the viewer module resources by not permitting the viewer to read excessive amounts of data at any one time, i.e., to read only enough data into any one ring buffer (18) so that the amount of data in the ring buffer (18) is roughly equivalent to the amount of the other ring buffers (18) and yet permitting the viewer to read large enough chunks of data to promote efficient use of the fill system.

Description

2~7 19~ PCT/US90/07~2 MEDIA PIPELINE SYSTEM

Back~round of the Invention The invention relates to displaying non-linear media data, i.e., digitized audio and video data.
Non-linear media data is audio and video data recorded on a linear medium, e.g., a VHS videotape cassette, and stored in digitized form on a computer storage device, e.g., a hard disk drive. Typically, linear audio data is recorded with a "pulse" equal to the speed at which the linear video data is recorded. That is, if the video data is recorded at 30 frames per second (fps), the accompanying audio data is likewise recorded at 30 fps. This is obviously the case where the audio and video data are recorded simultaneously on a single medium, e.g., a single videotape cassette. However, the recording of the audio data can be distinct from the recording of the video data, e.g, a soundtrack can be recorded in London and a film clip can be shot on location in the Sahara Desert, in which case the speed of recording the video and the audio may or may not be equal. In addition, the stAn~rd speeds for filming video and recording audio vary from country to country. For example, the st~nA~rd speed for recording video in the United States is 30 fps, while the standard speed in Europe is 24 fps. Likewise, the audio sampling rate st~nA~d is 22 kHz, but 44 kHz is also used. Thus, in cases where the speeds are different, the two recordings (often referred to as media "c~nnels") must be effectively combined and displayed so that there are no visible or audible gaps or over1aps.

- 2 - ~7197~
As noted above, the speed at whlch vldeo data ls recorded and dlsplayed can vary, e.g., from 30 fps to 24 fps.
Vldeo data from dlfferent countrles, however, can be successfully edlted together and played at a slngle speed because the human eye cannot detect subtle varlatlons ln the number of frames per second. The human ear, however, can detect even subtle varlatlons ln the speed at whlch audlo data ls played. These varlatlons appear as audlble cllcks, sllences, or other dlstortlons. Over tlme, dlfferences ln the speed at whlch the vldeo data ls dlsplayed and the audlo data are played results ln vlslbly and audlbly mlsmatched vldeo and audlo data.
Summary of the Inventlon In accordance wlth the present lnventlon there ls provlded a medla plpellne system for dlsplaylng dlgltlzed audlo and vldeo, comprlslng: a medla flle database for acceptlng and maklng avallable a plurallty of medla flles, at least one of sald medla flles havlng dlgltlzed audlo medla data and at least another one of sald medla flles havlng vldeo medla data, each of sald medla flles belng dlvlded lnto a plurallty of frames; a plurallty of rlng buffers; a vlewer module comprlslng procedures to synchronlze the transfer of medla data from the medla flles lnto sald plurallty of rlng buffers, sald rlng buffers storlng the medla data before lt ls dlsplayed; a vldeo accelerator connected to recelve an output of at least one of sald rlng buffers for generatlng a vldeo dlsplay output; and a sound accelerator connected to recelve an output of at least one of sald rlng buffers for - 2a _ 2071 975 generatlng an audlo output.
In accordance wlth the present lnventlon there ls also provlded a system for playlng dlgltlzed medla data, comprlslng: a medla flle database for acceptlng and maklng avallable a plurallty of medla flles, at least one of sald medla flles contalnlng dlgltlzed audlo medla data and at least one of sald medla flles contalnlng dlgltlzed vldeo medla data, each of sald medla flles organlzed ln a plurallty of frames; at least one buffer array havlng an lnput recelvlng sald medla data and havlng an output provldlng such medla data; a module comprlsing means to synchronlze a transfer of sald medla data from the medla flles lnto sald at least one buffer array, sald at least one buffer array storlng the medla data before the medla data ls played; a vldeo dlsplay generator connected to recelve the output of the at least one buffer array for generatlng a vldeo dlsplay output; and a sound generator connected to recelve the output of the at least one buffer array for generatlng an audlo output.
In accordance wlth the present lnventlon there ls further provlded a method of playlng dlgltlzed medla data on a monltor, comprlslng the steps of: storlng the medla data ln a plurallty of medla flles and a plurallty of buffer memorles, wlth at least one of sald medla flles contalnlng vldeo medla data and at least one of sald medla flles contalnlng audlo medla data; ldentlfylng at least one of the buffer memorles contalnlng approxlmately the least amount of medla data; readlng sald medla data from at least one of the 207 ~ 975 - 2b -medla flles lnto at least one of sald buffer memorles contalnlng approxlmately the least amount of medla data;
slgnallng a sound generator whlch plays at least a part of the audlo media data contalned ln at least one of the buffer memorles; waltlng for an lnterrupt from the sound generator;
after recelvlng the lnterrupt from the sound generator, slgnallng a vldeo dlsplay generator whlch plays at least part of the vldeo medla data found ln at least one of the buffer memorles.
In accordance wlth the present lnventlon there 18 also provlded a method of playing dlgltlzed medla data, comprlslng the steps of: storlng the medla data ln a medla flle database that accepts and makes avallable a plurallty of medla flles, at least one of sald medla flles contalnln.~
dlgltlzed audlo medla data and at least one of sald medla flles contalnlng dlgltlzed vldeo medla data; organlzlng each of sald medla flles lnto a plurallty of frames;
synchronlzlng a transfer of sald medla data from the medla flies lnto at least one buffer array whereln the at least one buffer array stores the medla data before lt ls played;
generatlng a vldeo dlsplay output from at least a part of said vldeo medla data ln the at least one buffer array wlth a vldeo dlsplay generator; and generatlng an audlo output from at least a part of sald audlo medla data ln the at least one buffer array wlth a sound generator.
In accordance wlth the present lnventlon there ls further provlded a system for playlng dlgltlzed medla data, comprlslng: a medla data flle database for acceptlng and -. 64371-41 ~ ,~. , ~

2 ~ 5 - 2c -maklng avallable a plurallty of media data flles, at least one of sald medla data flles contalnlng dlgltlzed audlo medla data and at least one of sald medla data flles contalnlng dlgltlzed vldeo medla data, each of sald medla data flles organlzed ln a plurallty of frames; a plurallty of buffers, each havlng an lnput recelvlng sald medla data and havlng an output provldlng sald medla data; means for staglng medla data from the medla flles lnto the buffers, sald buffers storlng the medla data before the medla data ls played;
a vldeo dlsplay generator connected to recelve the output of the at least one buffer for generatlng a vldeo dlsplay output; and a sound generator connected to recelve the output of the at least one buffer for generatlng an audlo output.
In accordance wlth the present lnventlon there ls further provlded a system for playlng dlgltlzed medla data, comprlslng: a medla flle database for acceptlng and maklng avallable at least one of sald medla data flles contalnlng dlgltlzed audlo medla data and at least one of sald medla data flles contalnlng dlgltlzed vldeo medla data, each of sald medla flles belng organlzed ln a plurallty of frames;
a plurallty of buffers, each havlng an lnput recelvlng sald medla data and havlng an output provldlng sald medla data;
means for readlng medla data from at least one medla flle lnto each buffer such that an amount of audlo medla data ln one buffer ls approxlmately equlvalent to the amount of medla data ln another buffer, sald buffers storlng the medla data before the medla data ls played; a vldeo dlsplay generator - 2d - 207 1 97~
connected to receive the output of the at least one buffer for generatlng a video dlsplay output; and a sound generator connected to recelve the output of the at least one buffer for generatlng an audlo output.
In accordance wlth the present lnventlon there ls provlded a method of playlng dlgltlzed medla data, comprlslng the step of: storlng the medla data ln a medla flle database that accepts and makes avallable a plurallty of medla flles, at least one of sald medla flles contalnlng dlgltlzed audlo media data and at least one of sald medla flles contalnlng dlgltlzed vldeo medla data; dlvldlng each of sald medla flles lnto a plurallty of frames; synchronlzlng a transfer of sald media data from the medla flles lnto a plurallty of rlng buffers whereln said ring buffers store the medla data before lt ls played; generatlng a vldeo dlsplay output from at least a part of sald vldeo medla data ln at least one of sald plurallty of rlng buffers wlth a video accelerator; and generatlng an audlo output from at least a part of sald audlo medla data ln at least one of said plurality of ring buffers wlth a sound accelerator.
The lnventlon ls a data plpellne system whlch synchronlzes the dlsplay of dlgltlzed audlo and vldeo data regardless of the speed at whlch the data was recorded on lts llnear medlum. To do thls, the vldeo data ls played at a constant speed, synchronlzed by the audlo speed. The system lncludes a medla flle database (MFD) that contalns a number of medla flles, each of whlch contalns elther dlgltlzed audlo or dlgltlzed vldeo medla data. The system also lncludes a - 2e - 207 ~ 975 vlewer module whlch synchronlzes operations to transfer the medla data from the medla flles lnto a number of rlng buffers (preferably software). Each rlng buffer ls assoclated wlth a medla channel belng dlsplayed. For example, there ls a rlng buffer whlch contalns medla data for the vldeo channel, a rlng buffer whlch contalns medla data for a flrst audlo channel, and a rlng buffer whlch contalns medla data for a second audlo channel. The two audlo channels are for stereo.
The vlewer module also synchronlzes calls to a vldeo accelerator card and a sound accelerator card so that the vldeo data and audlo data, whlch were recorded on a llnear medlum at dlfferlng pulse .~
~ . ~
3 ~Q-7I g75 PCT/US90/07~2 rates, are displayed at a constant rate without visible or audible gaps or overlaps.
Further, the invention uses a method of "staging"
data in the storage buffers, particularly ring buffers, to coordinate buffer loading to encourage efficient use of the viewer module resources by not permitting the viewer to read eY~e~cive amounts of data at any one time, i.e., to read only enough data into any one ring buffer so that the amount of data in the ring buffer is approximately equivalent to the amount of data in the other ring buffers.
Other advantages and features will become apparent from the following description, and from the claims.
DescriDtion of the Preferred Embodiment Fig. 1 is a block diagram of the components of a pipeline system according to the present invention.
Fig. 2 is a flow chart of the general operation of the system.
Fig. 3 is a flow chart of the specific operation of the PLAY AV pro~eduLe of the system.
Referring to Fig. 1, a pipeline system 10 includes a media file datAhAce (MFD) 12 which contains a number of media files 14a-14n. Each media file 14 contains either digitized audio or digitized video media data and is divided into sections called "frames". In the embodiment here described, one frame of video data is considered equivalent to the sta~Ard U.S. video frame, i.e., a video frame which is displayed for 1/3Oth of a second, regardless of whether it was .e_~ded at 30 fps or some other speed. Similarly, one frame of audio data (also referred to as an "audio buffer"), is stAn~rdized to consist of 735 audio samples, which are played in the time eguivalent of one video frame, i.e., l/30th of a second.

WO91/10323 2 0 7 1 ~ 7 5 PCT/US90/07482 The pipeline system 10 also includes a viewer module 16 which synchronizes the transfer of media data from the media files 14 into three ring buffers 18a-18c which store the data or pointers to the data before it is displayed.
For convenience, the terms "view" and "display" are used herein with respect to audio as well as video and should be understood to mean "play" when referring to audio. Each ring buffer is associated with a media channel. That is, ring buffer 18a contains media data for the video channel, ring buffer 18b contains media data for audio channel 1, and ring buffer 18c contains media data for audio channel 2.
Upon a signal from the viewer module, a pointer to a frame of video data in the ring buffer 18a is transferred to a conventional video accelerator card 20 preferably ~ vlSION~ model NuVista which displays the video data on a monitor 22. Likewise, upon a signal from the viewer module 16, a pointer to a frame of audio data in the ring buffers 18b and 18c is transferred to a conventional sound accelerator card 24 preferably DIGIDESIGN~ model SOUND
ArC~T~ATOR which plays the audio data through the monitor 22. The operation of the system and synchronization of the displaying of video data and playing of audio data is described below in connection with Fig. 2.
~eferring to Fig. 2, the operation of the pipeline system 10 (Fig. 1) is shown in flow chart form. Briefly, because it takes time to read data from the media files, and because typically all of the data will not fit into memory at any one time, the pipeline performs a real time "juggling act" to read from the files at the precise moment the data is required and in such a way as not to interfere with displaying the data in an essentially uninterrupted flow.
To do this, the viewer module determines which channel, i.e., which ring buffer 18, has the least data in it (step WO91/10323 ~7 I 9 75 PCT/US90/07482 100), reads data from a media file 14 into the ring buffer (step 102), and signals the sound accelerator 24 to play the next frames of audio data found in the ring buffers 18b and 18c (step 104). The viewer module 16 then waits for an interrupt from the sound accelerator 24 (step 106) which indicates that it is time to display the next frame of video data. Once the viewer module 16 receives the interrupt from the sound accelerator 24, it signals the video accelerator 20 to play the next video frame found in the buffer 18a (step 108). In this way, the frames of video data are synchronized by the frames of audio data. That is, at the end of every 735 audio samples, a new video frame is displayed. Thus, visible and audible discrepancies between the display of video and audio data are markedly reduced if not eliminated.
In general, "staging" the data in the ring buffers 18 encourages efficient use of the viewer module resources by not permitting the viewer to read excessive amounts of data at any one time, i.e., to read only enough data into any one ring buffer so that the amount of data in the ring buffer is roughly equivalent to the amount of data in the other ring buffers (see steps 254, 260 and 266 in Fig. 3).
The staging process also encourages efficient use of the file system (disks where media is stored) by permitting large efficient reads from the disk when there is time available.
Referring to ~ig. 3, the procedure PLAY AV is shown in flow chart form. The ~Ul~V_~ of PLAY_AV is to fill the ring buffers using the staging method discussed above, and to play a ~equence of frames or "clip" of video and audio data in such a manner that the video data is synchronized by the audio data as ~ eeed above.

WO91/10323 2 0 7 1 g 75 ` PCT/US90/07482 Before PLAY AV is called the system preloads all the ring buffers with data. This considerably improves efficiency since this can be done before the time-critical operations occur.
First, PLAY_AV performs an error check, i.e., determines if the number of frames to be played is zero (step 200). If the number of frames to be displayed is not zero, then PLAY AV performs further error checks, e.g., determines that the audio capability of the monitor 22 is initialized (by checking the value of the Boolean variable AUDIO_INIT DONE) and that the audio data is to be used to synchronize the video data (by checking the value of the Boolean variable SOUND SYNC) (step 202). Next, if there are no errors (step 202), then PLAY AV determines which audio channels are in use (step 204), i.e., from which of the ring buffers 18 audio data will be read. Note that the embodiment deccribed here uses two audio data channels, i.e., audio channel l and audio channel 2. Additional channels and hence additional buffers are of course possible. Fewer rh~nnels (i.e., l) are also permitted.
Having determined which channels are in use, PLAY_AV
next initializes variables for the frames of audio and video data to be displayed (step 206), i.e., assigns a value of 0 to the variables "nextAudiol", "nextAudio2", and "nextVideo". In addition, PLAY AV initializes the end of file marker for the video data ("videoEOF") to FALSE (step 208) and also initializes the end of file markers for the audio data ("audiolEOF" and "audio2EOF") (step 220).
Specifically, if audio c~ el l is being used (step 204) and ~o~Async is TRUE (step 202), then audiolEOF equals FA~SE. Otherwise, audiolEOF equals TRUE. Likewise, if audio channel 2 is being used (step 204) and soundsync is -WO 9l/10323 2 0 7 1 9 7 5 PCr/US90/07482 TRUE (step 202), then audio2EOF equals FALSE. Otherwise, audio2EOF equals TRUE.
Once PLAY AV has determined from which ch~ ls it will read data (steps 204-210), it begins an infinite (while 5 TRUE) loop to read, transfer, and display media data.
PLAY AV does not exit the loop until the clip is exhausted, i.e., there are no more frames to display. At the beginning of each pass through the loop, PL~Y AV initializes several variables, including the maximum number of bytes it will 10 read ("max read") and the number of audio channel 1 and audio ch~nnPl 2 bytes yet to be played ("AbytesUnplayedl"
and "AbytesUnplayed2") (step 212). In addition, PLAY AV
initializes several variables that indicate whether it should "wait", execute a "critical" read, or execute an 15 "efficient" read (step 214) (each of which is described below in more detail), and also initializes a variable "fewest buffers" to MAX LONG (step 216), i.e., a number far larger than the number of bytes in a ring buffer.
Having initialized the loop variables, PLAY AV next 20 determines which of the ring buffers has the least amount of data in it, i.e., which ring buffer has fewer bytes free.
PLI~Y AV begins by checking ring buffer 18b (audio channel 1) as described below.
To determine what the state of ring buffer 18b 25 (audio ch~n~el 1) is, PL~Y AV determines if audiolEOF is FALSE and ring buffer 18b has at least 735 bytes free (step 218). If 80, PI~Y AV goes on to determine if the number of bytes free in ring buffer 18b is less than fewest buffers (step 220) (which is always true initially since 30 fewest buffers was assigned MAX LONG above). The action variable is then assigned a value of "read AUDIOl" (step 222). The critical variable is assigned a value of TRUE if fewest buffers is less than a predefined number WO91/10323 2 0 7 1 g ~ 5 PCT/US90/07482 (AUDIO ALERT BUFS), and is assigned a value of FALSE
otherwise (step 224). And the efficient variable is assigned a value of TRUE if the number of bytes free in ring buffer 18b is greater than or equal to a predefined number (EFFICIENT AUDIO BYTES) and if the size of the next audio frame times the typical audio frame size is greater than or equal to EFFICIENT AUDIO BYTES (step 226). Otherwise the variable efficient is assigned a value of FALSE.
To determine what the state of ring buffer 18c (audio channel 2) is, PLAY AV determines if audio2EOF is FALSE and ring buffer 18c has at least 735 bytes free (step 228). If so, PLAY AV goes on to determine if the number of bytes free in ring buffer 18c is less than fewest buffers (step 230) (i.e., whether ring buffer 18c has fewer bytes than ring buffer 18b as determined above). If ring buffer 18c indeed contains fewer bytes, the action variable is assigned a value of "read AUDIO2" (step 232). The critical variable is assigned a value of TRUE if fewest buffers is less than a predefined number (AUDIO ALERT BUFS), and is assigned a value of FALSE otherwise (step 234). And the efficient variable is assigned a value of TRUE if the number of bytes free in ring buffer 18c is greater than or equal to a predefined number (EFFICIENT AUDIO BYTES) and if the size of the next audio frame times the typical audio frame size is greater than or equal to EFFICIENT AUDIO BYTES (step 236). Otherwise the efficient variable is assigned a value of FALSE.
Finally, to determine what the state of ring buffer 18a (video channel) is, PLAY AV determines if videoEOF is FALSE and ring buffer 18c has at least 1 byte free (step 238). If so, PLAY AV goes on to determine if the number of bytes free in ring buffer 18a is less than fewest_buffers (step 240) (i.e., whether ring buffer 18a has fewer bytes WO91/10323 ~ 7 5 PCT/US90/07482 _ g _ than ring buffer 18c as determined above). If ring buffer 18a indeed contains fewer bytes, the action variable is assigned a value of "read VIDEO" (step 242). The critical variable is assigned a value of TRUE if fewest buffers is less than a predefined number (VIDEO ALERT BUFS), and is assigned a value of FALSE otherwise (step 244). And the efficient variable is assigned a value of TRUE if the number of bytes free in ring buffer 18a is greater than or equal to a predefined number (EFFICIENT VIDEO BUFS) and if the size of the next video frame is greater than or equal to EFFICIENT VIDEO_BUFS (step 246). Otherwise, the efficient variable is assigned a value of FALSE.
Having determined, in steps 218-246, which channel and hence ring buffer has the fewest bytes and therefore should be filled, PLAY AV executes either a critical read operation or an efficient read operation depending on the values assigned to the critical and efficient variables. In addition, the execution of the efficient read operation further depends on two factors: 1) whether there is an upcoming transition between clips, i.e., the end of the current clip is near and the viewer 16 will soon need to retrieve data from a different media file 14; and 2) whether the viewer is coming to an end of the ring buffer from which it is reading. If either of these factors is true, the efficient variable is also true. Thus, if the critical and efficient variables are both FALSE (step 248), PLAY AV
assigns the value of "wait~ to the action variable and checks several other conditions to determine if some other value should be assigned to the action variable (step 250).
(The conditions are ~ Gduced below in Boolean notation below for ease of underst~n~;ng).

WO 91/10323 2 0 ~ 5 PCI/US90/07482 lf ~ csltlcal ~ !efflclent) actlon - walt;
f l!vldeoEOF L~ vbufsFree ~- VID MIN READ
IvbufsFree ~- EFFICIENT VIDEO BUFS) Il ( InextVldeoTA < EFFICIENT_VIDEO BUFS) ~ ~nextVldeoTA ~ 0) ) ) actlon - read VIDEO;

lf ~ac~lon walt ~ !audlolEOF
~arlngl.abytesFree >- 735) ( larlngl.abytesFree ~- EFFiCIENT AUD O ByTEs) 11 ~nextAudlolTA TYPIC~L AUDIO BUFFER SIZE < EFFICIENT AUDIO BYTES) L~ InextAudlol~A ~ 01 ) ) actlon - read AUDIOl;

lf lactlon !- read VIDEO ~ !au~'n~E
~ ~arlng2.abytesFr e >- 735) L~ ~ ~arlng2.abytQsFrQe ~ C~Nl_AD IO_BYTES) I I
~nextAudlo2TA~TYPICAL AUDIO_BUFFER SIZE < EFFICIENT AUDIO BYTES) L~ Yt~ 2TA > 0) ) ) lf lactlon - walt) actlon - re-d AUDI02;
el e t actlon ls read_AUDIOl /
( Could do elther Al or A2 tuff.
Do the one ~lth the ~ost empty rlng buff-r.
lf larlng2.-bytesFree ~ arlngl.abytesFr e) ~ctlon - read_AUDI02;
/- lf not then ctlon ls alre-dy r ad AUDIOl. ~/

nd nalysls for non-cr~t " l non-efflcl-nt reads /

Depending on the outcome of the analysis above, the action variable has one of three-values: read VIDEO, read AUDIOl, or read AUDI02. In the case of read VIDEO, PLAY AV assigns to the variable "vidTrigger" a number of bytes to read from the media file 14 (step 2S2). However, if that number exceeds the number necessary to match the number of bytes contained in the audio channels, PLAY AV
adjusts the number downward (step 254) so that viewer resources are not tied up reading an excessive amount of video data. (See the discussion of staging above.) Finally, PLAY AV retrieves the video bytes from the media file and transfers them to the ring buffer 18a (step 256).
In the case of read_AUDI01, PLAY_AV assigns to the variable max read a number of bytes to read from the media file 14 (258). However, if that number exceeds the number of bytes contained in audio channel 2, PLAY AV adjusts the number downward (step 260) so that viewer resources are not tied up reA~ i ng an excessive amount of audio data. Finally, PLAY AV retrieves the audio bytes from the media file 14 and transfers them to the ring buffer 18b (step 262).
In the case of read AUDIO2, PLAY AV assigns to the variable max read a number of bytes to read from the media file 14 (step 264). However, if that number exceeds the number of bytes contained in audio channel 1, PLAY AV
adjusts the number downward (step 266) so that viewer resou~e_ are not tied up r~A~ing an excessive amount of audio data. Finally, PLAY_AV retrieves the audio bytes from the media file 14 and transfers them to the ring buffer 18c (step 268).
Having determined into which ring buffer to read data and done so (steps 218-268), PLAY_AV next chec~c several conditions which might cause the display to stop (step 270), e.g., the viewer reached the end of file for the WO91/10323 ~ 7 1`~75 PCT/US90/07482 video data, the viewer reached the end of file for the audiol or audio2 data, or the user interrupted the display.
Finally, PLAY AV selects the current frame from one of the ring buffers (step 272), and sends a pointer to the frame to the appropriate hardware (step 274), i.e., the video accelerator card 22 or the sound accelerator card 24 depending on whether the frame is video or audio. The hardware plays the frame (step 276) and then interrupts the software (step 278), i.e., PLAY_AV, which then repeats the above described process.
In order to ensure that the audio and video stay in synch, it is essential that the system read the correct number of audio bytes of data corresponding to the video frame being played. This is especially important where the audio track was digitized independently of the video track.
To ensure synchronization, when any audio is digitized, the system stores away in the audio media file the number of video frames associated with that audio. Then, later, when a request for a certain number of frames of audio is made, the system can form a pLG~oLLion against the original number of video frames and audio bytes to find the correct number of audio bytes needed to agree with the number of video frames in the current request.
To ensure efficiency when playing video that has been ca~LuLed at less than 30 frames per second, the system stores a capture mask with any video media file that has been ca~L~led at this lower rate. The capture mask consists of a sequence of O's and l's. There are m one-bits and a total of n bits all together, to indicate that only m video frames are present out of every n. When playing this video, the system ~lccec~ively rotates this capture mask one bit to the left. If the high order bit is a l, this means this is a new frame and we play it. If the bit is a 0, this means WO91/10323 207~-~75 PCT/US90/07482 this is a repeated frame and we need not play it. The capture mask always ends with a ~, so when it shifts into a word of all 0's, we reload the capture mask.
The attached appendix embodies the viewer module 16 of Fig.
l. The programming language and compiler used are l'~lNK C
version 3.0l by Symantec Corporation, and the computer used is the Macintosh II running under Mac OS version 6Ø2.
Portions of the disclosure of this patent document, including the appendix, contain material which is subject to copyright protection and as to which copyright is claimed.
The copyright owner has no objection to the facsimile reproduction by anyone of the patent document as it appears in the Patent and Trademark Office files, but otherwise lS reserves all copyright rights whatsoever, for example, including but not restricted to the right to load the software on a computer system.
Other emhoAiments are within the following claims.

WO91/10323 ~ 07 1 9 15 PCT/US90/07482 SOURCE CODE APPENDIX

Applicants: Eric C. Peters et al.
Title: MEDIA PIPELINE SYSTEM

WO 91/10323 ~Q 7 I !~ 7 5 PCI`/US90/07482 r . a l?~g-~ond y, D~ 4, 1989 17:01 Module Name: Vlewer.c * Module Descriptlon: Standard routine to vlew audio/vldeo se~lu~nces.
~ / \
I The followlng programs are the sole property of Avld Te~hn~l yy, Inc.,l s I and contaln lts proprletary and c~fld~ntlal lnformatlon. I
I Copyright ~ 1989, Avid Technology Revislon Hlstory:
SLog: Fn11n~ertng PVCS:Sources:vlewer.c v S
Rev 1.56 04 Dec 1989 17:01:12 SJR
force set the audio mocde on play Rev 1.55 01 Dec 1989 22:55:12 stan ~ make abridged reads more efficient by using 0 for frames wanted * Rev 1.54 29 Nov 1989 18:27:40 SJR
dumped mfm get sourcename Rev 1.53 23 Nov 1989 18:23:20 stan change 8000 to long; flx capture mask bugs Rev 1.52 14 Nov 1989 23:05:28 stan allow h~nA~lrAl stuff to play to end even lf audlo differ ln slze Rev 1.51 11 Nov 1989 17:19:22 stan keep track of total number of audlo frames yet to be played Rev 1.50 06 Nov 1989 22:59:16 stan No change.
Rev 1.49 03 Nov 1989 14:26:42 stan ~ audlo reads are not repeatable * Rev 1.48 20 Oct 1989 17:56:50 JLB
Flxed debug prlntf.
Rev 1.47 20 Oct 1989 10:54:28 SJR
Rev 1.46 19 Oct l9B9 16:39:26 JLB
New glst mapplng functlons Rev 1.45 13 Oct 1989 18:32:16 stan use new mfm calls Rev 1.44 27 Sep 1989 16:50:36 stan don't allocate rlnglog untll needed Rev 1.43 27 Sep 1989 16:44:20 stan don't report plpe dry on V-only edlt * Rev 1.42 27 Sep 1989 15:44:20 stan put ltems ln reglsters Rev 1.41 26 Sep 1989 22:11:38 stan general tunlng and abort on true vldeo dry Rev 1.40 26 Sep 1989 18:15:18 stan flx bug wlth black frames Rev 1.39 26 Sep 1989 13:46:12 stan Flx Len's stutter bug - buffer not multlple of 3 Rev 1.38 24 Sep 1989 22:23:44 stan tunlng Rev 1.37 23 Sep 1989 14:27:22 stan WO 91/10323 2 ~ 7 1 ~ 7 ~ PCI`/US90/07482 or . c Pag- 2 ~ond y, D~ 4, 1989 17:01 * remove scr1hh1~Pr from preload ~ Rev 1.36 22 Sep 1989 18:57:52 stan -* add eof flag to getnextav ~ Rev 1.3S 22 Sep 1989 17:55:30 stan * make sure there's a buffer's worth of space avallable ln rlng t Rev 1.34 22 Sep 1989 03:29:36 stan * tunlng and made audlo plpe larger Rev 1.33 21 Sep 1989 18:50:26 stan tune vlewer Rev 1.32 21 Sep 1989 15:00:54 stan flx aud transltlons wlth multlple rhAnnPlS
~ Rev 1.31 18 Sep 1989 17:41:32 stan * add audlo2 EOF
* Rev 1.30 16 Sep 1989 18:27:04 stan ~ Rev 1.29 15 Sep 1989 20:27:34 stan * make vlewer_result global Rev 1.28 lS Sep 1989 16:34:30 stan don't check vldeo posltlon lf no vldeo ln ob~ect Rev 1.27 13 Sep 1989 22:33:02 stan * check buffer polnters only when non-0 Rev 1.26 13 Sep 1989 16:22:14 stan more strlngent error rhp~k1nq; check for scr1hhllnq lnto arlng structure Rev 1.25 12 Sep 1989 22:08:00 stan flxed audlo2 staglng bug ~ Rev 1.24 12 Sep 1989 00:04:22 JHR
* audlo2-only flxes ~ Rev 1.23 07 Sep 1989 00:59:24 stan * handle plpes ln bytes not buffers ~ Rev 1.22 05 Sep 1989 22:14:36 stan * audlo2 stats ~ Rev 1.21 30 Aug 1989 14:27:50 stan * handle two audlo rh~nnPl~ ln one ob~ect ~ Rev 1.20 30 Aug 1989 13:58:58 stan * use OUT_AUDIOl for ~ r~l stuff.
Rev 1.19 28 Aug 1989 21:40:24 stan remove ~Phuqqt nq SS IqeS
~ Rev 1.18 22 Aug 1989 18:00:50 stan * mods for 2 ~h~nnpl~ of audlo ~ Rev 1.15 14 Aug 1989 21:55:42 stan * remove ~iPhuqqinq prlntouts Rev 1.14 14 Aug 1989 17:37:02 stan * allow playlng audlo-only se~ n~e.
~ Rev 1.13 02 Aug 1989 16:47:48 stan * partlal wor~s on new two channel audlo stuf r I Rev 1.12 28 Jul 1989 17:09:50 stan * spllt out plpe dlsplay Rev 1.11 27 Jul 1989 11:59:10 SJR
Ellmlnate references lnto MFILE structures.

WO 91/10323 -17- 2~Q71 !~7S PCI`/US90/07482 r-r . o P~g~ 3 ~ond y, D- '-r 4, 1989 17:01 Rev 1.10 26 Jul 1989 17:56:34 stan spllt out statlstlcs ~ Rev 1.9 14 Jul 1989 17:14:34 stan * partlal flx for nll ob~ect bug Rev 1.8 14 Jul 1989 00:14:48 stan cd quallty stuff Rev 1.7 12 Jul 1989 00:16:38 stan sync audlo changes lt * Rev 1.6 09 Jul 1989 18:35:14 JHR
~ Commented out a couple of prlntf's at the end of SHOW
* Rev 1.5 06 Jul 1989 21:03:06 stan update audlo meadla flle header lnfo Rev 1.4 30 Jun 1989 17:43:54 stan Don't use VISTA lf vlewer ls not entlrely c~nt~1n~d ln vlsta screen.
Rev 1.3 28 Jun 1989 19:01:32 stan some tweaklng to reduce dry count Rev 1.1 27 Jun 1989 22:06:26 stan allow nll sound; allow nll vldeo; flx many bugs ~r Who Date Descrlptlon stan ll-Jun-1989 dlsplay audlo and vldeo plpes stan 7-Jun-1989 add statlstlcs stan 31-May-1989 handle audlo mode stan 30-May-1989 use byte-slzed buffers play audlo lmmedlately after preloadlng lt stan 26-May-1989 swltch lnterrupt routlnes lf run out of audlo and have more vldeo stan 25-May-1989 flx several bugs ln whlch vlewer stlcks on stan 22-May-1989 handle abrldged flles stan/erlc 12-May-1989 handle VISTA code path for capture masks stan/~oe 12-May-1989 remove sync manager calls; add tool manager Stan/Bedell l9-Apr-1989 Add more suppor~ for 24fps stuff ~ Stan 17-Apr-1989 Allow audlo rate to agree wlth frame rate.
t Add routlne set_audlo rate.
Stan 27-Mar-1989 Flxed bug that causes play button to not reset when vldeo gets to the end ~and stlcks there) on systems wlth no vlsta and no sound accelerator.
~/
#lnclude <stdlo.h>
#lnclude ~VRetraceMgr.h>
#lnclude "shell.h"
#lnclude "avld base.h"
#lnclude "lstat.h"
#lnclude "dlsk lo.h"
#lnclude "mfm.ha #lnclude "frames.h"
#lnclude "ob~ect_manager.h"
#lnclude "vlewer.h"
#lnclude "swltcher.h"
#lnclude "ctabrtns.hn #lnclude "host rtn.h"
tlnclude n~ l hn #lnclude "So~n~Tntf.h"
~lnclude "memrtns.h"
~lnclude "toolman.h"
#lnclude ~rutlls.h n #lnclude "VlstaIntf.h"
~lnclude ~Vlsta.h"
~lnclude ~Dlgldeslgn.h"
rlnclude ~macro.h"

WO 91/10323 2 ~ 7 ~ 9 ~ 5 PCr/US90/07482 v~-~-r . a ~g~ 4 ~ond~y, D- '-r 4, 1989 17:01 #lnclude "vlewer stats.h"
~lnclude "vlewer_pvt.h"
/***** Structure Deflnltlons *****/
typedef struct long buffers; /* numher of segments (also known as buffers or frames~ glven to caller */
long bytes loaded; /* number of bytes loaded ln the mfm read */
AudloMode audlo mode; /* mode for thls plece of audlo */
channel t channel; /* channel for this plece of audlo */
) AF sync;
/***** FYternAl P~ 6n~IU~S *****/
/~**** FYt~rnAl VArtahlDS *****/
extern VStat *Vlstat;
extern AStat *Alstat;
extern AStat *A2stat;

/***~* Global vartAhl~5 *****/
AI~A1 nR1 ng arlngl;
AudloRlng arlng2;
frame hdr t *vlewer result - O;
/***** Statlc Var1Ah]ns *****/
statlc Boolean audlo lnlt_done = FALSE;
statlc 3001ean vlewer lnlt_done ~ FALSE;
statlc long new speed;
statlc V3LTask myTask;
statlc long vldeo rate = 30;
statlc 8001ean ob~ect has two audlo rhAnn~ls;
statlc Sound *backup arlngl soun~huf = O, *backup arlng2_so~n~huf = 0; /* for ~hugglng purposes */
statlc Boolean underfl_ ssage ~YplA1n~d = FALSE;
statlc 3001ean overr~lnMPso ~p explalned ~ FALSE;
statlc Boolean dryc~ul~ ssage explalned = FALSE;
/* Statlc VArtAhles for Plng 8uffer r~n,, t */

long apos; /* VOLATILE */
/* frame number ln ob~ect for currently playlng audlo */
lcng C3count; /* Decremented by r~llhac~ routlnes */
/* thls ls the number of lnterrupts left to be processed */
/* l.e. the number of ob~ect frames left to be played */
/* audlo buffer polnters and counts ~/

long TotalVbufs;
long NumVReads;
lnt max audlo queue elements;
lnt audlo underflows;
lnt vldeo underflows;

/* vldeo buffer polnters and counts */
/* lndexes start at O and go to VID_RING_SIZE-l */
lnt vbufHead, /* lndex of next buffer to play */
vbufsUnplayed, /* number of fllled buffers yet to be played ~/
vbufsFree, /* number of free buffers */
vbufTall; /* lnctex of next buffer to flll ~/
lnt VPlpeEmpty;
statlc long frame repeat_count~VID_RING SIZE]; /* how many tlmes to show thls frame ~/

001ean VlstaPresent, UseVlsta; /* For demolng (forces Vls~a not be used) */
3001ean VlstaInUse ~ FALSE; /* True means ln time crltlcal coàe uslng VISTA */
long overrun;

WO 91/10323 ~ I 9 ~ 5 PcI/US90/07482 ~-~-r.o ~g- 5 ~o~d~y, D- ~-r 4, 1989 17:01 long IdleTlcks, TotalTlcks, OtherTlcks;
lonq sbTlcks, mfmTlcks, NumFrames;
extern RlngLog (*rlnglog)[];
extern lnt lognum;
statlc long rlnglog_start_tlme;
statlc long statistlcs-O;
extern long stat_tlmer;
/***** Deflned below *****/
statlc Boolean playAVvlsta ~ob~ect_num_t ob~ect, prevlew parms t *parms, long start, long len, Boolean soundsync, short edltBuf);
statlc Boolean playAVfcb ~ob~ect_num_t ob~ect, prevlew_parms t *parms, long start, long len, short edltBuf);
statlc 3001ean play synch tlmer ~ob~ect num t ob~ect, prevlew parms t *parms, long len, long speed, short edltBuf);
statlc vold play audlo ~Sound *ptr, AF sync *af sync, AudloRlng *arlng);
statlc vold lnltAudloPlpe ~ob~ect_num_t ob~ect, long start, long max length, channel t t~h~nnt~l5~ long total length);
statlc long lnltVldeoPlpe ~ob~ect num t ob~ect, long start, long length);
statlc GatNextAV ~ob~ect num t ob~ect, channel t channel, long maxbufs, long ~nextTA, long maxbytes, AudloRlng ~arlng, AF sync *af sync, Sound **loadptr, Boolean ~eof, lstat t *lstat);
statlc vold t~allh ck ~long t~hp~r~ long buflen, char *bufptr, long buflen2, char *bufptr2);
statlc vold lnlt audlo ~vold);
statlc rht~c~TnSync ~ob~ect num t ob~ect);
statlc vold EmptyAudloRlngBuffers~vold);
statlc Boolean Choul~ :UseVlsta~prevlew parms t *parms,long speed,long vldeo_rate);
pascal vold Tlmerrallha~k~vold);
typedef enumi walt, read VIDEO, read AUDIOl, read_AUDI02 ) read actlon;
/****~"***~*"************ ******* * ' ***$**/
/**** Macro C~ ~n~c ~***/
/t *~**tlttt**~tt~*******t~***~****~**~*~t ~**************~*t~t~/
extern cmd block header '~command llst;
cmd block entry vlewer cmd entrles[] =
( "STATISTICSn, n [ON I OFF]", show stat, JNL ALL C~DS, O, "Set flag controlllng whether or not statlstlcs are shown.", NULLi, ( "PIPEn, nn, show plpe, JNL_ALL_CMDS, O, "Show vldeo and audlo plpe actlon from last show.", NULL
NULL, NULL
~;
cmd block header vlewer cmd block =
vlewer_cmd entrles, NULL, NULL, "Vlewer Ct - nt~ S n, NULL
~, /****~ *'~ **~***~*********~******~**************~*~*/
/**~*Externally-C~llah1t~ Routlnes ****/
/*tt~tt--~tt*~ ~tt~ *~*~tt~*t*~*~**~**~,t~tt***~tt~/

short show stat~argc,argv) lnt argc;

WO 91/10323 ~ ~ 7 1 9 rl ~ PCI'/US90/07482 vl-~r-r . a ~ngo 6 ~ond~y, D~ r 4, 1989 17:01 char **argv;

lf (argc = 0) statlstlcs = 1 - statlstlcs;
else lf lstrcmp(argv[l],"OFF") = 0) statlstlcs = 0;
else statlstlcs = l;
lf (statlstlcs && rlnglog-0) rlnglog ~ (RlngLog (*)[])AvNewPtr((MAX_RING_LOG_ENTRIES+l)*slzeof(RlngLog),STD_CHECK);

lf ('statlstlcs &L rlnglog) DlsposPtr(rlnglog);
rlnglog = 0;
) return 0;

/ *********~*******~*****************~***********
* NAME: lnlt_vlewer * Purpose: Inltlallze the vlewer for operatlon */
vold lnlt_vlewer() lf (vlewer_lnlt_done) return;

lf (VlstaDevlce = 0) VlstaPresent = FALSE;
else VlstaPresent = TRUE;
add_c -n~c (&command_llst, &vlewer_cmd_block);

/*
rlnglog = (RlngLog (*)[])AvNewPtr((MAX_RING_LOG_ENTRIES+l)~slzeof(RlngLog),STD_CHECK);

/~
~ Allocate the statlstlcs blocks.
*/
Vlstat = (VStat *)AvNewPtr(slzeof(VStat),STD_CHECK);
Alstat ~ (AStat *)AvNewPtr(slzeof(AStat),STD_CHECK);
A2stat = (Astat *)AvNewPtr(slzeof(AStat),STD_CHECK);
vlewer_lnlt_done - TRUE;
) /**************~********************************~
* NAME: lnlt_audlo ~ Purpose: Inltlallze the audlo portlon of the vlewer for operatlon vold lnlt audlol) lstat_t lstat;
long bufslz;
lf l'audlo lnlt_done) /I prlntf (nInltlng sound drlver\n"); */

max_audlo queue_elements - AuD-RING-ByTE-sIzE/sMALLEsl-AuDIo-BuFFER-sIzE + 1 I /~ safety value of */ 20;

WO 91/10323 ~ ) 7~ PCI/US90/07482 ~l-~-r.c ~g~ 7 ~ond~y, D~ r 4, 1989 17:01 ResetErr(&lstat~;
lf (soun~Tnltlallze(max-aud~o queue_el~ ~ s, (ProcPtr) &callha~ noErr) ( prlntf~nUnable to lnltlallze sound lnterface\nn);
return;

if (arlngl.sndbuf - O) bufslz ~ AUD_RING_BYTE_SIZE;
arlngl.sndbuf = (Sound ~)AvNewPtr(bufslz, &lstat);
lf (arlngl.sndbuf = O I I lstat != ISTAT_OK) ( prlntf(nUnable to allocate audlo rlng buffer l.\nn);
return;
arlngl. sn~huf lPn - bufslz;
arlngl.endbuf - arlngl.sndbuf + bufslz;
arlngl.l .- ` f = arlngl.endbuf;
) lf (arlng2.sndbuf -- O) bufslz = AUD_RING_BYTE_SIZE;
arlng2.sndbuf = (Sound ~)AvNewPtr~bufslz, Llstat);
lf ~arlng2.sndbuf = O I I lstat != ISTAT_OK) ( prlntf(nUnable to allocate audlo rlng buffer 2.\n~);
return;
) arlng2.~huflPn - bufslz;
arlng2.endbuf - arlng2.sndbuf + bufslz;
arlng2.~ .-~ `_f ~ arlng2.endbuf;

~ The followlng code wlll need to change wlth cd audlo * slnce dlgltlze mlght reallocate the buffers.
/

lf ~backup_arlng2_soun~hnf = o) backup_arlng2_ soun~hl1f = arlng2.sndbuf;
'f ~backup_arlngl_50un~hl.f o) backup_arlngl_soundbuf = arlngl.sndbuf;
audlo_lnlt_done = TRUE;
) * NAME: show * Purpose: prevlew a glven ob~ect uslng audlo & vldeo.
* Returns: TRUE lf the vlewer was aborted.
~ FALSE lf lt ran to normal completlon.
~/
Boolean show~ob~ect, parms, start, length, speed, edltBuf) ob~ect_num_t ob~ect;
prevlew parms_t ~parms; /~ PLAYBACK PARAMETERS ~/
long start;
long length;
long speed;
short edltBuf;
channel_t ch_used, ma~orChan;
char ~data;
long last_frame, ob~_len, preload;
lstat_t lstat:
Boolean avldabort;
Polnt ul;
long Tstart;

WO 91/10323 2 0 7 1 ~ 7 5 Ptc~r/US9O/07482 v~-~r-r . a P~g- 8 Xtond-y, D~ 4, 1989 17:01 VlstaInUse = FALSE;
avldabort - FALSE;
ResetErrt&lstat);
audlo_underflows - 0;
vldeo_underflows - 0;
lf (!vlewer lnlt_done) lnlt vlewer ~);
lf ('vlewer lnlt done) prlntf ~nVlewer not lnlt1~11zed\n"); /* !!!No way to get here!!! */
return~FALSE);
) ) lf (length =-; 0) return(FALSE);
vldeo_rate = GetOb~ectFrameRate(ob~ect, &lstat);
lf (lstat != ISTAT OK) prlntf(nError ln vlewer: Could not get ob~ect frame rate.\nn);
check_lstat(lstat);
goto SHOW EXIT;

/*
* Determlne whether we should use the VISTA board or not.
*/
UseVlsta - Chnult- UseVlsta(parms,speed,vldeo_rate);

/*
* The ob~ect knows whlch rh~nnPlq are enabled.
* We allow the caller to speclfy fewer rhAnnr-~q wlth the ch enabled argument.
* Store the resultlng set of rh~nnols to be played ln ch used.
*/
ch used - parms->ch enabled & flnd ob~ect ch~nnPlc(ob~ect,&l3tat);
lf (lstat !~ ISTAT OK) prlntf(nError ln vlewer: Could not flnd ob~ect's rh~nn~ls.\nn);
check lstat(lstat);
goto SHt~W EXIT;
lf (ch used 0) goto SHOW EXIT;
ma~orChan = flndMa~orChannel(ch used);
lf (start - PV_FROM_CURRENT) start = get_current(ob~ect, ma~orChan, &lstat);
lf (lstat != ISTAT_OK) prlntf(nError ln vlewer: Could not get current posltlon of ob~ect.\n");
check_lstat(lstat);
goto SHOW_EXIT;
I

Tstart ~ get_current(ob~ect, ma~orChan, &lstat);
lf (lstat != ISTAT_OK) prlntf(nError ln vlewer: Could not get current posltlon of ob~ect.~n");
check-lstat(lstat);
goto SHOW_EXIT;
) set_current(ob~ect, start, OUT_ALL, &lstat);
lf (lstat !- ISTAT_OK) WO 91/10323 2- û 7 1 9 7 S PCI/US90/07482 v~ r . o P~g~ g ~ond y, Da- '-r 4, 1989 17:01 prlntf~nError ln vlewer: Could not set current positlon ln ob~ect.\nn);
check_lstat~lstat);
goto SHCW_EXIT;
}

lf ~ ~ch_used & OUT_VIDEO) 0) ~seVlsta = FALSE;
new_speed = speed;
lf ~ ~ch_used & OUT_AUDIO_ALL) - OUT AUDIOl+OUT AUDIO2) ob~ect_has_two_audio_rhann~ls - TROE;
/~ prlntf~nPlaylng b1na-~ral selectlon for your en~oyment.\nn); ~/

else ob~ect_has_two_audio_rnann~lc ~ FALSE;
lf ~ch used & OUT_AUDIO_ALL) lnlt_audio~);
lf ~statlstlcs) ~
clear_Vstatlstlcs~Vlstat);
clear_Astatlstlcs~Alstat);
clear_Astatlstlcs~A2stat);
lognum = 0;
rlnglog_start_tlme 5 Tlcks;
EmptyAll~t~1ng~lffers~);
vbufTall = 0;
vbufHead - 0;
vbufsUnplayed - 0;
vbufsFree - VID_RING_SIZE;
) VPlpeEmpty = 0;
overrun ~ 0;
/~
* Go preload the vldeo rlng buffers.

lf ~UseVlsta) ul.h - parms-~area.x_offset;
ul.v - parms->area.y_offset;
LocalToGlobal~&ul);
ul.h -= ~*PrimaryDevlce)->gdRect.left;
ul.v -~ ~PrimaryDevlce)->gdRect.top;
ul.h -= ul.h % 4;
ul.v -= ul.v % 4;
NVInltPlay~ul.h, ul.v);
lnltVldeoPlpe~ob~ect, start, length);
) /*
Go preload the audlo rlng buffers.
/
CBcount = length; /~ must appear before the call to play_audlo ~/
lf ~ch_used & OUT_AUDIO_ALL) long prelen;
/~ let's not preload the whole rlng buffer ~takes too long) ~/
prelen - mln~length,150+250);
lnltAudioPlpe~ob~ect, start, prelen, ch_used & OUT_AUDIO_ALL, length);
) lf ~statlstlcs) WO gl/10323 2 Q 7 1 9 7S PCI-/US90/07482 r~o~or . a Pmg- 1 o ~o~d~y, D~ 4, 1989 17:01 reset_Vstatlstlcs(Vlstat);
reset Astatlstlcs~Alstat);
reset_Astatlstlcs~A2stat);
) Num~rames = 0;
IdleTlcks = 0;
mfmTlcks = 0;
sbTlcks - 0;
TotalTlcks = -Tlcks;
lf ~ch used 6 OUT AUDIO ALL) lf ~UseVlsta~
avldabort - playAVvlsta~ob~ect, parms, start, length, TRUE, edltBuf);
else avldabort = playAVfcb~ob~ect, parms, start, length, edltBuf);
else ( lf ~UseVlsta) avldabort = playAVvlsta~ob~ect, parms, start, length, FALSE, editBuf);
else avldabort = play synch tlmer~ob~ect, parms, length, speed, edltBuf);
) TotalTlcks += Tlcks;
OtherTlcks = TotalTlcks - IdleTlcks - sbTlcks - mfmTlcks;
if ~new speed > 0) ob~ len - get length~ob~ect, &lstat);
check lstat~lstat);
last frame - mln~start+length, ob~ len) - l;
last frame = mln ~apos, last frame);
else last frame = max ~0, apos);
set current~ob~ect, last frame, OUT ALL, &lstat);
tmPos~hanqed ~ob~ect, edltBuf, last_frame, STD CHECK);
lf ~UseVlsta) NVTermlnate ~);
lf ~audlo_ ll n~rf l _ ) prlntf~nAudlo near underruns: %d.\n",audlo underflows);
lf ~!underf11 5c~g~ ~Yrla1n~d) ( prlntf~" Deflnltlon: An underrun occurs when all avallable audlo\n");
prlntf~" or vldeo samples are used up ln the rlng buffer\nn);
prlntf~" when more samples are read ln from the medla flle.\n");underfl~ ss ~e oY~la1nDd = TRUE;
) lf ~vldeo underflows) prlntf~nVldeo near underruns: %d.\n",vldeo underflows);
lf ~!underfl ;_ eYpl~1n~d) prlntf~" Deflnltlon: An underrun occurs when all avallable audio\nn);
prlntf~" or vldeo samples are used up ln the rlng buffer when more~n");
prlntf~" samples are read ln from the media flle.\nn);
underflo~ ssaqe ~Ypla1n~d = TRUE;

) i lf ~statlstlcs) prlntf~nTotal: %ld Idle: %ld dlsplay: %ld mfm: %ld other: %ld\n", TotalTlr~c, IdleTlcks, sbTlcks, mfmT1r~c~ OtherTicks);
lf ~!UseVlsta) &~ TotalTlcks != 0) WO 91/10323 2 ~ ~ ~ 9 7 S PCI`/US90/07482 v~ . o ~-g- 11 Xo~d~y, D~ r 4, 1989 17:01 prlntf ("Frames/sec: %ld\nn, ~NumFrames * 60~/TotalTlcks);
prlnt_stats(vldeo-rate);
) SHOW EXIT:
lf (audlo lnlt_done) SounaQulet();
audlo_lnlt_done e FALSE;

VlstaIn~se - FALSE;
SetRecordMonltor(TRUE);
OM_FlushGlsts(ob~ect,STD_CHECK);
return(avldabort);
) / *~*~****t~********~*****
~ play_audlo */
statlc vold play_audlo(ptr,af_sync,arlng) Sound *ptr; /* ptr to flrst byte of flrst audlo buffer */
AF sync *af sync; /* synchronlzatlon structure */
AudloRlng *arlng; /* whlch rlng buffer ~/
reglster short n;
reglster channel t channel; /* whlch audlo channel (JUST ONE AUDIO CHANNEL) */
OSErr ret;
reglster Sound *bufptr;
long audlo_buflen;
AudloMode mode;
long byte_count;
long buf_count;
Sound *bufptrl, *bufptr2;
Boolean audlo2;
channel - af sync->channel;
mode - af sync->audlo_mode;
byte_count ~ af sync->bytes loaded;
bufptr 5 ptr;
/* the mode settlng done here wlll be really used ln a future release. the onlyreal lnformatlon we wlll need then ls the dlfference between 22 and 44 khz */
audlo2 - (channel = OUT_AUDIO2);
/*
Conflrm that the polnters are okay.
We assume that the caller ls calllng us correctly and speclfylng one and only one audlo channel (and no vldeo ~h~nnels).
/
lf (audlo2) lf (backup_arlng2_soundbuf !- arlng2.sndbuf) prlntf~nAudlo rlng buffer structure has been scrlbbled lnto.\n");
prlntf(nStart of audlo2 rlng buffer should be %lx.\nn,backu~_arlng2_soundbuf);
prlntf~nbut the arlng2 structure thlnks lt ls ~lx.\n",arlng2.sndbuf);
}

lf (bufptr < arlng2.sndbuf 1 I bufptr+byte_count > arlng2.endbuf) prlntf (nBad sound bufptr, ~lxt%ld, audlo channel 2.\nn,bufptr,byte_count);
lf ~bufptr < arlng2.sndbuf) prlntf(nBuffer polnter polnts to before start ~%lx) of a2 rlng buffer.~-.n, arlng2.sndbuf);
lf (bufptr+byte_count > arlng2.endbuf~
prlntf(nBuffer polnter polnts to after end (~lx) of a2 rlng buffer.\nn, arlng2.endbuf~;
return;

WO 91/10323 2 () 7 1 97 5 PCI/US90/07482 v~-lr-r . a P~g- 12 ~ODd~y, D~ 4, 1989 17:01 else /* audlo 1 */
lf ~backup arlngl-sounrlh~lf != aringl.sndbuf) printf~nAudio ring buffer structure has been scrlhblr~d into.\nn);
prlntf~nStart of audiol rinq buffer should be %lx.\nn,backup aringl soundbuf);
printf("but the arlngl structure thinks lt ls %lx.\n",arlngl.sndbuf);
lf ~bufptr < arlngl.sndbuf I I bufptr+byte count > arlngl.endbuf) prlntf ~nBad sound bufptr, %lx+%ld, audlo channel l.\nn,bufptr,byte count~;
lf ~bufptr c arlngl.sndbuf) prlntf~nBuffer polnter polnts to before start ~%lx) of al rlng buffer.\nn, arlngl.sndbuf);
lf ~bufptr+byte count > arlngl.endbuf) prlntf~nBuffer polnter polnts to after end ~%lx) of al rlng buffer.\nn, arlngl.endbuf);
return;
) /*
* Note the fact that we have handled these audio buffers.
*/
arlng->abufs~ ~1n1ng -- af sync->buffers;
/*
* Now break the distlngulshed channel ~channel 1) lnto audio buffers.
* For each one, queue lt to the sound accelerator unless there ls not ~ enough matchlng audio ln channel 2 ~when playlng h1n~1~r~
* In that case, ~ust leave the audio staged.
*/
lf ~ob~ect_has two audio rh~nnpls) mode = Buf8_22 s;
bufptrl = arlngl.abufStaglng;
bufptr2 ~ arlng2.abufStaglng;
whlle ~TRUE) ( lf ~arlngl.abytesStaged-0 11 arlng2.abytesStaged=0) return;
/*
* We have some palrs of audio that have been staged.
~ We now wlsh to queue them to the sound arr~lr~rator.
* We must do thls a buffer at a time.
* An audio buffer corresponds to a vldeo buffer, but the exact number of samples ls lmmaterlal.
~ Tr,~ ~r.. l~ly of how the samples came ln, we wlll now break * up the distlngulshed channel lnto multlple buffers based on ~ abufsStaged and abytesStaged. We then take the flrst buffer * and check that there are at least that many bytes avallable * ln the secnn~ry audio rlng buffer. If so, we palr these bytes together and send them as a buffer palr to * the sound accelerarator.
*/
lf ~arlngl.abufsStaged~0) prlntf~nT~rnnc~ctency: No primary audlo buffers staged, yet %ld audlo bv~es staged.\n", arlngl.abytesStaged);
arlngl.abytesStaged = 0;
return;
) audlo buflen - arlngl.abytesStaged / arlngl.abufsStaged;
audlo buflen ~ ~audlo_buflen/3)*3; /* must be a multlple of 3 */

WO 91/10323 2~7 I 9-~5 PCI/US90/07482 ~o~-r . o --2 7-- P-g- 13 ~ond~y, D~ 4, 1989 17:01 lf ~audlo buflen ~ 100) prlntf(nFunny event ln SBPlay two_~h~nnPIc: audlo buflen-%ld.~nn, audlo buflen);
prlntf(" al bytes staged = %ld.\n",arlngl.abytesStaged~;
prlntf(" al bufs staged 5 %d.\nn, arlngl.abufsStaged);
) /*
Do nothlng at thls tlme lf we don't have at least a buffer's * worth of samples ln both audlo rlng buffers.
~/
lf (arlng2.abytesStaged ~ audlo buflen) return;
et ~ SBPlay two_~h~nnoi q (bufptrl, audlo buflen, mode, bufptr2, channel);
lf (ret != 0) char *msg;
swltch(ret) case noSA: msg = nNo sound acr~lerator.~l; break;
case 1 1 1 QUPI1P: msg = nQueue address lnvalld.n; break;case qFull: msg = nRan out of audlo queue elements."; break;
case tlmeOut: msg = nTlmeout."; break;
prlntf(nError from SBPlay two rh~nn~i~q %d (%s)\nn, ret, msg);
break;
) bufptrl +- audlo buflen;
arlngl.abytesStaged - audlo buflen;
arlngl.abufStaglng += audlo buflen;
arlngl.abufsStaged--;
bufptr2 +~ audlo buflen;
arlng2.abytesStaged -= audlo buflen;
arlng2.abufStaglng +- audlo buflen;
aring2.abufsStaged--;
) else /* monaural */
mode = Buf8 22 m;
buf count - af sync->buffers;
for (n-buf count; n>0; n--) audlo buflen = byte_count/n;
audlo buflen = (audlo buflen/3)*3;
ret - SBPlay(bufptr, audlo buflen, mode, channel);
lf (ret != 0) /~*** thls should be a subroutlne char *msg;
swltch(ret) case noSA: msg = nNo sound accelerator."; break;
case 1 1 1 QUPUP: msg = nQueue address lnvalld."; break;case qFull: msg = "Ran out of audlo queue elements."; break;
case tlmeOut: msg = nTlmeout.n; break;
prlntf (nError from SBPlay: ~d (%s)\nn, ret, msg);
break;
bufptr +- audlo buflen;
byte count -- audlo buflen;
lf (channel - OUT AUDIO2) wo gl/10323 2 0 7 i 9 7 5 PCI-/US90/07482 v~-~r-r . a P~g- 1 ~ord y, D~ r ~, 1989 17:01 ( aring2.abytesStaged - audlo buflen:
arlng2.abufsStaged--;
arlng2.abufStaglng +- audlo_buflen;

else arlngl.abytesStaged - audlo buflen;
arlngl.abufsStaged--;
arlngl.abufStaglng +- audlo_buflen;
}
) lf (audlo2) ( lf ~arlng2.abufsStaged -O && arlng2.abytesStaged>O) ( prlntf~nFalled to queue all staged audlo2 bytes. %ld bytes left over.\nn, arlng2.abytesStaged);
arlng2.abytesStaged - O;
) }

else ( lf ~arlngl.abufsStaged ~0 ~ arlngl.abytesStaged~Ol prlntf(nFalled to queue all staged audlol bytes. %ld bytes left over.~nn, arlngl.abytesStaged);
arlngl.abytesStaged = O;

/********************************************************/
/**** TnternAl Routlnes ****/
/*************~******************************************/
long CBcount at overrun = O;
********~*~********************************************************
~ NAME: playAVvlsta * PURPOSE: Plays an ob~ect synchlng the vldeo to the audlo *************~**~******************************************************/
statlc Boolean dlsplaylng_reason_for_stopplng - FALSE; /* TRUE for ~huqq1 nq */
statlc Boolean playAVvlsta(ob~ect, parms, start, length, soundsync, edltBuf) ob~ect_num_t ob~ect;
prevlew_parms_t ~parms;
long start;
long length;
Boolean soundsync;
short edltBuf;
( long old_apos, dum, new_apos;
lnt vldTrlgger;
lstat_t lstat;
Boolean aborted;
reglster 300lean vldeoEOF, al~A101 F~F, An~1 o~F~F;
lnt 1, bufsLoaded;
Sound *startBuf;
long AbytesrlnrlAyedl;
long Abyt~cUnrlAyed2;
Boolean a~101Cr1tlcal;
Boolean audlo2Crltlcal:
AF sync af_sync;
channel_t audlo_rhAnn~ls_used;
long nextVldeoTA;

W O 91/10323 ~ ~ 7I 9 ~ ~ PC~r/US90/07482 r . a P~g- 15 ~o~d~y, D~ 4, 1989 17:01 long nextAudiolTA;
long nextAudlo2TA;
reglster read_actlon actlon;
Boolean crltlcal;
long fewest buffers;
Boolean efflclent;
Boolean eof;
lf (length 0) return(FALSE);
lf ('audio_lnlt_done && soundsync) prlntf (nAUDIO not lnlt1 A 11zed~\n");
return (FALSE);
}

udio rh~nnPls-used = flnd_ob~ect rh~nnpls(ob~ect~sTD-cHEcK) & parms->ch_enabled & OUT_AUDIO ALL;
nextAudiolTA = 0;
nextAudlo2TA = 0;
nextVldeoTA = 0;
vldeoEOF = FALSE;
if ( (audio rh~nnPl~_used&OUT_AUDI01) &6 soundsync ) audiolEOF = FALSE;
else audiolEOF = TRUE;
lf ( (audio-rh~nnpl~ used&OUT_AUDI02) && soundsync ) audio2EOF = FALSE;
else audlo2EOF = TRUE;
/* Thus, lf audlo<n>EOF ls FALSE, then audio channel <n> ls present ln thls ob~ect. ~/
apos = old_apos = start;
aborted = FALSE;
NumVReads = 0;
TotalVbufs = 0;
lf (!soundsync) ( /~ Install tlmer lnterrupt routlne */
myTask.qType - vType;
myTask.vblAddr = (ProcPtr) ~Tlmerc~llha~k;
myTask.vblCount = 2;
myTask.vblPhase = 0;
VInstall(&myTask);

IdleTlcks -~ Tlcks;
VlstaInUse = TRUE;
whlle (TRUE) /~ Loop untll f~l lha~k sets a flag ~/
long max_read;
max_read = mln(CBcount,10000);
AbytesUnplayedl = arlngl.sndbuflen - arlngl.abytesFree; /~ not qulte true ~/AbytesUnplayed2 - arlng2.sndbuflen - arlng2.abytesFree;
/~
Determlne whlch channel has the fewest number of buffers avallable ln the rlng buffers. Thls wlll be the channel that we read from.
Determlne at the same tlme lf the read would be a crltlcal read and/or an efflclent read.
A crltlcal read ls one that we really want to do lmmediately, because the number of audlo buffers left to be played ln the rlng buffer ls low.
An efflclent read ls one that reads ln a lot of buffers lnto memory.
~/

WO 91/10323 ~ 0 7 ~ ~ 7 ~ PCI/US90/07482 v~-~ r . o ~ 3 P~g- 16 ~o~d~y, D~ '- 4, 1989 17:01 actlon ~ wait;
crltlcal = FALSE;
efflclent - FALSE;

fewest_buffers s MAX LONG;
lf (!audiolEOF
&L arlngl.abytesFree >= 735) lf (arlngl.abufsUnplayed ~ fewest buffers) fewest buffers = arlngl.abufsUnplayed;
actlon - read AUDIOl;
crltlcal = tfewest buffers <- AUDIO ALERT BUFS);
efflclent - ~arlngl.abytesFree >- EFFICIENT AUDIO BYTES) && ~n~Yt~ 1olTA~TYPICAL AUDIO BUFFER SIZE >- EFFICIENT AUDIO BYTES);
) ) if ~!audlo2EOF
~& arlng2.abytesFree >= 735) lf ~arlng2.abufsUnplayed < fewest_buffers) fewest_buffers = arlng2.abufsUnplayed;
actlon ~ read_AUDI02;
crltlcal - ~fewest_buffers <- AUDIO ALERT BUFS);
efflclent = ~arlng2.abytesFree >- EFFICIENT AUDIO BYTES) && ~nextAudlo2TA~TYPICAL AUDIO BUFFER SIZE >= EFFICIENT AUDIO BYTES);
) ) lf t!vldeoEOF && vbufsFree>0) ( lf ~vbufsUnplayed < fewest buffers) fewest buffers = vbufsUnplayed;
actlon - read VIDEO;
critlcal = ~fewest_buffers <= VIDEO ALERT ~3UFS);
efflclent = ~vbufsFree >= ~ hl_VIDEO BUFS) &&
~nextVldeoTA >= EFFICIENT VIDEO BUFS) ;
) /~
t We have determ1n~ whlch plpe ls the most empty.
However, we won't necess~r11y do a read unless thls empty conditlon ls crltlcal.
If the conditlon ls not crltlcal, then we wlll read anyway lf lt ls re~Q~n~hly efflclent to do so or lf we are forced ~ to do a short read because of an upc~1ng transltlon or t because we are up agalnst a barrler at the end of the rlng buffer.

lf ~!crltlcal && !efflclent) actlon = walt;

lf ~!vldeoEOF &i vbufsFree >= VID MIN READ &&
~vbufsFree >= EFFICIENT_VIDEO_BUFS) ~ nextVldeoTA < EFFICIENT VIDEO BUFS) &~ ~nextVldeoTA > 0) ) ) actlon - read VIDEO;
) lf ~actlon walt ~& !audlolEOF
&& ~arlngl.abytesFree >= 735) ~ arlngl.abytesFree >= EFFICIENT AUDIO BYTES) I I

WO 91/10323 2` ~ 719~5 PCI`/US90/07482 v~ ~-r . a ~ 31-- P-g- 17 ~ond~y, De 4, lsas 17:01 (nextAudlolTA*TYPICAL AUDIO BUFFER_SIZE < EFFICIENT AUDIO BYTES) && ~nextAudlolTA > 0) ) ) actlon = read AUDIOl;

lf ~actlon !- read VIDEO && !Au~1o7F~oF
&~ ~arlng2.abytesFree >- 735) && ~ ~arlng2.abytesFree >= ~IC~ AUDIO BYTES) I I
~nextAudlo2TA*TYPICAL AUDIO BUFFER SIZE < EFFICIENT AUDIO BYTES) && ~nextAudlo2TA > 0) ) ) lf (actlon - walt) actlon = read AUDI02;
else /* actlon ls read AUDIOl */
/~
Could do elther Al or A2 stuff.
Do the one wlth the most empty rlng buffer.
lf ~arlng2.abytesFree > arlngl.abytesFree) actlon - read AUDI02;
/* lf not, then actlon ls already read AUDIOl. */
) j /~ end analysls for non-crltlcal, non-efflclent reads */
swltch ~actlon) case read VIDEO:
vldTrlgger = VID MIN READ;
lf ~vbufHead>vbufTall && VID_RING_SIZE-vbufTall <- vldTrlgger+2) vldTrlgger - VID RING SIZE-vbufTall;
/* Note: vldTrlgger mlght be 0 lf buffer ls full */
vldTrlgger = mln ~vldTrlgger, nextVldeoTA);
lf ~vbufTall>vbufR~a~) vldTrlgger = mln ~vldTrlgger, VID_RING_SIZE-vbufTall);
lf ~vbufsFree >- vldTrlgger && vbufsFree > 0) rh~r~TnSync~ob~ect);
IdleTlcks +- Tlcks;
lf ~max read > 0) long tmp max;
/*
~ Don't want to read too much vldeo at a tlme * slnce thls wlll take too long and use up * other resources.

tmp_max = max_read;
lf ~!Au~1olFnF) tmp_max - mln~tmp-max,arlngl.abufsUnplayed);
lf ~!au~1o7FOF) tmp max = mln~tmp max,arlng2.abufsUnplayed);
tmp max ~- VldeoF S17~;
/* ~ should go ln next call as llmlt on bytes noe loglcal bufs ~/
~ufsLoaded - GetNextAV ~ob~ect, OUT_VIDEO, 0, &nextVldeoTA, tmp_max, WO 91/10323 2 ~ 7 ~ ~ 7 ~ PCr/US90/07482 ~l-~-r.~ - 32- ~g- 18 ~o~t~y, D-c '- ~, 1989 17:01 0, 0, 0, &eof, 61stat);
lf (lstat !- ISTAT_OK I I eof) vldeoEOF = TROE;
lf (dlsplaylng_reason_for_stopplng) lf (lstat) prlntf(nSettlng vldeo EOF because error ~ %d. (CBcount - %ld)\n", lstat,C3count);
else prlntf(nSettlng vldeo EOF because at end of flle. (CBcount - %ld)\nn~cBco else bufsLoaded = 0;
vldeoEOF - TRUE;
lf (dlsplaylng reason_for_stopplng) prlntf(nSettlng vldeo EOF because max read ~ %ld. (CBcount e %ld)\nn, max read,CBcount);

IdleTlcks -= Tlcks;
break;
case read AUDIOl:
IdleTlcks +- Tlcks;

max_read = mln(max_read,arlngl.abufsP ~ t n t ng);
lf (max_read > 0) /~
~ Don't want to read too much audlo at once, because * thls wlll hang the system up.

bufsLoaded = GetNextAV (ob~ect, OUT_AUDIOl, max_read, ~nextAudlolTA, MAX REAL AUDIO_BYTES, ~arlngl, &af sync, ~startBuf, ~eof, ~lstat);
lf (lstat != ISTAT_OK I I eof) audlolEOF = TRUE;
lf (dlsplaylng_reason_for_stopplng) lf (lstat) prlntf(nSettlng audlol EOF because error ~ %lx. (CBcount - %ld)\nn, lstat,CBcount);
else prlntf(nSettlng audlol EOF because at end of flle. (CBcount = %ld)\nn, CBcount);
}
lf (bufsLoaded) play audlo(startBuf,~af sync,~arlngl);
) else bufsLoaded ~ 0;
t ol F~F = TRUE;
lf (dlsplaylng_reason_for stopplng) prlntf(nSettlng audlol EOF because max_read ~ %ld. ~CBcount = %ld)\nn, max read,CBcount);
) IdleTlcks -= Tlcks;

break;

WO 91/10323 ~1~7`I 9`~ PCI/US90/07482 vlo~or . c ~?~g~ 1 9 ~onday, D~ 4, 1989 17:01 case read AUDIO2:
IdleTlcks += Ticks;

max read = mln~max read,arlng2.abufs~ ~l n 1 ng~;
lf ~max_read > 0) /*
Don't want to read too much audlo at once, because thls wlll hang the system up.
~/
lf ~ob~ect has two_audlo_rh~nn~ls ll ~audlo rhann~l 5 usQdLouT AUDI02)) bufsLoaded = GetNextAV ~ob~ect, OUT AUDIO2, max read, &nextAudlo2TA, MAX_REAL AUDIO BYTES, &arlng2, &af sync, &startBuf, Leof~ &lstat~;
) else bufsLoaded = 0;
lf (lstat != ISTAT OK I I eof) audlo2EOF = T~UE;
lf ~dlsplaylng_reason_for_stopplng) {

lf ~lstat) prlntf~nSettlng audlo2 EOF because error = %lx. ~CBcount = %ld)\n", lstat,CBcount);
else prlntf~nSettlng audlo2 EOF because at end of flle. ~CBcount = %ld)\n", CBcount);
) lf ~bufsLoaded) play_audlo~startBuf,&af_sync,&arlng2);
) else ( bufsLoaded = 0;
audlo2EOF = TRUE;
lf ~dlsplaylng_reason_for_stopplng) prlntf~nSettlng audlo2 EOF because max_read ~ %ld. ~CBcount = %ld)\n~', max_read,CBcount);
) IdleTlcks -= Tlcks;
break;
case walt:
break;

) /~ Done wlth read ~lf any) ~/

lf ~audlolEOF && arlngl.abufsUnplayed 0 && CBcount > 0 && soundsync && laudlo-rh~nn~ls-usedLouT-AuDIol) ) soundsync = FALSE;
/* Install tlmer lnterrupt routlne to handle flnal unsynced vldeo~/
lf (dlsplaylng_reason_for_stopplng) prlntf~nSwltchlng to unsynced vldeo. ~CBcount = %ld)~n",~ ount);
myTask.qType ~ vType;
myTask.vbLAddr ~ (ProcPtr) &Tlmerr~llhark;
myTask.vblCount = 2;
myTask.vblPhase - 0;
VInstall~LmyTask);
avld walt~3,STD_CHECK); /~ allow sound ~rreler~tor to flnlsh ~/

WO 91/10323 2 0 7 :1~ 7 5 PCI`/US90/07482 ~-~-r . c P-g- 2 0 ~ont y, D~ r 4, 1989 17:01 SoundQulet ~);
) lf (vbufsUnplayed <= 0 &L vldeoEOF) lf (displaylng_reason for_stopplng) prlntf(nStopplng because vbufsUnplayed = %d. (CBcount = %ld)\nn, vbufsUnplayed,CBcount);
break;

lf ~arlngl.abufsUnplayed <= 0 6& audiolEOF &L ~audio ~hann~lc_used&OUT AUDIOl) ) lf ~dlsplaylng_reason_for_stopplng) prlntf(nStopplng because abufslUnplayed - ~d. ~CBcount - %ld)~nn, arlngl.abufsUnplayed,CBcount);
break;
) lf ~arlng2.abufsUnplayed c= 0 LL audio2EOF i& ~audio_~hAnnPls_used&OUT_AUDI02) ) lf ~dlsplaylng_reason for_stopplng) prlntf~nStopplng because abufs2Unplayed = %d. ~CBcount = %ld)\nn, arlng2.abufsUnplayed,CBcount);
break;
) lf ~check_abort_key~parms->check_key)) aborted - TRUE;
lf ~displaylng reason_for_stopplng) prlntf~"Aborted by user.\n");
break;
) new_apos = apos; /* slnce apos mlght change as we look at lt */
lf ~new_apos != old_apos) tmNowPlaylng(ob~ect, editBuf, new_apos, &lstat);
old_apos = new_apos;
) lf (CBcount = 0) lf (dlsplaylng_reason_for_stopping) prlntf(nSettlng audio and vldeo EOF because CBcount=0.\nn);
audiolEOF = TRUE;
AU~107F~F = TRUE;
vldeoEOF = TRUE;
/* should we do a BREAK here? */
) /*
* In the b1nA--rAl case, we could get hung up lf there ls more Al to play but no more A2. We prematurely abort lf that happens.
/
lf ~audio_~hAnn~lc_used OUT_AUDIOl+OUT_AUDI02 && audiolEOF && audlo2EOF
&L arlng2.abufsUnplayed - arlng2.abufsStaged 6L arlng2.abytesStaged < 730) /* kludge ~/

lf ~displaylng_reason_for stopplng) prlntf~nSettlng CBcounte0 because A2 has run short.\nn);
CBcount = 0;
break;
) lf ~CBcount < 0) lf ~displaylng_reason_for_stopplng) prlntf( n Stopplng because CBcount<0. (CBcount = %ld)~n n ~ CBcount);
aborted - FALSE;
break;

WO91/10323 ~7 1:~7~- PCI/US90/07482 v~ -r . a Png- 21 ~onday, D~ 4, 1989 17:01 CBcount = 0; /~ synchronously stop playlng vldeo ~/
VlstaInUse = EALSE;

apos++; /~ not sure why thls helps ~/
lf ~soundsync) lf ~!aborted~ avld_walt~3,STD_CHECK); /~ see comment ln playAVfcb ~/
SoundQulet ~);
else VRemove~&myTask);
apos--; /* Slnce flrst lnterrupt displays flrst frams ~/

Delay 13, cdum);

lf ~IdleTlcks c o) IdleTlcks +~ Tlcks;
lf (VPlpeEmpty > 0) prlntf ~nVldeo dry count: %d.~nn, VPlpeEmpty);
prlntf~nCBcount when ran dry was: %ld.\n",CBcount_at_overrun);
lf ~'drycountMPss~_oYplA1n~d) prlntf~" Deflnltlon: The vldeo plpe has run dry when the rlng buffer\nn);
prlntf~" ls empty at the end of the lnterrupt routlne.\nn);
dryc~u..l~ ssage_PyrlA1np~ = TRUE;
lf lNumVReads != 0 && statlstlcs) prlntf (nAverage frames per read: %f\nn, ~float)TotalVbufs/NumVReads~;
lf ~overrun > 0) prlntf ~nVldeo overrun count: %ld\n", overrun);
lf ('overrunMessage _PYpl A 1 nP~
prlntf(" Deflnltlon: A vldeo overrun occurs when the VISTA board ls stlll\nn~;
prlntf(" playlng a frame when we trlgger the next frame to be played.\n"~;
OverrunMP55age_PY~l A 1 n~d = TRUE;

return(aborted);
) rhc~rirTnSync (ob~ect) ob~ect_num_t ob~ect;
reglster long pos;
lstat t lstat;
pos - get_current (ob~ect, OUT_VIDEO, Llstat);
lf (pos < apos~
set_current (ob~ect, apos, OUT_VIDEO, Llstat~;
check for errors?

NAME: playAVfcb PURPOSE: Plays vldeo (wlthout a VISTAI synced to audio; uses fastCopyBlts W O 91/10323 2 0 7 ~ g7 5 PC~r/US90/07482 ~or . a --3 6-- ~-g- 22 ~o~d y, D~- - 4, l9S9 17:0l statlc Boolean playAVfcb ~ob~ect, parms, start, length, edltBuf) ob~ect num t ob~ect;
prevlew parms t ~parms;
long start;
long length;
short edltBuf;

reglster long old apos, new apos;
lstat t istat;
Boolean aborted;
reglster lnt l, bufsLoaded;
Sound ~startBuf;
AF sync af sync;
channel t rhannols used, audlo rh~nno~s used;
long nextAudlolTA;
long next~ o2TA;
Boolean eof;

lf ~length - 0) return(FALSE);
~hAnno1s_used - parms->ch onabled & flnd ob~ect chAnnolq~ob~ect,STD_C~ECK);
audlo_~hAnnols_used = ~h~nn~1q_u5ea & OUT_AUDIO ALL;
old_apos - start;
apos ~ start;

no~tA--~1OlTA = 0;
nextAudlo2TA - 0;
aborted ~ FALSE;
IdleTlcks -- Tlcks;
whlle ~TRUE) /~ Loop untll r~l lha~ sets a flag l/
/~
Slnce apos can change ln the lnterrupt routlne, ~ we make a copy ln "new_aposn.
new_apos - apos;
lf ~new apos-old apos > 0) IdleTlcks += Tlcks;
lf ~rhAnnolc used ~ OUT_VIDEO) lnc current (ob~ect, new_apos-old_apos, OUT_VIDEO, &lstat);
lf tlstat = ISTAT_OFF_END) prlntf(nIn~ ted off the end of the ob~ect.\nn);
break;
else lf (lstat != ISTAT OK) check lstat~lstat);

old_apos = new_apos;

tmPos~hAngQ~ (ob~ect, edltBuf, new_apos, &lstat);
NumFrames++;
IdleTlcks -= Tlcks;
) lf ~ob~ect has two audlo_rhAnnolq) lf ~arlngl.abytesFree > AUD_~IN_BYTE READ) long max read;

WO 91/10323 2 ~ 7 ~ 9 7 5 Pcr/usgo/o7482 ~-~-r.a ~g- 23 ~ond~y, De '-r 4, 1989 17:01 max_read - mln~CBcount-arlngl.abufsUnplayed,MAX_REAL_AUDIO BYTES);
max_read - mln(max_read,arlngl.abuf sr~ ~1 n t nq);
lf (max_read ~ 0) bufsLoaded = GetNextAV (ob~ect, OUT_AUDIOl, max_read, &nextAudlolTA, 0, &arlngl, &af_sync, &start8uf, &eof, &lstat);
lf (bufsT~A~) play_audlo(startBuf,&af_sync,&arlngl);
}

lf (arlng2.abytesFree > AUD_MIN_BYTE READ) long max_read;

max_read = mln(CBcount-arlng2.abufsUnplayed,MAX_REAL_AUDIO_BYTES);
max_read ~ mln(max_read,arlng2.abuf eP ~1 n 1 nq);
lf (max_read ~ 0) lf (ob~ect_has_two_audlo_~h~nn~ls) bufsLoaded = GetNextAV (ob~ect, OUT_AUDI02, max_read, &nextAudlo2TA, 0, &arlng2, &af_sync, &startBuf, &eof, &lstat);
lf (bufsLoaded) play_audlo(startBuf,&af_sync,&arlng21;

}
else / * ~ ril l * /
lf (audlo_~h~nnPis_used = OUT_AUDI02) lf (arlng2.abytesFree > AUD_MIN_BYTE_READ) long max_read;
max_read - mln(CBcount-arlng2.abufsUnplayed,MAX_ r~EAL _AUDIO_BYTES);
max_read = mln(max read,arlng2.abufsP- ~1 n 1 nq);
lf (max_read > 0) bufsLoaded ~ GetNextAV (ob~ect, OUT_AUDI02, max_read, ~nextAudio2TA, 0, &arlng2, &af_sync, &startBuf, &eof, &lstat);
lf (bufsLoaded) play_audio(startBuf,~af_sync,~arlng2);

else /* channel l ~/
lf (arlngl.abytesFree > AUD_MIN_BYTE_READ) long max_read;

max read - mln(CBcount-arlngl.abufsUnplayed,MAX_REAL AUDIO_BYTES);
max_read - mln(max read,arlngl.abuf Sr. ~1 n 1 ng);
lf (max_read > 0l bufsLoaded - GetNextAV (ob~ect, OUT AUDIOl, max read, &nextAudlolTA, 0, &arlngl, WO91/10323 2 0~ 1 97 5 PCI/US90/07482 vi lr-r . o P~g- 24 ~ond~y, D-- - 4, 1989 17:01 &af sync, &startBuf, &eof, &lstat);
lf (bufsLoaded) play audlo~startBuf,&af sync,~arlngl);
) lf ((aringl.abufsunplayed = 0 11 arlng2.abufsUnplayed = 0) L& CBcount <= 0) ( /~
At thls polnt, the sound acc~lerator has queued the last audlo buffer to be played. Unfortunately, lt gets played by an asynchronous p~u~essoI and there ls no easy way to flnd out when lt ls done.
If we ~ust dld a break now, we would call soundqulet and prematurely abort the last few buffers of audlo.
We kludge around thls problem by waltlng 2/60ths of a second now.
A better sol-~t1~n would be to call a routlne called so~ 1t that would walt fcr the sound accelerator to flnlsh anythlng lt was playlng.
~/
avld_walt(3,STD CHECK);
break;
) lf Icheck_abort key~parms->check_key)) aborted - TROE;
break;
) ) IdleTlcks +- Tlcks;

Solln' iQll 1~t ();
return~aborted);
) PURPOSE: Called from sound manager after flnlsh of each audlo frame.
Updates r1ng buffer pn1nterC and tlckles the Vlsta.

tatlc vold c~l lh~ rhp - ,buflen,bufptr,buflen2,bufptr2) long cbparam;
reglster long buflen;
reglster char ~bufptr;
reglster long buflen2;
reglster char ~bufptr2;
reglster channel_t channel;
CBcount--; /~ Can be checked by synchronous routlnes ~/
lf ~CBcount < 0) return;
apos++;
channel - ~channel_t)cbparam;
lf ~ob~ect_has_two_audlo_~h~nn~1s) ( arlngl.ahuf~^ld - bufptr + buflen;
arlngl.~ufs~l~rl~yed ~r~o~r . a 3 9 P~go 25 ~o~d~y, D~ '-r 4, 1989 17:01 arlngl.abytesFree +- buflen;
arlng2.ah~fR~a~ - bufptr2 + buflen2;
arlng2.abufsUnplayed--;
arlng2.abytesFree +- buflen2;
else /~ mono ~/

lf (channel -~ OUT_AUDI01) arlngl.ahl~fH~a~ - bufptr + buflen;
arlngl.abufsUnplayed--;
arlngl.abytesFree +- buflen;
else /~ audlo2 ~/
/~
Note that ~hen runnlng mono, we use bufptr and buflen ~not bufptr2 and buflen2~
~ no matter what channel ls belng played.

arlng2.ahufR~a~ ~ bufptr + buflen;
arlng2.abufsUnplayed--;
arlng2.abytesFree +- buflen;
) frame repeat count[vbufHead]--;
lf ~frame repeat count[vbufHeadl - ) lf ~vbufsUnplayed > 0) lf ~UseVlsta) lf ~GetGSPCtl~) ~ 0x8) /* Check lf Vlsta stlll playlng last frame ~/
overrun++; /* Overrun lf so ~/
CBcount = 0; /* thls ls fatal, force an abort ~/
lf ~CBcount) NVPlayFrame ~ Trlgger Vlsta to play next frame */
/~ last lnterrupt means we are done ~/

vbufHead++;
lf ~vb~fH~a~-VID RING SIZE) vbufHead - 0;
vbufsUnplayed vbufsFree++;
else lf ~CBcount > 0) /~ SERIOUS OVERRUN, go BO0M t/
VPlpeEmpty++;
CBcount at overrun = CBcount;
CBcount - 0; /~ force thlngs to shut down ~/
) ) NAME: Tlmercallhar~
PURPOSE: Called every so often when there ls no audlo to trlgger on.
~ Updates rlng buffer polnters and tlckles the Vlsta.

pascal vold Tlmerc~llhar~ ~) WO 91/10323 2 0 ~ J PCI/US90/07482 vi-~-r.c P~g- 26 ~ond y, D~ 4, 1989 17:01 SetUpA5~);

CBcount--; /* Can be checked by synchronous routlnes */
lf ~CBcount c 0) goto TCBexlt;
apos++; /* Needed when uslng fastcopyblts wlth sound */

frame_repeat_count[vbufHead]--;
lf ~frame_repeat count~vbufHead] - 0) lf ~vbufsUnplayed > 0) ( lf ~UseVlsta) lf (GetGSPCtl~) i 0x8) overrun++;
CBcount = 0;
lf (CBcount) NVPlayFrame ~);

) vbufHead++;
lf ~vbufHead>-VID_RING_SIZE) vbufHead - 0;
vbufsUnplayed--;
vbufsFree++;
) ) lf ~vbufsUnplayed <= 0 &L CBcount > 0) /* empty or almost empty */
( VPlpeEmpty++;
CBcount_at_overrun = CBcount;
) TCBexlt:
myTask.vblCount = 2;
RestoreA5~);
) /**~*~*~********************~*~**~***~*~********~**************
* NAME: GetNextAV

* PURPOSE: Get some more audlo or vldQo data.
* NB: It's lmportant to use local coples of the rlng buffer polnters * slnce they could change durlng the routlne.
~******~*****~******************************************~***************/
statlc lnt GetNextAV ~ob~ect, channel, maxbufs, nextTA, maxbytes, arlng, af_sync, startBuf, eof, lstat) ob~ect_num_t ob~ect; /* ob~ect to be shown */
channel_t channel; /* whlch channel */
long *nextTA;
long maxbufs; /* llmlt on number of frames ~buffers) wanted */
/* 0 means no llmlt on buffers, */
/* l.e., use as much of rlng buffer as posslble */
long maxbytes; /* llmlt on number of bytes wanted */
/* 0 means no llmlt on bytes, */
/* l.e., use as much of rlng buffer as posslble */
/* Thls parameter ls for audlo bytes only */
/* It ls lgnored for vldeo requests. ~/
reglster AudloRlng *arlng;
AF sync *af sync;
Sound **startBuf; /* Address ~o recelve locatlon of buffer that gets ioaded ~/
Boolean *eof; /* gets set to TRUE lf we are at end-of-flle ~/
lstat t *lstat;

WO 91/10323 2 0 7 1 9 ~ 5 PCI/US90/07482 ~-~or.a ~mg- 27 ~ond~y, ~ - 4, 1989 17:01 char *data;
reglster char *bufptr;
reglster long touchAhead;
long cf;
long default_mask; /* reload mask when mask shlfts to 0 */
long current_mask; /* current state of capture mask */
long bufsFree, buf Uoa~ ~
bufTall, numBufs~htA1 nP~I, h~BufsObtalned;
reglster Sound *~ fRoa~, *AbufTall;
reglster long AbytesFree;
long numBufs;
long numBytesFree;
Boolean re~eatahle;
~ lA~rArRea~_t read_lnfo;
long numBytes~htA1~P~;
char *next_ptr;
numBufs - 0;
*eof = FALSE;
lf (channel ~ OUT_VIDEO) bufHead ~ vbufRoa~;
bufTall - vbufTall;
bufsFree - vbufsFree;
) else ( AbufHead - arlng->AhufRoA~;
AbufTall - arlng->abufTall;
AbytesFree = arlng->abytesFree;
) numPhysBufsOhtA1nPd -- C;
touchAhead - *nextTA;
~nextTA - 0;
lf (touchAhead <- 0) touchAhead - GetTouchAhead(ob~ect, channel, TRUE, STD_CHECR);
lf ~touchAhead <- 0) ( *lstat = ISTAT_OFF END;
goto nAVepl;
) get_frame(ob~ect, channel, frames, lstat);
lf ~*lstat != ISTAT_OK) goto nAVepl;
vlewer result ~ swltcher_outtframes, channel);
/*
<---- data loaded ----->
+

+ _ Ah-fhoa~ +~ abuftall ~/
lf (channel ~ OUT VIDEO) bufptr - ~char *)~VldeoBufl + VldeoF Slze * bufTall);
numBufs - ~bufTall>bufHead ? VID_RING_SIZE - bufTall : bufsFree);

~197~
-4 2-vl~ .a P-g- 28 ~ond y, D~ 4, 1989 17:01 lf ~hufsFree V~D_RING_SIZE) vbufTall = 0;
vbufHead - 0;
vbufsUnplayed = 0;
bufptr - (char ~)VldeoBufl;
bufHead - 0;
bufTall e O;
vldeo_underflows++;

numBufs - mln ~numBufs, touchAhead);
lf ~maxbufs) numBufs - mln ~numBufs, maxbufs);
numBytesFree - numBufs ~ VldeoF S1 ?o;
/~
~ Real numBufs ls ln loglcal buffers, so can be large.
~/
numBufs = touchAhead;

else /~ audlo ~/

/~
lf ~maxbufs > max_audlo_queue_elements) maxbufs = max_audlo_queue_elements;

If the rlng buffer ls empty, then for efflclency sake, reset all the polnters back to the beg1nn1ng.
~/
lf ~AbytesFree e arlng->e~Ahuflpn) arlng->abufTall = arlng->sndbuf;
arlng->~h,1fRP~A ~ arlng->sndbuf;
arlng->abufStaglng = artng->abufTall;
arlng->abufsUnplayed ~ 0;
arlng->abytesFree = arlng->sndbuflen;
arlng->abufsStaged = 0;
arlng->abytesStaged ~ 0;
arlng->1 .- _f ~ arlng->endbuf;

AbufHead ~ arlng->~huf~P1A;
AbufTall = arlng->abufTall;

If the Head ls before the tall and there ls not much room between * the tall and the end of the rlng buffer, then let's arbltrarlly cut the rlng buffer short and wrap around the tall to the beg1nn1ng of the buffer.
~/ , lf ~AbufHead c= AbufTall && AbytesFree > 0 &&
arlng->endbuf-AbufTall < AUD_MIN_BYTE_READ) lf ~AbufHead-arlng->sndbuf >= AUD_MIN_BYTE_READ) arlng->~ - _ = arlng->abufTall;
/t * If there are any samples left staged, we must move them around to the beq1nn1ng of the buffer.
~/
lf ~arlng->abytPsSt~gPd) unclgnPd s~aged = arlng->a_ytesStaged;
movmem~arlng->abufStaglng,arlng->sndbuf,staged);

WO gl/10323 ~ ~ 7 I ~ ~5` PCI/US90/07482 vl- r-r . o P~g- 2 9 ~ond~y, Ds. - 4, 1989 17: 01 arlng-'abufStaglng = arlng->sndbuf;
arlng->abufTall - arlng->sndbuf + arlng->abytesStagsd;
arlng->i . ~ _f -- arlng->abytesStaged;
) else arlng->abufStaglng - arlng->sndbuf;
arlng->abufTall arlng->sndbuf;
) AbufTall = arlng->abufTall;
) ) bufptr = AbufTall;
/*
* If the audlo buffer tall ls beyond the head, t then the number of free bytes goes from the tall to the end of * the buffer.
* Otherwlse (the tall ls before or at the head~, the number t of free bytes goes from the tall to the head.
* However, there ls an ; lgtlollc case of when the head and tall * c~1n~i~o. In thls case, the rlng buffer ls elther completely full * or completely empty. In thls case, we declde that lt ls I completely empty lf abytesfree equals the slze of the rlng buffer.
*/
numBytesFree - ~AbufTall>AbufHead ? arlng->endbuf-AbufTall : AbufHead-AbufTall~;
lf ~numBytesFree ~ O ~ AbytesFree -- arlng->cn~huflon) numBytesFree - arlng->endbuf-AbufTall;
lf ~maxbytes) numBytesFree - mln~numBytesFree,maxbytes);
numBufs - touchAhead;
lf ~numBytesFree - 0) numBufs = 0;
lf ~maxbufs) numBufs = mln ~numBufs, maxbufs);
) lf ~numBytesFree 0) return~0);
lf ~statlstlcs) ~
~*rlnglog)[lognum].before_tlme - Tlcks - rlnglog start_tlme;
~*rlnglog)[lognum].posltlon = apos;
~*rlnglog)[lognum].before vbufHead = VhUfRoa~;
(*rlnglog)[lognuml.before_vbufTall - vbufTall;
(*rlnglog)[lognum].before_vbufsFree - vbufsFree;
(*rlnglog)[lognuml.before ah~fRoa~l - arlngl.ahufuo~a~-arlngl.sndbuf;
~*rlnglog)[lognuml.before_abufTalll = arlngl.abufTall-arlngl.sndbuf;
~*rlnglog)[lognum].before_abytesFreel = arlngl.abytesFree;
~*rlnglog)[lognum].before_endbufl - arlngl.~ r;
~*rlnglog)[lognuml.before_ahllfuoa~ = arlng2.ahllfuoa~-arlng2.sndbuf;
~*rlnglog)[lognuml.before_abufTall2 = arlng2.abufTall-arlng2.sndbuf;
~*rlnglog)[lognum].before_abytesFree2 ~ arlng2.abytesFree;
~*rlnglog)[lognuml.before endbuf2 - arlng2.~._ ` _ ;
~*rlnglog)[lognuml.channel - channel;
~*rlnglog)[lognum].maxbytes ~ maxbytes;
stat_tlmer = Tlcks;
) lf ~maxbytes - 0) maxbytes - numBytesFree;
/*
* Ignore the lstat error. If an extremely serlous * error occurs, then the glst wlll be set to 0.
A mlnor error glves the reason ln lstat and returns a glst * showlng black or sllence or somethlng to let us keep golng.
lf ~vlewer result->glst ;; 0) ( name t source name;

WO 91/10323 ~ ~,7 ~ ~ 7 5 PCI`/US90/07482 v~o~or . c~ Pmgo 30 ~onday, D~ 4, 1989 17:01 lstat t lstat2, lstat3;
t1 -^ ' t start tlme;
MFM CRUX errCrux;
sourceuld t uld;

prlntf(nError ln vlewer: Could not open medla flle.\nn);
errCrux - mfm get CRUX from GIST~vlewer result->glst, Llstat2);

mfm ge~_sourceuld~errCrux,~uld,&lstat3);
lf ~lstat2 ISTAT OK) ~ ~lstat3 ISTAT OK)) SMGetName~uld,source name,&lstat2);
prlntf~" Source tape: is.\nn,source name);
prlntf~" Offset: ~ld.\nn,vlewer result->offset);
start tlme - mfm get start_tlme~errCrux,~lstat2);
/* should also prlnt offset as t1 ' */

check lstat~*lstat);
goto nAVepl;

lf ~rhAnn~l~ouT VIDEO) repeataole = TRUE; /* we can handle r~r~AtAhl~ frames */
else repcatAh1e - FALSE;
mfmTlcks ~ Tlcks;
next ptr - mfm read~vlewer result->glst, vlewer result->offset, bufptr, numBytesFree, numBufs, &read lnfo, ~repeatable, lstat);
mfmTl~c +- Tlcks;
numPhysBufsnhtAlnod - read lnfo.physlcal frames;
~ ~s~htA1nD~ - read lnfo.loglcal frames;
numBytesnhta1 n~ ~ next_ptr - bufptr;
lf ~*lstat ISTAT SOURCE END) *eof = TRUE;

lf ~*lstat != ISTAT OK) goto nAVepl;
lf ~startBuf) *startBuf - ~Sound *)bufptr; /* return buffer to caller */
lf ~channel ~ OUT VIDEO) reglster lnt l;
reglster lnt fr;
fr - vbufTall - l; /* start one back */

vbufTall +- numphysBufsnhtA1n~;
lf ~vbufTall >~ VID_RING SIZE) vbufTall -- VID_RING_SIZE; /* faster than mod */
vbufsUnplayed +- numPhysBufsObtalned;
vbufsFree -- numPhysBufsnhtA1 n~;
/*
* If the flle has an Acsor1Ated capture mask, then some frames have to be * shown multlple tlmes. Set the frame repeat count's correctly ln that case.
*/
default mask - read lnfo.speclflc.vldeo_cm8.capture.mask;
current mask - default_mask read_lnfo.speclflc.vldeo_cm8.capture.shlft;
current_mask l= 0x80000000; /* must show flrst frame */
lf (repeatable) /* abrldged or sllde flle */
frame repeat_count~++fr~ ~ numBufsObtalned;
else /* normal flle */
for ~1-0; 1< numBufsObtalned; l++) lf ~default_mask) lf ~current_mask < 0) WO 91/10323 ~Q 7 1 9:7~ PCI/US90/07482 ~ r . c ~?~g~ 31 ~ond~y, D~ 4, 1989 17:01 frame repeat_count[++fr] - 0;
) frame_repeat_count[fr]++;
current_mask = current_mask <c l;
lf (current-mask = 0) current_mask = default_mask;
) else ( /* no capture mask; set all repeat counts to 1 *t frame_repeat_count[++fr] = l;
) ) TotalVbufs +- numPhys8ufsObtalned;
NumVReads++;
) else /* audlo */
( MFM_CRUX audCrux;
audCrux - mfm_get_CRUX_from_GIST(vlewer_result->glst, STD_CHECK);
af_sync->bytes_loaded = numBytesObtalned;
af_sync->buffers - numBufsObtalned;
af_sync->audlo_mode = read_lnfo.speclClc.audlo.audlomode;
af_sync->channel - channel;
lf (arlng->abufsUnplayed - 0) audlo_underflows++;
lf (numBufsohtA1npd < 0 Il numBufsobtalned*sMALLEsT-AuDIo-BuFFER-sIzE>AuD-RING-ByTE-sIzE) prlntflnOOPS: numbufsobtalned - %ld.\nn,numBufsnbtA1nPd);
lf (channel - OUT_AUDIOl) ( lf ~arlng->abufsStaged < 0 Il arlng->abufsStaged*SMALLEST_AUDIO_BUFFER_SIZE>AUD_RING_BYTE_SIZE) prlntf("OOPS: abufsStaged - %d.\n",arlng->abufsStaged);
) arlng->abufTall += numBytesObtalned;
arlng->abufsUnplayed += numBufsObtalned;
arlng->abytesFree -- numBytpsnh~A1np~;
arlng->abufsStaged += numBufsObtalned;
arlng->abytesStaged +- numBytesObtalned;
lf (channel OUT AUDIOl) ( lf (arlng->abufsStaged < 0 Il arlng->abufsStaged*SMALLEST_AUDIO_BUFFER_SIZE>AUD_RING_BYTE_SIZE) prlntf (nOOPS: abufsStaged = %d.\nn,arlng->abufsStaged);
) ) lf (statlstlcs) ( long frameslze;
(*rlnglog)[lognum].after_tlme - Tlcks - rlnglog_start_tlme;
~*rlnglog)[lognum].bufptr = bufptr;
('rlnglog)[lognum].numBufs - numSufsObtalned;
(*rlnglog)[lognum].after_vbufHead = vbufHead;
(*rlnglog)[lognum].after_vbufTall = vbufTall;
(*rlnglog)[lognum].after_vbufsFree = vbufsFree;
(*rlnglog)[lognum].after_abufHeadl = arlngl.abufHead-arlngl.sndbuf;
(*rlnglog)[lognuml.after_abufTalll = arlngl.abufTall-arlngl.sndbuf;
(-rlnglog)[lognuml.after_abytesFreel = arlngl.abytesFree;
(*rlnglog)[lognum].after_endbufl = arlngl.~,- uf;
(*rlnglog)[lognum].after_ahuf~Pa~ = arlng2.abufHead-arlng2.sndbuf;
~*rlnglog)[lognum].after_abufTall2 = arlng2.abufTall-arlng2.sndbuf;
(*rlnglog)[lognum].after_abytesFree2 = arlng2.abytesFree;
(*rlnglog)[lognum].after_endbuf2 = arlng2.~
(*rlnglog)[lognum].abuflen - numBytesObtalned;
lf ~channel ~ OUT_VlDEO) (-rlnglog)[lognuml.bytes_read - numBufsObtalned * VldeoFrameSlze;

WO 91/10323 ~ i PCI /US90/07482 r r . c --4 6 ~ I?~go 32~ond y, D~ 4, 1989 17:01 else (*rlnglog)[lognum].bytes_read = numBytesObtalned;
lf (lognum c MAX RING LOG ENTRIES~ lognum++;

lf (channel & OUT VIDEO) gather Vstats~numByte~ht~1 nP~ Vlstat);
lf (channel & OUT AUDIOl) qather Astats~numBytesObtalned,Alstat);
lf (channel & OUT AUDIO2) gather Astats~numBytesObtalned,A2stat);

lnc current~ob~ect, numBufsmht~1npd~ channel, lstat);
lf (*lstat != ISTAT OK) goto nAVepl;
nAVepl:
~nextTA - GetTouchAhead~ob~ect, channel, TRUE, STD CHECK);
return ~numPhysBufsObtalned);
) /~***************~**********t*****************7~******~***************

* NAME: play synch tlmer * PURPOSE: Plays an ob~ect at a glven speed ********************************************************************~***/
statlc Boolean play synch tlmer(ob~ect, parms, length, speed, edltBuf) ob~ect num t ob~ect;
prevlew parms t *parms;
long length;
long speed;
short edltBuf;

lstat t lstat;
long startTlcks, vldeo delta, dlff, end, vpos, oldvpos;
long refTlcks, refpos, prevTlck;
float showfortlcks;
Boolean aborted;

lf~length - 0) return~FALSE);
prlntf ~nNot uslng Vlsta.\nn);
new speed - speed;
speed - -10000; /* to get thlngs prlmed */
oldvpos - -1;
vpos = get current~ob~ect, WT VIDE0, ~lstat);
end = vpos + length - l;
aborted = TRUE;
whlle ~TRUE) vpos = max (0, vpos);
vpos - mln ~vpos, end);
lf ~vpos != oldvpos) prevTlck - Tlcks;
set currenttob~ect, vpos, OUT VIDEO, &lstat);
lf ~lstat - ISTAT_OFF_END) prlntf~nIn.,~ -Pd off the end of the CMOB. vpos ~ %ld end = ~ld\n", vpos, end);
vpos - end;

W O 91/10323 2 0 7 ~ ~ 7 ~ Pt~ /US90/07482 r.o ~g~ 33 ~ond~y, D~ 4, 1989 17:01 aborted - FALSE;
goto pstEplloque;
else check_lstat~lstat);
tmPosrhanged tob~ect, edltBuf, vpos, &lstat);
check_lstat tlstat);
oldvpos - vpos;
NumFrames++;
) else lf t tvpos end && speed > 0) ll tvpos - 0 && speed < 0) ) t aborted ~ FALSE;
goto pstEpllogue;
) ) lf (check_abort_keytparms->check_key)) goto pstEpllogue;
lf (new_speed != speed) speed = new_speed;
lf tspeed !e 0) showfortlcks = (vldeo-rate l) / (float)speed;
showfortlcks = abs (showfortlcks);
refpos - vpos;
refTlcks - prevTlck;
) dlff = Tlcks - refTlcks;
lf (speed > 0) vpos ~ refpos + (dlff / showfortlcks);
lf (speed < 0) vpos = refpos - (dlff / showfortlcks);

lf (speed - 0 && !Button ()) goto pstEpllogue;
) aoorted - FALSE;
pstEpllogue:
apos - vpos; /* !!! patch */
return(aborted);
) ~***********************************************************************
* NAME: lnltAudloPlpe * PURPOSE: Inlt1al17pc the audio plpPllnP and preloads as * much audlo data as poQQ1hlP lnto the plp~l1ne * After prPlna~1ng, lt queues them up for playlng.
************************************************************************/
#deflne MAX_PRELOAD_TRANSITIONS 100 statlc vold lnltAudloPlpe(ob~ect, start, max_length, rh~nnPis~ total_length) ob~ect_num t ob~ect;
long start; /* startlng frame number */
long max_length; /* number of frames of audlo avallable for preload */
channel t ch~nn~ls; /* whlch audio rh~nn~lc to play */
long total_length; t* total number of frames of audlo to be played */
reglster lnt bufsLoaded;
lnt bufsTr~AD~;

WO 91/10323 ~ 0 ~ 1~ !i 7 ~- PCI/US90/07482 ~r~ o~r . a --4 8 ~ I?~g~ 34 ~o~d~y, D~ '- 4, 1989 17:01 lstat_t lstat;
lnt translts; t~ number of ;5~, t 5 ln preloaded audlo ~/
Sound ~starts[MAX_eRELOAD_TRANSITI0NS];
A~ nM~p modes[MAX_PRELOAD_TRANSITIONS~;
A~_sync af_syncs[MAX_PRELOAD_TRANSITIONSI;
Sound *aud ptrl, ~aud ptr2;
lnt l;
long audlo_buflen;
long preTlcks;
long preBytes;
long max_lenl, max_len2;
long nextAudTA;
Boolean eof;
Empty~l~A1OR1 nq~l~f fers();
max_lenl - mln~max_length,max_audlo_queue_elementsJ;
max_len2 - max lenl;
aud ptrl = arlngl.sndbuf;
aud ptr2 - arlng2.sndbuf;
translts - 0;
preaytes = 0;
1f (rhAnnPic & OUT_AUDIOl) arlngl.abufsP. ~1 n t ng = total_length;
else arlngl.abuf sr~ ~ 1 n 1 ng = O;
lf ~hannpls & OUT_AUDIO2) arlng2.abufs~ -1 n1 ng - total_length;
else arlng2.abufsR -1 n 1 ng = O;
whlle (TRUE) Read the next segment of audlo ~l.e. plece of audlo medla flle up to next transltlon) ~/
lf (ob~ect-has-two-audlo-~hAnn~ls) ( lf ~max_lenl <s 0 66 max_len2 <= 0) break;
/~
~ Preload channel 1.
~/
nextAudTA - 0;
bufsLoA~Pd = GetNextAV(ob~ect, OUT_AUDIOl, max_lenl, &nextAudTA, 0, &arlngl, &af_syncs[transltsj, 0, &eof, &lstat);
max_lenl -- bufsLoA~P~;
lf (bufsLoaded) ~ n r the length and mode of thls segment.
~/
starts[translts] = aud ptrl;
aud ptrl += af_syncs[translts].bytes_loaded;
lf (statlstlcs) preBytes +e af_syncs[transltsJ.bytes_loaded;
translts++;
lf (trAnelts MAX_PRELOAD_TRANSIT.ONS) break;

/~
~ Preload channel 2.
~/

WO 91/10323 2 Q 7 ~ PCI'/US90/07482 vlo~ror . a ~ 4 9 ~ ~?~g~ 3s ~ond~y, D~ 4, 1989 17:01 nextAudTA - 0;
lf ~ob~ect has two_audlo_rhAnnPlc) bufsLoA~P~7 - GetNextAV~ob~ect, OUT_AUDIO2, max len2, &nextAudTA, 0, &arlng2, &af_syncs[transltsl, 0, &eof, &lstat);
max len2 -= bufsLoa~P~;
lf ~bufsloA~P~7) /~
~ D ' _r the length and mode of thls segment.
~/
starts[translts] - aud ptr2;
aud_ptr2 +- af syncs[translts].bytes_loaded;
lf ~statlstlcs) preBytes +- af_syncs[translts].bytes_loaded;
translts++;
lf ~transLts = MAX_PRELOAD_TRANSITIONS) break;
) lf ~bufsLoaded - 0 && bufsLoaded2 = 0) break;
else /~ - ~urA~ ~/

channel t channel;
AudloRlng ~rlng;
channel - ~hAnnPlq & OUT_AUDIO_ALL;
lf ~max_lenl <= 0) break;
lf ~channel 0~T_AUDI02) rlng ~ &arlng2;
else rlng - &arlngl;
nextAudTA = 0;
bufsLoaded = GetNextAV~ob~ect, channel, max_lenl, &nextAudTA, 0, rlng, &af syncs[translts~, 0, &eof, &lstat);
lf ~bufsLoaded ~- 0) break;
max lenl -- bufsln~P~;
/~
~ Remember the length and mode of thls segment.
~/
starts[translts] - ~channel OUT_AUDIO2 ? aud_ptr2 : aud_ptrl);
lf ~channel OUT_AUDIO2) aud_ptr2 +- af_syncs[transltsl.bytes_loaded;
else aud_ptrl += af syncs[translts].bytes_loaded;
lf ~statlstlcs) preBytes += af syncs[translts].bytes loaded;
translts++;
lf ~translts - MAX PREL0AD_TRANSITIONS) break;
) /*
Now that all that long, tlme cnn 1 ng medla flle I/O ls done, we can queue up all thls audlo to be played.
~/
lf ~statlstlcs) preTlcks = Tlcks;
for~l-0; l<translts; l++) {
Q1 ng ~ rlng;
lf ~af_syncs[l].channel O~T_AUDIO2) rlng - ~arlng2;
else WO 91/10323 2 0 7 ~ 9 7 ~ PCI`/US90/07482 -r . a P-g- 3 6 ~o~dny, D~ 4, 1989 17:01 rlng = 6arlngl;
play audlo~starts~ af syncs[l],rlng);
) lf (statlstlcs) I
preTlcks = Tlcks - preTlcks;
lf ~preTlcks) Alstat->playRate - preBytes/preTlcks;
else Alstat->playRate = 0;

audlo_underflows - 0;
return;
) statlc vold Empty~ 1~R1n~Rllffers() ( arlngl.abufTall = arlngl.sndbuf;
arlngl. ahll f UoaA = arlngl.sndbuf;
arlngl.abufStaglng = arlngl.abufTall;
arlngl.abufsUnplayed = 0;
arlngl.abytesFree = arlngl.sndbuflen;
arlngl.abufsStaged = 0;
arlngl.abytesStaged = 0;
arlngl.t -- `_ ~ arlngl.endbuf;
arlngl.abufsn 1 nt ng = 0;
arlng2.abufTall - arlng2.sndbuf;
arlng2. ahll f ~aA~ ~ arlng2.sndbuf;
arlng2.abufStaglng = arlng2.abufTall;
arlng2.abufsUnplayed = 0;
arlng2.abytesFree = arlng2.sndbuflen;
arlng2.abufsStaged = 0;
arlng2.abytesStaged = 0;
arlng2.~ arlng2.endbuf;
arlng2.abufsR 1 n 1 ng = O;

/*****~****t~****************t********************~*******************
NAME: lnltVldeoPlpe * PUP~POSE: InlttAl1zac the vldeo plpellne and preloads as * much vldeo data as poss1ble lnto the plpellne *******~***~**************~********************************************/
tatlc long lnltVldeoPlpe~ob~ect, start, length) ob~ect_num_t ob~ect;
long start;
reglster long length;
I

reglster lne bufs~ aAa~;
lstat_t lstat;
long nextVldeoTA;
Boolean eof;
vbufTall = 0;
vbuf~ead ~ 0;
vbufsUnplayed = 0;
vbufsFree ~ VID_RING SIZE;
nextVldeoTA = 0;
do ( ufsLoaded = GetNextAV (ob~ect~ OUT_VIDEO, 0, 6nextVldeoTA, VID RING_SIZE*VldeoFrameSlze, 0, 0, 0, 6eof, 61stat);
length -~ bufsLoaded;

WO 91/10323 ~ 0 7 1 g 7 ~i PCI`/US90/07482 ~-r . c Pmg- 3?
~ont y, D~ 4, 1989 17:01 ) whlle ~bufsLoaded != 0 &~ length > 0);
lf lvbufsUnplayed) NVPlayFrame (); /* Trlgger Vlsta to play flrst frame */
vldeo_underflows = 0; /* lgnore preload under-runs */
return((long)vbufsUnplayed);
) /*~***~*~**~*~*~**~*~*~*~************1~*~*
* NAME: sh~ 'eUseVlsta * Purpose: declde lf we should use the vlsta ha ` re or not.
* Returns: TRUE lf the vlewer should use the VISTA board.
FALSE lf lt should not.
statlc Boolean Shn~ _ UseVlsta(parms,speed,vldeo_rate) prevlew_parms_t ~parms;
long speed;
long vldeo_rate;
Boolean UseVlsta;
Polnt vlewerTopLeft, vlewerBottomRlght;
/*
For demo purposes, we allow the user to dlsable the VISTA.
* He does thls by depresslng the shlft key on the keyboard as he cllcks on the play button.

UseVlsta = VlstaPresent;
lf (CurrentEvent.v- f1ers 6 shlftKey) /* for demolng ~/
prlntf (nNot uslng Vlsta.\nn);
UseVlsta - FALSE;

/~
If the user uses the speed bar to select a non-standard speed, then we can not use the VISTA board.
We also don't use the VISTA lf the caller has requested us not to, by settlng ~ the PV_IGNORE_VISTA blt ln the flags argument (ln the parms structure).

lf (speed != vldeo_rate I I parms->flags&PV_IGNORE_VISTA) UseVlsta e FALSE;
/~
If the vlewer rectangle ls not completely lnslde the screen contalnlng ~ the VISTA, then don't use the VISTA.

/~ convert to MAC structure */
vlewerTopLeft.h = parms->area.x_offset;
vlewerTopLeft.v - parms->area.y_offset;
vlewerBottomRlght.h - parms->area.x_offset + parms->area.x slze*parms->zoom;
vlewerBottomRlght.v - parms->area.y offset + parms->area.y_slze~parms->zoom;
/~ swltch to global coordlnates */
LocalToGlobal~6vlewerTopLeft);
LocalToGlobal~6vle~ r~ott~ ~1 ght );
lf ~!PtInRect~vlewerTopLeft, 6l~PrlmaryDevlce)->gdRect) Il 'PtInRect~vlewerLott~ ~1ght,6~PrlmaryDevlce)->gdRect) ) prlntf (nNot uslng Vlsta.\nn);
UseVlsta - FALSE;

~71~75 vi-~ r.~ P-g- 38 ~ond~y, D~ 4, 1989 17:01 return~UseVlsta);

NAME: check abort_key Purpose: Run a user-supplled routlne to check to * see lf the user hlt the abort key, and handle the anlmate abort cleanly.

statlc Boolean check abort key(check key) bfunc ~check key;
lf (check key != NULL) lf ((~check key)(~new speed)) return(TRUE);
) return(FALSE);

W O 91/10323 ~ 0 7 1 ~ ~ S PC~r/US90/07482 ~ r.h Frld~y, July 28, 1989 16:30 /*
~ Include flle for those modules uslng the prevlewer.
*/
/*
~pdates:
9/29/88 GM - Added functlon prototypes.
~/
typedef struct channel t ch ~n~hleA;
avld bltmap t out bltmap;
ag area t area;
bfunc ~check_key;
short zoom;
short squeeze;
long lnc~
u long flags;
~ prevlew_parms_t;
/*
~ flags */
#deflne PV NONE 0x00000000 /* Dlsplay no tlmecode ~/
#deflne PV_SRC 0x0000000l /* Dlsplay source ~1 ?_Ci~ */
#deflne PV DST 0x00000002 /~ Dlsplay destlnatlon t1 _~ */
#deflne PV IGNORE_VISTA 0x00000004 /* Do not use VISTA */
#deflne PV FROM CURRENT -l t~ (START POS) Play from current pos */
oolean show(ob~ect num t ob~ect, prevlew parms t ~parms, long start, long length, long speed, short edlt buf);
vold lnlt vlewer(vold);
vold set audlo rate(long rate);

WO 91/10323 2 0 7 ~ ~ 7 ~ PCr/US90/07482 ~54--r ~t~t~.~ P~g~
~u--d-y, ~ ~L- ` - 5, 1989 21:04 typedef struct ~
long shortAtlcks;
long longAtlcks;
long shortAreads;
long longAreads;
long shortAbytes;
long longAbytes;
long shortestAread;
long longestAread;
long preAtlcks;
long preAreads;
long preAbytes;
long preAspeed;
long shortAspeed;
long longAspeed;
long Aspeed;
long preAaverage;
long shortAaverage;
long longAaverage;
long bothAaverage;
long playRate;
~ AStat;
typedef struct ~
long shortVtlcks;
long longVtlcks;
long shortVreads;
long longVreads;
long shortVbytes;
long longVbytes;
long shortestVread;
long longestVread;
long preVticks;
long preVreads;
long preVbytes;
long preVspeed;
long shortVspeed;
long longVspeed;
long Vspeed;
long preVaverage;
long shortVaverage;
long longVaverage;
long bothVaverage;
~ VStat;
vold clear Vstatlstlcs~VStat ~stat);
vold clear Astatlstlcs(AStat ~stat);
vold reset Vstatlstlcs~VStat ~stat);
vold reset Astatlstlcs(AStat ~stat);
vold prlnt stats(long vldeo rate);
vold gather Vstats~long bytes ~hta1nP~VStat *Vstat);
vold gather Astats~long bytes obta1np~Astat ~Astat);
vold formVstats~VStat ~Vstat), vold formAstats(AStat ~Astat);

WO 91/10323 2 0 7 1 9 7 ~ PCI/US90/07482 v~ r ~vt.~ p~g~
8~tl~--A.y~ , 1989 17 :18 /*
* SLog: ~ ng l nPe rlng:PVCS:Sources:vlewer_pvt.h_v S
* Rev 1.8 11 Nov 1989 17:18:28 stan * keep track of number of audlo frames yet to be played (total) * Rev 1.7 26 Sep 1989 22:10:56 stan * moved ln deflnes from vlewer * Rev 1.6 24 Sep 1989 22:25:42 stan * tunlng * Rev 1.5 22 Sep 1989 03:27:40 stan * ~Yp~n~d audlo rlng buffer * Rev 1.4 07 Sep 1989 00:55:56 stan * dlsplay ln bytes * Rev 1.3 05 Sep 1989 22:16:22 stan * audlo2 stats * Rev 1.2 22 Aug 1989 18:17:38 stan * changes for two ~h~nnr~lC of audlo * Rev 1.1 28 Jul 1989 17:11:14 stan * move ln new ltems from vlewer.h * Rev 1.0 26 Jul 1989 18:00:56 stan * Inltlal revlslon.

/*
* Thls header cont~1n~ data prlvate to the vlewer.
* ~The vlewer lncludes vlewer.c, vlewer_plpe_display.c, and vlewer_stats.c.) */
/*
* Wlth 8-blt mono, one audlo buffer ls 735 bytes when playlng vldeo at 30 frames/sec.
* When playlng vldeo at 24 frames/sec, thls ls 918 bytes lnstead.
* For 16-blt stereo, multlply thls number by 8.
* [The slze of a vldeo frame buffer is 128 X 96 s 12288 bytes.]
* Mono sound buffers must have length that ls a multlple of 3.
*/
#deflne MAX_SAMPLES_PER AUDIO BUFFER MaxSamples #deflne LARGEST_AUDIO_BUFFER_SIZE ~918L * 8L) #deflne SMALLEST_AUDIO_BUFFER_SIZE 735L
#deflne AUD_RING_BYTE_SIZE ~SMALLEST_AUDIO_BUFFER_SIZE * 180L) /* set to 480 for cd quallty */
#deflne AUD MIN_BYTE_READ ~30L * 735L) #deflne TYPICAL_VIDEO_BUFFER_SIZE 12288L
#deflne TYPICAL_AUDIO_BUFFER_SIZE 735L
#deflne MAX REAL_AUDIO_BYTES (80L*735L) #deflne MAX_REAL_VIDEO_BUFS 8 /*
* We have a crltlcal need to read audlo lf the number of avallable audlo * bytes ls less than AUDIO ALERT_BYTES.
* We have a crltlcal need to read vldeo lf the number of avallable vldeo * bytes ls less than VIDEO_ALERT 3YTES.
/

#deflne AUDIO_ALERT_3YTES ~15L * 735L) #deflne VIDEO_ALERT_BYTES ( 6L * 12288L) #define VID_RING_SIZE 20 #deflne VID MIN_READ 5 ~deflne SHORT_READ_BYTES 25000L
~deflne .YAX_RING LOG ENTRIES 1000L_ WO 91/10323 2 0 7 ~ ~ 7 ~ PCI`/US90/07482 v~ r PVt . )~ ~ag- 2 ~atUrtay, ~ , 1989 17 :18 #deflne AUDIO ALERT BUFS 15 #deflne VIDEO_ALERT BUFS 5 #deflne ~ C~:N1 VIDEO BUFS 7 #deflne EFFICIENT AUDIO BYTES ~SOL * 785L) typedef char Sound;
typedef struct Sound *sndbuf; /* polnter to audlo buffer area */
/* ~perr~nDnt; set up upon 1st use) */
long cn~huflDn; /* length ln bytes of audlo rlng buffer */
Sound *ahufRD~; /* ptr to flrst byte of sound stlll to be played */
Sound *abufTall; /* ptr to flrst free byte ln audlo buffer */
lnt abufsUnplayed; /I number of (varlable slzed) audlo buffers stlll */
/* to be played ln the audlo rlng buffer */
lnt abufsStaged; /* number of audlo buffers ln staglng area */
/* waltlng to be queued to the sound acc~l~rAtor */
long abytesFree; /* number of bytes free ln audlo rlng buffer */
/* thls lncludes wasted bytes at the end of the buffer */
/* that were not used because they could not hold a */
/* full audlo buffer */
Sound *abufStaglng; /* polnter to start of staglng area t/
Sound *endbuf; /* polnter to flrst byte after physlcal end of rlng buffer */
Sound ~t .~~ ` ~f; /* polnter to flrst byte after t~ ._rAry end of rlng buffer */
/* needed only when rlng buffer has wrapped around */
/* and there wasn't enough room for another audlo buffer */
long abytesStaged; /* number of bytes loaded lnto rlng buffer */
/* that have not yet been queued to the sound accDlDrator */
long abufsn ln1ng; /* total number of audlo buffers ln se~UDnre . ~1n1ng */
/* to be placed ln the rlng buffer and played */
) AudloRlng;
/*
< data >
<- empty -> <- -- queued > <-- -- staged --- ~ -> <- -- empty ----->
I X I X I X I X I X I X I O I O I O I O I O I O I
~ A A A A

I +<__ ~h-fu~A~ +<----abufStaglng +<----abufTall +<-- sndbuf ~_____> I
I

endbuf --->+
t/
typedef struct ~
long before tlme; /* tlme before read lnltlated A/
long posltlon;
lnt before vbufRe~;
lnt before vbufTall:
lnt before vbufsFree;
long before ~h-fRD~
long before abufTalll;
long before abytesFreel;
Sound ~before endbufl;
long before ~h~fRD~
long before abufTall2;
long before abytesFree2;
Sound *before endbuf2;
channel t channel, /* channel ~ust read ln */
long abuflen;
long maxbytes;
char *bufptr;
long numBufs;
long bytes read; /* bytes ~ust read ln */
long after tlme; /* tlme when read completed */
lnt after vb~fR~
lnt after vbufTall;
lnt after vbufsFree;

W O 91/10323 2 0 7 1 1 7 S PC~r/US90/07482 vi-~ r ~vt.h Pag- 3 S~ A - y, V~ 1, 1989 17:18 long after abufHeadl;
long after abufTaill;
long after abytesFreel;
Sound ~after endbufl;
long after AhufU~
long after a_ufTall2;
long after abytesFree2;
Sound *after endbuf2;
) RlngLog;
statlc vold DlsplayVldeoPlpe ~voldl;
statlc vold InltVPDlsplay Ivold);
statlc vold InltPtrAn1.~plAy (vold);
short show statllnt argc, char ~argv);
short show_plpe~lnt argc, char ~argv);
~oolean check abort key(bfunc ~check key);

Claims (57)

Claims
1. A media pipeline system for displaying digitized audio and video, comprising:
a media file database for accepting and making available a plurality of media files, at least one of said media files having digitized audio media data and at least another one of said media files having video media data, each of said media files being divided into a plurality of frames;
a plurality of ring buffers;
a viewer module comprising procedures to synchronize the transfer of media data from the media files into said plurality of ring buffers, said ring buffers storing the media data before it is displayed;
a video accelerator connected to receive an output of at least one of said ring buffers for generating a video display output; and a sound accelerator connected to receive an output of at least one of said ring buffers for generating an audio output.
2. The system of claim 1 wherein one of said ring buffers receives and stores only audio media and another of said ring buffers receives and stores only video media.
3. The system of claim 2, wherein two of said ring buffers receive and store only audio data.
4. The system of claim 2, further comprising a controller for signalling said sound accelerator to start playing a part of the media data found on a ring buffer containing audio data, said sound accelerator producing an output signal after playing said part, said controller being responsive to said sound accelerator output signal for signalling said video accelerator to start displaying part of the media data stored in a ring buffer containing video data.
5. The system of claim 1, wherein at least one of said audio media files contains audio data for a first audio channel and at least another of said audio media files contains audio data for a second audio channel.
6. The system of claim 5, wherein one of said ring buffers receives and stores only video media data, another one of said ring buffers receives and stores only audio media data for said first channel and another one of said ring buffers receives and stores only audio media data for said second channel.
7. The system of claim 1, wherein said viewer module procedures to synchronize media data transfer include a data transfer coordinator to stage the transfer of data to said plurality of ring buffers so that at any one time the amount of data in one ring buffer is approximately equivalent to the amount of data in at least one other ring buffer.
8. The system of claim 7, wherein said transfer coordinator acts so that at any one time the amount of data in one ring buffer is approximately equivalent to the amount of data in all other ring buffers.
9. The system of claim 1, wherein said viewer module further comprises procedures for determining which of said ring buffers contains the least media data and transferring media data to the ring buffer having the least media data.
10. The system of claim 9, wherein said viewer module procedures include a transfer coordinator for transferring data to a ring buffer in disregard of other conditions when said ring buffer contents are below a predetermined minimum.
11. A method of displaying digitized media data on a monitor, comprising the steps of:
storing the media data in a plurality of media files and a plurality of ring buffers, at least one of which contains video media data and at least one of which contains audio media data;
determining which of the ring buffers contains the least media data;
reading media data from one of the media files into the ring buffer having the least media data;
signaling a sound accelerator card which plays a part of the media data found one of the audio ring buffers;
waiting for an interrupt from the sound accelerator card;
signaling a video accelerator card which plays the a part of the media data found in one of the video ring buffers.
12. The method of claim 11, further comprising the step of executing a critical read operation when the number of bytes contained in a ring buffer is less than a predefined minimum.
13. The method of claim 12, further comprising the step of executing an efficient read operation when the number of bytes contained in a ring buffer is greater than a predefined number.
14. The system of claim 1, wherein the ring buffers re preloaded with data (before playing begins) to increase efficiency.
15. The method of claim 11, further comprising the step of determining the number of bytes of audio needed to properly synchronize with a given amount of video by using a proportion with the amount of video that was associted with this audio when it was digitized.
16. The system of claim 1, further enhanced by a set of capture masks used to efficiently play back material that was captured at fewer than 30 frames per second.
17. A system for playing digitized media data, comprising:
a media file database for accepting and making available a plurality of media files, at least one of said media files containing digitized audio media data and at least one of said media files containing digitized video media data, each of said media files organized in a plurality of frames;
at least one buffer array having an input receiving said media data and having an output providing such media data;
a module comprising means to synchronize a transfer of said media data from the media files into said at least one buffer array, said at least one buffer array storing the media data before the media data is played;
a video display generator connected to receive the output of the at least one buffer array for generating a video display output; and a sound generator connected to receive the output of the at least one buffer array for generating an audio output.
18. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and at least a first of said buffer memories receives and stores only said audio media data and at least a second of said buffer memories receives and stores only said video media data.
19. The system of claim 18 wherein at least two of said buffer memories receive and store only said audio media data.
20. The system of claim 18, further comprising a controller for signaling said sound generator to play at least a part of the audio media data contained in at least one of said buffer memories, said sound generator producing a sound generator output signal after playing said part, said controller being responsive to said sound generator output signal and signaling said video display generator to play at least a part of the video media data stored in at least one of said buffer memories.
21. The system of claim 17, wherein at least a first of said audio media files contains said audio media data for a first audio channel and at least a second of said audio media files contains said audio media data for a second audio channel.
22. The system of claim 21, wherein the at least one buffer array is a plurality of buffer memories and at least a first of said buffer memories receives and stores only said video media data, at least a second of said buffer memories receives and stores only said audio media data for said first channel, and at least a third of said buffer memories receives and stores only said audio media data for said second audio channel.
23. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and said means to synchronize said media data transfer includes a data transfer coordinator to stage the media data transfer to said plurality of buffer memories so that at any one time a first amount of said media data in a first of said buffer memories is at least approximately equivalent to a second amount of said media data in at least a second of said buffer memories.
24. The system of claim 23, wherein said data transfer coordinator acts so that at any one time at least a first amount of said media data in at least a first of said buffer memories is at least approximately equivalent to an amount of said media data in all other of the plurality of buffer memories.
25. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and said module further comprises means for identifying at least one of said buffer memories containing approximately the least amount of media data and transferring said media data from a media file to at least one of said buffer memories containing approximately a least amount of media data.
26. The system of claim 25, wherein said means for synchronizing includes a transfer coordinator for transferring said media data to at least one of said buffer memories in disregard of at least one other condition when said buffer memory contents are below a predetermined minimum amount.
27. A method of playing digitized media data on a monitor, comprising the steps of:
storing the media data in a plurality of media files and a plurality of buffer memories, with at least one of said media files containing video media data and at least one of said media files containing audio media data;
identifying at least one of the buffer memories containing approximately the least amount of media data;
reading said media data from at least one of the media files into at least one of said buffer memories containing approximately the least amount of media data;
signaling a sound generator which plays at least a part of the audio media data contained in at least one of the buffer memories;
waiting for an interrupt from the sound generator;
after receiving the interrupt from the sound generator, signaling a video display generator which plays at least part of the video media data found in at least one of the buffer memories.
28. The method of claim 27, further comprising a step of executing a critical read operation when an amount of said media data contained in at least one of said buffer memories is less than a predefined minimum amount.
29. The method of claim 28, further comprising a step of executing an efficient read operation when an amount of media data free in at least one of said buffer memories is greater than a predefined maximum amount.
30. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and at least one of the buffer memories is preloaded with media data before playing begins.
31. The method of claim 27, further comprising a step of determining a first amount of the audio media data needed to properly synchronize with a second amount of video media data by using a proportion with a third amount of video media data that was associated with the first amount of audio media data when the first amount of audio media data was digitized.
32. The system of claim 17, further enhanced by a set of capture masks used to efficiently play back said media data that was captured at fewer than a minimal number of frames per second.
33. The system of claim 25, wherein said module further includes a transfer coordinator for executing an efficient read operation when an amount of media data free in at least one of said buffer memories is greater than a predefined maximum amount.
34. The system of claim 17, wherein the means for synchronizing includes means for determining a first amount of a second amount of audio media data needed to properly synchronize with a third amount of video media data by using a proportion with a fourth amount of video media data that was associated with the second amount of audio media data when the second amount of audio media data was digitized.
35. The system of claim 17 wherein the at least one buffer array comprises a plurality of ring buffers.
36. A method of playing digitized media data, comprising the steps of:
storing the media data in a media file database that accepts and makes available a plurality of media files, at least one of said media files containing digitized audio media data and at least one of said media files containing digitized video media data;
organizing each of said media files into a plurality of frames;
synchronizing a transfer of said media data from the media files into at least one buffer array wherein the at least one buffer array stores the media data before it is played;
generating a video display output from at least a part of said video media data in the at least one buffer array with a video display generator; and generating an audio output from at least a part of said audio media data in the at least one buffer array with a sound generator.
37. The method of claim 36, wherein the at least one buffer array is a plurality of buffer memories, and wherein the step of synchronizing a transfer of said media data includes steps of storing only video media data in at least a first buffer memory and storing only audio media data in at least a second buffer memory.
38. The method of claim 37, wherein the step of synchronizing a transfer of said media data further includes the step of storing only audio media data in a third buffer memory of said buffer memories.
39. The method of claim 37, further comprising the steps of signaling said sound generator to play at least a part of the audio media data contained in at least one of said buffer memories, said sound generator producing a sound generator output signal after playing said part, being responsive to said sound generator output signal and signaling said video display generator to play at least a part of the video media data stored in at least one of said buffer memories.
40. The method of claim 36, wherein at least a first of said media files contains said audio media data for a first audio channel and at least a second of said media files contains said audio media data for a second audio channel.
41. The method of claim 40, wherein the at least one buffer array is a plurality of buffer memories, and wherein the step of synchronizing a transfer of said media data includes steps of storing only video media data in at least a first buffer memory, storing only audio media data for said first audio channel in a second buffer memory and storing only audio media data for said second audio channel in a third buffer memory.
42. The method of claim 36, wherein the at least one buffer array is a plurality of buffer memories, further comprising a step of coordinating data transfer between the media files and the plurality of buffer memories such that at any one time a first amount of said media data in a first of said buffer memories is at least approximately equivalent to an amount of said media data in at least a second of said buffer memories.
43. The method of claim 42, wherein the step of coordinating includes coordinating the data transfer such that at any one time a first amount of said media data in a first of said buffer memories is at least approximately equivalent to an amount of said media data in all other of the plurality of buffer memories.
44. The method of claim 36, wherein the at least one buffer array is a plurality of buffer memories, and wherein the step of synchronizing a transfer includes steps of identifying at least one of said buffer memories containing approximately a least amount of media data, and transferring said media data from a media file to at least one of said the one buffer memories containing approximately the least amount of said media data.
45. The method of claim 44, wherein the step of synchronizing a transfer includes steps for transferring said media data to at least one of said buffer memories in disregard of at least one other condition when said buffer memory contents are below a predetermined minimum amount.
46. The method of claim 44, further comprising a step of executing a critical read operation when an amount of said media data contained in at least one of the buffer memories is less than a predefined minimum amount.
47. The method of claim 44, further comprising a step of executing an efficient read operation when an amount of media data free in at least one of the buffer memories is greater than a predefined maximum amount.
48. The method of claim 26, further comprising a step of determining a first amount of a second amount of audio media data needed to properly synchronize with a third amount of video media data by using a proportion with a fourth amount of video media data that was associated with the second amount of audio media data when the second amount of audio media data was digitized.
49. A system for playing digitized media data, comprising:
a media data file database for accepting and making available a plurality of media data files, at least one of said media data files containing digitized audio media data and at least one of said media data files containing digitized video media data, each of said media data files organized in a plurality of frames;
a plurality of buffers, each having an input receiving said media data and having an output providing said media data;
means for staging media data from the media files into the buffers, said buffers storing the media data before the media data is played;
a video display generator connected to receive the output of the at least one buffer for generating a video display output; and a sound generator connected to receive the output of the at least one buffer for generating an audio output.
50. A system for playing digitized media data, comprising:
a media file database for accepting and making available at least one of said media data files containing digitized audio media data and at least one of said media data files containing digitized video media data, each of said media files being organized in a plurality of frames;
a plurality of buffers, each having an input receiving said media data and having an output providing said media data;
means for reading media data from at least one media file into each buffer such that an amount of audio media data in one buffer is approximately equivalent to the amount of media data in another buffer, said buffers storing the media data before the media data is played;
a video display generator connected to receive the output of the at least one buffer for generating a video display output; and a sound generator connected to receive the output of the at least one buffer for generating an audio output.
51. The system of claim 49, wherein the at least one media file is stored on a computer readable random access recording medium.
52. A method of playing digitized media data, comprising the steps of:
storing the media data in a media file database that accepts and makes available a plurality of media files, at least one of said media files containing digitized audio media data and at least one of said media files containing digitized video media data;
dividing each of said media files into a plurality of frames;
synchronizing a transfer of said media data from the media files into a plurality of ring buffers wherein said ring buffers store the media data before it is played;
generating a video display output from at least a part of said video media data in at least one of said plurality of ring buffers with a video accelerator; and generating an audio output from at least a part of said audio media data in at least one of said plurality of ring buffers with a sound accelerator.
53. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and said module further comprises procedures for determining at least one of said buffer memories containing approximately the least amount of media data.
54. The system of claim 17, wherein the at least one buffer array is a plurality of buffer memories and said module further comprises means for identifying at least one of said buffer memories containing approximately the least amount of media data.
55. The system of claim 25, wherein said means for synchronizing includes means for executing a critical read operation when an amount of said media data contained in at least one of said buffer memories is less than a predefined minimum amount.
56. The method of claim 36, further enhanced by steps for preloading at least one buffer memory, wherein the at least one buffer array is a plurality of buffer memories, with said media data before playing beings.
57. The method of claim 36, further enhanced by steps for using a set of capture masks, wherein the set of capture masks permit the efficient play back of said media data which was captured at fewer than a minimal number of frames per second.
CA002071975A 1989-12-22 1990-12-19 Media pipeline system Expired - Lifetime CA2071975C (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US455,567 1989-12-22
US07/455,567 US5045940A (en) 1989-12-22 1989-12-22 Video/audio transmission systsem and method

Publications (2)

Publication Number Publication Date
CA2071975A1 CA2071975A1 (en) 1991-06-23
CA2071975C true CA2071975C (en) 1996-04-30

Family

ID=23809361

Family Applications (1)

Application Number Title Priority Date Filing Date
CA002071975A Expired - Lifetime CA2071975C (en) 1989-12-22 1990-12-19 Media pipeline system

Country Status (10)

Country Link
US (2) US5045940A (en)
EP (3) EP1278379A3 (en)
JP (1) JP3168003B2 (en)
KR (1) KR920704509A (en)
AT (1) ATE227488T1 (en)
AU (3) AU652733B2 (en)
CA (1) CA2071975C (en)
DE (1) DE69034016T2 (en)
MC (1) MC2215A1 (en)
WO (1) WO1991010323A1 (en)

Families Citing this family (92)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5253275A (en) 1991-01-07 1993-10-12 H. Lee Browne Audio and video transmission and receiving system
US5262964A (en) * 1991-04-10 1993-11-16 International Business Machines Corporation Method and apparatus for variable playback speed of multimedia data interchange within a data processing system
US5528281A (en) * 1991-09-27 1996-06-18 Bell Atlantic Network Services Method and system for accessing multimedia data over public switched telephone network
US5790174A (en) * 1991-09-27 1998-08-04 Bell Atlantic Network Services, Inc. PSTN architecture for video-on-demand services
US5715018A (en) * 1992-04-10 1998-02-03 Avid Technology, Inc. Digital advertisement insertion system
GB2280778B (en) * 1992-04-10 1996-12-04 Avid Technology Inc Digital audio workstation providing digital storage and display of video information
US6678461B1 (en) 1992-04-10 2004-01-13 Avid Technology, Inc. Media recorder for capture and playback of live and prerecorded audio and/or video information
CA2327070C (en) 1992-07-01 2001-12-25 Avid Technology, Inc. Electronic film editing system using both film and videotape format
US5812216A (en) 1994-04-19 1998-09-22 Avid Technology, Inc. Method and apparatus for creating motion picture transitions according to non-linear light response
US6357047B1 (en) 1997-06-30 2002-03-12 Avid Technology, Inc. Media pipeline with multichannel video processing and playback
US5644364A (en) * 1993-04-16 1997-07-01 Avid Technology, Inc. Media pipeline with multichannel video processing and playback
GB9307894D0 (en) * 1993-04-16 1993-06-02 Avid Technology Inc Multichannel digital image compression and processing
EP0694241A4 (en) * 1993-04-16 1996-05-29 Data Translation Inc Adaptive video decompression
US6006020A (en) * 1993-04-16 1999-12-21 Media 100 Inc. Video peripheral circuitry exercising bus master control over a bus of a host computer
EP1089279A3 (en) 1993-04-16 2004-01-07 Avid Technology, Inc. Synchronisation of multiple media streams
JPH08512439A (en) * 1993-04-16 1996-12-24 データ トランスレイション,インコーポレイテッド Display of subsampled video image on computer display
WO1994024823A1 (en) * 1993-04-16 1994-10-27 Data Translation, Inc. Adaptive video compression using variable quantization
CA2160560A1 (en) * 1993-04-16 1994-10-27 Daniel F. Cutter Video peripheral for a computer
US5506932A (en) * 1993-04-16 1996-04-09 Data Translation, Inc. Synchronizing digital audio to digital video
US5592399A (en) * 1993-05-26 1997-01-07 Intel Corporation Pipelined video encoder architecture
US5551016A (en) * 1993-07-01 1996-08-27 Queen's University At Kingston Monitoring system and interface apparatus therefor
US5463565A (en) * 1993-10-29 1995-10-31 Time Warner Entertainment Co., L.P. Data block format for software carrier and player therefor
US5535137A (en) * 1994-02-14 1996-07-09 Sony Corporation Of Japan Random access audio/video processor with compressed video resampling to allow higher bandwidth throughput
US5583652A (en) * 1994-04-28 1996-12-10 International Business Machines Corporation Synchronized, variable-speed playback of digitally recorded audio and video
JP3816972B2 (en) * 1994-08-08 2006-08-30 株式会社ハイニックスセミコンダクター DIGITAL VIDEO STORAGE SYSTEM, ITS VIDEO DATA STORING METHOD AND VIEWING METHOD
US5613032A (en) * 1994-09-02 1997-03-18 Bell Communications Research, Inc. System and method for recording, playing back and searching multimedia events wherein video, audio and text can be searched and retrieved
JP3548245B2 (en) * 1994-10-04 2004-07-28 キヤノン株式会社 Information recording / reproducing device, information reproducing device, and information reproducing method
US7623754B1 (en) 1995-02-23 2009-11-24 Avid Technology, Inc. Motion picture recording device using digital, computer-readable non-linear media
US6977673B1 (en) 1995-02-23 2005-12-20 Avid Technology, Inc. Portable moving picture recording device including switching control for multiple data flow configurations
US5999406A (en) * 1995-02-23 1999-12-07 Avid Technology, Inc. Dockable electronic equipment container
US7532807B2 (en) * 1995-04-07 2009-05-12 Avid Technology, Inc. Combined editing system and digital moving picture recording system
US6807676B1 (en) 1995-07-14 2004-10-19 General Instrument Corporation Methods of formatting data to maximize the readability and the amount of song identification information displayed on a limited number of lines
US5784095A (en) * 1995-07-14 1998-07-21 General Instrument Corporation Digital audio system with video output program guide
US5761537A (en) * 1995-09-29 1998-06-02 Intel Corporation Method and apparatus for integrating three dimensional sound into a computer system having a stereo audio circuit
US6836295B1 (en) 1995-12-07 2004-12-28 J. Carl Cooper Audio to video timing measurement for MPEG type television systems
KR100207687B1 (en) * 1995-12-09 1999-07-15 윤종용 Decoder for use in mpeg system and audio/video synchronization method
FI107106B (en) * 1996-06-13 2001-05-31 Ville Juhana Ollikainen File server based on a scattered data transfer structure
US5883670A (en) * 1996-08-02 1999-03-16 Avid Technology, Inc. Motion video processing circuit for capture playback and manipulation of digital motion video information on a computer
US6212208B1 (en) * 1996-11-11 2001-04-03 Matsushita Electric Industrial Co., Ltd. Method for coding and multiplexing multimedia data, apparatus for coding and multiplexing multimedia data, record media containing program for coding and multiplexing multimedia data
US6167083A (en) * 1997-04-04 2000-12-26 Avid Technology, Inc. Computer system and process for capture editing and playback of motion video compressed using interframe and intraframe techniques
US6105083A (en) * 1997-06-20 2000-08-15 Avid Technology, Inc. Apparatus and method for controlling transfer of data between and processing of data by interconnected data processing elements
US7295752B1 (en) 1997-08-14 2007-11-13 Virage, Inc. Video cataloger system with audio track extraction
US6567980B1 (en) 1997-08-14 2003-05-20 Virage, Inc. Video cataloger system with hyperlinked output
US6360234B2 (en) 1997-08-14 2002-03-19 Virage, Inc. Video cataloger system with synchronized encoders
US6463444B1 (en) 1997-08-14 2002-10-08 Virage, Inc. Video cataloger system with extensibility
US6426778B1 (en) * 1998-04-03 2002-07-30 Avid Technology, Inc. System and method for providing interactive components in motion video
US6763523B1 (en) 1998-04-03 2004-07-13 Avid Technology, Inc. Intelligent transfer of multimedia data files from an editing system to a playback device
US6961801B1 (en) 1998-04-03 2005-11-01 Avid Technology, Inc. Method and apparatus for accessing video data in memory across flow-controlled interconnects
US20030133448A1 (en) * 1998-04-03 2003-07-17 Craig R. Frink Packet protocol for encoding and decoding video data and data flow signals and devices for implementing the packet protocol
US6833865B1 (en) * 1998-09-01 2004-12-21 Virage, Inc. Embedded metadata engines in digital capture devices
US6766357B1 (en) 1999-04-15 2004-07-20 Avid Technology, Inc. Apparatus and method for efficient transfer of multimedia data for playback
US7120924B1 (en) 2000-02-29 2006-10-10 Goldpocket Interactive, Inc. Method and apparatus for receiving a hyperlinked television broadcast
US7367042B1 (en) 2000-02-29 2008-04-29 Goldpocket Interactive, Inc. Method and apparatus for hyperlinking in a television broadcast
US7343617B1 (en) 2000-02-29 2008-03-11 Goldpocket Interactive, Inc. Method and apparatus for interaction with hyperlinks in a television broadcast
US7725812B1 (en) 2000-03-31 2010-05-25 Avid Technology, Inc. Authoring system for combining temporal and nontemporal digital media
US7260564B1 (en) 2000-04-07 2007-08-21 Virage, Inc. Network video guide and spidering
US7962948B1 (en) 2000-04-07 2011-06-14 Virage, Inc. Video-enabled community building
US7555557B2 (en) * 2000-04-07 2009-06-30 Avid Technology, Inc. Review and approval system
US7222163B1 (en) 2000-04-07 2007-05-22 Virage, Inc. System and method for hosting of video content over a network
US8171509B1 (en) 2000-04-07 2012-05-01 Virage, Inc. System and method for applying a database to video multimedia
US6816835B2 (en) * 2000-06-15 2004-11-09 Sharp Kabushiki Kaisha Electronic mail system and device
US20020188628A1 (en) * 2001-04-20 2002-12-12 Brian Cooper Editing interactive content with time-based media
US7930624B2 (en) * 2001-04-20 2011-04-19 Avid Technology, Inc. Editing time-based media with enhanced content
EP1440379A4 (en) * 2001-10-31 2008-11-05 Thomson Licensing Admission control system for home video servers
US9330060B1 (en) * 2003-04-15 2016-05-03 Nvidia Corporation Method and device for encoding and decoding video image data
US8660182B2 (en) * 2003-06-09 2014-02-25 Nvidia Corporation MPEG motion estimation based on dual start points
US7760918B2 (en) * 2003-08-06 2010-07-20 Zinayida Bezvershenko Identification of a person based on ultra-sound scan analyses of hand bone geometry
CA2438220C (en) * 2003-08-06 2011-11-08 Click-Into Inc. Identification of a person based on ultra-sound scan analyses of hand bone geometry
US8423597B1 (en) 2003-08-29 2013-04-16 Nvidia Corporation Method and system for adaptive matrix trimming in an inverse discrete cosine transform (IDCT) operation
US7983835B2 (en) 2004-11-03 2011-07-19 Lagassey Paul J Modular intelligent transportation system
US8797926B2 (en) 2004-06-04 2014-08-05 Apple Inc. Networked media station
US8443038B2 (en) 2004-06-04 2013-05-14 Apple Inc. Network media device
US20070110074A1 (en) 2004-06-04 2007-05-17 Bob Bradley System and Method for Synchronizing Media Presentation at Multiple Recipients
US10972536B2 (en) 2004-06-04 2021-04-06 Apple Inc. System and method for synchronizing media presentation at multiple recipients
US7631119B2 (en) 2004-06-25 2009-12-08 Apple Inc. Techniques for providing audio for synchronized playback by multiple devices
US7620753B1 (en) 2005-03-17 2009-11-17 Apple Inc. Lockless access to a ring buffer
US7792024B1 (en) 2005-03-18 2010-09-07 Apple Inc. IO latency reduction
US8731071B1 (en) 2005-12-15 2014-05-20 Nvidia Corporation System for performing finite input response (FIR) filtering in motion estimation
US8724702B1 (en) 2006-03-29 2014-05-13 Nvidia Corporation Methods and systems for motion estimation used in video coding
US8660380B2 (en) * 2006-08-25 2014-02-25 Nvidia Corporation Method and system for performing two-dimensional transform on data value array with reduced power consumption
US8756482B2 (en) * 2007-05-25 2014-06-17 Nvidia Corporation Efficient encoding/decoding of a sequence of data frames
US20080291209A1 (en) * 2007-05-25 2008-11-27 Nvidia Corporation Encoding Multi-media Signals
US9118927B2 (en) * 2007-06-13 2015-08-25 Nvidia Corporation Sub-pixel interpolation and its application in motion compensated encoding of a video signal
US8873625B2 (en) * 2007-07-18 2014-10-28 Nvidia Corporation Enhanced compression in representing non-frame-edge blocks of image frames
US8666181B2 (en) * 2008-12-10 2014-03-04 Nvidia Corporation Adaptive multiple engine image motion detection system and method
US8559793B2 (en) 2011-05-26 2013-10-15 Avid Technology, Inc. Synchronous data tracks in a media editing system
US9798698B2 (en) 2012-08-13 2017-10-24 Nvidia Corporation System and method for multi-color dilu preconditioner
US9210204B2 (en) 2013-10-31 2015-12-08 At&T Intellectual Property I, Lp Synchronizing media presentation at multiple devices
US11297369B2 (en) 2018-03-30 2022-04-05 Apple Inc. Remotely controlling playback devices
US10783929B2 (en) 2018-03-30 2020-09-22 Apple Inc. Managing playback groups
US10993274B2 (en) 2018-03-30 2021-04-27 Apple Inc. Pairing devices by proxy
US10614857B2 (en) 2018-07-02 2020-04-07 Apple Inc. Calibrating media playback channels for synchronized presentation

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US3609227A (en) * 1968-09-09 1971-09-28 Ampex Random access audio/video information retrieval system
US4536836A (en) * 1981-11-27 1985-08-20 Storage Technology Corporation Detection of sequential data stream
US4667286A (en) * 1984-12-20 1987-05-19 Advanced Micro Devices, Inc. Method and apparatus for transferring data between a disk and a central processing unit
US4698664A (en) * 1985-03-04 1987-10-06 Apert-Herzog Corporation Audio-visual monitoring system
FR2611942B1 (en) * 1987-02-25 1991-11-29 France Etat BROADBAND SERVER, PARTICULARLY FOR TRANSMISSION OF MUSIC OR IMAGES
US4882743A (en) * 1988-08-01 1989-11-21 American Telephone And Telegraph Multi-location video conference system
US4949169A (en) * 1989-10-27 1990-08-14 International Business Machines Corporation Audio-video data interface for a high speed communication link in a video-graphics display window environment

Also Published As

Publication number Publication date
EP1278379A3 (en) 2003-02-26
ATE227488T1 (en) 2002-11-15
EP0830026A3 (en) 1999-02-10
AU670875B2 (en) 1996-08-01
DE69034016T2 (en) 2003-07-17
EP0830026A2 (en) 1998-03-18
AU6603894A (en) 1994-09-22
WO1991010323A1 (en) 1991-07-11
AU652733B2 (en) 1994-09-08
AU685712B2 (en) 1998-01-22
US5045940A (en) 1991-09-03
AU7143391A (en) 1991-07-24
JPH05502989A (en) 1993-05-20
DE69034016D1 (en) 2002-12-12
AU7057796A (en) 1997-01-16
KR920704509A (en) 1992-12-19
CA2071975A1 (en) 1991-06-23
EP0506877A4 (en) 1993-07-14
JP3168003B2 (en) 2001-05-21
EP0506877A1 (en) 1992-10-07
EP1278379A2 (en) 2003-01-22
EP0830026B1 (en) 2002-11-06
MC2215A1 (en) 1992-11-26
USRE40107E1 (en) 2008-02-26

Similar Documents

Publication Publication Date Title
CA2071975C (en) Media pipeline system
US5828904A (en) System for data retrieval by scheduling retrieval if number of units scheduled equals or less than predetermined number and retrieving before or at time elapsed
US5737531A (en) System for synchronizing by transmitting control packet to omit blocks from transmission, and transmitting second control packet when the timing difference exceeds second predetermined threshold
US8699854B2 (en) Method for reproducing data recorded on an interactive recording medium in conjunction with associated auxiliary data
JP2908977B2 (en) server
US6578070B1 (en) Method and apparatus for implementing seamless playback of continuous media feeds
US7149868B2 (en) Analyzing, indexing and seeking of streaming information
JP2002517138A (en) Method of recording compressed digital audio and video
EP0660221A1 (en) Method for controlling real-time presentation of audio/visual data on a computer system
US20060039680A1 (en) Playback control methods and arrangements for a DVD player
US5951690A (en) Synchronizing an audio-visual stream synchronized to a clock with a video display that is synchronized to a different clock
JP2002057985A (en) Method and device for decoding digital video stream through insertion of dummy header in digital video system
EP1223756A2 (en) Digital recording/playback apparatus
US7184653B2 (en) Unique digital content identifier generating methods and arrangements
US7194548B1 (en) Data transmission apparatus, receiving apparatus, and sending apparatus
KR20050103503A (en) Method of reproducing content information for an interactive optical disk apparatus
US20040103445A1 (en) Method for reproducing contents information in interactive optical disc device and method for providing contents information in contents provider server
WO2015038186A1 (en) Auxiliary content synchronization system and method
KR20050059219A (en) Method for recording of data stream on multiple recording media
US8548301B2 (en) Record carrier carrying a video signal and at least one additional information signal
US7835614B2 (en) Data recording method, data recording apparatus, and data recording medium
JPH1010653A (en) Synchronization controller
KR20040076560A (en) Method for reproducing contents information in interactive optical disc player
JPH04326165A (en) Picture processor

Legal Events

Date Code Title Description
EEER Examination request
MKLA Lapsed
MKLC Lapsed (correction)
MKLC Lapsed (correction)

Effective date: 20070124