You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/pixblockdsp: Improve 8 vs 16 bit check
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. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -21,7 +21,6 @@
|
|||||||
#include "libavutil/attributes.h"
|
#include "libavutil/attributes.h"
|
||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
#include "libavutil/aarch64/cpu.h"
|
#include "libavutil/aarch64/cpu.h"
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#include "libavcodec/pixblockdsp.h"
|
#include "libavcodec/pixblockdsp.h"
|
||||||
|
|
||||||
void ff_get_pixels_neon(int16_t *block, const uint8_t *pixels,
|
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,
|
|||||||
const uint8_t *s2, ptrdiff_t stride);
|
const uint8_t *s2, ptrdiff_t stride);
|
||||||
|
|
||||||
av_cold void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c,
|
av_cold void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c,
|
||||||
AVCodecContext *avctx,
|
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
int cpu_flags = av_get_cpu_flags();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "libavutil/attributes.h"
|
#include "libavutil/attributes.h"
|
||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
#include "libavutil/arm/cpu.h"
|
#include "libavutil/arm/cpu.h"
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#include "libavcodec/pixblockdsp.h"
|
#include "libavcodec/pixblockdsp.h"
|
||||||
|
|
||||||
void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels,
|
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,
|
|||||||
const uint8_t *s2, ptrdiff_t stride);
|
const uint8_t *s2, ptrdiff_t stride);
|
||||||
|
|
||||||
av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c,
|
av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c,
|
||||||
AVCodecContext *avctx,
|
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
int cpu_flags = av_get_cpu_flags();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "libavcodec/pixblockdsp.h"
|
#include "libavcodec/pixblockdsp.h"
|
||||||
#include "pixblockdsp_mips.h"
|
#include "pixblockdsp_mips.h"
|
||||||
|
|
||||||
void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_mips(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
int cpu_flags = av_get_cpu_flags();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
@ -31,27 +31,13 @@ void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
|
|||||||
if (have_mmi(cpu_flags)) {
|
if (have_mmi(cpu_flags)) {
|
||||||
c->diff_pixels = ff_diff_pixels_mmi;
|
c->diff_pixels = ff_diff_pixels_mmi;
|
||||||
|
|
||||||
if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
|
if (!high_bit_depth)
|
||||||
c->get_pixels = ff_get_pixels_8_mmi;
|
c->get_pixels = ff_get_pixels_8_mmi;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_msa(cpu_flags)) {
|
if (have_msa(cpu_flags)) {
|
||||||
c->diff_pixels = ff_diff_pixels_msa;
|
c->diff_pixels = ff_diff_pixels_msa;
|
||||||
|
|
||||||
switch (avctx->bits_per_raw_sample) {
|
c->get_pixels = high_bit_depth ? ff_get_pixels_16_msa : ff_get_pixels_8_msa;
|
||||||
case 9:
|
|
||||||
case 10:
|
|
||||||
case 12:
|
|
||||||
case 14:
|
|
||||||
c->get_pixels = ff_get_pixels_16_msa;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type !=
|
|
||||||
AVMEDIA_TYPE_VIDEO) {
|
|
||||||
c->get_pixels = ff_get_pixels_8_msa;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,38 +87,31 @@ static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1,
|
|||||||
|
|
||||||
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx)
|
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
av_unused const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
|
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8 &&
|
||||||
|
avctx->bits_per_raw_sample <= 16;
|
||||||
|
|
||||||
c->diff_pixels_unaligned =
|
c->diff_pixels_unaligned =
|
||||||
c->diff_pixels = diff_pixels_c;
|
c->diff_pixels = diff_pixels_c;
|
||||||
|
|
||||||
switch (avctx->bits_per_raw_sample) {
|
if (high_bit_depth) {
|
||||||
case 9:
|
|
||||||
case 10:
|
|
||||||
case 12:
|
|
||||||
case 14:
|
|
||||||
c->get_pixels_unaligned = get_pixels_unaligned_16_c;
|
c->get_pixels_unaligned = get_pixels_unaligned_16_c;
|
||||||
c->get_pixels = get_pixels_16_c;
|
c->get_pixels = get_pixels_16_c;
|
||||||
break;
|
} else {
|
||||||
default:
|
c->get_pixels_unaligned =
|
||||||
if (avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
|
c->get_pixels = get_pixels_8_c;
|
||||||
c->get_pixels_unaligned =
|
|
||||||
c->get_pixels = get_pixels_8_c;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ARCH_AARCH64
|
#if ARCH_AARCH64
|
||||||
ff_pixblockdsp_init_aarch64(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_aarch64(c, high_bit_depth);
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
ff_pixblockdsp_init_arm(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_arm(c, high_bit_depth);
|
||||||
#elif ARCH_PPC
|
#elif ARCH_PPC
|
||||||
ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_ppc(c, high_bit_depth);
|
||||||
#elif ARCH_RISCV
|
#elif ARCH_RISCV
|
||||||
ff_pixblockdsp_init_riscv(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_riscv(c, high_bit_depth);
|
||||||
#elif ARCH_X86
|
#elif ARCH_X86
|
||||||
ff_pixblockdsp_init_x86(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_x86(c, high_bit_depth);
|
||||||
#elif ARCH_MIPS
|
#elif ARCH_MIPS
|
||||||
ff_pixblockdsp_init_mips(c, avctx, high_bit_depth);
|
ff_pixblockdsp_init_mips(c, high_bit_depth);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -42,17 +42,17 @@ typedef struct PixblockDSPContext {
|
|||||||
} PixblockDSPContext;
|
} PixblockDSPContext;
|
||||||
|
|
||||||
void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx);
|
void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx);
|
||||||
void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_aarch64(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_arm(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_ppc(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
|
void ff_pixblockdsp_init_mips(PixblockDSPContext *c,
|
||||||
unsigned high_bit_depth);
|
unsigned high_bit_depth);
|
||||||
|
|
||||||
#endif /* AVCODEC_PIXBLOCKDSP_H */
|
#endif /* AVCODEC_PIXBLOCKDSP_H */
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "libavutil/ppc/cpu.h"
|
#include "libavutil/ppc/cpu.h"
|
||||||
#include "libavutil/ppc/util_altivec.h"
|
#include "libavutil/ppc/util_altivec.h"
|
||||||
|
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#include "libavcodec/pixblockdsp.h"
|
#include "libavcodec/pixblockdsp.h"
|
||||||
|
|
||||||
#if HAVE_ALTIVEC
|
#if HAVE_ALTIVEC
|
||||||
@ -263,7 +262,6 @@ static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1,
|
|||||||
#endif /* HAVE_VSX */
|
#endif /* HAVE_VSX */
|
||||||
|
|
||||||
av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c,
|
av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c,
|
||||||
AVCodecContext *avctx,
|
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
#if HAVE_ALTIVEC
|
#if HAVE_ALTIVEC
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "libavutil/attributes.h"
|
#include "libavutil/attributes.h"
|
||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
#include "libavutil/riscv/cpu.h"
|
#include "libavutil/riscv/cpu.h"
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#include "libavcodec/pixblockdsp.h"
|
#include "libavcodec/pixblockdsp.h"
|
||||||
|
|
||||||
void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels,
|
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,
|
|||||||
const uint8_t *s2, ptrdiff_t stride);
|
const uint8_t *s2, ptrdiff_t stride);
|
||||||
|
|
||||||
av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
|
av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
|
||||||
AVCodecContext *avctx,
|
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
#if HAVE_RV
|
#if HAVE_RV
|
||||||
|
@ -28,7 +28,6 @@ void ff_diff_pixels_sse2(int16_t *block, const uint8_t *s1, const uint8_t *s2,
|
|||||||
ptrdiff_t stride);
|
ptrdiff_t stride);
|
||||||
|
|
||||||
av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
|
av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
|
||||||
AVCodecContext *avctx,
|
|
||||||
unsigned high_bit_depth)
|
unsigned high_bit_depth)
|
||||||
{
|
{
|
||||||
int cpu_flags = av_get_cpu_flags();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
|
Reference in New Issue
Block a user