Skip to content

Commit

Permalink
Merge branch 'mpv-player:master' into plex-htpc-hdr-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
mitzsch authored Oct 23, 2023
2 parents b4d8a3a + 1805681 commit 0adbe08
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 103 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ jobs:
matrix:
cc:
- "clang"
cxx:
- "clang++"
os:
- "macos-12"
- "macos-13"
Expand All @@ -104,6 +106,7 @@ jobs:
./ci/build-macos.sh
env:
CC: "${{ matrix.cc }}"
CXX: "${{ matrix.cxx }}"
TRAVIS_OS_NAME: "${{ matrix.os }}"

- name: Print meson log
Expand All @@ -126,12 +129,19 @@ jobs:
container:
image: "registry.opensuse.org/home/mia/images/images/mpv-ci:stable-deps"
env:
CC: "${{ matrix.cc }}"
CC: "${{ matrix.config.cc }}"
CXX: "${{ matrix.config.cxx }}"
strategy:
matrix:
cc:
- "gcc"
- "clang"
config:
- {
cc: "gcc",
cxx: "g++",
}
- {
cc: "clang",
cxx: "clang++",
}
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -179,6 +189,7 @@ jobs:
pkg update
# Requested in ci/build-freebsd.sh
pkg install -y \
git \
cmake \
evdev-proto \
ffmpeg \
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/subprojects
/subprojects/*
!/subprojects/libplacebo.wrap
2 changes: 1 addition & 1 deletion ci/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" \
meson setup build \
-Dprefix="${MPV_INSTALL_PREFIX}" \
-D{libmpv,tests}=true \
-D{gl,iconv,lcms2,libplacebo,lua,jpeg,plain-gl,zlib}=enabled \
-D{gl,iconv,lcms2,lua,jpeg,plain-gl,zlib}=enabled \
-D{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl}=enabled

meson compile -C build -j4
Expand Down
2 changes: 1 addition & 1 deletion ci/build-mingw64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ meson setup $build --cross-file "$prefix_dir/crossfile" \
-Dc_args="-Wno-error=deprecated -Wno-error=deprecated-declarations" \
--buildtype debugoptimized \
-Dlibmpv=true -Dlua=luajit \
-D{shaderc,spirv-cross,d3d11,libplacebo}=enabled
-D{shaderc,spirv-cross,d3d11}=enabled

meson compile -C $build

Expand Down
24 changes: 21 additions & 3 deletions filters/f_hwtransfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ static bool select_format(struct priv *p, int input_fmt,
return false;
}

// If there is no capability to do uploads or conversions during uploads,
// assume that directly displaying the input format works. Maybe it does,
// maybe it doesn't but at this point, it's clear that we simply don't know
// and should assume it works, rather than blocking unnecessarily.
if (p->num_fmts == 0 && p->num_upload_fmts == 0) {
*out_hw_input_fmt = input_fmt;
*out_hw_output_fmt = input_fmt;
return true;
}

// First find the closest hw input fmt. Some hwdec APIs return crazy lists of
// "supported" formats, which then are not supported or crash (???), so
// the this is a good way to avoid problems.
Expand Down Expand Up @@ -281,8 +291,8 @@ static AVHWFramesConstraints *build_static_constraints(struct mp_hwdec_ctx *ctx)

int num_sw_formats;
for (num_sw_formats = 0;
ctx->supported_formats[num_sw_formats] != 0;
num_sw_formats++);
ctx->supported_formats && ctx->supported_formats[num_sw_formats] != 0;
num_sw_formats++);

cstr->valid_sw_formats =
av_malloc_array(num_sw_formats + 1,
Expand Down Expand Up @@ -523,7 +533,15 @@ static bool probe_formats(struct mp_filter *f, int hw_imgfmt, bool use_conversio
return false;
p->conversion_filter_name = ctx->conversion_filter_name;

return p->num_upload_fmts > 0;
/*
* In the case of needing to do hardware conversion vs uploading, we will
* still consider ourselves to be successful if we see no available upload
* formats for a conversion and there is no conversion filter. This means
* that we cannot do conversions at all, and should just assume we can pass
* through whatever format we are given.
*/
return p->num_upload_fmts > 0 ||
(use_conversion_filter && !p->conversion_filter_name);
}

