[vlc-commits] VideoToolbox: add 4K support for Twister SoCs
Felix Paul Kühne
git at videolan.org
Mon Nov 16 19:14:20 CET 2015
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Nov 16 18:49:05 2015 +0100| [79f6c2f2fa5ae6a9d86b0ac066d1109d0f9e697a] | committer: Felix Paul Kühne
VideoToolbox: add 4K support for Twister SoCs
Also add a couple of missing warnings
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=79f6c2f2fa5ae6a9d86b0ac066d1109d0f9e697a
---
modules/codec/videotoolbox.m | 60 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 7 deletions(-)
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 0b3ded2..4fff71c 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -44,6 +44,12 @@
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
+
+/* support iOS SDKs < v9.1 */
+#ifndef CPUFAMILY_ARM_TWISTER
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#endif
+
#endif
#pragma mark - module descriptor
@@ -89,6 +95,7 @@ void VTDictionarySetInt32(CFMutableDictionaryRef, CFStringRef, int);
static void copy420YpCbCr8Planar(picture_t *, CVPixelBufferRef buffer,
unsigned i_width, unsigned i_height);
static BOOL deviceSupportsAdvancedProfiles();
+static BOOL deviceSupportsAdvancedLevels();
struct picture_sys_t {
CFTypeRef pixelBuffer;
@@ -158,12 +165,19 @@ static CMVideoCodecType CodecPrecheck(decoder_t *p_dec)
#if !TARGET_OS_IPHONE
/* a level higher than 5.2 was not tested, so don't dare to
* try to decode it*/
- if (i_level > 52)
+ if (i_level > 52) {
+ msg_Dbg(p_dec, "unsupported H264 level %zu", i_level);
return -1;
+ }
#else
/* on SoC A8, 4.2 is the highest specified profile */
- if (i_level > 42)
- return -1;
+ if (i_level > 42) {
+ /* on Twister, we can do up to 5.2 */
+ if (!deviceSupportsAdvancedLevels() || i_level > 52) {
+ msg_Dbg(p_dec, "unsupported H264 level %zu", i_level);
+ return -1;
+ }
+ }
#endif
break;
@@ -322,6 +336,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
if (i_ret != VLC_SUCCESS) {
free(p_alloc_buf);
+ msg_Warn(p_dec, "extra buffer allocation failed");
return VLC_EGENERIC;
}
@@ -329,6 +344,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
size_t i_sps_size = 0, i_pps_size = 0;
if (!p_buf) {
free(p_alloc_buf);
+ msg_Warn(p_dec, "extra buffer allocation failed");
return VLC_EGENERIC;
}
@@ -341,7 +357,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
&p_pps_buf,
&i_pps_size);
if (i_ret != VLC_SUCCESS) {
- msg_Warn(p_dec, "sps pps parsing failed");
+ msg_Warn(p_dec, "sps pps detection failed");
free(p_alloc_buf);
return VLC_EGENERIC;
}
@@ -353,6 +369,7 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
if (i_ret != VLC_SUCCESS) {
free(p_alloc_buf);
+ msg_Warn(p_dec, "sps pps parsing failed");
return VLC_EGENERIC;
}
/* this data is more trust-worthy than what we receive
@@ -373,8 +390,10 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
&sps_data, p_sps_buf, i_sps_size,
p_pps_buf, i_pps_size);
free(p_alloc_buf);
- if (!p_block)
+ if (!p_block) {
+ msg_Warn(p_dec, "buffer creation failed");
return VLC_EGENERIC;
+ }
extradata = CFDataCreate(kCFAllocatorDefault,
p_block->p_buffer,
@@ -585,8 +604,10 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t *p_block)
/* setup storage */
p_sys->outputTimeStamps = [[NSMutableArray alloc] init];
p_sys->outputFrames = [[NSMutableDictionary alloc] init];
- if (!p_sys->outputFrames)
+ if (!p_sys->outputFrames) {
+ msg_Warn(p_dec, "buffer management structure allocation failed");
return VLC_ENOMEM;
+ }
p_sys->b_started = YES;
@@ -638,8 +659,9 @@ static int OpenDecoder(vlc_object_t *p_this)
/* check quickly if we can digest the offered data */
CMVideoCodecType codec;
codec = CodecPrecheck(p_dec);
- if (codec == -1)
+ if (codec == -1) {
return VLC_EGENERIC;
+ }
/* now that we see a chance to decode anything, allocate the
* internals and start the decoding session */
@@ -715,6 +737,30 @@ static BOOL deviceSupportsAdvancedProfiles()
#endif
}
+static BOOL deviceSupportsAdvancedLevels()
+{
+#if TARGET_IPHONE_SIMULATOR
+ return YES;
+#endif
+#if TARGET_OS_IPHONE
+ size_t size;
+ int32_t cpufamily;
+
+ size = sizeof(cpufamily);
+ sysctlbyname("hw.cpufamily", &cpufamily, &size, NULL, 0);
+
+ /* Proper 4K decoding requires a Twister SoC
+ * Everything below will kill the decoder daemon */
+ if (cpufamily == CPUFAMILY_ARM_TWISTER) {
+ return YES;
+ }
+
+ return NO;
+#else
+ return YES;
+#endif
+}
+
static inline void bo_add_mp4_tag_descr(bo_t *p_bo, uint8_t tag, uint32_t size)
{
bo_add_8(p_bo, tag);
More information about the vlc-commits
mailing list