?? scale_v2_c.c
字號:
/* ======================================================================== */
/* NAME */
/* scale_v2 -- Vertical scaling down by 2 */
/* */
/* USAGE */
/* This routine has the following C prototype: */
/* */
/* void scale_v2 */
/* ( */
/* unsigned char *restrict inp, */
/* int pixs, */
/* int stride, */
/* int lns, */
/* unsigned char *restrict outp */
/* ) */
/* */
/* The scale_v2 routine accepts an array "inp" of "lns" lines each */
/* of "pixs" pixels seperated by "stride" bytes, and produces an */
/* output array "outp" of "lns >> 1" and "pixs" pixels. */
/* */
/* DESCRIPTION */
/* The scale_v2 algorithm performs vertical scaling by a factor of */
/* "2" by averaging succesive lines as opposed to mere pixel dropping. */
/* */
/* TECHNIQUES */
/* None */
/* */
/* ASSUMPTIONS */
/* 'lns' must be a multiple of 2, and can be greater than or equal */
/* to 2. The input and output pointers are double word aligned. The */
/* number of pixels to process is a multiple of eight, and the number */
/* of lines to process are two. */
/* */
/* NOTES */
/* */
/* SOURCE */
/* None */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2001 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
#pragma CODE_SECTION(scale_v2_cn, ".text:ansi");
#include "scale_v2_c.h"
void scale_v2_cn
(
unsigned char *restrict inp,
int pixs,
int stride,
int lns,
unsigned char *restrict outp
)
{
int i, j;
unsigned char pix0, pix1;
unsigned char out_pix;
/*--------------------------------------------------------------------*/
/* Infrom the compiler of any safe assumptions that can be made. */
/* These include assuming that the input and output pointers are */
/* double word aligned, and the number of pixels to be processed */
/* is a multiple of eight. In addition the number of lines is a */
/* multiple of 2. */
/*--------------------------------------------------------------------*/
#ifndef NOASSUME
_nassert((int)(pixs)%8 == 0);
_nassert((int)(inp)%8 == 0);
_nassert((int)(outp)%8 == 0);
_nassert(stride != pixs);
_nassert(pixs >= 64);
_nassert(lns >= 2);
#endif
/*--------------------------------------------------------------------*/
/* The output image has half the number of lines of the input image. */
/* Load in pixels that are stride elements away and average them */
/* after rounding. At the end of processing any two lines increment */
/* the input pointer to jump by 2 lines. */
/*--------------------------------------------------------------------*/
for ( j = 0; j < (lns >> 1); j++)
{
#ifndef NOASSUME
#pragma UNROLL(2);
#endif
for ( i = 0; i < pixs; i++)
{
pix0 = inp[i];
pix1 = inp[i + stride];
out_pix = (pix0 + pix1 + 1) >> 1;
*outp++ = out_pix;
}
inp += (2 * stride);
}
}
/* ======================================================================== */
/* End of file: scale_v2_c.c */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2002 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -