Alpha Blending Mixer Picture-in-Picture Design Example
This design example illustrates how to implement picture-in-picture (PiP) video mixing using Altera's Alpha Blending Mixer MegaCore® function in DSP Builder. In PiP, the background video is played in the center of the screen, while smaller square video clips are played in corners of the screen. The Alpha Blending Mixer MegaCore function allows up to eight video image layers to play simultaneously. Furthermore, every foreground layer can use a different alpha value to control its transparency, resulting in true image blending effects.
In this design example, two video image layers demonstrate the operation of PiP. User-specified location information for the foreground layer is loaded into the Alpha Blending Mixer MegaCore function's control registers (via the Avalon® memory-mapped control interface) prior to the input of the video streams. Once the location information is decided for all image layers, the input data streams are mixed in the Alpha Blending Mixer MegaCore function. The output video data is written into a binary data file using MATLAB Simulink Video Sink. Using a video conversion utility provided in this package, you can convert the output binary file to an .avi file for display. A binary-to-avi conversion block is included in the design to implement the video conversion automatically. The final output of this design example is pre-simulated and stored as a reference in caroutput.avi at 3 fps.
Download the files used in this example:
Files in the zip download include:
- alpha_mixer.mdl - DSP Builder design file
- ini.m - MATLAB initialization file for the design example
- avi-is-avi.exe - DOS executable to convert an avi file to and from a binary file
- background.bin - Input 640 x 480 background binary video stream
- foreground.bin - Input 176 x 144 foreground binary video stream
- caroutput.avi - Pre-simulated output video
Figure 1. Top-Level Diagram of the Alpha Blending Mixer Picture-in-Picture Design Example in DSP Builder

View Full Size
In this example, the Alpha Blending Mixer intellectual property (IP) MegaCore function uses the parameters shown in Table 1.
| Table 1. Parameter Description |
| Parameter |
Value |
Description |
| Number of Layers |
2 |
Number of image layers to overlay |
| Input Resolution |
- |
640 width x 480 height (pixels) for background layer
176 width x 144 height (pixels) for foreground layer |
| Bits-Per-Pixel Per Color Plane |
8 |
Number of bits per pixel per plane |
| Number of Color Planes in Sequence |
3 |
Input video streams are sent as R'G'B' R'G'B' R'G'B' |
| Enable Alpha Blending |
on |
Alpha data sink ports are generated for streams of alpha values |
| Alpha Bits-Per-Pixel Per Color Plane |
4 |
Number of bits used to represent the alpha coefficient |
| Foreground Alpha Input Value |
4 |
Foreground layer has equivalent alpha value 0.25 |
Foreground Image Location
X Coordinate |
463 |
The X coordinate of the bottom-left corner of the foreground layer |
Foreground Image Location
Y Coordinate |
335 |
The Y coordinate of the bottom-left corner of the foreground layer |
Signals
Table 2 defines the input and output signals of the Alpha Blending Mixer MegaCore function.
| Table 2. Signals for the Alpha Blending Mixer MegaCore Function |
| Signal |
Direction |
Description |
alpha_in_1_data |
Input |
Alpha data stream for the foreground layer. |
alpha_in_1_valid |
Input |
Alpha data valid signal for the foreground layer. |
| alpha_in_0_data |
Input |
Alpha data stream for the foreground layer. |
| alpha_in_0_valid |
Input |
Alpha data valid signal for the foreground layer. |
din_0_data |
Input |
Data input bus for the background layer. |
din_0_valid |
Input |
Data valid signal for the background video stream. |
din_1_data |
Input |
Data input bus for the foreground layer. |
din_1_valid |
Input |
Data valid signal for the foreground video stream. |
dout_ready |
Input |
Data output ready signal. |
control_av_address |
Input |
Avalon memory-mapped slave interface mixer control address lines. Specifies control register offsets into the slave address space. |
control_av_chipselect |
Input |
Avalon slave interface mixer control chip-select signal. The input port ignores all other Avalon signal inputs unless this signal is asserted. |
control_av_write |
Input |
Avalon slave interface mixer control write request signal. |
control_av_writedata |
Input |
Avalon slave interface mixer control lines for write data transfers. Video image location information is written into the control registers. |
control_test_writetog |
Output |
Test port associated with Avalon-MM slave port mix_control. This port exists for internal testing purposes only and should not be connected in the user design. |
reset |
Input |
MegaCore function asynchronous reset signal. |
alpha_in_0_ready |
Output |
Alpha data input ready signal for the background. |
alpha_in_1_ready |
Output |
Alpha data input ready signal for the foreground. |
din_0_ready |
Output |
Video image data input ready signal for the background. |
din_1_ready |
Output |
Video image data input ready signal for the foreground. |
dout_data |
Output |
Data output bus. |
control_av_readdata |
Output |
Avalon-MM readdata bus of slave port mix_control. These output lines are used for read transfers. |
control_test_writeack |
Input |
Test port associated with Avalon-MM slave port mix_control. This port exists for internal testing purposes only and should not be connected in the user design. |
dout_valid |
Output |
Data valid signal that indicates the validity of the output data signals. |
Related Links
|