DSP Blockset
  Go to block:
    Search    Help Desk 
Rebuffer    See Also

Rebuffer the input sequence to a smaller or larger frame size.

Library

Buffers, in General DSP

Description

The Rebuffer block redistributes the input samples to a new frame size, larger or smaller than the input frame size. Rebuffering to a larger frame size yields an output with a slower frame rate than the input.

Rebuffering to a smaller frame size yields an output with a faster frame rate than the input.

The block coordinates the output frame size and frame rate of nonoverlapping buffers so that the sequence sample period (i.e., the sample-to-sample interval) is the same at both the input and output, Tso=Tsi.

The Frame-based inputs check box allows you to choose between sample-based and frame-based operation.

Sample-Based Operation

For sample-based operation (default), the Frame-based inputs check box in the parameter dialog box is not selected, and the Rebuffer block creates frame-based outputs from the sample-based inputs.

Scalar Inputs.    Scalar inputs are buffered into a vector frame (top illustration, initial delay not shown). The size of the output frame, Mo, is determined by the Buffer size parameter. The Buffer overlap parameter specifies the number of samples, L, from the previous buffer to include in the current buffer. The number of new input samples the block acquires before propagating the buffered data to the output is the difference between the Buffer size and Buffer overlap, Mo-L.

The output frame period is (Mo-L)*Tsi, which is equal to the sequence sample period, Tsi, when the Buffer overlap is Mo-1. For negative Buffer overlap values, the block simply discards L input samples after the buffer fills, and outputs the buffer with period (Mo-L)*Tsi, which is slower than the zero-overlap case.

Note
To multiplex independent scalar channels into a multichannel vector signal, use the Simulink Mux block.

Vector Inputs.    In sample-based operation, a sequence of length-N vector inputs is buffered into a Mo-by-N matrix, where Mo is specified by the Buffer size parameter. Each of the N input vector elements represents a distinct channel.

The illustration below shows the block operating on a 4-channel vector input with a Buffer size of 3 and a Buffer overlap of 1.

The output frame period of (Mo-L)*Tsi is the same as that for scalar inputs, described above.

Note that the input sample vectors do not begin appearing at the output until the second row of the second matrix. The first output matrix (all zeros in this example) reflects the block's initial buffer, while the first row of zeros in the second output is a result of the one-sample overlap between consecutive output frames.

You can use the rebuffer_delay function with a frame size of 1 to precisely compute the delay (in samples) for sample-based signals. For the above example,

This agrees with the four samples of delay (zeros) shown in the figure above.

Matrix Inputs.    In sample-based operation, an M-by-N matrix input is treated as a single vector with M*N elements. In other words, the matrix input u is reshaped to the vector input u(:).

Frame-Based Operation

For frame-based operation, the Frame-based inputs check box in the parameter dialog box is selected and the Rebuffer block redistributes the samples in the input frame to an output frame of different size and rate.

Scalar Inputs.    Scalar input processing is the same for frame-based operation as for sample-based operation. The Number of channels parameter must be set to 1.

Vector Inputs.    In frame-based operation, a length-Mi vector input represents a single frame of data (Mi sequential samples) from one channel. The Number of channels parameter should correspondingly be set to 1. The Buffer size specifies the size of the output frame, i.e., the number of consecutive samples from the input frame to rebuffer into the output frame. This value, Mo, can be greater or less than the number of samples in the input frame.

The Buffer overlap parameter specifies the number of samples, L, from the previous buffer to include in the current buffer. The number of new samples the block acquires before propagating the buffered data to the output is the difference between the Buffer size and Buffer overlap, Mo-L.

The input frame period is Mi*Tsi, where Tsi is the sequence sample period. The output frame period is (Mo-L)*Tsi, which is equal to the sequence sample period when the Buffer overlap is Mo-1. The output sample period is therefore related to the input sample period by

Negative Buffer overlap values are not permitted.

The illustration below shows the block rebuffering a 1-channel input with a Buffer size of 3 and a Buffer overlap of 1.

Note that the sequence is delayed by eight samples, and the first eight output samples adopt the value specified for the Initial condition, which is zero in this example. Use the rebuffer_delay function to determine the length of this initial delay for any combination of frame size and overlap.

Matrix Inputs.    The block's operation for frame-based vector inputs extends naturally to frame-based matrix inputs. In frame-based operation, an Mi-by-N matrix input is treated as a collection of N frames, each containing Mi sequential time samples from an independent signal. The Number of channels parameter specifies the number of independent signals (columns, N) in the matrix.

The Buffer size and Buffer overlap parameters work the same for matrix inputs as for vector inputs, described above. The number of columns in the output is the same as the input (i.e., each of the N channels is preserved in the output).

The figure below shows the block buffering a 2-channel input with a Buffer size of 3 and a Buffer overlap of 1.

Initial Conditions

The Rebuffer block's buffer is initialized to the value specified by the Initial condition parameter, and the block repeats this buffer at the output for the first D steps of the simulation (from t=0 to t=D-1), where D is the initial delay. For sample-based operation, D equals Mo-L. For frame-based operation, use the rebuffer_delay function to compute the exact delay (in samples) that the Rebuffer block introduces for a given combination of buffer size and buffer overlap.

For general frame-to-frame rebuffering, the Initial condition must be a scalar value, which is then repeated across all elements of the initial output(s). In the special case where the input is a N-channel sample vector (and the block's output is therefore an Mo-by-N frame matrix), the Initial condition can be:

In the special case where the output is a sample vector (the result of unbuffering an Mi-by-N frame matrix or a length-Mi frame vector), the Initial condition can be:

Note
If you expect to generate code for the Rebuffer block using the Real-Time Workshop, you should ensure that inputs are contiguous in memory. See the Contiguous Copy block for more information.

Dialog Box

Buffer size
The number of consecutive samples, Mo, from each channel to buffer into the output frame.
Buffer overlap
The number of samples, L, by which consecutive output frames overlap.
Initial conditions
The value of the block's initial output, a scalar, vector, or matrix.
Frame-based inputs
Selects frame-based operation.
Number of channels
For frame based operation, the number of channels (columns, N) in the input matrix.

See Also

Buffer
Distributor
Partial Unbuffer
Shift Register
Unbuffer
rebuffer_delay


[ Previous | Help Desk | Next ]