mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-29 07:06:59 +08:00
Remove any pretense for big endian support
I wouldn't have to care, but fuck big endian.
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "options/options.h"
|
||||
#include "options/m_config.h"
|
||||
#include "osdep/endian.h"
|
||||
#include "common/msg.h"
|
||||
#include "common/common.h"
|
||||
#include "common/global.h"
|
||||
@@ -734,11 +733,7 @@ bool ao_need_conversion(struct ao_convert_fmt *fmt)
|
||||
}
|
||||
|
||||
// The LSB is always ignored.
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define SHIFT24(x) ((3-(x))*8)
|
||||
#else
|
||||
#define SHIFT24(x) (((x)+1)*8)
|
||||
#endif
|
||||
|
||||
static void convert_plane(int type, void *data, int num_samples)
|
||||
{
|
||||
|
||||
+1
-4
@@ -39,7 +39,6 @@
|
||||
#include "options/m_config.h"
|
||||
#include "options/m_option.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/endian.h"
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
@@ -262,9 +261,7 @@ static const struct alsa_fmt mp_alsa_formats[] = {
|
||||
{AF_FORMAT_S16, SND_PCM_FORMAT_S16},
|
||||
{AF_FORMAT_S32, SND_PCM_FORMAT_S32},
|
||||
{AF_FORMAT_S32, SND_PCM_FORMAT_S24, .bits = 32, .pad_msb = 8},
|
||||
{AF_FORMAT_S32,
|
||||
MP_SELECT_LE_BE(SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_S24_3BE),
|
||||
.bits = 24, .pad_msb = 0},
|
||||
{AF_FORMAT_S32, SND_PCM_FORMAT_S24_3LE, .bits = 24, .pad_msb = 0},
|
||||
{AF_FORMAT_FLOAT, SND_PCM_FORMAT_FLOAT},
|
||||
{AF_FORMAT_DOUBLE, SND_PCM_FORMAT_FLOAT64},
|
||||
{0},
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "audio/out/ao_coreaudio_utils.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "osdep/endian.h"
|
||||
#include "osdep/semaphore.h"
|
||||
#include "audio/format.h"
|
||||
|
||||
@@ -180,9 +179,6 @@ static void ca_fill_asbd_raw(AudioStreamBasicDescription *asbd, int mp_format,
|
||||
asbd->mFormatFlags |= kAudioFormatFlagIsSignedInteger;
|
||||
}
|
||||
|
||||
if (BYTE_ORDER == BIG_ENDIAN)
|
||||
asbd->mFormatFlags |= kAudioFormatFlagIsBigEndian;
|
||||
|
||||
asbd->mFramesPerPacket = 1;
|
||||
asbd->mBytesPerPacket = asbd->mBytesPerFrame =
|
||||
asbd->mFramesPerPacket * channels_per_buffer *
|
||||
|
||||
+2
-3
@@ -40,7 +40,6 @@
|
||||
#include "common/common.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "osdep/endian.h"
|
||||
|
||||
#include <sys/soundcard.h>
|
||||
|
||||
@@ -95,11 +94,11 @@ static const struct mp_chmap oss_layouts[MP_NUM_CHANNELS + 1] = {
|
||||
};
|
||||
|
||||
#if !defined(AFMT_S16_NE) && defined(AFMT_S16_LE) && defined(AFMT_S16_BE)
|
||||
#define AFMT_S16_NE MP_SELECT_LE_BE(AFMT_S16_LE, AFMT_S16_BE)
|
||||
#define AFMT_S16_NE AFMT_S16_LE
|
||||
#endif
|
||||
|
||||
#if !defined(AFMT_S32_NE) && defined(AFMT_S32_LE) && defined(AFMT_S32_BE)
|
||||
#define AFMT_S32_NE AFMT_S32MP_SELECT_LE_BE(AFMT_S32_LE, AFMT_S32_BE)
|
||||
#define AFMT_S32_NE AFMT_S32_LE
|
||||
#endif
|
||||
|
||||
static const int format_table[][2] = {
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/endian.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
// for GetFileType to detect pipes
|
||||
@@ -119,14 +118,6 @@ static int init(struct ao *ao)
|
||||
|
||||
if (priv->waveheader) {
|
||||
// WAV files must have one of the following formats
|
||||
|
||||
// And they don't work in big endian; fixing it would be simple, but
|
||||
// nobody cares.
|
||||
if (BYTE_ORDER == BIG_ENDIAN) {
|
||||
MP_FATAL(ao, "Not supported on big endian.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (ao->format) {
|
||||
case AF_FORMAT_U8:
|
||||
case AF_FORMAT_S16:
|
||||
|
||||
+1
-3
@@ -38,8 +38,6 @@
|
||||
#include "video/fmt-conversion.h"
|
||||
#include "video/img_format.h"
|
||||
|
||||
#include "osdep/endian.h"
|
||||
|
||||
struct demux_rawaudio_opts {
|
||||
struct m_channels channels;
|
||||
int samplerate;
|
||||
@@ -49,7 +47,7 @@ struct demux_rawaudio_opts {
|
||||
// Ad-hoc schema to systematically encode the format as int
|
||||
#define PCM(sign, is_float, bits, is_be) \
|
||||
((sign) | ((is_float) << 1) | ((is_be) << 2) | ((bits) << 3))
|
||||
#define NE (BYTE_ORDER == BIG_ENDIAN)
|
||||
#define NE 0
|
||||
|
||||
#define OPT_BASE_STRUCT struct demux_rawaudio_opts
|
||||
const struct m_sub_options demux_rawaudio_conf = {
|
||||
|
||||
@@ -217,11 +217,9 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
|
||||
}
|
||||
} else {
|
||||
// filename
|
||||
void *tmp = talloc_new(NULL);
|
||||
bstr file = p.arg;
|
||||
char *file0 = bstrdup0(tmp, p.arg);
|
||||
char *file0 = bstrdup0(NULL, p.arg);
|
||||
process_non_option(files, file0);
|
||||
talloc_free(tmp);
|
||||
talloc_free(file0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#ifndef MP_ENDIAN_H_
|
||||
#define MP_ENDIAN_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !defined(BYTE_ORDER)
|
||||
|
||||
#if defined(__BYTE_ORDER)
|
||||
#define BYTE_ORDER __BYTE_ORDER
|
||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#define BIG_ENDIAN __BIG_ENDIAN
|
||||
#elif defined(__DARWIN_BYTE_ORDER)
|
||||
#define BYTE_ORDER __DARWIN_BYTE_ORDER
|
||||
#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
|
||||
#define BIG_ENDIAN __DARWIN_BIG_ENDIAN
|
||||
#else
|
||||
#include <libavutil/bswap.h>
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
#define BYTE_ORDER 1234
|
||||
#define LITTLE_ENDIAN 4321
|
||||
#define BIG_ENDIAN 1234
|
||||
#else
|
||||
#define BYTE_ORDER 1234
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !defined(BYTE_ORDER) */
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define MP_SELECT_LE_BE(LE, BE) BE
|
||||
#else
|
||||
#define MP_SELECT_LE_BE(LE, BE) LE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -92,7 +92,7 @@ char *mp_imgfmt_to_name_buf(char *buf, size_t buf_size, int fmt)
|
||||
name = "unknown";
|
||||
snprintf(buf, buf_size, "%s", name);
|
||||
int len = strlen(buf);
|
||||
if (len > 2 && buf[len - 2] == MP_SELECT_LE_BE('l', 'b') && buf[len - 1] == 'e')
|
||||
if (len > 2 && buf[len - 2] == 'l' && buf[len - 1] == 'e')
|
||||
buf[len - 2] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
+3
-10
@@ -20,16 +20,9 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "osdep/endian.h"
|
||||
#include "misc/bstr.h"
|
||||
#include "video/csputils.h"
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define MP_SELECT_LE_BE(LE, BE) BE
|
||||
#else
|
||||
#define MP_SELECT_LE_BE(LE, BE) LE
|
||||
#endif
|
||||
|
||||
#define MP_MAX_PLANES 4
|
||||
|
||||
// All pixels start in byte boundaries
|
||||
@@ -56,7 +49,7 @@
|
||||
// set if in big endian, or endian independent
|
||||
#define MP_IMGFLAG_BE 0x4000
|
||||
// set if in native (host) endian, or endian independent
|
||||
#define MP_IMGFLAG_NE MP_SELECT_LE_BE(MP_IMGFLAG_LE, MP_IMGFLAG_BE)
|
||||
#define MP_IMGFLAG_NE MP_IMGFLAG_LE
|
||||
// Carries a palette in plane[1] (see IMGFMT_PAL8 for format of the palette).
|
||||
// Note that some non-paletted formats have this flag set, because FFmpeg
|
||||
// mysteriously expects some formats to carry a palette plane for no apparent
|
||||
@@ -216,8 +209,8 @@ enum mp_imgfmt {
|
||||
// normally byte-accessed formats:
|
||||
// IMGFMT_RGB32 = r | (g << 8) | (b << 16) | (a << 24)
|
||||
// IMGFMT_BGR32 = b | (g << 8) | (r << 16) | (a << 24)
|
||||
IMGFMT_RGB32 = MP_SELECT_LE_BE(IMGFMT_RGBA, IMGFMT_ABGR),
|
||||
IMGFMT_BGR32 = MP_SELECT_LE_BE(IMGFMT_BGRA, IMGFMT_ARGB),
|
||||
IMGFMT_RGB32 = IMGFMT_RGBA,
|
||||
IMGFMT_BGR32 = IMGFMT_BGRA,
|
||||
};
|
||||
|
||||
static inline bool IMGFMT_IS_RGB(int fmt)
|
||||
|
||||
@@ -56,16 +56,6 @@ const struct formatmap_entry formats[] = {
|
||||
{SDL_PIXELFORMAT_IYUV, IMGFMT_420P, 0},
|
||||
{SDL_PIXELFORMAT_UYVY, IMGFMT_UYVY, 0},
|
||||
//{SDL_PIXELFORMAT_YVYU, IMGFMT_YVYU, 0},
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
{SDL_PIXELFORMAT_RGB888, IMGFMT_0RGB, 0}, // RGB888 means XRGB8888
|
||||
{SDL_PIXELFORMAT_RGBX8888, IMGFMT_RGB0, 0}, // has no alpha -> bad for OSD
|
||||
{SDL_PIXELFORMAT_BGR888, IMGFMT_0BGR, 0}, // BGR888 means XBGR8888
|
||||
{SDL_PIXELFORMAT_BGRX8888, IMGFMT_BGR0, 0}, // has no alpha -> bad for OSD
|
||||
{SDL_PIXELFORMAT_ARGB8888, IMGFMT_ARGB, 1}, // matches SUBBITMAP_RGBA
|
||||
{SDL_PIXELFORMAT_RGBA8888, IMGFMT_RGBA, 1},
|
||||
{SDL_PIXELFORMAT_ABGR8888, IMGFMT_ABGR, 1},
|
||||
{SDL_PIXELFORMAT_BGRA8888, IMGFMT_BGRA, 1},
|
||||
#else
|
||||
{SDL_PIXELFORMAT_RGB888, IMGFMT_BGR0, 0}, // RGB888 means XRGB8888
|
||||
{SDL_PIXELFORMAT_RGBX8888, IMGFMT_0BGR, 0}, // has no alpha -> bad for OSD
|
||||
{SDL_PIXELFORMAT_BGR888, IMGFMT_RGB0, 0}, // BGR888 means XBGR8888
|
||||
@@ -74,7 +64,6 @@ const struct formatmap_entry formats[] = {
|
||||
{SDL_PIXELFORMAT_RGBA8888, IMGFMT_ABGR, 1},
|
||||
{SDL_PIXELFORMAT_ABGR8888, IMGFMT_RGBA, 1},
|
||||
{SDL_PIXELFORMAT_BGRA8888, IMGFMT_ARGB, 1},
|
||||
#endif
|
||||
{SDL_PIXELFORMAT_RGB24, IMGFMT_RGB24, 0},
|
||||
{SDL_PIXELFORMAT_BGR24, IMGFMT_BGR24, 0},
|
||||
{SDL_PIXELFORMAT_RGB565, IMGFMT_RGB565, 0},
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "fmt-conversion.h"
|
||||
#include "csputils.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/endian.h"
|
||||
|
||||
//global sws_flags from the command line
|
||||
struct sws_opts {
|
||||
@@ -294,13 +293,11 @@ int mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src,
|
||||
}
|
||||
|
||||
static const int endian_swaps[][2] = {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#if defined(AV_PIX_FMT_YA16) && defined(AV_PIX_FMT_RGBA64)
|
||||
{AV_PIX_FMT_YA16BE, AV_PIX_FMT_YA16LE},
|
||||
{AV_PIX_FMT_RGBA64BE, AV_PIX_FMT_RGBA64LE},
|
||||
{AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_GRAY16LE},
|
||||
{AV_PIX_FMT_RGB48BE, AV_PIX_FMT_RGB48LE},
|
||||
#endif
|
||||
#endif
|
||||
{AV_PIX_FMT_NONE, AV_PIX_FMT_NONE}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user