/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
+#include "lib/video_content.h"
#include "lib/player.h"
+#include "lib/audio_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
"<Name>und; 2 channels</Name>"
"<Id>2</Id>"
"<FrameRate>44100</FrameRate>"
+ "<Length>44100</Length>"
"<Channels>2</Channels>"
"<FirstAudio>0</FirstAudio>"
"<Mapping>"
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
/* 25fps content, 24fps DCP; length should be increased */
film->set_video_frame_rate (24);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 24.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 24.0));
/* 25fps content, 30fps DCP; length should be decreased */
film->set_video_frame_rate (30);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 30.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 30.0));
/* 25fps content, 50fps DCP; length should be the same */
film->set_video_frame_rate (50);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
/* 25fps content, 60fps DCP; length should be decreased */
film->set_video_frame_rate (60);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() * (50.0 / 60) / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() * (50.0 / 60) / 25.0));
+
+ /* Make the content audio-only */
+ content->video.reset ();
+
+ /* 24fps content, 24fps DCP */
+ film->set_video_frame_rate (24);
+ content->set_video_frame_rate (24);
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ /* 25fps content, 25fps DCP */
+ film->set_video_frame_rate (25);
+ content->set_video_frame_rate (25);
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ /* 25fps content, 24fps DCP; length should be increased */
+ film->set_video_frame_rate (24);
+ BOOST_CHECK_SMALL (abs (content->full_length().get() - DCPTime::from_seconds(25.0 / 24).get()), 2);
+ /* 25fps content, 30fps DCP; length should be decreased */
+ film->set_video_frame_rate (30);
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (25.0 / 30));
+ /* 25fps content, 50fps DCP; length should be the same */
+ film->set_video_frame_rate (50);
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ /* 25fps content, 60fps DCP; length should be decreased */
+ film->set_video_frame_rate (60);
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (50.0 / 60));
+
}
/** Test Player::dcp_to_content_video */
list<string> notes;
shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
- film->set_sequence_video (false);
+ film->set_sequence (false);
film->add_content (content);
shared_ptr<Player> player (new Player (film, film->playlist ()));
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.60)), 0);
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 0);
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.60)), 40);
- BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 169);
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 168);
/* Position 3s, 1.6s trim, content rate 24, DCP rate 25. Here the trim is in ContentTime,
so it's 1.6s at 24fps.
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 72);
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 144);
BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 396);
+
+ /* Position 0s, no trim, content rate 29.9978733, DCP rate 30 */
+ content->set_position (DCPTime::from_seconds (0));
+ content->set_trim_start (ContentTime::from_seconds (0));
+ content->set_video_frame_rate (29.9978733);
+ film->set_video_frame_rate (30);
+ player->setup_pieces ();
+ BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
+ piece = player->_pieces.front ();
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0);
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (3200)), 1);
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (6400)), 2);
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (9600)), 3);
+ BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (12800)), 4);
+
}
/** Test Player::content_video_to_dcp */
list<string> notes;
shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
- film->set_sequence_video (false);
+ film->set_sequence (false);
film->add_content (content);
shared_ptr<Player> player (new Player (film, film->playlist ()));
list<string> notes;
shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
- AudioStreamPtr stream = content->audio_streams().front();
- film->set_sequence_video (false);
+ AudioStreamPtr stream = content->audio->streams().front();
+ film->set_sequence (false);
film->add_content (content);
shared_ptr<Player> player (new Player (film, film->playlist ()));