1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Files
ffmpeg/libavcodec/bitpacked_dec_init.h
Devin Heitmueller 508b82c605 avcodec/bitpacked: add x86 SIMD unpacking
Add runtime-dispatched SSSE3 and AVX2 implementations for packed
10-bit YUV 4:2:2. The SSSE3 loop follows the negative-width output-offset
pattern used by v210. The AVX2 loop processes 16 pixels at a time and has
an internal eight-pixel tail.

Both implementations use exact-width input loads and therefore do not
rely on padded input or legal overread. They passed 300 consecutive checkasm
seeds.

Benchmark command:
./tests/checkasm/checkasm --bench --test=bitpackeddec \
    --duration=1000000 51000

Intel Xeon E-2356G, GCC 8.5, NASM 2.15.03:
bitpacked_unpack_yuv422p10_c:      13516.7
bitpacked_unpack_yuv422p10_ssse3:   3415.8 (3.96x)
bitpacked_unpack_yuv422p10_avx2:    2183.1 (6.19x)
2026-10-15 18:46:02 +00:00

57 lines
1.8 KiB
C

/*
* Bitpacked decoder DSP init
* Copyright (c) 2017 Savoir-faire Linux, Inc
* Copyright (c) 2026 Devin Heitmueller <dheitmueller@ltnglobal.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_BITPACKED_DEC_INIT_H
#define AVCODEC_BITPACKED_DEC_INIT_H
#include <stdint.h>
#include "config.h"
#include "libavutil/attributes.h"
#include "bitpacked_dec.h"
static void bitpacked_unpack_yuv422p10_c(const uint8_t *src,
uint16_t *y, uint16_t *u, uint16_t *v,
int width)
{
for (int i = 0; i < width; i += 2) {
*u++ = (src[0] << 2) | (src[1] >> 6);
*v++ = ((src[2] << 6) | (src[3] >> 2)) & 0x3ff;
*y++ = ((src[1] << 4) | (src[2] >> 4)) & 0x3ff;
*y++ = ((src[3] << 8) | src[4]) & 0x3ff;
src += 5;
}
}
av_unused static av_cold void ff_bitpackeddec_init(struct BitpackedContext *s)
{
s->unpack_yuv422p10 = bitpacked_unpack_yuv422p10_c;
#if ARCH_AARCH64
ff_bitpacked_init_aarch64(s);
#elif ARCH_X86 && HAVE_X86ASM
ff_bitpacked_init_x86(s);
#endif
}
#endif /* AVCODEC_BITPACKED_DEC_INIT_H */