/src/openh264/codec/processing/src/imagerotate/imagerotate.cpp
Line | Count | Source |
1 | | /*! |
2 | | * \copy |
3 | | * Copyright (c) 2013, Cisco Systems |
4 | | * All rights reserved. |
5 | | * |
6 | | * Redistribution and use in source and binary forms, with or without |
7 | | * modification, are permitted provided that the following conditions |
8 | | * are met: |
9 | | * |
10 | | * * Redistributions of source code must retain the above copyright |
11 | | * notice, this list of conditions and the following disclaimer. |
12 | | * |
13 | | * * Redistributions in binary form must reproduce the above copyright |
14 | | * notice, this list of conditions and the following disclaimer in |
15 | | * the documentation and/or other materials provided with the |
16 | | * distribution. |
17 | | * |
18 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
21 | | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
22 | | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
24 | | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 | | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
26 | | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
28 | | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | | * POSSIBILITY OF SUCH DAMAGE. |
30 | | * |
31 | | */ |
32 | | |
33 | | #include "imagerotate.h" |
34 | | |
35 | | WELSVP_NAMESPACE_BEGIN |
36 | | |
37 | | /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | | |
39 | 0 | CImageRotating::CImageRotating (int32_t iCpuFlag) { |
40 | 0 | m_iCPUFlag = iCpuFlag; |
41 | 0 | m_eMethod = METHOD_IMAGE_ROTATE; |
42 | 0 | WelsMemset (&m_pfRotateImage, 0, sizeof (m_pfRotateImage)); |
43 | 0 | InitImageRotateFuncs (m_pfRotateImage, m_iCPUFlag); |
44 | 0 | } |
45 | | |
46 | 0 | CImageRotating::~CImageRotating() { |
47 | 0 | } |
48 | | |
49 | 0 | void CImageRotating::InitImageRotateFuncs (SImageRotateFuncs& sImageRotateFuncs, int32_t iCpuFlag) { |
50 | 0 | sImageRotateFuncs.pfImageRotate90D = ImageRotate90D_c; |
51 | 0 | sImageRotateFuncs.pfImageRotate180D = ImageRotate180D_c; |
52 | 0 | sImageRotateFuncs.pfImageRotate270D = ImageRotate270D_c; |
53 | 0 | } |
54 | | EResult CImageRotating::ProcessImageRotate (int32_t iType, uint8_t* pSrc, uint32_t uiBytesPerPixel, uint32_t iWidth, |
55 | 0 | uint32_t iHeight, uint8_t* pDst) { |
56 | 0 | if (iType == 90) { |
57 | 0 | m_pfRotateImage.pfImageRotate90D (pSrc, uiBytesPerPixel, iWidth, iHeight, pDst); |
58 | 0 | } else if (iType == 180) { |
59 | 0 | m_pfRotateImage.pfImageRotate180D (pSrc, uiBytesPerPixel, iWidth, iHeight, pDst); |
60 | 0 | } else if (iType == 270) { |
61 | 0 | m_pfRotateImage.pfImageRotate270D (pSrc, uiBytesPerPixel, iWidth, iHeight, pDst); |
62 | 0 | } else { |
63 | 0 | return RET_NOTSUPPORTED; |
64 | 0 | } |
65 | 0 | return RET_SUCCESS; |
66 | 0 | } |
67 | | |
68 | 0 | EResult CImageRotating::Process (int32_t iType, SPixMap* pSrc, SPixMap* pDst) { |
69 | 0 | EResult eReturn = RET_INVALIDPARAM; |
70 | |
|
71 | 0 | if ((pSrc->eFormat == VIDEO_FORMAT_RGBA) || |
72 | 0 | (pSrc->eFormat == VIDEO_FORMAT_BGRA) || |
73 | 0 | (pSrc->eFormat == VIDEO_FORMAT_ABGR) || |
74 | 0 | (pSrc->eFormat == VIDEO_FORMAT_ARGB)) { |
75 | 0 | eReturn = ProcessImageRotate (iType, (uint8_t*)pSrc->pPixel[0], pSrc->iSizeInBits * 8, pSrc->sRect.iRectWidth, |
76 | 0 | pSrc->sRect.iRectHeight, (uint8_t*)pDst->pPixel[0]); |
77 | 0 | } else if (pSrc->eFormat == VIDEO_FORMAT_I420) { |
78 | 0 | ProcessImageRotate (iType, (uint8_t*)pSrc->pPixel[0], pSrc->iSizeInBits * 8, pSrc->sRect.iRectWidth, |
79 | 0 | pSrc->sRect.iRectHeight, (uint8_t*)pDst->pPixel[0]); |
80 | 0 | ProcessImageRotate (iType, (uint8_t*)pSrc->pPixel[1], pSrc->iSizeInBits * 8, (pSrc->sRect.iRectWidth >> 1), |
81 | 0 | (pSrc->sRect.iRectHeight >> 1), (uint8_t*)pDst->pPixel[1]); |
82 | 0 | eReturn = ProcessImageRotate (iType, (uint8_t*)pSrc->pPixel[2], pSrc->iSizeInBits * 8, (pSrc->sRect.iRectWidth >> 1), |
83 | 0 | (pSrc->sRect.iRectHeight >> 1), (uint8_t*)pDst->pPixel[2]); |
84 | 0 | } else { |
85 | 0 | eReturn = RET_NOTSUPPORTED; |
86 | 0 | } |
87 | |
|
88 | 0 | return eReturn; |
89 | 0 | } |
90 | | |
91 | | |
92 | | WELSVP_NAMESPACE_END |