mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-01 20:18:15 +01:00
The ffmpeg submodule held prebuilt libraries for every platform next to the sources (about 1.5 GB checked out), and nothing uses those any more. Only the needed sources are copied in, from the submodule's commit, along with every header and template they include. The path is new, so checking out commits on either side of this works. It's also cut down to what PPSSPP uses: the H.264, AAC, MP3, ATRAC3 and ATRAC3+ decoders, the H.264 parser, the demuxers as before, and the FFV1 encoder, AVI muxer and file protocol for AVI dumping. config.h takes its CONFIG_ values from FFmpeg 3.0.2's own configure run with just those enabled. The raw H.264 demuxer stays even though nothing opens raw H.264: probing PSMF data uses it to identify the video stream's codec, which otherwise comes out as none. On top of that: - The files nothing links (configure would build them, but they're never pulled out of the static library, going by the GCC link map) are left out: mostly libavutil's crypto and hashing and the alternative DCT/IDCT/FFT versions. - libswresample isn't built, now that nothing uses it. - The H.264 decoder only does 8-bit video, which is all the PSP has. The SPS parser rejects any other bit depth, and the DSP files no longer build their 9- to 16-bit variants, which the linker kept because the init functions pick one by bit depth at run time. That's 160 files to compile instead of 277, and 391 of FFmpeg's vendored, about 5.8 MB. The README in ext/ffmpeg has what was done, the PPSSPP patches in the copy, how to add a component, and the tradeoffs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
173 lines
5.2 KiB
C
173 lines
5.2 KiB
C
/*
|
|
* 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
|
|
*/
|
|
|
|
// This header should only be used to simplify code where
|
|
// threading is optional, not as a generic threading abstraction.
|
|
|
|
#ifndef AVUTIL_THREAD_H
|
|
#define AVUTIL_THREAD_H
|
|
|
|
#include "config.h"
|
|
|
|
#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
|
|
|
|
#define USE_ATOMICS 0
|
|
|
|
#if HAVE_PTHREADS
|
|
#include <pthread.h>
|
|
|
|
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
|
|
|
#include "log.h"
|
|
|
|
#define ASSERT_PTHREAD_NORET(func, ...) do { \
|
|
int ret = func(__VA_ARGS__); \
|
|
if (ret) { \
|
|
av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \
|
|
" failed with error: %s\n", av_err2str(AVERROR(ret))); \
|
|
abort(); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ASSERT_PTHREAD(func, ...) do { \
|
|
ASSERT_PTHREAD_NORET(func, __VA_ARGS__); \
|
|
return 0; \
|
|
} while (0)
|
|
|
|
static inline int strict_pthread_join(pthread_t thread, void **value_ptr)
|
|
{
|
|
ASSERT_PTHREAD(pthread_join, thread, value_ptr);
|
|
}
|
|
|
|
static inline int strict_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
|
{
|
|
if (attr) {
|
|
ASSERT_PTHREAD_NORET(pthread_mutex_init, mutex, attr);
|
|
} else {
|
|
pthread_mutexattr_t local_attr;
|
|
ASSERT_PTHREAD_NORET(pthread_mutexattr_init, &local_attr);
|
|
ASSERT_PTHREAD_NORET(pthread_mutexattr_settype, &local_attr, PTHREAD_MUTEX_ERRORCHECK);
|
|
ASSERT_PTHREAD_NORET(pthread_mutex_init, mutex, &local_attr);
|
|
ASSERT_PTHREAD_NORET(pthread_mutexattr_destroy, &local_attr);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static inline int strict_pthread_mutex_destroy(pthread_mutex_t *mutex)
|
|
{
|
|
ASSERT_PTHREAD(pthread_mutex_destroy, mutex);
|
|
}
|
|
|
|
static inline int strict_pthread_mutex_lock(pthread_mutex_t *mutex)
|
|
{
|
|
ASSERT_PTHREAD(pthread_mutex_lock, mutex);
|
|
}
|
|
|
|
static inline int strict_pthread_mutex_unlock(pthread_mutex_t *mutex)
|
|
{
|
|
ASSERT_PTHREAD(pthread_mutex_unlock, mutex);
|
|
}
|
|
|
|
static inline int strict_pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
|
|
{
|
|
ASSERT_PTHREAD(pthread_cond_init, cond, attr);
|
|
}
|
|
|
|
static inline int strict_pthread_cond_destroy(pthread_cond_t *cond)
|
|
{
|
|
ASSERT_PTHREAD(pthread_cond_destroy, cond);
|
|
}
|
|
|
|
static inline int strict_pthread_cond_signal(pthread_cond_t *cond)
|
|
{
|
|
ASSERT_PTHREAD(pthread_cond_signal, cond);
|
|
}
|
|
|
|
static inline int strict_pthread_cond_broadcast(pthread_cond_t *cond)
|
|
{
|
|
ASSERT_PTHREAD(pthread_cond_broadcast, cond);
|
|
}
|
|
|
|
static inline int strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|
{
|
|
ASSERT_PTHREAD(pthread_cond_wait, cond, mutex);
|
|
}
|
|
|
|
static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
|
|
{
|
|
ASSERT_PTHREAD(pthread_once, once_control, init_routine);
|
|
}
|
|
|
|
#define pthread_join strict_pthread_join
|
|
#define pthread_mutex_init strict_pthread_mutex_init
|
|
#define pthread_mutex_destroy strict_pthread_mutex_destroy
|
|
#define pthread_mutex_lock strict_pthread_mutex_lock
|
|
#define pthread_mutex_unlock strict_pthread_mutex_unlock
|
|
#define pthread_cond_init strict_pthread_cond_init
|
|
#define pthread_cond_destroy strict_pthread_cond_destroy
|
|
#define pthread_cond_signal strict_pthread_cond_signal
|
|
#define pthread_cond_broadcast strict_pthread_cond_broadcast
|
|
#define pthread_cond_wait strict_pthread_cond_wait
|
|
#define pthread_once strict_pthread_once
|
|
#endif
|
|
|
|
#elif HAVE_OS2THREADS
|
|
#include "compat/os2threads.h"
|
|
#else
|
|
#include "compat/w32pthreads.h"
|
|
#endif
|
|
|
|
#define AVMutex pthread_mutex_t
|
|
|
|
#define ff_mutex_init pthread_mutex_init
|
|
#define ff_mutex_lock pthread_mutex_lock
|
|
#define ff_mutex_unlock pthread_mutex_unlock
|
|
#define ff_mutex_destroy pthread_mutex_destroy
|
|
|
|
#define AVOnce pthread_once_t
|
|
#define AV_ONCE_INIT PTHREAD_ONCE_INIT
|
|
|
|
#define ff_thread_once(control, routine) pthread_once(control, routine)
|
|
|
|
#else
|
|
|
|
#define USE_ATOMICS 1
|
|
|
|
#define AVMutex char
|
|
|
|
#define ff_mutex_init(mutex, attr) (0)
|
|
#define ff_mutex_lock(mutex) (0)
|
|
#define ff_mutex_unlock(mutex) (0)
|
|
#define ff_mutex_destroy(mutex) (0)
|
|
|
|
#define AVOnce char
|
|
#define AV_ONCE_INIT 0
|
|
|
|
static inline int ff_thread_once(char *control, void (*routine)(void))
|
|
{
|
|
if (!*control) {
|
|
routine();
|
|
*control = 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* AVUTIL_THREAD_H */
|