Commit 59976140 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Drop Evas code

parent 426935a8
......@@ -226,18 +226,12 @@ libmedialibrary_la_LDFLAGS += -Wl,-undefined,dynamic_lookup,-framework,Foundatio
endif
if HAVE_EVAS
libmedialibrary_la_SOURCES += src/metadata_services/vlc/imagecompressors/EvasCompressor.cpp
noinst_HEADERS += src/metadata_services/vlc/imagecompressors/EvasCompressor.h
libmedialibrary_la_CPPFLAGS += $(EVAS_CFLAGS)
else
if HAVE_LIBJPEG
libmedialibrary_la_SOURCES += src/metadata_services/vlc/imagecompressors/JpegCompressor.cpp
noinst_HEADERS += src/metadata_services/vlc/imagecompressors/JpegCompressor.h
libmedialibrary_la_CPPFLAGS += $(LIBJPEG_CFLAGS)
libmedialibrary_la_LIBADD += $(LIBJPEG_LIBS)
endif
endif
lib_LTLIBRARIES = libmedialibrary.la
if HAVE_DARWIN
......
......@@ -295,15 +295,6 @@ PKG_CHECK_MODULES(LIBJPEG, libjpeg, [
])
AM_CONDITIONAL([HAVE_LIBJPEG], [test "${have_libjpeg}" = "yes"])
AC_ARG_ENABLE(evas, AC_HELP_STRING([--enable-evas], [Use evas to compress thumbnails]))
AS_IF([test "$enable_evas" = "yes"],
[PKG_CHECK_MODULES(EVAS, evas, [
have_evas="yes"
AC_DEFINE(HAVE_EVAS, 1, [Define to 1 if evas is available])
])])
AM_CONDITIONAL([HAVE_EVAS], [test "${have_evas}" = "yes"])
AC_ARG_ENABLE(tests,AC_HELP_STRING([--disable-tests], [Disable build of automated tests suites]))
AM_CONDITIONAL([HAVE_TESTS], [test "${enable_tests}" = "yes"])
AS_IF([test "${enable_tests}" = "yes"], [
......
......@@ -39,8 +39,6 @@
#ifdef HAVE_JPEG
#include "imagecompressors/JpegCompressor.h"
#elif defined(HAVE_EVAS)
#include "imagecompressors/EvasCompressor.h"
#else
#error No image compressor available
#endif
......@@ -55,8 +53,6 @@ VLCThumbnailer::VLCThumbnailer( MediaLibraryPtr ml )
{
#ifdef HAVE_JPEG
m_compressor.reset( new JpegCompressor );
#elif defined(HAVE_EVAS)
m_compressor.reset( new EvasCompressor );
#endif
}
......
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "EvasCompressor.h"
#include <Evas_Engine_Buffer.h>
#include <cstring>
namespace medialibrary
{
EvasCompressor::EvasCompressor()
: m_canvas( nullptr, &evas_free )
, m_buffSize( 0 )
{
static int fakeBuffer;
#ifndef TIZEN
evas_init();
#endif
auto method = evas_render_method_lookup("buffer");
m_canvas.reset( evas_new() );
if ( m_canvas == nullptr )
throw std::runtime_error( "Failed to allocate canvas" );
evas_output_method_set( m_canvas.get(), method );
evas_output_size_set(m_canvas.get(), 1, 1 );
evas_output_viewport_set( m_canvas.get(), 0, 0, 1, 1 );
auto einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get( m_canvas.get() );
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
einfo->info.dest_buffer = &fakeBuffer;
einfo->info.dest_buffer_row_bytes = 4;
einfo->info.use_color_key = 0;
einfo->info.alpha_threshold = 0;
einfo->info.func.new_update_region = NULL;
einfo->info.func.free_update_region = NULL;
evas_engine_info_set( m_canvas.get(), (Evas_Engine_Info *)einfo );
}
EvasCompressor::~EvasCompressor()
{
#if !defined(TIZEN)
evas_shutdown();
#endif
}
const char* EvasCompressor::extension() const
{
return "png";
}
const char* EvasCompressor::fourCC() const
{
return "RV32";
}
uint32_t EvasCompressor::bpp() const
{
return 4;
}
bool EvasCompressor::compress( const uint8_t* buffer, const std::string& output,
uint32_t inputWidth, uint32_t inputHeight,
uint32_t outputWidth, uint32_t outputHeight,
uint32_t hOffset, uint32_t vOffset )
{
const auto stride = inputWidth * 4u;
auto evas_obj = std::unique_ptr<Evas_Object, void(*)(Evas_Object*)>( evas_object_image_add( m_canvas.get() ), evas_object_del );
if ( evas_obj == nullptr )
return false;
auto buffSize = outputWidth * outputHeight * bpp();
if ( m_buffSize < buffSize )
{
m_cropBuffer.reset( new uint8_t[ buffSize ] );
m_buffSize = buffSize;
}
auto p_buff = buffer;
if ( outputWidth != inputWidth )
{
p_buff += vOffset * stride;
for ( auto y = 0u; y < outputHeight; ++y )
{
memcpy( m_cropBuffer.get() + y * outputWidth * 4, p_buff + (hOffset * 4),
outputWidth * 4 );
p_buff += stride;
}
vOffset = 0;
p_buff = m_cropBuffer.get();
}
evas_object_image_colorspace_set( evas_obj.get(), EVAS_COLORSPACE_ARGB8888 );
evas_object_image_size_set( evas_obj.get(), outputWidth, outputHeight );
evas_object_image_data_set( evas_obj.get(), const_cast<uint8_t*>( p_buff + vOffset * stride ) );
evas_object_image_save( evas_obj.get(), output.c_str(), NULL, "quality=100 compress=9");
return true;
}
}
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include "IImageCompressor.h"
#include <Evas.h>
#include <memory>
namespace medialibrary
{
class EvasCompressor : public IImageCompressor
{
public:
EvasCompressor();
virtual ~EvasCompressor();
virtual const char* extension() const override;
virtual const char* fourCC() const override;
virtual uint32_t bpp() const override;
virtual bool compress( const uint8_t* buffer, const std::string& output,
uint32_t inputWidth, uint32_t inputHeight,
uint32_t outputWidth, uint32_t outputHeight,
uint32_t hOffset, uint32_t vOffset ) override;
private:
std::unique_ptr<Evas, void(*)(Evas*)> m_canvas;
std::unique_ptr<uint8_t[]> m_cropBuffer;
size_t m_buffSize;
};
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment