You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/asvenc,dvenc: Optimize unaligned checks away if possible
For certain arches (AARCH64, x86, generic) get_pixels and get_pixels_unaligned always coincide for 8 bit input. In these cases it is possible to avoid checks for unaligned input in asvenc, dvenc. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -301,9 +301,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((uintptr_t)pict->data[0] & 7 || pict->linesize[0] & 7 ||
|
if (!PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED &&
|
||||||
(uintptr_t)pict->data[1] & 7 || pict->linesize[1] & 7 ||
|
((uintptr_t)pict->data[0] & 7 || pict->linesize[0] & 7 ||
|
||||||
(uintptr_t)pict->data[2] & 7 || pict->linesize[2] & 7)
|
(uintptr_t)pict->data[1] & 7 || pict->linesize[1] & 7 ||
|
||||||
|
(uintptr_t)pict->data[2] & 7 || pict->linesize[2] & 7))
|
||||||
a->get_pixels = a->pdsp.get_pixels_unaligned;
|
a->get_pixels = a->pdsp.get_pixels_unaligned;
|
||||||
else
|
else
|
||||||
a->get_pixels = a->pdsp.get_pixels;
|
a->get_pixels = a->pdsp.get_pixels;
|
||||||
|
@ -1200,9 +1200,10 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
|
|||||||
DVEncContext *s = c->priv_data;
|
DVEncContext *s = c->priv_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((uintptr_t)frame->data[0] & 7 || frame->linesize[0] & 7 ||
|
if (!PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED &&
|
||||||
(uintptr_t)frame->data[1] & 7 || frame->linesize[1] & 7 ||
|
((uintptr_t)frame->data[0] & 7 || frame->linesize[0] & 7 ||
|
||||||
(uintptr_t)frame->data[2] & 7 || frame->linesize[2] & 7)
|
(uintptr_t)frame->data[1] & 7 || frame->linesize[1] & 7 ||
|
||||||
|
(uintptr_t)frame->data[2] & 7 || frame->linesize[2] & 7))
|
||||||
s->get_pixels = s->pdsp.get_pixels_unaligned;
|
s->get_pixels = s->pdsp.get_pixels_unaligned;
|
||||||
else
|
else
|
||||||
s->get_pixels = s->pdsp.get_pixels;
|
s->get_pixels = s->pdsp.get_pixels;
|
||||||
|
@ -22,9 +22,14 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED \
|
||||||
|
!(ARCH_ARM || ARCH_MIPS || ARCH_PPC || ARCH_RISCV)
|
||||||
|
|
||||||
typedef struct PixblockDSPContext {
|
typedef struct PixblockDSPContext {
|
||||||
void (*get_pixels)(int16_t *restrict block /* align 16 */,
|
void (*get_pixels)(int16_t *restrict block /* align 16 */,
|
||||||
const uint8_t *pixels /* align 8 for <= 8 bit, 16 otherwise */,
|
/* align 16 for > 8 bits; align 8 for <= 8 bits
|
||||||
|
* (or 1 if PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED is set) */
|
||||||
|
const uint8_t *pixels,
|
||||||
ptrdiff_t stride);
|
ptrdiff_t stride);
|
||||||
void (*get_pixels_unaligned)(int16_t *restrict block /* align 16 */,
|
void (*get_pixels_unaligned)(int16_t *restrict block /* align 16 */,
|
||||||
const uint8_t *pixels,
|
const uint8_t *pixels,
|
||||||
|
Reference in New Issue
Block a user