From 6780405ab64519fec41300871414ac4ef1c34e2e Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 31 Dec 2024 14:19:12 +0800 Subject: [PATCH] update patches --- .github/workflows/build.yml | 6 +- .github/workflows/build_gpl.yml | 4 +- avbuild.sh | 3 + ...1-mmal-enable-0-copy-for-egl-interop.patch | 35 ++ ...gure-fix-mmal-probing-in-cross-build.patch | 30 ++ ...eotoolbox-check-runtime-availability.patch | 76 ++++ ...k-whether-cropping-is-set-before-use.patch | 36 ++ ...c-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch | 42 ++ ...oolbox-allow-software-implementation.patch | 34 ++ .../0007-h264-increase-MAX_SLICES-to-64.patch | 27 ++ .../7.0/0008-mmal-add-vp8-mjpeg-wmv3.patch | 130 ++++++ ...copy_frame-to-support-retrieving-sw-.patch | 83 ++++ ...emove-opengl-compatibility-attribute.patch | 32 ++ ...igure-do-not-filter-libpath-for-msvc.patch | 24 + patches/7.0/0012-configure-enable-icf.patch | 26 ++ ...ure-suppor-static-build-via-clang-cl.patch | 33 ++ ...e-api-version-to-work-with-old-drive.patch | 255 +++++++++++ ...runtime-9.1-function-ptrs-before-use.patch | 34 ++ ...nvenc-check-sdk-10.0-ptrs-at-runtime.patch | 37 ++ ...po-fix-large-tempo-4-crash-lower-min.patch | 34 ++ patches/7.0/0018-flv-support-hevc-opus.patch | 112 +++++ ...-long-argument-list-error-on-windows.patch | 50 +++ ...e-flags-from-pkg-config-for-msvc-in-.patch | 29 ++ ...in-enable-windres-for-small-and-msvc.patch | 34 ++ ...022-configure-add-extra-windresflags.patch | 76 ++++ ...-depth-to-disable-rarely-used-depths.patch | 379 ++++++++++++++++ .../0024-wolfSSL-new-TLS-backend-patch.patch | 410 ++++++++++++++++++ ...index-only-keyframes-to-ensure-accur.patch | 27 ++ ...dows-shared-static-libs-in-one-build.patch | 55 +++ ...olboxenc-add-hevc-main42210-and-p210.patch | 73 ++++ ...mestamp-change-precision-of-av_ts_ma.patch | 65 +++ ...pport-segments-pretend-to-be-gif-png.patch | 65 +++ ...extutils-Add-missing-time_internal.h.patch | 28 ++ ...vaapi-fix-undefined-close-on-windows.patch | 27 ++ ...32-matroskadec-support-S_TEXT-WEBVTT.patch | 107 +++++ ...x-instead-of-CreateMutex-to-fix-win8.patch | 37 ++ ...2-mmal-enable-0-copy-for-egl-interop.patch | 35 ++ ...gure-fix-mmal-probing-in-cross-build.patch | 30 ++ ...eotoolbox-check-runtime-availability.patch | 76 ++++ ...k-whether-cropping-is-set-before-use.patch | 36 ++ ...c-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch | 42 ++ ...oolbox-allow-software-implementation.patch | 34 ++ .../0008-h264-increase-MAX_SLICES-to-64.patch | 27 ++ .../7.1/0009-mmal-add-vp8-mjpeg-wmv3.patch | 130 ++++++ ...copy_frame-to-support-retrieving-sw-.patch | 83 ++++ ...emove-opengl-compatibility-attribute.patch | 32 ++ ...igure-do-not-filter-libpath-for-msvc.patch | 24 + patches/7.1/0013-configure-enable-icf.patch | 26 ++ ...ure-suppor-static-build-via-clang-cl.patch | 33 ++ ...e-api-version-to-work-with-old-drive.patch | 255 +++++++++++ ...runtime-9.1-function-ptrs-before-use.patch | 34 ++ ...nvenc-check-sdk-10.0-ptrs-at-runtime.patch | 37 ++ ...po-fix-large-tempo-4-crash-lower-min.patch | 34 ++ patches/7.1/0019-flv-support-hevc-opus.patch | 112 +++++ ...-long-argument-list-error-on-windows.patch | 50 +++ ...e-flags-from-pkg-config-for-msvc-in-.patch | 29 ++ ...in-enable-windres-for-small-and-msvc.patch | 34 ++ ...023-configure-add-extra-windresflags.patch | 76 ++++ ...-depth-to-disable-rarely-used-depths.patch | 379 ++++++++++++++++ .../0025-wolfSSL-new-TLS-backend-patch.patch | 410 ++++++++++++++++++ ...index-only-keyframes-to-ensure-accur.patch | 27 ++ ...dows-shared-static-libs-in-one-build.patch | 55 +++ ...olboxenc-add-hevc-main42210-and-p210.patch | 62 +++ ...mestamp-change-precision-of-av_ts_ma.patch | 65 +++ ...pport-segments-pretend-to-be-gif-png.patch | 65 +++ ...nown-profile-bitstream-warning-for-s.patch | 28 ++ ...aapi-fix-undefined-close-on-windows.patch} | 4 +- ...xtutils-Add-missing-time_internal.h.patch} | 24 +- ...34-matroskadec-support-S_TEXT-WEBVTT.patch | 20 +- ...ough-TRC-and-primaries-for-YUV-input.patch | 0 ...x-instead-of-CreateMutex-to-fix-win8.patch | 10 +- ...2-mmal-enable-0-copy-for-egl-interop.patch | 6 +- ...gure-fix-mmal-probing-in-cross-build.patch | 10 +- ...eotoolbox-check-runtime-availability.patch | 16 +- ...k-whether-cropping-is-set-before-use.patch | 12 +- ...c-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch | 14 +- ...oolbox-allow-software-implementation.patch | 10 +- .../0008-h264-increase-MAX_SLICES-to-64.patch | 8 +- .../master/0009-mmal-add-vp8-mjpeg-wmv3.patch | 24 +- ...copy_frame-to-support-retrieving-sw-.patch | 6 +- ...emove-opengl-compatibility-attribute.patch | 10 +- ...igure-do-not-filter-libpath-for-msvc.patch | 10 +- .../master/0013-configure-enable-icf.patch | 10 +- ...ure-suppor-static-build-via-clang-cl.patch | 10 +- ...e-api-version-to-work-with-old-drive.patch | 32 +- ...runtime-9.1-function-ptrs-before-use.patch | 10 +- ...nvenc-check-sdk-10.0-ptrs-at-runtime.patch | 10 +- ...po-fix-large-tempo-4-crash-lower-min.patch | 8 +- .../master/0019-flv-support-hevc-opus.patch | 70 ++- ...-long-argument-list-error-on-windows.patch | 6 +- ...e-flags-from-pkg-config-for-msvc-in-.patch | 10 +- ...in-enable-windres-for-small-and-msvc.patch | 12 +- ...023-configure-add-extra-windresflags.patch | 20 +- ...-depth-to-disable-rarely-used-depths.patch | 18 +- .../0025-wolfSSL-new-TLS-backend-patch.patch | 32 +- ...index-only-keyframes-to-ensure-accur.patch | 10 +- ...dows-shared-static-libs-in-one-build.patch | 12 +- ...olboxenc-add-hevc-main42210-and-p210.patch | 4 +- ...mestamp-change-precision-of-av_ts_ma.patch | 6 +- ...pport-segments-pretend-to-be-gif-png.patch | 6 +- ...nown-profile-bitstream-warning-for-s.patch | 6 +- ...vaapi-fix-undefined-close-on-windows.patch | 27 ++ ...33-matroskadec-support-S_TEXT-WEBVTT.patch | 107 +++++ 103 files changed, 5275 insertions(+), 250 deletions(-) create mode 100644 patches/7.0/0001-mmal-enable-0-copy-for-egl-interop.patch create mode 100644 patches/7.0/0002-configure-fix-mmal-probing-in-cross-build.patch create mode 100644 patches/7.0/0003-videotoolbox-check-runtime-availability.patch create mode 100644 patches/7.0/0004-mediacodec-check-whether-cropping-is-set-before-use.patch create mode 100644 patches/7.0/0005-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch create mode 100644 patches/7.0/0006-videotoolbox-allow-software-implementation.patch create mode 100644 patches/7.0/0007-h264-increase-MAX_SLICES-to-64.patch create mode 100644 patches/7.0/0008-mmal-add-vp8-mjpeg-wmv3.patch create mode 100644 patches/7.0/0009-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch create mode 100644 patches/7.0/0010-videotoolbox-remove-opengl-compatibility-attribute.patch create mode 100644 patches/7.0/0011-configure-do-not-filter-libpath-for-msvc.patch create mode 100644 patches/7.0/0012-configure-enable-icf.patch create mode 100644 patches/7.0/0013-configure-suppor-static-build-via-clang-cl.patch create mode 100644 patches/7.0/0014-nvenc-use-runtime-api-version-to-work-with-old-drive.patch create mode 100644 patches/7.0/0015-nvenc-check-runtime-9.1-function-ptrs-before-use.patch create mode 100644 patches/7.0/0016-nvenc-check-sdk-10.0-ptrs-at-runtime.patch create mode 100644 patches/7.0/0017-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch create mode 100644 patches/7.0/0018-flv-support-hevc-opus.patch create mode 100644 patches/7.0/0019-msvc-fix-long-argument-list-error-on-windows.patch create mode 100644 patches/7.0/0020-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch create mode 100644 patches/7.0/0021-win-enable-windres-for-small-and-msvc.patch create mode 100644 patches/7.0/0022-configure-add-extra-windresflags.patch create mode 100644 patches/7.0/0023-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch create mode 100644 patches/7.0/0024-wolfSSL-new-TLS-backend-patch.patch create mode 100644 patches/7.0/0025-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch create mode 100644 patches/7.0/0026-windows-shared-static-libs-in-one-build.patch create mode 100644 patches/7.0/0027-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch create mode 100644 patches/7.0/0028-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch create mode 100644 patches/7.0/0029-hls-support-segments-pretend-to-be-gif-png.patch create mode 100644 patches/7.0/0030-avfilter-textutils-Add-missing-time_internal.h.patch create mode 100644 patches/7.0/0031-hwcontext_vaapi-fix-undefined-close-on-windows.patch create mode 100644 patches/7.0/0032-matroskadec-support-S_TEXT-WEBVTT.patch create mode 100644 patches/7.1/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch create mode 100644 patches/7.1/0002-mmal-enable-0-copy-for-egl-interop.patch create mode 100644 patches/7.1/0003-configure-fix-mmal-probing-in-cross-build.patch create mode 100644 patches/7.1/0004-videotoolbox-check-runtime-availability.patch create mode 100644 patches/7.1/0005-mediacodec-check-whether-cropping-is-set-before-use.patch create mode 100644 patches/7.1/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch create mode 100644 patches/7.1/0007-videotoolbox-allow-software-implementation.patch create mode 100644 patches/7.1/0008-h264-increase-MAX_SLICES-to-64.patch create mode 100644 patches/7.1/0009-mmal-add-vp8-mjpeg-wmv3.patch create mode 100644 patches/7.1/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch create mode 100644 patches/7.1/0011-videotoolbox-remove-opengl-compatibility-attribute.patch create mode 100644 patches/7.1/0012-configure-do-not-filter-libpath-for-msvc.patch create mode 100644 patches/7.1/0013-configure-enable-icf.patch create mode 100644 patches/7.1/0014-configure-suppor-static-build-via-clang-cl.patch create mode 100644 patches/7.1/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch create mode 100644 patches/7.1/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch create mode 100644 patches/7.1/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch create mode 100644 patches/7.1/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch create mode 100644 patches/7.1/0019-flv-support-hevc-opus.patch create mode 100644 patches/7.1/0020-msvc-fix-long-argument-list-error-on-windows.patch create mode 100644 patches/7.1/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch create mode 100644 patches/7.1/0022-win-enable-windres-for-small-and-msvc.patch create mode 100644 patches/7.1/0023-configure-add-extra-windresflags.patch create mode 100644 patches/7.1/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch create mode 100644 patches/7.1/0025-wolfSSL-new-TLS-backend-patch.patch create mode 100644 patches/7.1/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch create mode 100644 patches/7.1/0027-windows-shared-static-libs-in-one-build.patch create mode 100644 patches/7.1/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch create mode 100644 patches/7.1/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch create mode 100644 patches/7.1/0030-hls-support-segments-pretend-to-be-gif-png.patch create mode 100644 patches/7.1/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch rename patches/{master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch => 7.1/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch} (82%) rename patches/{master/0032-textutils-include-time_internal.h.patch => 7.1/0033-avfilter-textutils-Add-missing-time_internal.h.patch} (51%) rename patches/{master => 7.1}/0034-matroskadec-support-S_TEXT-WEBVTT.patch (84%) rename patches/{master => 7.1}/FFmpeg-devel-avcodec-amfenc-Pass-through-TRC-and-primaries-for-YUV-input.patch (100%) create mode 100644 patches/master/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch create mode 100644 patches/master/0033-matroskadec-support-S_TEXT-WEBVTT.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6cd198..deb275b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ env: jobs: Apple: # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix - runs-on: macos-latest + runs-on: macos-15 env: TARGET_OS: ${{ matrix.target }} CONFIG_SUFFIX: -${{ matrix.config }} @@ -524,7 +524,7 @@ jobs: path: ffmpeg-*.tar.xz Android: - runs-on: macos-latest + runs-on: macos-15 env: TARGET_OS: android CONFIG_SUFFIX: -${{ matrix.config }} @@ -572,7 +572,7 @@ jobs: path: ffmpeg-*.tar.xz FFmpeg-xcframework: - runs-on: macos-latest + runs-on: macos-15 needs: [Apple] steps: - name: Download iOS diff --git a/.github/workflows/build_gpl.yml b/.github/workflows/build_gpl.yml index 742f76b..493d2dd 100644 --- a/.github/workflows/build_gpl.yml +++ b/.github/workflows/build_gpl.yml @@ -18,7 +18,7 @@ env: jobs: Apple: # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix - runs-on: macos-latest + runs-on: macos-15 env: TARGET_OS: ${{ matrix.target }} CONFIG_SUFFIX: -gpl-${{ matrix.config }} @@ -249,7 +249,7 @@ jobs: path: ffmpeg-*.tar.xz Android: - runs-on: macos-latest + runs-on: macos-15 env: TARGET_OS: android CONFIG_SUFFIX: -gpl-${{ matrix.config }} diff --git a/avbuild.sh b/avbuild.sh index 8e82a9d..305476d 100755 --- a/avbuild.sh +++ b/avbuild.sh @@ -101,6 +101,9 @@ PATCH_BRANCH=master [ $FFMAJOR -lt 5 ] && PATCH_BRANCH=4.4 [ $FFMAJOR -eq 5 ] && PATCH_BRANCH=5.1 [ $FFMAJOR -eq 6 ] && PATCH_BRANCH=6.$FFMINOR +[ $FFMAJOR -eq 7 ] && { + $FFGIT || PATCH_BRANCH=7.$FFMINOR +} echo "FFmpeg/Libav version: $FFMAJOR.$FFMINOR git: $FFGIT. patch set version: $PATCH_BRANCH" USE_VK=$FFGIT USE_VAAPI_WIN32=$FFGIT diff --git a/patches/7.0/0001-mmal-enable-0-copy-for-egl-interop.patch b/patches/7.0/0001-mmal-enable-0-copy-for-egl-interop.patch new file mode 100644 index 0000000..52b70c4 --- /dev/null +++ b/patches/7.0/0001-mmal-enable-0-copy-for-egl-interop.patch @@ -0,0 +1,35 @@ +From 32384390987626641fbb194bc121766b690ddade Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:19:07 +0800 +Subject: [PATCH 01/32] mmal: enable 0-copy for egl interop + +--- + libavcodec/mmaldec.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index a8cda27570..21d5b5e159 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -304,6 +304,8 @@ static int ffmal_update_format(AVCodecContext *avctx) + goto fail; + + if (avctx->pix_fmt == AV_PIX_FMT_MMAL) { ++ if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_ZERO_COPY, 1))) ++ goto fail; + format_out->encoding = MMAL_ENCODING_OPAQUE; + } else { + format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420; +@@ -341,7 +343,8 @@ static int ffmal_update_format(AVCodecContext *avctx) + FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended); + decoder->output[0]->buffer_num = + FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers; +- ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num, ++ ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0], ++ decoder->output[0]->buffer_num, + decoder->output[0]->buffer_size); + if (!ctx->pool_out->pool) { + ret = AVERROR(ENOMEM); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0002-configure-fix-mmal-probing-in-cross-build.patch b/patches/7.0/0002-configure-fix-mmal-probing-in-cross-build.patch new file mode 100644 index 0000000..10b1c07 --- /dev/null +++ b/patches/7.0/0002-configure-fix-mmal-probing-in-cross-build.patch @@ -0,0 +1,30 @@ +From 33fc7724f126cfe1757451bee573c7c9b03dd245 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:22:25 +0800 +Subject: [PATCH 02/32] configure: fix mmal probing in cross build + +--- + configure | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index 20d4e4b615..91e3af3b8f 100755 +--- a/configure ++++ b/configure +@@ -7019,11 +7019,11 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt + check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto || + die "ERROR: mbedTLS not found"; } + enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } +-enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host || ++enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host -lvcos -lpthread || + { ! enabled cross_compile && + add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline && + add_ldflags -L/opt/vc/lib/ && +- check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } || ++ check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host -lvcos -lpthread; } || + die "ERROR: mmal not found" && + check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } + enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError || +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0003-videotoolbox-check-runtime-availability.patch b/patches/7.0/0003-videotoolbox-check-runtime-availability.patch new file mode 100644 index 0000000..d4a7b58 --- /dev/null +++ b/patches/7.0/0003-videotoolbox-check-runtime-availability.patch @@ -0,0 +1,76 @@ +From 1f56f900c86382dbc70960d704683196a3526b20 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:35:28 +0800 +Subject: [PATCH 03/32] videotoolbox: check runtime availability + +fix warnings/errors for new compiler (since xcode9) if targeting +macOS<10.8 +--- + libavcodec/videotoolbox.c | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index f4da80640d..3f256e72a9 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -40,6 +40,10 @@ + #include + #include + ++#if !__has_builtin(__builtin_available) ++#define __builtin_available(...) (true) ++#endif ++ + #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder + # define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder CFSTR("RequireHardwareAcceleratedVideoDecoder") + #endif +@@ -712,7 +716,7 @@ static void videotoolbox_decoder_callback(void *opaque, + + static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) + { +- OSStatus status; ++ OSStatus status = kVTInvalidSessionErr; + CMSampleBufferRef sample_buf; + AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); + VTContext *vtctx = avctx->internal->hwaccel_priv_data; +@@ -724,13 +728,15 @@ static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) + if (!sample_buf) + return -1; + +- status = VTDecompressionSessionDecodeFrame(videotoolbox->session, ++ if (__builtin_available(macOS 10.8, iOS 8.0, tvOS 10.2, *)) { ++ status = VTDecompressionSessionDecodeFrame(videotoolbox->session, + sample_buf, + 0, // decodeFlags + NULL, // sourceFrameRefCon + 0); // infoFlagsOut +- if (status == noErr) +- status = VTDecompressionSessionWaitForAsynchronousFrames(videotoolbox->session); ++ if (status == noErr) ++ status = VTDecompressionSessionWaitForAsynchronousFrames(videotoolbox->session); ++ } + + CFRelease(sample_buf); + +@@ -864,7 +870,7 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec + static int videotoolbox_start(AVCodecContext *avctx) + { + AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); +- OSStatus status; ++ OSStatus status = kVTInvalidSessionErr; + VTDecompressionOutputCallbackRecord decoder_cb; + CFDictionaryRef decoder_spec; + CFDictionaryRef buf_attr; +@@ -955,7 +961,8 @@ static int videotoolbox_start(AVCodecContext *avctx) + decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback; + decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data; + +- status = VTDecompressionSessionCreate(NULL, // allocator ++ if (__builtin_available(macOS 10.8, iOS 8.0, tvOS 10.2, *)) ++ status = VTDecompressionSessionCreate(NULL, // allocator + videotoolbox->cm_fmt_desc, // videoFormatDescription + decoder_spec, // videoDecoderSpecification + buf_attr, // destinationImageBufferAttributes +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0004-mediacodec-check-whether-cropping-is-set-before-use.patch b/patches/7.0/0004-mediacodec-check-whether-cropping-is-set-before-use.patch new file mode 100644 index 0000000..19f12c1 --- /dev/null +++ b/patches/7.0/0004-mediacodec-check-whether-cropping-is-set-before-use.patch @@ -0,0 +1,36 @@ +From 85c541d3a0134dbcf9afc3ea966e6112b15875c5 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:52:35 +0800 +Subject: [PATCH 04/32] mediacodec: check whether cropping is set before use + +--- + libavcodec/mediacodecdec_common.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c +index d6f91e6e89..0310e21070 100644 +--- a/libavcodec/mediacodecdec_common.c ++++ b/libavcodec/mediacodecdec_common.c +@@ -402,10 +402,15 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte + } + + /* Optional fields */ +- AMEDIAFORMAT_GET_INT32(s->crop_top, "crop-top", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_bottom, "crop-bottom", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_left, "crop-left", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0); ++ if (ff_AMediaFormat_getInt32(s->format, "crop-top", &s->crop_top) && ff_AMediaFormat_getInt32(s->format, "crop-bottom", &s->crop_bottom)) ++ height = s->crop_bottom + 1 - s->crop_top; ++ else ++ height = s->height; ++ ++ if (ff_AMediaFormat_getInt32(s->format, "crop-left", &s->crop_left) && ff_AMediaFormat_getInt32(s->format, "crop-right", &s->crop_right)) ++ width = s->crop_right + 1 - s->crop_left; ++ else ++ width = s->width; + + // Try "crop" for NDK + if (!(s->crop_right && s->crop_bottom) && s->use_ndk_codec) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0005-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch b/patches/7.0/0005-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch new file mode 100644 index 0000000..77d812e --- /dev/null +++ b/patches/7.0/0005-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch @@ -0,0 +1,42 @@ +From ee807f40880b48bb1857fba7c6da4ed1b935999f Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Nov 2017 14:56:53 +0800 +Subject: [PATCH 05/32] avcodec: add AV_HWACCEL_FLAG_ALLOW_SOFTWARE + +a hw decoder may have software or hybrid implementation, for example videotoolbox hevc. +the performance may be better than ffmpeg sw decoder. +--- + libavcodec/avcodec.h | 4 ++++ + libavcodec/options_table.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h +index 83dc487251..003ad59ced 100644 +--- a/libavcodec/avcodec.h ++++ b/libavcodec/avcodec.h +@@ -2173,6 +2173,10 @@ typedef struct AVHWAccel { + */ + #define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3) + ++/** ++ * Hardware acceleration can use it's software implementation. ++ */ ++#define AV_HWACCEL_FLAG_ALLOW_SOFTWARE (1 << 8) + /** + * @} + */ +diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h +index 7a2ef3474e..fdc38e3a9e 100644 +--- a/libavcodec/options_table.h ++++ b/libavcodec/options_table.h +@@ -395,6 +395,7 @@ static const AVOption avcodec_options[] = { + {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, ++{"allow_software", "allow to use software implementation in HW accelerated decoder", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_SOFTWARE}, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, + {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, + {"side_data_prefer_packet", "Comma-separated list of side data types for which user-supplied (container) data is preferred over coded bytestream", +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0006-videotoolbox-allow-software-implementation.patch b/patches/7.0/0006-videotoolbox-allow-software-implementation.patch new file mode 100644 index 0000000..ea60710 --- /dev/null +++ b/patches/7.0/0006-videotoolbox-allow-software-implementation.patch @@ -0,0 +1,34 @@ +From 6671aa21d45d84bd3b707dad229604f698df62b5 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Nov 2017 15:05:26 +0800 +Subject: [PATCH 06/32] videotoolbox: allow software implementation + +hevc is supported on macOS 10.12+ and iOS11+. sw implementaion is +provided for old devices. vt sw decoder is more energy effecient than +ffmpeg sw decoder. the sum of program and vt service cpu usage is about +50% lower than ffmpeg. decoding speed is faster sometimes(if opengl +compatiblility attribute is disabled) +--- + libavcodec/videotoolbox.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index 3f256e72a9..87056afca8 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -818,9 +818,9 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec + &kCFTypeDictionaryValueCallBacks); + + CFDictionarySetValue(config_info, +- codec_type == kCMVideoCodecType_HEVC ? +- kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder : +- kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, ++ (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_SOFTWARE) ++ ? kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder ++ : kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, + kCFBooleanTrue); + + avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault, +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0007-h264-increase-MAX_SLICES-to-64.patch b/patches/7.0/0007-h264-increase-MAX_SLICES-to-64.patch new file mode 100644 index 0000000..fa7c823 --- /dev/null +++ b/patches/7.0/0007-h264-increase-MAX_SLICES-to-64.patch @@ -0,0 +1,27 @@ +From 8bc90de7eb5a50d09f97f8dd70c4ee471298c300 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 13 Nov 2017 12:23:10 +0800 +Subject: [PATCH 07/32] h264: increase MAX_SLICES to 64 + +lavfilters is 256. 64 can fix corrupt decoded frames +https://github.com/wang-bin/QtAV/issues/923 +--- + libavcodec/h264dec.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h +index 447c2499d9..b06eb14833 100644 +--- a/libavcodec/h264dec.h ++++ b/libavcodec/h264dec.h +@@ -58,7 +58,7 @@ + * The maximum number of slices supported by the decoder. + * must be a power of 2 + */ +-#define MAX_SLICES 32 ++#define MAX_SLICES 64 + + #ifdef ALLOW_INTERLACE + #define MB_MBAFF(h) (h)->mb_mbaff +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0008-mmal-add-vp8-mjpeg-wmv3.patch b/patches/7.0/0008-mmal-add-vp8-mjpeg-wmv3.patch new file mode 100644 index 0000000..4f915c3 --- /dev/null +++ b/patches/7.0/0008-mmal-add-vp8-mjpeg-wmv3.patch @@ -0,0 +1,130 @@ +From fc3e616c3d5fbb4f5509cc700f46bf430523f8e1 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 13 Nov 2017 15:14:26 +0800 +Subject: [PATCH 08/32] mmal: add vp8, mjpeg, wmv3 + +--- + configure | 3 +++ + libavcodec/allcodecs.c | 3 +++ + libavcodec/mmaldec.c | 26 ++++++++++++++++++++++++++ + 3 files changed, 32 insertions(+) + +diff --git a/configure b/configure +index 91e3af3b8f..17d72ec5d5 100755 +--- a/configure ++++ b/configure +@@ -3351,6 +3351,7 @@ hevc_vaapi_encoder_select="atsc_a53 cbs_h265 vaapi_encode" + hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" + hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf" + hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" ++mjpeg_mmal_decoder_deps="mmal" + mjpeg_cuvid_decoder_deps="cuvid" + mjpeg_qsv_decoder_select="qsvdec" + mjpeg_qsv_encoder_deps="libmfx" +@@ -3378,6 +3379,7 @@ vc1_cuvid_decoder_deps="cuvid" + vc1_mmal_decoder_deps="mmal" + vc1_qsv_decoder_select="qsvdec" + vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" ++vp8_mmal_decoder_deps="mmal" + vp8_cuvid_decoder_deps="cuvid" + vp8_mediacodec_decoder_deps="mediacodec" + vp8_mediacodec_encoder_deps="mediacodec" +@@ -3397,6 +3399,7 @@ vp9_vaapi_encoder_select="vaapi_encode" + vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9" + vp9_qsv_encoder_select="qsvenc" + vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m" ++wmv3_mmal_decoder_deps="mmal" + av1_qsv_decoder_select="qsvdec" + av1_qsv_encoder_select="qsvenc" + av1_qsv_encoder_deps="libvpl" +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index 2386b450a6..722b3d8b02 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -865,6 +865,7 @@ extern const FFCodec ff_hevc_vaapi_encoder; + extern const FFCodec ff_hevc_videotoolbox_encoder; + extern const FFCodec ff_libkvazaar_encoder; + extern const FFCodec ff_mjpeg_cuvid_decoder; ++extern const FFCodec ff_mjpeg_mmal_decoder; + extern const FFCodec ff_mjpeg_qsv_encoder; + extern const FFCodec ff_mjpeg_qsv_decoder; + extern const FFCodec ff_mjpeg_vaapi_encoder; +@@ -883,6 +884,7 @@ extern const FFCodec ff_vc1_cuvid_decoder; + extern const FFCodec ff_vp8_cuvid_decoder; + extern const FFCodec ff_vp8_mediacodec_decoder; + extern const FFCodec ff_vp8_mediacodec_encoder; ++extern const FFCodec ff_vp8_mmal_decoder; + extern const FFCodec ff_vp8_qsv_decoder; + extern const FFCodec ff_vp8_v4l2m2m_encoder; + extern const FFCodec ff_vp8_vaapi_encoder; +@@ -892,6 +894,7 @@ extern const FFCodec ff_vp9_mediacodec_encoder; + extern const FFCodec ff_vp9_qsv_decoder; + extern const FFCodec ff_vp9_vaapi_encoder; + extern const FFCodec ff_vp9_qsv_encoder; ++extern const FFCodec ff_wmv3_mmal_decoder; + + // null codecs + extern const FFCodec ff_vnull_decoder; +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index 21d5b5e159..0bfeec6bd3 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -387,15 +387,24 @@ static av_cold int ffmmal_init_decoder(AVCodecContext *avctx) + format_in = decoder->input[0]->format; + format_in->type = MMAL_ES_TYPE_VIDEO; + switch (avctx->codec_id) { ++ case AV_CODEC_ID_MJPEG: ++ format_in->encoding = MMAL_ENCODING_MJPEG; ++ break; + case AV_CODEC_ID_MPEG2VIDEO: + format_in->encoding = MMAL_ENCODING_MP2V; + break; + case AV_CODEC_ID_MPEG4: + format_in->encoding = MMAL_ENCODING_MP4V; + break; ++ case AV_CODEC_ID_VP8: ++ format_in->encoding = MMAL_ENCODING_VP8; ++ break; + case AV_CODEC_ID_VC1: + format_in->encoding = MMAL_ENCODING_WVC1; + break; ++ case AV_CODEC_ID_WMV3: // may be not enabled ++ format_in->encoding = MMAL_ENCODING_WMV3; ++ break; + case AV_CODEC_ID_H264: + default: + format_in->encoding = MMAL_ENCODING_H264; +@@ -824,6 +833,20 @@ static const AVCodecHWConfigInternal *const mmal_hw_configs[] = { + NULL + }; + ++AVHWAccel ff_vp8_mmal_hwaccel = { ++ .name = "vp8_mmal", ++ .type = AVMEDIA_TYPE_VIDEO, ++ .id = AV_CODEC_ID_VP8, ++ .pix_fmt = AV_PIX_FMT_MMAL, ++}; ++ ++AVHWAccel ff_wmv3_mmal_hwaccel = { ++ .name = "wmv3_mmal", ++ .type = AVMEDIA_TYPE_VIDEO, ++ .id = AV_CODEC_ID_WMV3, ++ .pix_fmt = AV_PIX_FMT_MMAL, ++}; ++ + static const AVOption options[]={ + {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, + {"extra_decoder_buffers", "extra MMAL internal buffered frames", offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, +@@ -856,6 +879,9 @@ static const AVClass ffmmal_dec_class = { + }; + + FFMMAL_DEC(h264, AV_CODEC_ID_H264) ++FFMMAL_DEC(mjpeg, AV_CODEC_ID_MJPEG) + FFMMAL_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO) + FFMMAL_DEC(mpeg4, AV_CODEC_ID_MPEG4) + FFMMAL_DEC(vc1, AV_CODEC_ID_VC1) ++FFMMAL_DEC(vp8, AV_CODEC_ID_VP8) ++FFMMAL_DEC(wmv3, AV_CODEC_ID_WMV3) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0009-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch b/patches/7.0/0009-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch new file mode 100644 index 0000000..68dea45 --- /dev/null +++ b/patches/7.0/0009-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch @@ -0,0 +1,83 @@ +From 0a20f47e3621edb219dfaabc616f2fd6bea64771 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 17 Nov 2017 14:54:23 +0800 +Subject: [PATCH 09/32] mmal: add option copy_frame to support retrieving sw + frames w/o copy + +mmal buffer->data is already in host memory. AFAIK decoders implemented in omx must +be configured to output frames to either memory or something directly used by renderer, +for example mediacodec surface, mmal buffer and omxil eglimage. +test result: big buck bunny 1080p fps increases from about 100 to 110 if copy_frame is +turned off +--- + libavcodec/mmaldec.c | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index 0bfeec6bd3..119c16db26 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -71,6 +71,7 @@ typedef struct MMALDecodeContext { + AVClass *av_class; + int extra_buffers; + int extra_decoder_buffers; ++ int copy_frame; + + MMAL_COMPONENT_T *decoder; + MMAL_QUEUE_T *queue_decoded_frames; +@@ -147,7 +148,6 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef *pool, + atomic_fetch_add_explicit(&ref->pool->refcount, 1, memory_order_relaxed); + mmal_buffer_header_acquire(buffer); + +- frame->format = AV_PIX_FMT_MMAL; + frame->data[3] = (uint8_t *)ref->buffer; + return 0; + } +@@ -652,20 +652,34 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, + + if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) + goto done; ++ frame->format = AV_PIX_FMT_MMAL; + } else { + int w = FFALIGN(avctx->width, 32); + int h = FFALIGN(avctx->height, 16); + uint8_t *src[4]; + int linesize[4]; + +- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) +- goto done; ++ if (ctx->copy_frame) { ++ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) ++ goto done; + + av_image_fill_arrays(src, linesize, + buffer->data + buffer->type->video.offset[0], + avctx->pix_fmt, w, h, 1); + av_image_copy2(frame->data, frame->linesize, src, linesize, + avctx->pix_fmt, avctx->width, avctx->height); ++ } else { ++ if ((ret = ff_decode_frame_props(avctx, frame)) < 0) ++ goto done; ++ /* buffer->type->video.offset/pitch[i]; is always 0 */ ++ av_image_fill_arrays(src, linesize, ++ buffer->data + buffer->type->video.offset[0], ++ avctx->pix_fmt, w, h, 1); ++ if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) ++ goto done; ++ memcpy(frame->data, src, sizeof(src)); ++ memcpy(frame->linesize, linesize, sizeof(linesize)); ++ } + } + + frame->sample_aspect_ratio = avctx->sample_aspect_ratio; +@@ -850,6 +864,7 @@ AVHWAccel ff_wmv3_mmal_hwaccel = { + static const AVOption options[]={ + {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, + {"extra_decoder_buffers", "extra MMAL internal buffered frames", offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, ++ {"copy_frame", "copy deocded data to avframe", offsetof(MMALDecodeContext, copy_frame), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 256, 0}, + {NULL} + }; + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0010-videotoolbox-remove-opengl-compatibility-attribute.patch b/patches/7.0/0010-videotoolbox-remove-opengl-compatibility-attribute.patch new file mode 100644 index 0000000..5ec8e1a --- /dev/null +++ b/patches/7.0/0010-videotoolbox-remove-opengl-compatibility-attribute.patch @@ -0,0 +1,32 @@ +From 8283d68e52dfb30e40a87cfee22607151fc4fa9d Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 15 Dec 2017 11:34:06 +0800 +Subject: [PATCH 10/32] videotoolbox: remove opengl compatibility attribute + +1. a cvpixelbuffer backed by iosurface can always be converted to an opengl texture, using CGLTexImageIOSurface2D for macOS, and undocumented api texImageIOSurface(which is internally used by public api CVOpenGLESTextureCacheCreateTextureFromImage) for iOS4.0+. +2. enabling the attribute can slow down decoding speed a lot. I tested many video clips on my macbook air. for example: ffmpeg -ss 00:00:00 -t 00:03:00 -hwaccel videotoolbox -an -i big_buck_bunny_1080p_h264.mov -f null ->/dev/null, result with the attribute +enabled: frame= 2082 fps= 85 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=7.34x +disabled: frame= 2031 fps=104 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=9.22x +--- + libavcodec/videotoolbox.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index 87056afca8..b7b0a93ee6 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -792,11 +792,6 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, + CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); +-#if TARGET_OS_IPHONE +- CFDictionarySetValue(buffer_attributes, kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue); +-#else +- CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfaceOpenGLTextureCompatibilityKey, kCFBooleanTrue); +-#endif + + CFRelease(io_surface_properties); + CFRelease(cv_pix_fmt); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0011-configure-do-not-filter-libpath-for-msvc.patch b/patches/7.0/0011-configure-do-not-filter-libpath-for-msvc.patch new file mode 100644 index 0000000..beeb4f1 --- /dev/null +++ b/patches/7.0/0011-configure-do-not-filter-libpath-for-msvc.patch @@ -0,0 +1,24 @@ +From 70e1d3b5798da27f9c9fbc227b6caee03fa03a4a Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 30 Mar 2018 10:46:43 +0800 +Subject: [PATCH 11/32] configure: do not filter -libpath for msvc + +--- + configure | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure b/configure +index 17d72ec5d5..59672c8d3f 100755 +--- a/configure ++++ b/configure +@@ -4786,6 +4786,7 @@ msvc_common_flags(){ + -lz) echo zlib.lib ;; + -lx264) echo libx264.lib ;; + -lstdc++) ;; ++ -libpath:*|-LIBPATH:*)echo $flag ;; + -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; + -L*) echo -libpath:${flag#-L} ;; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0012-configure-enable-icf.patch b/patches/7.0/0012-configure-enable-icf.patch new file mode 100644 index 0000000..745a400 --- /dev/null +++ b/patches/7.0/0012-configure-enable-icf.patch @@ -0,0 +1,26 @@ +From aa32c1b396358faf20cca0e1c7ce277aa2226092 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 11 Sep 2018 23:16:49 +0800 +Subject: [PATCH 12/32] configure: enable icf + +--- + configure | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/configure b/configure +index 59672c8d3f..babad3c6dd 100755 +--- a/configure ++++ b/configure +@@ -7511,6 +7511,9 @@ test_cc -mno-red-zone < +Date: Sun, 14 Apr 2019 11:42:42 +0800 +Subject: [PATCH 13/32] configure: suppor static build via clang-cl + +--- + configure | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index babad3c6dd..4a2c2398ed 100755 +--- a/configure ++++ b/configure +@@ -5851,7 +5851,15 @@ case $target_os in + SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' + SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)' + enabled x86_64 && objformat="win64" || objformat="win32" +- ranlib=: ++ # ranlib is required by llvm toolchain, clang-cl is detected as msvc ++ [ "$toolchain" = msvc ] && { ++ ranlib=: ++ } || { ++ LIBPREF= # patch win clang static lib ++ LIBSUF=.lib ++ LD_LIB='%.lib' ++ SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' ++ } + enable dos_paths + ;; + cygwin*) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0014-nvenc-use-runtime-api-version-to-work-with-old-drive.patch b/patches/7.0/0014-nvenc-use-runtime-api-version-to-work-with-old-drive.patch new file mode 100644 index 0000000..c5293af --- /dev/null +++ b/patches/7.0/0014-nvenc-use-runtime-api-version-to-work-with-old-drive.patch @@ -0,0 +1,255 @@ +From c98216afe29ec26ef4bf66af0a919cd577858aed Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Wed, 12 Jun 2019 10:43:50 +0800 +Subject: [PATCH 14/32] nvenc: use runtime api version to work with old drivers + +the document recommends to use build version, so using latest nvenc +headers requires latest driver version. But api and abi change rarely, +so requesting runtime version should work, and does work for my tests. +--- + libavcodec/nvenc.c | 79 +++++++++++++++++++++++++++++----------------- + libavcodec/nvenc.h | 3 ++ + 2 files changed, 53 insertions(+), 29 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index a44beb349f..c4d41a9131 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -302,20 +302,35 @@ static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level) + av_log(avctx, level, "The minimum required Nvidia driver for nvenc is %s or newer\n", minver); + } + ++static inline uint32_t struct_ver_rt(NvencContext* ctx, uint32_t struct_ver) ++{ ++ return ((uint32_t)ctx->apiver_rt | ((struct_ver)<<16) | (0x7 << 28)); ++} ++ ++static inline uint32_t api_ver(uint32_t major_ver, uint32_t minor_ver) ++{ ++ return major_ver | (minor_ver << 24); ++} ++ + static av_cold int nvenc_load_libraries(AVCodecContext *avctx) + { + NvencContext *ctx = avctx->priv_data; + NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; + NVENCSTATUS err; + uint32_t nvenc_max_ver; ++ uint32_t nvenc_max_major; ++ uint32_t nvenc_max_minor; ++ uint32_t func_ver = NV_ENCODE_API_FUNCTION_LIST_VER; + int ret; +- + ret = cuda_load_functions(&dl_fn->cuda_dl, avctx); +- if (ret < 0) ++ if (ret < 0) { ++ av_log(avctx, AV_LOG_ERROR, "cuda_load_functions error"); + return ret; ++ } + + ret = nvenc_load_functions(&dl_fn->nvenc_dl, avctx); + if (ret < 0) { ++ av_log(avctx, AV_LOG_ERROR, "nvenc_load_functions error"); + nvenc_print_driver_requirement(avctx, AV_LOG_ERROR); + return ret; + } +@@ -323,19 +338,25 @@ static av_cold int nvenc_load_libraries(AVCodecContext *avctx) + err = dl_fn->nvenc_dl->NvEncodeAPIGetMaxSupportedVersion(&nvenc_max_ver); + if (err != NV_ENC_SUCCESS) + return nvenc_print_error(avctx, err, "Failed to query nvenc max version"); +- +- av_log(avctx, AV_LOG_VERBOSE, "Loaded Nvenc version %d.%d\n", nvenc_max_ver >> 4, nvenc_max_ver & 0xf); ++ nvenc_max_major = nvenc_max_ver >> 4; ++ nvenc_max_minor = nvenc_max_ver & 0xf; ++ //ctx->apiver_rt = NVENCAPI_VERSION; ++ ctx->apiver_rt = api_ver(nvenc_max_major, nvenc_max_minor); ++ ctx->config_ver_rt = struct_ver_rt(ctx, 7) | (1<<31); /*NV_ENC_CONFIG_VER */ ++ if (ctx->apiver_rt < api_ver(8, 1)) ++ ctx->config_ver_rt = struct_ver_rt(ctx, 6) | (1<<31); ++ func_ver = struct_ver_rt(ctx, 2); ++ av_log(avctx, AV_LOG_INFO, "Loaded Nvenc version %d.%d\n", nvenc_max_major, nvenc_max_minor); + + if ((NVENCAPI_MAJOR_VERSION << 4 | NVENCAPI_MINOR_VERSION) > nvenc_max_ver) { +- av_log(avctx, AV_LOG_ERROR, "Driver does not support the required nvenc API version. " ++ av_log(avctx, AV_LOG_WARNING, "Driver does not support the required nvenc API version. " + "Required: %d.%d Found: %d.%d\n", + NVENCAPI_MAJOR_VERSION, NVENCAPI_MINOR_VERSION, +- nvenc_max_ver >> 4, nvenc_max_ver & 0xf); +- nvenc_print_driver_requirement(avctx, AV_LOG_ERROR); +- return AVERROR(ENOSYS); ++ nvenc_max_major, nvenc_max_minor); ++ nvenc_print_driver_requirement(avctx, AV_LOG_WARNING); ++ //return AVERROR(ENOSYS); + } +- +- dl_fn->nvenc_funcs.version = NV_ENCODE_API_FUNCTION_LIST_VER; ++ dl_fn->nvenc_funcs.version = func_ver; + + err = dl_fn->nvenc_dl->NvEncodeAPICreateInstance(&dl_fn->nvenc_funcs); + if (err != NV_ENC_SUCCESS) +@@ -376,8 +397,8 @@ static av_cold int nvenc_open_session(AVCodecContext *avctx) + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs; + NVENCSTATUS ret; + +- params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; +- params.apiVersion = NVENCAPI_VERSION; ++ params.version = struct_ver_rt(ctx, 1); ++ params.apiVersion = ctx->apiver_rt; + if (ctx->d3d11_device) { + params.device = ctx->d3d11_device; + params.deviceType = NV_ENC_DEVICE_TYPE_DIRECTX; +@@ -438,7 +459,7 @@ static int nvenc_check_cap(AVCodecContext *avctx, NV_ENC_CAPS cap) + NV_ENC_CAPS_PARAM params = { 0 }; + int ret, val = 0; + +- params.version = NV_ENC_CAPS_PARAM_VER; ++ params.version = struct_ver_rt(ctx, 1);//NV_ENC_CAPS_PARAM_VER; + params.capsToQuery = cap; + + ret = p_nvenc->nvEncGetEncodeCaps(ctx->nvencoder, ctx->init_encode_params.encodeGUID, ¶ms, &val); +@@ -801,7 +822,7 @@ static av_cold void set_constqp(AVCodecContext *avctx) + #endif + + rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; +- ++ /*rc->reservedBitField1 = 0;*/ + if (ctx->init_qp_p >= 0) { + rc->constQP.qpInterP = ctx->init_qp_p; + if (ctx->init_qp_i >= 0 && ctx->init_qp_b >= 0) { +@@ -1545,16 +1566,16 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + int res = 0; + int dw, dh; + +- ctx->encode_config.version = NV_ENC_CONFIG_VER; +- ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; ++ ctx->encode_config.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; ++ ctx->init_encode_params.version = struct_ver_rt(ctx, 5) | (1<<31);//NV_ENC_INITIALIZE_PARAMS_VER; + + ctx->init_encode_params.encodeHeight = avctx->height; + ctx->init_encode_params.encodeWidth = avctx->width; + + ctx->init_encode_params.encodeConfig = &ctx->encode_config; + +- preset_config.version = NV_ENC_PRESET_CONFIG_VER; +- preset_config.presetCfg.version = NV_ENC_CONFIG_VER; ++ preset_config.version = struct_ver_rt(ctx, 4) | (1<<31);// NV_ENC_PRESET_CONFIG_VER; ++ preset_config.presetCfg.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; + + #ifdef NVENC_HAVE_NEW_PRESETS + ctx->init_encode_params.tuningInfo = ctx->tuning_info; +@@ -1580,7 +1601,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + + memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); + +- ctx->encode_config.version = NV_ENC_CONFIG_VER; ++ ctx->encode_config.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; + + compute_dar(avctx, &dw, &dh); + ctx->init_encode_params.darHeight = dh; +@@ -1740,7 +1761,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) + + NVENCSTATUS nv_status; + NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; +- allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; ++ allocOut.version = struct_ver_rt(ctx, 1);//NV_ENC_CREATE_BITSTREAM_BUFFER_VER; + + if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) { + ctx->surfaces[idx].in_ref = av_frame_alloc(); +@@ -1756,7 +1777,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) + return AVERROR(EINVAL); + } + +- allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; ++ allocSurf.version = struct_ver_rt(ctx, 1);//NV_ENC_CREATE_INPUT_BUFFER_VER; + allocSurf.width = avctx->width; + allocSurf.height = avctx->height; + allocSurf.bufferFmt = ctx->surfaces[idx].format; +@@ -1843,7 +1864,7 @@ static av_cold int nvenc_setup_extradata(AVCodecContext *avctx) + char tmpHeader[NV_MAX_SEQ_HDR_LEN]; + + NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; +- payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; ++ payload.version = struct_ver_rt(ctx, 1);//NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; + + payload.spsppsBuffer = tmpHeader; + payload.inBufferSize = sizeof(tmpHeader); +@@ -1875,7 +1896,7 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) + + /* the encoder has to be flushed before it can be closed */ + if (ctx->nvencoder) { +- NV_ENC_PIC_PARAMS params = { .version = NV_ENC_PIC_PARAMS_VER, ++ NV_ENC_PIC_PARAMS params = { .version = struct_ver_rt(ctx, 4) | (1<<31),// NV_ENC_PIC_PARAMS_VER, + .encodePicFlags = NV_ENC_PIC_FLAG_EOS }; + + res = nvenc_push_context(avctx); +@@ -2099,7 +2120,7 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame) + if (idx < 0) + return idx; + +- reg.version = NV_ENC_REGISTER_RESOURCE_VER; ++ reg.version = struct_ver_rt(ctx, 3);// NV_ENC_REGISTER_RESOURCE_VER; + reg.width = frames_ctx->width; + reg.height = frames_ctx->height; + reg.pitch = frame->linesize[0]; +@@ -2154,7 +2175,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, + return res; + + if (!ctx->registered_frames[reg_idx].mapped) { +- ctx->registered_frames[reg_idx].in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER; ++ ctx->registered_frames[reg_idx].in_map.version = struct_ver_rt(ctx, 4);// NV_ENC_MAP_INPUT_RESOURCE_VER; + ctx->registered_frames[reg_idx].in_map.registeredResource = ctx->registered_frames[reg_idx].regptr; + nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &ctx->registered_frames[reg_idx].in_map); + if (nv_status != NV_ENC_SUCCESS) { +@@ -2174,7 +2195,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, + } else { + NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 }; + +- lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER; ++ lockBufferParams.version = struct_ver_rt(ctx, 1);//NV_ENC_LOCK_INPUT_BUFFER_VER; + lockBufferParams.inputBuffer = nvenc_frame->input_surface; + + nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams); +@@ -2336,7 +2357,7 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur + + enum AVPictureType pict_type; + +- lock_params.version = NV_ENC_LOCK_BITSTREAM_VER; ++ lock_params.version = struct_ver_rt(ctx, 1);//NV_ENC_LOCK_BITSTREAM_VER; + + lock_params.doNotWait = 0; + lock_params.outputBitstream = tmpoutsurf->output_surface; +@@ -2559,7 +2580,7 @@ static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame) + int reconfig_bitrate = 0, reconfig_dar = 0; + int dw, dh; + +- params.version = NV_ENC_RECONFIGURE_PARAMS_VER; ++ params.version = struct_ver_rt(ctx, 1) | (1<<31);//NV_ENC_RECONFIGURE_PARAMS_VER; + params.reInitEncodeParams = ctx->init_encode_params; + + compute_dar(avctx, &dw, &dh); +@@ -2652,7 +2673,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; + + NV_ENC_PIC_PARAMS pic_params = { 0 }; +- pic_params.version = NV_ENC_PIC_PARAMS_VER; ++ pic_params.version = struct_ver_rt(ctx, 4) | (1<<31);//NV_ENC_PIC_PARAMS_VER; + + if ((!ctx->cu_context && !ctx->d3d11_device) || !ctx->nvencoder) + return AVERROR(EINVAL); +diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h +index d99d8a0d76..9a01230424 100644 +--- a/libavcodec/nvenc.h ++++ b/libavcodec/nvenc.h +@@ -179,6 +179,9 @@ typedef struct NvencContext + { + AVClass *avclass; + ++ uint32_t apiver_rt; ++ uint32_t config_ver_rt; ++ + NvencDynLoadFunctions nvenc_dload_funcs; + + NV_ENC_INITIALIZE_PARAMS init_encode_params; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0015-nvenc-check-runtime-9.1-function-ptrs-before-use.patch b/patches/7.0/0015-nvenc-check-runtime-9.1-function-ptrs-before-use.patch new file mode 100644 index 0000000..a655fdf --- /dev/null +++ b/patches/7.0/0015-nvenc-check-runtime-9.1-function-ptrs-before-use.patch @@ -0,0 +1,34 @@ +From 5727a4e09044baa93da1c80266666609495ab568 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 5 Jun 2020 14:05:42 +0800 +Subject: [PATCH 15/32] nvenc: check runtime 9.1 function ptrs before use + +--- + libavcodec/nvenc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index c4d41a9131..161649612f 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -167,7 +167,7 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err, + NvencContext *ctx = avctx->priv_data; + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs; + +- if (p_nvenc && ctx->nvencoder) ++ if (p_nvenc && ctx->nvencoder && p_nvenc->nvEncGetLastErrorString) + details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder); + #endif + +@@ -1692,7 +1692,7 @@ FF_ENABLE_DEPRECATION_WARNINGS + } + + #ifdef NVENC_HAVE_CUSTREAM_PTR +- if (ctx->cu_context) { ++ if (ctx->cu_context && p_nvenc->nvEncSetIOCudaStreams) { + nv_status = p_nvenc->nvEncSetIOCudaStreams(ctx->nvencoder, &ctx->cu_stream, &ctx->cu_stream); + if (nv_status != NV_ENC_SUCCESS) { + nvenc_pop_context(avctx); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0016-nvenc-check-sdk-10.0-ptrs-at-runtime.patch b/patches/7.0/0016-nvenc-check-sdk-10.0-ptrs-at-runtime.patch new file mode 100644 index 0000000..d4ba557 --- /dev/null +++ b/patches/7.0/0016-nvenc-check-sdk-10.0-ptrs-at-runtime.patch @@ -0,0 +1,37 @@ +From 762d9c402c9c2fea673ed8e6c3b443dbeade516b Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 3 Jul 2020 14:09:54 +0800 +Subject: [PATCH 16/32] nvenc: check sdk 10.0 ptrs at runtime + +--- + libavcodec/nvenc.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index 161649612f..790c87a7b1 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -1585,17 +1585,18 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + else if (ctx->flags & NVENC_LOWLATENCY) + ctx->init_encode_params.tuningInfo = NV_ENC_TUNING_INFO_LOW_LATENCY; + ++ if (p_nvenc->nvEncGetEncodePresetConfigEx) + nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder, + ctx->init_encode_params.encodeGUID, + ctx->init_encode_params.presetGUID, + ctx->init_encode_params.tuningInfo, + &preset_config); +-#else ++ else ++#endif + nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, + ctx->init_encode_params.encodeGUID, + ctx->init_encode_params.presetGUID, + &preset_config); +-#endif + if (nv_status != NV_ENC_SUCCESS) + return nvenc_print_error(avctx, nv_status, "Cannot get the preset configuration"); + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0017-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch b/patches/7.0/0017-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch new file mode 100644 index 0000000..7bee7c7 --- /dev/null +++ b/patches/7.0/0017-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch @@ -0,0 +1,34 @@ +From fa3c7cfd594f7258b7d5a76ef4f773c6712a805a Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 9 Aug 2020 23:35:08 +0800 +Subject: [PATCH 17/32] lavfi/atempo: fix large tempo(>4) crash, lower min + +--- + libavfilter/af_atempo.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c +index 654b080e89..18f689a0c4 100644 +--- a/libavfilter/af_atempo.c ++++ b/libavfilter/af_atempo.c +@@ -155,7 +155,7 @@ typedef struct ATempoContext { + uint64_t nsamples_out; + } ATempoContext; + +-#define YAE_ATEMPO_MIN 0.5 ++#define YAE_ATEMPO_MIN 0 + #define YAE_ATEMPO_MAX 100.0 + + #define OFFSET(x) offsetof(ATempoContext, x) +@@ -439,7 +439,7 @@ static int yae_load_data(ATempoContext *atempo, + } + + // samples are not expected to be skipped, unless tempo is greater than 2: +- av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); ++ //av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); + + while (atempo->position[0] < stop_here && src < src_end) { + int src_samples = (src_end - src) / atempo->stride; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0018-flv-support-hevc-opus.patch b/patches/7.0/0018-flv-support-hevc-opus.patch new file mode 100644 index 0000000..66d7a21 --- /dev/null +++ b/patches/7.0/0018-flv-support-hevc-opus.patch @@ -0,0 +1,112 @@ +From a8c70b6f2e066b8dbed99bf42fb21b2e3e8de9d0 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 27 Sep 2021 17:35:17 +0800 +Subject: [PATCH 18/32] flv: support hevc, opus + +--- + libavformat/flv.h | 2 ++ + libavformat/flvdec.c | 17 ++++++++++++++++- + libavformat/flvenc.c | 4 ++++ + 3 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/libavformat/flv.h b/libavformat/flv.h +index f710963b92..8e72d62a5f 100644 +--- a/libavformat/flv.h ++++ b/libavformat/flv.h +@@ -105,6 +105,7 @@ enum { + FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET, + FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET, + FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET, ++ FLV_CODECID_OPUS = 13<< FLV_AUDIO_CODECID_OFFSET, + }; + + enum { +@@ -116,6 +117,7 @@ enum { + FLV_CODECID_H264 = 7, + FLV_CODECID_REALH263= 8, + FLV_CODECID_MPEG4 = 9, ++ FLV_CODECID_HEVC = 12, + }; + + enum { +diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c +index 892371fcd0..df969ea3f4 100644 +--- a/libavformat/flvdec.c ++++ b/libavformat/flvdec.c +@@ -263,6 +263,10 @@ static int flv_same_audio_codec(AVCodecParameters *apar, int flags) + case FLV_CODECID_PCM_ALAW: + return apar->sample_rate == 8000 && + apar->codec_id == AV_CODEC_ID_PCM_ALAW; ++ case FLV_CODECID_OPUS: ++ return apar->sample_rate == 48000 && ++ apar->bits_per_coded_sample == 16 && ++ apar->codec_id == AV_CODEC_ID_OPUS; + default: + return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET); + } +@@ -321,6 +325,11 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, + apar->sample_rate = 8000; + apar->codec_id = AV_CODEC_ID_PCM_ALAW; + break; ++ case FLV_CODECID_OPUS: ++ apar->sample_rate = 48000; ++ apar->bits_per_coded_sample = 16; ++ apar->codec_id = AV_CODEC_ID_OPUS; ++ break; + default: + avpriv_request_sample(s, "Audio codec (%x)", + flv_codecid >> FLV_AUDIO_CODECID_OFFSET); +@@ -352,6 +361,8 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid) + return vpar->codec_id == AV_CODEC_ID_VP6A; + case FLV_CODECID_H264: + return vpar->codec_id == AV_CODEC_ID_H264; ++ case FLV_CODECID_HEVC: ++ return vpar->codec_id == AV_CODEC_ID_HEVC; + default: + return vpar->codec_tag == flv_codecid; + } +@@ -413,6 +424,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, + case FLV_CODECID_MPEG4: + par->codec_id = AV_CODEC_ID_MPEG4; + break; ++ case FLV_CODECID_HEVC: ++ par->codec_id = AV_CODEC_ID_HEVC; ++ vstreami->need_parsing = AVSTREAM_PARSE_NONE; ++ break; + default: + avpriv_request_sample(s, "Video codec (%x)", flv_codecid); + par->codec_tag = flv_codecid; +@@ -1463,7 +1478,7 @@ retry_duration: + } + + if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || +- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { ++ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) { + // sign extension + int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000; + pts = av_sat_add64(dts, cts); +diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c +index a7d4fa46a2..c0087457f4 100644 +--- a/libavformat/flvenc.c ++++ b/libavformat/flvenc.c +@@ -67,6 +67,7 @@ static const AVCodecTag flv_audio_codec_ids[] = { + { AV_CODEC_ID_PCM_MULAW, FLV_CODECID_PCM_MULAW >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET }, ++ { AV_CODEC_ID_OPUS, FLV_CODECID_OPUS >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_NONE, 0 } + }; + +@@ -136,6 +137,9 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par) + if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters + return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | + FLV_SAMPLESSIZE_16BIT | FLV_STEREO; ++ else if (par->codec_id == AV_CODEC_ID_OPUS) // specs force these parameters ++ return FLV_CODECID_OPUS | FLV_SAMPLERATE_44100HZ | ++ FLV_SAMPLESSIZE_16BIT | FLV_STEREO; + else if (par->codec_id == AV_CODEC_ID_SPEEX) { + if (par->sample_rate != 16000) { + av_log(s, AV_LOG_ERROR, +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0019-msvc-fix-long-argument-list-error-on-windows.patch b/patches/7.0/0019-msvc-fix-long-argument-list-error-on-windows.patch new file mode 100644 index 0000000..d15ea74 --- /dev/null +++ b/patches/7.0/0019-msvc-fix-long-argument-list-error-on-windows.patch @@ -0,0 +1,50 @@ +From bc9a940f6bc8e38c0465e68b67b30cc9229e1e18 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sat, 11 Dec 2021 18:08:43 +0800 +Subject: [PATCH 19/32] msvc: fix long argument list error on windows + +--- + compat/windows/makedef | 4 +++- + compat/windows/mslink | 11 ++++++++--- + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/compat/windows/makedef b/compat/windows/makedef +index add8222d13..cc1cdb2056 100755 +--- a/compat/windows/makedef ++++ b/compat/windows/makedef +@@ -48,7 +48,9 @@ trap 'rm -f -- $libname' EXIT + if [ -n "$AR" ]; then + $AR rcs ${libname} $@ >/dev/null + else +- lib.exe -out:${libname} $@ >/dev/null ++ echo $@ >objs${libname}.txt ++ lib.exe -out:${libname} @objs${libname}.txt >/dev/null ++ rm objs${libname}.txt + fi + if [ $? != 0 ]; then + echo "Could not create temporary library." >&2 +diff --git a/compat/windows/mslink b/compat/windows/mslink +index 6cab090071..d3202520cf 100755 +--- a/compat/windows/mslink ++++ b/compat/windows/mslink +@@ -1,9 +1,14 @@ + #!/bin/sh + ++cmdlist=$(echo "$@"|md5sum |cut -d " " -f 1).txt # including all arguments ++echo $@>$cmdlist ++ + LINK_EXE_PATH=$(dirname "$(command -v cl)")/link + if [ -x "$LINK_EXE_PATH" ]; then +- "$LINK_EXE_PATH" $@ ++ "$LINK_EXE_PATH" @$cmdlist + else +- link.exe $@ ++ link.exe @$cmdlist + fi +-exit $? ++ret=$? ++rm -f $cmdlist ++exit $ret +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0020-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch b/patches/7.0/0020-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch new file mode 100644 index 0000000..4601f69 --- /dev/null +++ b/patches/7.0/0020-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch @@ -0,0 +1,29 @@ +From 7b23952c005afd5de90bb56bec0d4c67ac4d244c Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 11 Jan 2022 16:17:56 +0800 +Subject: [PATCH 20/32] configure: rewrite flags from pkg-config for msvc in + msys + +cflags and libs from pkg-config is unix path, e.g. /c/msys64, but msvc +requires mixed form, e.g. c:/msys64 +--- + configure | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 4a2c2398ed..c7cc12b33d 100755 +--- a/configure ++++ b/configure +@@ -4789,7 +4789,8 @@ msvc_common_flags(){ + -libpath:*|-LIBPATH:*)echo $flag ;; + -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; +- -L*) echo -libpath:${flag#-L} ;; ++ -L*) [ -n "$MSYSTEM" ] && (echo $flag |sed 's,-L\/\([a-zA-Z]\)\(\/.*\),-libpath:\1:\2,' -) || echo -libpath:${flag#-L} ;; ++ -I*) [ -n "$MSYSTEM" ] && (echo $flag |sed 's,-L\/\([a-zA-Z]\)\(\/.*\),-I\1:\2,' -) || echo $flag ;; + -Wl,*) ;; + *) echo $flag ;; + esac +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0021-win-enable-windres-for-small-and-msvc.patch b/patches/7.0/0021-win-enable-windres-for-small-and-msvc.patch new file mode 100644 index 0000000..bcc0333 --- /dev/null +++ b/patches/7.0/0021-win-enable-windres-for-small-and-msvc.patch @@ -0,0 +1,34 @@ +From c2d5222bd6becbd8bc754732e693efb250dbbd93 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 13 Mar 2022 11:15:15 +0800 +Subject: [PATCH 21/32] win: enable windres for small and msvc + +--- + configure | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index c7cc12b33d..81be54f482 100755 +--- a/configure ++++ b/configure +@@ -5786,7 +5786,7 @@ case $target_os in + # Cannot build both shared and static libs when using dllimport. + disable static + fi +- ! enabled small && test_cmd $windres --version && enable gnu_windres ++ test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -Wl,--large-address-aware + add_cppflags -DWIN32_LEAN_AND_MEAN + shlibdir_default="$bindir_default" +@@ -5837,7 +5837,7 @@ case $target_os in + # Cannot build both shared and static libs with MSVC or icl. + disable static + fi +- ! enabled small && test_cmd $windres --version && enable gnu_windres ++ test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -LARGEADDRESSAWARE + add_cppflags -DWIN32_LEAN_AND_MEAN + shlibdir_default="$bindir_default" +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0022-configure-add-extra-windresflags.patch b/patches/7.0/0022-configure-add-extra-windresflags.patch new file mode 100644 index 0000000..a22c38b --- /dev/null +++ b/patches/7.0/0022-configure-add-extra-windresflags.patch @@ -0,0 +1,76 @@ +From 1ea5a38413c8894650ee1258f8948aeb625888a8 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 13 Mar 2022 14:38:23 +0800 +Subject: [PATCH 22/32] configure: add --extra-windresflags + +llvm windres requires more preprocess flags and target flags +--- + configure | 10 ++++++++++ + ffbuild/common.mak | 2 +- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 81be54f482..87a2d61206 100755 +--- a/configure ++++ b/configure +@@ -413,6 +413,7 @@ Toolchain options: + --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] + --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] + --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS] ++ --extra-windresflags=EWFLAGS add EWFLAGS to WINDRESFLAGS [$WINDRESFLAGS] + --extra-libs=ELIBS add ELIBS [$ELIBS] + --extra-version=STRING version string suffix [] + --optflags=OPTFLAGS override optimization-related compiler flags +@@ -995,6 +996,10 @@ add_host_ldflags(){ + append host_ldflags $($host_ldflags_filter "$@") + } + ++add_windresflags(){ ++ append WINDRESFLAGS "$@" ++} ++ + add_compat(){ + append compat_objs $1 + shift +@@ -4317,6 +4322,9 @@ for opt do + --extra-libs=*) + add_extralibs $optval + ;; ++ --extra-windresflags=*) ++ add_windresflags $optval ++ ;; + --disable-devices) + disable $INDEV_LIST $OUTDEV_LIST + ;; +@@ -5139,6 +5147,7 @@ add_cflags $extra_cflags + add_cxxflags $extra_cxxflags + add_objcflags $extra_objcflags + add_asflags $extra_cflags ++add_windresflags $extra_windresflags + + if test -n "$sysroot"; then + case "$cc_type" in +@@ -8081,6 +8090,7 @@ DOXYGEN=$doxygen + LDFLAGS=$LDFLAGS + LDEXEFLAGS=$LDEXEFLAGS + LDSOFLAGS=$LDSOFLAGS ++WINDRESFLAGS=$WINDRESFLAGS + SHFLAGS=$(echo $($ldflags_filter $SHFLAGS)) + ASMSTRIPFLAGS=$ASMSTRIPFLAGS + X86ASMFLAGS=$X86ASMFLAGS +diff --git a/ffbuild/common.mak b/ffbuild/common.mak +index 87a3ffd2b0..a93961d217 100644 +--- a/ffbuild/common.mak ++++ b/ffbuild/common.mak +@@ -104,7 +104,7 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS) + -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) + + %.o: %.rc +- $(WINDRES) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $< ++ $(WINDRES) $(WINDRESFLAGS) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $< + + %.i: %.c + $(CC) $(CCFLAGS) $(CC_E) $< +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0023-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch b/patches/7.0/0023-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch new file mode 100644 index 0000000..c6a5d6c --- /dev/null +++ b/patches/7.0/0023-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch @@ -0,0 +1,379 @@ +From a22de2bf696cf020099d0b3cccec38484f52b538 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 1 Jul 2022 16:03:06 +0800 +Subject: [PATCH 23/32] add h264-max-bit-depth to disable rarely used depths + +--- + configure | 6 ++++++ + libavcodec/h264chroma.c | 4 ++++ + libavcodec/h264dsp.c | 20 ++++++++++++++++++++ + libavcodec/h264idct.c | 8 ++++++++ + libavcodec/h264pred.c | 16 ++++++++++++++++ + libavcodec/h264qpel.c | 17 +++++++++++++++++ + libavcodec/x86/h264_intrapred_init.c | 2 ++ + libavcodec/x86/h264chroma_init.c | 3 ++- + libavcodec/x86/h264dsp_init.c | 2 ++ + 9 files changed, 77 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 87a2d61206..7e5e54d457 100755 +--- a/configure ++++ b/configure +@@ -433,6 +433,7 @@ Advanced options (experts only): + disable buffer boundary checking in bitreaders + (faster, but may crash) + --sws-max-filter-size=N the max filter size swscale uses [$sws_max_filter_size_default] ++ --h264-max-bit-depth=N the max h264 decoding bit depth [$h264_max_bit_depth_default] + + Optimization options (experts only): + --disable-asm disable all assembly optimizations +@@ -2684,6 +2685,7 @@ CMDLINE_SET=" + env + extra_version + gas ++ h264_max_bit_depth + host_cc + host_cflags + host_extralibs +@@ -4101,6 +4103,9 @@ enable valgrind_backtrace + sws_max_filter_size_default=256 + set_default sws_max_filter_size + ++h264_max_bit_depth_default=10 ++set_default h264_max_bit_depth ++ + # internal components are enabled by default + enable $EXTRALIBS_LIST + +@@ -8184,6 +8189,7 @@ cat > $TMPH < 8 + #define BIT_DEPTH 16 + #include "h264chroma_template.c" + #undef BIT_DEPTH ++#endif + + #define SET_CHROMA(depth) \ + c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \ +@@ -41,7 +43,9 @@ + av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth) + { + if (bit_depth > 8 && bit_depth <= 16) { ++#if H264_MAX_BIT_DEPTH > 8 + SET_CHROMA(16); ++#endif + } else { + SET_CHROMA(8); + } +diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c +index 4d2ee10bab..86f2ace1ac 100644 +--- a/libavcodec/h264dsp.c ++++ b/libavcodec/h264dsp.c +@@ -39,29 +39,39 @@ + #include "h264dsp_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + + #define BIT_DEPTH 8 + #include "h264addpx_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH > 8 + #define BIT_DEPTH 16 + #include "h264addpx_template.c" + #undef BIT_DEPTH ++#endif + + av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + const int chroma_format_idc) +@@ -74,7 +84,9 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth) + + if (bit_depth > 8 && bit_depth <= 16) { ++#if (H264_MAX_BIT_DEPTH > 8) + ADDPX_DSP(16); ++#endif + } else { + ADDPX_DSP(8); + } +@@ -133,18 +145,26 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + c->h264_loop_filter_strength= NULL; + + switch (bit_depth) { ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + H264_DSP(9); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + H264_DSP(10); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + H264_DSP(12); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + H264_DSP(14); + break; ++#endif + default: + av_assert0(bit_depth<=8); + H264_DSP(8); +diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c +index 6a771affe1..e871496ea4 100644 +--- a/libavcodec/h264idct.c ++++ b/libavcodec/h264idct.c +@@ -31,18 +31,26 @@ + #include "h264idct_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif +diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c +index 25f9995a0b..33c5cf8a88 100644 +--- a/libavcodec/h264pred.c ++++ b/libavcodec/h264pred.c +@@ -37,21 +37,29 @@ + #include "h264pred_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + + static void pred4x4_127_dc_c(uint8_t *src, const uint8_t *topright, + ptrdiff_t _stride) +@@ -538,18 +546,26 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, + h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\ + + switch (bit_depth) { ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + H264_PRED(9) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + H264_PRED(10) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + H264_PRED(12) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + H264_PRED(14) + break; ++#endif + default: + av_assert0(bit_depth<=8); + H264_PRED(8) +diff --git a/libavcodec/h264qpel.c b/libavcodec/h264qpel.c +index 65fef03304..5a91b695b1 100644 +--- a/libavcodec/h264qpel.c ++++ b/libavcodec/h264qpel.c +@@ -27,23 +27,32 @@ + #include "h264qpel_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif ++ + #undef pixeltmp + + #define pixeltmp int32_t ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + + + av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth) +@@ -82,18 +91,26 @@ av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth) + default: + SET_QPEL(8); + break; ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + SET_QPEL(9); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + SET_QPEL(10); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + SET_QPEL(12); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + SET_QPEL(14); + break; ++#endif + } + + #if ARCH_AARCH64 +diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c +index aa9bc721f0..0de899ca4b 100644 +--- a/libavcodec/x86/h264_intrapred_init.c ++++ b/libavcodec/x86/h264_intrapred_init.c +@@ -265,6 +265,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, + } + } + } else if (bit_depth == 10) { ++#if H264_MAX_BIT_DEPTH >= 10 + if (EXTERNAL_MMXEXT(cpu_flags)) { + h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; + h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; +@@ -328,5 +329,6 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, + h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx; + h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx; + } ++#endif /* H264_MAX_BIT_DEPTH >= 10 */ + } + } +diff --git a/libavcodec/x86/h264chroma_init.c b/libavcodec/x86/h264chroma_init.c +index 34934b6ad0..c0d6e13886 100644 +--- a/libavcodec/x86/h264chroma_init.c ++++ b/libavcodec/x86/h264chroma_init.c +@@ -79,7 +79,7 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) + c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext; + c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext; + } +- ++#if H264_MAX_BIT_DEPTH > 8 + if (EXTERNAL_MMXEXT(cpu_flags) && bit_depth > 8 && bit_depth <= 10) { + c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext; + c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext; +@@ -105,4 +105,5 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) + c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx; + c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx; + } ++#endif /* H264_MAX_BIT_DEPTH > 8 */ + } +diff --git a/libavcodec/x86/h264dsp_init.c b/libavcodec/x86/h264dsp_init.c +index dc8fc4f720..39999bd2d2 100644 +--- a/libavcodec/x86/h264dsp_init.c ++++ b/libavcodec/x86/h264dsp_init.c +@@ -275,6 +275,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, + c->h264_idct_dc_add = ff_h264_idct_dc_add_8_avx; + } + } else if (bit_depth == 10) { ++#if H264_MAX_BIT_DEPTH >= 10 + if (EXTERNAL_MMXEXT(cpu_flags)) { + #if ARCH_X86_32 && !HAVE_ALIGNED_STACK + c->h264_v_loop_filter_luma = ff_deblock_v_luma_10_mmxext; +@@ -362,6 +363,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, + c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx; + #endif /* HAVE_ALIGNED_STACK */ + } ++#endif /* H264_MAX_BIT_DEPTH >= 10 */ + } + #endif + } +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0024-wolfSSL-new-TLS-backend-patch.patch b/patches/7.0/0024-wolfSSL-new-TLS-backend-patch.patch new file mode 100644 index 0000000..b81ed3c --- /dev/null +++ b/patches/7.0/0024-wolfSSL-new-TLS-backend-patch.patch @@ -0,0 +1,410 @@ +From edb8270ee1c6cfdd2b189f08b17be27bebb5ba47 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 3 May 2022 00:03:18 +0800 +Subject: [PATCH 24/32] wolfSSL - new TLS backend patch + +https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233802.html +--- + configure | 20 ++-- + libavformat/Makefile | 1 + + libavformat/network.c | 6 + + libavformat/tls.h | 3 + + libavformat/tls_wolfssl.c | 245 ++++++++++++++++++++++++++++++++++++++ + 5 files changed, 267 insertions(+), 8 deletions(-) + create mode 100644 libavformat/tls_wolfssl.c + +diff --git a/configure b/configure +index 7e5e54d457..23b60a2892 100755 +--- a/configure ++++ b/configure +@@ -207,7 +207,7 @@ External library support: + --enable-gmp enable gmp, needed for rtmp(t)e support + if openssl or librtmp is not used [no] + --enable-gnutls enable gnutls, needed for https support +- if openssl, libtls or mbedtls is not used [no] ++ if wolfssl, openssl, libtls or mbedtls is not used [no] + --disable-iconv disable iconv [autodetect] + --enable-jni enable JNI support [no] + --enable-ladspa enable LADSPA audio filtering [no] +@@ -280,7 +280,7 @@ External library support: + --enable-libtesseract enable Tesseract, needed for ocr filter [no] + --enable-libtheora enable Theora encoding via libtheora [no] + --enable-libtls enable LibreSSL (via libtls), needed for https support +- if openssl, gnutls or mbedtls is not used [no] ++ if wolfssl, openssl, gnutls or mbedtls is not used [no] + --enable-libtorch enable Torch as one DNN backend [no] + --enable-libtwolame enable MP2 encoding via libtwolame [no] + --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] +@@ -292,6 +292,8 @@ External library support: + native implementation exists [no] + --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] + --enable-libwebp enable WebP encoding via libwebp [no] ++ --enable-wolfssl enable WolfSSL), needed for https support ++ if openssl, gnutls, libtls or mbedtls is not used [no] + --enable-libx264 enable H.264 encoding via x264 [no] + --enable-libx265 enable HEVC encoding via x265 [no] + --enable-libxeve enable EVC encoding via libxeve [no] +@@ -313,7 +315,7 @@ External library support: + --disable-lzma disable lzma [autodetect] + --enable-decklink enable Blackmagic DeckLink I/O support [no] + --enable-mbedtls enable mbedTLS, needed for https support +- if openssl, gnutls or libtls is not used [no] ++ if wolfssl, openssl, gnutls or libtls is not used [no] + --enable-mediacodec enable Android MediaCodec support [no] + --enable-mediafoundation enable encoding via MediaFoundation [auto] + --disable-metal disable Apple Metal framework [autodetect] +@@ -322,7 +324,7 @@ External library support: + --enable-opencl enable OpenCL processing [no] + --enable-opengl enable OpenGL rendering [no] + --enable-openssl enable openssl, needed for https support +- if gnutls, libtls or mbedtls is not used [no] ++ if wolfssl, gnutls, libtls or mbedtls is not used [no] + --enable-pocketsphinx enable PocketSphinx, needed for asr filter [no] + --disable-sndio disable sndio support [autodetect] + --disable-schannel disable SChannel SSP, needed for TLS support on +@@ -1983,6 +1985,7 @@ EXTERNAL_LIBRARY_LIST=" + openssl + pocketsphinx + vapoursynth ++ wolfssl + " + + HWACCEL_AUTODETECT_LIBRARY_LIST=" +@@ -3757,13 +3760,13 @@ rtmpte_protocol_suggest="zlib" + rtmpts_protocol_select="ffrtmphttp_protocol https_protocol" + rtmpts_protocol_suggest="zlib" + rtp_protocol_select="udp_protocol" +-schannel_conflict="openssl gnutls libtls mbedtls" ++schannel_conflict="openssl gnutls libtls mbedtls wolfssl" + sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags" + sctp_protocol_select="network" +-securetransport_conflict="openssl gnutls libtls mbedtls" ++securetransport_conflict="openssl gnutls libtls mbedtls wolfssl" + srtp_protocol_select="rtp_protocol srtp" + tcp_protocol_select="network" +-tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls" ++tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls wolfssl" + tls_protocol_select="tcp_protocol" + udp_protocol_select="network" + udplite_protocol_select="network" +@@ -3786,7 +3789,7 @@ libsmbclient_protocol_deps="libsmbclient gplv3" + libsrt_protocol_deps="libsrt" + libsrt_protocol_select="network" + libssh_protocol_deps="libssh" +-libtls_conflict="openssl gnutls mbedtls" ++libtls_conflict="openssl gnutls mbedtls wolfssl" + libzmq_protocol_deps="libzmq" + libzmq_protocol_select="network" + +@@ -6848,6 +6851,7 @@ enabled decklink && { require_headers DeckLinkAPI.h && + enabled frei0r && require_headers "frei0r.h" + enabled gmp && require gmp gmp.h mpz_export -lgmp + enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init ++enabled wolfssl && require_pkg_config wolfssl wolfssl wolfssl/ssl.h wolfSSL_library_init + enabled jni && { [ $target_os = "android" ] && check_headers jni.h && enabled pthreads || die "ERROR: jni not found"; } + enabled ladspa && require_headers "ladspa.h dlfcn.h" + enabled lcms2 && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h cmsCreateContext +diff --git a/libavformat/Makefile b/libavformat/Makefile +index ae86954e7c..2aece478bd 100644 +--- a/libavformat/Makefile ++++ b/libavformat/Makefile +@@ -702,6 +702,7 @@ TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o + TLS-OBJS-$(CONFIG_LIBTLS) += tls_libtls.o + TLS-OBJS-$(CONFIG_MBEDTLS) += tls_mbedtls.o + TLS-OBJS-$(CONFIG_OPENSSL) += tls_openssl.o ++TLS-OBJS-$(CONFIG_WOLFSSL) += tls_wolfssl.o + TLS-OBJS-$(CONFIG_SECURETRANSPORT) += tls_securetransport.o + TLS-OBJS-$(CONFIG_SCHANNEL) += tls_schannel.o + OBJS-$(CONFIG_TLS_PROTOCOL) += tls.o $(TLS-OBJS-yes) +diff --git a/libavformat/network.c b/libavformat/network.c +index f752efc411..cc1de280aa 100644 +--- a/libavformat/network.c ++++ b/libavformat/network.c +@@ -39,6 +39,9 @@ int ff_tls_init(void) + #if CONFIG_GNUTLS + ff_gnutls_init(); + #endif ++#if CONFIG_WOLFSSL ++ ff_wolfssl_init(); ++#endif + #endif + return 0; + } +@@ -52,6 +55,9 @@ void ff_tls_deinit(void) + #if CONFIG_GNUTLS + ff_gnutls_deinit(); + #endif ++#if CONFIG_WOLFSSL ++ ff_wolfssl_deinit(); ++#endif + #endif + } + +diff --git a/libavformat/tls.h b/libavformat/tls.h +index 6c6aa01a9a..0cfad1c82b 100644 +--- a/libavformat/tls.h ++++ b/libavformat/tls.h +@@ -55,6 +55,9 @@ typedef struct TLSShared { + + int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options); + ++void ff_wolfssl_init(void); ++void ff_wolfssl_deinit(void); ++ + void ff_gnutls_init(void); + void ff_gnutls_deinit(void); + +diff --git a/libavformat/tls_wolfssl.c b/libavformat/tls_wolfssl.c +new file mode 100644 +index 0000000000..23255c0f1b +--- /dev/null ++++ b/libavformat/tls_wolfssl.c +@@ -0,0 +1,245 @@ ++/* ++ * TLS/SSL Protocol ++ * Copyright (c) 2011 Martin Storsjo ++ * Copyright (c) 2018 samsamsam@o2.pl ++ * ++ * 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 ++ ++#include "avformat.h" ++#include "network.h" ++#include "os_support.h" ++#include "url.h" ++#include "tls.h" ++#include "libavutil/thread.h" ++ ++ ++#include ++#include ++ ++typedef struct TLSContext { ++ const AVClass *class; ++ TLSShared tls_shared; ++ WOLFSSL_CTX *ctx; ++ WOLFSSL *ssl; ++} TLSContext; ++ ++static AVMutex wolfssl_mutex = AV_MUTEX_INITIALIZER; ++static int wolfssl_init; ++ ++void ff_wolfssl_init(void) ++{ ++ ++ ff_mutex_lock(&wolfssl_mutex); ++ if (!wolfssl_init) { ++ wolfSSL_Init(); ++ } ++ wolfssl_init++; ++ ff_mutex_unlock(&wolfssl_mutex); ++} ++ ++void ff_wolfssl_deinit(void) ++{ ++ ff_mutex_lock(&wolfssl_mutex); ++ wolfssl_init--; ++ if (!wolfssl_init) { ++ wolfSSL_Cleanup(); ++ } ++ ff_mutex_unlock(&wolfssl_mutex); ++} ++ ++static int print_tls_error(URLContext *h, int ret, WOLFSSL *ssl) ++{ ++ char error_buffer[WOLFSSL_MAX_ERROR_SZ]; ++ av_log(h, AV_LOG_ERROR, "%i -> %s\n", wolfSSL_get_error(ssl,0), wolfSSL_ERR_error_string(wolfSSL_get_error(ssl,0), error_buffer)); ++ return AVERROR(EIO); ++} ++ ++static int tls_close(URLContext *h) ++{ ++ TLSContext *c = h->priv_data; ++ if (c->ssl) { ++ wolfSSL_shutdown(c->ssl); ++ wolfSSL_free(c->ssl); ++ } ++ if (c->ctx) ++ wolfSSL_CTX_free(c->ctx); ++ if (c->tls_shared.tcp) ++ ffurl_close(c->tls_shared.tcp); ++ //ff_wolfssl_deinit(); ++ return 0; ++} ++ ++static int wolfssl_recv_callback(WOLFSSL* ssl, char* buf, int sz, void* ctx) ++{ ++ URLContext *h = (URLContext*) ctx; ++ int ret = ffurl_read(h, buf, sz); ++ if (ret >= 0) ++ return ret; ++ if (ret == AVERROR_EXIT) ++ return WOLFSSL_CBIO_ERR_GENERAL; ++ errno = EIO; ++ return WOLFSSL_CBIO_ERR_GENERAL; ++} ++ ++static int wolfssl_send_callback(WOLFSSL* ssl, char* buf, int sz, void* ctx) ++{ ++ URLContext *h = (URLContext*) ctx; ++ int ret = ffurl_write(h, buf, sz); ++ if (ret >= 0) ++ return ret; ++ if (ret == AVERROR_EXIT) ++ return WOLFSSL_CBIO_ERR_GENERAL; ++ errno = EIO; ++ return WOLFSSL_CBIO_ERR_GENERAL; ++} ++ ++static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) ++{ ++ char error_buffer[WOLFSSL_MAX_ERROR_SZ]; ++ TLSContext *p = h->priv_data; ++ TLSShared *c = &p->tls_shared; ++ int ret; ++ ++ //ff_wolfssl_init(); ++ ++ if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) ++ goto fail; ++ // Modified to compile with minimal wolfSSL library which only has client methods ++ //p->ctx = wolfSSL_CTX_new(c->listen ? wolfSSLv23_server_method() : wolfSSLv23_client_method()); // wolfTLSv1_1_client_method ++ p->ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); ++#ifndef NO_FILESYSTEM ++ if (!p->ctx) { ++ av_log(h, AV_LOG_ERROR, "%s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ if (c->ca_file) { ++ if (!wolfSSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL)) ++ av_log(h, AV_LOG_ERROR, "wolfSSL_CTX_load_verify_locations %s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ } ++ if (c->cert_file && !wolfSSL_CTX_use_certificate_chain_file(p->ctx, c->cert_file)) { ++ av_log(h, AV_LOG_ERROR, "Unable to load cert file %s: %s\n", ++ c->cert_file, wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ if (c->key_file && !wolfSSL_CTX_use_PrivateKey_file(p->ctx, c->key_file, WOLFSSL_FILETYPE_PEM)) { ++ av_log(h, AV_LOG_ERROR, "Unable to load key file %s: %s\n", ++ c->key_file, wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++#endif ++ ++ wolfSSL_CTX_set_verify(p->ctx, ++ c->verify ? WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT : ++ WOLFSSL_VERIFY_NONE, ++ NULL); ++ ++#ifdef HAVE_SNI ++ if (!c->listen && !c->numerichost && !wolfSSL_CTX_UseSNI(p->ctx, WOLFSSL_SNI_HOST_NAME, c->host, ++ (unsigned short)strlen(c->host))) { ++ av_log(h, AV_LOG_ERROR, "failed to configure server name indication (SNI) %s: %d -> %s\n", ++ c->host, wolfSSL_get_error(p->ssl,0), wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ } ++#endif ++ ++ wolfSSL_CTX_SetIORecv(p->ctx, wolfssl_recv_callback); ++ wolfSSL_CTX_SetIOSend(p->ctx, wolfssl_send_callback); ++ ++ p->ssl = wolfSSL_new(p->ctx); ++ if (!p->ssl) { ++ av_log(h, AV_LOG_ERROR, "%s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ ++ wolfSSL_SetIOReadCtx(p->ssl, c->tcp); ++ wolfSSL_SetIOWriteCtx(p->ssl, c->tcp); ++ ++ // Modified to compile with minimal wolfSSL library which only has client methods ++ //ret = c->listen ? wolfSSL_accept(p->ssl) : wolfSSL_connect(p->ssl); ++ ret = wolfSSL_connect(p->ssl); ++ if (ret == 0) { ++ av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n"); ++ ret = AVERROR(EIO); ++ goto fail; ++ } else if (ret < 0) { ++ ret = print_tls_error(h, ret, p->ssl); ++ goto fail; ++ } ++ ++ return 0; ++fail: ++ tls_close(h); ++ return ret; ++} ++ ++static int tls_read(URLContext *h, uint8_t *buf, int size) ++{ ++ TLSContext *c = h->priv_data; ++ int ret = wolfSSL_read(c->ssl, buf, size); ++ if (ret > 0) ++ return ret; ++ if (ret == 0) ++ return AVERROR_EOF; ++ return print_tls_error(h, ret, c->ssl); ++} ++ ++static int tls_write(URLContext *h, const uint8_t *buf, int size) ++{ ++ TLSContext *c = h->priv_data; ++ int ret = wolfSSL_write(c->ssl, buf, size); ++ if (ret > 0) ++ return ret; ++ if (ret == 0) ++ return AVERROR_EOF; ++ return print_tls_error(h, ret, c->ssl); ++} ++ ++static int tls_get_file_handle(URLContext *h) ++{ ++ TLSContext *c = h->priv_data; ++ return ffurl_get_file_handle(c->tls_shared.tcp); ++} ++ ++static const AVOption options[] = { ++ TLS_COMMON_OPTIONS(TLSContext, tls_shared), ++ { NULL } ++}; ++ ++static const AVClass tls_class = { ++ .class_name = "tls", ++ .item_name = av_default_item_name, ++ .option = options, ++ .version = LIBAVUTIL_VERSION_INT, ++}; ++ ++const URLProtocol ff_tls_protocol = { ++ .name = "tls", ++ .url_open2 = tls_open, ++ .url_read = tls_read, ++ .url_write = tls_write, ++ .url_close = tls_close, ++ .url_get_file_handle = tls_get_file_handle, ++ .priv_data_size = sizeof(TLSContext), ++ .flags = URL_PROTOCOL_FLAG_NETWORK, ++ .priv_data_class = &tls_class, ++}; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0025-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch b/patches/7.0/0025-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch new file mode 100644 index 0000000..200bcab --- /dev/null +++ b/patches/7.0/0025-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch @@ -0,0 +1,27 @@ +From d0e48dd5572672d6f662f39aa6bef8d282ac9f1b Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Feb 2023 18:08:11 +0800 +Subject: [PATCH 25/32] avformat/mpegts: index only keyframes to ensure + accurate seeks + +https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190507032623.80375-1-ffmpeg@tmm1.net/ +--- + libavformat/mpegts.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c +index 320926248b..9600e81faa 100644 +--- a/libavformat/mpegts.c ++++ b/libavformat/mpegts.c +@@ -3359,7 +3359,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, + av_packet_free(&pkt); + return AV_NOPTS_VALUE; + } +- if (pkt->dts != AV_NOPTS_VALUE && pkt->pos >= 0) { ++ if (pkt->dts != AV_NOPTS_VALUE && pkt->pos >= 0 && (pkt->flags & AV_PKT_FLAG_KEY)) { + ff_reduce_index(s, pkt->stream_index); + av_add_index_entry(s->streams[pkt->stream_index], pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); + if (pkt->stream_index == stream_index && pkt->pos >= *ppos) { +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0026-windows-shared-static-libs-in-one-build.patch b/patches/7.0/0026-windows-shared-static-libs-in-one-build.patch new file mode 100644 index 0000000..ead7740 --- /dev/null +++ b/patches/7.0/0026-windows-shared-static-libs-in-one-build.patch @@ -0,0 +1,55 @@ +From aa24ce30d3c0843d3cd290396473707a4da4eb13 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 15 Oct 2023 13:22:34 +0800 +Subject: [PATCH 26/32] windows: shared + static libs in one build + +av_export_avutil avpriv_vga16_font will result in LINK4217 warning when building ffmpeg.dll, and undefined dllimport avpriv_vga16_font error when linking exe +--- + configure | 8 +++++--- + libavutil/xga_font_data.h | 4 ++-- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/configure b/configure +index 23b60a2892..ac932dd3a6 100755 +--- a/configure ++++ b/configure +@@ -5852,8 +5852,12 @@ case $target_os in + # for shared libs. + LD_LIB='%.lib' + # Cannot build both shared and static libs with MSVC or icl. +- disable static ++ #disable static # we can build shared and static libs. let user disable it explicitly ++ LIBPREF=lib #already defined. use lib as prefix to match windows system static lib name pattern(libcmt.lib, libucrt.lib etc.) ++ else ++ LIBPREF= # if only build static libs, fftools exes always link to .lib without lib prefix + fi ++ LIBSUF=.lib + test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -LARGEADDRESSAWARE + add_cppflags -DWIN32_LEAN_AND_MEAN +@@ -5873,8 +5877,6 @@ case $target_os in + [ "$toolchain" = msvc ] && { + ranlib=: + } || { +- LIBPREF= # patch win clang static lib +- LIBSUF=.lib + LD_LIB='%.lib' + SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' + } +diff --git a/libavutil/xga_font_data.h b/libavutil/xga_font_data.h +index 69dc337120..decbf6e0c2 100644 +--- a/libavutil/xga_font_data.h ++++ b/libavutil/xga_font_data.h +@@ -29,7 +29,7 @@ + #include + #include "internal.h" + +-extern av_export_avutil const uint8_t avpriv_cga_font[2048]; +-extern av_export_avutil const uint8_t avpriv_vga16_font[4096]; ++extern const uint8_t avpriv_cga_font[2048]; ++extern const uint8_t avpriv_vga16_font[4096]; + + #endif /* AVUTIL_XGA_FONT_DATA_H */ +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0027-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch b/patches/7.0/0027-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch new file mode 100644 index 0000000..2a9fe7b --- /dev/null +++ b/patches/7.0/0027-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch @@ -0,0 +1,73 @@ +From 9aba9d12036f4c4d5b4d942c8848475285eb21b5 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 22 Dec 2022 10:39:29 +0800 +Subject: [PATCH 27/32] lavc/videotoolboxenc: add hevc main42210 and p210 + +supported by apple silicon +--- + libavcodec/defs.h | 1 + + libavcodec/videotoolboxenc.c | 8 ++++++++ + 2 files changed, 9 insertions(+) + +diff --git a/libavcodec/defs.h b/libavcodec/defs.h +index 00d840ec19..7256b2a748 100644 +--- a/libavcodec/defs.h ++++ b/libavcodec/defs.h +@@ -159,6 +159,7 @@ + #define AV_PROFILE_HEVC_MAIN_10 2 + #define AV_PROFILE_HEVC_MAIN_STILL_PICTURE 3 + #define AV_PROFILE_HEVC_REXT 4 ++#define AV_PROFILE_HEVC_MAIN_10_422 5 + #define AV_PROFILE_HEVC_SCC 9 + + #define AV_PROFILE_VVC_MAIN_10 1 +diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c +index 5ea9afee22..599d7348ed 100644 +--- a/libavcodec/videotoolboxenc.c ++++ b/libavcodec/videotoolboxenc.c +@@ -114,6 +114,7 @@ static struct{ + + CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel; + CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel; ++ CFStringRef kVTProfileLevel_HEVC_Main42210_AutoLevel; + + CFStringRef kVTCompressionPropertyKey_RealTime; + CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha; +@@ -185,6 +186,7 @@ static void loadVTEncSymbols(void){ + + GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel, "HEVC_Main_AutoLevel"); + GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel, "HEVC_Main10_AutoLevel"); ++ GET_SYM(kVTProfileLevel_HEVC_Main42210_AutoLevel, "HEVC_Main10_AutoLevel"); + + GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime"); + GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha, +@@ -965,6 +967,10 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx, + *profile_level_val = + compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel; + break; ++ case AV_PROFILE_HEVC_MAIN_10_422: ++ *profile_level_val = ++ compat_keys.kVTProfileLevel_HEVC_Main42210_AutoLevel; ++ break; + } + + if (!*profile_level_val) { +@@ -2808,6 +2814,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_BGRA, + AV_PIX_FMT_P010LE, ++ AV_PIX_FMT_P210, + AV_PIX_FMT_NONE + }; + +@@ -2939,6 +2946,7 @@ static const AVOption hevc_options[] = { + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, INT_MAX, VE, .unit = "profile" }, + { "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, .unit = "profile" }, + { "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, .unit = "profile" }, ++ { "main42210","Main42210 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN_10_422 }, INT_MIN, INT_MAX, VE, .unit = "profile" }, + + { "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE }, + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0028-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch b/patches/7.0/0028-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch new file mode 100644 index 0000000..03c67dc --- /dev/null +++ b/patches/7.0/0028-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch @@ -0,0 +1,65 @@ +From 196f561ad4bb2a6676fb8d2b612391ea59c4e827 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 11 Aug 2024 10:27:43 +0800 +Subject: [PATCH 28/32] Revert "avutil/timestamp: change precision of + av_ts_make_time_string()" + +This reverts commit 8c936e9b437aaed0ca10f3ec2edebf06cad6a5b5. +av_ts_make_time_string2 on android arm64 takes about 1s +--- + libavutil/timestamp.h | 4 +++- + tests/ref/fate/filter-metadata-scdet | 12 ++++++------ + tests/ref/fate/filter-metadata-silencedetect | 2 +- + 3 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/libavutil/timestamp.h b/libavutil/timestamp.h +index fa53a46b98..7e6da894df 100644 +--- a/libavutil/timestamp.h ++++ b/libavutil/timestamp.h +@@ -73,7 +73,9 @@ char *av_ts_make_time_string2(char *buf, int64_t ts, AVRational tb); + static inline char *av_ts_make_time_string(char *buf, int64_t ts, + const AVRational *tb) + { +- return av_ts_make_time_string2(buf, ts, *tb); ++ if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); ++ else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts); ++ return buf; + } + + /** +diff --git a/tests/ref/fate/filter-metadata-scdet b/tests/ref/fate/filter-metadata-scdet +index d385920fcd..ca5dbaaefc 100644 +--- a/tests/ref/fate/filter-metadata-scdet ++++ b/tests/ref/fate/filter-metadata-scdet +@@ -1,11 +1,11 @@ + pts=1620|tag:lavfi.scd.score=59.252|tag:lavfi.scd.mafd=60.175|tag:lavfi.scd.time=2.7 + pts=4140|tag:lavfi.scd.score=36.070|tag:lavfi.scd.mafd=44.209|tag:lavfi.scd.time=6.9 +-pts=5800|tag:lavfi.scd.score=55.819|tag:lavfi.scd.mafd=55.819|tag:lavfi.scd.time=9.666667 ++pts=5800|tag:lavfi.scd.score=55.819|tag:lavfi.scd.mafd=55.819|tag:lavfi.scd.time=9.66667 + pts=6720|tag:lavfi.scd.score=18.580|tag:lavfi.scd.mafd=22.505|tag:lavfi.scd.time=11.2 + pts=8160|tag:lavfi.scd.score=49.240|tag:lavfi.scd.mafd=49.444|tag:lavfi.scd.time=13.6 +-pts=9760|tag:lavfi.scd.score=51.497|tag:lavfi.scd.mafd=51.801|tag:lavfi.scd.time=16.266667 +-pts=14080|tag:lavfi.scd.score=34.165|tag:lavfi.scd.mafd=34.337|tag:lavfi.scd.time=23.466667 +-pts=15700|tag:lavfi.scd.score=58.310|tag:lavfi.scd.mafd=58.315|tag:lavfi.scd.time=26.166667 +-pts=18500|tag:lavfi.scd.score=16.504|tag:lavfi.scd.mafd=19.603|tag:lavfi.scd.time=30.833333 ++pts=9760|tag:lavfi.scd.score=51.497|tag:lavfi.scd.mafd=51.801|tag:lavfi.scd.time=16.2667 ++pts=14080|tag:lavfi.scd.score=34.165|tag:lavfi.scd.mafd=34.337|tag:lavfi.scd.time=23.4667 ++pts=15700|tag:lavfi.scd.score=58.310|tag:lavfi.scd.mafd=58.315|tag:lavfi.scd.time=26.1667 ++pts=18500|tag:lavfi.scd.score=16.504|tag:lavfi.scd.mafd=19.603|tag:lavfi.scd.time=30.8333 + pts=20040|tag:lavfi.scd.score=13.764|tag:lavfi.scd.mafd=19.060|tag:lavfi.scd.time=33.4 +-pts=21760|tag:lavfi.scd.score=64.451|tag:lavfi.scd.mafd=64.551|tag:lavfi.scd.time=36.266667 ++pts=21760|tag:lavfi.scd.score=64.451|tag:lavfi.scd.mafd=64.551|tag:lavfi.scd.time=36.2667 +diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect +index e66ffe5fdd..bc53fea047 100644 +--- a/tests/ref/fate/filter-metadata-silencedetect ++++ b/tests/ref/fate/filter-metadata-silencedetect +@@ -1,5 +1,5 @@ + pts=0|tag:lavfi.silence_duration=0.523107|tag:lavfi.silence_end=0.690023|tag:lavfi.silence_start=0.736417 +-pts=46080|tag:lavfi.silence_start=1.276259|tag:lavfi.silence_end=1.807506|tag:lavfi.silence_duration=0.531247 ++pts=46080|tag:lavfi.silence_start=1.27626|tag:lavfi.silence_end=1.80751|tag:lavfi.silence_duration=0.531247 + pts=92160 + pts=138240 + pts=184320 +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0029-hls-support-segments-pretend-to-be-gif-png.patch b/patches/7.0/0029-hls-support-segments-pretend-to-be-gif-png.patch new file mode 100644 index 0000000..0ffc41c --- /dev/null +++ b/patches/7.0/0029-hls-support-segments-pretend-to-be-gif-png.patch @@ -0,0 +1,65 @@ +From b0f1ef4a0d529e65dc283d7787a511e485d35da4 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Sep 2024 15:59:13 +0800 +Subject: [PATCH 29/32] hls: support segments pretend to be gif & png + +--- + libavformat/hls.c | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +diff --git a/libavformat/hls.c b/libavformat/hls.c +index 8702113e9f..476e27cfc0 100644 +--- a/libavformat/hls.c ++++ b/libavformat/hls.c +@@ -221,6 +221,7 @@ typedef struct HLSContext { + AVIOInterruptCB *interrupt_callback; + AVDictionary *avio_opts; + AVDictionary *seg_format_opts; ++ int seg_allow_img; + char *allowed_extensions; + int max_reload; + int http_persistent; +@@ -2111,7 +2112,30 @@ static int hls_read_header(AVFormatContext *s) + pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? s->max_analyze_duration : 4 * AV_TIME_BASE; + pls->ctx->interrupt_callback = s->interrupt_callback; + url = av_strdup(pls->segments[0]->url); +- ret = av_probe_input_buffer(&pls->pb.pub, &in_fmt, url, NULL, 0, 0); ++ unsigned skip = 0; ++ if (!c->seg_allow_img) { ++ uint8_t b[10] = { 0 }; // probe at most 10 ++ avio_read(&pls->pb.pub, b, sizeof(b)); ++ avio_seek(&pls->pb.pub, 0, SEEK_SET); ++ const AVProbeData pd = { ++ .buf = b, // png, gif read_probe only use this field ++ .buf_size = sizeof(b), ++ }; ++// optional: ffifmt(av_find_input_format("gif" or "gif_pipe" or "png_pipe"))->read_probe ++ int max_score = AVPROBE_SCORE_MAX - 2; // png_pipe, gif, gif_pipe score >= AVPROBE_SCORE_MAX - 1 ++ const AVInputFormat* img_fmt = av_probe_input_format2(&pd, 1, &max_score); // ++ if (img_fmt) { ++ if (av_strstart(img_fmt->name, "png", NULL)) { // "png_pipe" ++ skip = 3; // skip until ts sync byte 'G'(0x47) ++ av_log(s, AV_LOG_INFO, "segments pretend to be png\n"); ++ } else if (av_strstart(img_fmt->name, "gif", NULL)) { // "gif", "gif_pipe" ++ skip = 10; ++ av_log(s, AV_LOG_INFO, "segments pretend to be gif\n"); ++ } ++ } ++ } ++ ++ ret = av_probe_input_buffer(&pls->pb.pub, &in_fmt, url, NULL, skip, 0); + if (ret < 0) { + /* Free the ctx - it isn't initialized properly at this point, + * so avformat_close_input shouldn't be called. If +@@ -2586,6 +2610,8 @@ static const AVOption hls_options[] = { + OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, + {"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, ++ {"seg_allow_img", "Allow segments detected as gif and png images, 0 = disable, 1 = enable", ++ OFFSET(seg_allow_img), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS}, + {NULL} + }; + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0030-avfilter-textutils-Add-missing-time_internal.h.patch b/patches/7.0/0030-avfilter-textutils-Add-missing-time_internal.h.patch new file mode 100644 index 0000000..6476675 --- /dev/null +++ b/patches/7.0/0030-avfilter-textutils-Add-missing-time_internal.h.patch @@ -0,0 +1,28 @@ +From b162a3b29790434e73fd74b37e06810854dfd1ef Mon Sep 17 00:00:00 2001 +From: Zhao Zhili +Date: Mon, 18 Nov 2024 16:43:28 +0800 +Subject: [PATCH 30/32] avfilter/textutils: Add missing time_internal.h + +This fix build error on Windows with MSVC. We need time_internal.h +for gmtime_r and localtime_r. + +Signed-off-by: Zhao Zhili +--- + libavfilter/textutils.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libavfilter/textutils.c b/libavfilter/textutils.c +index ef658d04a2..c61b0ad12f 100644 +--- a/libavfilter/textutils.c ++++ b/libavfilter/textutils.c +@@ -30,6 +30,7 @@ + #include "libavutil/error.h" + #include "libavutil/file.h" + #include "libavutil/time.h" ++#include "libavutil/time_internal.h" + + static int ff_expand_text_function_internal(FFExpandTextContext *expand_text, AVBPrint *bp, + char *name, unsigned argc, char **argv) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0031-hwcontext_vaapi-fix-undefined-close-on-windows.patch b/patches/7.0/0031-hwcontext_vaapi-fix-undefined-close-on-windows.patch new file mode 100644 index 0000000..a3ddfd7 --- /dev/null +++ b/patches/7.0/0031-hwcontext_vaapi-fix-undefined-close-on-windows.patch @@ -0,0 +1,27 @@ +From 17a6ab16b765fff6099b1baf5c246f1309de1024 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 19 Nov 2024 19:43:02 +0800 +Subject: [PATCH 31/32] hwcontext_vaapi: fix undefined close() on windows + +--- + libavutil/hwcontext_vaapi.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c +index 95a68e62c5..07aa12d403 100644 +--- a/libavutil/hwcontext_vaapi.c ++++ b/libavutil/hwcontext_vaapi.c +@@ -1631,8 +1631,10 @@ static void vaapi_device_free(AVHWDeviceContext *ctx) + XCloseDisplay(priv->x11_display); + #endif + ++#if HAVE_VAAPI_DRM + if (priv->drm_fd >= 0) + close(priv->drm_fd); ++#endif + + av_freep(&priv); + } +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.0/0032-matroskadec-support-S_TEXT-WEBVTT.patch b/patches/7.0/0032-matroskadec-support-S_TEXT-WEBVTT.patch new file mode 100644 index 0000000..2e2ff6b --- /dev/null +++ b/patches/7.0/0032-matroskadec-support-S_TEXT-WEBVTT.patch @@ -0,0 +1,107 @@ +From 9a33d881cd8e6378880f8a1ed2109504d254682a Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 17 Dec 2024 23:21:57 +0800 +Subject: [PATCH 32/32] matroskadec: support S_TEXT/WEBVTT + +fix ticket #5641 +--- + libavformat/matroska.c | 1 + + libavformat/matroskadec.c | 26 ++++++++++++++++++++++++++ + 2 files changed, 27 insertions(+) + +diff --git a/libavformat/matroska.c b/libavformat/matroska.c +index d0ecfbeb6a..23c4ad6949 100644 +--- a/libavformat/matroska.c ++++ b/libavformat/matroska.c +@@ -63,6 +63,7 @@ const CodecTags ff_mkv_codec_tags[]={ + {"D_WEBVTT/CAPTIONS" , AV_CODEC_ID_WEBVTT}, + {"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT}, + {"D_WEBVTT/METADATA" , AV_CODEC_ID_WEBVTT}, ++ {"S_TEXT/WEBVTT" , AV_CODEC_ID_WEBVTT}, + + {"S_TEXT/UTF8" , AV_CODEC_ID_SUBRIP}, + {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT}, +diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c +index ae3565b0c3..1d332220b3 100644 +--- a/libavformat/matroskadec.c ++++ b/libavformat/matroskadec.c +@@ -3727,6 +3727,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + MatroskaTrack *track, + AVStream *st, + uint8_t *data, int data_len, ++ MatroskaBlockMore *blockmore, int nb_blockmore, + uint64_t timecode, + uint64_t duration, + int64_t pos) +@@ -3736,13 +3737,28 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + int id_len, settings_len, text_len; + uint8_t *p, *q; + int err; ++ const int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9); + + if (data_len <= 0) + return AVERROR_INVALIDDATA; + ++ if (!webm_style) { ++ text = data; ++ text_len = data_len; ++ if (nb_blockmore <= 0) ++ goto make_pkt; ++ data = blockmore->additional.data; ++ data_len = blockmore->additional.size; ++ } ++ + p = data; + q = data + data_len; + ++ if (webm_style) ++ goto parse_id; ++ goto parse_settings; ++ ++parse_id: + id = p; + id_len = -1; + while (p < q) { +@@ -3758,7 +3774,11 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + if (p >= q || *p != '\n') + return AVERROR_INVALIDDATA; + p++; ++ if (webm_style) ++ goto parse_settings; ++ goto make_pkt; + ++parse_settings: + settings = p; + settings_len = -1; + while (p < q) { +@@ -3774,7 +3794,11 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + if (p >= q || *p != '\n') + return AVERROR_INVALIDDATA; + p++; ++ if (webm_style) ++ goto parse_text; ++ goto parse_id; + ++parse_text: + text = p; + text_len = q - p; + while (text_len > 0) { +@@ -3785,6 +3809,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + text_len = len; + } + ++make_pkt: + if (text_len <= 0) + return AVERROR_INVALIDDATA; + +@@ -4177,6 +4202,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf + } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) { + res = matroska_parse_webvtt(matroska, track, st, + out_data, out_size, ++ blockmore, nb_blockmore, + timecode, lace_duration, + pos); + if (!buf) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch b/patches/7.1/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch new file mode 100644 index 0000000..f0c2c6c --- /dev/null +++ b/patches/7.1/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch @@ -0,0 +1,37 @@ +From 2464a43f75759c44257a83967bc88fc368bbcb78 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sat, 28 Oct 2017 20:26:50 +0800 +Subject: [PATCH 01/34] use CreateMutexEx instead of CreateMutex to fix win8 + store app link error + +--- + libavutil/hwcontext_d3d11va.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c +index 9b3c5f389f..69d5eff49e 100644 +--- a/libavutil/hwcontext_d3d11va.c ++++ b/libavutil/hwcontext_d3d11va.c +@@ -42,6 +42,10 @@ + #include "thread.h" + #include "compat/w32dlfcn.h" + ++#ifndef CreateMutexEx ++#define CreateMutexEx(lpMutexAttributes, lpName, dwFlags, dwDesiredAccess) CreateMutex(lpMutexAttributes, lpName, dwFlags) ++#endif ++ + typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + + static AVOnce functions_loaded = AV_ONCE_INIT; +@@ -499,7 +503,7 @@ static int d3d11va_device_init(AVHWDeviceContext *hwdev) + HRESULT hr; + + if (!device_hwctx->lock) { +- device_hwctx->lock_ctx = CreateMutex(NULL, 0, NULL); ++ device_hwctx->lock_ctx = CreateMutexEx(NULL, NULL, 0, 0); + if (device_hwctx->lock_ctx == INVALID_HANDLE_VALUE) { + av_log(NULL, AV_LOG_ERROR, "Failed to create a mutex\n"); + return AVERROR(EINVAL); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0002-mmal-enable-0-copy-for-egl-interop.patch b/patches/7.1/0002-mmal-enable-0-copy-for-egl-interop.patch new file mode 100644 index 0000000..fb2666d --- /dev/null +++ b/patches/7.1/0002-mmal-enable-0-copy-for-egl-interop.patch @@ -0,0 +1,35 @@ +From 0dccfde81e2d5370484012934ebcbb8c366d9094 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:19:07 +0800 +Subject: [PATCH 02/34] mmal: enable 0-copy for egl interop + +--- + libavcodec/mmaldec.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index e42591110f..44f2916413 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -305,6 +305,8 @@ static int ffmal_update_format(AVCodecContext *avctx) + goto fail; + + if (avctx->pix_fmt == AV_PIX_FMT_MMAL) { ++ if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_ZERO_COPY, 1))) ++ goto fail; + format_out->encoding = MMAL_ENCODING_OPAQUE; + } else { + format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420; +@@ -342,7 +344,8 @@ static int ffmal_update_format(AVCodecContext *avctx) + FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended); + decoder->output[0]->buffer_num = + FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers; +- ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num, ++ ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0], ++ decoder->output[0]->buffer_num, + decoder->output[0]->buffer_size); + if (!ctx->pool_out->pool) { + ret = AVERROR(ENOMEM); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0003-configure-fix-mmal-probing-in-cross-build.patch b/patches/7.1/0003-configure-fix-mmal-probing-in-cross-build.patch new file mode 100644 index 0000000..c77afe0 --- /dev/null +++ b/patches/7.1/0003-configure-fix-mmal-probing-in-cross-build.patch @@ -0,0 +1,30 @@ +From 32e85d7cfbc3c504b29bc0fcb2afe3830dd222a9 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:22:25 +0800 +Subject: [PATCH 03/34] configure: fix mmal probing in cross build + +--- + configure | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index d77a55b653..f64a87d53c 100755 +--- a/configure ++++ b/configure +@@ -7064,11 +7064,11 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt + check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto || + die "ERROR: mbedTLS not found"; } + enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } +-enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host || ++enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host -lvcos -lpthread || + { ! enabled cross_compile && + add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline && + add_ldflags -L/opt/vc/lib/ && +- check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } || ++ check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host -lvcos -lpthread; } || + die "ERROR: mmal not found" && + check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } + enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError || +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0004-videotoolbox-check-runtime-availability.patch b/patches/7.1/0004-videotoolbox-check-runtime-availability.patch new file mode 100644 index 0000000..e67946e --- /dev/null +++ b/patches/7.1/0004-videotoolbox-check-runtime-availability.patch @@ -0,0 +1,76 @@ +From 60f4f5a59584b483fbc4b974057253e805c3d220 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:35:28 +0800 +Subject: [PATCH 04/34] videotoolbox: check runtime availability + +fix warnings/errors for new compiler (since xcode9) if targeting +macOS<10.8 +--- + libavcodec/videotoolbox.c | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index 505483ef66..220daa9c1c 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -41,6 +41,10 @@ + #include + #include + ++#if !__has_builtin(__builtin_available) ++#define __builtin_available(...) (true) ++#endif ++ + #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder + # define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder CFSTR("RequireHardwareAcceleratedVideoDecoder") + #endif +@@ -713,7 +717,7 @@ static void videotoolbox_decoder_callback(void *opaque, + + static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) + { +- OSStatus status; ++ OSStatus status = kVTInvalidSessionErr; + CMSampleBufferRef sample_buf; + AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); + VTContext *vtctx = avctx->internal->hwaccel_priv_data; +@@ -725,13 +729,15 @@ static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) + if (!sample_buf) + return -1; + +- status = VTDecompressionSessionDecodeFrame(videotoolbox->session, ++ if (__builtin_available(macOS 10.8, iOS 8.0, tvOS 10.2, *)) { ++ status = VTDecompressionSessionDecodeFrame(videotoolbox->session, + sample_buf, + 0, // decodeFlags + NULL, // sourceFrameRefCon + 0); // infoFlagsOut +- if (status == noErr) +- status = VTDecompressionSessionWaitForAsynchronousFrames(videotoolbox->session); ++ if (status == noErr) ++ status = VTDecompressionSessionWaitForAsynchronousFrames(videotoolbox->session); ++ } + + CFRelease(sample_buf); + +@@ -865,7 +871,7 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec + static int videotoolbox_start(AVCodecContext *avctx) + { + AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); +- OSStatus status; ++ OSStatus status = kVTInvalidSessionErr; + VTDecompressionOutputCallbackRecord decoder_cb; + CFDictionaryRef decoder_spec; + CFDictionaryRef buf_attr; +@@ -956,7 +962,8 @@ static int videotoolbox_start(AVCodecContext *avctx) + decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback; + decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data; + +- status = VTDecompressionSessionCreate(NULL, // allocator ++ if (__builtin_available(macOS 10.8, iOS 8.0, tvOS 10.2, *)) ++ status = VTDecompressionSessionCreate(NULL, // allocator + videotoolbox->cm_fmt_desc, // videoFormatDescription + decoder_spec, // videoDecoderSpecification + buf_attr, // destinationImageBufferAttributes +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0005-mediacodec-check-whether-cropping-is-set-before-use.patch b/patches/7.1/0005-mediacodec-check-whether-cropping-is-set-before-use.patch new file mode 100644 index 0000000..241107c --- /dev/null +++ b/patches/7.1/0005-mediacodec-check-whether-cropping-is-set-before-use.patch @@ -0,0 +1,36 @@ +From fdd13be58af8ebca14a08833e71bac75988e0284 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Oct 2017 23:52:35 +0800 +Subject: [PATCH 05/34] mediacodec: check whether cropping is set before use + +--- + libavcodec/mediacodecdec_common.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c +index 3770b4f3ae..fbede7b377 100644 +--- a/libavcodec/mediacodecdec_common.c ++++ b/libavcodec/mediacodecdec_common.c +@@ -588,10 +588,15 @@ static int mediacodec_dec_parse_video_format(AVCodecContext *avctx, MediaCodecDe + } + + /* Optional fields */ +- AMEDIAFORMAT_GET_INT32(s->crop_top, "crop-top", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_bottom, "crop-bottom", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_left, "crop-left", 0); +- AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0); ++ if (ff_AMediaFormat_getInt32(s->format, "crop-top", &s->crop_top) && ff_AMediaFormat_getInt32(s->format, "crop-bottom", &s->crop_bottom)) ++ height = s->crop_bottom + 1 - s->crop_top; ++ else ++ height = s->height; ++ ++ if (ff_AMediaFormat_getInt32(s->format, "crop-left", &s->crop_left) && ff_AMediaFormat_getInt32(s->format, "crop-right", &s->crop_right)) ++ width = s->crop_right + 1 - s->crop_left; ++ else ++ width = s->width; + + // Try "crop" for NDK + if (!(s->crop_right && s->crop_bottom) && s->use_ndk_codec) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch b/patches/7.1/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch new file mode 100644 index 0000000..781a3a6 --- /dev/null +++ b/patches/7.1/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch @@ -0,0 +1,42 @@ +From 6fb854ed3f24d0688304839c1ab60adf38103ed5 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Nov 2017 14:56:53 +0800 +Subject: [PATCH 06/34] avcodec: add AV_HWACCEL_FLAG_ALLOW_SOFTWARE + +a hw decoder may have software or hybrid implementation, for example videotoolbox hevc. +the performance may be better than ffmpeg sw decoder. +--- + libavcodec/avcodec.h | 4 ++++ + libavcodec/options_table.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h +index 77ca8dee1f..30faaddbc1 100644 +--- a/libavcodec/avcodec.h ++++ b/libavcodec/avcodec.h +@@ -2184,6 +2184,10 @@ typedef struct AVHWAccel { + */ + #define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3) + ++/** ++ * Hardware acceleration can use it's software implementation. ++ */ ++#define AV_HWACCEL_FLAG_ALLOW_SOFTWARE (1 << 8) + /** + * @} + */ +diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h +index 47da41b0ad..652b3ab21d 100644 +--- a/libavcodec/options_table.h ++++ b/libavcodec/options_table.h +@@ -400,6 +400,7 @@ static const AVOption avcodec_options[] = { + {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, ++{"allow_software", "allow to use software implementation in HW accelerated decoder", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_SOFTWARE}, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, + {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, + {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, + {"side_data_prefer_packet", "Comma-separated list of side data types for which user-supplied (container) data is preferred over coded bytestream", +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0007-videotoolbox-allow-software-implementation.patch b/patches/7.1/0007-videotoolbox-allow-software-implementation.patch new file mode 100644 index 0000000..2ecda2e --- /dev/null +++ b/patches/7.1/0007-videotoolbox-allow-software-implementation.patch @@ -0,0 +1,34 @@ +From 1c3887f547122c8faa1e4434dc3fb918d90592b4 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Nov 2017 15:05:26 +0800 +Subject: [PATCH 07/34] videotoolbox: allow software implementation + +hevc is supported on macOS 10.12+ and iOS11+. sw implementaion is +provided for old devices. vt sw decoder is more energy effecient than +ffmpeg sw decoder. the sum of program and vt service cpu usage is about +50% lower than ffmpeg. decoding speed is faster sometimes(if opengl +compatiblility attribute is disabled) +--- + libavcodec/videotoolbox.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index 220daa9c1c..c7e867e7f8 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -819,9 +819,9 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec + &kCFTypeDictionaryValueCallBacks); + + CFDictionarySetValue(config_info, +- codec_type == kCMVideoCodecType_HEVC ? +- kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder : +- kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, ++ (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_SOFTWARE) ++ ? kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder ++ : kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, + kCFBooleanTrue); + + avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault, +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0008-h264-increase-MAX_SLICES-to-64.patch b/patches/7.1/0008-h264-increase-MAX_SLICES-to-64.patch new file mode 100644 index 0000000..8b34373 --- /dev/null +++ b/patches/7.1/0008-h264-increase-MAX_SLICES-to-64.patch @@ -0,0 +1,27 @@ +From b98d8688225b36301085559693d9281e587e9b1b Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 13 Nov 2017 12:23:10 +0800 +Subject: [PATCH 08/34] h264: increase MAX_SLICES to 64 + +lavfilters is 256. 64 can fix corrupt decoded frames +https://github.com/wang-bin/QtAV/issues/923 +--- + libavcodec/h264dec.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h +index ccd7583bf4..a68f3fe151 100644 +--- a/libavcodec/h264dec.h ++++ b/libavcodec/h264dec.h +@@ -58,7 +58,7 @@ + * The maximum number of slices supported by the decoder. + * must be a power of 2 + */ +-#define MAX_SLICES 32 ++#define MAX_SLICES 64 + + #ifdef ALLOW_INTERLACE + #define MB_MBAFF(h) (h)->mb_mbaff +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0009-mmal-add-vp8-mjpeg-wmv3.patch b/patches/7.1/0009-mmal-add-vp8-mjpeg-wmv3.patch new file mode 100644 index 0000000..e270812 --- /dev/null +++ b/patches/7.1/0009-mmal-add-vp8-mjpeg-wmv3.patch @@ -0,0 +1,130 @@ +From fda6837f38aeb731713b28d1187808651947eb7a Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 13 Nov 2017 15:14:26 +0800 +Subject: [PATCH 09/34] mmal: add vp8, mjpeg, wmv3 + +--- + configure | 3 +++ + libavcodec/allcodecs.c | 3 +++ + libavcodec/mmaldec.c | 26 ++++++++++++++++++++++++++ + 3 files changed, 32 insertions(+) + +diff --git a/configure b/configure +index f64a87d53c..4fbb2827c5 100755 +--- a/configure ++++ b/configure +@@ -3387,6 +3387,7 @@ hevc_vulkan_encoder_select="atsc_a53 cbs_h265 vulkan_encode" + hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" + hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf" + hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" ++mjpeg_mmal_decoder_deps="mmal" + mjpeg_cuvid_decoder_deps="cuvid" + mjpeg_qsv_decoder_select="qsvdec" + mjpeg_qsv_encoder_deps="libmfx" +@@ -3417,6 +3418,7 @@ vc1_cuvid_decoder_deps="cuvid" + vc1_mmal_decoder_deps="mmal" + vc1_qsv_decoder_select="qsvdec" + vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" ++vp8_mmal_decoder_deps="mmal" + vp8_cuvid_decoder_deps="cuvid" + vp8_mediacodec_decoder_deps="mediacodec" + vp8_mediacodec_encoder_deps="mediacodec" +@@ -3437,6 +3439,7 @@ vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9" + vp9_qsv_encoder_select="qsvenc" + vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m" + vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec" ++wmv3_mmal_decoder_deps="mmal" + + # parsers + aac_parser_select="adts_header mpeg4audio" +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index aa0fc47647..b4753fbb77 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -865,6 +865,7 @@ extern const FFCodec ff_hevc_videotoolbox_encoder; + extern const FFCodec ff_hevc_vulkan_encoder; + extern const FFCodec ff_libkvazaar_encoder; + extern const FFCodec ff_mjpeg_cuvid_decoder; ++extern const FFCodec ff_mjpeg_mmal_decoder; + extern const FFCodec ff_mjpeg_qsv_encoder; + extern const FFCodec ff_mjpeg_qsv_decoder; + extern const FFCodec ff_mjpeg_vaapi_encoder; +@@ -884,6 +885,7 @@ extern const FFCodec ff_vc1_cuvid_decoder; + extern const FFCodec ff_vp8_cuvid_decoder; + extern const FFCodec ff_vp8_mediacodec_decoder; + extern const FFCodec ff_vp8_mediacodec_encoder; ++extern const FFCodec ff_vp8_mmal_decoder; + extern const FFCodec ff_vp8_qsv_decoder; + extern const FFCodec ff_vp8_v4l2m2m_encoder; + extern const FFCodec ff_vp8_vaapi_encoder; +@@ -894,6 +896,7 @@ extern const FFCodec ff_vp9_qsv_decoder; + extern const FFCodec ff_vp9_vaapi_encoder; + extern const FFCodec ff_vp9_qsv_encoder; + extern const FFCodec ff_vvc_qsv_decoder; ++extern const FFCodec ff_wmv3_mmal_decoder; + + // null codecs + extern const FFCodec ff_vnull_decoder; +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index 44f2916413..338fd33c9f 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -388,15 +388,24 @@ static av_cold int ffmmal_init_decoder(AVCodecContext *avctx) + format_in = decoder->input[0]->format; + format_in->type = MMAL_ES_TYPE_VIDEO; + switch (avctx->codec_id) { ++ case AV_CODEC_ID_MJPEG: ++ format_in->encoding = MMAL_ENCODING_MJPEG; ++ break; + case AV_CODEC_ID_MPEG2VIDEO: + format_in->encoding = MMAL_ENCODING_MP2V; + break; + case AV_CODEC_ID_MPEG4: + format_in->encoding = MMAL_ENCODING_MP4V; + break; ++ case AV_CODEC_ID_VP8: ++ format_in->encoding = MMAL_ENCODING_VP8; ++ break; + case AV_CODEC_ID_VC1: + format_in->encoding = MMAL_ENCODING_WVC1; + break; ++ case AV_CODEC_ID_WMV3: // may be not enabled ++ format_in->encoding = MMAL_ENCODING_WMV3; ++ break; + case AV_CODEC_ID_H264: + default: + format_in->encoding = MMAL_ENCODING_H264; +@@ -825,6 +834,20 @@ static const AVCodecHWConfigInternal *const mmal_hw_configs[] = { + NULL + }; + ++AVHWAccel ff_vp8_mmal_hwaccel = { ++ .name = "vp8_mmal", ++ .type = AVMEDIA_TYPE_VIDEO, ++ .id = AV_CODEC_ID_VP8, ++ .pix_fmt = AV_PIX_FMT_MMAL, ++}; ++ ++AVHWAccel ff_wmv3_mmal_hwaccel = { ++ .name = "wmv3_mmal", ++ .type = AVMEDIA_TYPE_VIDEO, ++ .id = AV_CODEC_ID_WMV3, ++ .pix_fmt = AV_PIX_FMT_MMAL, ++}; ++ + static const AVOption options[]={ + {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, + {"extra_decoder_buffers", "extra MMAL internal buffered frames", offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, +@@ -857,6 +880,9 @@ static const AVClass ffmmal_dec_class = { + }; + + FFMMAL_DEC(h264, AV_CODEC_ID_H264) ++FFMMAL_DEC(mjpeg, AV_CODEC_ID_MJPEG) + FFMMAL_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO) + FFMMAL_DEC(mpeg4, AV_CODEC_ID_MPEG4) + FFMMAL_DEC(vc1, AV_CODEC_ID_VC1) ++FFMMAL_DEC(vp8, AV_CODEC_ID_VP8) ++FFMMAL_DEC(wmv3, AV_CODEC_ID_WMV3) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch b/patches/7.1/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch new file mode 100644 index 0000000..66796ee --- /dev/null +++ b/patches/7.1/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch @@ -0,0 +1,83 @@ +From 54e3f83286b5baab1e93118196feca0d2e51314e Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 17 Nov 2017 14:54:23 +0800 +Subject: [PATCH 10/34] mmal: add option copy_frame to support retrieving sw + frames w/o copy + +mmal buffer->data is already in host memory. AFAIK decoders implemented in omx must +be configured to output frames to either memory or something directly used by renderer, +for example mediacodec surface, mmal buffer and omxil eglimage. +test result: big buck bunny 1080p fps increases from about 100 to 110 if copy_frame is +turned off +--- + libavcodec/mmaldec.c | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c +index 338fd33c9f..8d81d3ada7 100644 +--- a/libavcodec/mmaldec.c ++++ b/libavcodec/mmaldec.c +@@ -72,6 +72,7 @@ typedef struct MMALDecodeContext { + AVClass *av_class; + int extra_buffers; + int extra_decoder_buffers; ++ int copy_frame; + + MMAL_COMPONENT_T *decoder; + MMAL_QUEUE_T *queue_decoded_frames; +@@ -148,7 +149,6 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef *pool, + atomic_fetch_add_explicit(&ref->pool->refcount, 1, memory_order_relaxed); + mmal_buffer_header_acquire(buffer); + +- frame->format = AV_PIX_FMT_MMAL; + frame->data[3] = (uint8_t *)ref->buffer; + return 0; + } +@@ -653,20 +653,34 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, + + if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) + goto done; ++ frame->format = AV_PIX_FMT_MMAL; + } else { + int w = FFALIGN(avctx->width, 32); + int h = FFALIGN(avctx->height, 16); + uint8_t *src[4]; + int linesize[4]; + +- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) +- goto done; ++ if (ctx->copy_frame) { ++ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) ++ goto done; + + av_image_fill_arrays(src, linesize, + buffer->data + buffer->type->video.offset[0], + avctx->pix_fmt, w, h, 1); + av_image_copy2(frame->data, frame->linesize, src, linesize, + avctx->pix_fmt, avctx->width, avctx->height); ++ } else { ++ if ((ret = ff_decode_frame_props(avctx, frame)) < 0) ++ goto done; ++ /* buffer->type->video.offset/pitch[i]; is always 0 */ ++ av_image_fill_arrays(src, linesize, ++ buffer->data + buffer->type->video.offset[0], ++ avctx->pix_fmt, w, h, 1); ++ if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0) ++ goto done; ++ memcpy(frame->data, src, sizeof(src)); ++ memcpy(frame->linesize, linesize, sizeof(linesize)); ++ } + } + + frame->sample_aspect_ratio = avctx->sample_aspect_ratio; +@@ -851,6 +865,7 @@ AVHWAccel ff_wmv3_mmal_hwaccel = { + static const AVOption options[]={ + {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, + {"extra_decoder_buffers", "extra MMAL internal buffered frames", offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, ++ {"copy_frame", "copy deocded data to avframe", offsetof(MMALDecodeContext, copy_frame), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 256, 0}, + {NULL} + }; + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0011-videotoolbox-remove-opengl-compatibility-attribute.patch b/patches/7.1/0011-videotoolbox-remove-opengl-compatibility-attribute.patch new file mode 100644 index 0000000..1ffdfad --- /dev/null +++ b/patches/7.1/0011-videotoolbox-remove-opengl-compatibility-attribute.patch @@ -0,0 +1,32 @@ +From bbed7e552a937c6ee5383e4d07f37a065de71ead Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 15 Dec 2017 11:34:06 +0800 +Subject: [PATCH 11/34] videotoolbox: remove opengl compatibility attribute + +1. a cvpixelbuffer backed by iosurface can always be converted to an opengl texture, using CGLTexImageIOSurface2D for macOS, and undocumented api texImageIOSurface(which is internally used by public api CVOpenGLESTextureCacheCreateTextureFromImage) for iOS4.0+. +2. enabling the attribute can slow down decoding speed a lot. I tested many video clips on my macbook air. for example: ffmpeg -ss 00:00:00 -t 00:03:00 -hwaccel videotoolbox -an -i big_buck_bunny_1080p_h264.mov -f null ->/dev/null, result with the attribute +enabled: frame= 2082 fps= 85 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=7.34x +disabled: frame= 2031 fps=104 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A speed=9.22x +--- + libavcodec/videotoolbox.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c +index c7e867e7f8..9a8ea11d54 100644 +--- a/libavcodec/videotoolbox.c ++++ b/libavcodec/videotoolbox.c +@@ -793,11 +793,6 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, + CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); +-#if TARGET_OS_IPHONE +- CFDictionarySetValue(buffer_attributes, kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue); +-#else +- CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfaceOpenGLTextureCompatibilityKey, kCFBooleanTrue); +-#endif + + CFRelease(io_surface_properties); + CFRelease(cv_pix_fmt); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0012-configure-do-not-filter-libpath-for-msvc.patch b/patches/7.1/0012-configure-do-not-filter-libpath-for-msvc.patch new file mode 100644 index 0000000..818f62a --- /dev/null +++ b/patches/7.1/0012-configure-do-not-filter-libpath-for-msvc.patch @@ -0,0 +1,24 @@ +From 8bef8d1a7a1dd619f91795a01e86f1c4a314f3bf Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 30 Mar 2018 10:46:43 +0800 +Subject: [PATCH 12/34] configure: do not filter -libpath for msvc + +--- + configure | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure b/configure +index 4fbb2827c5..c38632adb1 100755 +--- a/configure ++++ b/configure +@@ -4846,6 +4846,7 @@ msvc_common_flags(){ + -lz) echo zlib.lib ;; + -lx264) echo libx264.lib ;; + -lstdc++) ;; ++ -libpath:*|-LIBPATH:*)echo $flag ;; + -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; + -L*) echo -libpath:${flag#-L} ;; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0013-configure-enable-icf.patch b/patches/7.1/0013-configure-enable-icf.patch new file mode 100644 index 0000000..e3e3944 --- /dev/null +++ b/patches/7.1/0013-configure-enable-icf.patch @@ -0,0 +1,26 @@ +From da0bff2cccb9e6e9017bc4f1bba9076d2d21fc11 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 11 Sep 2018 23:16:49 +0800 +Subject: [PATCH 13/34] configure: enable icf + +--- + configure | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/configure b/configure +index c38632adb1..894142edaa 100755 +--- a/configure ++++ b/configure +@@ -7556,6 +7556,9 @@ test_cc -mno-red-zone < +Date: Sun, 14 Apr 2019 11:42:42 +0800 +Subject: [PATCH 14/34] configure: suppor static build via clang-cl + +--- + configure | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 894142edaa..801625553b 100755 +--- a/configure ++++ b/configure +@@ -5893,7 +5893,15 @@ case $target_os in + SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' + SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)' + enabled x86_64 && objformat="win64" || objformat="win32" +- ranlib=: ++ # ranlib is required by llvm toolchain, clang-cl is detected as msvc ++ [ "$toolchain" = msvc ] && { ++ ranlib=: ++ } || { ++ LIBPREF= # patch win clang static lib ++ LIBSUF=.lib ++ LD_LIB='%.lib' ++ SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' ++ } + enable dos_paths + ;; + cygwin*) +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch b/patches/7.1/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch new file mode 100644 index 0000000..af2c4c4 --- /dev/null +++ b/patches/7.1/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch @@ -0,0 +1,255 @@ +From d1bdfa99404c7973f03135d23667f33394c6aee3 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Wed, 12 Jun 2019 10:43:50 +0800 +Subject: [PATCH 15/34] nvenc: use runtime api version to work with old drivers + +the document recommends to use build version, so using latest nvenc +headers requires latest driver version. But api and abi change rarely, +so requesting runtime version should work, and does work for my tests. +--- + libavcodec/nvenc.c | 79 +++++++++++++++++++++++++++++----------------- + libavcodec/nvenc.h | 3 ++ + 2 files changed, 53 insertions(+), 29 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index 2cce478be0..5f80e4663e 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -314,20 +314,35 @@ static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level) + av_log(avctx, level, "The minimum required Nvidia driver for nvenc is %s or newer\n", minver); + } + ++static inline uint32_t struct_ver_rt(NvencContext* ctx, uint32_t struct_ver) ++{ ++ return ((uint32_t)ctx->apiver_rt | ((struct_ver)<<16) | (0x7 << 28)); ++} ++ ++static inline uint32_t api_ver(uint32_t major_ver, uint32_t minor_ver) ++{ ++ return major_ver | (minor_ver << 24); ++} ++ + static av_cold int nvenc_load_libraries(AVCodecContext *avctx) + { + NvencContext *ctx = avctx->priv_data; + NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; + NVENCSTATUS err; + uint32_t nvenc_max_ver; ++ uint32_t nvenc_max_major; ++ uint32_t nvenc_max_minor; ++ uint32_t func_ver = NV_ENCODE_API_FUNCTION_LIST_VER; + int ret; +- + ret = cuda_load_functions(&dl_fn->cuda_dl, avctx); +- if (ret < 0) ++ if (ret < 0) { ++ av_log(avctx, AV_LOG_ERROR, "cuda_load_functions error"); + return ret; ++ } + + ret = nvenc_load_functions(&dl_fn->nvenc_dl, avctx); + if (ret < 0) { ++ av_log(avctx, AV_LOG_ERROR, "nvenc_load_functions error"); + nvenc_print_driver_requirement(avctx, AV_LOG_ERROR); + return ret; + } +@@ -335,19 +350,25 @@ static av_cold int nvenc_load_libraries(AVCodecContext *avctx) + err = dl_fn->nvenc_dl->NvEncodeAPIGetMaxSupportedVersion(&nvenc_max_ver); + if (err != NV_ENC_SUCCESS) + return nvenc_print_error(avctx, err, "Failed to query nvenc max version"); +- +- av_log(avctx, AV_LOG_VERBOSE, "Loaded Nvenc version %d.%d\n", nvenc_max_ver >> 4, nvenc_max_ver & 0xf); ++ nvenc_max_major = nvenc_max_ver >> 4; ++ nvenc_max_minor = nvenc_max_ver & 0xf; ++ //ctx->apiver_rt = NVENCAPI_VERSION; ++ ctx->apiver_rt = api_ver(nvenc_max_major, nvenc_max_minor); ++ ctx->config_ver_rt = struct_ver_rt(ctx, 7) | (1<<31); /*NV_ENC_CONFIG_VER */ ++ if (ctx->apiver_rt < api_ver(8, 1)) ++ ctx->config_ver_rt = struct_ver_rt(ctx, 6) | (1<<31); ++ func_ver = struct_ver_rt(ctx, 2); ++ av_log(avctx, AV_LOG_INFO, "Loaded Nvenc version %d.%d\n", nvenc_max_major, nvenc_max_minor); + + if ((NVENCAPI_MAJOR_VERSION << 4 | NVENCAPI_MINOR_VERSION) > nvenc_max_ver) { +- av_log(avctx, AV_LOG_ERROR, "Driver does not support the required nvenc API version. " ++ av_log(avctx, AV_LOG_WARNING, "Driver does not support the required nvenc API version. " + "Required: %d.%d Found: %d.%d\n", + NVENCAPI_MAJOR_VERSION, NVENCAPI_MINOR_VERSION, +- nvenc_max_ver >> 4, nvenc_max_ver & 0xf); +- nvenc_print_driver_requirement(avctx, AV_LOG_ERROR); +- return AVERROR(ENOSYS); ++ nvenc_max_major, nvenc_max_minor); ++ nvenc_print_driver_requirement(avctx, AV_LOG_WARNING); ++ //return AVERROR(ENOSYS); + } +- +- dl_fn->nvenc_funcs.version = NV_ENCODE_API_FUNCTION_LIST_VER; ++ dl_fn->nvenc_funcs.version = func_ver; + + err = dl_fn->nvenc_dl->NvEncodeAPICreateInstance(&dl_fn->nvenc_funcs); + if (err != NV_ENC_SUCCESS) +@@ -388,8 +409,8 @@ static av_cold int nvenc_open_session(AVCodecContext *avctx) + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs; + NVENCSTATUS ret; + +- params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; +- params.apiVersion = NVENCAPI_VERSION; ++ params.version = struct_ver_rt(ctx, 1); ++ params.apiVersion = ctx->apiver_rt; + if (ctx->d3d11_device) { + params.device = ctx->d3d11_device; + params.deviceType = NV_ENC_DEVICE_TYPE_DIRECTX; +@@ -450,7 +471,7 @@ static int nvenc_check_cap(AVCodecContext *avctx, NV_ENC_CAPS cap) + NV_ENC_CAPS_PARAM params = { 0 }; + int ret, val = 0; + +- params.version = NV_ENC_CAPS_PARAM_VER; ++ params.version = struct_ver_rt(ctx, 1);//NV_ENC_CAPS_PARAM_VER; + params.capsToQuery = cap; + + ret = p_nvenc->nvEncGetEncodeCaps(ctx->nvencoder, ctx->init_encode_params.encodeGUID, ¶ms, &val); +@@ -840,7 +861,7 @@ static av_cold void set_constqp(AVCodecContext *avctx) + #endif + + rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; +- ++ /*rc->reservedBitField1 = 0;*/ + if (ctx->init_qp_p >= 0) { + rc->constQP.qpInterP = ctx->init_qp_p; + if (ctx->init_qp_i >= 0 && ctx->init_qp_b >= 0) { +@@ -1623,16 +1644,16 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + int res = 0; + int dw, dh; + +- ctx->encode_config.version = NV_ENC_CONFIG_VER; +- ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; ++ ctx->encode_config.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; ++ ctx->init_encode_params.version = struct_ver_rt(ctx, 5) | (1<<31);//NV_ENC_INITIALIZE_PARAMS_VER; + + ctx->init_encode_params.encodeHeight = avctx->height; + ctx->init_encode_params.encodeWidth = avctx->width; + + ctx->init_encode_params.encodeConfig = &ctx->encode_config; + +- preset_config.version = NV_ENC_PRESET_CONFIG_VER; +- preset_config.presetCfg.version = NV_ENC_CONFIG_VER; ++ preset_config.version = struct_ver_rt(ctx, 4) | (1<<31);// NV_ENC_PRESET_CONFIG_VER; ++ preset_config.presetCfg.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; + + #ifdef NVENC_HAVE_NEW_PRESETS + ctx->init_encode_params.tuningInfo = ctx->tuning_info; +@@ -1658,7 +1679,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + + memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); + +- ctx->encode_config.version = NV_ENC_CONFIG_VER; ++ ctx->encode_config.version = ctx->config_ver_rt;//NV_ENC_CONFIG_VER; + + compute_dar(avctx, &dw, &dh); + ctx->init_encode_params.darHeight = dh; +@@ -1833,7 +1854,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) + + NVENCSTATUS nv_status; + NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; +- allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; ++ allocOut.version = struct_ver_rt(ctx, 1);//NV_ENC_CREATE_BITSTREAM_BUFFER_VER; + + if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) { + ctx->surfaces[idx].in_ref = av_frame_alloc(); +@@ -1849,7 +1870,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) + return AVERROR(EINVAL); + } + +- allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; ++ allocSurf.version = struct_ver_rt(ctx, 1);//NV_ENC_CREATE_INPUT_BUFFER_VER; + allocSurf.width = avctx->width; + allocSurf.height = avctx->height; + allocSurf.bufferFmt = ctx->surfaces[idx].format; +@@ -1937,7 +1958,7 @@ static av_cold int nvenc_setup_extradata(AVCodecContext *avctx) + char tmpHeader[NV_MAX_SEQ_HDR_LEN]; + + NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; +- payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; ++ payload.version = struct_ver_rt(ctx, 1);//NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; + + payload.spsppsBuffer = tmpHeader; + payload.inBufferSize = sizeof(tmpHeader); +@@ -1969,7 +1990,7 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) + + /* the encoder has to be flushed before it can be closed */ + if (ctx->nvencoder) { +- NV_ENC_PIC_PARAMS params = { .version = NV_ENC_PIC_PARAMS_VER, ++ NV_ENC_PIC_PARAMS params = { .version = struct_ver_rt(ctx, 4) | (1<<31),// NV_ENC_PIC_PARAMS_VER, + .encodePicFlags = NV_ENC_PIC_FLAG_EOS }; + + res = nvenc_push_context(avctx); +@@ -2193,7 +2214,7 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame) + if (idx < 0) + return idx; + +- reg.version = NV_ENC_REGISTER_RESOURCE_VER; ++ reg.version = struct_ver_rt(ctx, 3);// NV_ENC_REGISTER_RESOURCE_VER; + reg.width = frames_ctx->width; + reg.height = frames_ctx->height; + reg.pitch = frame->linesize[0]; +@@ -2248,7 +2269,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, + return res; + + if (!ctx->registered_frames[reg_idx].mapped) { +- ctx->registered_frames[reg_idx].in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER; ++ ctx->registered_frames[reg_idx].in_map.version = struct_ver_rt(ctx, 4);// NV_ENC_MAP_INPUT_RESOURCE_VER; + ctx->registered_frames[reg_idx].in_map.registeredResource = ctx->registered_frames[reg_idx].regptr; + nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &ctx->registered_frames[reg_idx].in_map); + if (nv_status != NV_ENC_SUCCESS) { +@@ -2268,7 +2289,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, + } else { + NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 }; + +- lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER; ++ lockBufferParams.version = struct_ver_rt(ctx, 1);//NV_ENC_LOCK_INPUT_BUFFER_VER; + lockBufferParams.inputBuffer = nvenc_frame->input_surface; + + nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams); +@@ -2469,7 +2490,7 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur + + enum AVPictureType pict_type; + +- lock_params.version = NV_ENC_LOCK_BITSTREAM_VER; ++ lock_params.version = struct_ver_rt(ctx, 1);//NV_ENC_LOCK_BITSTREAM_VER; + + lock_params.doNotWait = 0; + lock_params.outputBitstream = tmpoutsurf->output_surface; +@@ -2692,7 +2713,7 @@ static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame) + int reconfig_bitrate = 0, reconfig_dar = 0; + int dw, dh; + +- params.version = NV_ENC_RECONFIGURE_PARAMS_VER; ++ params.version = struct_ver_rt(ctx, 1) | (1<<31);//NV_ENC_RECONFIGURE_PARAMS_VER; + params.reInitEncodeParams = ctx->init_encode_params; + + compute_dar(avctx, &dw, &dh); +@@ -2785,7 +2806,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; + + NV_ENC_PIC_PARAMS pic_params = { 0 }; +- pic_params.version = NV_ENC_PIC_PARAMS_VER; ++ pic_params.version = struct_ver_rt(ctx, 4) | (1<<31);//NV_ENC_PIC_PARAMS_VER; + + if ((!ctx->cu_context && !ctx->d3d11_device) || !ctx->nvencoder) + return AVERROR(EINVAL); +diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h +index 0130b99369..5696f712ff 100644 +--- a/libavcodec/nvenc.h ++++ b/libavcodec/nvenc.h +@@ -184,6 +184,9 @@ typedef struct NvencContext + { + AVClass *avclass; + ++ uint32_t apiver_rt; ++ uint32_t config_ver_rt; ++ + NvencDynLoadFunctions nvenc_dload_funcs; + + NV_ENC_INITIALIZE_PARAMS init_encode_params; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch b/patches/7.1/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch new file mode 100644 index 0000000..a0c1209 --- /dev/null +++ b/patches/7.1/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch @@ -0,0 +1,34 @@ +From 70c06da1ed5ff5d341266ca0e0dab12b89f4c99d Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 5 Jun 2020 14:05:42 +0800 +Subject: [PATCH 16/34] nvenc: check runtime 9.1 function ptrs before use + +--- + libavcodec/nvenc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index 5f80e4663e..986b2e759b 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -167,7 +167,7 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err, + NvencContext *ctx = avctx->priv_data; + NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs; + +- if (p_nvenc && ctx->nvencoder) ++ if (p_nvenc && ctx->nvencoder && p_nvenc->nvEncGetLastErrorString) + details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder); + #endif + +@@ -1785,7 +1785,7 @@ FF_ENABLE_DEPRECATION_WARNINGS + } + + #ifdef NVENC_HAVE_CUSTREAM_PTR +- if (ctx->cu_context) { ++ if (ctx->cu_context && p_nvenc->nvEncSetIOCudaStreams) { + nv_status = p_nvenc->nvEncSetIOCudaStreams(ctx->nvencoder, &ctx->cu_stream, &ctx->cu_stream); + if (nv_status != NV_ENC_SUCCESS) { + nvenc_pop_context(avctx); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch b/patches/7.1/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch new file mode 100644 index 0000000..7365013 --- /dev/null +++ b/patches/7.1/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch @@ -0,0 +1,37 @@ +From e2f3b43ce78367d9883f3ce3f26ab12238398f58 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 3 Jul 2020 14:09:54 +0800 +Subject: [PATCH 17/34] nvenc: check sdk 10.0 ptrs at runtime + +--- + libavcodec/nvenc.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index 986b2e759b..41784274ed 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -1663,17 +1663,18 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) + else if (ctx->flags & NVENC_LOWLATENCY) + ctx->init_encode_params.tuningInfo = NV_ENC_TUNING_INFO_LOW_LATENCY; + ++ if (p_nvenc->nvEncGetEncodePresetConfigEx) + nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder, + ctx->init_encode_params.encodeGUID, + ctx->init_encode_params.presetGUID, + ctx->init_encode_params.tuningInfo, + &preset_config); +-#else ++ else ++#endif + nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, + ctx->init_encode_params.encodeGUID, + ctx->init_encode_params.presetGUID, + &preset_config); +-#endif + if (nv_status != NV_ENC_SUCCESS) + return nvenc_print_error(avctx, nv_status, "Cannot get the preset configuration"); + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch b/patches/7.1/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch new file mode 100644 index 0000000..d244621 --- /dev/null +++ b/patches/7.1/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch @@ -0,0 +1,34 @@ +From aa2038775fdd8fd5c56879841ad534730d645f6c Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 9 Aug 2020 23:35:08 +0800 +Subject: [PATCH 18/34] lavfi/atempo: fix large tempo(>4) crash, lower min + +--- + libavfilter/af_atempo.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c +index 3b03caa4d0..a6a021b000 100644 +--- a/libavfilter/af_atempo.c ++++ b/libavfilter/af_atempo.c +@@ -154,7 +154,7 @@ typedef struct ATempoContext { + uint64_t nsamples_out; + } ATempoContext; + +-#define YAE_ATEMPO_MIN 0.5 ++#define YAE_ATEMPO_MIN 0 + #define YAE_ATEMPO_MAX 100.0 + + #define OFFSET(x) offsetof(ATempoContext, x) +@@ -442,7 +442,7 @@ static int yae_load_data(ATempoContext *atempo, + } + + // samples are not expected to be skipped, unless tempo is greater than 2: +- av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); ++ //av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); + + while (atempo->position[0] < stop_here && src < src_end) { + int src_samples = (src_end - src) / atempo->stride; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0019-flv-support-hevc-opus.patch b/patches/7.1/0019-flv-support-hevc-opus.patch new file mode 100644 index 0000000..b118417 --- /dev/null +++ b/patches/7.1/0019-flv-support-hevc-opus.patch @@ -0,0 +1,112 @@ +From 5a642855c10b47d27be3d9d474928fd62d0b4ab4 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Mon, 27 Sep 2021 17:35:17 +0800 +Subject: [PATCH 19/34] flv: support hevc, opus + +--- + libavformat/flv.h | 2 ++ + libavformat/flvdec.c | 17 ++++++++++++++++- + libavformat/flvenc.c | 4 ++++ + 3 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/libavformat/flv.h b/libavformat/flv.h +index f710963b92..8e72d62a5f 100644 +--- a/libavformat/flv.h ++++ b/libavformat/flv.h +@@ -105,6 +105,7 @@ enum { + FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET, + FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET, + FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET, ++ FLV_CODECID_OPUS = 13<< FLV_AUDIO_CODECID_OFFSET, + }; + + enum { +@@ -116,6 +117,7 @@ enum { + FLV_CODECID_H264 = 7, + FLV_CODECID_REALH263= 8, + FLV_CODECID_MPEG4 = 9, ++ FLV_CODECID_HEVC = 12, + }; + + enum { +diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c +index 1fb3e0cd3f..2326dcc1da 100644 +--- a/libavformat/flvdec.c ++++ b/libavformat/flvdec.c +@@ -263,6 +263,10 @@ static int flv_same_audio_codec(AVCodecParameters *apar, int flags) + case FLV_CODECID_PCM_ALAW: + return apar->sample_rate == 8000 && + apar->codec_id == AV_CODEC_ID_PCM_ALAW; ++ case FLV_CODECID_OPUS: ++ return apar->sample_rate == 48000 && ++ apar->bits_per_coded_sample == 16 && ++ apar->codec_id == AV_CODEC_ID_OPUS; + default: + return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET); + } +@@ -321,6 +325,11 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, + apar->sample_rate = 8000; + apar->codec_id = AV_CODEC_ID_PCM_ALAW; + break; ++ case FLV_CODECID_OPUS: ++ apar->sample_rate = 48000; ++ apar->bits_per_coded_sample = 16; ++ apar->codec_id = AV_CODEC_ID_OPUS; ++ break; + default: + avpriv_request_sample(s, "Audio codec (%x)", + flv_codecid >> FLV_AUDIO_CODECID_OFFSET); +@@ -352,6 +361,8 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid) + return vpar->codec_id == AV_CODEC_ID_VP6A; + case FLV_CODECID_H264: + return vpar->codec_id == AV_CODEC_ID_H264; ++ case FLV_CODECID_HEVC: ++ return vpar->codec_id == AV_CODEC_ID_HEVC; + default: + return vpar->codec_tag == flv_codecid; + } +@@ -413,6 +424,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, + case FLV_CODECID_MPEG4: + par->codec_id = AV_CODEC_ID_MPEG4; + break; ++ case FLV_CODECID_HEVC: ++ par->codec_id = AV_CODEC_ID_HEVC; ++ vstreami->need_parsing = AVSTREAM_PARSE_NONE; ++ break; + default: + avpriv_request_sample(s, "Video codec (%x)", flv_codecid); + par->codec_tag = flv_codecid; +@@ -1464,7 +1479,7 @@ retry_duration: + } + + if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || +- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { ++ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) { + // sign extension + int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000; + pts = av_sat_add64(dts, cts); +diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c +index f34df61c0e..3719b61476 100644 +--- a/libavformat/flvenc.c ++++ b/libavformat/flvenc.c +@@ -69,6 +69,7 @@ static const AVCodecTag flv_audio_codec_ids[] = { + { AV_CODEC_ID_PCM_MULAW, FLV_CODECID_PCM_MULAW >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET }, ++ { AV_CODEC_ID_OPUS, FLV_CODECID_OPUS >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_NONE, 0 } + }; + +@@ -138,6 +139,9 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par) + if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters + return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | + FLV_SAMPLESSIZE_16BIT | FLV_STEREO; ++ else if (par->codec_id == AV_CODEC_ID_OPUS) // specs force these parameters ++ return FLV_CODECID_OPUS | FLV_SAMPLERATE_44100HZ | ++ FLV_SAMPLESSIZE_16BIT | FLV_STEREO; + else if (par->codec_id == AV_CODEC_ID_SPEEX) { + if (par->sample_rate != 16000) { + av_log(s, AV_LOG_ERROR, +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0020-msvc-fix-long-argument-list-error-on-windows.patch b/patches/7.1/0020-msvc-fix-long-argument-list-error-on-windows.patch new file mode 100644 index 0000000..d55cd52 --- /dev/null +++ b/patches/7.1/0020-msvc-fix-long-argument-list-error-on-windows.patch @@ -0,0 +1,50 @@ +From 6b620f66303722fa36f7822aa279b27aceb88341 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sat, 11 Dec 2021 18:08:43 +0800 +Subject: [PATCH 20/34] msvc: fix long argument list error on windows + +--- + compat/windows/makedef | 4 +++- + compat/windows/mslink | 11 ++++++++--- + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/compat/windows/makedef b/compat/windows/makedef +index add8222d13..cc1cdb2056 100755 +--- a/compat/windows/makedef ++++ b/compat/windows/makedef +@@ -48,7 +48,9 @@ trap 'rm -f -- $libname' EXIT + if [ -n "$AR" ]; then + $AR rcs ${libname} $@ >/dev/null + else +- lib.exe -out:${libname} $@ >/dev/null ++ echo $@ >objs${libname}.txt ++ lib.exe -out:${libname} @objs${libname}.txt >/dev/null ++ rm objs${libname}.txt + fi + if [ $? != 0 ]; then + echo "Could not create temporary library." >&2 +diff --git a/compat/windows/mslink b/compat/windows/mslink +index 6cab090071..d3202520cf 100755 +--- a/compat/windows/mslink ++++ b/compat/windows/mslink +@@ -1,9 +1,14 @@ + #!/bin/sh + ++cmdlist=$(echo "$@"|md5sum |cut -d " " -f 1).txt # including all arguments ++echo $@>$cmdlist ++ + LINK_EXE_PATH=$(dirname "$(command -v cl)")/link + if [ -x "$LINK_EXE_PATH" ]; then +- "$LINK_EXE_PATH" $@ ++ "$LINK_EXE_PATH" @$cmdlist + else +- link.exe $@ ++ link.exe @$cmdlist + fi +-exit $? ++ret=$? ++rm -f $cmdlist ++exit $ret +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch b/patches/7.1/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch new file mode 100644 index 0000000..837f7ee --- /dev/null +++ b/patches/7.1/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch @@ -0,0 +1,29 @@ +From 192a4c5cdb111be629afa0e6b84e617f83dc9de7 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 11 Jan 2022 16:17:56 +0800 +Subject: [PATCH 21/34] configure: rewrite flags from pkg-config for msvc in + msys + +cflags and libs from pkg-config is unix path, e.g. /c/msys64, but msvc +requires mixed form, e.g. c:/msys64 +--- + configure | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 801625553b..b913877828 100755 +--- a/configure ++++ b/configure +@@ -4849,7 +4849,8 @@ msvc_common_flags(){ + -libpath:*|-LIBPATH:*)echo $flag ;; + -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; +- -L*) echo -libpath:${flag#-L} ;; ++ -L*) [ -n "$MSYSTEM" ] && (echo $flag |sed 's,-L\/\([a-zA-Z]\)\(\/.*\),-libpath:\1:\2,' -) || echo -libpath:${flag#-L} ;; ++ -I*) [ -n "$MSYSTEM" ] && (echo $flag |sed 's,-L\/\([a-zA-Z]\)\(\/.*\),-I\1:\2,' -) || echo $flag ;; + -Wl,*) ;; + *) echo $flag ;; + esac +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0022-win-enable-windres-for-small-and-msvc.patch b/patches/7.1/0022-win-enable-windres-for-small-and-msvc.patch new file mode 100644 index 0000000..a8f69e5 --- /dev/null +++ b/patches/7.1/0022-win-enable-windres-for-small-and-msvc.patch @@ -0,0 +1,34 @@ +From 9f363fb42830e279a64dbd71f0635669d361de2c Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 13 Mar 2022 11:15:15 +0800 +Subject: [PATCH 22/34] win: enable windres for small and msvc + +--- + configure | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index b913877828..417e0130a6 100755 +--- a/configure ++++ b/configure +@@ -5828,7 +5828,7 @@ case $target_os in + # Cannot build both shared and static libs when using dllimport. + disable static + fi +- ! enabled small && test_cmd $windres --version && enable gnu_windres ++ test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -Wl,--large-address-aware + add_cppflags -DWIN32_LEAN_AND_MEAN + shlibdir_default="$bindir_default" +@@ -5879,7 +5879,7 @@ case $target_os in + # Cannot build both shared and static libs with MSVC or icl. + disable static + fi +- ! enabled small && test_cmd $windres --version && enable gnu_windres ++ test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -LARGEADDRESSAWARE + add_cppflags -DWIN32_LEAN_AND_MEAN + shlibdir_default="$bindir_default" +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0023-configure-add-extra-windresflags.patch b/patches/7.1/0023-configure-add-extra-windresflags.patch new file mode 100644 index 0000000..52903e8 --- /dev/null +++ b/patches/7.1/0023-configure-add-extra-windresflags.patch @@ -0,0 +1,76 @@ +From 31c6cf636f88af099dfe9dd2fe3807c5fc45bc0c Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 13 Mar 2022 14:38:23 +0800 +Subject: [PATCH 23/34] configure: add --extra-windresflags + +llvm windres requires more preprocess flags and target flags +--- + configure | 10 ++++++++++ + ffbuild/common.mak | 2 +- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 417e0130a6..378922c768 100755 +--- a/configure ++++ b/configure +@@ -417,6 +417,7 @@ Toolchain options: + --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] + --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] + --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS] ++ --extra-windresflags=EWFLAGS add EWFLAGS to WINDRESFLAGS [$WINDRESFLAGS] + --extra-libs=ELIBS add ELIBS [$ELIBS] + --extra-version=STRING version string suffix [] + --optflags=OPTFLAGS override optimization-related compiler flags +@@ -999,6 +1000,10 @@ add_host_ldflags(){ + append host_ldflags $($host_ldflags_filter "$@") + } + ++add_windresflags(){ ++ append WINDRESFLAGS "$@" ++} ++ + add_compat(){ + append compat_objs $1 + shift +@@ -4365,6 +4370,9 @@ for opt do + --extra-libs=*) + add_extralibs $optval + ;; ++ --extra-windresflags=*) ++ add_windresflags $optval ++ ;; + --disable-devices) + disable $INDEV_LIST $OUTDEV_LIST + ;; +@@ -5204,6 +5212,7 @@ add_cflags $extra_cflags + add_cxxflags $extra_cxxflags + add_objcflags $extra_objcflags + add_asflags $extra_cflags ++add_windresflags $extra_windresflags + + if test -n "$sysroot"; then + case "$cc_type" in +@@ -8124,6 +8133,7 @@ DOXYGEN=$doxygen + LDFLAGS=$LDFLAGS + LDEXEFLAGS=$LDEXEFLAGS + LDSOFLAGS=$LDSOFLAGS ++WINDRESFLAGS=$WINDRESFLAGS + SHFLAGS=$(echo $($ldflags_filter $SHFLAGS)) + ASMSTRIPFLAGS=$ASMSTRIPFLAGS + X86ASMFLAGS=$X86ASMFLAGS +diff --git a/ffbuild/common.mak b/ffbuild/common.mak +index 87a3ffd2b0..a93961d217 100644 +--- a/ffbuild/common.mak ++++ b/ffbuild/common.mak +@@ -104,7 +104,7 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS) + -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) + + %.o: %.rc +- $(WINDRES) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $< ++ $(WINDRES) $(WINDRESFLAGS) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $< + + %.i: %.c + $(CC) $(CCFLAGS) $(CC_E) $< +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch b/patches/7.1/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch new file mode 100644 index 0000000..9af36d2 --- /dev/null +++ b/patches/7.1/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch @@ -0,0 +1,379 @@ +From 6a768bc35c270b107a7f69f068f9e5c6ef792185 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Fri, 1 Jul 2022 16:03:06 +0800 +Subject: [PATCH 24/34] add h264-max-bit-depth to disable rarely used depths + +--- + configure | 6 ++++++ + libavcodec/h264chroma.c | 4 ++++ + libavcodec/h264dsp.c | 20 ++++++++++++++++++++ + libavcodec/h264idct.c | 8 ++++++++ + libavcodec/h264pred.c | 16 ++++++++++++++++ + libavcodec/h264qpel.c | 17 +++++++++++++++++ + libavcodec/x86/h264_intrapred_init.c | 2 ++ + libavcodec/x86/h264chroma_init.c | 3 ++- + libavcodec/x86/h264dsp_init.c | 2 ++ + 9 files changed, 77 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 378922c768..4c1b9192c2 100755 +--- a/configure ++++ b/configure +@@ -437,6 +437,7 @@ Advanced options (experts only): + disable buffer boundary checking in bitreaders + (faster, but may crash) + --sws-max-filter-size=N the max filter size swscale uses [$sws_max_filter_size_default] ++ --h264-max-bit-depth=N the max h264 decoding bit depth [$h264_max_bit_depth_default] + + Optimization options (experts only): + --disable-asm disable all assembly optimizations +@@ -2693,6 +2694,7 @@ CMDLINE_SET=" + env + extra_version + gas ++ h264_max_bit_depth + host_cc + host_cflags + host_extralibs +@@ -4149,6 +4151,9 @@ enable valgrind_backtrace + sws_max_filter_size_default=256 + set_default sws_max_filter_size + ++h264_max_bit_depth_default=10 ++set_default h264_max_bit_depth ++ + # internal components are enabled by default + enable $EXTRALIBS_LIST + +@@ -8227,6 +8232,7 @@ cat > $TMPH < 8 + #define BIT_DEPTH 16 + #include "h264chroma_template.c" + #undef BIT_DEPTH ++#endif + + #define SET_CHROMA(depth) \ + c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \ +@@ -41,7 +43,9 @@ + av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth) + { + if (bit_depth > 8 && bit_depth <= 16) { ++#if H264_MAX_BIT_DEPTH > 8 + SET_CHROMA(16); ++#endif + } else { + SET_CHROMA(8); + } +diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c +index 1ba936be1c..5c01f14ff8 100644 +--- a/libavcodec/h264dsp.c ++++ b/libavcodec/h264dsp.c +@@ -39,29 +39,39 @@ + #include "h264dsp_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264dsp_template.c" + #undef BIT_DEPTH ++#endif + + #define BIT_DEPTH 8 + #include "h264addpx_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH > 8 + #define BIT_DEPTH 16 + #include "h264addpx_template.c" + #undef BIT_DEPTH ++#endif + + av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + const int chroma_format_idc) +@@ -74,7 +84,9 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth) + + if (bit_depth > 8 && bit_depth <= 16) { ++#if (H264_MAX_BIT_DEPTH > 8) + ADDPX_DSP(16); ++#endif + } else { + ADDPX_DSP(8); + } +@@ -133,18 +145,26 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, + c->h264_loop_filter_strength= NULL; + + switch (bit_depth) { ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + H264_DSP(9); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + H264_DSP(10); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + H264_DSP(12); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + H264_DSP(14); + break; ++#endif + default: + av_assert0(bit_depth<=8); + H264_DSP(8); +diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c +index 6a771affe1..e871496ea4 100644 +--- a/libavcodec/h264idct.c ++++ b/libavcodec/h264idct.c +@@ -31,18 +31,26 @@ + #include "h264idct_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264idct_template.c" + #undef BIT_DEPTH ++#endif +diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c +index 25f9995a0b..33c5cf8a88 100644 +--- a/libavcodec/h264pred.c ++++ b/libavcodec/h264pred.c +@@ -37,21 +37,29 @@ + #include "h264pred_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264pred_template.c" + #undef BIT_DEPTH ++#endif + + static void pred4x4_127_dc_c(uint8_t *src, const uint8_t *topright, + ptrdiff_t _stride) +@@ -538,18 +546,26 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, + h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\ + + switch (bit_depth) { ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + H264_PRED(9) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + H264_PRED(10) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + H264_PRED(12) + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + H264_PRED(14) + break; ++#endif + default: + av_assert0(bit_depth<=8); + H264_PRED(8) +diff --git a/libavcodec/h264qpel.c b/libavcodec/h264qpel.c +index 65fef03304..5a91b695b1 100644 +--- a/libavcodec/h264qpel.c ++++ b/libavcodec/h264qpel.c +@@ -27,23 +27,32 @@ + #include "h264qpel_template.c" + #undef BIT_DEPTH + ++#if H264_MAX_BIT_DEPTH >= 9 + #define BIT_DEPTH 9 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 10 + #define BIT_DEPTH 10 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif ++ + #undef pixeltmp + + #define pixeltmp int32_t ++#if H264_MAX_BIT_DEPTH >= 12 + #define BIT_DEPTH 12 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + ++#if H264_MAX_BIT_DEPTH >= 14 + #define BIT_DEPTH 14 + #include "h264qpel_template.c" + #undef BIT_DEPTH ++#endif + + + av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth) +@@ -82,18 +91,26 @@ av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth) + default: + SET_QPEL(8); + break; ++#if H264_MAX_BIT_DEPTH >= 9 + case 9: + SET_QPEL(9); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 10 + case 10: + SET_QPEL(10); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 12 + case 12: + SET_QPEL(12); + break; ++#endif ++#if H264_MAX_BIT_DEPTH >= 14 + case 14: + SET_QPEL(14); + break; ++#endif + } + + #if ARCH_AARCH64 +diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c +index aa9bc721f0..0de899ca4b 100644 +--- a/libavcodec/x86/h264_intrapred_init.c ++++ b/libavcodec/x86/h264_intrapred_init.c +@@ -265,6 +265,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, + } + } + } else if (bit_depth == 10) { ++#if H264_MAX_BIT_DEPTH >= 10 + if (EXTERNAL_MMXEXT(cpu_flags)) { + h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; + h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; +@@ -328,5 +329,6 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, + h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx; + h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx; + } ++#endif /* H264_MAX_BIT_DEPTH >= 10 */ + } + } +diff --git a/libavcodec/x86/h264chroma_init.c b/libavcodec/x86/h264chroma_init.c +index 34934b6ad0..c0d6e13886 100644 +--- a/libavcodec/x86/h264chroma_init.c ++++ b/libavcodec/x86/h264chroma_init.c +@@ -79,7 +79,7 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) + c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext; + c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext; + } +- ++#if H264_MAX_BIT_DEPTH > 8 + if (EXTERNAL_MMXEXT(cpu_flags) && bit_depth > 8 && bit_depth <= 10) { + c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext; + c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext; +@@ -105,4 +105,5 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) + c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx; + c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx; + } ++#endif /* H264_MAX_BIT_DEPTH > 8 */ + } +diff --git a/libavcodec/x86/h264dsp_init.c b/libavcodec/x86/h264dsp_init.c +index dc8fc4f720..39999bd2d2 100644 +--- a/libavcodec/x86/h264dsp_init.c ++++ b/libavcodec/x86/h264dsp_init.c +@@ -275,6 +275,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, + c->h264_idct_dc_add = ff_h264_idct_dc_add_8_avx; + } + } else if (bit_depth == 10) { ++#if H264_MAX_BIT_DEPTH >= 10 + if (EXTERNAL_MMXEXT(cpu_flags)) { + #if ARCH_X86_32 && !HAVE_ALIGNED_STACK + c->h264_v_loop_filter_luma = ff_deblock_v_luma_10_mmxext; +@@ -362,6 +363,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, + c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx; + #endif /* HAVE_ALIGNED_STACK */ + } ++#endif /* H264_MAX_BIT_DEPTH >= 10 */ + } + #endif + } +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0025-wolfSSL-new-TLS-backend-patch.patch b/patches/7.1/0025-wolfSSL-new-TLS-backend-patch.patch new file mode 100644 index 0000000..6c53cbd --- /dev/null +++ b/patches/7.1/0025-wolfSSL-new-TLS-backend-patch.patch @@ -0,0 +1,410 @@ +From 41e5590c6a02820a4907ded38973679088a971d8 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 3 May 2022 00:03:18 +0800 +Subject: [PATCH 25/34] wolfSSL - new TLS backend patch + +https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233802.html +--- + configure | 20 ++-- + libavformat/Makefile | 1 + + libavformat/network.c | 6 + + libavformat/tls.h | 3 + + libavformat/tls_wolfssl.c | 245 ++++++++++++++++++++++++++++++++++++++ + 5 files changed, 267 insertions(+), 8 deletions(-) + create mode 100644 libavformat/tls_wolfssl.c + +diff --git a/configure b/configure +index 4c1b9192c2..2af59a3e7e 100755 +--- a/configure ++++ b/configure +@@ -208,7 +208,7 @@ External library support: + --enable-gmp enable gmp, needed for rtmp(t)e support + if openssl or librtmp is not used [no] + --enable-gnutls enable gnutls, needed for https support +- if openssl, libtls or mbedtls is not used [no] ++ if wolfssl, openssl, libtls or mbedtls is not used [no] + --disable-iconv disable iconv [autodetect] + --enable-jni enable JNI support [no] + --enable-ladspa enable LADSPA audio filtering [no] +@@ -283,7 +283,7 @@ External library support: + --enable-libtesseract enable Tesseract, needed for ocr filter [no] + --enable-libtheora enable Theora encoding via libtheora [no] + --enable-libtls enable LibreSSL (via libtls), needed for https support +- if openssl, gnutls or mbedtls is not used [no] ++ if wolfssl, openssl, gnutls or mbedtls is not used [no] + --enable-libtorch enable Torch as one DNN backend [no] + --enable-libtwolame enable MP2 encoding via libtwolame [no] + --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] +@@ -296,6 +296,8 @@ External library support: + --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] + --enable-libvvenc enable H.266/VVC encoding via vvenc [no] + --enable-libwebp enable WebP encoding via libwebp [no] ++ --enable-wolfssl enable WolfSSL), needed for https support ++ if openssl, gnutls, libtls or mbedtls is not used [no] + --enable-libx264 enable H.264 encoding via x264 [no] + --enable-libx265 enable HEVC encoding via x265 [no] + --enable-libxeve enable EVC encoding via libxeve [no] +@@ -317,7 +319,7 @@ External library support: + --disable-lzma disable lzma [autodetect] + --enable-decklink enable Blackmagic DeckLink I/O support [no] + --enable-mbedtls enable mbedTLS, needed for https support +- if openssl, gnutls or libtls is not used [no] ++ if wolfssl, openssl, gnutls or libtls is not used [no] + --enable-mediacodec enable Android MediaCodec support [no] + --enable-mediafoundation enable encoding via MediaFoundation [auto] + --disable-metal disable Apple Metal framework [autodetect] +@@ -326,7 +328,7 @@ External library support: + --enable-opencl enable OpenCL processing [no] + --enable-opengl enable OpenGL rendering [no] + --enable-openssl enable openssl, needed for https support +- if gnutls, libtls or mbedtls is not used [no] ++ if wolfssl, gnutls, libtls or mbedtls is not used [no] + --enable-pocketsphinx enable PocketSphinx, needed for asr filter [no] + --disable-sndio disable sndio support [autodetect] + --disable-schannel disable SChannel SSP, needed for TLS support on +@@ -1990,6 +1992,7 @@ EXTERNAL_LIBRARY_LIST=" + openssl + pocketsphinx + vapoursynth ++ wolfssl + " + + HWACCEL_AUTODETECT_LIBRARY_LIST=" +@@ -3800,13 +3803,13 @@ rtmpte_protocol_suggest="zlib" + rtmpts_protocol_select="ffrtmphttp_protocol https_protocol" + rtmpts_protocol_suggest="zlib" + rtp_protocol_select="udp_protocol" +-schannel_conflict="openssl gnutls libtls mbedtls" ++schannel_conflict="openssl gnutls libtls mbedtls wolfssl" + sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags" + sctp_protocol_select="network" +-securetransport_conflict="openssl gnutls libtls mbedtls" ++securetransport_conflict="openssl gnutls libtls mbedtls wolfssl" + srtp_protocol_select="rtp_protocol srtp" + tcp_protocol_select="network" +-tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls" ++tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls wolfssl" + tls_protocol_select="tcp_protocol" + udp_protocol_select="network" + udplite_protocol_select="network" +@@ -3829,7 +3832,7 @@ libsmbclient_protocol_deps="libsmbclient gplv3" + libsrt_protocol_deps="libsrt" + libsrt_protocol_select="network" + libssh_protocol_deps="libssh" +-libtls_conflict="openssl gnutls mbedtls" ++libtls_conflict="openssl gnutls mbedtls wolfssl" + libzmq_protocol_deps="libzmq" + libzmq_protocol_select="network" + +@@ -6889,6 +6892,7 @@ enabled decklink && { require_headers DeckLinkAPI.h && + enabled frei0r && require_headers "frei0r.h" + enabled gmp && require gmp gmp.h mpz_export -lgmp + enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init ++enabled wolfssl && require_pkg_config wolfssl wolfssl wolfssl/ssl.h wolfSSL_library_init + enabled jni && { [ $target_os = "android" ] && check_headers jni.h && enabled pthreads || die "ERROR: jni not found"; } + enabled ladspa && require_headers "ladspa.h dlfcn.h" + enabled lcms2 && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h cmsCreateContext +diff --git a/libavformat/Makefile b/libavformat/Makefile +index 7ca68a7036..dcc3dac87e 100644 +--- a/libavformat/Makefile ++++ b/libavformat/Makefile +@@ -705,6 +705,7 @@ TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o + TLS-OBJS-$(CONFIG_LIBTLS) += tls_libtls.o + TLS-OBJS-$(CONFIG_MBEDTLS) += tls_mbedtls.o + TLS-OBJS-$(CONFIG_OPENSSL) += tls_openssl.o ++TLS-OBJS-$(CONFIG_WOLFSSL) += tls_wolfssl.o + TLS-OBJS-$(CONFIG_SECURETRANSPORT) += tls_securetransport.o + TLS-OBJS-$(CONFIG_SCHANNEL) += tls_schannel.o + OBJS-$(CONFIG_TLS_PROTOCOL) += tls.o $(TLS-OBJS-yes) +diff --git a/libavformat/network.c b/libavformat/network.c +index 2eabd0c167..d794953358 100644 +--- a/libavformat/network.c ++++ b/libavformat/network.c +@@ -44,6 +44,9 @@ int ff_tls_init(void) + #if CONFIG_GNUTLS + ff_gnutls_init(); + #endif ++#if CONFIG_WOLFSSL ++ ff_wolfssl_init(); ++#endif + #endif + return 0; + } +@@ -57,6 +60,9 @@ void ff_tls_deinit(void) + #if CONFIG_GNUTLS + ff_gnutls_deinit(); + #endif ++#if CONFIG_WOLFSSL ++ ff_wolfssl_deinit(); ++#endif + #endif + } + +diff --git a/libavformat/tls.h b/libavformat/tls.h +index 6c6aa01a9a..0cfad1c82b 100644 +--- a/libavformat/tls.h ++++ b/libavformat/tls.h +@@ -55,6 +55,9 @@ typedef struct TLSShared { + + int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options); + ++void ff_wolfssl_init(void); ++void ff_wolfssl_deinit(void); ++ + void ff_gnutls_init(void); + void ff_gnutls_deinit(void); + +diff --git a/libavformat/tls_wolfssl.c b/libavformat/tls_wolfssl.c +new file mode 100644 +index 0000000000..23255c0f1b +--- /dev/null ++++ b/libavformat/tls_wolfssl.c +@@ -0,0 +1,245 @@ ++/* ++ * TLS/SSL Protocol ++ * Copyright (c) 2011 Martin Storsjo ++ * Copyright (c) 2018 samsamsam@o2.pl ++ * ++ * 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 ++ ++#include "avformat.h" ++#include "network.h" ++#include "os_support.h" ++#include "url.h" ++#include "tls.h" ++#include "libavutil/thread.h" ++ ++ ++#include ++#include ++ ++typedef struct TLSContext { ++ const AVClass *class; ++ TLSShared tls_shared; ++ WOLFSSL_CTX *ctx; ++ WOLFSSL *ssl; ++} TLSContext; ++ ++static AVMutex wolfssl_mutex = AV_MUTEX_INITIALIZER; ++static int wolfssl_init; ++ ++void ff_wolfssl_init(void) ++{ ++ ++ ff_mutex_lock(&wolfssl_mutex); ++ if (!wolfssl_init) { ++ wolfSSL_Init(); ++ } ++ wolfssl_init++; ++ ff_mutex_unlock(&wolfssl_mutex); ++} ++ ++void ff_wolfssl_deinit(void) ++{ ++ ff_mutex_lock(&wolfssl_mutex); ++ wolfssl_init--; ++ if (!wolfssl_init) { ++ wolfSSL_Cleanup(); ++ } ++ ff_mutex_unlock(&wolfssl_mutex); ++} ++ ++static int print_tls_error(URLContext *h, int ret, WOLFSSL *ssl) ++{ ++ char error_buffer[WOLFSSL_MAX_ERROR_SZ]; ++ av_log(h, AV_LOG_ERROR, "%i -> %s\n", wolfSSL_get_error(ssl,0), wolfSSL_ERR_error_string(wolfSSL_get_error(ssl,0), error_buffer)); ++ return AVERROR(EIO); ++} ++ ++static int tls_close(URLContext *h) ++{ ++ TLSContext *c = h->priv_data; ++ if (c->ssl) { ++ wolfSSL_shutdown(c->ssl); ++ wolfSSL_free(c->ssl); ++ } ++ if (c->ctx) ++ wolfSSL_CTX_free(c->ctx); ++ if (c->tls_shared.tcp) ++ ffurl_close(c->tls_shared.tcp); ++ //ff_wolfssl_deinit(); ++ return 0; ++} ++ ++static int wolfssl_recv_callback(WOLFSSL* ssl, char* buf, int sz, void* ctx) ++{ ++ URLContext *h = (URLContext*) ctx; ++ int ret = ffurl_read(h, buf, sz); ++ if (ret >= 0) ++ return ret; ++ if (ret == AVERROR_EXIT) ++ return WOLFSSL_CBIO_ERR_GENERAL; ++ errno = EIO; ++ return WOLFSSL_CBIO_ERR_GENERAL; ++} ++ ++static int wolfssl_send_callback(WOLFSSL* ssl, char* buf, int sz, void* ctx) ++{ ++ URLContext *h = (URLContext*) ctx; ++ int ret = ffurl_write(h, buf, sz); ++ if (ret >= 0) ++ return ret; ++ if (ret == AVERROR_EXIT) ++ return WOLFSSL_CBIO_ERR_GENERAL; ++ errno = EIO; ++ return WOLFSSL_CBIO_ERR_GENERAL; ++} ++ ++static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) ++{ ++ char error_buffer[WOLFSSL_MAX_ERROR_SZ]; ++ TLSContext *p = h->priv_data; ++ TLSShared *c = &p->tls_shared; ++ int ret; ++ ++ //ff_wolfssl_init(); ++ ++ if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0) ++ goto fail; ++ // Modified to compile with minimal wolfSSL library which only has client methods ++ //p->ctx = wolfSSL_CTX_new(c->listen ? wolfSSLv23_server_method() : wolfSSLv23_client_method()); // wolfTLSv1_1_client_method ++ p->ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); ++#ifndef NO_FILESYSTEM ++ if (!p->ctx) { ++ av_log(h, AV_LOG_ERROR, "%s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ if (c->ca_file) { ++ if (!wolfSSL_CTX_load_verify_locations(p->ctx, c->ca_file, NULL)) ++ av_log(h, AV_LOG_ERROR, "wolfSSL_CTX_load_verify_locations %s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ } ++ if (c->cert_file && !wolfSSL_CTX_use_certificate_chain_file(p->ctx, c->cert_file)) { ++ av_log(h, AV_LOG_ERROR, "Unable to load cert file %s: %s\n", ++ c->cert_file, wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ if (c->key_file && !wolfSSL_CTX_use_PrivateKey_file(p->ctx, c->key_file, WOLFSSL_FILETYPE_PEM)) { ++ av_log(h, AV_LOG_ERROR, "Unable to load key file %s: %s\n", ++ c->key_file, wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++#endif ++ ++ wolfSSL_CTX_set_verify(p->ctx, ++ c->verify ? WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT : ++ WOLFSSL_VERIFY_NONE, ++ NULL); ++ ++#ifdef HAVE_SNI ++ if (!c->listen && !c->numerichost && !wolfSSL_CTX_UseSNI(p->ctx, WOLFSSL_SNI_HOST_NAME, c->host, ++ (unsigned short)strlen(c->host))) { ++ av_log(h, AV_LOG_ERROR, "failed to configure server name indication (SNI) %s: %d -> %s\n", ++ c->host, wolfSSL_get_error(p->ssl,0), wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ } ++#endif ++ ++ wolfSSL_CTX_SetIORecv(p->ctx, wolfssl_recv_callback); ++ wolfSSL_CTX_SetIOSend(p->ctx, wolfssl_send_callback); ++ ++ p->ssl = wolfSSL_new(p->ctx); ++ if (!p->ssl) { ++ av_log(h, AV_LOG_ERROR, "%s\n", wolfSSL_ERR_error_string(wolfSSL_get_error(p->ssl,0), error_buffer)); ++ ret = AVERROR(EIO); ++ goto fail; ++ } ++ ++ wolfSSL_SetIOReadCtx(p->ssl, c->tcp); ++ wolfSSL_SetIOWriteCtx(p->ssl, c->tcp); ++ ++ // Modified to compile with minimal wolfSSL library which only has client methods ++ //ret = c->listen ? wolfSSL_accept(p->ssl) : wolfSSL_connect(p->ssl); ++ ret = wolfSSL_connect(p->ssl); ++ if (ret == 0) { ++ av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n"); ++ ret = AVERROR(EIO); ++ goto fail; ++ } else if (ret < 0) { ++ ret = print_tls_error(h, ret, p->ssl); ++ goto fail; ++ } ++ ++ return 0; ++fail: ++ tls_close(h); ++ return ret; ++} ++ ++static int tls_read(URLContext *h, uint8_t *buf, int size) ++{ ++ TLSContext *c = h->priv_data; ++ int ret = wolfSSL_read(c->ssl, buf, size); ++ if (ret > 0) ++ return ret; ++ if (ret == 0) ++ return AVERROR_EOF; ++ return print_tls_error(h, ret, c->ssl); ++} ++ ++static int tls_write(URLContext *h, const uint8_t *buf, int size) ++{ ++ TLSContext *c = h->priv_data; ++ int ret = wolfSSL_write(c->ssl, buf, size); ++ if (ret > 0) ++ return ret; ++ if (ret == 0) ++ return AVERROR_EOF; ++ return print_tls_error(h, ret, c->ssl); ++} ++ ++static int tls_get_file_handle(URLContext *h) ++{ ++ TLSContext *c = h->priv_data; ++ return ffurl_get_file_handle(c->tls_shared.tcp); ++} ++ ++static const AVOption options[] = { ++ TLS_COMMON_OPTIONS(TLSContext, tls_shared), ++ { NULL } ++}; ++ ++static const AVClass tls_class = { ++ .class_name = "tls", ++ .item_name = av_default_item_name, ++ .option = options, ++ .version = LIBAVUTIL_VERSION_INT, ++}; ++ ++const URLProtocol ff_tls_protocol = { ++ .name = "tls", ++ .url_open2 = tls_open, ++ .url_read = tls_read, ++ .url_write = tls_write, ++ .url_close = tls_close, ++ .url_get_file_handle = tls_get_file_handle, ++ .priv_data_size = sizeof(TLSContext), ++ .flags = URL_PROTOCOL_FLAG_NETWORK, ++ .priv_data_class = &tls_class, ++}; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch b/patches/7.1/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch new file mode 100644 index 0000000..3801b2c --- /dev/null +++ b/patches/7.1/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch @@ -0,0 +1,27 @@ +From e9e3f4ef5c6663563a048d96c08ff759032c9681 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 9 Feb 2023 18:08:11 +0800 +Subject: [PATCH 26/34] avformat/mpegts: index only keyframes to ensure + accurate seeks + +https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190507032623.80375-1-ffmpeg@tmm1.net/ +--- + libavformat/mpegts.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c +index 04565a2011..2c4a00847c 100644 +--- a/libavformat/mpegts.c ++++ b/libavformat/mpegts.c +@@ -3361,7 +3361,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, + av_packet_free(&pkt); + return AV_NOPTS_VALUE; + } +- if (pkt->dts != AV_NOPTS_VALUE && pkt->pos >= 0) { ++ if (pkt->dts != AV_NOPTS_VALUE && pkt->pos >= 0 && (pkt->flags & AV_PKT_FLAG_KEY)) { + ff_reduce_index(s, pkt->stream_index); + av_add_index_entry(s->streams[pkt->stream_index], pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); + if (pkt->stream_index == stream_index && pkt->pos >= *ppos) { +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0027-windows-shared-static-libs-in-one-build.patch b/patches/7.1/0027-windows-shared-static-libs-in-one-build.patch new file mode 100644 index 0000000..4675a99 --- /dev/null +++ b/patches/7.1/0027-windows-shared-static-libs-in-one-build.patch @@ -0,0 +1,55 @@ +From 060b64572ed7e3c4a75a5ae324a8b345b28ecb5e Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 15 Oct 2023 13:22:34 +0800 +Subject: [PATCH 27/34] windows: shared + static libs in one build + +av_export_avutil avpriv_vga16_font will result in LINK4217 warning when building ffmpeg.dll, and undefined dllimport avpriv_vga16_font error when linking exe +--- + configure | 8 +++++--- + libavutil/xga_font_data.h | 4 ++-- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/configure b/configure +index 2af59a3e7e..2a25390562 100755 +--- a/configure ++++ b/configure +@@ -5894,8 +5894,12 @@ case $target_os in + # for shared libs. + LD_LIB='%.lib' + # Cannot build both shared and static libs with MSVC or icl. +- disable static ++ #disable static # we can build shared and static libs. let user disable it explicitly ++ LIBPREF=lib #already defined. use lib as prefix to match windows system static lib name pattern(libcmt.lib, libucrt.lib etc.) ++ else ++ LIBPREF= # if only build static libs, fftools exes always link to .lib without lib prefix + fi ++ LIBSUF=.lib + test_cmd $windres --version && enable gnu_windres + enabled x86_32 && check_ldflags -LARGEADDRESSAWARE + add_cppflags -DWIN32_LEAN_AND_MEAN +@@ -5915,8 +5919,6 @@ case $target_os in + [ "$toolchain" = msvc ] && { + ranlib=: + } || { +- LIBPREF= # patch win clang static lib +- LIBSUF=.lib + LD_LIB='%.lib' + SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' + } +diff --git a/libavutil/xga_font_data.h b/libavutil/xga_font_data.h +index 69dc337120..decbf6e0c2 100644 +--- a/libavutil/xga_font_data.h ++++ b/libavutil/xga_font_data.h +@@ -29,7 +29,7 @@ + #include + #include "internal.h" + +-extern av_export_avutil const uint8_t avpriv_cga_font[2048]; +-extern av_export_avutil const uint8_t avpriv_vga16_font[4096]; ++extern const uint8_t avpriv_cga_font[2048]; ++extern const uint8_t avpriv_vga16_font[4096]; + + #endif /* AVUTIL_XGA_FONT_DATA_H */ +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch b/patches/7.1/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch new file mode 100644 index 0000000..92e32f8 --- /dev/null +++ b/patches/7.1/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch @@ -0,0 +1,62 @@ +From 3708a5da8e1081f4c073c4f4533db7b1995b6ef5 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Thu, 22 Dec 2022 10:39:29 +0800 +Subject: [PATCH 28/34] lavc/videotoolboxenc: add hevc main42210 and p210 + +supported by apple silicon +--- + libavcodec/videotoolboxenc.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c +index da7b291b03..9fce54e155 100644 +--- a/libavcodec/videotoolboxenc.c ++++ b/libavcodec/videotoolboxenc.c +@@ -115,6 +115,7 @@ static struct{ + + CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel; + CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel; ++ CFStringRef kVTProfileLevel_HEVC_Main42210_AutoLevel; + + CFStringRef kVTCompressionPropertyKey_RealTime; + CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha; +@@ -186,6 +187,7 @@ static void loadVTEncSymbols(void){ + + GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel, "HEVC_Main_AutoLevel"); + GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel, "HEVC_Main10_AutoLevel"); ++ GET_SYM(kVTProfileLevel_HEVC_Main42210_AutoLevel, "HEVC_Main10_AutoLevel"); + + GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime"); + GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha, +@@ -971,6 +973,11 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx, + *profile_level_val = + compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel; + break; ++ case AV_PROFILE_HEVC_REXT: ++ // only main42210 is supported, omit depth and chroma subsampling ++ *profile_level_val = ++ compat_keys.kVTProfileLevel_HEVC_Main42210_AutoLevel; ++ break; + } + + if (!*profile_level_val) { +@@ -2839,6 +2846,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_BGRA, + AV_PIX_FMT_P010LE, ++ AV_PIX_FMT_P210, + AV_PIX_FMT_NONE + }; + +@@ -2971,6 +2979,8 @@ static const AVOption hevc_options[] = { + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, INT_MAX, VE, .unit = "profile" }, + { "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, .unit = "profile" }, + { "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, .unit = "profile" }, ++ { "main42210","Main 4:2:2 10 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_REXT }, INT_MIN, INT_MAX, VE, .unit = "profile" }, ++ { "rext", "Main 4:2:2 10 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_REXT }, INT_MIN, INT_MAX, VE, .unit = "profile" }, + + { "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE }, + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch b/patches/7.1/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch new file mode 100644 index 0000000..04c6687 --- /dev/null +++ b/patches/7.1/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch @@ -0,0 +1,65 @@ +From cf76ffc24c14450da1d356693bce2f6116501e9c Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 11 Aug 2024 10:27:43 +0800 +Subject: [PATCH 29/34] Revert "avutil/timestamp: change precision of + av_ts_make_time_string()" + +This reverts commit 8c936e9b437aaed0ca10f3ec2edebf06cad6a5b5. +av_ts_make_time_string2 on android arm64 takes about 1s +--- + libavutil/timestamp.h | 4 +++- + tests/ref/fate/filter-metadata-scdet | 12 ++++++------ + tests/ref/fate/filter-metadata-silencedetect | 2 +- + 3 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/libavutil/timestamp.h b/libavutil/timestamp.h +index fa53a46b98..7e6da894df 100644 +--- a/libavutil/timestamp.h ++++ b/libavutil/timestamp.h +@@ -73,7 +73,9 @@ char *av_ts_make_time_string2(char *buf, int64_t ts, AVRational tb); + static inline char *av_ts_make_time_string(char *buf, int64_t ts, + const AVRational *tb) + { +- return av_ts_make_time_string2(buf, ts, *tb); ++ if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); ++ else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts); ++ return buf; + } + + /** +diff --git a/tests/ref/fate/filter-metadata-scdet b/tests/ref/fate/filter-metadata-scdet +index d385920fcd..ca5dbaaefc 100644 +--- a/tests/ref/fate/filter-metadata-scdet ++++ b/tests/ref/fate/filter-metadata-scdet +@@ -1,11 +1,11 @@ + pts=1620|tag:lavfi.scd.score=59.252|tag:lavfi.scd.mafd=60.175|tag:lavfi.scd.time=2.7 + pts=4140|tag:lavfi.scd.score=36.070|tag:lavfi.scd.mafd=44.209|tag:lavfi.scd.time=6.9 +-pts=5800|tag:lavfi.scd.score=55.819|tag:lavfi.scd.mafd=55.819|tag:lavfi.scd.time=9.666667 ++pts=5800|tag:lavfi.scd.score=55.819|tag:lavfi.scd.mafd=55.819|tag:lavfi.scd.time=9.66667 + pts=6720|tag:lavfi.scd.score=18.580|tag:lavfi.scd.mafd=22.505|tag:lavfi.scd.time=11.2 + pts=8160|tag:lavfi.scd.score=49.240|tag:lavfi.scd.mafd=49.444|tag:lavfi.scd.time=13.6 +-pts=9760|tag:lavfi.scd.score=51.497|tag:lavfi.scd.mafd=51.801|tag:lavfi.scd.time=16.266667 +-pts=14080|tag:lavfi.scd.score=34.165|tag:lavfi.scd.mafd=34.337|tag:lavfi.scd.time=23.466667 +-pts=15700|tag:lavfi.scd.score=58.310|tag:lavfi.scd.mafd=58.315|tag:lavfi.scd.time=26.166667 +-pts=18500|tag:lavfi.scd.score=16.504|tag:lavfi.scd.mafd=19.603|tag:lavfi.scd.time=30.833333 ++pts=9760|tag:lavfi.scd.score=51.497|tag:lavfi.scd.mafd=51.801|tag:lavfi.scd.time=16.2667 ++pts=14080|tag:lavfi.scd.score=34.165|tag:lavfi.scd.mafd=34.337|tag:lavfi.scd.time=23.4667 ++pts=15700|tag:lavfi.scd.score=58.310|tag:lavfi.scd.mafd=58.315|tag:lavfi.scd.time=26.1667 ++pts=18500|tag:lavfi.scd.score=16.504|tag:lavfi.scd.mafd=19.603|tag:lavfi.scd.time=30.8333 + pts=20040|tag:lavfi.scd.score=13.764|tag:lavfi.scd.mafd=19.060|tag:lavfi.scd.time=33.4 +-pts=21760|tag:lavfi.scd.score=64.451|tag:lavfi.scd.mafd=64.551|tag:lavfi.scd.time=36.266667 ++pts=21760|tag:lavfi.scd.score=64.451|tag:lavfi.scd.mafd=64.551|tag:lavfi.scd.time=36.2667 +diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect +index e66ffe5fdd..bc53fea047 100644 +--- a/tests/ref/fate/filter-metadata-silencedetect ++++ b/tests/ref/fate/filter-metadata-silencedetect +@@ -1,5 +1,5 @@ + pts=0|tag:lavfi.silence_duration=0.523107|tag:lavfi.silence_end=0.690023|tag:lavfi.silence_start=0.736417 +-pts=46080|tag:lavfi.silence_start=1.276259|tag:lavfi.silence_end=1.807506|tag:lavfi.silence_duration=0.531247 ++pts=46080|tag:lavfi.silence_start=1.27626|tag:lavfi.silence_end=1.80751|tag:lavfi.silence_duration=0.531247 + pts=92160 + pts=138240 + pts=184320 +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0030-hls-support-segments-pretend-to-be-gif-png.patch b/patches/7.1/0030-hls-support-segments-pretend-to-be-gif-png.patch new file mode 100644 index 0000000..b481238 --- /dev/null +++ b/patches/7.1/0030-hls-support-segments-pretend-to-be-gif-png.patch @@ -0,0 +1,65 @@ +From 2aee05ff2865a0067884cbf29fe70731a74dcdfc Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Sun, 29 Sep 2024 15:59:13 +0800 +Subject: [PATCH 30/34] hls: support segments pretend to be gif & png + +--- + libavformat/hls.c | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +diff --git a/libavformat/hls.c b/libavformat/hls.c +index 62473a15dd..7aa18079d9 100644 +--- a/libavformat/hls.c ++++ b/libavformat/hls.c +@@ -222,6 +222,7 @@ typedef struct HLSContext { + AVIOInterruptCB *interrupt_callback; + AVDictionary *avio_opts; + AVDictionary *seg_format_opts; ++ int seg_allow_img; + char *allowed_extensions; + int max_reload; + int http_persistent; +@@ -2113,7 +2114,30 @@ static int hls_read_header(AVFormatContext *s) + pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? s->max_analyze_duration : 4 * AV_TIME_BASE; + pls->ctx->interrupt_callback = s->interrupt_callback; + url = av_strdup(pls->segments[0]->url); +- ret = av_probe_input_buffer(&pls->pb.pub, &in_fmt, url, NULL, 0, 0); ++ unsigned skip = 0; ++ if (!c->seg_allow_img) { ++ uint8_t b[10] = { 0 }; // probe at most 10 ++ avio_read(&pls->pb.pub, b, sizeof(b)); ++ avio_seek(&pls->pb.pub, 0, SEEK_SET); ++ const AVProbeData pd = { ++ .buf = b, // png, gif read_probe only use this field ++ .buf_size = sizeof(b), ++ }; ++// optional: ffifmt(av_find_input_format("gif" or "gif_pipe" or "png_pipe"))->read_probe ++ int max_score = AVPROBE_SCORE_MAX - 2; // png_pipe, gif, gif_pipe score >= AVPROBE_SCORE_MAX - 1 ++ const AVInputFormat* img_fmt = av_probe_input_format2(&pd, 1, &max_score); // ++ if (img_fmt) { ++ if (av_strstart(img_fmt->name, "png", NULL)) { // "png_pipe" ++ skip = 3; // skip until ts sync byte 'G'(0x47) ++ av_log(s, AV_LOG_INFO, "segments pretend to be png\n"); ++ } else if (av_strstart(img_fmt->name, "gif", NULL)) { // "gif", "gif_pipe" ++ skip = 10; ++ av_log(s, AV_LOG_INFO, "segments pretend to be gif\n"); ++ } ++ } ++ } ++ ++ ret = av_probe_input_buffer(&pls->pb.pub, &in_fmt, url, NULL, skip, 0); + if (ret < 0) { + /* Free the ctx - it isn't initialized properly at this point, + * so avformat_close_input shouldn't be called. If +@@ -2590,6 +2614,8 @@ static const AVOption hls_options[] = { + OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, + {"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, ++ {"seg_allow_img", "Allow segments detected as gif and png images, 0 = disable, 1 = enable", ++ OFFSET(seg_allow_img), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS}, + {NULL} + }; + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/7.1/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch b/patches/7.1/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch new file mode 100644 index 0000000..5c00684 --- /dev/null +++ b/patches/7.1/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch @@ -0,0 +1,28 @@ +From 375afbcba709a856174ab2f200bd7b15ed85c432 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 15 Oct 2024 17:07:02 +0800 +Subject: [PATCH 31/34] hevc: disable Unknown profile bitstream warning for + small configuration + +--- + libavcodec/hevc/ps.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c +index f18b88489b..0f3f330671 100644 +--- a/libavcodec/hevc/ps.c ++++ b/libavcodec/hevc/ps.c +@@ -254,9 +254,9 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, + profile_name = ff_hevc_profiles[i].name; + break; + } +-#endif + av_log(avctx, profile_name ? AV_LOG_DEBUG : AV_LOG_WARNING, + "%s profile bitstream\n", profile_name ? profile_name : "Unknown"); ++#endif + + for (i = 0; i < 32; i++) { + ptl->profile_compatibility_flag[i] = get_bits1(gb); +-- +2.39.5 (Apple Git-154) + diff --git a/patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch b/patches/7.1/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch similarity index 82% rename from patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch rename to patches/7.1/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch index e9fc860..242868f 100644 --- a/patches/master/0033-hwcontext_vaapi-fix-undefined-close-on-windows.patch +++ b/patches/7.1/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch @@ -1,7 +1,7 @@ -From 58a25729988efd3a61f3e1e9df97b8a3e0cf6130 Mon Sep 17 00:00:00 2001 +From a47e10589c24a2ec292080771ad1a370eb0dbae1 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 19 Nov 2024 19:43:02 +0800 -Subject: [PATCH 33/33] hwcontext_vaapi: fix undefined close() on windows +Subject: [PATCH 32/34] hwcontext_vaapi: fix undefined close() on windows --- libavutil/hwcontext_vaapi.c | 2 ++ diff --git a/patches/master/0032-textutils-include-time_internal.h.patch b/patches/7.1/0033-avfilter-textutils-Add-missing-time_internal.h.patch similarity index 51% rename from patches/master/0032-textutils-include-time_internal.h.patch rename to patches/7.1/0033-avfilter-textutils-Add-missing-time_internal.h.patch index 6a3b69a..d312e84 100644 --- a/patches/master/0032-textutils-include-time_internal.h.patch +++ b/patches/7.1/0033-avfilter-textutils-Add-missing-time_internal.h.patch @@ -1,15 +1,18 @@ -From 3e8678a486b50da2c1c7dae32eeb93d32327feb4 Mon Sep 17 00:00:00 2001 -From: wang-bin -Date: Tue, 19 Nov 2024 19:27:09 +0800 -Subject: [PATCH 32/32] textutils: include time_internal.h +From 478036b92d4f633189dbbfa24ceee536c5df92da Mon Sep 17 00:00:00 2001 +From: Zhao Zhili +Date: Mon, 18 Nov 2024 16:43:28 +0800 +Subject: [PATCH 33/34] avfilter/textutils: Add missing time_internal.h -fix undefined localtime_r in msvc +This fix build error on Windows with MSVC. We need time_internal.h +for gmtime_r and localtime_r. + +Signed-off-by: Zhao Zhili --- - libavfilter/textutils.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libavfilter/textutils.c | 1 + + 1 file changed, 1 insertion(+) diff --git a/libavfilter/textutils.c b/libavfilter/textutils.c -index e6b5239b20..471346cc51 100644 +index e6b5239b20..eabf842ab5 100644 --- a/libavfilter/textutils.c +++ b/libavfilter/textutils.c @@ -31,6 +31,7 @@ @@ -20,11 +23,6 @@ index e6b5239b20..471346cc51 100644 static int ff_expand_text_function_internal(FFExpandTextContext *expand_text, AVBPrint *bp, char *name, unsigned argc, char **argv) -@@ -380,4 +381,3 @@ int ff_load_textfile(void *log_ctx, const char *textfile, - - return 0; - } -- -- 2.39.5 (Apple Git-154) diff --git a/patches/master/0034-matroskadec-support-S_TEXT-WEBVTT.patch b/patches/7.1/0034-matroskadec-support-S_TEXT-WEBVTT.patch similarity index 84% rename from patches/master/0034-matroskadec-support-S_TEXT-WEBVTT.patch rename to patches/7.1/0034-matroskadec-support-S_TEXT-WEBVTT.patch index 8011a37..2259fdf 100644 --- a/patches/master/0034-matroskadec-support-S_TEXT-WEBVTT.patch +++ b/patches/7.1/0034-matroskadec-support-S_TEXT-WEBVTT.patch @@ -1,4 +1,4 @@ -From 3836044c87f817ae2da23aedc0c2df82f37b9383 Mon Sep 17 00:00:00 2001 +From 0a63ceebe5b105d7845cd1c19fb9e816294abcad Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 17 Dec 2024 23:21:57 +0800 Subject: [PATCH 34/34] matroskadec: support S_TEXT/WEBVTT @@ -6,8 +6,8 @@ Subject: [PATCH 34/34] matroskadec: support S_TEXT/WEBVTT fix ticket #5641 --- libavformat/matroska.c | 1 + - libavformat/matroskadec.c | 27 +++++++++++++++++++++++++++ - 2 files changed, 28 insertions(+) + libavformat/matroskadec.c | 26 ++++++++++++++++++++++++++ + 2 files changed, 27 insertions(+) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index d0ecfbeb6a..23c4ad6949 100644 @@ -22,7 +22,7 @@ index d0ecfbeb6a..23c4ad6949 100644 {"S_TEXT/UTF8" , AV_CODEC_ID_SUBRIP}, {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT}, diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c -index 0e150f9138..eaf39c02dd 100644 +index a2947c97e7..8235178842 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3765,6 +3765,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, @@ -33,12 +33,11 @@ index 0e150f9138..eaf39c02dd 100644 uint64_t timecode, uint64_t duration, int64_t pos) -@@ -3773,14 +3774,29 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, - uint8_t *id, *settings, *text, *buf; +@@ -3774,13 +3775,28 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, int id_len, settings_len, text_len; uint8_t *p, *q; -+ int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9); int err; ++ const int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9); if (data_len <= 0) return AVERROR_INVALIDDATA; @@ -75,7 +74,7 @@ index 0e150f9138..eaf39c02dd 100644 settings = p; settings_len = -1; while (p < q) { -@@ -3812,7 +3832,12 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, +@@ -3812,7 +3832,11 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, if (p >= q || *p != '\n') return AVERROR_INVALIDDATA; p++; @@ -83,12 +82,11 @@ index 0e150f9138..eaf39c02dd 100644 + goto parse_text; + goto parse_id; -+// parse_comment +parse_text: text = p; text_len = q - p; while (text_len > 0) { -@@ -3823,6 +3848,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, +@@ -3823,6 +3847,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, text_len = len; } @@ -96,7 +94,7 @@ index 0e150f9138..eaf39c02dd 100644 if (text_len <= 0) return AVERROR_INVALIDDATA; -@@ -4215,6 +4241,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf +@@ -4215,6 +4240,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) { res = matroska_parse_webvtt(matroska, track, st, out_data, out_size, diff --git a/patches/master/FFmpeg-devel-avcodec-amfenc-Pass-through-TRC-and-primaries-for-YUV-input.patch b/patches/7.1/FFmpeg-devel-avcodec-amfenc-Pass-through-TRC-and-primaries-for-YUV-input.patch similarity index 100% rename from patches/master/FFmpeg-devel-avcodec-amfenc-Pass-through-TRC-and-primaries-for-YUV-input.patch rename to patches/7.1/FFmpeg-devel-avcodec-amfenc-Pass-through-TRC-and-primaries-for-YUV-input.patch diff --git a/patches/master/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch b/patches/master/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch index 0766b3a..4d494c2 100644 --- a/patches/master/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch +++ b/patches/master/0001-use-CreateMutexEx-instead-of-CreateMutex-to-fix-win8.patch @@ -1,7 +1,7 @@ -From 9132ffb16ca0e36ff744772a254a4a3e6cddc34e Mon Sep 17 00:00:00 2001 +From d6b3c9a190328940368849df9a924ab4e44f63b1 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sat, 28 Oct 2017 20:26:50 +0800 -Subject: [PATCH 01/29] use CreateMutexEx instead of CreateMutex to fix win8 +Subject: [PATCH 01/33] use CreateMutexEx instead of CreateMutex to fix win8 store app link error --- @@ -9,7 +9,7 @@ Subject: [PATCH 01/29] use CreateMutexEx instead of CreateMutex to fix win8 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c -index 9b3c5f389f..69d5eff49e 100644 +index 1a047ce57b..415f0f2fc3 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -42,6 +42,10 @@ @@ -23,7 +23,7 @@ index 9b3c5f389f..69d5eff49e 100644 typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); static AVOnce functions_loaded = AV_ONCE_INIT; -@@ -499,7 +503,7 @@ static int d3d11va_device_init(AVHWDeviceContext *hwdev) +@@ -503,7 +507,7 @@ static int d3d11va_device_init(AVHWDeviceContext *hwdev) HRESULT hr; if (!device_hwctx->lock) { @@ -33,5 +33,5 @@ index 9b3c5f389f..69d5eff49e 100644 av_log(NULL, AV_LOG_ERROR, "Failed to create a mutex\n"); return AVERROR(EINVAL); -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0002-mmal-enable-0-copy-for-egl-interop.patch b/patches/master/0002-mmal-enable-0-copy-for-egl-interop.patch index c69cd08..b92cb76 100644 --- a/patches/master/0002-mmal-enable-0-copy-for-egl-interop.patch +++ b/patches/master/0002-mmal-enable-0-copy-for-egl-interop.patch @@ -1,7 +1,7 @@ -From 49019c9853698bac801bfcea7b376336d64122b0 Mon Sep 17 00:00:00 2001 +From 34175494e05a1df8e89360041862191c10aadd77 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 29 Oct 2017 23:19:07 +0800 -Subject: [PATCH 02/29] mmal: enable 0-copy for egl interop +Subject: [PATCH 02/33] mmal: enable 0-copy for egl interop --- libavcodec/mmaldec.c | 5 ++++- @@ -31,5 +31,5 @@ index e42591110f..44f2916413 100644 if (!ctx->pool_out->pool) { ret = AVERROR(ENOMEM); -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0003-configure-fix-mmal-probing-in-cross-build.patch b/patches/master/0003-configure-fix-mmal-probing-in-cross-build.patch index 7aabc82..b6339c8 100644 --- a/patches/master/0003-configure-fix-mmal-probing-in-cross-build.patch +++ b/patches/master/0003-configure-fix-mmal-probing-in-cross-build.patch @@ -1,17 +1,17 @@ -From ebd9d0f347dc77066d77424af037e00d244c4592 Mon Sep 17 00:00:00 2001 +From 3a4b2cd68c809eeb329c0ecbba177dd557da86b6 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 29 Oct 2017 23:22:25 +0800 -Subject: [PATCH 03/29] configure: fix mmal probing in cross build +Subject: [PATCH 03/33] configure: fix mmal probing in cross build --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure -index 37178d7d81..18b84f9103 100755 +index 0a7ce31e09..c8414194cf 100755 --- a/configure +++ b/configure -@@ -7040,11 +7040,11 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt +@@ -7094,11 +7094,11 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto || die "ERROR: mbedTLS not found"; } enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } @@ -26,5 +26,5 @@ index 37178d7d81..18b84f9103 100755 check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError || -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0004-videotoolbox-check-runtime-availability.patch b/patches/master/0004-videotoolbox-check-runtime-availability.patch index 85926b9..7db1979 100644 --- a/patches/master/0004-videotoolbox-check-runtime-availability.patch +++ b/patches/master/0004-videotoolbox-check-runtime-availability.patch @@ -1,7 +1,7 @@ -From 4eb952da7f438c974459b70c7b909b971644daea Mon Sep 17 00:00:00 2001 +From cc01670a46f9f5469d5ae59dbf4bb00000c418c0 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 29 Oct 2017 23:35:28 +0800 -Subject: [PATCH 04/29] videotoolbox: check runtime availability +Subject: [PATCH 04/33] videotoolbox: check runtime availability fix warnings/errors for new compiler (since xcode9) if targeting macOS<10.8 @@ -10,7 +10,7 @@ macOS<10.8 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c -index 3dd804bb0c..b2a14a11b2 100644 +index a606c29ded..35f31aa05a 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -41,6 +41,10 @@ @@ -24,7 +24,7 @@ index 3dd804bb0c..b2a14a11b2 100644 #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder # define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder CFSTR("RequireHardwareAcceleratedVideoDecoder") #endif -@@ -713,7 +717,7 @@ static void videotoolbox_decoder_callback(void *opaque, +@@ -737,7 +741,7 @@ static void videotoolbox_decoder_callback(void *opaque, static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) { @@ -33,7 +33,7 @@ index 3dd804bb0c..b2a14a11b2 100644 CMSampleBufferRef sample_buf; AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); VTContext *vtctx = avctx->internal->hwaccel_priv_data; -@@ -725,13 +729,15 @@ static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) +@@ -749,13 +753,15 @@ static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) if (!sample_buf) return -1; @@ -52,7 +52,7 @@ index 3dd804bb0c..b2a14a11b2 100644 CFRelease(sample_buf); -@@ -865,7 +871,7 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec +@@ -896,7 +902,7 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec static int videotoolbox_start(AVCodecContext *avctx) { AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); @@ -61,7 +61,7 @@ index 3dd804bb0c..b2a14a11b2 100644 VTDecompressionOutputCallbackRecord decoder_cb; CFDictionaryRef decoder_spec; CFDictionaryRef buf_attr; -@@ -956,7 +962,8 @@ static int videotoolbox_start(AVCodecContext *avctx) +@@ -990,7 +996,8 @@ static int videotoolbox_start(AVCodecContext *avctx) decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback; decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data; @@ -72,5 +72,5 @@ index 3dd804bb0c..b2a14a11b2 100644 decoder_spec, // videoDecoderSpecification buf_attr, // destinationImageBufferAttributes -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0005-mediacodec-check-whether-cropping-is-set-before-use.patch b/patches/master/0005-mediacodec-check-whether-cropping-is-set-before-use.patch index 01380ce..5d1fe95 100644 --- a/patches/master/0005-mediacodec-check-whether-cropping-is-set-before-use.patch +++ b/patches/master/0005-mediacodec-check-whether-cropping-is-set-before-use.patch @@ -1,17 +1,17 @@ -From 9e965413d8d2f9ee54eb3b62907d9d3d950650b5 Mon Sep 17 00:00:00 2001 +From c1907ee2c7d435a388fef457520764d312b63825 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 29 Oct 2017 23:52:35 +0800 -Subject: [PATCH 05/29] mediacodec: check whether cropping is set before use +Subject: [PATCH 05/33] mediacodec: check whether cropping is set before use --- libavcodec/mediacodecdec_common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c -index b1ee8b609a..dfa2a3ab09 100644 +index 8a270f2f29..a4256a99e2 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c -@@ -587,10 +587,15 @@ static int mediacodec_dec_parse_video_format(AVCodecContext *avctx, MediaCodecDe +@@ -588,10 +588,15 @@ static int mediacodec_dec_parse_video_format(AVCodecContext *avctx, MediaCodecDe } /* Optional fields */ @@ -30,7 +30,7 @@ index b1ee8b609a..dfa2a3ab09 100644 + width = s->width; // Try "crop" for NDK - if (!(s->crop_right && s->crop_bottom) && s->use_ndk_codec) + // MediaTek SOC return some default value like Rect(0, 0, 318, 238) -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch b/patches/master/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch index 43da15c..7f5bc19 100644 --- a/patches/master/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch +++ b/patches/master/0006-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch @@ -1,7 +1,7 @@ -From 7f3c995023e7062f28b9c2083f413698d48d34dc Mon Sep 17 00:00:00 2001 +From ac6d70c5e43b3e25a56ff2acdcabae079304fc54 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Thu, 9 Nov 2017 14:56:53 +0800 -Subject: [PATCH 06/29] avcodec: add AV_HWACCEL_FLAG_ALLOW_SOFTWARE +Subject: [PATCH 06/33] avcodec: add AV_HWACCEL_FLAG_ALLOW_SOFTWARE a hw decoder may have software or hybrid implementation, for example videotoolbox hevc. the performance may be better than ffmpeg sw decoder. @@ -11,10 +11,10 @@ the performance may be better than ffmpeg sw decoder. 2 files changed, 5 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index 2da63c87ea..0621258d27 100644 +index 12e6e8749f..8091d3231a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h -@@ -2174,6 +2174,10 @@ typedef struct AVHWAccel { +@@ -2200,6 +2200,10 @@ typedef struct AVHWAccel { */ #define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3) @@ -26,10 +26,10 @@ index 2da63c87ea..0621258d27 100644 * @} */ diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h -index 33f1bce887..eb3c4325ee 100644 +index 47da41b0ad..652b3ab21d 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h -@@ -399,6 +399,7 @@ static const AVOption avcodec_options[] = { +@@ -400,6 +400,7 @@ static const AVOption avcodec_options[] = { {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, @@ -38,5 +38,5 @@ index 33f1bce887..eb3c4325ee 100644 {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, {"side_data_prefer_packet", "Comma-separated list of side data types for which user-supplied (container) data is preferred over coded bytestream", -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0007-videotoolbox-allow-software-implementation.patch b/patches/master/0007-videotoolbox-allow-software-implementation.patch index f9dca9b..08bc2d3 100644 --- a/patches/master/0007-videotoolbox-allow-software-implementation.patch +++ b/patches/master/0007-videotoolbox-allow-software-implementation.patch @@ -1,7 +1,7 @@ -From 2da938f65f91243fdcc79374f4ea12102f4fb7df Mon Sep 17 00:00:00 2001 +From 500d943d374859e5f6c526c6bbb3f8122e396e2b Mon Sep 17 00:00:00 2001 From: wang-bin Date: Thu, 9 Nov 2017 15:05:26 +0800 -Subject: [PATCH 07/29] videotoolbox: allow software implementation +Subject: [PATCH 07/33] videotoolbox: allow software implementation hevc is supported on macOS 10.12+ and iOS11+. sw implementaion is provided for old devices. vt sw decoder is more energy effecient than @@ -13,10 +13,10 @@ compatiblility attribute is disabled) 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c -index b2a14a11b2..69de24436d 100644 +index 35f31aa05a..5f4fa4ab6c 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c -@@ -819,9 +819,9 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec +@@ -843,9 +843,9 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue(config_info, @@ -30,5 +30,5 @@ index b2a14a11b2..69de24436d 100644 avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault, -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0008-h264-increase-MAX_SLICES-to-64.patch b/patches/master/0008-h264-increase-MAX_SLICES-to-64.patch index f66362c..6d1742f 100644 --- a/patches/master/0008-h264-increase-MAX_SLICES-to-64.patch +++ b/patches/master/0008-h264-increase-MAX_SLICES-to-64.patch @@ -1,7 +1,7 @@ -From f487cee5f265cf0c19a8452de9a7e2bafea24981 Mon Sep 17 00:00:00 2001 +From 4fc279873c32a975f60611819202c8fa7fa2c064 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Mon, 13 Nov 2017 12:23:10 +0800 -Subject: [PATCH 08/29] h264: increase MAX_SLICES to 64 +Subject: [PATCH 08/33] h264: increase MAX_SLICES to 64 lavfilters is 256. 64 can fix corrupt decoded frames https://github.com/wang-bin/QtAV/issues/923 @@ -10,7 +10,7 @@ https://github.com/wang-bin/QtAV/issues/923 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index ccd7583bf4..a68f3fe151 100644 +index 5abc60c09d..bdfe2c2beb 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -58,7 +58,7 @@ @@ -23,5 +23,5 @@ index ccd7583bf4..a68f3fe151 100644 #ifdef ALLOW_INTERLACE #define MB_MBAFF(h) (h)->mb_mbaff -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0009-mmal-add-vp8-mjpeg-wmv3.patch b/patches/master/0009-mmal-add-vp8-mjpeg-wmv3.patch index 753db7f..a0d7ca5 100644 --- a/patches/master/0009-mmal-add-vp8-mjpeg-wmv3.patch +++ b/patches/master/0009-mmal-add-vp8-mjpeg-wmv3.patch @@ -1,7 +1,7 @@ -From db13a9df735a6a339480dc1b986138a8adec6c44 Mon Sep 17 00:00:00 2001 +From cae44a70a0c54e212b1bd71d83423c19a11b52e6 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Mon, 13 Nov 2017 15:14:26 +0800 -Subject: [PATCH 09/29] mmal: add vp8, mjpeg, wmv3 +Subject: [PATCH 09/33] mmal: add vp8, mjpeg, wmv3 --- configure | 3 +++ @@ -10,10 +10,10 @@ Subject: [PATCH 09/29] mmal: add vp8, mjpeg, wmv3 3 files changed, 32 insertions(+) diff --git a/configure b/configure -index 1c13f51db2..a2c1aff490 100755 +index c8414194cf..89573b1146 100755 --- a/configure +++ b/configure -@@ -3380,6 +3380,7 @@ hevc_vaapi_encoder_select="atsc_a53 cbs_h265 vaapi_encode" +@@ -3414,6 +3414,7 @@ hevc_vulkan_encoder_select="atsc_a53 cbs_h265 vulkan_encode" hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf" hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" @@ -21,7 +21,7 @@ index 1c13f51db2..a2c1aff490 100755 mjpeg_cuvid_decoder_deps="cuvid" mjpeg_qsv_decoder_select="qsvdec" mjpeg_qsv_encoder_deps="libmfx" -@@ -3408,6 +3409,7 @@ vc1_cuvid_decoder_deps="cuvid" +@@ -3444,6 +3445,7 @@ vc1_cuvid_decoder_deps="cuvid" vc1_mmal_decoder_deps="mmal" vc1_qsv_decoder_select="qsvdec" vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" @@ -29,7 +29,7 @@ index 1c13f51db2..a2c1aff490 100755 vp8_cuvid_decoder_deps="cuvid" vp8_mediacodec_decoder_deps="mediacodec" vp8_mediacodec_encoder_deps="mediacodec" -@@ -3428,6 +3430,7 @@ vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9" +@@ -3464,6 +3466,7 @@ vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9" vp9_qsv_encoder_select="qsvenc" vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m" vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec" @@ -38,18 +38,18 @@ index 1c13f51db2..a2c1aff490 100755 # parsers aac_parser_select="adts_header mpeg4audio" diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c -index 09385be4ee..567e8e824b 100644 +index 433a2265a3..02ccfcf040 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c -@@ -860,6 +860,7 @@ extern const FFCodec ff_hevc_vaapi_encoder; - extern const FFCodec ff_hevc_videotoolbox_encoder; +@@ -871,6 +871,7 @@ extern const FFCodec ff_hevc_videotoolbox_encoder; + extern const FFCodec ff_hevc_vulkan_encoder; extern const FFCodec ff_libkvazaar_encoder; extern const FFCodec ff_mjpeg_cuvid_decoder; +extern const FFCodec ff_mjpeg_mmal_decoder; extern const FFCodec ff_mjpeg_qsv_encoder; extern const FFCodec ff_mjpeg_qsv_decoder; extern const FFCodec ff_mjpeg_vaapi_encoder; -@@ -878,6 +879,7 @@ extern const FFCodec ff_vc1_cuvid_decoder; +@@ -890,6 +891,7 @@ extern const FFCodec ff_vc1_cuvid_decoder; extern const FFCodec ff_vp8_cuvid_decoder; extern const FFCodec ff_vp8_mediacodec_decoder; extern const FFCodec ff_vp8_mediacodec_encoder; @@ -57,7 +57,7 @@ index 09385be4ee..567e8e824b 100644 extern const FFCodec ff_vp8_qsv_decoder; extern const FFCodec ff_vp8_v4l2m2m_encoder; extern const FFCodec ff_vp8_vaapi_encoder; -@@ -888,6 +890,7 @@ extern const FFCodec ff_vp9_qsv_decoder; +@@ -900,6 +902,7 @@ extern const FFCodec ff_vp9_qsv_decoder; extern const FFCodec ff_vp9_vaapi_encoder; extern const FFCodec ff_vp9_qsv_encoder; extern const FFCodec ff_vvc_qsv_decoder; @@ -126,5 +126,5 @@ index 44f2916413..338fd33c9f 100644 +FFMMAL_DEC(vp8, AV_CODEC_ID_VP8) +FFMMAL_DEC(wmv3, AV_CODEC_ID_WMV3) -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch b/patches/master/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch index 9942343..c6eef4c 100644 --- a/patches/master/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch +++ b/patches/master/0010-mmal-add-option-copy_frame-to-support-retrieving-sw-.patch @@ -1,7 +1,7 @@ -From 2804d21a8ac09f4f2b1967c6a38e6c5fed29a21f Mon Sep 17 00:00:00 2001 +From c70c531c2ed26b5c294dba4d5b09ff8ac36d6a0d Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 17 Nov 2017 14:54:23 +0800 -Subject: [PATCH 10/29] mmal: add option copy_frame to support retrieving sw +Subject: [PATCH 10/33] mmal: add option copy_frame to support retrieving sw frames w/o copy mmal buffer->data is already in host memory. AFAIK decoders implemented in omx must @@ -79,5 +79,5 @@ index 338fd33c9f..8d81d3ada7 100644 }; -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0011-videotoolbox-remove-opengl-compatibility-attribute.patch b/patches/master/0011-videotoolbox-remove-opengl-compatibility-attribute.patch index 22e4d10..8db0824 100644 --- a/patches/master/0011-videotoolbox-remove-opengl-compatibility-attribute.patch +++ b/patches/master/0011-videotoolbox-remove-opengl-compatibility-attribute.patch @@ -1,7 +1,7 @@ -From 90ec04079e71ad2a8bc3358c6ecf566c5f54b6fa Mon Sep 17 00:00:00 2001 +From 07124043d934c31e1f67097a2aa86aa8bd9d32ba Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 15 Dec 2017 11:34:06 +0800 -Subject: [PATCH 11/29] videotoolbox: remove opengl compatibility attribute +Subject: [PATCH 11/33] videotoolbox: remove opengl compatibility attribute 1. a cvpixelbuffer backed by iosurface can always be converted to an opengl texture, using CGLTexImageIOSurface2D for macOS, and undocumented api texImageIOSurface(which is internally used by public api CVOpenGLESTextureCacheCreateTextureFromImage) for iOS4.0+. 2. enabling the attribute can slow down decoding speed a lot. I tested many video clips on my macbook air. for example: ffmpeg -ss 00:00:00 -t 00:03:00 -hwaccel videotoolbox -an -i big_buck_bunny_1080p_h264.mov -f null ->/dev/null, result with the attribute @@ -12,10 +12,10 @@ disabled: frame= 2031 fps=104 q=-0.0 Lsize=N/A time=00:03:00.00 bitrate=N/A spee 1 file changed, 5 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c -index 69de24436d..059ed66554 100644 +index 5f4fa4ab6c..5fb796fc19 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c -@@ -793,11 +793,6 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, +@@ -817,11 +817,6 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); @@ -28,5 +28,5 @@ index 69de24436d..059ed66554 100644 CFRelease(io_surface_properties); CFRelease(cv_pix_fmt); -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0012-configure-do-not-filter-libpath-for-msvc.patch b/patches/master/0012-configure-do-not-filter-libpath-for-msvc.patch index 92cf69c..3af913e 100644 --- a/patches/master/0012-configure-do-not-filter-libpath-for-msvc.patch +++ b/patches/master/0012-configure-do-not-filter-libpath-for-msvc.patch @@ -1,17 +1,17 @@ -From 843961015a7996eb1595a82f3e6be8f774dff37b Mon Sep 17 00:00:00 2001 +From 73626a49e702baee25ef2c2c8af37c1a2cea89ec Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 30 Mar 2018 10:46:43 +0800 -Subject: [PATCH 12/29] configure: do not filter -libpath for msvc +Subject: [PATCH 12/33] configure: do not filter -libpath for msvc --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure -index 197bc46971..c33d93a7d1 100755 +index 89573b1146..c21be8837b 100755 --- a/configure +++ b/configure -@@ -4823,6 +4823,7 @@ msvc_common_flags(){ +@@ -4867,6 +4867,7 @@ msvc_common_flags(){ -lz) echo zlib.lib ;; -lx264) echo libx264.lib ;; -lstdc++) ;; @@ -20,5 +20,5 @@ index 197bc46971..c33d93a7d1 100755 -LARGEADDRESSAWARE) echo $flag ;; -L*) echo -libpath:${flag#-L} ;; -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0013-configure-enable-icf.patch b/patches/master/0013-configure-enable-icf.patch index 5f8fa46..9ca85ff 100644 --- a/patches/master/0013-configure-enable-icf.patch +++ b/patches/master/0013-configure-enable-icf.patch @@ -1,17 +1,17 @@ -From 4746cfc06082dbd6a2ba9379e7416799a9ae3ff9 Mon Sep 17 00:00:00 2001 +From 4ba1d4c98fd1d472bd3f4e04b5647742372c2ca9 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 11 Sep 2018 23:16:49 +0800 -Subject: [PATCH 13/29] configure: enable icf +Subject: [PATCH 13/33] configure: enable icf --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure -index c33d93a7d1..240b8b438e 100755 +index c21be8837b..d92b74b0c9 100755 --- a/configure +++ b/configure -@@ -7531,6 +7531,9 @@ test_cc -mno-red-zone < Date: Sun, 14 Apr 2019 11:42:42 +0800 -Subject: [PATCH 14/29] configure: suppor static build via clang-cl +Subject: [PATCH 14/33] configure: suppor static build via clang-cl --- configure | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/configure b/configure -index 240b8b438e..efd2e3b2ae 100755 +index d92b74b0c9..870ba4c866 100755 --- a/configure +++ b/configure -@@ -5870,7 +5870,15 @@ case $target_os in +@@ -5915,7 +5915,15 @@ case $target_os in SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)' enabled x86_64 && objformat="win64" || objformat="win32" @@ -29,5 +29,5 @@ index 240b8b438e..efd2e3b2ae 100755 ;; cygwin*) -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch b/patches/master/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch index 066449a..1efdf25 100644 --- a/patches/master/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch +++ b/patches/master/0015-nvenc-use-runtime-api-version-to-work-with-old-drive.patch @@ -1,7 +1,7 @@ -From 67c05ae4416db156b91a3f6b460625969baed5ab Mon Sep 17 00:00:00 2001 +From b43bc155b0b39cbbf6135aa98493087dd0391d79 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Wed, 12 Jun 2019 10:43:50 +0800 -Subject: [PATCH 15/29] nvenc: use runtime api version to work with old drivers +Subject: [PATCH 15/33] nvenc: use runtime api version to work with old drivers the document recommends to use build version, so using latest nvenc headers requires latest driver version. But api and abi change rarely, @@ -12,7 +12,7 @@ so requesting runtime version should work, and does work for my tests. 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c -index 2cce478be0..5f80e4663e 100644 +index 06e3fb81a4..f3f1db1529 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -314,20 +314,35 @@ static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level) @@ -116,7 +116,7 @@ index 2cce478be0..5f80e4663e 100644 if (ctx->init_qp_p >= 0) { rc->constQP.qpInterP = ctx->init_qp_p; if (ctx->init_qp_i >= 0 && ctx->init_qp_b >= 0) { -@@ -1623,16 +1644,16 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) +@@ -1625,16 +1646,16 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) int res = 0; int dw, dh; @@ -137,7 +137,7 @@ index 2cce478be0..5f80e4663e 100644 #ifdef NVENC_HAVE_NEW_PRESETS ctx->init_encode_params.tuningInfo = ctx->tuning_info; -@@ -1658,7 +1679,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) +@@ -1660,7 +1681,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); @@ -146,7 +146,7 @@ index 2cce478be0..5f80e4663e 100644 compute_dar(avctx, &dw, &dh); ctx->init_encode_params.darHeight = dh; -@@ -1833,7 +1854,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) +@@ -1835,7 +1856,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) NVENCSTATUS nv_status; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; @@ -155,7 +155,7 @@ index 2cce478be0..5f80e4663e 100644 if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) { ctx->surfaces[idx].in_ref = av_frame_alloc(); -@@ -1849,7 +1870,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) +@@ -1851,7 +1872,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) return AVERROR(EINVAL); } @@ -164,7 +164,7 @@ index 2cce478be0..5f80e4663e 100644 allocSurf.width = avctx->width; allocSurf.height = avctx->height; allocSurf.bufferFmt = ctx->surfaces[idx].format; -@@ -1937,7 +1958,7 @@ static av_cold int nvenc_setup_extradata(AVCodecContext *avctx) +@@ -1939,7 +1960,7 @@ static av_cold int nvenc_setup_extradata(AVCodecContext *avctx) char tmpHeader[NV_MAX_SEQ_HDR_LEN]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; @@ -173,7 +173,7 @@ index 2cce478be0..5f80e4663e 100644 payload.spsppsBuffer = tmpHeader; payload.inBufferSize = sizeof(tmpHeader); -@@ -1969,7 +1990,7 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) +@@ -1971,7 +1992,7 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) /* the encoder has to be flushed before it can be closed */ if (ctx->nvencoder) { @@ -182,7 +182,7 @@ index 2cce478be0..5f80e4663e 100644 .encodePicFlags = NV_ENC_PIC_FLAG_EOS }; res = nvenc_push_context(avctx); -@@ -2193,7 +2214,7 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame) +@@ -2195,7 +2216,7 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame) if (idx < 0) return idx; @@ -191,7 +191,7 @@ index 2cce478be0..5f80e4663e 100644 reg.width = frames_ctx->width; reg.height = frames_ctx->height; reg.pitch = frame->linesize[0]; -@@ -2248,7 +2269,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, +@@ -2250,7 +2271,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, return res; if (!ctx->registered_frames[reg_idx].mapped) { @@ -200,7 +200,7 @@ index 2cce478be0..5f80e4663e 100644 ctx->registered_frames[reg_idx].in_map.registeredResource = ctx->registered_frames[reg_idx].regptr; nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &ctx->registered_frames[reg_idx].in_map); if (nv_status != NV_ENC_SUCCESS) { -@@ -2268,7 +2289,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, +@@ -2270,7 +2291,7 @@ static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, } else { NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 }; @@ -209,7 +209,7 @@ index 2cce478be0..5f80e4663e 100644 lockBufferParams.inputBuffer = nvenc_frame->input_surface; nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams); -@@ -2469,7 +2490,7 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur +@@ -2471,7 +2492,7 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur enum AVPictureType pict_type; @@ -218,7 +218,7 @@ index 2cce478be0..5f80e4663e 100644 lock_params.doNotWait = 0; lock_params.outputBitstream = tmpoutsurf->output_surface; -@@ -2692,7 +2713,7 @@ static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame) +@@ -2694,7 +2715,7 @@ static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame) int reconfig_bitrate = 0, reconfig_dar = 0; int dw, dh; @@ -227,7 +227,7 @@ index 2cce478be0..5f80e4663e 100644 params.reInitEncodeParams = ctx->init_encode_params; compute_dar(avctx, &dw, &dh); -@@ -2785,7 +2806,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) +@@ -2787,7 +2808,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; NV_ENC_PIC_PARAMS pic_params = { 0 }; @@ -251,5 +251,5 @@ index 0130b99369..5696f712ff 100644 NV_ENC_INITIALIZE_PARAMS init_encode_params; -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch b/patches/master/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch index f841df4..91530d6 100644 --- a/patches/master/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch +++ b/patches/master/0016-nvenc-check-runtime-9.1-function-ptrs-before-use.patch @@ -1,14 +1,14 @@ -From 6bce89c7566aed0087aca2f21d9242cd8b5808a5 Mon Sep 17 00:00:00 2001 +From 1597ff8fb998f7af86495373f6020a4de11e11b0 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 5 Jun 2020 14:05:42 +0800 -Subject: [PATCH 16/29] nvenc: check runtime 9.1 function ptrs before use +Subject: [PATCH 16/33] nvenc: check runtime 9.1 function ptrs before use --- libavcodec/nvenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c -index 5f80e4663e..986b2e759b 100644 +index f3f1db1529..08cdcbae02 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -167,7 +167,7 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err, @@ -20,7 +20,7 @@ index 5f80e4663e..986b2e759b 100644 details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder); #endif -@@ -1785,7 +1785,7 @@ FF_ENABLE_DEPRECATION_WARNINGS +@@ -1787,7 +1787,7 @@ FF_ENABLE_DEPRECATION_WARNINGS } #ifdef NVENC_HAVE_CUSTREAM_PTR @@ -30,5 +30,5 @@ index 5f80e4663e..986b2e759b 100644 if (nv_status != NV_ENC_SUCCESS) { nvenc_pop_context(avctx); -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch b/patches/master/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch index d413132..926cd02 100644 --- a/patches/master/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch +++ b/patches/master/0017-nvenc-check-sdk-10.0-ptrs-at-runtime.patch @@ -1,17 +1,17 @@ -From 56a988d654c5e3ae45eaad7d027bc3d34e40cd61 Mon Sep 17 00:00:00 2001 +From f73d42c0f75567e3ff8ebe7482df2276f64e37d4 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 3 Jul 2020 14:09:54 +0800 -Subject: [PATCH 17/29] nvenc: check sdk 10.0 ptrs at runtime +Subject: [PATCH 17/33] nvenc: check sdk 10.0 ptrs at runtime --- libavcodec/nvenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c -index 986b2e759b..41784274ed 100644 +index 08cdcbae02..2ec9787d51 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c -@@ -1663,17 +1663,18 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) +@@ -1665,17 +1665,18 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) else if (ctx->flags & NVENC_LOWLATENCY) ctx->init_encode_params.tuningInfo = NV_ENC_TUNING_INFO_LOW_LATENCY; @@ -33,5 +33,5 @@ index 986b2e759b..41784274ed 100644 return nvenc_print_error(avctx, nv_status, "Cannot get the preset configuration"); -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch b/patches/master/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch index 65b3709..d66d72c 100644 --- a/patches/master/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch +++ b/patches/master/0018-lavfi-atempo-fix-large-tempo-4-crash-lower-min.patch @@ -1,14 +1,14 @@ -From 19606633e602d717f3eeec1783598cdba8194201 Mon Sep 17 00:00:00 2001 +From a10de2561f2c21fc7b1d842b032787c3c68edc52 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 9 Aug 2020 23:35:08 +0800 -Subject: [PATCH 18/29] lavfi/atempo: fix large tempo(>4) crash, lower min +Subject: [PATCH 18/33] lavfi/atempo: fix large tempo(>4) crash, lower min --- libavfilter/af_atempo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c -index 3658348c45..4e4c79794a 100644 +index 3b03caa4d0..a6a021b000 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -154,7 +154,7 @@ typedef struct ATempoContext { @@ -30,5 +30,5 @@ index 3658348c45..4e4c79794a 100644 while (atempo->position[0] < stop_here && src < src_end) { int src_samples = (src_end - src) / atempo->stride; -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0019-flv-support-hevc-opus.patch b/patches/master/0019-flv-support-hevc-opus.patch index 572544e..9b41f07 100644 --- a/patches/master/0019-flv-support-hevc-opus.patch +++ b/patches/master/0019-flv-support-hevc-opus.patch @@ -1,27 +1,27 @@ -From 7656a981987539bd68b767c96333da3948ccf0fe Mon Sep 17 00:00:00 2001 +From f2b4eb78f4f0d0f62e64ddb7c8bab4578e33b478 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Mon, 27 Sep 2021 17:35:17 +0800 -Subject: [PATCH 19/29] flv: support hevc, opus +Subject: [PATCH 19/33] flv: support hevc, opus --- libavformat/flv.h | 2 ++ libavformat/flvdec.c | 17 ++++++++++++++++- - libavformat/flvenc.c | 4 ++++ - 3 files changed, 22 insertions(+), 1 deletion(-) + libavformat/flvenc.c | 1 + + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libavformat/flv.h b/libavformat/flv.h -index f710963b92..8e72d62a5f 100644 +index 1ea88ff851..a65e23f42b 100644 --- a/libavformat/flv.h +++ b/libavformat/flv.h -@@ -105,6 +105,7 @@ enum { - FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET, +@@ -106,6 +106,7 @@ enum { + FLV_CODECID_EX_HEADER = 9 << FLV_AUDIO_CODECID_OFFSET, FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET, FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET, + FLV_CODECID_OPUS = 13<< FLV_AUDIO_CODECID_OFFSET, }; enum { -@@ -116,6 +117,7 @@ enum { +@@ -117,6 +118,7 @@ enum { FLV_CODECID_H264 = 7, FLV_CODECID_REALH263= 8, FLV_CODECID_MPEG4 = 9, @@ -30,10 +30,10 @@ index f710963b92..8e72d62a5f 100644 enum { diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c -index 22a9b9e4a7..3a3c35328b 100644 +index 018249d1fe..8a6ea12e12 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c -@@ -263,6 +263,10 @@ static int flv_same_audio_codec(AVCodecParameters *apar, int flags) +@@ -291,6 +291,10 @@ static int flv_same_audio_codec(AVCodecParameters *apar, int flags, uint32_t cod case FLV_CODECID_PCM_ALAW: return apar->sample_rate == 8000 && apar->codec_id == AV_CODEC_ID_PCM_ALAW; @@ -44,7 +44,7 @@ index 22a9b9e4a7..3a3c35328b 100644 default: return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET); } -@@ -321,6 +325,11 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, +@@ -349,6 +353,11 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, apar->sample_rate = 8000; apar->codec_id = AV_CODEC_ID_PCM_ALAW; break; @@ -53,19 +53,19 @@ index 22a9b9e4a7..3a3c35328b 100644 + apar->bits_per_coded_sample = 16; + apar->codec_id = AV_CODEC_ID_OPUS; + break; - default: - avpriv_request_sample(s, "Audio codec (%x)", - flv_codecid >> FLV_AUDIO_CODECID_OFFSET); -@@ -352,6 +361,8 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid) - return vpar->codec_id == AV_CODEC_ID_VP6A; + case MKBETAG('m', 'p', '4', 'a'): + apar->codec_id = AV_CODEC_ID_AAC; + return; +@@ -399,6 +408,8 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid) case FLV_CODECID_H264: + case MKBETAG('a', 'v', 'c', '1'): return vpar->codec_id == AV_CODEC_ID_H264; + case FLV_CODECID_HEVC: + return vpar->codec_id == AV_CODEC_ID_HEVC; default: return vpar->codec_tag == flv_codecid; } -@@ -413,6 +424,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, +@@ -461,6 +472,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, case FLV_CODECID_MPEG4: par->codec_id = AV_CODEC_ID_MPEG4; break; @@ -76,17 +76,17 @@ index 22a9b9e4a7..3a3c35328b 100644 default: avpriv_request_sample(s, "Video codec (%x)", flv_codecid); par->codec_tag = flv_codecid; -@@ -1463,7 +1478,7 @@ retry_duration: - } +@@ -1654,7 +1669,7 @@ retry_duration: - if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || -- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { -+ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) { - // sign extension - int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000; - pts = av_sat_add64(dts, cts); + if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || + (st->codecpar->codec_id == AV_CODEC_ID_H264 && (!enhanced_flv || type == PacketTypeCodedFrames)) || +- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { ++ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) { + // sign extension + int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000; + pts = av_sat_add64(dts, cts); diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c -index f34df61c0e..3719b61476 100644 +index f3f32dc433..f9464dcef3 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -69,6 +69,7 @@ static const AVCodecTag flv_audio_codec_ids[] = { @@ -94,19 +94,9 @@ index f34df61c0e..3719b61476 100644 { AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET }, { AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET }, + { AV_CODEC_ID_OPUS, FLV_CODECID_OPUS >> FLV_AUDIO_CODECID_OFFSET }, - { AV_CODEC_ID_NONE, 0 } - }; - -@@ -138,6 +139,9 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par) - if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters - return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | - FLV_SAMPLESSIZE_16BIT | FLV_STEREO; -+ else if (par->codec_id == AV_CODEC_ID_OPUS) // specs force these parameters -+ return FLV_CODECID_OPUS | FLV_SAMPLERATE_44100HZ | -+ FLV_SAMPLESSIZE_16BIT | FLV_STEREO; - else if (par->codec_id == AV_CODEC_ID_SPEEX) { - if (par->sample_rate != 16000) { - av_log(s, AV_LOG_ERROR, + { AV_CODEC_ID_OPUS, MKBETAG('O', 'p', 'u', 's') }, + { AV_CODEC_ID_FLAC, MKBETAG('f', 'L', 'a', 'C') }, + { AV_CODEC_ID_AC3, MKBETAG('a', 'c', '-', '3') }, -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0020-msvc-fix-long-argument-list-error-on-windows.patch b/patches/master/0020-msvc-fix-long-argument-list-error-on-windows.patch index 7c1cf93..3238c8a 100644 --- a/patches/master/0020-msvc-fix-long-argument-list-error-on-windows.patch +++ b/patches/master/0020-msvc-fix-long-argument-list-error-on-windows.patch @@ -1,7 +1,7 @@ -From acc3810102fde8d57c12219dd0ca67e4495deb35 Mon Sep 17 00:00:00 2001 +From 9243ff3c58a8b1ba26556c9bf22abacb4d1ba257 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sat, 11 Dec 2021 18:08:43 +0800 -Subject: [PATCH 20/29] msvc: fix long argument list error on windows +Subject: [PATCH 20/33] msvc: fix long argument list error on windows --- compat/windows/makedef | 4 +++- @@ -46,5 +46,5 @@ index 6cab090071..d3202520cf 100755 +rm -f $cmdlist +exit $ret -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch b/patches/master/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch index e453883..79a4594 100644 --- a/patches/master/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch +++ b/patches/master/0021-configure-rewrite-flags-from-pkg-config-for-msvc-in-.patch @@ -1,7 +1,7 @@ -From 7a7d65b5dbdf2d5579cf706059101079205d431e Mon Sep 17 00:00:00 2001 +From f9ab38a77402cea589d0a65d33051aebdf67d225 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 11 Jan 2022 16:17:56 +0800 -Subject: [PATCH 21/29] configure: rewrite flags from pkg-config for msvc in +Subject: [PATCH 21/33] configure: rewrite flags from pkg-config for msvc in msys cflags and libs from pkg-config is unix path, e.g. /c/msys64, but msvc @@ -11,10 +11,10 @@ requires mixed form, e.g. c:/msys64 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure -index efd2e3b2ae..229c6d4216 100755 +index 870ba4c866..c61842314f 100755 --- a/configure +++ b/configure -@@ -4826,7 +4826,8 @@ msvc_common_flags(){ +@@ -4870,7 +4870,8 @@ msvc_common_flags(){ -libpath:*|-LIBPATH:*)echo $flag ;; -l*) echo ${flag#-l}.lib ;; -LARGEADDRESSAWARE) echo $flag ;; @@ -25,5 +25,5 @@ index efd2e3b2ae..229c6d4216 100755 *) echo $flag ;; esac -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0022-win-enable-windres-for-small-and-msvc.patch b/patches/master/0022-win-enable-windres-for-small-and-msvc.patch index c26ba63..063bd88 100644 --- a/patches/master/0022-win-enable-windres-for-small-and-msvc.patch +++ b/patches/master/0022-win-enable-windres-for-small-and-msvc.patch @@ -1,17 +1,17 @@ -From a41752800a7f11a1bb6f9a6dd76efd3965f06c66 Mon Sep 17 00:00:00 2001 +From ca320794b795ce555d335909d1151eb07506ced3 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 13 Mar 2022 11:15:15 +0800 -Subject: [PATCH 22/29] win: enable windres for small and msvc +Subject: [PATCH 22/33] win: enable windres for small and msvc --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure -index 229c6d4216..d48f6ce7b4 100755 +index c61842314f..904ad1f40b 100755 --- a/configure +++ b/configure -@@ -5805,7 +5805,7 @@ case $target_os in +@@ -5850,7 +5850,7 @@ case $target_os in # Cannot build both shared and static libs when using dllimport. disable static fi @@ -20,7 +20,7 @@ index 229c6d4216..d48f6ce7b4 100755 enabled x86_32 && check_ldflags -Wl,--large-address-aware add_cppflags -DWIN32_LEAN_AND_MEAN shlibdir_default="$bindir_default" -@@ -5856,7 +5856,7 @@ case $target_os in +@@ -5901,7 +5901,7 @@ case $target_os in # Cannot build both shared and static libs with MSVC or icl. disable static fi @@ -30,5 +30,5 @@ index 229c6d4216..d48f6ce7b4 100755 add_cppflags -DWIN32_LEAN_AND_MEAN shlibdir_default="$bindir_default" -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0023-configure-add-extra-windresflags.patch b/patches/master/0023-configure-add-extra-windresflags.patch index 455390d..f9b1413 100644 --- a/patches/master/0023-configure-add-extra-windresflags.patch +++ b/patches/master/0023-configure-add-extra-windresflags.patch @@ -1,7 +1,7 @@ -From c4148286c619bab77ad035278739c519cedd3823 Mon Sep 17 00:00:00 2001 +From 1ae990f653f1b2ef4b70b387ff0f6e212dfb4b9a Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 13 Mar 2022 14:38:23 +0800 -Subject: [PATCH 23/29] configure: add --extra-windresflags +Subject: [PATCH 23/33] configure: add --extra-windresflags llvm windres requires more preprocess flags and target flags --- @@ -10,10 +10,10 @@ llvm windres requires more preprocess flags and target flags 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/configure b/configure -index d48f6ce7b4..5e980a1a6a 100755 +index 904ad1f40b..26c5c38032 100755 --- a/configure +++ b/configure -@@ -416,6 +416,7 @@ Toolchain options: +@@ -418,6 +418,7 @@ Toolchain options: --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS] @@ -21,7 +21,7 @@ index d48f6ce7b4..5e980a1a6a 100755 --extra-libs=ELIBS add ELIBS [$ELIBS] --extra-version=STRING version string suffix [] --optflags=OPTFLAGS override optimization-related compiler flags -@@ -998,6 +999,10 @@ add_host_ldflags(){ +@@ -1003,6 +1004,10 @@ add_host_ldflags(){ append host_ldflags $($host_ldflags_filter "$@") } @@ -32,7 +32,7 @@ index d48f6ce7b4..5e980a1a6a 100755 add_compat(){ append compat_objs $1 shift -@@ -4354,6 +4359,9 @@ for opt do +@@ -4396,6 +4401,9 @@ for opt do --extra-libs=*) add_extralibs $optval ;; @@ -42,7 +42,7 @@ index d48f6ce7b4..5e980a1a6a 100755 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST ;; -@@ -5181,6 +5189,7 @@ add_cflags $extra_cflags +@@ -5225,6 +5233,7 @@ add_cflags $extra_cflags add_cxxflags $extra_cxxflags add_objcflags $extra_objcflags add_asflags $extra_cflags @@ -50,7 +50,7 @@ index d48f6ce7b4..5e980a1a6a 100755 if test -n "$sysroot"; then case "$cc_type" in -@@ -8102,6 +8111,7 @@ DOXYGEN=$doxygen +@@ -8163,6 +8172,7 @@ DOXYGEN=$doxygen LDFLAGS=$LDFLAGS LDEXEFLAGS=$LDEXEFLAGS LDSOFLAGS=$LDSOFLAGS @@ -59,7 +59,7 @@ index d48f6ce7b4..5e980a1a6a 100755 ASMSTRIPFLAGS=$ASMSTRIPFLAGS X86ASMFLAGS=$X86ASMFLAGS diff --git a/ffbuild/common.mak b/ffbuild/common.mak -index 87a3ffd2b0..a93961d217 100644 +index 023adb8567..90bd652580 100644 --- a/ffbuild/common.mak +++ b/ffbuild/common.mak @@ -104,7 +104,7 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS) @@ -72,5 +72,5 @@ index 87a3ffd2b0..a93961d217 100644 %.i: %.c $(CC) $(CCFLAGS) $(CC_E) $< -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch b/patches/master/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch index 222b939..bd978d5 100644 --- a/patches/master/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch +++ b/patches/master/0024-add-h264-max-bit-depth-to-disable-rarely-used-depths.patch @@ -1,7 +1,7 @@ -From f419dab41e31329222c905685e7aeedacde37274 Mon Sep 17 00:00:00 2001 +From 8a5fd36569ff455bed089e00c97c754ce1b62c97 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 1 Jul 2022 16:03:06 +0800 -Subject: [PATCH 24/29] add h264-max-bit-depth to disable rarely used depths +Subject: [PATCH 24/33] add h264-max-bit-depth to disable rarely used depths --- configure | 6 ++++++ @@ -16,10 +16,10 @@ Subject: [PATCH 24/29] add h264-max-bit-depth to disable rarely used depths 9 files changed, 77 insertions(+), 1 deletion(-) diff --git a/configure b/configure -index 5e980a1a6a..783866fea4 100755 +index 26c5c38032..e30c78d71b 100755 --- a/configure +++ b/configure -@@ -436,6 +436,7 @@ Advanced options (experts only): +@@ -438,6 +438,7 @@ Advanced options (experts only): disable buffer boundary checking in bitreaders (faster, but may crash) --sws-max-filter-size=N the max filter size swscale uses [$sws_max_filter_size_default] @@ -27,7 +27,7 @@ index 5e980a1a6a..783866fea4 100755 Optimization options (experts only): --disable-asm disable all assembly optimizations -@@ -2693,6 +2694,7 @@ CMDLINE_SET=" +@@ -2708,6 +2709,7 @@ CMDLINE_SET=" env extra_version gas @@ -35,7 +35,7 @@ index 5e980a1a6a..783866fea4 100755 host_cc host_cflags host_extralibs -@@ -4138,6 +4140,9 @@ enable valgrind_backtrace +@@ -4177,6 +4179,9 @@ enable valgrind_backtrace sws_max_filter_size_default=256 set_default sws_max_filter_size @@ -45,7 +45,7 @@ index 5e980a1a6a..783866fea4 100755 # internal components are enabled by default enable $EXTRALIBS_LIST -@@ -8205,6 +8210,7 @@ cat > $TMPH < $TMPH < Date: Tue, 3 May 2022 00:03:18 +0800 -Subject: [PATCH 25/29] wolfSSL - new TLS backend patch +Subject: [PATCH 25/33] wolfSSL - new TLS backend patch https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233802.html --- @@ -14,7 +14,7 @@ https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233802.html create mode 100644 libavformat/tls_wolfssl.c diff --git a/configure b/configure -index 783866fea4..c4e2ce4652 100755 +index e30c78d71b..7e2cf1b605 100755 --- a/configure +++ b/configure @@ -208,7 +208,7 @@ External library support: @@ -26,7 +26,7 @@ index 783866fea4..c4e2ce4652 100755 --disable-iconv disable iconv [autodetect] --enable-jni enable JNI support [no] --enable-ladspa enable LADSPA audio filtering [no] -@@ -282,7 +282,7 @@ External library support: +@@ -283,7 +283,7 @@ External library support: --enable-libtesseract enable Tesseract, needed for ocr filter [no] --enable-libtheora enable Theora encoding via libtheora [no] --enable-libtls enable LibreSSL (via libtls), needed for https support @@ -35,7 +35,7 @@ index 783866fea4..c4e2ce4652 100755 --enable-libtorch enable Torch as one DNN backend [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] -@@ -295,6 +295,8 @@ External library support: +@@ -296,6 +296,8 @@ External library support: --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] --enable-libvvenc enable H.266/VVC encoding via vvenc [no] --enable-libwebp enable WebP encoding via libwebp [no] @@ -44,7 +44,7 @@ index 783866fea4..c4e2ce4652 100755 --enable-libx264 enable H.264 encoding via x264 [no] --enable-libx265 enable HEVC encoding via x265 [no] --enable-libxeve enable EVC encoding via libxeve [no] -@@ -316,7 +318,7 @@ External library support: +@@ -317,7 +319,7 @@ External library support: --disable-lzma disable lzma [autodetect] --enable-decklink enable Blackmagic DeckLink I/O support [no] --enable-mbedtls enable mbedTLS, needed for https support @@ -53,7 +53,7 @@ index 783866fea4..c4e2ce4652 100755 --enable-mediacodec enable Android MediaCodec support [no] --enable-mediafoundation enable encoding via MediaFoundation [auto] --disable-metal disable Apple Metal framework [autodetect] -@@ -325,7 +327,7 @@ External library support: +@@ -326,7 +328,7 @@ External library support: --enable-opencl enable OpenCL processing [no] --enable-opengl enable OpenGL rendering [no] --enable-openssl enable openssl, needed for https support @@ -62,15 +62,15 @@ index 783866fea4..c4e2ce4652 100755 --enable-pocketsphinx enable PocketSphinx, needed for asr filter [no] --disable-sndio disable sndio support [autodetect] --disable-schannel disable SChannel SSP, needed for TLS support on -@@ -1988,6 +1990,7 @@ EXTERNAL_LIBRARY_LIST=" - openssl +@@ -1995,6 +1997,7 @@ EXTERNAL_LIBRARY_LIST=" pocketsphinx vapoursynth + vulkan_static + wolfssl " HWACCEL_AUTODETECT_LIBRARY_LIST=" -@@ -3790,13 +3793,13 @@ rtmpte_protocol_suggest="zlib" +@@ -3827,13 +3830,13 @@ rtmpte_protocol_suggest="zlib" rtmpts_protocol_select="ffrtmphttp_protocol https_protocol" rtmpts_protocol_suggest="zlib" rtp_protocol_select="udp_protocol" @@ -87,7 +87,7 @@ index 783866fea4..c4e2ce4652 100755 tls_protocol_select="tcp_protocol" udp_protocol_select="network" udplite_protocol_select="network" -@@ -3819,7 +3822,7 @@ libsmbclient_protocol_deps="libsmbclient gplv3" +@@ -3856,7 +3859,7 @@ libsmbclient_protocol_deps="libsmbclient gplv3" libsrt_protocol_deps="libsrt" libsrt_protocol_select="network" libssh_protocol_deps="libssh" @@ -96,7 +96,7 @@ index 783866fea4..c4e2ce4652 100755 libzmq_protocol_deps="libzmq" libzmq_protocol_select="network" -@@ -6866,6 +6869,7 @@ enabled decklink && { require_headers DeckLinkAPI.h && +@@ -6919,6 +6922,7 @@ enabled decklink && { require_headers DeckLinkAPI.h && enabled frei0r && require_headers "frei0r.h" enabled gmp && require gmp gmp.h mpz_export -lgmp enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init @@ -105,10 +105,10 @@ index 783866fea4..c4e2ce4652 100755 enabled ladspa && require_headers "ladspa.h dlfcn.h" enabled lcms2 && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h cmsCreateContext diff --git a/libavformat/Makefile b/libavformat/Makefile -index 7ca68a7036..dcc3dac87e 100644 +index 074efc118a..8ea80d3abd 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile -@@ -705,6 +705,7 @@ TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o +@@ -707,6 +707,7 @@ TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o TLS-OBJS-$(CONFIG_LIBTLS) += tls_libtls.o TLS-OBJS-$(CONFIG_MBEDTLS) += tls_mbedtls.o TLS-OBJS-$(CONFIG_OPENSSL) += tls_openssl.o @@ -117,7 +117,7 @@ index 7ca68a7036..dcc3dac87e 100644 TLS-OBJS-$(CONFIG_SCHANNEL) += tls_schannel.o OBJS-$(CONFIG_TLS_PROTOCOL) += tls.o $(TLS-OBJS-yes) diff --git a/libavformat/network.c b/libavformat/network.c -index 6db82b6d26..8775670bea 100644 +index 2eabd0c167..d794953358 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -44,6 +44,9 @@ int ff_tls_init(void) @@ -406,5 +406,5 @@ index 0000000000..23255c0f1b + .priv_data_class = &tls_class, +}; -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch b/patches/master/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch index eec8857..8e755be 100644 --- a/patches/master/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch +++ b/patches/master/0026-avformat-mpegts-index-only-keyframes-to-ensure-accur.patch @@ -1,7 +1,7 @@ -From 863a4031e8f5621d27b4617724df0c3269e671e4 Mon Sep 17 00:00:00 2001 +From 97dc22305de1c1efe9eca72d5605a131e639b9c3 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Thu, 9 Feb 2023 18:08:11 +0800 -Subject: [PATCH 26/29] avformat/mpegts: index only keyframes to ensure +Subject: [PATCH 26/33] avformat/mpegts: index only keyframes to ensure accurate seeks https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190507032623.80375-1-ffmpeg@tmm1.net/ @@ -10,10 +10,10 @@ https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190507032623.80375-1-ffmpeg@ 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index 6b02187eb1..ae891ebb92 100644 +index 765bedec5c..de0227faf3 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c -@@ -3361,7 +3361,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, +@@ -3382,7 +3382,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, av_packet_free(&pkt); return AV_NOPTS_VALUE; } @@ -23,5 +23,5 @@ index 6b02187eb1..ae891ebb92 100644 av_add_index_entry(s->streams[pkt->stream_index], pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); if (pkt->stream_index == stream_index && pkt->pos >= *ppos) { -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0027-windows-shared-static-libs-in-one-build.patch b/patches/master/0027-windows-shared-static-libs-in-one-build.patch index 5c40d6a..f6f98d3 100644 --- a/patches/master/0027-windows-shared-static-libs-in-one-build.patch +++ b/patches/master/0027-windows-shared-static-libs-in-one-build.patch @@ -1,7 +1,7 @@ -From 8a0bad8dee4478ea3163eda03bdbfc9bb7e1491e Mon Sep 17 00:00:00 2001 +From 0187be90396df7f13d941697dc1a867fe4bf6884 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 15 Oct 2023 13:22:34 +0800 -Subject: [PATCH 27/29] windows: shared + static libs in one build +Subject: [PATCH 27/33] windows: shared + static libs in one build av_export_avutil avpriv_vga16_font will result in LINK4217 warning when building ffmpeg.dll, and undefined dllimport avpriv_vga16_font error when linking exe --- @@ -10,10 +10,10 @@ av_export_avutil avpriv_vga16_font will result in LINK4217 warning when building 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure b/configure -index c4e2ce4652..a295b83dd6 100755 +index 7e2cf1b605..62a5143df7 100755 --- a/configure +++ b/configure -@@ -5871,8 +5871,12 @@ case $target_os in +@@ -5916,8 +5916,12 @@ case $target_os in # for shared libs. LD_LIB='%.lib' # Cannot build both shared and static libs with MSVC or icl. @@ -27,7 +27,7 @@ index c4e2ce4652..a295b83dd6 100755 test_cmd $windres --version && enable gnu_windres enabled x86_32 && check_ldflags -LARGEADDRESSAWARE add_cppflags -DWIN32_LEAN_AND_MEAN -@@ -5892,8 +5896,6 @@ case $target_os in +@@ -5937,8 +5941,6 @@ case $target_os in [ "$toolchain" = msvc ] && { ranlib=: } || { @@ -51,5 +51,5 @@ index 69dc337120..decbf6e0c2 100644 #endif /* AVUTIL_XGA_FONT_DATA_H */ -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch b/patches/master/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch index b9fdd2d..b477dc2 100644 --- a/patches/master/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch +++ b/patches/master/0028-lavc-videotoolboxenc-add-hevc-main42210-and-p210.patch @@ -1,7 +1,7 @@ -From 5e6f730da38e65d23bc1e6bfb9369c3d4b4ef796 Mon Sep 17 00:00:00 2001 +From 4712ee8fb4561cb9c073165c15eada8bad6477ef Mon Sep 17 00:00:00 2001 From: wang-bin Date: Thu, 22 Dec 2022 10:39:29 +0800 -Subject: [PATCH 28/30] lavc/videotoolboxenc: add hevc main42210 and p210 +Subject: [PATCH 28/33] lavc/videotoolboxenc: add hevc main42210 and p210 supported by apple silicon --- diff --git a/patches/master/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch b/patches/master/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch index 1e857bc..d3386d2 100644 --- a/patches/master/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch +++ b/patches/master/0029-Revert-avutil-timestamp-change-precision-of-av_ts_ma.patch @@ -1,7 +1,7 @@ -From cabe90d500966bf74a9cefe4cc57df53e216ea4a Mon Sep 17 00:00:00 2001 +From 17ce25eb57cd80013398a13cf973937a7812a4df Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 11 Aug 2024 10:27:43 +0800 -Subject: [PATCH 29/29] Revert "avutil/timestamp: change precision of +Subject: [PATCH 29/33] Revert "avutil/timestamp: change precision of av_ts_make_time_string()" This reverts commit 8c936e9b437aaed0ca10f3ec2edebf06cad6a5b5. @@ -61,5 +61,5 @@ index e66ffe5fdd..bc53fea047 100644 pts=138240 pts=184320 -- -2.39.3 (Apple Git-146) +2.39.5 (Apple Git-154) diff --git a/patches/master/0030-hls-support-segments-pretend-to-be-gif-png.patch b/patches/master/0030-hls-support-segments-pretend-to-be-gif-png.patch index cebf706..4ff2cd2 100644 --- a/patches/master/0030-hls-support-segments-pretend-to-be-gif-png.patch +++ b/patches/master/0030-hls-support-segments-pretend-to-be-gif-png.patch @@ -1,14 +1,14 @@ -From a5c5359023c696e002f9c52721452c3c4d719a1f Mon Sep 17 00:00:00 2001 +From 1c17bc32d734bdae57320a59420a2a7f56c1ead8 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sun, 29 Sep 2024 15:59:13 +0800 -Subject: [PATCH 30/30] hls: support segments pretend to be gif & png +Subject: [PATCH 30/33] hls: support segments pretend to be gif & png --- libavformat/hls.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c -index 62473a15dd..7aa18079d9 100644 +index 045741c3b4..525ca999dc 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -222,6 +222,7 @@ typedef struct HLSContext { diff --git a/patches/master/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch b/patches/master/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch index 1ffb9c3..0606eef 100644 --- a/patches/master/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch +++ b/patches/master/0031-hevc-disable-Unknown-profile-bitstream-warning-for-s.patch @@ -1,7 +1,7 @@ -From 476fb02d88e8d86c1883f81b40d5d9ba57f95487 Mon Sep 17 00:00:00 2001 +From 4505760e37550c826d8790252e231737e6cbfa9b Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 15 Oct 2024 17:07:02 +0800 -Subject: [PATCH 31/31] hevc: disable Unknown profile bitstream warning for +Subject: [PATCH 31/33] hevc: disable Unknown profile bitstream warning for small configuration --- @@ -9,7 +9,7 @@ Subject: [PATCH 31/31] hevc: disable Unknown profile bitstream warning for 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c -index a1d352eec5..0efb4bc393 100644 +index 285084685b..e1f54f3c74 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -254,9 +254,9 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, diff --git a/patches/master/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch b/patches/master/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch new file mode 100644 index 0000000..f7ace23 --- /dev/null +++ b/patches/master/0032-hwcontext_vaapi-fix-undefined-close-on-windows.patch @@ -0,0 +1,27 @@ +From 26bf49c0209caaf26e94a1ecff365d459a9b859f Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 19 Nov 2024 19:43:02 +0800 +Subject: [PATCH 32/33] hwcontext_vaapi: fix undefined close() on windows + +--- + libavutil/hwcontext_vaapi.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c +index 95aa38d9d2..95fbba514c 100644 +--- a/libavutil/hwcontext_vaapi.c ++++ b/libavutil/hwcontext_vaapi.c +@@ -1643,8 +1643,10 @@ static void vaapi_device_free(AVHWDeviceContext *ctx) + XCloseDisplay(priv->x11_display); + #endif + ++#if HAVE_VAAPI_DRM + if (priv->drm_fd >= 0) + close(priv->drm_fd); ++#endif + + av_freep(&priv); + } +-- +2.39.5 (Apple Git-154) + diff --git a/patches/master/0033-matroskadec-support-S_TEXT-WEBVTT.patch b/patches/master/0033-matroskadec-support-S_TEXT-WEBVTT.patch new file mode 100644 index 0000000..28c1229 --- /dev/null +++ b/patches/master/0033-matroskadec-support-S_TEXT-WEBVTT.patch @@ -0,0 +1,107 @@ +From 991822db7a7b064685d0d11bb05e4c0c37a4e9d2 Mon Sep 17 00:00:00 2001 +From: wang-bin +Date: Tue, 17 Dec 2024 23:21:57 +0800 +Subject: [PATCH 33/33] matroskadec: support S_TEXT/WEBVTT + +fix ticket #5641 +--- + libavformat/matroska.c | 1 + + libavformat/matroskadec.c | 26 ++++++++++++++++++++++++++ + 2 files changed, 27 insertions(+) + +diff --git a/libavformat/matroska.c b/libavformat/matroska.c +index d0ecfbeb6a..23c4ad6949 100644 +--- a/libavformat/matroska.c ++++ b/libavformat/matroska.c +@@ -63,6 +63,7 @@ const CodecTags ff_mkv_codec_tags[]={ + {"D_WEBVTT/CAPTIONS" , AV_CODEC_ID_WEBVTT}, + {"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT}, + {"D_WEBVTT/METADATA" , AV_CODEC_ID_WEBVTT}, ++ {"S_TEXT/WEBVTT" , AV_CODEC_ID_WEBVTT}, + + {"S_TEXT/UTF8" , AV_CODEC_ID_SUBRIP}, + {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT}, +diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c +index efa3e44c85..0fbcf3a720 100644 +--- a/libavformat/matroskadec.c ++++ b/libavformat/matroskadec.c +@@ -3765,6 +3765,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + MatroskaTrack *track, + AVStream *st, + uint8_t *data, int data_len, ++ MatroskaBlockMore *blockmore, int nb_blockmore, + uint64_t timecode, + uint64_t duration, + int64_t pos) +@@ -3774,13 +3775,28 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + int id_len, settings_len, text_len; + uint8_t *p, *q; + int err; ++ const int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9); + + if (data_len <= 0) + return AVERROR_INVALIDDATA; + ++ if (!webm_style) { ++ text = data; ++ text_len = data_len; ++ if (nb_blockmore <= 0) ++ goto make_pkt; ++ data = blockmore->additional.data; ++ data_len = blockmore->additional.size; ++ } ++ + p = data; + q = data + data_len; + ++ if (webm_style) ++ goto parse_id; ++ goto parse_settings; ++ ++parse_id: + id = p; + id_len = -1; + while (p < q) { +@@ -3796,7 +3812,11 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + if (p >= q || *p != '\n') + return AVERROR_INVALIDDATA; + p++; ++ if (webm_style) ++ goto parse_settings; ++ goto make_pkt; + ++parse_settings: + settings = p; + settings_len = -1; + while (p < q) { +@@ -3812,7 +3832,11 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + if (p >= q || *p != '\n') + return AVERROR_INVALIDDATA; + p++; ++ if (webm_style) ++ goto parse_text; ++ goto parse_id; + ++parse_text: + text = p; + text_len = q - p; + while (text_len > 0) { +@@ -3823,6 +3847,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, + text_len = len; + } + ++make_pkt: + if (text_len <= 0) + return AVERROR_INVALIDDATA; + +@@ -4215,6 +4240,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf + } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) { + res = matroska_parse_webvtt(matroska, track, st, + out_data, out_size, ++ blockmore, nb_blockmore, + timecode, lace_duration, + pos); + if (!buf) +-- +2.39.5 (Apple Git-154) +