1 /* 2 * Copyright (c) 2018 Hoppsan G. Pig 3 * 4 * This file is part of VapourSynth. 5 * 6 * VapourSynth is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * VapourSynth is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with VapourSynth; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef P2P_API_H_ 22 #define P2P_API_H_ 23 24 #include <stddef.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** 31 * Notation: [Xa-Ya-Za] 32 * 33 * [] denotes a machine word of the specified endianness. Xa-Ya-Za denote 34 * component X, Y, and Z packed in the word, with bit depths a, b, c, in order 35 * from MSB to LSB. Padding bits are represented by the component '!'. 36 */ 37 enum p2p_packing { 38 /** [R8-G8-B8] */ 39 p2p_rgb24_be, /* RGB */ 40 p2p_rgb24_le, /* BGR */ 41 p2p_rgb24, 42 /** [A8-R8-G8-B8] */ 43 p2p_argb32_be, /* ARGB */ 44 p2p_argb32_le, /* BGRA */ 45 p2p_argb32, 46 /** [A8-Y8-U8-V8] */ 47 p2p_ayuv_be, /* AYUV */ 48 p2p_ayuv_le, /* VUYA */ 49 p2p_ayuv, 50 /** [R16-G16-B16] */ 51 p2p_rgb48_be, /* RGB, big-endian components */ 52 p2p_rgb48_le, /* BGR, little-endian components */ 53 p2p_rgb48, 54 /** [A16-R16-G16-B16] */ 55 p2p_argb64_be, /* ARGB big-endian components */ 56 p2p_argb64_le, /* BGRA little-endian components */ 57 p2p_argb64, 58 /** [A2-R10-G10-B10] */ 59 p2p_rgb30_be, /* ARGB packed in big-endian DWORD */ 60 p2p_rgb30_le, /* ARGB packed in little-endian DWORD */ 61 p2p_rgb30, 62 /** [A2-V10-Y10-U10] */ 63 p2p_y410_be, /* AVYU packed in big-endian DWORD */ 64 p2p_y410_le, /* AVYU packed in little-endian DWORD */ 65 p2p_y410, 66 /** [A16-V16-Y16-U16] */ 67 p2p_y416_be, /* AVYU, big-endian components */ 68 p2p_y416_le, /* UYVA, little-endian components */ 69 p2p_y416, 70 /** [Y8] [U8] [Y8] [V8] */ 71 p2p_yuy2, 72 /** [U8] [Y8] [V8] [Y8] */ 73 p2p_uyvy, 74 /** [Y10-!6] [U10-!6] [Y10-!6] [V10-!6] */ 75 p2p_y210_be, /* YUYV, big-endian components, lower 6 bits zero */ 76 p2p_y210_le, /* YUYV, little-endian components, lower 6 bits zero. Microsoft Y210. */ 77 p2p_y210, 78 /** [Y16] [U16] [Y16] [V16] */ 79 p2p_y216_be, /* YUYV, big-endian components */ 80 p2p_y216_le, /* YUYV, little-endian components. Microsoft Y216. */ 81 p2p_y216, 82 /** [!2-V10-Y10-U10] [!2-Y10-U10-Y10] [!2-U10-Y10-V10] [!2-Y10-V10-Y10] */ 83 p2p_v210_be, /* v210 with big-endian DWORDs */ 84 p2p_v210_le, /* Apple/QuickTime v210 */ 85 p2p_v210, 86 /** [U16] [Y16] [V16] [Y16] */ 87 p2p_v216_be, /* UYVY, big-endian components */ 88 p2p_v216_le, /* UYVY, little-endian components. Apple/QuickTime v216. */ 89 p2p_v216, 90 /** [U8-V8] */ 91 p2p_nv12_be, /* aka NV21, V first */ 92 p2p_nv12_le, /* NV12 */ 93 p2p_nv12, 94 /** [U10-!6-V10-!6] */ 95 p2p_p010_be, /* NV21, big-endian components, lower 6 bits zero */ 96 p2p_p010_le, /* NV12, little-endian components, lower 6 bits zero. Microsoft P010. */ 97 p2p_p010, 98 /** [U16-V16] */ 99 p2p_p016_be, /* NV21, big-endian components */ 100 p2p_p016_le, /* NV12, little-endian components. Microsoft P016. */ 101 p2p_p016, 102 /** [U10-!6-V10-!6] */ 103 p2p_p210_be, /* NV21, big-endian components, lower 6 bits zero */ 104 p2p_p210_le, /* NV12, little-endian components, lower 6 bits zero. Microsoft P210. */ 105 p2p_p210, 106 /** [U16-V16] */ 107 p2p_p216_be, /* NV21, big-endian components */ 108 p2p_p216_le, /* NV12, little-endian components. Microsoft P216. */ 109 p2p_p216, 110 /** [R8-G8-B8-A8] */ 111 p2p_rgba32_be, /* RGBA */ 112 p2p_rgba32_le, /* ABGR */ 113 p2p_rgba32, 114 /** [R16-G16-B16-A16] */ 115 p2p_rgba64_be, /* RGBA, big-endian components */ 116 p2p_rgba64_le, /* ABGR, little-endian components */ 117 p2p_rgba64, 118 /** [A16-B16-G16-R16] */ 119 p2p_abgr64_be, /* ABGR, big-endian components */ 120 p2p_abgr64_le, /* RGBA, little-endian components */ 121 p2p_abgr64, 122 /** [B16-G16-R16] */ 123 p2p_bgr48_be, /* BGR, big-endian components */ 124 p2p_bgr48_le, /* RGB, little-endian components */ 125 p2p_bgr48, 126 /** [B16-G16-R16-A16] */ 127 p2p_bgra64_be, /* BGRA, big-endian components */ 128 p2p_bgra64_le, /* ARGB, little-endian components */ 129 p2p_bgra64, 130 131 p2p_packing_max, 132 }; 133 134 struct p2p_buffer_param { 135 /** 136 * Planar order: R-G-B-A or Y-U-V-A. Alpha is optional. 137 * Packed order: Y-UV if NV12/21, else single plane. Y optional for NV12/21. 138 */ 139 const void *src[4]; 140 void *dst[4]; 141 ptrdiff_t src_stride[4]; 142 ptrdiff_t dst_stride[4]; 143 unsigned width; 144 unsigned height; 145 enum p2p_packing packing; 146 }; 147 148 /** Pack/unpack a range of pixels from a scanline. */ 149 typedef void (*p2p_unpack_func)(const void *src, void * const dst[4], unsigned left, unsigned right); 150 typedef void (*p2p_pack_func)(const void * const src[4], void *dst, unsigned left, unsigned right); 151 152 /** Select a line pack/unpack function. */ 153 p2p_unpack_func p2p_select_unpack_func(enum p2p_packing packing); 154 p2p_pack_func p2p_select_pack_func(enum p2p_packing packing); 155 p2p_pack_func p2p_select_pack_func_ex(enum p2p_packing packing, int alpha_one_fill); 156 157 158 /** When processing formats like NV12, ignore the unpacked plane. */ 159 #define P2P_SKIP_UNPACKED_PLANES (1UL << 0) 160 /** When packing, store a bit pattern of all ones in the alpha channel instead of all zeros. */ 161 #define P2P_ALPHA_SET_ONE (1UL << 1) 162 163 /** Helper function to pack/unpack between memory locations. */ 164 void p2p_unpack_frame(const struct p2p_buffer_param *param, unsigned long flags); 165 void p2p_pack_frame(const struct p2p_buffer_param *param, unsigned long flags); 166 167 #ifdef __cplusplus 168 } /* extern "C" */ 169 #endif 170 171 #endif /* P2P_API_H_ */ 172