📄 umc_h264_ccf.cpp
字号:
//// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright (c) 2004 - 2005 Intel Corporation. All Rights Reserved.//#include "ippi.h"#include "umc_h264_video_encoder.h"#include "umc_h264_ccf.h"#include "umc_h264_enc_cpb.h"/************************************************************* * Name: colorCnvtFrame * Description: Color convert and copy input frame. ************************************************************/namespace UMC{voidH264EncoderFrame::ColorCnvtFrame ( const H264_Image &src ){// //InputColorConvertorCatalog[m_uColorConvertor].ColorConvertor //[SSE_IMPL] C8_H26X_YUV12toEncYUV12( src.format.dimensions.width, src.format.dimensions.height, src.format.yuv_info.y_pitch, src.format.yuv_info.u_pitch, src.format.yuv_info.v_pitch, m_lumaSize.width, m_lumaSize.height, src, m_pYPlane, m_pUPlane, m_pVPlane, m_pitch);}void C8_H26X_YUV12toEncYUV12( Ipp32u InputWidth, Ipp32u InputHeight, Ipp32u YInputPitch, Ipp32u UInputPitch, Ipp32u VInputPitch, Ipp32u OutputWidth, Ipp32u OutputHeight, const H264_Image &src, Ipp8u *YPlane, Ipp8u *UPlane, Ipp8u *VPlane, const int pitch){#if 0 int i, j; Ipp32u *pnext = (Ipp32u *)lpInput; Ipp32u *plast; Ipp32u t; Ipp16u t16; Ipp8u *p8next; int byte_ypitch_adj; int byte_uvpitch_adj; int yinput_height = InputHeight; int yinput_width = InputWidth; int yheight_diff = 0; int ywidth_diff = 0; int uvheight_diff = 0; int uvwidth_diff = 0; int uvinput_width = yinput_width >> 1; int uvinput_height = yinput_height >> 1; int uvoutput_width = OutputWidth >> 1; int widthx16 = (OutputWidth + 0xF) & ~0xF; int width_diff = widthx16 - OutputWidth; int heightx16 = (OutputHeight + 0xF) & ~0xF; int height_diff = heightx16 - OutputHeight; if ( !width_diff && !height_diff && !uvheight_diff && !uvwidth_diff) { IppiSize src_size,dst_size; IppiRect src_rect; src_size.width=InputWidth; src_size.height=InputHeight; dst_size.width=OutputWidth; dst_size.height=OutputHeight; src_rect.x=0; src_rect.y=0; src_rect.width=InputWidth; src_rect.height=InputHeight; ippiResize_8u_C1R(lpInput, src_size,YInputPitch,src_rect,YPlane,pitch,dst_size,1.0,1.0,IPPI_INTER_LINEAR); src_size.width/=2; src_size.height/=2; dst_size.width/=2; dst_size.height/=2; src_rect.width/=2; src_rect.height/=2; ippiResize_8u_C1R(lpInput+InputWidth*InputHeight, src_size,UInputPitch,src_rect,UPlane,pitch,dst_size,1.0,1.0,IPPI_INTER_LINEAR); ippiResize_8u_C1R(lpInput+InputWidth*InputHeight+(InputWidth*InputHeight/4), src_size,VInputPitch,src_rect,VPlane,pitch,dst_size,1.0,1.0,IPPI_INTER_LINEAR);/* IppiSize s; s.height=InputHeight; s.width=InputWidth; ippiCopy_8u_C1R(lpInput,InputWidth,YPlane,pitch,s); s.height=InputHeight/2; s.width=InputWidth/2; ippiCopy_8u_C1R(lpInput+InputWidth*InputHeight,InputWidth/2,UPlane,pitch,s); ippiCopy_8u_C1R(lpInput+InputWidth*InputHeight+(InputWidth*InputHeight/4),InputWidth/2,VPlane,pitch,s);*/ /* pitchify( OutputWidth, OutputHeight, lpInput, YPlane, UPlane, VPlane, pitch ); */ return; } // This routine has to handle two cases: // - arbitrary frame size (width and height may be any multiple of 4 up to CIF size). // - backward compatibility with H263 (320x240 -> 352x288 still mode) // Note: Crop and stretch was not supported for YUV12 conversion in H263. if (width_diff) { byte_ypitch_adj = pitch - widthx16; byte_uvpitch_adj = pitch - (widthx16 >> 1); } else { byte_ypitch_adj = pitch - OutputWidth; byte_uvpitch_adj = pitch - (OutputWidth >> 1); ywidth_diff = OutputWidth - yinput_width; yheight_diff = OutputHeight - yinput_height; uvwidth_diff = ywidth_diff >> 1; uvheight_diff = yheight_diff >> 1; } // Y Plane conversion. for (j = yinput_height; j > 0; j--, YPlane += byte_ypitch_adj) { for (i = yinput_width; (i & ~0xF); i-=16, YPlane+=16) { *(Ipp32u *)YPlane = *pnext++; *(Ipp32u *)(YPlane+4) = *pnext++; *(Ipp32u *)(YPlane+8) = *pnext++; *(Ipp32u *)(YPlane+12) = *pnext++; } if (i & 0x8) { *(Ipp32u *)YPlane = *pnext++; *(Ipp32u *)(YPlane+4) = *pnext++; YPlane += 8; } if (i & 0x4) { *(Ipp32u *)YPlane = *pnext++; YPlane += 4; } // The next two cases are mutually exclusive. If there is a width_diff, // then there is no ywidth_diff. If there is a ywidth_diff, then there // is no width_diff. Both width_diff and ywidth_diff may be zero. if (width_diff) { t = (*(YPlane-1)) << 24; t |= (t>>8) | (t>>16) | (t>>24); *(Ipp32u *)YPlane = t; if ((width_diff-4) > 0) { *(Ipp32u *)(YPlane + 4) = t; } if ((width_diff-8) > 0) { *(Ipp32u *)(YPlane + 8) = t; } YPlane += width_diff; } for (i = ywidth_diff; i > 0; i -= 4) { *(Ipp32u *)YPlane = 0; YPlane += 4; } } // The next two cases are mutually exclusive. If there is a height_diff, // then there is no yheight_diff. If there is a yheight_diff, then there // is no height_diff. Both height_diff and yheight_diff may be zero. if (height_diff) { for (j = height_diff; j > 0; j-- ) { plast = (Ipp32u *)(YPlane - pitch); for (i = widthx16; i > 0; i -= 4, YPlane += 4) { *(Ipp32u *)YPlane = *plast++; } YPlane += byte_ypitch_adj; } } for (j = yheight_diff; j > 0; j--, YPlane += byte_ypitch_adj) { for (i = widthx16; i > 0; i -= 4) { *(Ipp32u *)YPlane = 0; YPlane += 4; } } // U Plane conversion. p8next = (Ipp8u *)pnext; for (j = uvinput_height; j > 0; j--, UPlane += byte_uvpitch_adj) { for (i = uvinput_width; (i & ~0x7); i-=8, UPlane+=8, p8next+=8) { *(Ipp32u *)UPlane = *(Ipp32u *)p8next; *(Ipp32u *)(UPlane+4) = *(Ipp32u *)(p8next+4); } if (i & 0x4) { *(Ipp32u *)UPlane = *(Ipp32u *)p8next; UPlane += 4, p8next += 4; } if (i & 0x2) { *(Ipp16u *)UPlane = *(Ipp16u *)p8next; UPlane += 2, p8next += 2; } // The next two cases are mutually exclusive. If there is a width_diff, // then there is no uvwidth_diff. If there is a uvwidth_diff, then there // is no width_diff. Both width_diff and uvwidth_diff may be zero. if (width_diff) { t16 = (*(UPlane-1)) << 8; t16 |= (t16>>8); *(Ipp16u*)UPlane = t16; UPlane += 2; if ((width_diff-4) > 0) { *(Ipp16u*)UPlane = t16; UPlane += 2; } if ((width_diff-8) > 0) { *(Ipp16u*)UPlane = t16; UPlane += 2; } } for (i = uvwidth_diff; i > 0; i -= 4) { *(Ipp32u *)UPlane = 0x80808080; UPlane += 4; } } // The next two cases are mutually exclusive. If there is a height_diff, // then there is no uvheight_diff. If there is a uvheight_diff, then there // is no height_diff. Both height_diff and uvheight_diff may be zero. if (height_diff) { for (j = (height_diff >> 1); j > 0; j--, UPlane += byte_uvpitch_adj ) { plast = (Ipp32u *)(UPlane - pitch); for (i = (widthx16 >> 1); i > 0; i -= 4, UPlane += 4) { *(Ipp32u *)UPlane = *plast++; } } } for (j = uvheight_diff; j > 0; j--, UPlane += byte_uvpitch_adj) { for (i = uvoutput_width; i > 0; i -= 4) { *(Ipp32u *)UPlane = 0x80808080; UPlane += 4; } } // V Plane conversion. for (j = uvinput_height; j > 0; j--, VPlane += byte_uvpitch_adj) { for (i = uvinput_width; (i & ~0x7); i-=8, VPlane+=8, p8next+=8) { *(Ipp32u *)VPlane = *(Ipp32u *)p8next; *(Ipp32u *)(VPlane+4) = *(Ipp32u *)(p8next+4); } if (i & 0x4) { *(Ipp32u *)VPlane = *(Ipp32u *)p8next; VPlane += 4, p8next += 4; } if (i & 0x2) { *(Ipp16u *)VPlane = *(Ipp16u *)p8next; VPlane += 2, p8next += 2; } // The next two cases are mutually exclusive. If there is a width_diff, // then there is no uvwidth_diff. If there is a uvwidth_diff, then there // is no width_diff. Both width_diff and uvwidth_diff may be zero. if (width_diff) { t16 = (*(VPlane-1)) << 8; t16 |= (t16>>8); *(Ipp16u*)VPlane = t16; VPlane += 2; if ((width_diff-4) > 0) { *(Ipp16u*)VPlane = t16; VPlane += 2; } if ((width_diff-8) > 0) { *(Ipp16u*)VPlane = t16; VPlane += 2; } } for (i = uvwidth_diff; i > 0; i -= 4) { *(Ipp32u *)VPlane = 0x80808080; VPlane += 4; } } // The next two cases are mutually exclusive. If there is a height_diff, // then there is no uvheight_diff. If there is a uvheight_diff, then there // is no height_diff. Both height_diff and uvheight_diff may be zero. if (height_diff) { for (j = (height_diff >> 1); j > 0; j--, VPlane += byte_uvpitch_adj ) { plast = (Ipp32u *)(VPlane - pitch); for (i = (widthx16 >> 1); i > 0; i -= 4, VPlane += 4) { *(Ipp32u *)VPlane = *plast++; } } } for (j = uvheight_diff; j > 0; j--, VPlane += byte_uvpitch_adj) { for (i = uvoutput_width; i > 0; i -= 4) { *(Ipp32u *)VPlane = 0x80808080; VPlane += 4; } }#else double x_f=OutputWidth*1.0/InputWidth; double y_f=OutputHeight*1.0/InputHeight; IppiSize src_size,dst_size; IppiRect src_rect; src_size.width=InputWidth; src_size.height=InputHeight; dst_size.width=OutputWidth; dst_size.height=OutputHeight; src_rect.x=0; src_rect.y=0; src_rect.width=InputWidth; src_rect.height=InputHeight; ippiResize_8u_C1R(src.yuv_info.y_plane, src_size,YInputPitch,src_rect,YPlane,pitch,dst_size,x_f,y_f,IPPI_INTER_LINEAR); src_size.width/=2; src_size.height/=2; dst_size.width/=2; dst_size.height/=2; src_rect.width/=2; src_rect.height/=2; ippiResize_8u_C1R(src.yuv_info.v_plane, src_size,VInputPitch,src_rect,VPlane,pitch,dst_size,x_f,y_f,IPPI_INTER_LINEAR); ippiResize_8u_C1R(src.yuv_info.u_plane, src_size,UInputPitch,src_rect,UPlane,pitch,dst_size,x_f,y_f,IPPI_INTER_LINEAR);#endif} // C8_H26X_YUV12toEncYUV12} //namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -