diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-27 22:38:43 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-27 22:38:43 +0000 |
| commit | 00e9647a9ede540f2d567c19025278c25a87c830 (patch) | |
| tree | 145f7fc92cfa0670e7da304b965d30f751ab1b14 /examples | |
| parent | 8c2f3517e868078b551bb01d975f2956cb692fbf (diff) | |
Various tweaks; work on read_dcp example.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/read_dcp.cc | 45 | ||||
| -rw-r--r-- | examples/wscript | 2 |
2 files changed, 43 insertions, 4 deletions
diff --git a/examples/read_dcp.cc b/examples/read_dcp.cc index 43f5f0be..f3c47a3c 100644 --- a/examples/read_dcp.cc +++ b/examples/read_dcp.cc @@ -19,12 +19,21 @@ /* If you are using an installed libdcp, these #includes would need to be changed to #include <libdcp/dcp.h> -#include <libdcp/cpl.h> -#include <libdcp/mono_picture_asset.h> +#include <libdcp/picture_mxf.h> ... etc. ... */ #include "dcp.h" +#include "cpl.h" +#include "reel.h" +#include "reel_picture_asset.h" +#include "mono_picture_frame.h" +#include "mono_picture_mxf.h" +#include "stereo_picture_mxf.h" +#include "sound_mxf.h" +#include "subtitle_content.h" +#include "argb_frame.h" +#include <Magick++.h> /** @file examples/read_dcp.cc * @brief Shows how to read a DCP. @@ -45,7 +54,37 @@ main () } std::cout << "DCP has " << dcp.cpls().size() << " CPLs.\n"; - std::cout << "DCP has " << dcp.assets().size() << " assets.\n"; + std::list<boost::shared_ptr<dcp::Asset> > assets = dcp.assets (); + std::cout << "DCP has " << assets.size() << " assets.\n"; + for (std::list<boost::shared_ptr<dcp::Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) { + if (boost::dynamic_pointer_cast<dcp::MonoPictureMXF> (*i)) { + std::cout << "2D picture\n"; + } else if (boost::dynamic_pointer_cast<dcp::StereoPictureMXF> (*i)) { + std::cout << "3D picture\n"; + } else if (boost::dynamic_pointer_cast<dcp::SoundMXF> (*i)) { + std::cout << "Sound\n"; + } else if (boost::dynamic_pointer_cast<dcp::SubtitleContent> (*i)) { + std::cout << "Subtitle\n"; + } else if (boost::dynamic_pointer_cast<dcp::CPL> (*i)) { + std::cout << "CPL\n"; + } + std::cout << "\t" << (*i)->file().leaf().string() << "\n"; + } + + /* Take the first CPL */ + boost::shared_ptr<dcp::CPL> cpl = dcp.cpls().front (); + + /* Get the MXF of the picture asset in the first reel */ + boost::shared_ptr<dcp::MonoPictureMXF> picture_mxf = boost::dynamic_pointer_cast<dcp::MonoPictureMXF> (cpl->reels().front()->main_picture()->mxf ()); + + /* Get the 1000th frame of it */ + boost::shared_ptr<const dcp::MonoPictureFrame> picture_frame_j2k = picture_mxf->get_frame(999); + + /* Get a ARGB copy of it */ + boost::shared_ptr<dcp::ARGBFrame> picture_frame_rgb = picture_frame_j2k->argb_frame (); + + Magick::Image image (picture_frame_rgb->size().width, picture_frame_rgb->size().height, "BGRA", Magick::CharPixel, picture_frame_rgb->data ()); + image.write ("frame.png"); return 0; } diff --git a/examples/wscript b/examples/wscript index 7de1199d..ce94bfa2 100644 --- a/examples/wscript +++ b/examples/wscript @@ -10,7 +10,7 @@ def build(bld): obj = bld(features = 'cxx cxxprogram') obj.name = 'read_dcp' obj.use = 'libdcp' - obj.uselib = 'OPENJPEG CXML' + obj.uselib = 'OPENJPEG CXML MAGICK' obj.source = 'read_dcp.cc' obj.target = 'read_dcp' obj.install_path = '' |
