next up previous contents index
Next: 1.4 Related Work Up: 1. Introduction Previous: 1.2 Application Modeling   Contents   Index

1.3 Example

We illustrate the use of YAPI with an example of a filter that scales video lines. The purpose of the example is twofold. First we illustrate the combination of deterministic and non-deterministic communication. Second we illustrate the decoupling of the data types that are used for communication and computation. To this end we assume that the filter receives a stream of window widths from a window manager through input port $p$ and a stream of pixels from a video source through input port $q$. The function of the filter is to scale the incoming video frames according to the incoming window widths and to transmit the resulting stream of pixels through output port $r$ as outlined in the code fragment shown in Figure 1.4.

Figure 1.4: Horizontal Video Scaling
\begin{figure}\centerline{\epsfig{figure=Figures/horscaler.eps,width=0.75\textwidth}}\end{figure}

The video source and the window manager are not synchronized. We assume that the video source produces frames at a constant rate using write action $\mbox{\it write}(p', f, h \times w)$, where $p'$ is an output port and $f$ is a video frame of $h$ video lines that each contain $w$ video pixels. The behavior of the window manager is unknown because it is controlled by the user. In order to cope with the non-deterministic behavior of the window manager we guard the read action of the window width in the filter with the select action $\mbox{\it select}(p, 1, q, h \times w)$. If the select action returns 0 then this indicates that port $p$ can deliver one token. Hence, we initiate the read action $\mbox{\it read}(p, w', 1)$ to obtain the new window width $w'$ without the danger of blocking forever. If the select action returns 1 then this means that port $q$ can deliver $h \times w$ tokens. Hence, we initiate the filtering of the next video frame. The resulting latency between input and output depends on the granularity of the filter. The filter shown in the example is line-based which means that it reads the video frame by $h$ consecutive read actions $\mbox{\it read}(q,l,w)$ where $l$ represents a video line of $w$ pixels thereby introducing a latency of one video line. Frame-based and pixel-based filters are also feasible. Note that in this scenario it is possible to scale two or more video frames to the same window width, but that it is not possible to change the width of a window in the middle of a video frame. In order to specify the latter, for instance to allow non-rectangular windows, the select action should be moved to the inner loop that iterates over the video lines.


next up previous contents index
Next: 1.4 Related Work Up: 1. Introduction Previous: 1.2 Application Modeling   Contents   Index
© Copyright Koninklijke Philips Electronics NV 2006