📄 refbuf.c
字号:
/*
***********************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2003, Advanced Audio Video Coding Standard, Part II
*
* DISCLAIMER OF WARRANTY
*
* These software programs are available to the users without any
* license fee or royalty on an "as is" basis. The AVS disclaims
* any and all warranties, whether express, implied, or statutory,
* including any implied warranties of merchantability or of fitness
* for a particular purpose. In no event shall the contributors or
* the AVS be liable for any incidental, punitive, or consequential
* damages of any kind whatsoever arising from the use of this program.
*
* This disclaimer of warranty extends to the user of this program
* and user's customers, employees, agents, transferees, successors,
* and assigns.
*
* The AVS does not represent or warrant that the program furnished
* hereunder are free of infringement of any third-party patents.
* Commercial implementations of AVS, including shareware, may be
* subject to royalty fees to patent holders. Information regarding
* the AVS patent policy is available from the AVS Web site at
* http://www.avs.org.cn
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY.
************************************************************************
*/
/*
*************************************************************************************
* File name:
* Function:
*
*************************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
#include "refbuf.h"
#define CACHELINESIZE 32
static pel_t line[16];
/*
*************************************************************************
* Function:Reference buffer write routines
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
void PutPel_14 (pel_t **Pic, int y, int x, pel_t val)
{
Pic [IMG_PAD_SIZE*4+y][IMG_PAD_SIZE*4+x] = val;
}
/*
*************************************************************************
* Function:Reference buffer read, Full pel
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
pel_t *FastLineX (int dummy, pel_t* Pic, int y, int x)
{
return Pic + y*img->width + x;
}
/*
*************************************************************************
* Function:
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
pel_t *UMVLineX (int size, pel_t* Pic, int y, int x)
{
int i, maxx;
pel_t *Picy;
Picy = Pic + max(0,min(img->height-1,y)) * img->width;
if (x < 0) // Left edge
{
maxx = min(0,x+size);
for (i = x; i < maxx; i++)
{
line[i-x] = Picy [0]; // Replicate left edge pixel
}
maxx = x+size;
for (i = 0; i < maxx; i++) // Copy non-edge pixels
line[i-x] = Picy [i];
}
else if (x > img->width-size) // Right edge
{
maxx = img->width;
for (i = x; i < maxx; i++)
{
line[i-x] = Picy [i]; // Copy non-edge pixels
}
maxx = x+size;
for (i = max(img->width,x); i < maxx; i++)
{
line[i-x] = Picy [img->width-1]; // Replicate right edge pixel
}
}
else // No edge
{
return Picy + x;
}
return line;
}
/*
*************************************************************************
* Function:Reference buffer, 1/4 pel
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
pel_t UMVPelY_14 (pel_t **Pic, int y, int x)
{
int width4 = ((img->width+2*IMG_PAD_SIZE-1)<<2);
int height4 = ((img->height+2*IMG_PAD_SIZE-1)<<2);
x = x + IMG_PAD_SIZE*4;
y = y + IMG_PAD_SIZE*4;
if (x < 0)
{
if (y < 0)
return Pic [y&3][x&3];
if (y > height4)
return Pic [height4+(y&3)][x&3];
return Pic [y][x&3];
}
if (x > width4)
{
if (y < 0)
return Pic [y&3][width4+(x&3)];
if (y > height4)
return Pic [height4+(y&3)][width4+(x&3)];
return Pic [y][width4+(x&3)];
}
if (y < 0) // note: corner pixels were already processed
return Pic [y&3][x];
if (y > height4)
return Pic [height4+(y&3)][x];
return Pic [y][x];
}
pel_t FastPelY_14 (pel_t **Pic, int y, int x)
{
return Pic [IMG_PAD_SIZE*4+y][IMG_PAD_SIZE*4+x];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -