aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Davilla <davilla@4pi.com>2011-03-26 00:53:05 -0400
committerS. Davilla <davilla@4pi.com>2011-03-26 00:58:59 -0400
commitfd2c0793e897ac1acb728063c106933cfd1a4049 (patch)
treef31899702aca9fdbc9f056b290c74cac2c3c698b
parent49f51243823204d5540d0b4e4ffec9ebabb5886c (diff)
fixes #11348, videotoolbox hw decode support under iOS/ATV 4.3.x
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp70
-rw-r--r--xbmc/osx/DarwinUtils.h1
-rw-r--r--xbmc/osx/DarwinUtils.mm13
3 files changed, 65 insertions, 19 deletions
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
index bec2b25c52..38bf28aafa 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
@@ -108,15 +108,26 @@ extern void VTDecompressionSessionInvalidate(VTDecompressionSessionRef session);
extern void VTDecompressionSessionRelease(VTDecompressionSessionRef session);
extern VTDecompressionSessionRef VTDecompressionSessionRetain(VTDecompressionSessionRef session);
extern OSStatus VTDecompressionSessionWaitForAsynchronousFrames(VTDecompressionSessionRef session);
+
//-----------------------------------------------------------------------------------
// /System/Library/Frameworks/CoreMedia.framework
+union
+{
+ void* lpAddress;
+ // iOS <= 4.2
+ OSStatus (*FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom1)(
+ CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
+ UInt32 atomId, const UInt8 *data, CFIndex len, CMFormatDescriptionRef *formatDesc);
+ // iOS >= 4.3
+ OSStatus (*FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom2)(
+ CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
+ UInt32 atomId, const UInt8 *data, CFIndex len, CFDictionaryRef extensions, CMFormatDescriptionRef *formatDesc);
+} FigVideoHack;
extern OSStatus FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom(
CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
UInt32 atomId, const UInt8 *data, CFIndex len, CMFormatDescriptionRef *formatDesc);
-extern void FigFormatDescriptionRelease(CMFormatDescriptionRef desc);
+
extern CMSampleBufferRef FigSampleBufferRetain(CMSampleBufferRef buf);
-extern void FigSampleBufferRelease(CMSampleBufferRef buf);
-extern void FigBlockBufferRelease(CMBlockBufferRef buf);
//-----------------------------------------------------------------------------------
#pragma pack(pop)
@@ -138,6 +149,7 @@ int CheckNP2( unsigned x )
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// helper functions for debuging VTDecompression
+#if _DEBUG
char* vtutil_string_to_utf8(CFStringRef s)
{
char *result;
@@ -223,7 +235,7 @@ void vtdec_session_dump_properties(VTDecompressionSessionRef session)
error:
CLog::Log(LOGDEBUG, "failed to dump properties\n");
}
-
+#endif
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// helper function that inserts an int32_t into a dictionary
@@ -324,15 +336,35 @@ CreateFormatDescriptionFromCodecData(VTFormatId format_id, int width, int height
CMFormatDescriptionRef fmt_desc;
OSStatus status;
- status = FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom(
- NULL, // CFAllocatorRef allocator ???
- format_id,
- width,
- height,
- atom,
- extradata,
- extradata_size,
- &fmt_desc);
+ FigVideoHack.lpAddress = (void*)FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom;
+
+ if (GetIOSVersion() < 4.3)
+ {
+ CLog::Log(LOGDEBUG, "%s - GetIOSVersion says < 4.3", __FUNCTION__);
+ status = FigVideoHack.FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom1(
+ NULL,
+ format_id,
+ width,
+ height,
+ atom,
+ extradata,
+ extradata_size,
+ &fmt_desc);
+ }
+ else
+ {
+ CLog::Log(LOGDEBUG, "%s - GetIOSVersion says >= 4.3", __FUNCTION__);
+ status = FigVideoHack.FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom2(
+ NULL,
+ format_id,
+ width,
+ height,
+ atom,
+ extradata,
+ extradata_size,
+ NULL,
+ &fmt_desc);
+ }
if (status == kVTDecoderNoErr)
return fmt_desc;
@@ -375,7 +407,7 @@ CreateSampleBufferFrom(CMFormatDescriptionRef fmt_desc, void *demux_buff, size_t
&sBufOut); // CMSampleBufferRef *sBufOut
}
- FigBlockBufferRelease(newBBufOut);
+ CFRelease(newBBufOut);
/*
CLog::Log(LOGDEBUG, "%s - CreateSampleBufferFrom size %ld demux_buff [0x%08x] sBufOut [0x%08x]",
@@ -909,7 +941,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o
{
if (m_fmt_desc)
{
- FigFormatDescriptionRelease(m_fmt_desc);
+ CFRelease(m_fmt_desc);
m_fmt_desc = NULL;
}
m_pFormatName = "";
@@ -945,7 +977,7 @@ void CDVDVideoCodecVideoToolBox::Dispose()
DestroyVTSession();
if (m_fmt_desc)
{
- FigFormatDescriptionRelease(m_fmt_desc);
+ CFRelease(m_fmt_desc);
m_fmt_desc = NULL;
}
@@ -1048,7 +1080,7 @@ int CDVDVideoCodecVideoToolBox::Decode(BYTE* pData, int iSize, double dts, doubl
CLog::Log(LOGNOTICE, "%s - VTDecompressionSessionDecodeFrame returned(%d)",
__FUNCTION__, (int)status);
CFRelease(frameInfo);
- FigSampleBufferRelease(sampleBuff);
+ CFRelease(sampleBuff);
if (demux_size)
m_dllAvUtil->av_free(demux_buff);
return VC_ERROR;
@@ -1065,14 +1097,14 @@ int CDVDVideoCodecVideoToolBox::Decode(BYTE* pData, int iSize, double dts, doubl
CLog::Log(LOGNOTICE, "%s - VTDecompressionSessionWaitForAsynchronousFrames returned(%d)",
__FUNCTION__, (int)status);
CFRelease(frameInfo);
- FigSampleBufferRelease(sampleBuff);
+ CFRelease(sampleBuff);
if (demux_size)
m_dllAvUtil->av_free(demux_buff);
return VC_ERROR;
}
CFRelease(frameInfo);
- FigSampleBufferRelease(sampleBuff);
+ CFRelease(sampleBuff);
if (demux_size)
m_dllAvUtil->av_free(demux_buff);
}
diff --git a/xbmc/osx/DarwinUtils.h b/xbmc/osx/DarwinUtils.h
index b30d01b3bb..daab73da22 100644
--- a/xbmc/osx/DarwinUtils.h
+++ b/xbmc/osx/DarwinUtils.h
@@ -27,6 +27,7 @@
extern "C"
{
#endif
+ float GetIOSVersion(void);
int GetDarwinFrameworkPath(bool forPython, char* path, uint32_t *pathsize);
int GetDarwinExecutablePath(char* path, uint32_t *pathsize);
diff --git a/xbmc/osx/DarwinUtils.mm b/xbmc/osx/DarwinUtils.mm
index 0309907dc2..a9121065ca 100644
--- a/xbmc/osx/DarwinUtils.mm
+++ b/xbmc/osx/DarwinUtils.mm
@@ -28,6 +28,7 @@
#if defined(__APPLE__)
#if defined(__arm__)
#import <Foundation/Foundation.h>
+ #import <UIKit/UIKit.h>
#import <mach/mach_host.h>
#import <sys/sysctl.h>
#else
@@ -36,6 +37,18 @@
#import "DarwinUtils.h"
+float GetIOSVersion(void)
+{
+ float version;
+#if defined(__arm__)
+ version = [[[UIDevice currentDevice] systemVersion] floatValue];
+#else
+ version = 0.0f;
+#endif
+
+ return(version);
+}
+
int GetDarwinFrameworkPath(bool forPython, char* path, uint32_t *pathsize)
{
// see if we can figure out who we are