Table of Contents

NAME

QccVIDMotionEstimationMAE, QccVIDMotionEstimationExtractBlock, QccVIDMotionEstimationInsertBlock, QccVIDMotionEstimationFullSearch, QccVIDMotionEstimationCalcReferenceFrameSize, QccVIDMotionEstimationCreateReferenceFrame, QccVIDMotionEstimationCreateCompensatedFrame - routines for full-search, block-based motion estimation and compensation

SYNOPSIS

#include "libQccPack.h"

double QccVIDMotionEstimationMAE(QccMatrix current_block, QccMatrix reference_block, int block_size);

int QccVIDMotionEstimationExtractBlock(const QccIMGImageComponent *image, double row, double col, QccMatrix block, int block_size, int subpixel_accuracy);

int QccVIDMotionEstimationInsertBlock(QccIMGImageComponent *image, double row, double col, const QccMatrix block, int block_size, int subpixel_accuracy);

int QccVIDMotionEstimationFullSearch(const QccIMGImageComponent *current_frame, const QccIMGImageComponent *reference_frame, QccIMGImageComponent *motion_vectors_horizontal, QccIMGImageComponent *motion_vectors_vertical, int block_size, int window_size, int subpixel_accuracy);

int QccVIDMotionEstimationCalcReferenceFrameSize(int num_rows, int num_cols, int *reference_num_rows, int *reference_num_cols, int subpixel_accuracy);

int QccVIDMotionEstimationCreateReferenceFrame(const QccIMGImageComponent *current_frame, QccIMGImageComponent *reference_frame, int subpixel_accuracy, const QccFilter *filter1, const QccFilter *filter2, const QccFilter *filter3);

int QccVIDMotionEstimationCreateCompensatedFrame(QccIMGImageComponent *motion_compensated_frame, const QccIMGImageComponent *reference_frame, const QccIMGImageComponent *motion_vectors_horizontal, const QccIMGImageComponent *motion_vectors_vertical, int block_size, int subpixel_accuracy);

DESCRIPTION

QccVIDMotionEstimationMAE() calculates the mean absolute error (MAE) between current_block and reference_block where both blocks have a block size of block_size by block_size.

QccVIDMotionEstimationExtractBlock() extracts a block of size block_size by block_size from image. The block is extracted from location (row, col), where this location is the upper-left corner of the block to extact. subpixel_accuracy is one of QCCVID_ME_FULLPIXEL, QCCVID_ME_HALFPIXEL, QCCVID_ME_QUARTERPIXEL, or QCCVID_ME_EIGHTHPIXEL, indicating full-, half-, quarter-, or eighth-pixel accuracy. Unless the accuracy is full-pixel, image is assumed to be interpolated to support motion-estimation at the specified accuracy (using QccVIDMotionEstimationCreateReferenceFrame() described below). Unless the accuracy is full-pixel, row and col refer to the location in the original image, not the interpolated image.

QccVIDMotionEstimationInsertBlock() does the inverse of QccVIDMotionEstimationExtractBlock(); that is, it inserts block into the specified location in image.

QccVIDMotionEstimationFullSearch() does full-search, block-based motion estimation in current_frame using reference_frame as the reference frame. That is, for each block in current_frame, every block in a window surrounding the current-block location in reference_frame is searched, and the best-matching block chosen. The motion vectors indicating the displacement from the blocks in current_frame to their matching blocks in reference_frame are returned in motion_vectors_horizontal and motion_vectors_vertical, which are the horizontal and vertical components of the motion vectors, respectively. block_size gives the size of the blocks to match. window_size gives the size of the window to search in reference_frame (window_size should be positive, so that the search window is -window_size to +window_size). subpixel_accuracy is one of QCCVID_ME_FULLPIXEL, QCCVID_ME_HALFPIXEL, QCCVID_ME_QUARTERPIXEL, or QCCVID_ME_EIGHTHPIXEL, indicating full-, half-, quarter-, or eighth-pixel motion-estimation accuracy. It is assumed that reference_frame is already interpolated to support the specified accuracy using QccVIDMotionEstimationCreateReferenceFrame().

QccVIDMotionEstimationCalcReferenceFrameSize() returns the size that a reference frame needs to be to support motion-estimation accuracy of the specified subpixel_accuracy. num_rows and num_cols give the original size of the frame; the size of the interpolated reference frame is returned in reference_num_rows and reference_num_cols.

QccVIDMotionEstimationCreateReferenceFrame() interpolates current_frame into reference_frame at the specified subpixel_accuracy. If subpixel_accuracy is QCCVID_ME_FULLPIXEL, current_frame is simply copied into reference_frame. If subpixel_accuracy is QCCVID_ME_HALFPIXEL, and filter1 is not NULL, then current_frame is filtered into reference_frame using QccIMGImageComponentInterpolateFilter(3) . On the other hand, if filter1 is NULL, then bilinear interpolation is performed via QccIMGImageComponentInterpolateBilinear(3) . Similarly, if subpixel_accuracy is QCCVID_ME_QUARTERPIXEL, then filter1 and filter2 determine whether bilinear or filtered interpolation is used to go from full-pixel to half-pixel accuracy (filter1), and from half-pixel to quarter-pixel accuracy (filter2). Likewise, filter3 determines whether bilinear or filtered interpolation is used in going from quarter-pixel to eighth-pixel accuracy when subpixel_accuracy is QCCVID_ME_EIGHTHPIXEL.

QccVIDMotionEstimationCreateCompensatedFrame() extracts blocks from reference_frame to create motion_compensated_frame, where the blocks are extracted according to the specified motion field as given by motion_vectors_horizontal and motion_vectors_vertical. block_size gives the size of the blocks, and subpixel_accuracy indicates the subpixel accuracy of reference_frame. It is assumed that reference_frame is interpolated with QccVIDMotionEstimationCreateReferenceFrame() to the specified subpixel_accuracy.

RETURN VALUE

These routines return 0 on success, and 1 on failure.

SEE ALSO

QccVIDMotionVectorsEncode(3) , QccVIDMotionVectorsDecode(3) , memc(1) , QccPackVID(3) , QccPackENT(3) , QccPack(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



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