struct mp_hwupload mp_hwupload_create(struct mp_filter *parent, int hw_imgfmt,
Expand Down
44 changes: 16 additions & 28 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ libavutil = dependency('libavutil', version: '>= 56.70.100')
libswresample = dependency('libswresample', version: '>= 3.9.100')
libswscale = dependency('libswscale', version: '>= 5.9.100')

libplacebo = dependency('libplacebo', version: '>=6.338.0', fallback: ['libplacebo', 'libplacebo'],
default_options: ['default_library=static', 'demos=false'])

libass = dependency('libass', version: '>= 0.12.2')

# the dependency order of libass -> ffmpeg is necessary due to
Expand All @@ -32,6 +35,7 @@ dependencies = [libass,
libavfilter,
libavformat,
libavutil,
libplacebo,
libswresample,
libswscale]

Expand All @@ -44,6 +48,7 @@ features = {
'avif-muxer': libavformat.version().version_compare('>= 59.24.100'),
'libass': true,
'threads': true,
'libplacebo': true,
}


Expand Down Expand Up @@ -234,6 +239,12 @@ sources = files(
'video/repack.c',
'video/sws_utils.c',

## libplacebo
'video/out/placebo/ra_pl.c',
'video/out/placebo/utils.c',
'video/out/vo_gpu_next.c',
'video/out/gpu_next/context.c',

## osdep
'osdep/io.c',
'osdep/semaphore_osx.c',
Expand Down Expand Up @@ -930,16 +941,6 @@ if features['jpeg']
dependencies += jpeg
endif

libplacebo = dependency('libplacebo', version: '>=6.292.0', required: get_option('libplacebo'))
features += {'libplacebo': libplacebo.found()}
if features['libplacebo']
dependencies += libplacebo
sources += files('video/out/placebo/ra_pl.c',
'video/out/placebo/utils.c',
'video/out/vo_gpu_next.c',
'video/out/gpu_next/context.c')
endif

sdl2_video = get_option('sdl2-video').require(
features['sdl2'],
error_message: 'sdl2 was not found!',
Expand Down Expand Up @@ -1257,7 +1258,7 @@ endif
# vulkan
vulkan_opt = get_option('vulkan').require(
libplacebo.get_variable('pl_has_vulkan', default_value: '0') == '1',
error_message: 'libplacebo could not be found!',
error_message: 'libplacebo compiled without vulkan support!',
)
vulkan = dependency('vulkan', version: '>= 1.1.70', required: vulkan_opt)
features += {'vulkan': vulkan.found()}
Expand Down Expand Up @@ -1330,9 +1331,8 @@ endif

vulkan_interop = get_option('vulkan-interop').require(
features['vulkan'] and vulkan.version().version_compare('>=1.3.238') and
features['libplacebo'] and
libavutil.version().version_compare('>=58.11.100'),
error_message: 'Vulkan Interop requires vulkan headers >= 1.3.238, libplacebo, and libavutil >= 58.11.100',
error_message: 'Vulkan Interop requires vulkan headers >= 1.3.238, and libavutil >= 58.11.100',
)
features += {'vulkan-interop': vulkan_interop.allowed()}
if vulkan_interop.allowed()
Expand Down Expand Up @@ -1426,14 +1426,9 @@ features += {'vaapi': vaapi.allowed()}
if features['vaapi']
dependencies += libva
sources += files('video/filter/vf_vavpp.c',
'video/vaapi.c')
endif

features += {'vaapi-egl': features['vaapi'] and features['egl'] and features['drm']}
features += {'vaapi-libplacebo': features['vaapi'] and libplacebo.found()}

if features['vaapi-egl'] or features['vaapi-libplacebo']
sources += files('video/out/hwdec/hwdec_vaapi.c')
'video/vaapi.c',
'video/out/hwdec/hwdec_vaapi.c',
'video/out/hwdec/dmabuf_interop_pl.c')
endif

dmabuf_interop_gl = features['egl'] and features['drm']
Expand All @@ -1442,12 +1437,6 @@ if features['dmabuf-interop-gl']
sources += files('video/out/hwdec/dmabuf_interop_gl.c')
endif

dmabuf_interop_pl = features['vaapi-libplacebo']
features += {'dmabuf-interop-pl': dmabuf_interop_pl}
if features['dmabuf-interop-pl']
sources += files('video/out/hwdec/dmabuf_interop_pl.c')
endif

vdpau_opt = get_option('vdpau').require(
features['x11'],
error_message: 'x11 was not found!',
Expand Down Expand Up @@ -1786,7 +1775,6 @@ if get_option('tests')
endif

summary({'d3d11': features['d3d11'],
'gpu-next': features['libplacebo'],
'javascript': features['javascript'],
'libmpv': get_option('libmpv'),
'lua': features['lua'],
Expand Down
1 change: 0 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ option('gl-dxinterop', type: 'feature', value: 'auto', description: 'OpenGL/Dire
option('gl-win32', type: 'feature', value: 'auto', description: 'OpenGL Win32 Backend')
option('gl-x11', type: 'feature', value: 'disabled', description: 'OpenGL X11/GLX (deprecated/legacy)')
option('jpeg', type: 'feature', value: 'auto', description: 'JPEG support')
option('libplacebo', type: 'feature', value: 'auto', description: 'libplacebo support')
option('rpi', type: 'feature', value: 'disabled', description: 'Raspberry Pi support')
option('sdl2-video', type: 'feature', value: 'auto', description: 'SDL2 video output')
option('shaderc', type: 'feature', value: 'auto', description: 'libshaderc SPIR-V compiler')
Expand Down
4 changes: 1 addition & 3 deletions options/m_config_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ struct m_group_data {
uint64_t ts; // timestamp of the data copy
};

static const union m_option_value default_value = {0};

static void add_sub_group(struct m_config_shadow *shadow, const char *name_prefix,
int parent_group_index, int parent_ptr,
const struct m_sub_options *subopts);
Expand Down Expand Up @@ -241,7 +239,7 @@ const void *m_config_shadow_get_opt_default(struct m_config_shadow *shadow,
if (subopt->defaults)
return (char *)subopt->defaults + opt->offset;

return &default_value;
return &m_option_value_default;
}

void *m_config_cache_get_opt_data(struct m_config_cache *cache, int32_t id)
Expand Down
7 changes: 3 additions & 4 deletions options/m_config_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ int m_config_set_option_cli(struct m_config *config, struct bstr name,
BSTR_P(name), BSTR_P(param), flags);
}

union m_option_value val = {0};
union m_option_value val = m_option_value_default;

// Some option types are "impure" and work on the existing data.
// (Prime examples: --vf-add, --sub-file)
Expand Down Expand Up @@ -783,7 +783,7 @@ int m_config_set_option_node(struct m_config *config, bstr name,

// Do this on an "empty" type to make setting the option strictly overwrite
// the old value, as opposed to e.g. appending to lists.
union m_option_value val = {0};
union m_option_value val = m_option_value_default;

if (data->format == MPV_FORMAT_STRING) {
bstr param = bstr0(data->u.string);
Expand Down Expand Up @@ -868,9 +868,8 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
}
char *def = NULL;
const void *defptr = m_config_get_co_default(config, co);
const union m_option_value default_value = {0};
if (!defptr)
defptr = &default_value;
defptr = &m_option_value_default;
if (defptr)
def = m_option_pretty_print(opt, defptr);
if (def) {
Expand Down
5 changes: 5 additions & 0 deletions options/m_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ union m_option_value {
struct m_channels channels;
};

// Keep fully zeroed instance of m_option_value to use as a default value, before
// any specific union member is used. C standard says that `= {0}` activates and
// initializes only the first member of the union, leaving padding bits undefined.
static const union m_option_value m_option_value_default;

////////////////////////////////////////////////////////////////////////////

struct m_option_action {
Expand Down
6 changes: 3 additions & 3 deletions options/m_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int m_property_multiply(struct mp_log *log,
const struct m_property *prop_list,
const char *property, double f, void *ctx)
{
union m_option_value val = {0};
union m_option_value val = m_option_value_default;
struct m_option opt = {0};
int r;

Expand Down Expand Up @@ -98,7 +98,7 @@ static int do_action(const struct m_property *prop_list, const char *name,
int m_property_do(struct mp_log *log, const struct m_property *prop_list,
const char *name, int action, void *arg, void *ctx)
{
union m_option_value val = {0};
union m_option_value val = m_option_value_default;
int r;

struct m_option opt = {0};
Expand Down Expand Up @@ -562,7 +562,7 @@ int m_property_read_list(int action, void *arg, int count,
r = get_item(n, M_PROPERTY_GET_TYPE, &opt, ctx);
if (r != M_PROPERTY_OK)
goto err;
union m_option_value val = {0};
union m_option_value val = m_option_value_default;
r = get_item(n, M_PROPERTY_GET, &val, ctx);
if (r != M_PROPERTY_OK)
goto err;
Expand Down
6 changes: 0 additions & 6 deletions osdep/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2)))
#endif

#if __STDC_VERSION__ >= 201112L
#include <stdalign.h>
#else
#define alignof(x) (offsetof(struct {char unalign_; x u;}, u))
#endif

#ifdef __GNUC__
#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable())
#else
Expand Down
6 changes: 4 additions & 2 deletions player/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ static void getproperty_fn(void *arg)
struct getproperty_request *req = arg;
const struct m_option *type = get_mp_type_get(req->format);

union m_option_value xdata = {0};
union m_option_value xdata = m_option_value_default;
void *data = req->data ? req->data : &xdata;

int err = -1;
Expand Down Expand Up @@ -1560,6 +1560,8 @@ int mpv_observe_property(mpv_handle *ctx, uint64_t userdata,
.type = type,
.change_ts = 1, // force initial event
.refcount = 1,
.value = m_option_value_default,
.value_ret = m_option_value_default,
};
ctx->properties_change_ts += 1;
MP_TARRAY_APPEND(ctx, ctx->properties, ctx->num_properties, prop);
Expand Down Expand Up @@ -1682,7 +1684,7 @@ static void send_client_property_changes(struct mpv_handle *ctx)
bool changed = false;
if (prop->format) {
const struct m_option *type = prop->type;
union m_option_value val = {0};
union m_option_value val = m_option_value_default;
struct getproperty_request req = {
.mpctx = ctx->mpctx,
.name = prop->name,
Expand Down
Loading

0 comments on commit 0adbe08

Please sign in to comment.