Table of Contents

NAME

QccVIDSpatialBlockEncode, QccVIDSpatialBlockDecode - encode/decode an image sequence using the spatial-block algorithm

SYNOPSIS

#include "libQccPack.h"

int QccVIDSpatialBlockEncode(QccIMGImageSequence *image_sequence, const QccFilter *filter1, const QccFilter *filter2, const QccFilter *filter3, int subpixel_accuracy, QccBitBuffer *output_buffer, int blocksize, int num_levels, int target_bit_cnt, const QccWAVWavelet *wavelet, const QccString mv_filename, int read_motion_vectors, int quiet);

int QccVIDSpatialBlockDecodeHeader(QccBitBuffer *input_buffer, int *num_rows, int *num_cols, int *start_frame_num, int *end_frame_num, int *blocksize, int *num_levels, int *target_bit_cnt);

int QccVIDSpatialBlockDecode(QccIMGImageSequence *image_sequence, const QccFilter *filter1, const QccFilter *filter2, const QccFilter *filter3, int subpixel_accuracy, QccBitBuffer *input_buffer, int target_bit_cnt, int blocksize, int num_levels, const QccWAVWavelet *wavelet, const QccString mv_filename, int quiet);

DESCRIPTION

Encoding

QccVIDSpatialBlockEncode() encodes an image_sequence using the spatial-block video-coding algorithm. Essentially, the spatial-block algorithm involves traditional block-based motion estimation and motion compensation in the spatial-domain followed by a wavelet-based embedded coding of the motion-compensation resdiual; see "ALGORITHM" below for greater detail.

image_sequence is the image sequence to be coded and should indicate a collection of grayscale images of the same size stored as separate, numbered files; the filename indicated by image_sequence must contain one printf(3) -style numerical descriptor which will then be filled in the current frame number (e.g., football.%03d.pgm will become football.000.pgm, football.001.pgm, etc.; see QccPackIMG(3) ). Each frame of image_sequence must have a size which is an integer multiple of blocksize both horizontally and vertically. Both the start_frame_num and end_frame_num fields of image_sequence should indicate the desired starting and stopping frames, respectively, for the encoding; these should either be set manually or via a call to QccIMGImageSequenceFindFrameNums(3) prior to calling QccVIDSpatialBlockEncode().

filter1, filter2, and filter3 are interpolation filters for supporting the subpixel accuracy specified by subpixel_accuracy which can be one of QCCVID_ME_FULLPIXEL, QCCVID_ME_HALFPIXEL, QCCVID_ME_QUARTERPIXEL, or QCCVID_ME_EIGHTHPIXEL, indicating full-, half-, quarter-, or eighth-pixel accuracy, respectively.

output_buffer is the output bitstream which must be of QCCBITBUFFER_OUTPUT type and opened via a prior call to QccBitBufferStart(3) .

num_levels gives the number of levels of dyadic wavelet decomposition to perform, and wavelet is the wavelet to use for decomposition.

When encoding the current frame, QccVIDSpatialBlockEncode() will first output to output_buffer all the motion vectors for the frame, and then an embedded intraframe encoding of the motion-compensated residual. target_bit_cnt is the desired number of bits to output for each frame, including motion vectors and motion-compensated residual. After target_num_bits have been produced for the current frame, QccVIDSpatialBlockEncode() will call QccBitBufferFlush(3) to flush the bit-buffer contents to the output bitstream. Encoding of the next frame starts on the next byte boundary of the output bitstream.

mv_filename gives the filename for files of motion vectors. If read_motion_vectors is FALSE, then the motion-vectors are written to mv_filename via QccVIDMotionVectorsWriteFile(3) . mv_filename should have a printf(3) -style numerical descriptor which will then be filled in with the current frame number before writing, so that motion vectors are separated into multiple files, one file per frame. On the other hand, if read_motion_vectors is TRUE, then motion vectors are read from mv_filename via QccVIDMotionVectorsReadFile(3) , in which case QccVIDSpatialBlockEncode() performs no motion estimation itself, using simply the motion vectors read from the files for coding.

If quiet = 0, QccVIDSpatialBlockEncode() will print to stdout a number of statistics concerning each frame as it is encoding. If quiet = 1, this verbose output is suppressed.

Decoding

QccVIDSpatialBlockDecodeHeader() decodes the header information in a bitstream produced by QccVIDSpatialBlockEncode(). The input bitstream is input_buffer which must be of QCCBITBUFFER_INPUT type and open via a prior call to QccBitBufferStart(3) . The header information is returned in num_rows (vertical size of image-sequence frames), num_cols (horizontal size of image-sequence frames), start_frame_num (number of the first frame of the sequence), end_frame_num (number of the last frame of the sequence), num_levels (number of wavelet-transform levels), and target_bit_cnt (number of bits encoded for each frame).

QccVIDSpatialBlockDecode() decodes the bitstream input_buffer, reconstructing each image of the output image sequence and writing it to a separate, numbered grayscale-image file. The filename denoted by image_sequence must contain one printf(3) -style numerical descriptor which is filled in with the number of the current frame being decoded. The bitstream must already have had its header read by a prior call to QccVIDSpatialBlockDecodeHeader() (i.e., you call QccVIDSpatialBlockDecodeHeader() first and then QccVIDSpatialBlockDecode()). If quiet = 0, then QccVIDSpatialBlockDecode() prints a brief message to stdout after decoding each frame; if quiet = 1, then this message is suppressed.

filter1, filter2, and filter3 are interpolation filters for supporting the subpixel accuracy specified by subpixel_accuracy which can be one of QCCVID_ME_FULLPIXEL, QCCVID_ME_HALFPIXEL, QCCVID_ME_QUARTERPIXEL, or QCCVID_ME_EIGHTHPIXEL, indicating full-, half-, quarter-, or eighth-pixel accuracy, respectively.

mv_filename gives the name of files of motion vectors. If mv_filename is NULL, then QccVIDSpatialBlockDecode() simply decodes the motion vectors to use in decoding from the bitstream (the usual state of affairs). On the other hand, if mv_filename is not NULL, then the motion vectors stored in the bitstream are ignored and, rather, the motion vectors are read from mv_filename instead. mv_filename should have a printf(3) -style numerical descriptor which will then be filled in with the current frame number before reading via QccVIDMotionVectorsReadFile(3) .

ALGORITHM

The spatial-block video-coding algorithm here is a generic implementation of the simple process of spatial-domain motion estimation and motion compensation followed by an embedded wavelet-based coding of the residual frames. Motion estimation is carried out via a call to QccVIDMotionEstimationFullSearch(3) , while motion compensation uses the reference frame created by a call to QccVIDMotionEstimationCreateReferenceFrame(3) , with subpixel accuracy supported as described for this latter routine. Finally, the motion-compensation residual is coded via a call to QccSPIHTEncode(3) using the specified wavelet and num_levels.

SEE ALSO

spatialblockencode(1) , spatialblockdecode(1) , QccVIDMotionVectorsReadFile(3) , QccVIDMotionVectorsWriteFile(3) , QccVIDMotionEstimationFullSearch(3) , QccVIDMotionEstimationCreateReferenceFrame(3) , QccSPIHTEncode(3) , QccPackVID(3) , QccPackSPIHT(3) , QccPackWAV(3) , QccPackIMG(3) , QccPack(3)

S. Cui, Y. Wang, and J. E. Fowler, "Motion Compensation Via Redundant-Wavelet Multihypothesis," IEEE Transactions on Image Processing, submitted March 2004. Revised February 2005.

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads