2 Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "video_mxf_decoder.h"
21 #include "video_decoder.h"
22 #include "video_mxf_content.h"
23 #include "j2k_image_proxy.h"
24 #include <dcp/mono_picture_asset.h>
25 #include <dcp/stereo_picture_asset.h>
26 #include <dcp/exceptions.h>
28 using boost::shared_ptr;
30 VideoMXFDecoder::VideoMXFDecoder (shared_ptr<const VideoMXFContent> content, shared_ptr<Log> log)
33 video.reset (new VideoDecoder (this, content, log));
37 VideoMXFDecoder::pass (PassReason reason, bool)
39 shared_ptr<dcp::MonoPictureAsset> mono;
41 mono.reset (new dcp::MonoPictureAsset (_content->path(0)));
42 } catch (dcp::MXFFileError& e) {
43 /* maybe it's stereo */
44 } catch (dcp::DCPReadError& e) {
45 /* maybe it's stereo */
48 shared_ptr<dcp::StereoPictureAsset> stereo;
50 stereo.reset (new dcp::StereoPictureAsset (_content->path(0)));
51 } catch (dcp::MXFFileError& e) {
55 } catch (dcp::DCPReadError& e) {
61 double const vfr = _content->active_video_frame_rate ();
62 int64_t const frame = _next.frames_round (vfr);
65 video->give (shared_ptr<ImageProxy> (new J2KImageProxy (mono->get_frame(frame), mono->size())), frame);
67 video->give (shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame(frame), stereo->size(), dcp::EYE_LEFT)), frame);
68 video->give (shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame(frame), stereo->size(), dcp::EYE_RIGHT)), frame);
71 _next += ContentTime::from_frames (1, vfr);
75 VideoMXFDecoder::seek (ContentTime t, bool accurate)
77 video->seek (t, accurate);