Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 1 | /* |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 2 | * This file is part of FFmpeg. |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 3 | * |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 4 | * FFmpeg is free software; you can redistribute it and/or |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 9 | * FFmpeg is distributed in the hope that it will be useful, |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 15 | * License along with FFmpeg; if not, write to the Free Software |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #ifndef AVCODEC_COPY_BLOCK_H |
| 20 | #define AVCODEC_COPY_BLOCK_H |
| 21 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 22 | #include <stddef.h> |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 23 | #include <stdint.h> |
| 24 | |
| 25 | #include "libavutil/intreadwrite.h" |
| 26 | |
Clément Bœsch | 21c18b0 | 2017-03-20 08:22:36 | [diff] [blame] | 27 | static inline void copy_block2(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 28 | { |
| 29 | int i; |
Clément Bœsch | 6492629 | 2017-03-20 08:23:15 | [diff] [blame] | 30 | for (i = 0; i < h; i++) { |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 31 | AV_COPY16U(dst, src); |
Clément Bœsch | 6492629 | 2017-03-20 08:23:15 | [diff] [blame] | 32 | dst += dstStride; |
| 33 | src += srcStride; |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 37 | static inline void copy_block4(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 38 | { |
| 39 | int i; |
Vittorio Giovara | d37c962 | 2014-03-10 16:05:12 | [diff] [blame] | 40 | for (i = 0; i < h; i++) { |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 41 | AV_COPY32U(dst, src); |
Vittorio Giovara | d37c962 | 2014-03-10 16:05:12 | [diff] [blame] | 42 | dst += dstStride; |
| 43 | src += srcStride; |
Michael Niedermayer | b058301 | 2013-02-09 12:16:57 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 47 | static inline void copy_block8(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 48 | { |
| 49 | int i; |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 50 | for (i = 0; i < h; i++) { |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 51 | AV_COPY64U(dst, src); |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 52 | dst += dstStride; |
| 53 | src += srcStride; |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 57 | static inline void copy_block9(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 58 | { |
| 59 | int i; |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 60 | for (i = 0; i < h; i++) { |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 61 | AV_COPY64U(dst, src); |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 62 | dst[8] = src[8]; |
| 63 | dst += dstStride; |
| 64 | src += srcStride; |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 68 | static inline void copy_block16(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Vittorio Giovara | d37c962 | 2014-03-10 16:05:12 | [diff] [blame] | 69 | { |
| 70 | int i; |
| 71 | for (i = 0; i < h; i++) { |
| 72 | AV_COPY128U(dst, src); |
| 73 | dst += dstStride; |
| 74 | src += srcStride; |
| 75 | } |
| 76 | } |
| 77 | |
Diego Biurrun | 73f5e17 | 2016-08-26 10:38:33 | [diff] [blame] | 78 | static inline void copy_block17(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h) |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 79 | { |
| 80 | int i; |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 81 | for (i = 0; i < h; i++) { |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 82 | AV_COPY128U(dst, src); |
Vittorio Giovara | b4e355c | 2014-03-10 20:44:26 | [diff] [blame] | 83 | dst[16] = src[16]; |
| 84 | dst += dstStride; |
| 85 | src += srcStride; |
Diego Biurrun | b9ba525 | 2013-02-07 21:03:49 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
| 89 | #endif /* AVCODEC_COPY_BLOCK_H */ |