summaryrefslogtreecommitdiff
path: root/src/lib/video_mxf_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-29 16:01:14 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-29 16:01:14 +0100
commit92c691f29c5da9abca6a06605998e09f9b8103bb (patch)
tree1ecd83269fcce0f7bf83279ea4920cdeb5b1a939 /src/lib/video_mxf_decoder.cc
parent420b50e7e5130194d8e8f4a51514c005e2df3dd0 (diff)
Fix handling of incorrectly-recognised JPEG2000 files.
Previously we asked libdcp whether an imported J2K file was RGB or XYZ. The answer it gives is sometimes wrong, for reasons that are not clear (either the files are not marked correctly, or openjpeg is not parsing whatever metadata correctly). However it seems that, in general, we use the user's specified colour conversion to decide what to do with an image, rather than asking the image what should be done to it. Hence it makes more sense to assume that if a user specifies no colour conversion for a J2K file then the file is XYZ. With preview, the colour conversion from XYZ back to RGB is done by FFmpeg, so we have to set the pixel format correctly on the Image that comes back from J2KImageProxy. Now we get that pixel format from the configured colourspace conversion rather than from openjpeg's guess as to the file's colourspace. It's a bit ugly that the only thing we ask the file about is whether or not it is in YUV (which governs whether or not FFmpeg applies the user's configured YUV-to-RGB conversion). Everything else is decided by the configured conversion. I think there's still some uglyness in here that I can't put my finger on.
Diffstat (limited to 'src/lib/video_mxf_decoder.cc')
-rw-r--r--src/lib/video_mxf_decoder.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/video_mxf_decoder.cc b/src/lib/video_mxf_decoder.cc
index 938d7deaf..dc4f8d60b 100644
--- a/src/lib/video_mxf_decoder.cc
+++ b/src/lib/video_mxf_decoder.cc
@@ -77,10 +77,16 @@ VideoMXFDecoder::pass (PassReason, bool)
}
if (_mono_reader) {
- video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_mono_reader->get_frame(frame), _size)), frame);
+ video->give (
+ shared_ptr<ImageProxy> (new J2KImageProxy (_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE)), frame
+ );
} else {
- video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_LEFT)), frame);
- video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_RIGHT)), frame);
+ video->give (
+ shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_LEFT, AV_PIX_FMT_XYZ12LE)), frame
+ );
+ video->give (
+ shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_RIGHT, AV_PIX_FMT_XYZ12LE)), frame
+ );
}
_next += ContentTime::from_frames (1, vfr);