Chapter 4. Compiling Native Language Video Formats

Compiling video formats is similar to compiling any other source language. A good place to start is with the man (reference) page (vfc); this shows the different options available to you.

Moreover, using the compiler to create video format object files from your own source files is similar to using templates. You can read “How to Use the Compiler With Templates” for a description of that process.

This chapter describes the following topics:

Specification of Rules Files

You can write a video format to run on multiple architectures. However, it must be compiled independently for each architecture. To compile for each architecture, you must specify two distinguishing characteristics of the target hardware: the chip and board which will run the timing you generate with the compiler.

Use the -c option to specify the rules files used for each chip and board. For example, if the rules file for the chip is samplechip.def and the board is sampleboard.def, you would use the following syntax:

vfc -c chip=samplechip.def,board=sampleboard.def ...

Refer to vfc(1) for details of which chip and board to use for each architecture. The man (reference) page there is updated more frequently than is this document.

Format Analysis

When it compiles a format, the video format compiler analyzes the frame to determine locations and durations of salient features, such as sync, back porch, and so on. You can use the -a ascii option to get a textual description.

Example 4-1. Use of -a ascii Output


1280x1024_60.vfo:
 Total lines per frame:   1065
 Total pixels per line:   1680
 Active lines per frame:  1024
 Active pixels per line:  1280
 Frames per second:       60
 Fields per frame:        1
 Swaps per frame:         1
 Pixel clock:             107.352 MHz, period = 9.31515 nsec
 Hardware pixel rounding:  every 2 pixels
 Line analysis: 
  Length:                 1680 Pixels, 1 Lines, 15.6495 usec; (line 0)
  Frequency:              63.9 KHz, period = 15.6495 usec
 Horizontal Sync:         120 Pixels, 1.11782 usec; (line 38)
 Horizontal Back Porch:   240 Pixels, 2.23564 usec; (line 38)
 Horizontal Active:       1280 Pixels, 11.9234 usec; (line 38)
 Horizontal Front Porch:  40 Pixels, 372.606 nsec; (line 38)
 Field Information:
  Field Duration:           1.7892e+06 Pixels, 1065 Lines, 16.667 msec; (line 0)
  Vertical Sync:            5040 Pixels, 3 Lines, 46.9484 usec; (line 0)
  Vertical Sync Pulse:      5160 Pixels, 3.07143 Lines, 48.0662 usec; (line 0)
  Vertical Back Porch:      58800 Pixels, 35 Lines, 547.731 usec; (line 3)
  Vertical Active:          1.72e+06 Pixels, 1024 Lines, 16.025 msec; (line 38)
  Vertical Front Porch:     5040 Pixels, 3 Lines, 46.9484 usec; (line 1062)

In Example 4-1, you can see the output created by -a ascii to the standard high-resolution video format (the format source is in Example 5-1). The definitions of each of the named sections is in the tutorial in Chapter 3, “Building Blocks of a Video Format.” In parentheses, following some specifications, you will find the line number on which the compiler made the determination of each item.

You can optionally specify a file name as an argument to this option, as in -a ascii=/usr/tmp/foo; the default is stdout.

The Pre-Processor and Its Options

As a convenience to users, vfc uses a pre-processor when compiling formats. The default is cc -E (see cc(1) for more information on the C-language preprocessor); however, not all users have the C development environment. To use a different pre-processor, use the -i option.

The -p option to vfc allows you to pass options directly to the pre-processor. Be certain to quote the string you pass, for example:

vfc -p "-DFPS=30" ...

When you quote the string, it keeps vfc from interpreting the pre-processor's option as one of its own.