libavc/common/ih264_padding.c
Ram Mohan M 0ab5c42d27 libavc: Remove duplicate code and improve readability
This commit does not introduce any new functionality w.r.t previous
commit. But it fixes few things. They are listed below
1. Guard Bands in header files are fixed
2. Header files contains function definition comments. These are same
as in source file. Maintaining same comment at two locations is
unnecessary. These are removed.
3. Maintain Indentation consistency across the code.
4. Remove unused code
2023-10-06 16:53:23 -07:00

319 lines
7.3 KiB
C

/******************************************************************************
*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/**
*******************************************************************************
* @file
* ih264_padding.c
*
* @brief
* Contains function definitions for Padding
*
* @author
* ittiam
*
* @par List of Functions:
* - ih264_pad_top
* - ih264_pad_bottom
* - ih264_pad_left_luma
* - ih264_pad_left_chroma
* - ih264_pad_right_luma
* - ih264_pad_right_chroma
*
* @remarks
* none
*
*******************************************************************************
*/
/*****************************************************************************/
/* File Includes */
/*****************************************************************************/
/* System Include Files */
#include <stddef.h>
#include <string.h>
/* User Include Files */
#include "ih264_typedefs.h"
#include "ih264_macros.h"
#include "ih264_padding.h"
/*****************************************************************************/
/* Function Definitions */
/*****************************************************************************/
/**
*******************************************************************************
*
* @brief pad at the top of a 2d array
*
* @par Description:
* The top row of a 2d array is replicated for pad_size times at the top
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] wd
* width of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_top(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 wd,
WORD32 pad_size)
{
WORD32 row;
for(row = 1; row <= pad_size; row++)
{
memcpy(pu1_src - row * src_strd, pu1_src, wd);
}
}
/**
*******************************************************************************
*
* @brief pad at the bottom of a 2d array
*
* @par Description:
* The bottom row of a 2d array is replicated for pad_size times at the bottom
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] wd
* width of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_bottom(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 wd,
WORD32 pad_size)
{
WORD32 row;
for(row = 1; row <= pad_size; row++)
{
memcpy(pu1_src + (row - 1) * src_strd, pu1_src - 1 * src_strd, wd);
}
}
/**
*******************************************************************************
*
* @brief pad (luma block) at the left of a 2d array
*
* @par Description:
* The left column of a 2d array is replicated for pad_size times to the left
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] ht
* height of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_left_luma(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 ht,
WORD32 pad_size)
{
WORD32 row;
for(row = 0; row < ht; row++)
{
memset(pu1_src - pad_size, *pu1_src, pad_size);
pu1_src += src_strd;
}
}
/**
*******************************************************************************
*
* @brief pad (chroma block) at the left of a 2d array
*
* @par Description:
* The left column of a 2d array is replicated for pad_size times to the left
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] ht
* height of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_left_chroma(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 ht,
WORD32 pad_size)
{
WORD32 row, col;
UWORD16 u2_uv_val;
UWORD16 *pu2_src = (UWORD16 *)pu1_src;
src_strd >>= 1;
pad_size >>= 1;
for(row = 0; row < ht; row++)
{
u2_uv_val = pu2_src[0];
for(col = -pad_size; col < 0; col++)
{
pu2_src[col] = u2_uv_val;
}
pu2_src += src_strd;
}
}
/**
*******************************************************************************
*
* @brief pad (luma block) at the right of a 2d array
*
* @par Description:
* The right column of a 2d array is replicated for pad_size times at the right
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] ht
* height of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_right_luma(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 ht,
WORD32 pad_size)
{
WORD32 row;
for(row = 0; row < ht; row++)
{
memset(pu1_src, *(pu1_src -1), pad_size);
pu1_src += src_strd;
}
}
/**
*******************************************************************************
*
* @brief pad (chroma block) at the right of a 2d array
*
* @par Description:
* The right column of a 2d array is replicated for pad_size times at the right
*
* @param[in] pu1_src
* pointer to the source
*
* @param[in] src_strd
* source stride
*
* @param[in] ht
* height of the array
*
* @param[in] pad_size
* padding size of the array
*
* @returns none
*
* @remarks none
*
*******************************************************************************
*/
void ih264_pad_right_chroma(UWORD8 *pu1_src,
WORD32 src_strd,
WORD32 ht,
WORD32 pad_size)
{
WORD32 row, col;
UWORD16 u2_uv_val;
UWORD16 *pu2_src = (UWORD16 *)pu1_src;
src_strd >>= 1;
pad_size >>= 1;
for(row = 0; row < ht; row++)
{
u2_uv_val = pu2_src[-1];
for(col = 0; col < pad_size; col++)
{
pu2_src[col] = u2_uv_val;
}
pu2_src += src_strd;
}
}