Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[rbp] added raspberrypi omx image decoding

  • Loading branch information...
commit 8bd067db9a3bb264e947a065229adaeba7a0509e 1 parent d7b9041
huceke huceke authored
3  xbmc/guilib/GUITexture.cpp
View
@@ -321,6 +321,9 @@ bool CGUITextureBase::AllocResources()
return false;
m_texture = texture;
+
+ m_info.orientation = m_texture.m_orientation;
+
changed = true;
}
else
55 xbmc/guilib/Texture.cpp
View
@@ -36,6 +36,11 @@
#include "URL.h"
#include "filesystem/AndroidAppFile.h"
#endif
+
+#ifdef TARGET_RASPBERRY_PI
+#include "xbmc/cores/omxplayer/OMXImage.h"
+#endif
+
/************************************************************************/
/* */
/************************************************************************/
@@ -230,6 +235,56 @@ CBaseTexture *CBaseTexture::LoadFromFileInMemory(unsigned char *buffer, size_t b
bool CBaseTexture::LoadFromFile(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight,
bool autoRotate, unsigned int *originalWidth, unsigned int *originalHeight)
{
+#ifdef TARGET_RASPBERRY_PI
+ if (URIUtils::GetExtension(texturePath).Equals(".jpg") ||
+ URIUtils::GetExtension(texturePath).Equals(".tbn")
+ /*|| URIUtils::GetExtension(texturePath).Equals(".png")*/)
+ {
+ COMXImage omx_image;
+
+ if(omx_image.ReadFile(texturePath))
+ {
+ //if(omx_image.Decode(maxWidth, maxHeight))
+ if(omx_image.Decode(omx_image.GetWidth(), omx_image.GetHeight()))
+ {
+ if (originalWidth)
+ *originalWidth = omx_image.GetOriginalWidth();
+ if (originalHeight)
+ *originalHeight = omx_image.GetOriginalHeight();
+
+ m_hasAlpha = omx_image.IsAlpha();
+
+ Allocate(omx_image.GetDecodedWidth(), omx_image.GetDecodedHeight(), XB_FMT_A8R8G8B8);
+
+ if(!m_pixels)
+ {
+ CLog::Log(LOGERROR, "Texture manager (OMX) out of memory");
+ omx_image.Close();
+ return false;
+ }
+
+ if (autoRotate && omx_image.GetOrientation())
+ m_orientation = omx_image.GetOrientation() - 1;
+
+ if(omx_image.GetDecodedData())
+ {
+ int size = ( (GetPitch() * GetRows() * 4 ) < omx_image.GetDecodedSize() ) ?
+ GetPitch() * GetRows() * 4 : omx_image.GetDecodedSize();
+
+ memcpy(m_pixels, (unsigned char *)omx_image.GetDecodedData(), size);
+ }
+
+ omx_image.Close();
+
+ return true;
+ }
+ else
+ {
+ omx_image.Close();
+ }
+ }
+ }
+#endif
if (URIUtils::GetExtension(texturePath).Equals(".dds"))
{ // special case for DDS images
CDDSImage image;
16 xbmc/pictures/Picture.cpp
View
@@ -19,6 +19,11 @@
*
*/
+#include "system.h"
+#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+ #include "config.h"
+#endif
+
#include "Picture.h"
#include "settings/AdvancedSettings.h"
#include "settings/GUISettings.h"
@@ -30,14 +35,22 @@
#include "DllSwScale.h"
#include "guilib/JpegIO.h"
#include "guilib/Texture.h"
+#if defined(HAVE_OMXLIB)
+#include "cores/omxplayer/OMXImage.h"
+#endif
using namespace XFILE;
bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile)
{
CLog::Log(LOGDEBUG, "cached image '%s' size %dx%d", thumbFile.c_str(), width, height);
- if (URIUtils::GetExtension(thumbFile).Equals(".jpg"))
+ if (URIUtils::GetExtension(thumbFile).Equals(".jpg") || URIUtils::GetExtension(thumbFile).Equals(".tbn"))
{
+#if defined(HAVE_OMXLIB)
+ COMXImage omxImage;
+ if (omxImage.CreateThumbnailFromSurface((BYTE *)buffer, width, height, XB_FMT_A8R8G8B8, stride, thumbFile.c_str()))
+ return true;
+#endif
CJpegIO jpegImage;
if (jpegImage.CreateThumbnailFromSurface((BYTE *)buffer, width, height, XB_FMT_A8R8G8B8, stride, thumbFile.c_str()))
return true;
@@ -104,6 +117,7 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
dest_width = std::min(width, dest_width);
dest_height = std::min(height, dest_height);
+
// create a buffer large enough for the resulting image
GetScale(width, height, dest_width, dest_height);
uint32_t *buffer = new uint32_t[dest_width * dest_height];
Please sign in to comment.
Something went wrong with that request. Please try again.