Before this commit, the input in get_pixels and get_pixels_unaligned has been treated inconsistenly: - The generic code treated 9, 10, 12 and 14 bits as 16bit input (these bits correspond to what FFmpeg's dsputils supported), everything with <= 8 bits as 8 bit and everything else as 8 bit when used via AVDCT (which exposes these functions and purports to support up to 14 bits). - AARCH64, ARM, PPC and RISC-V, x86 ignore this AVDCT special case. - RISC-V also ignored the restriction to 9, 10, 12 and 14 for its 16bit check and treated everything > 8 bits as 16bit. - The mmi MIPS code treats everything as 8 bit when used via AVDCT (this is certainly broken); otherwise it checks for <= 8 bits. The msa MIPS code behaves like the generic code. This commit changes this to treat 9..16 bits as 16 bit input, everything else as 8 bit (the former because it makes sense, the latter to preserve the behaviour for external users*). *: The only internal user of AVDCT (the spp filter) always uses 8, 9 or 10 bits.
Showing the changes to libavcodec (8 of 8 files). Show all
Unified · Split
| @@ -21,7 +21,6 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "libavutil/attributes.h" |
| 22 | 22 | #include "libavutil/cpu.h" |
| 23 | 23 | #include "libavutil/aarch64/cpu.h" |
| 24 | −#include "libavcodec/avcodec.h" | |
| 25 | 24 | #include "libavcodec/pixblockdsp.h" |
| 26 | 25 | |
| 27 | 26 | void ff_get_pixels_neon(int16_t *block, const uint8_t *pixels, |
| @@ -30,7 +29,6 @@ void ff_diff_pixels_neon(int16_t *block, const uint8_t *s1, · 2 unmodified lines | ||
| 30 | 29 | const uint8_t *s2, ptrdiff_t stride); |
| 31 | 30 | |
| 32 | 31 | av_cold void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c, |
| 33 | − AVCodecContext *avctx, | |
| 34 | 32 | unsigned high_bit_depth) |
| 35 | 33 | { |
| 36 | 34 | int cpu_flags = av_get_cpu_flags(); |
| @@ -21,7 +21,6 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "libavutil/attributes.h" |
| 22 | 22 | #include "libavutil/cpu.h" |
| 23 | 23 | #include "libavutil/arm/cpu.h" |
| 24 | −#include "libavcodec/avcodec.h" | |
| 25 | 24 | #include "libavcodec/pixblockdsp.h" |
| 26 | 25 | |
| 27 | 26 | void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, |
| @@ -39,7 +38,6 @@ void ff_diff_pixels_unaligned_neon(int16_t *block, const uint8_t *s1, · 11 unmodified lines | ||
| 39 | 38 | const uint8_t *s2, ptrdiff_t stride); |
| 40 | 39 | |
| 41 | 40 | av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c, |
| 42 | − AVCodecContext *avctx, | |
| 43 | 41 | unsigned high_bit_depth) |
| 44 | 42 | { |
| 45 | 43 | int cpu_flags = av_get_cpu_flags(); |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "libavcodec/pixblockdsp.h" |
| 24 | 24 | #include "pixblockdsp_mips.h" |
| 25 | 25 | |
| 26 | −void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 26 | +void ff_pixblockdsp_init_mips(PixblockDSPContext *c, | |
| 27 | 27 | unsigned high_bit_depth) |
| 28 | 28 | { |
| 29 | 29 | int cpu_flags = av_get_cpu_flags(); |
| @@ -31,27 +31,13 @@ void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, · 1 unmodified line | ||
| 31 | 31 | if (have_mmi(cpu_flags)) { |
| 32 | 32 | c->diff_pixels = ff_diff_pixels_mmi; |
| 33 | 33 | |
| 34 | − if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { | |
| 34 | + if (!high_bit_depth) | |
| 35 | 35 | c->get_pixels = ff_get_pixels_8_mmi; |
| 36 | − } | |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | 38 | if (have_msa(cpu_flags)) { |
| 40 | 39 | c->diff_pixels = ff_diff_pixels_msa; |
| 41 | 40 | |
| 42 | − switch (avctx->bits_per_raw_sample) { | |
| 43 | − case 9: | |
| 44 | − case 10: | |
| 45 | − case 12: | |
| 46 | − case 14: | |
| 47 | − c->get_pixels = ff_get_pixels_16_msa; | |
| 48 | − break; | |
| 49 | − default: | |
| 50 | − if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type != | |
| 51 | − AVMEDIA_TYPE_VIDEO) { | |
| 52 | − c->get_pixels = ff_get_pixels_8_msa; | |
| 53 | − } | |
| 54 | − break; | |
| 55 | − } | |
| 41 | + c->get_pixels = high_bit_depth ? ff_get_pixels_16_msa : ff_get_pixels_8_msa; | |
| 56 | 42 | } |
| 57 | 43 | } |
| @@ -87,38 +87,31 @@ static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, · 86 unmodified lines | ||
| 87 | 87 | |
| 88 | 88 | av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) |
| 89 | 89 | { |
| 90 | − av_unused const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; | |
| 90 | + const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8 && | |
| 91 | + avctx->bits_per_raw_sample <= 16; | |
| 91 | 92 | |
| 92 | 93 | c->diff_pixels_unaligned = |
| 93 | 94 | c->diff_pixels = diff_pixels_c; |
| 94 | 95 | |
| 95 | − switch (avctx->bits_per_raw_sample) { | |
| 96 | − case 9: | |
| 97 | − case 10: | |
| 98 | − case 12: | |
| 99 | − case 14: | |
| 96 | + if (high_bit_depth) { | |
| 100 | 97 | c->get_pixels_unaligned = get_pixels_unaligned_16_c; |
| 101 | − c->get_pixels = get_pixels_16_c; | |
| 102 | − break; | |
| 103 | − default: | |
| 104 | − if (avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { | |
| 105 | − c->get_pixels_unaligned = | |
| 106 | − c->get_pixels = get_pixels_8_c; | |
| 107 | − } | |
| 108 | − break; | |
| 98 | + c->get_pixels = get_pixels_16_c; | |
| 99 | + } else { | |
| 100 | + c->get_pixels_unaligned = | |
| 101 | + c->get_pixels = get_pixels_8_c; | |
| 109 | 102 | } |
| 110 | 103 | |
| 111 | 104 | #if ARCH_AARCH64 |
| 112 | − ff_pixblockdsp_init_aarch64(c, avctx, high_bit_depth); | |
| 105 | + ff_pixblockdsp_init_aarch64(c, high_bit_depth); | |
| 113 | 106 | #elif ARCH_ARM |
| 114 | − ff_pixblockdsp_init_arm(c, avctx, high_bit_depth); | |
| 107 | + ff_pixblockdsp_init_arm(c, high_bit_depth); | |
| 115 | 108 | #elif ARCH_PPC |
| 116 | − ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth); | |
| 109 | + ff_pixblockdsp_init_ppc(c, high_bit_depth); | |
| 117 | 110 | #elif ARCH_RISCV |
| 118 | − ff_pixblockdsp_init_riscv(c, avctx, high_bit_depth); | |
| 111 | + ff_pixblockdsp_init_riscv(c, high_bit_depth); | |
| 119 | 112 | #elif ARCH_X86 |
| 120 | − ff_pixblockdsp_init_x86(c, avctx, high_bit_depth); | |
| 113 | + ff_pixblockdsp_init_x86(c, high_bit_depth); | |
| 121 | 114 | #elif ARCH_MIPS |
| 122 | − ff_pixblockdsp_init_mips(c, avctx, high_bit_depth); | |
| 115 | + ff_pixblockdsp_init_mips(c, high_bit_depth); | |
| 123 | 116 | #endif |
| 124 | 117 | } |
| @@ -42,17 +42,17 @@ typedef struct PixblockDSPContext { · 41 unmodified lines | ||
| 42 | 42 | } PixblockDSPContext; |
| 43 | 43 | |
| 44 | 44 | void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx); |
| 45 | −void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 45 | +void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c, | |
| 46 | 46 | unsigned high_bit_depth); |
| 47 | −void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 47 | +void ff_pixblockdsp_init_arm(PixblockDSPContext *c, | |
| 48 | 48 | unsigned high_bit_depth); |
| 49 | −void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 49 | +void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, | |
| 50 | 50 | unsigned high_bit_depth); |
| 51 | −void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 51 | +void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, | |
| 52 | 52 | unsigned high_bit_depth); |
| 53 | −void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 53 | +void ff_pixblockdsp_init_x86(PixblockDSPContext *c, | |
| 54 | 54 | unsigned high_bit_depth); |
| 55 | −void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, | |
| 55 | +void ff_pixblockdsp_init_mips(PixblockDSPContext *c, | |
| 56 | 56 | unsigned high_bit_depth); |
| 57 | 57 | |
| 58 | 58 | #endif /* AVCODEC_PIXBLOCKDSP_H */ |
| @@ -27,7 +27,6 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "libavutil/ppc/cpu.h" |
| 28 | 28 | #include "libavutil/ppc/util_altivec.h" |
| 29 | 29 | |
| 30 | −#include "libavcodec/avcodec.h" | |
| 31 | 30 | #include "libavcodec/pixblockdsp.h" |
| 32 | 31 | |
| 33 | 32 | #if HAVE_ALTIVEC |
| @@ -263,7 +262,6 @@ static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1, · 229 unmodified lines | ||
| 263 | 262 | #endif /* HAVE_VSX */ |
| 264 | 263 | |
| 265 | 264 | av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, |
| 266 | − AVCodecContext *avctx, | |
| 267 | 265 | unsigned high_bit_depth) |
| 268 | 266 | { |
| 269 | 267 | #if HAVE_ALTIVEC |
| @@ -24,7 +24,6 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "libavutil/attributes.h" |
| 25 | 25 | #include "libavutil/cpu.h" |
| 26 | 26 | #include "libavutil/riscv/cpu.h" |
| 27 | −#include "libavcodec/avcodec.h" | |
| 28 | 27 | #include "libavcodec/pixblockdsp.h" |
| 29 | 28 | |
| 30 | 29 | void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels, |
| @@ -42,7 +41,6 @@ void ff_diff_pixels_unaligned_rvv(int16_t *block, const uint8_t *s1, · 11 unmodified lines | ||
| 42 | 41 | const uint8_t *s2, ptrdiff_t stride); |
| 43 | 42 | |
| 44 | 43 | av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, |
| 45 | − AVCodecContext *avctx, | |
| 46 | 44 | unsigned high_bit_depth) |
| 47 | 45 | { |
| 48 | 46 | #if HAVE_RV |
| @@ -28,7 +28,6 @@ void ff_diff_pixels_sse2(int16_t *block, const uint8_t *s1, const uint8_t *s2, · 27 unmodified lines | ||
| 28 | 28 | ptrdiff_t stride); |
| 29 | 29 | |
| 30 | 30 | av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, |
| 31 | − AVCodecContext *avctx, | |
| 32 | 31 | unsigned high_bit_depth) |
| 33 | 32 | { |
| 34 | 33 | int cpu_flags = av_get_cpu_flags(); |