History

avcodec/v210enc: Move ff_v210enc_init into a header

This removes a dependency of checkasm on lavc/v210_enc.o and also allows to inline ff_v210enc_init() irrespectively of interposing. This dependency pulled basically all of libavcodec into checkasm, in particular all codecs. This also makes checkasm work when using shared Windows builds: On Windows, it needs to be known to the compiler whether a data symbol is external to the library/executable or not; hence the need for av_export_avutil. checkasm needs access to the internals of the libraries it tests and is therefore linked statically to all the libraries. This means that the users of avpriv_cga_font and avpriv_vga16_font in libavcodec (namely ansi.o, bintext.o, tmv.o) end up in the same executable as the symbols, although they have been compiled as if these symbols were external, leading to linker errors. With this commit said files are discarded by the linker, bypassing this problem.

Andreas Rheinhardt committed 4 years ago

Commit d496bbe1 parent 0c2489f5 files · +92 −59Browse files

Unified · Split

5 files
  1. libavcodec/v210_template.c +0 −10
  2. libavcodec/v210enc.c +1 −46
  3. libavcodec/v210enc.h +0 −2
  4. libavcodec/v210enc_init.h +90 −0
  5. tests/checkasm/v210enc.c +1 −1
libavcodec/v210_template.c+0−10
@@ -22,16 +22,6 @@ · 21 unmodified lines
2222 #include "bytestream.h"
2323 #include "internal.h"
2424
25−#define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1<<depth)-(1<<(depth-8))-1))
26−#define WRITE_PIXELS(a, b, c, depth) \
27− do { \
28− val = CLIP(*a++, depth) << (10-depth); \
29− val |= (CLIP(*b++, depth) << (20-depth)) | \
30− (CLIP(*c++, depth) << (30-depth)); \
31− AV_WL32(dst, val); \
32− dst += 4; \
33− } while (0)
34−
3525 static void RENAME(v210_enc)(AVCodecContext *avctx,
3626 uint8_t *dst, const AVFrame *pic)
3727 {
libavcodec/v210enc.c+1−46
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "encode.h"
2828 #include "internal.h"
2929 #include "v210enc.h"
30+#include "v210enc_init.h"
3031
3132 #define TYPE uint8_t
3233 #define DEPTH 8
@@ -48,52 +49,6 @@ · 15 unmodified lines
4849 #undef BYTES_PER_PIXEL
4950 #undef TYPE
5051
51−static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
52− const uint8_t *v, uint8_t *dst,
53− ptrdiff_t width)
54−{
55− uint32_t val;
56− int i;
57−
58− /* unroll this to match the assembly */
59− for (i = 0; i < width - 11; i += 12) {
60− WRITE_PIXELS(u, y, v, 8);
61− WRITE_PIXELS(y, u, y, 8);
62− WRITE_PIXELS(v, y, u, 8);
63− WRITE_PIXELS(y, v, y, 8);
64− WRITE_PIXELS(u, y, v, 8);
65− WRITE_PIXELS(y, u, y, 8);
66− WRITE_PIXELS(v, y, u, 8);
67− WRITE_PIXELS(y, v, y, 8);
68− }
69−}
70−
71−static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
72− const uint16_t *v, uint8_t *dst,
73− ptrdiff_t width)
74−{
75− uint32_t val;
76− int i;
77−
78− for (i = 0; i < width - 5; i += 6) {
79− WRITE_PIXELS(u, y, v, 10);
80− WRITE_PIXELS(y, u, y, 10);
81− WRITE_PIXELS(v, y, u, 10);
82− WRITE_PIXELS(y, v, y, 10);
83− }
84−}
85−
86−av_cold void ff_v210enc_init(V210EncContext *s)
87−{
88− s->pack_line_8 = v210_planar_pack_8_c;
89− s->pack_line_10 = v210_planar_pack_10_c;
90− s->sample_factor_8 = 2;
91− s->sample_factor_10 = 1;
92−
93− if (ARCH_X86)
94− ff_v210enc_init_x86(s);
95−}
96−
9752 static av_cold int encode_init(AVCodecContext *avctx)
9853 {
9954 V210EncContext *s = avctx->priv_data;
libavcodec/v210enc.h+0−2
@@ -32,8 +32,6 @@ typedef struct V210EncContext { · 31 unmodified lines
3232 int sample_factor_10;
3333 } V210EncContext;
3434
35−void ff_v210enc_init(V210EncContext *s);
36−
3735 void ff_v210enc_init_x86(V210EncContext *s);
3836
3937 #endif /* AVCODEC_V210ENC_H */
libavcodec/v210enc_init.h+90−0
@@ -0,0 +1,90 @@
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+
79+static av_cold av_unused void ff_v210enc_init(V210EncContext *s)
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)
87+ ff_v210enc_init_x86(s);
88+}
89+
90+#endif /* AVCODEC_V210ENC_INIT_H */
tests/checkasm/v210enc.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020
2121 #include <string.h>
2222 #include "checkasm.h"
23−#include "libavcodec/v210enc.h"
23+#include "libavcodec/v210enc_init.h"
2424 #include "libavutil/common.h"
2525 #include "libavutil/internal.h"
2626 #include "libavutil/intreadwrite.h"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t