1 /***************************************************************************** 2 * copy.h: Fast YV12/NV12 copy 3 ***************************************************************************** 4 * Copyright (C) 2009 Laurent Aimar 5 * $Id: 6c438378ef5152f0dff00cc450a22ba4e6cd625a $ 6 * 7 * Authors: Laurent Aimar <fenrir_AT_ videolan _DOT_ org> 8 * 9 * This program is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU Lesser General Public License as published by 11 * the Free Software Foundation; either version 2.1 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public License 20 * along with this program; if not, write to the Free Software Foundation, 21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 *****************************************************************************/ 23 24 #ifndef VLC_VIDEOCHROMA_COPY_H_ 25 #define VLC_VIDEOCHROMA_COPY_H_ 26 27 #include <assert.h> 28 29 typedef struct { 30 # ifdef CAN_COMPILE_SSE2 31 uint8_t *buffer; 32 size_t size; 33 # endif 34 } copy_cache_t; 35 36 int CopyInitCache(copy_cache_t *cache, unsigned width); 37 void CopyCleanCache(copy_cache_t *cache); 38 39 /* YUVY/RGB copies */ 40 void CopyPacked(picture_t *dst, const uint8_t *src, 41 const size_t src_pitch, unsigned height, 42 const copy_cache_t *cache); 43 44 /* Copy planes from NV12/NV21 to NV12/NV21 */ 45 void Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2], 46 const size_t src_pitch[static 2], unsigned height, 47 const copy_cache_t *cache); 48 49 /* Copy planes from I420/YV12 to I420/YV12 */ 50 void Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3], 51 const size_t src_pitch[static 3], unsigned height, 52 const copy_cache_t *cache); 53 54 /* Copy planes from I420/YV12 to NV12/NV21 */ 55 void Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3], 56 const size_t src_pitch[static 3], unsigned height, 57 const copy_cache_t *cache); 58 59 /* Copy planes from NV12/NV21 to I420/YV12 */ 60 void Copy420_SP_to_P(picture_t *dst, const uint8_t *src[static 2], 61 const size_t src_pitch[static 2], unsigned height, 62 const copy_cache_t *cache); 63 64 /* Copy planes from I420_10 to P010. A positive bitshift value will shift bits 65 * to the right, a negative value will shift to the left. */ 66 void Copy420_16_P_to_SP(picture_t *dst, const uint8_t *src[static 3], 67 const size_t src_pitch[static 3], unsigned height, 68 int bitshift, const copy_cache_t *cache); 69 70 /* Copy planes from P010 to I420_10. A positive bitshift value will shift bits 71 * to the right, a negative value will shift to the left. */ 72 void Copy420_16_SP_to_P(picture_t *dst, const uint8_t *src[static 2], 73 const size_t src_pitch[static 2], unsigned height, 74 int bitshift, const copy_cache_t *cache); 75 76 /* XXX: Not optimized copy (no SEE) */ 77 void CopyFromI420_10ToP010(picture_t *dst, const uint8_t *src[static 3], 78 const size_t src_pitch[static 3], 79 unsigned height, const copy_cache_t *cache); 80 81 /** 82 * Swap UV planes of a Tri Planars picture. 83 * 84 * It just swap the planes information without doing any copy. 85 */ 86 void picture_SwapUV(picture_t *picture); 87 88 /** 89 * This functions sets the internal plane pointers/dimensions for the given 90 * buffer. 91 * This is useful when mapping opaque surfaces into CPU planes. 92 * 93 * picture is the picture to update 94 * data is the buffer pointer to use as the start of data for all the planes 95 * pitch is the internal line pitch for the buffer 96 */ 97 int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned pitch); 98 99 #endif 100