This removes a dependency of checkasm on lavfi/vf_hflip.o and also allows to inline ff_hflip_init() irrespectively of interposing.
Showing the changes to libavfilter (3 of 4 files). Show all
Unified · Split
| @@ -34,7 +34,6 @@ typedef struct FlipContext { · 33 unmodified lines | ||
| 34 | 34 | void (*flip_line[4])(const uint8_t *src, uint8_t *dst, int w); |
| 35 | 35 | } FlipContext; |
| 36 | 36 | |
| 37 | −int ff_hflip_init(FlipContext *s, int step[4], int nb_planes); | |
| 38 | 37 | void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes); |
| 39 | 38 | |
| 40 | 39 | #endif /* AVFILTER_HFLIP_H */ |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #include "formats.h" |
| 32 | 32 | #include "hflip.h" |
| 33 | 33 | #include "internal.h" |
| 34 | +#include "vf_hflip_init.h" | |
| 34 | 35 | #include "video.h" |
| 35 | 36 | #include "libavutil/pixdesc.h" |
| 36 | 37 | #include "libavutil/internal.h" |
| @@ -61,70 +62,6 @@ static int query_formats(AVFilterContext *ctx) · 24 unmodified lines | ||
| 61 | 62 | return ff_set_common_formats(ctx, pix_fmts); |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | −static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w) | |
| 65 | −{ | |
| 66 | − int j; | |
| 67 | − | |
| 68 | − for (j = 0; j < w; j++) | |
| 69 | − dst[j] = src[-j]; | |
| 70 | −} | |
| 71 | − | |
| 72 | −static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
| 73 | −{ | |
| 74 | − const uint16_t *src = (const uint16_t *)ssrc; | |
| 75 | − uint16_t *dst = (uint16_t *)ddst; | |
| 76 | − int j; | |
| 77 | − | |
| 78 | − for (j = 0; j < w; j++) | |
| 79 | − dst[j] = src[-j]; | |
| 80 | −} | |
| 81 | − | |
| 82 | −static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
| 83 | −{ | |
| 84 | − const uint32_t *src = (const uint32_t *)ssrc; | |
| 85 | − uint32_t *dst = (uint32_t *)ddst; | |
| 86 | − int j; | |
| 87 | − | |
| 88 | − for (j = 0; j < w; j++) | |
| 89 | − dst[j] = src[-j]; | |
| 90 | −} | |
| 91 | − | |
| 92 | −static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w) | |
| 93 | −{ | |
| 94 | − const uint8_t *in = src; | |
| 95 | − uint8_t *out = dst; | |
| 96 | − int j; | |
| 97 | − | |
| 98 | − for (j = 0; j < w; j++, out += 3, in -= 3) { | |
| 99 | − int32_t v = AV_RB24(in); | |
| 100 | − | |
| 101 | − AV_WB24(out, v); | |
| 102 | − } | |
| 103 | −} | |
| 104 | − | |
| 105 | −static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w) | |
| 106 | −{ | |
| 107 | − const uint8_t *in = src; | |
| 108 | − uint8_t *out = dst; | |
| 109 | − int j; | |
| 110 | − | |
| 111 | − for (j = 0; j < w; j++, out += 6, in -= 6) { | |
| 112 | − int64_t v = AV_RB48(in); | |
| 113 | − | |
| 114 | − AV_WB48(out, v); | |
| 115 | − } | |
| 116 | −} | |
| 117 | − | |
| 118 | −static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
| 119 | −{ | |
| 120 | − const uint64_t *src = (const uint64_t *)ssrc; | |
| 121 | − uint64_t *dst = (uint64_t *)ddst; | |
| 122 | − int j; | |
| 123 | − | |
| 124 | − for (j = 0; j < w; j++) | |
| 125 | − dst[j] = src[-j]; | |
| 126 | −} | |
| 127 | − | |
| 128 | 65 | static int config_props(AVFilterLink *inlink) |
| 129 | 66 | { |
| 130 | 67 | FlipContext *s = inlink->dst->priv; |
| @@ -145,29 +82,6 @@ static int config_props(AVFilterLink *inlink) · 14 unmodified lines | ||
| 145 | 82 | return ff_hflip_init(s, s->max_step, nb_planes); |
| 146 | 83 | } |
| 147 | 84 | |
| 148 | −int ff_hflip_init(FlipContext *s, int step[4], int nb_planes) | |
| 149 | −{ | |
| 150 | − int i; | |
| 151 | − | |
| 152 | − for (i = 0; i < nb_planes; i++) { | |
| 153 | − step[i] *= s->bayer_plus1; | |
| 154 | − switch (step[i]) { | |
| 155 | − case 1: s->flip_line[i] = hflip_byte_c; break; | |
| 156 | − case 2: s->flip_line[i] = hflip_short_c; break; | |
| 157 | − case 3: s->flip_line[i] = hflip_b24_c; break; | |
| 158 | − case 4: s->flip_line[i] = hflip_dword_c; break; | |
| 159 | − case 6: s->flip_line[i] = hflip_b48_c; break; | |
| 160 | − case 8: s->flip_line[i] = hflip_qword_c; break; | |
| 161 | − default: | |
| 162 | − return AVERROR_BUG; | |
| 163 | − } | |
| 164 | − } | |
| 165 | − if (ARCH_X86) | |
| 166 | − ff_hflip_init_x86(s, step, nb_planes); | |
| 167 | − | |
| 168 | − return 0; | |
| 169 | −} | |
| 170 | − | |
| 171 | 85 | typedef struct ThreadData { |
| 172 | 86 | AVFrame *in, *out; |
| 173 | 87 | } ThreadData; |
| @@ -0,0 +1,110 @@ | ||
| 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 | + | |
| 107 | + return 0; | |
| 108 | +} | |
| 109 | + | |
| 110 | +#endif /* AVFILTER_HFLIP_INIT_H */ | |