- double const afr = _content->active_video_frame_rate(film);
-
- Frame frame;
- if (!_position) {
- /* This is the first data we have received since initialisation or seek. Set
- the position based on the frame that was given. After this first time
- we just cound frames, since (as with audio) it seems that ContentTimes
- are unreliable from FFmpegDecoder. They are much better than audio times
- but still we get the occasional one which is duplicated. In this case
- ffmpeg seems to carry on regardless, processing the video frame as normal.
- If we drop the frame with the duplicated timestamp we obviously lose sync.
- */
- _position = ContentTime::from_frames (decoder_frame, afr);
- if (_content->video->frame_type() == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
- frame = decoder_frame / 2;
- _last_emitted_eyes = EYES_RIGHT;
- } else {
- frame = decoder_frame;
- }
- } else {
- VideoFrameType const ft = _content->video->frame_type ();
- if (ft == VIDEO_FRAME_TYPE_3D_ALTERNATE || ft == VIDEO_FRAME_TYPE_3D) {
- DCPOMATIC_ASSERT (_last_emitted_eyes);
- if (_last_emitted_eyes.get() == EYES_RIGHT) {
- frame = _position->frames_round(afr) + 1;
- } else {
- frame = _position->frames_round(afr);
- }
- } else {
- frame = _position->frames_round(afr) + 1;
- }
- }