libvmx
VMX Codec
Loading...
Searching...
No Matches
vmxcodec_arm.h
Go to the documentation of this file.
1/*
2* MIT License
3*
4* Copyright (c) 2025 Open Media Transport Contributors
5*
6* Permission is hereby granted, free of charge, to any person obtaining a copy
7* of this software and associated documentation files (the "Software"), to deal
8* in the Software without restriction, including without limitation the rights
9* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10* copies of the Software, and to permit persons to whom the Software is
11* furnished to do so, subject to the following conditions:
12*
13* The above copyright notice and this permission notice shall be included in all
14* copies or substantial portions of the Software.
15*
16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22* SOFTWARE.
23*
24*/
25#pragma once
26#include "vmxcodec.h"
27#if defined(ARM64)
28
29#include "vmxcodec_common.h"
30#include "sse2neon.h"
31
32#if defined(__APPLE__)
33#include <libkern/OSByteOrder.h>
34#define VMX_BUFFERSWAP(t) OSSwapInt64(t)
35#define __lzcnt64(t) __builtin_clzll(t)
36#define __lzcnt(t) __builtin_clz(t)
37#define _tzcnt_u64(t) __builtin_ctzll(t)
38#else
39#if defined(_MSC_VER)
40#define VMX_BUFFERSWAP(t) _byteswap_uint64(t)
41static uint64_t __lzcnt64(uint64_t t)
42{
43 unsigned long index;
44 if (_BitScanReverse64(&index, t))
45 {
46 return 63 - index;
47 }
48 else {
49 return 64;
50 }
51}
52static inline uint32_t __lzcnt(uint32_t t)
53{
54 unsigned long index;
55 if (_BitScanReverse(&index, t))
56 {
57 return 31 - index;
58 }
59 else {
60 return 32;
61 }
62}
63static inline uint64_t _tzcnt_u64(uint64_t t)
64{
65 unsigned long index;
66 if (_BitScanForward64(&index, t)) {
67 return index;
68 }
69 else {
70 return 64;
71 }
72}
73#else
74#define VMX_BUFFERSWAP(t) __builtin_bswap64(t)
75#define __lzcnt64(t) __builtin_clzll(t)
76#define __lzcnt(t) __builtin_clz(t)
77#define _tzcnt_u64(t) __builtin_ctzll(t)
78#endif
79#endif
80
81
82void VMX_BROADCAST_DC_8X8_128(short src, BYTE* dst, int stride, short addVal);
83void VMX_BROADCAST_DC_8X8_128_16(short src, BYTE* dst, int stride, short addVal);
84void VMX_ZIG_INVQUANTIZE_IDCT_8X8_128(short* src, unsigned short* matrix, BYTE* dst, int stride, short addVal);
85void VMX_ZIG_INVQUANTIZE_IDCT_8X8_128_16(short* src, unsigned short* matrix, BYTE* dst, int stride, short addVal);
86void VMX_FDCT_8X8_QUANT_ZIG_128(const BYTE* src, int stride, unsigned short* matrix, short addVal, __m128i* out0, __m128i* out1, __m128i* out2, __m128i* out3, __m128i* out4, __m128i* out5, __m128i* out6, __m128i* out7);
87void VMX_FDCT_8X8_QUANT_ZIG_128_16(const BYTE* src, int stride, unsigned short* matrix, short addVal, __m128i* out0, __m128i* out1, __m128i* out2, __m128i* out3, __m128i* out4, __m128i* out5, __m128i* out6, __m128i* out7);
88void VMX_PlanarToUYVY(BYTE* ysrc, int ystride, BYTE* usrc, int ustride, BYTE* vsrc, int vstride, BYTE* dst, int stride, VMX_SIZE size);
89void VMX_PlanarToP216(BYTE* ysrc, int ystride, BYTE* usrc, int ustride, BYTE* vsrc, int vstride, BYTE* dstY, int dstStrideY, BYTE* dstUV, int dstStrideUV, VMX_SIZE size);
90void VMX_UYVYToPlanar(BYTE* src, int stride, BYTE* ydst, int ystride, BYTE* udst, int ustride, BYTE* vdst, int vstride, VMX_SIZE size);
91void VMX_P216ToPlanar(BYTE* srcY, int srcStrideY, BYTE* srcUV, int srcStrideUV, BYTE* ydst, int ystride, BYTE* udst, int ustride, BYTE* vdst, int vstride, VMX_SIZE size);
92void VMX_AToPlanar(BYTE* src, int srcStride, BYTE* adst, int astride, VMX_SIZE size);
93void VMX_A16ToPlanar(BYTE* src, int srcStride, BYTE* adst, int astride, VMX_SIZE size);
94void VMX_PlanarToA(BYTE* asrc, int astride, BYTE* dst, int dstStride, VMX_SIZE size);
95void VMX_PlanarToA16(BYTE* asrc, int astride, BYTE* dst, int dstStride, VMX_SIZE size);
96void VMX_PlanarToYUY2(BYTE* ysrc, int ystride, BYTE* usrc, int ustride, BYTE* vsrc, int vstride, BYTE* dst, int stride, VMX_SIZE size);
97void VMX_YUY2ToPlanar(BYTE* src, int stride, BYTE* ydst, int ystride, BYTE* udst, int ustride, BYTE* vdst, int vstride, VMX_SIZE size);
98void VMX_NV12ToPlanar(BYTE* srcY, int strideY, BYTE* srcUV, int strideUV, BYTE* ydst, int ystride, BYTE* udst, int ustride, BYTE* vdst, int vstride, VMX_SIZE size);
99void VMX_YV12ToPlanar(BYTE* srcY, int srcStrideY, BYTE* srcU, int srcStrideU, BYTE* srcV, int srcStrideV, BYTE* ydst, int ystride, BYTE* udst, int ustride, BYTE* vdst, int vstride, VMX_SIZE size);
100void VMX_EncodePlaneInternal(VMX_INSTANCE* instance, VMX_PLANE* pPlane, VMX_SLICE_SET* s);
101void VMX_EncodePlaneInternal16(VMX_INSTANCE* instance, VMX_PLANE* pPlane, VMX_SLICE_SET* s);
102void VMX_YUV4224ToBGRA(BYTE* pSrcY, int iStrideY, BYTE* pSrcU, int iStrideU, BYTE* pSrcV, int iStrideV, BYTE* pSrcA, int iStrideA, BYTE* pDst, int dstStride, VMX_SIZE sz, const short* colorTable);
103void VMX_BGRAToYUV4224(BYTE* pSrc, int srcStride, BYTE* pDstY, int iStrideY, BYTE* pDstU, int iStrideU, BYTE* pDstV, int iStrideV, BYTE* pDstA, int iStrideA, VMX_SIZE sz, const ShortRGB* colorTables);
104void VMX_DecodePlaneInternal(VMX_INSTANCE* instance, VMX_PLANE* pPlane, VMX_SLICE_SET* s);
105void VMX_DecodePlaneInternal16(VMX_INSTANCE* instance, VMX_PLANE* pPlane, VMX_SLICE_SET* s);
106void VMX_DecodePlanePreviewInternal(VMX_INSTANCE* instance, VMX_PLANE* pPlane, VMX_SLICE_SET* s);
107void VMX_BGRXToUYVYInternal(BYTE* pSrc, int srcStride, BYTE* pDst, int iStride, VMX_SIZE sz, const ShortRGB* colorTables);
108int VMX_BGRXToUYVYConditionalInternal(BYTE* pSrc, BYTE* pSrcPrev, int srcStride, BYTE* pDst, int iStride, VMX_SIZE sz, const ShortRGB* colorTables);
109float VMX_CalculatePSNR_128(BYTE* p1, BYTE* p2, int stride, int bytesPerPixel, VMX_SIZE sz);
110
111#endif
int64x2_t __m128i
Definition sse2neon.h:415
Definition vmxcodec_common.h:143
Definition vmxcodec.h:147
Definition vmxcodec.h:138
Definition vmxcodec.h:50
Definition vmxcodec.h:124
unsigned char BYTE
Definition vmxcodec.h:48