FFmpeg
Loading...
Searching...
No Matches
huffyuvencdsp.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
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 *
9 * FFmpeg is distributed in the hope that it will be useful,
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
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
22#include "huffyuvencdsp.h"
23#include "mathops.h"
24
25#if HAVE_FAST_64BIT
26#define BITS 64
27typedef uint64_t uint_native;
28#else
29#define BITS 32
30typedef uint32_t uint_native;
31#endif
32#define RN AV_JOIN(AV_RN, BITS)
33#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A)
34#define WNA AV_JOIN(AV_JOIN(AV_WN, BITS), A)
35
36// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
37#define pb_7f (~(uint_native)0 / 255 * 0x7f)
38#define pb_80 (~(uint_native)0 / 255 * 0x80)
39
40// 0x00010001 or 0x0001000100010001 or whatever, depending on the cpu's native arithmetic size
41#define pw_1 ((uint_native)-1 / UINT16_MAX)
42
43static void diff_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w){
44 long i;
45#if !HAVE_FAST_UNALIGNED
46 if ((uintptr_t)src2 & (sizeof(uint_native) - 1)) {
47 for(i=0; i+3<w; i+=4){
48 dst[i+0] = (src1[i+0]-src2[i+0]) & mask;
49 dst[i+1] = (src1[i+1]-src2[i+1]) & mask;
50 dst[i+2] = (src1[i+2]-src2[i+2]) & mask;
51 dst[i+3] = (src1[i+3]-src2[i+3]) & mask;
52 }
53 }else
54#endif
55 {
56 uint_native pw_lsb = (mask >> 1) * pw_1;
57 uint_native pw_msb = pw_lsb + pw_1;
58
59 for (i = 0; i <= w - (int)sizeof(uint_native)/2; i += sizeof(uint_native)/2) {
60 uint_native a = RNA(src1 + i);
61 uint_native b = RN (src2 + i);
62 WNA(dst + i, ((a | pw_msb) - (b & pw_lsb)) ^ ((a^b^pw_msb) & pw_msb));
63 }
64 }
65 for (; i<w; i++)
66 dst[i] = (src1[i] - src2[i]) & mask;
67}
68
69static void sub_hfyu_median_pred_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top){
70 int i;
71 uint16_t l, lt;
72
73 l = *left;
74 lt = *left_top;
75
76 for(i=0; i<w; i++){
77 const int pred = mid_pred(l, src1[i], (l + src1[i] - lt) & mask);
78 lt = src1[i];
79 l = src2[i];
80 dst[i] = (l - pred) & mask;
81 }
82
83 *left = l;
84 *left_top = lt;
85}
86
88{
89 c->diff_int16 = diff_int16_c;
90 c->sub_hfyu_median_pred_int16 = sub_hfyu_median_pred_int16_c;
91
92#if ARCH_X86 && HAVE_X86ASM
94#endif
95}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
int a
const pixel * src2
void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, int bpp, int width)
#define b
Definition input.c:43
#define pw_1
Definition huffyuvdsp.c:28
#define WNA
static void sub_hfyu_median_pred_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top)
uint32_t uint_native
#define RNA
static void diff_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w)
#define RN
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, int bpp, int width)
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
uint8_t w
Definition llvidencdsp.c:39
static const uint16_t mask[17]
Definition lzw.c:38
#define mid_pred
Definition mathops.h:115
static const float pred[4]
Definition siprdata.h:259
#define src1
Definition h264pred.c:141
#define width
Definition dsp.h:89
static double c[64]