-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
5,275 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 32384390987626641fbb194bc121766b690ddade Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
30 changes: 30 additions & 0 deletions
30
patches/7.0/0002-configure-fix-mmal-probing-in-cross-build.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 33fc7724f126cfe1757451bee573c7c9b03dd245 Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
76 changes: 76 additions & 0 deletions
76
patches/7.0/0003-videotoolbox-check-runtime-availability.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
From 1f56f900c86382dbc70960d704683196a3526b20 Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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 <AvailabilityMacros.h> | ||
#include <TargetConditionals.h> | ||
|
||
+#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) | ||
|
36 changes: 36 additions & 0 deletions
36
patches/7.0/0004-mediacodec-check-whether-cropping-is-set-before-use.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 85c541d3a0134dbcf9afc3ea966e6112b15875c5 Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
42 changes: 42 additions & 0 deletions
42
patches/7.0/0005-avcodec-add-AV_HWACCEL_FLAG_ALLOW_SOFTWARE.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From ee807f40880b48bb1857fba7c6da4ed1b935999f Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
34 changes: 34 additions & 0 deletions
34
patches/7.0/0006-videotoolbox-allow-software-implementation.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From 6671aa21d45d84bd3b707dad229604f698df62b5 Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 8bc90de7eb5a50d09f97f8dd70c4ee471298c300 Mon Sep 17 00:00:00 2001 | ||
From: wang-bin <wbsecg1@gmail.com> | ||
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) | ||
|
Oops, something went wrong.