FFmpeg
v210enc_init.h
Go to the documentation of this file.
1 /*
2  * V210 encoder DSP init
3  *
4  * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at>
5  * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg 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 GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_V210ENC_INIT_H
25 #define AVCODEC_V210ENC_INIT_H
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #include "config.h"
31 #include "libavutil/attributes.h"
32 #include "libavutil/common.h"
33 #include "libavutil/intreadwrite.h"
34 #include "v210enc.h"
35 
36 #define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1<<depth)-(1<<(depth-8))-1))
37 #define WRITE_PIXELS(a, b, c, depth) \
38  do { \
39  val = CLIP(*a++, depth) << (10-depth); \
40  val |= (CLIP(*b++, depth) << (20-depth)) | \
41  (CLIP(*c++, depth) << (30-depth)); \
42  AV_WL32(dst, val); \
43  dst += 4; \
44  } while (0)
45 
46 static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
47  const uint8_t *v, uint8_t *dst,
48  ptrdiff_t width)
49 {
50  uint32_t val;
51 
52  /* unroll this to match the assembly */
53  for (int i = 0; i < width - 11; i += 12) {
54  WRITE_PIXELS(u, y, v, 8);
55  WRITE_PIXELS(y, u, y, 8);
56  WRITE_PIXELS(v, y, u, 8);
57  WRITE_PIXELS(y, v, y, 8);
58  WRITE_PIXELS(u, y, v, 8);
59  WRITE_PIXELS(y, u, y, 8);
60  WRITE_PIXELS(v, y, u, 8);
61  WRITE_PIXELS(y, v, y, 8);
62  }
63 }
64 
65 static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
66  const uint16_t *v, uint8_t *dst,
67  ptrdiff_t width)
68 {
69  uint32_t val;
70 
71  for (int i = 0; i < width - 5; i += 6) {
72  WRITE_PIXELS(u, y, v, 10);
73  WRITE_PIXELS(y, u, y, 10);
74  WRITE_PIXELS(v, y, u, 10);
75  WRITE_PIXELS(y, v, y, 10);
76  }
77 }
78 
80 {
81  s->pack_line_8 = v210_planar_pack_8_c;
82  s->pack_line_10 = v210_planar_pack_10_c;
83  s->sample_factor_8 = 2;
84  s->sample_factor_10 = 1;
85 
86 #if ARCH_X86
88 #endif
89 }
90 
91 #endif /* AVCODEC_V210ENC_INIT_H */
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:262
av_unused
#define av_unused
Definition: attributes.h:131
val
static double val(void *priv, double ch)
Definition: aeval.c:77
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
v210enc.h
V210EncContext
Definition: v210enc.h:26
WRITE_PIXELS
#define WRITE_PIXELS(a, b, c, depth)
Definition: v210enc_init.h:37
attributes.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
common.h
ff_v210enc_init_x86
void ff_v210enc_init_x86(V210EncContext *s)
Definition: v210enc_init.c:47
ff_v210enc_init
static av_cold av_unused void ff_v210enc_init(V210EncContext *s)
Definition: v210enc_init.h:79
v210_planar_pack_10_c
static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
Definition: v210enc_init.h:65
v210_planar_pack_8_c
static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
Definition: v210enc_init.h:46