FFmpeg
vf_hflip_init.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Benoit Fouet
3  * Copyright (c) 2010 Stefano Sabatini
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFILTER_HFLIP_INIT_H
23 #define AVFILTER_HFLIP_INIT_H
24 
25 #include <stdint.h>
26 
27 #include "config.h"
28 #include "libavutil/attributes.h"
29 #include "libavutil/intreadwrite.h"
30 #include "hflip.h"
31 
32 static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
33 {
34  for (int j = 0; j < w; j++)
35  dst[j] = src[-j];
36 }
37 
38 static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
39 {
40  const uint16_t *src = (const uint16_t *)ssrc;
41  uint16_t *dst = (uint16_t *)ddst;
42 
43  for (int j = 0; j < w; j++)
44  dst[j] = src[-j];
45 }
46 
47 static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
48 {
49  const uint32_t *src = (const uint32_t *)ssrc;
50  uint32_t *dst = (uint32_t *)ddst;
51 
52  for (int j = 0; j < w; j++)
53  dst[j] = src[-j];
54 }
55 
56 static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
57 {
58  const uint8_t *in = src;
59  uint8_t *out = dst;
60 
61  for (int j = 0; j < w; j++, out += 3, in -= 3) {
62  int32_t v = AV_RB24(in);
63 
64  AV_WB24(out, v);
65  }
66 }
67 
68 static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
69 {
70  const uint8_t *in = src;
71  uint8_t *out = dst;
72 
73  for (int j = 0; j < w; j++, out += 6, in -= 6) {
74  int64_t v = AV_RB48(in);
75 
76  AV_WB48(out, v);
77  }
78 }
79 
80 static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
81 {
82  const uint64_t *src = (const uint64_t *)ssrc;
83  uint64_t *dst = (uint64_t *)ddst;
84 
85  for (int j = 0; j < w; j++)
86  dst[j] = src[-j];
87 }
88 
89 static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
90 {
91  for (int i = 0; i < nb_planes; i++) {
92  step[i] *= s->bayer_plus1;
93  switch (step[i]) {
94  case 1: s->flip_line[i] = hflip_byte_c; break;
95  case 2: s->flip_line[i] = hflip_short_c; break;
96  case 3: s->flip_line[i] = hflip_b24_c; break;
97  case 4: s->flip_line[i] = hflip_dword_c; break;
98  case 6: s->flip_line[i] = hflip_b48_c; break;
99  case 8: s->flip_line[i] = hflip_qword_c; break;
100  default:
101  return AVERROR_BUG;
102  }
103  }
104 #if ARCH_X86
105  ff_hflip_init_x86(s, step, nb_planes);
106 #endif
107 
108  return 0;
109 }
110 
111 #endif /* AVFILTER_HFLIP_INIT_H */
AV_RB48
#define AV_RB48(x)
Definition: intreadwrite.h:472
out
FILE * out
Definition: movenc.c:54
av_unused
#define av_unused
Definition: attributes.h:131
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
ff_hflip_init_x86
void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes)
Definition: vf_hflip_init.c:31
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
hflip_short_c
static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
Definition: vf_hflip_init.h:38
hflip_byte_c
static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
Definition: vf_hflip_init.h:32
hflip_qword_c
static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
Definition: vf_hflip_init.h:80
AV_WB24
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
hflip.h
attributes.h
hflip_b24_c
static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
Definition: vf_hflip_init.h:56
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AV_WB48
#define AV_WB48(p, darg)
Definition: intreadwrite.h:481
FlipContext
Definition: hflip.h:27
hflip_dword_c
static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
Definition: vf_hflip_init.h:47
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
int32_t
int32_t
Definition: audioconvert.c:56
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AV_RB24
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:97
hflip_b48_c
static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
Definition: vf_hflip_init.h:68
ff_hflip_init
static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
Definition: vf_hflip_init.h:89