mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 07:47:32 +09:00
MoonchildProductions/UXP#2897: Fix ffvpx build on loongarch64
This commit is contained in:
parent
8dde509b85
commit
d7963fcc9e
18 changed files with 3559 additions and 23 deletions
61
media/ffvpx/libavutil/loongarch/cpu.c
Normal file
61
media/ffvpx/libavutil/loongarch/cpu.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Loongson Technology Corporation Limited
|
||||
* Contributed by Shiyou Yin <yinshiyou-hf@loongson.cn>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cpu.h"
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#define LA_HWCAP_LSX (1<<4)
|
||||
#define LA_HWCAP_LASX (1<<5)
|
||||
static int cpu_flags_getauxval(void)
|
||||
{
|
||||
int flags = 0;
|
||||
int flag = (int)getauxval(AT_HWCAP);
|
||||
|
||||
if (flag & LA_HWCAP_LSX)
|
||||
flags |= AV_CPU_FLAG_LSX;
|
||||
if (flag & LA_HWCAP_LASX)
|
||||
flags |= AV_CPU_FLAG_LASX;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
int ff_get_cpu_flags_loongarch(void)
|
||||
{
|
||||
#if defined __linux__
|
||||
return cpu_flags_getauxval();
|
||||
#else
|
||||
/* Assume no SIMD ASE supported */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t ff_get_cpu_max_align_loongarch(void)
|
||||
{
|
||||
int flags = av_get_cpu_flags();
|
||||
|
||||
if (flags & AV_CPU_FLAG_LASX)
|
||||
return 32;
|
||||
if (flags & AV_CPU_FLAG_LSX)
|
||||
return 16;
|
||||
|
||||
return 8;
|
||||
}
|
||||
31
media/ffvpx/libavutil/loongarch/cpu.h
Normal file
31
media/ffvpx/libavutil/loongarch/cpu.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Loongson Technology Corporation Limited
|
||||
* Contributed by Shiyou Yin <yinshiyou-hf@loongson.cn>
|
||||
*
|
||||
* 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 AVUTIL_LOONGARCH_CPU_H
|
||||
#define AVUTIL_LOONGARCH_CPU_H
|
||||
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/cpu_internal.h"
|
||||
|
||||
#define have_lsx(flags) CPUEXT(flags, LSX)
|
||||
#define have_lasx(flags) CPUEXT(flags, LASX)
|
||||
|
||||
#endif /* AVUTIL_LOONGARCH_CPU_H */
|
||||
1948
media/ffvpx/libavutil/loongarch/loongson_intrinsics.h
Normal file
1948
media/ffvpx/libavutil/loongarch/loongson_intrinsics.h
Normal file
File diff suppressed because it is too large
Load diff
12
media/ffvpx/libavutil/loongarch/moz.build
Normal file
12
media/ffvpx/libavutil/loongarch/moz.build
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
SOURCES += [
|
||||
'cpu.c',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'mozavutil'
|
||||
|
||||
include('/media/ffvpx/ffvpxcommon.mozbuild')
|
||||
48
media/ffvpx/libavutil/loongarch/timer.h
Normal file
48
media/ffvpx/libavutil/loongarch/timer.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Loongson Technology Corporation Limited
|
||||
* Contributed by Hecai Yuan <yuanhecai@loongson.cn>
|
||||
*
|
||||
* 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 AVUTIL_LOONGARCH_TIMER_H
|
||||
#define AVUTIL_LOONGARCH_TIMER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_INLINE_ASM
|
||||
|
||||
#define AV_READ_TIME read_time
|
||||
|
||||
static inline uint64_t read_time(void)
|
||||
{
|
||||
|
||||
#if ARCH_LOONGARCH64
|
||||
uint64_t a, id;
|
||||
__asm__ volatile ( "rdtime.d %0, %1" : "=r"(a), "=r"(id) :: );
|
||||
return a;
|
||||
#else
|
||||
uint32_t a, id;
|
||||
__asm__ volatile ( "rdtimel.w %0, %1" : "=r"(a), "=r"(id) :: );
|
||||
return (uint64_t)a;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_INLINE_ASM */
|
||||
|
||||
#endif /* AVUTIL_LOONGARCH_TIMER_H */
|
||||
|
|
@ -6,7 +6,21 @@
|
|||
# Due to duplicate file names, we compile libavutil/x86 in its own
|
||||
# moz.build file.
|
||||
if CONFIG['FFVPX_ASFLAGS']:
|
||||
<<<<<<< HEAD
|
||||
DIRS += ['x86']
|
||||
=======
|
||||
if CONFIG['CPU_ARCH'].startswith('x86'):
|
||||
DIRS += ['x86']
|
||||
elif CONFIG['CPU_ARCH'].startswith('arm'):
|
||||
DIRS += ['arm']
|
||||
|
||||
if CONFIG['CPU_ARCH'] == 'aarch64':
|
||||
DIRS += ['aarch64']
|
||||
elif CONFIG['CPU_ARCH'].startswith('ppc'):
|
||||
DIRS += ['ppc']
|
||||
elif CONFIG['CPU_ARCH'].startswith('loongarch64'):
|
||||
DIRS += ['loongarch']
|
||||
>>>>>>> fb438829b5 (MoonchildProductions/UXP#2897: Fix ffvpx build on loongarch64)
|
||||
|
||||
SharedLibrary('mozavutil')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2023 Loongson Technology Corporation Limited
|
||||
* Contributed by Hecai Yuan <yuanhecai@loongson.cn>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
|
|
@ -18,30 +19,17 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* high precision timer, useful to profile code
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TIMER_H
|
||||
#define AVUTIL_TIMER_H
|
||||
#ifndef AVUTIL_LOONGARCH_TIMER_H
|
||||
#define AVUTIL_LOONGARCH_TIMER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
#if CONFIG_LINUX_PERF
|
||||
# ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
# endif
|
||||
# include <unistd.h> // read(3)
|
||||
# include <sys/ioctl.h>
|
||||
# include <asm/unistd.h>
|
||||
# include <linux/perf_event.h>
|
||||
#endif
|
||||
#if HAVE_INLINE_ASM
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#define AV_READ_TIME read_time
|
||||
|
||||
<<<<<<< HEAD
|
||||
#if HAVE_MACH_MACH_TIME_H
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
|
@ -133,9 +121,22 @@
|
|||
#define STOP_TIMER(id) \
|
||||
tend = AV_READ_TIME(); \
|
||||
TIMER_REPORT(id, tend - tstart)
|
||||
#else
|
||||
#define START_TIMER
|
||||
#define STOP_TIMER(id) { }
|
||||
#endif
|
||||
=======
|
||||
static inline uint64_t read_time(void)
|
||||
{
|
||||
|
||||
#endif /* AVUTIL_TIMER_H */
|
||||
#if ARCH_LOONGARCH64
|
||||
uint64_t a, id;
|
||||
__asm__ volatile ( "rdtime.d %0, %1" : "=r"(a), "=r"(id) :: );
|
||||
return a;
|
||||
>>>>>>> fb438829b5 (MoonchildProductions/UXP#2897: Fix ffvpx build on loongarch64)
|
||||
#else
|
||||
uint32_t a, id;
|
||||
__asm__ volatile ( "rdtimel.w %0, %1" : "=r"(a), "=r"(id) :: );
|
||||
return (uint64_t)a;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_INLINE_ASM */
|
||||
|
||||
#endif /* AVUTIL_LOONGARCH_TIMER_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue