From 00e9647a9ede540f2d567c19025278c25a87c830 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jan 2014 22:38:43 +0000 Subject: Various tweaks; work on read_dcp example. --- examples/read_dcp.cc | 45 ++++++++++++++++++++++++++++++++++++++++++--- examples/wscript | 2 +- 2 files changed, 43 insertions(+), 4 deletions(-) (limited to 'examples') 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 -#include -#include +#include ... 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 /** @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 > assets = dcp.assets (); + std::cout << "DCP has " << assets.size() << " assets.\n"; + for (std::list >::const_iterator i = assets.begin(); i != assets.end(); ++i) { + if (boost::dynamic_pointer_cast (*i)) { + std::cout << "2D picture\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "3D picture\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "Sound\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "Subtitle\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "CPL\n"; + } + std::cout << "\t" << (*i)->file().leaf().string() << "\n"; + } + + /* Take the first CPL */ + boost::shared_ptr cpl = dcp.cpls().front (); + + /* Get the MXF of the picture asset in the first reel */ + boost::shared_ptr picture_mxf = boost::dynamic_pointer_cast (cpl->reels().front()->main_picture()->mxf ()); + + /* Get the 1000th frame of it */ + boost::shared_ptr picture_frame_j2k = picture_mxf->get_frame(999); + + /* Get a ARGB copy of it */ + boost::shared_ptr 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 = '' -- cgit v1.2.3