From 969f215957b25ec014aeed6e440ecb450e6927c1 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Fri, 9 Jun 2017 17:27:22 -0400 Subject: [PATCH 1/4] hevc: Add support for alternative transfer characterics SEI The use of this SEI is for backward compatibility in HLG HDR systems: older devices that cannot interpret the "arib-std-b67" transfer will get the compatible transfer (usually bt709 or bt2020) from the VUI, while newer devices that can interpret HDR will read the SEI and use its value instead. Signed-off-by: Vittorio Giovara --- libavcodec/hevc_sei.c | 9 +++++++++ libavcodec/hevc_sei.h | 7 +++++++ libavcodec/hevcdec.c | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 153d211b4b..0a5d4440bf 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -86,6 +86,13 @@ static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetB return 0; } +static int decode_nal_sei_alternative_transfer(HEVCSEIAlternativeTransfer *s, GetBitContext *gb) +{ + s->present = 1; + s->preferred_transfer_characteristics = get_bits(gb, 8); + return 0; +} + static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s, int type, int size) { @@ -96,6 +103,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s, return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb); case HEVC_SEI_TYPE_DISPLAY_ORIENTATION: return decode_nal_sei_display_orientation(&s->display_orientation, gb); + case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: + return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb); default: av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); skip_bits_long(gb, 8 * size); diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index b699fef45d..e4aeac1fbe 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -54,6 +54,7 @@ typedef enum { HEVC_SEI_TYPE_REGION_REFRESH_INFO = 134, HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO = 137, HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144, + HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147, } HEVC_SEI_Type; typedef struct HEVCSEIPictureHash { @@ -74,10 +75,16 @@ typedef struct HEVCSEIDisplayOrientation { int hflip, vflip; } HEVCSEIDisplayOrientation; +typedef struct HEVCSEIAlternativeTransfer { + int present; + int preferred_transfer_characteristics; +} HEVCSEIAlternativeTransfer; + typedef struct HEVCSEI { HEVCSEIPictureHash picture_hash; HEVCSEIFramePacking frame_packing; HEVCSEIDisplayOrientation display_orientation; + HEVCSEIAlternativeTransfer alternative_transfer; } HEVCSEI; int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 7a9182af9b..ac0b1a3c1d 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2407,6 +2407,12 @@ static int set_side_data(HEVCContext *s) s->sei.display_orientation.vflip); } + if (s->sei.alternative_transfer.present && + av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics) && + s->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) { + s->avctx->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics; + } + return 0; } From 61f589e31e84ae02d7ac6837f30f19c437b1fc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 30 Jun 2017 12:49:49 +0300 Subject: [PATCH 2/4] lavf: Remove codec_tag from dashenc and smoothstreamingenc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, the tags enforced and set on the segmenter muxer level mismatch what the mp4/ismv muxer uses (since 713efb2c0d013). Skip the codec_tag altogether here, to let the user (try to) set whichever codec/tag is preferred; the individual chained muxer will reject invalid codecs anyway. Signed-off-by: Martin Storsjö --- libavformat/dashenc.c | 1 - libavformat/smoothstreamingenc.c | 1 - 2 files changed, 2 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 7134af4978..336cea24ec 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1272,6 +1272,5 @@ AVOutputFormat ff_dash_muxer = { .write_header = dash_write_header, .write_packet = dash_write_packet, .write_trailer = dash_write_trailer, - .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, .priv_class = &dash_class, }; diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 997b9e636c..9a6682465b 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -662,6 +662,5 @@ AVOutputFormat ff_smoothstreaming_muxer = { .write_header = ism_write_header, .write_packet = ism_write_packet, .write_trailer = ism_write_trailer, - .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, .priv_class = &ism_class, }; From 1912973a2d0a4d7f8e323eb23ee4e0e29d5852ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 4 Jul 2017 20:03:00 +0300 Subject: [PATCH 3/4] d3d11va: Check WINAPI_FAMILY instead of HAVE_LOADLIBRARY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If using the winstore compat library, a fallback LoadLibrary function does exist, that only calls LoadPackagedLibrary though (which doesn't work for dynamically loading d3d11 DLLs). Therefore explicitly check the targeted API family instead. Make this check a reusable HAVE_* component which other parts of the libraries can check when necessary as well. Signed-off-by: Martin Storsjö --- configure | 14 +++++++++++++- libavutil/hwcontext_d3d11va.c | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 96bc5ab559..d92ce33e6d 100755 --- a/configure +++ b/configure @@ -1720,6 +1720,7 @@ HAVE_LIST=" sdl section_data_rel_ro threads + uwp vaapi_drm vaapi_x11 vdpau_x11 @@ -4894,7 +4895,18 @@ fi # d3d11va requires linking directly to dxgi and d3d11 if not building for # the desktop api partition -enabled LoadLibrary || d3d11va_extralibs="-ldxgi -ld3d11" +check_cpp < +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#error desktop, not uwp +#else +// WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP +#endif +#else +#error no family set +#endif +EOF enabled vaapi && require vaapi va/va.h vaInitialize -lva diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 75f78d8669..0a8cc5bc21 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -56,7 +56,7 @@ static PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice; static av_cold void load_functions(void) { -#if HAVE_LOADLIBRARY +#if !HAVE_UWP // We let these "leak" - this is fine, as unloading has no great benefit, and // Windows will mark a DLL as loaded forever if its internal refcount overflows // from too many LoadLibrary calls. @@ -486,7 +486,7 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, int ret; // (On UWP we can't check this.) -#if HAVE_LOADLIBRARY +#if !HAVE_UWP if (!LoadLibrary("d3d11_1sdklayers.dll")) is_debug = 0; #endif @@ -527,7 +527,7 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, ID3D10Multithread_Release(pMultithread); } -#if HAVE_LOADLIBRARY && HAVE_DXGIDEBUG_H +#if !HAVE_UWP && HAVE_DXGIDEBUG_H if (is_debug) { HANDLE dxgidebug_dll = LoadLibrary("dxgidebug.dll"); if (dxgidebug_dll) { From 4d330da006fe48178a4c8047f06270925eaedf63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 5 Jul 2017 12:36:03 +0300 Subject: [PATCH 4/4] os_support: Use HAVE_UWP instead of manually checking WINAPI_FAMILY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/os_support.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/libavformat/os_support.h b/libavformat/os_support.h index 965e16fa5e..55c2fdb1f1 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -129,18 +129,6 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout); #include #include "libavutil/wchar_filename.h" -#ifdef WINAPI_FAMILY -#include -// If a WINAPI_FAMILY is defined, check that the desktop API subset -// is enabled -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -#define USE_MOVEFILEEXA -#endif -#else -// If no WINAPI_FAMILY is defined, assume the full API subset -#define USE_MOVEFILEEXA -#endif - #define DEF_FS_FUNCTION(name, wfunc, afunc) \ static inline int win32_##name(const char *filename_utf8) \ { \ @@ -192,7 +180,7 @@ static inline int win32_rename(const char *src_utf8, const char *dest_utf8) fallback: /* filename may be be in CP_ACP */ -#ifdef USE_MOVEFILEEXA +#if !HAVE_UWP ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING); if (ret) errno = EPERM;