diff mbox

[FFmpeg-devel] videotoolboxenc.c crash on iOS8

Message ID CABmg8gU4OJc3rdTsP7x50Dc9Hsnsy9w_kTy4rnsCecUc1i1mYQ@mail.gmail.com
State New
Headers show

Commit Message

Rick Kern June 23, 2017, 1:45 p.m. UTC
On June 17, 2017 at 6:46:58 PM, Steven Liu (lingjiujianke@gmail.com) wrote:

2017-06-17 11:17 GMT+08:00 姜 文杰 <wj.jiang@outlook.com>:
> when use videotoolboxencoder in ffmpeg, some codes will lead to crash.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

From ee465de23b27cbeaaa25fd3d8abf57680394a284 Mon Sep 17 00:00:00 2001
From: jerett <wj.jiang@outlook.com>
Date: Mon, 16 Jan 2017 16:44:11 +0800
Subject: [PATCH 1/2] fix open videotoolbox bug on iOS8.4

---
libavcodec/videotoolboxenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

static pthread_once_t once_ctrl = PTHREAD_ONCE_INIT;
diff mbox

Patch

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index cb9e2fe6e8..dbc9031384 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1137,7 +1137,7 @@  static av_cold int vtenc_init(AVCodecContext *avctx)
kCFAllocatorDefault,
&has_b_frames_cfbool);

- if (!status) {
+ if (!status && has_b_frames_cfbool) {
//Some devices don't output B-frames for main profile, even
if requested.
vtctx->has_b_frames = CFBooleanGetValue(has_b_frames_cfbool);
CFRelease(has_b_frames_cfbool);
-- 
2.11.0 (Apple Git-81)


From 8eaab291bee268b0ae7fe4ed7795b2af4c55a275 Mon Sep 17 00:00:00 2001
From: jerett <wj.jiang@outlook.com>
Date: Sat, 17 Jun 2017 10:22:58 +0800
Subject: [PATCH 2/2] fix loadVTEncSymbols crash when symbol not found

---
libavcodec/videotoolboxenc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 37c7957394..96c5648818 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -73,11 +73,11 @@  static struct{

#define GET_SYM(symbol, defaultVal) \
do{ \
- CFStringRef cfstr = *(CFStringRef*)dlsym(RTLD_DEFAULT, #symbol); \
- if(!cfstr) \
+ CFStringRef* handle = (CFStringRef*)dlsym(RTLD_DEFAULT, #symbol);
\
+ if(!handle) \
compat_keys.symbol = CFSTR(defaultVal); \
else \
- compat_keys.symbol = cfstr; \
+ compat_keys.symbol = *handle; \
}while(0)