+ +
5797689 fix(windows): resolve MSVC test linkage, missing unistd, and export declarations
saifmukhtar · 2026-11-24
main
| 1 | /* |
| 2 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | * |
| 4 | * Copyright (c) 2017 Steinar H. Gunderson |
| 5 | * Copyright (c) 2017-2026 FFmpeg contributors |
| 6 | * Copyright (c) 2026 Saif Mukhtar (OpenAVX integration) |
| 7 | * |
| 8 | * OpenAVX - Open Audio-Video eXchange |
| 9 | * include/avx_speedhq.h - Standalone SpeedHQ intra-frame codec |
| 10 | * |
| 11 | * Derived from FFmpeg libavcodec (speedhq.c). |
| 12 | * Licensed under the GNU Lesser General Public License version 2.1 or later. |
| 13 | */ |
| 14 | |
| 15 | #ifndef AVX_SPEEDHQ_H |
| 16 | #define AVX_SPEEDHQ_H |
| 17 | |
| 18 | #include <stddef.h> |
| 19 | #include <stdint.h> |
| 20 | #include <stdbool.h> |
| 21 | #include "openavx.h" |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | /** |
| 28 | * Fast FourCC check for SpeedHQ compressed stream types (SHQ0-SHQ9). |
| 29 | */ |
| 30 | static inline bool avx_is_speedhq_fourcc(uint32_t fourcc) { |
| 31 | switch (fourcc) { |
| 32 | case OAVX_FOURCC_VIDEO_TYPE_SHQ0: |
| 33 | case OAVX_FOURCC_VIDEO_TYPE_SHQ1: |
| 34 | case OAVX_FOURCC_VIDEO_TYPE_SHQ2: |
| 35 | case OAVX_FOURCC_VIDEO_TYPE_SHQ3: |
| 36 | case OAVX_FOURCC_VIDEO_TYPE_SHQ4: |
| 37 | case OAVX_FOURCC_VIDEO_TYPE_SHQ5: |
| 38 | case OAVX_FOURCC_VIDEO_TYPE_SHQ7: |
| 39 | case OAVX_FOURCC_VIDEO_TYPE_SHQ9: |
| 40 | return true; |
| 41 | default: |
| 42 | return false; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Global initialization of SpeedHQ codec engine. |
| 48 | * Initializes static VLC tables and native SIMD vectorization. |
| 49 | */ |
| 50 | OPENAVX_API bool avx_speedhq_init(void); |
| 51 | |
| 52 | /** |
| 53 | * Dynamic Bitrate & Quantization Quality Control: |
| 54 | * Sets the default SpeedHQ quantization quality (20-98, default: 96). |
| 55 | * Lower quality drastically reduces wire bitrate for congested/WAN links. |
| 56 | */ |
| 57 | OPENAVX_API void avx_speedhq_set_quality(uint8_t quality); |
| 58 | OPENAVX_API uint8_t avx_speedhq_get_quality(void); |
| 59 | |
| 60 | /** |
| 61 | * Returns true if native SIMD hardware acceleration (AVX2/NEON) is active. |
| 62 | */ |
| 63 | OPENAVX_API bool avx_speedhq_has_acceleration(void); |
| 64 | |
| 65 | /** |
| 66 | * High-performance standalone encoder: |
| 67 | * Compresses packed UYVY 4:2:2 frame to SpeedHQ-2 (SHQ2) bitstream. |
| 68 | * Uses native SIMD (AVX2/NEON) vectorization. |
| 69 | */ |
| 70 | OPENAVX_API int avx_speedhq_encode(int width, int height, |
| 71 | const uint8_t *uyvy_data, |
| 72 | uint8_t *out_buf, size_t out_max, |
| 73 | size_t *out_size); |
| 74 | |
| 75 | /** |
| 76 | * High-performance standalone decoder: |
| 77 | * Decompresses SpeedHQ-2 (SHQ2) bitstream to packed UYVY 4:2:2. |
| 78 | * Uses native SIMD (AVX2/NEON) vectorization. |
| 79 | */ |
| 80 | OPENAVX_API int avx_speedhq_decode(int width, int height, |
| 81 | const uint8_t *shq_data, size_t shq_size, |
| 82 | uint8_t *uyvy_out); |
| 83 | |
| 84 | /** |
| 85 | * Pure C99 standalone fallback encoder (zero dependencies). |
| 86 | */ |
| 87 | OPENAVX_API int avx_speedhq_encode_c99(int width, int height, |
| 88 | const uint8_t *uyvy_data, |
| 89 | uint8_t *out_buf, size_t out_max, |
| 90 | size_t *out_size); |
| 91 | |
| 92 | /** |
| 93 | * Pure C99 standalone fallback decoder (zero dependencies). |
| 94 | */ |
| 95 | OPENAVX_API int avx_speedhq_decode_c99(int width, int height, |
| 96 | const uint8_t *shq_data, size_t shq_size, |
| 97 | uint8_t *uyvy_out); |
| 98 | |
| 99 | /** |
| 100 | * Extended high-performance standalone encoder: |
| 101 | * Compresses packed UYVY 4:2:2 frame and optional alpha plane to SpeedHQ (SHQ0-SHQ9) bitstream. |
| 102 | */ |
| 103 | OPENAVX_API int avx_speedhq_encode_ex(uint32_t fourcc, int width, int height, |
| 104 | const uint8_t *uyvy_data, const uint8_t *alpha_data, |
| 105 | uint8_t *out_buf, size_t out_max, |
| 106 | size_t *out_size); |
| 107 | |
| 108 | /** |
| 109 | * Strided and per-instance quality SpeedHQ encoder: |
| 110 | * `uyvy_stride == 0` defaults to width * 2; `alpha_stride == 0` defaults to width; |
| 111 | * `quality == 0` inherits the global default from avx_speedhq_get_quality(). |
| 112 | */ |
| 113 | OPENAVX_API int avx_speedhq_encode_strided_ex(uint32_t fourcc, int width, int height, |
| 114 | const uint8_t *uyvy_data, size_t uyvy_stride, |
| 115 | const uint8_t *alpha_data, size_t alpha_stride, |
| 116 | uint8_t quality, |
| 117 | uint8_t *out_buf, size_t out_max, |
| 118 | size_t *out_size); |
| 119 | |
| 120 | /** |
| 121 | * Extended high-performance standalone decoder: |
| 122 | * Decompresses SpeedHQ bitstream to packed UYVY 4:2:2 and optional alpha plane. |
| 123 | */ |
| 124 | OPENAVX_API int avx_speedhq_decode_ex(uint32_t fourcc, int width, int height, |
| 125 | const uint8_t *shq_data, size_t shq_size, |
| 126 | uint8_t *uyvy_out, uint8_t *alpha_out, |
| 127 | bool *p_has_alpha); |
| 128 | |
| 129 | /** |
| 130 | * Extended pure C99 standalone fallback encoder. |
| 131 | */ |
| 132 | OPENAVX_API int avx_speedhq_encode_c99_ex(uint32_t fourcc, int width, int height, |
| 133 | const uint8_t *uyvy_data, const uint8_t *alpha_data, |
| 134 | uint8_t *out_buf, size_t out_max, |
| 135 | size_t *out_size); |
| 136 | |
| 137 | /** |
| 138 | * Extended pure C99 standalone fallback decoder. |
| 139 | */ |
| 140 | OPENAVX_API int avx_speedhq_decode_c99_ex(uint32_t fourcc, int width, int height, |
| 141 | const uint8_t *shq_data, size_t shq_size, |
| 142 | uint8_t *uyvy_out, uint8_t *alpha_out, |
| 143 | bool *p_has_alpha); |
| 144 | |
| 145 | /** |
| 146 | * Free any global codec resources. |
| 147 | */ |
| 148 | OPENAVX_API void avx_speedhq_destroy(void); |
| 149 | |
| 150 | #ifdef __cplusplus |
| 151 | } |
| 152 | #endif |
| 153 | |
| 154 | #endif /* AVX_SPEEDHQ_H */ |