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
22#include "bytestream.h"22#include "bytestream.h"
23#include "internal.h"23#include "internal.h"
24 24
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
35static void RENAME(v210_enc)(AVCodecContext *avctx,25static void RENAME(v210_enc)(AVCodecContext *avctx,
36 uint8_t *dst, const AVFrame *pic)26 uint8_t *dst, const AVFrame *pic)
37{27{
libavcodec/v210enc.c+1−46
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#include "encode.h"27#include "encode.h"
28#include "internal.h"28#include "internal.h"
29#include "v210enc.h"29#include "v210enc.h"
30#include "v210enc_init.h"
30 31
31#define TYPE uint8_t32#define TYPE uint8_t
32#define DEPTH 833#define DEPTH 8
@@ -48,52 +49,6 @@ · 15 unmodified lines
48#undef BYTES_PER_PIXEL49#undef BYTES_PER_PIXEL
49#undef TYPE50#undef TYPE
50 51
51static 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
71static 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
86av_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
97static av_cold int encode_init(AVCodecContext *avctx)52static av_cold int encode_init(AVCodecContext *avctx)
98{53{
99 V210EncContext *s = avctx->priv_data;54 V210EncContext *s = avctx->priv_data;
libavcodec/v210enc.h+0−2
@@ -32,8 +32,6 @@ typedef struct V210EncContext { · 31 unmodified lines
32 int sample_factor_10;32 int sample_factor_10;
33} V210EncContext;33} V210EncContext;
34 34
35void ff_v210enc_init(V210EncContext *s);
36
37void ff_v210enc_init_x86(V210EncContext *s);35void ff_v210enc_init_x86(V210EncContext *s);
38 36
39#endif /* AVCODEC_V210ENC_H */37#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
46static 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
65static 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
79static 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
20 20
21#include <string.h>21#include <string.h>
22#include "checkasm.h"22#include "checkasm.h"
23#include "libavcodec/v210enc.h"23#include "libavcodec/v210enc_init.h"
24#include "libavutil/common.h"24#include "libavutil/common.h"
25#include "libavutil/internal.h"25#include "libavutil/internal.h"
26#include "libavutil/intreadwrite.h"26#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