Commit 91ed5673 authored by Manuel Günther's avatar Manuel Günther
Browse files

Based package on bob.io.base; Added bob_io_video library; Removed dependency on bob-io.

parent 0df59e6a
......@@ -8,7 +8,7 @@
#include "bobskin.h"
#include <stdexcept>
bobskin::bobskin(PyArrayObject* array, bob::core::array::ElementType eltype) {
bobskin::bobskin(PyArrayObject* array, bob::io::base::array::ElementType eltype) {
m_type.set<npy_intp>(eltype, PyArray_NDIM((PyArrayObject*)array),
PyArray_DIMS((PyArrayObject*)array),
......@@ -30,7 +30,7 @@ void bobskin::set(boost::shared_ptr<interface>) {
throw std::runtime_error("error is already set");
}
void bobskin::set (const bob::core::array::typeinfo&) {
void bobskin::set (const bob::io::base::array::typeinfo&) {
PyErr_SetString(PyExc_NotImplementedError, "setting C++ bobskin with (const typeinfo&) implemented - DEBUG ME!");
throw std::runtime_error("error is already set");
}
......
......@@ -2,7 +2,7 @@
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Tue 5 Nov 22:09:07 2013
*
* @brief A pythonic version of bob::core::array::interface, with minimal
* @brief A pythonic version of bob::io::base::array::interface, with minimal
* functionality.
*/
......@@ -11,7 +11,7 @@
#include <Python.h>
#include <bob/core/array.h>
#include <bob.io.base/array.h>
extern "C" {
#include <bob.blitz/capi.h>
......@@ -21,14 +21,14 @@ extern "C" {
/**
* Wraps a PyArrayObject such that we can access it from bob::io
*/
class bobskin: public bob::core::array::interface {
class bobskin: public bob::io::base::array::interface {
public: //api
/**
* @brief Builds a new skin from a numpy array object
*/
bobskin(PyArrayObject* array, bob::core::array::ElementType eltype);
bobskin(PyArrayObject* array, bob::io::base::array::ElementType eltype);
/**
* @brief By default, the interface is never freed. You must override
......@@ -50,12 +50,12 @@ class bobskin: public bob::core::array::interface {
* @brief Re-allocates this interface taking into consideration new
* requirements. The internal memory should be considered uninitialized.
*/
virtual void set (const bob::core::array::typeinfo& req);
virtual void set (const bob::io::base::array::typeinfo& req);
/**
* @brief Type information for this interface.
*/
virtual const bob::core::array::typeinfo& type() const { return m_type; }
virtual const bob::io::base::array::typeinfo& type() const { return m_type; }
/**
* @brief Borrows a reference from the underlying memory. This means
......@@ -75,7 +75,7 @@ class bobskin: public bob::core::array::interface {
private: //representation
bob::core::array::typeinfo m_type; ///< type information
bob::io::base::array::typeinfo m_type; ///< type information
void* m_ptr; ///< pointer to the data
};
......
......@@ -9,15 +9,14 @@
* Copyright (C) Idiap Research Institute, Martigny, Switzerland
*/
#include "reader.h"
#include <bob.io.video/reader.h>
#include <stdexcept>
#include <boost/format.hpp>
#include <boost/preprocessor.hpp>
#include <limits>
#include <bob/core/check.h>
#include <bob/core/blitz_array.h>
#include <bob.io.base/blitz_array.h>
#ifndef AV_PIX_FMT_RGB24
#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
......@@ -115,7 +114,7 @@ namespace bob { namespace io { namespace video {
/**
* This will make sure we can interface with the io subsystem
*/
m_typeinfo_video.dtype = m_typeinfo_frame.dtype = bob::core::array::t_uint8;
m_typeinfo_video.dtype = m_typeinfo_frame.dtype = bob::io::base::array::t_uint8;
m_typeinfo_video.nd = 4;
m_typeinfo_frame.nd = 3;
m_typeinfo_video.shape[0] = m_nframes;
......@@ -132,11 +131,11 @@ namespace bob { namespace io { namespace video {
size_t Reader::load(blitz::Array<uint8_t,4>& data,
bool throw_on_error, void (*check)(void)) const {
bob::core::array::blitz_array tmp(data);
bob::io::base::array::blitz_array tmp(data);
return load(tmp, throw_on_error, check);
}
size_t Reader::load(bob::core::array::interface& b,
size_t Reader::load(bob::io::base::array::interface& b,
bool throw_on_error, void (*check)(void)) const {
//checks if the output array shape conforms to the video specifications,
......@@ -153,7 +152,7 @@ namespace bob { namespace io { namespace video {
for (const_iterator it=begin(); it!=end();) {
if (check) check(); ///< runs user check function before we start our work
bob::core::array::blitz_array ref(static_cast<void*>(ptr), m_typeinfo_frame);
bob::io::base::array::blitz_array ref(static_cast<void*>(ptr), m_typeinfo_frame);
if (it.read(ref, throw_on_error)) {
ptr += frame_size;
++frames_read;
......@@ -244,11 +243,11 @@ namespace bob { namespace io { namespace video {
bool Reader::const_iterator::read(blitz::Array<uint8_t,3>& data,
bool throw_on_error) {
bob::core::array::blitz_array tmp(data);
bob::io::base::array::blitz_array tmp(data);
return read(tmp, throw_on_error);
}
bool Reader::const_iterator::read(bob::core::array::interface& data,
bool Reader::const_iterator::read(bob::io::base::array::interface& data,
bool throw_on_error) {
if (!m_parent) {
......@@ -269,7 +268,7 @@ namespace bob { namespace io { namespace video {
return false;
}
const bob::core::array::typeinfo& info = data.type();
const bob::io::base::array::typeinfo& info = data.type();
//checks if the output array shape conforms to the video specifications,
//otherwise, throw
......
......@@ -22,10 +22,10 @@ extern "C" {
#include <libavutil/mathematics.h>
}
#include <bob/core/logging.h>
#include <bob/core/assert.h>
#include <bob.core/logging.h>
#include <bob.core/assert.h>
#include "utils.h"
#include <bob.io.video/utils.h>
/**
* Some code to account for older versions of ffmpeg
......
......@@ -9,7 +9,7 @@
* Copyright (C) Idiap Research Institute, Martigny, Switzerland
*/
#include "writer.h"
#include <bob.io.video/writer.h>
#include <boost/format.hpp>
#include <boost/preprocessor.hpp>
......@@ -82,7 +82,7 @@ namespace bob { namespace io { namespace video {
open_output_file(m_filename, m_format_context);
//sets up the io layer typeinfo
m_typeinfo_video.dtype = m_typeinfo_frame.dtype = bob::core::array::t_uint8;
m_typeinfo_video.dtype = m_typeinfo_frame.dtype = bob::io::base::array::t_uint8;
m_typeinfo_video.nd = 4;
m_typeinfo_frame.nd = 4;
m_typeinfo_video.shape[0] = 0;
......@@ -196,16 +196,16 @@ namespace bob { namespace io { namespace video {
m_typeinfo_video.shape[0] += 1;
}
void Writer::append(const bob::core::array::interface& data) {
void Writer::append(const bob::io::base::array::interface& data) {
if (!m_opened) {
boost::format m("video writer for file `%s' is closed and cannot be written to");
m % m_filename;
throw std::runtime_error(m.str());
}
const bob::core::array::typeinfo& type = data.type();
const bob::io::base::array::typeinfo& type = data.type();
if ( type.dtype != bob::core::array::t_uint8 ) {
if ( type.dtype != bob::io::base::array::t_uint8 ) {
boost::format m("input data type = `%s' does not conform to the specified input specifications (3D array = `%s' or 4D array = `%s'), while writing data to file `%s'");
m % type.str() % m_typeinfo_frame.str() % m_typeinfo_video.str()
% m_filename;
......
......@@ -14,14 +14,15 @@
#include <boost/filesystem.hpp>
#include <boost/make_shared.hpp>
#include <bob/core/blitz_array.h>
#include <bob.io.base/blitz_array.h>
#include <bob/io/CodecRegistry.h>
#include "cpp/reader.h"
#include "cpp/writer.h"
#include "cpp/utils.h"
#include <bob.io.base/CodecRegistry.h>
#include <bob.io.base/File.h>
#include <bob.io.video/reader.h>
#include <bob.io.video/writer.h>
#include <bob.io.video/utils.h>
class VideoFile: public bob::io::File {
class VideoFile: public bob::io::base::File {
public: //api
......@@ -36,7 +37,7 @@ class VideoFile: public bob::io::File {
else if (mode == 'a' && boost::filesystem::exists(path)) {
// to be able to append must load all data and save in video::Writer
m_reader = boost::make_shared<bob::io::video::Reader>(m_filename);
bob::core::array::blitz_array data(m_reader->video_type());
bob::io::base::array::blitz_array data(m_reader->video_type());
m_reader->load(data);
size_t height = m_reader->height();
size_t width = m_reader->width();
......@@ -58,11 +59,11 @@ class VideoFile: public bob::io::File {
return m_filename.c_str();
}
virtual const bob::core::array::typeinfo& type_all() const {
virtual const bob::io::base::array::typeinfo& type_all() const {
return (m_reader)? m_reader->video_type() : m_writer->video_type();
}
virtual const bob::core::array::typeinfo& type() const {
virtual const bob::io::base::array::typeinfo& type() const {
return (m_reader)? m_reader->video_type() : m_writer->video_type();
}
......@@ -74,11 +75,11 @@ class VideoFile: public bob::io::File {
return s_codecname.c_str();
}
virtual void read_all(bob::core::array::interface& buffer) {
virtual void read_all(bob::io::base::array::interface& buffer) {
read(buffer, 0); ///we only have 1 video in a video file anyways
}
virtual void read(bob::core::array::interface& buffer, size_t index) {
virtual void read(bob::io::base::array::interface& buffer, size_t index) {
if (index != 0)
throw std::runtime_error("can only read all frames at once in video codecs");
......@@ -92,9 +93,9 @@ class VideoFile: public bob::io::File {
m_reader->load(buffer);
}
virtual size_t append (const bob::core::array::interface& buffer) {
virtual size_t append (const bob::io::base::array::interface& buffer) {
const bob::core::array::typeinfo& type = buffer.type();
const bob::io::base::array::typeinfo& type = buffer.type();
if (type.nd != 3 and type.nd != 4)
throw std::runtime_error("input buffer for videos must have 3 or 4 dimensions");
......@@ -112,7 +113,7 @@ class VideoFile: public bob::io::File {
return 1;
}
virtual void write (const bob::core::array::interface& buffer) {
virtual void write (const bob::io::base::array::interface& buffer) {
append(buffer);
......@@ -156,6 +157,6 @@ std::string VideoFile::s_codecname = "bob.video";
*
* @note: This method can be static.
*/
boost::shared_ptr<bob::io::File> make_file (const char* path, char mode) {
boost::shared_ptr<bob::io::base::File> make_file (const char* path, char mode) {
return boost::make_shared<VideoFile>(path, mode);
}
......@@ -11,7 +11,7 @@
#define BOB_IO_VIDEO_FILE_H
#include <boost/shared_ptr.hpp>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
/**
* This defines the factory method F that can create codecs of this type.
......@@ -33,6 +33,6 @@
*
* @note: This method can be static.
*/
boost::shared_ptr<bob::io::File> make_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_file (const char* path, char mode);
#endif /* BOB_IO_VIDEO_FILE_H */
......@@ -15,7 +15,7 @@
#include <blitz/array.h>
#include <stdint.h>
#include <bob/core/array.h>
#include <bob.io.base/array.h>
#include "utils.h"
namespace bob { namespace io { namespace video {
......@@ -123,13 +123,13 @@ namespace bob { namespace io { namespace video {
/**
* Returns the typing information for this video
*/
inline const bob::core::array::typeinfo& video_type() const
inline const bob::io::base::array::typeinfo& video_type() const
{ return m_typeinfo_video; }
/**
* Returns the typing information for this video
*/
inline const bob::core::array::typeinfo& frame_type() const
inline const bob::io::base::array::typeinfo& frame_type() const
{ return m_typeinfo_frame; }
/**
......@@ -163,7 +163,7 @@ namespace bob { namespace io { namespace video {
* of this method matches the number of frames indicated by
* numberOfFrames().
*/
size_t load(bob::core::array::interface& b,
size_t load(bob::io::base::array::interface& b,
bool throw_on_error=false, void (*check)(void)=0) const;
private: //methods
......@@ -260,7 +260,7 @@ namespace bob { namespace io { namespace video {
* verify the return value of this method matches the number of
* frames indicated by numberOfFrames().
*/
bool read (bob::core::array::interface& b, bool throw_on_error=false);
bool read (bob::io::base::array::interface& b, bool throw_on_error=false);
/**
* Reads the currently pointed frame and advances one position.
......@@ -365,8 +365,8 @@ namespace bob { namespace io { namespace video {
std::string m_codecname; ///< the name of the ffmpeg codec to be used
std::string m_codecname_long; ///< long version of m_codecname
std::string m_formatted_info; ///< printable information about the video
bob::core::array::typeinfo m_typeinfo_video; ///< read whole video type
bob::core::array::typeinfo m_typeinfo_frame; ///< read single frame type
bob::io::base::array::typeinfo m_typeinfo_video; ///< read whole video type
bob::io::base::array::typeinfo m_typeinfo_frame; ///< read single frame type
};
}}}
......
......@@ -11,7 +11,7 @@
#ifndef BOB_IO_VIDEO_WRITER_H
#define BOB_IO_VIDEO_WRITER_H
#include <bob/core/array.h>
#include <bob.io.base/array.h>
#include "utils.h"
namespace bob { namespace io { namespace video {
......@@ -133,13 +133,13 @@ namespace bob { namespace io { namespace video {
/**
* Compatibility layer type information
*/
const bob::core::array::typeinfo& video_type() const
const bob::io::base::array::typeinfo& video_type() const
{ return m_typeinfo_video; }
/**
* Compatibility layer type information
*/
const bob::core::array::typeinfo& frame_type() const
const bob::io::base::array::typeinfo& frame_type() const
{ return m_typeinfo_frame; }
/**
......@@ -166,10 +166,10 @@ namespace bob { namespace io { namespace video {
/**
* Writes a set of frames to the file. The frame set should be setup as a
* bob::core::array::interface organized this way: (frame-number,
* bob::io::base::array::interface organized this way: (frame-number,
* RGB color-bands, height, width) or (RGB color-bands, height, width).
*/
void append(const bob::core::array::interface& data);
void append(const bob::io::base::array::interface& data);
private: //not implemented
......@@ -196,8 +196,8 @@ namespace bob { namespace io { namespace video {
size_t m_gop;
std::string m_codecname;
std::string m_formatname;
bob::core::array::typeinfo m_typeinfo_video;
bob::core::array::typeinfo m_typeinfo_frame;
bob::io::base::array::typeinfo m_typeinfo_video;
bob::io::base::array::typeinfo m_typeinfo_frame;
size_t m_current_frame;
};
......
......@@ -2,7 +2,7 @@
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Wed 16 Oct 17:40:24 2013
*
* @brief Pythonic bindings to C++ constructs on bob.core
* @brief Pythonic bindings to C++ constructs on bob.io.video
*/
#ifdef NO_IMPORT_ARRAY
......@@ -14,7 +14,7 @@
#include <bob.io.base/api.h>
#include "file.h"
#include "cpp/utils.h"
#include <bob.io.video/utils.h>
extern "C" {
......
......@@ -14,7 +14,7 @@
#include <bob.io.base/api.h>
#include <stdexcept>
#include "cpp/reader.h"
#include <bob.io.video/reader.h>
#define VIDEOREADER_NAME "reader"
PyDoc_STRVAR(s_videoreader_str, BOB_EXT_MODULE_PREFIX "." VIDEOREADER_NAME);
......@@ -350,7 +350,7 @@ static PyObject* PyBobIoVideoReader_Load(PyBobIoVideoReaderObject* self, PyObjec
bool raise_on_error = false;
if (raise && PyObject_IsTrue(raise)) raise_on_error = true;
const bob::core::array::typeinfo& info = self->v->video_type();
const bob::io::base::array::typeinfo& info = self->v->video_type();
npy_intp shape[NPY_MAXDIMS];
for (size_t k=0; k<info.nd; ++k) shape[k] = info.shape[k];
......@@ -429,7 +429,7 @@ static PyObject* PyBobIoVideoReader_GetIndex (PyBobIoVideoReaderObject* self, Py
return 0;
}
const bob::core::array::typeinfo& info = self->v->frame_type();
const bob::io::base::array::typeinfo& info = self->v->frame_type();
npy_intp shape[NPY_MAXDIMS];
for (size_t k=0; k<info.nd; ++k) shape[k] = info.shape[k];
......@@ -472,7 +472,7 @@ static PyObject* PyBobIoVideoReader_GetSlice (PyBobIoVideoReaderObject* self, Py
self->v->numberOfFrames(), &start, &stop, &step, &slicelength) < 0) return 0;
//creates the return array
const bob::core::array::typeinfo& info = self->v->frame_type();
const bob::io::base::array::typeinfo& info = self->v->frame_type();
int type_num = PyBobIo_AsTypenum(info.dtype);
if (type_num == NPY_NOTYPE) return 0; ///< failure
......@@ -598,7 +598,7 @@ static PyObject* PyBobIoVideoReaderIterator_Next (PyBobIoVideoReaderIteratorObje
return 0;
}
const bob::core::array::typeinfo& info = self->pyreader->v->frame_type();
const bob::io::base::array::typeinfo& info = self->pyreader->v->frame_type();
npy_intp shape[NPY_MAXDIMS];
for (size_t k=0; k<info.nd; ++k) shape[k] = info.shape[k];
......
......@@ -17,7 +17,7 @@
#include <boost/preprocessor/stringize.hpp>
#include <boost/version.hpp>
#include <boost/format.hpp>
#include <bob/config.h>
#include <bob.core/config.h>
extern "C" {
......@@ -121,10 +121,10 @@ static PyObject* ffmpeg_version() {
}
/**
* Bob version, API version and platform
* bob.core c/c++ api version
*/
static PyObject* bob_version() {
return Py_BuildValue("sis", BOB_VERSION, BOB_API_VERSION, BOB_PLATFORM);
static PyObject* bob_core_version() {
return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_CORE_API_VERSION));
}
/**
......@@ -196,7 +196,7 @@ static PyObject* build_version_dictionary() {
if (!retval) return 0;
auto retval_ = make_safe(retval);
if (!dict_steal(retval, "Bob", bob_version())) return 0;
if (!dict_steal(retval, "Bob", bob_core_version())) return 0;
if (!dict_steal(retval, "FFmpeg", ffmpeg_version())) return 0;
if (!dict_steal(retval, "Boost", boost_version())) return 0;
if (!dict_steal(retval, "Compiler", compiler_version())) return 0;
......
......@@ -14,7 +14,7 @@
#include <bob.io.base/api.h>
#include <stdexcept>
#include "cpp/writer.h"
#include <bob.io.video/writer.h>
#define VIDEOWRITER_NAME "writer"
PyDoc_STRVAR(s_videowriter_str, BOB_EXT_MODULE_PREFIX "." VIDEOWRITER_NAME);
......
......@@ -10,18 +10,18 @@ extensions = bob.buildout
auto-checkout = *
develop = src/bob.extension
src/bob.blitz
src/bob.core
src/bob.io.base
.
; options for bob.buildout extension
debug = true
verbose = true
prefixes = /idiap/group/torch5spro/releases/preview/install/linux-x86_64-release
/Users/andre/work/bob/b/dbg/
[sources]
bob.extension = git https://github.com/bioidiap/bob.extension
bob.blitz = git https://github.com/bioidiap/bob.blitz
bob.core = git https://github.com/bioidiap/bob.core
bob.io.base = git https://github.com/bioidiap/bob.io.base
[scripts]
......
......@@ -4,16 +4,16 @@
# Mon 16 Apr 08:18:08 2012 CEST
from setuptools import setup, find_packages, dist
dist.Distribution(dict(setup_requires=['bob.blitz', 'bob.io.base']))
from bob.blitz.extension import Extension
dist.Distribution(dict(setup_requires=['bob.blitz', 'bob.core', 'bob.io.base']))
from bob.blitz.extension import Extension, Library, build_ext
from bob.extension import pkgconfig
import bob.io.base
include_dirs = [bob.io.base.get_include()]
import os
package_dir = os.path.dirname(os.path.realpath(__file__))
target_dir = os.path.join(package_dir, 'bob', 'io', 'video')
packages = [
'boost',
'bob-io >= 2.0.0a2',
'libavformat >= 52.31.0',
'libavcodec >= 52.20.0',
'libavutil >= 49.15.0',
......@@ -80,10 +80,25 @@ setup(
],
packages = packages,
boost_modules = ['system'],
include_dirs = include_dirs,
bob_packages = ['bob.core', 'bob.io.base'],
version = version,
define_macros = define_macros,
),
Library("bob_io_video",
[
"bob/io/video/cpp/utils.cpp",
"bob/io/video/cpp/reader.cpp",
"bob/io/video/cpp/writer.cpp",
],
package_directory = package_dir,
target_directory = target_dir,
define_macros = define_macros,
version = version,
bob_packages = ['bob.core', 'bob.io.base'],
packages = packages,
),
Extension("bob.io.video._library",
[
"bob/io/video/cpp/utils.cpp",
......@@ -96,12 +111,17 @@ setup(
"bob/io/video/main.cpp",
],
packages = packages,
include_dirs = include_dirs,
bob_packages = ['bob.core', 'bob.io.base'],
libraries = ['bob_io_video'],
version = version,
define_macros = define_macros,
),
],
cmdclass = {
'build_ext': build_ext
},
entry_points={
'console_scripts': [
'bob_video_test.py = bob.io.video.script.video_test:main',
......
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