LOG_WARNING("avcodec_send_packet returned %1 for a video packet", r);
}
- r = avcodec_receive_frame (context, _video_frame);
- if (r == AVERROR(EAGAIN) || r == AVERROR_EOF || (r < 0 && !packet)) {
- /* More input is required, no more frames are coming, or we are flushing and there was
- * some error which we just want to ignore.
- */
- return false;
- } else if (r < 0) {
- throw DecodeError (N_("avcodec_receive_frame"), N_("FFmpeg::decode_and_process_video_packet"), r);
- }
+ while (true) {
+ r = avcodec_receive_frame (context, _video_frame);
+ if (r == AVERROR(EAGAIN) || r == AVERROR_EOF || (r < 0 && !packet)) {
+ /* More input is required, no more frames are coming, or we are flushing and there was
+ * some error which we just want to ignore.
+ */
+ return false;
+ } else if (r < 0) {
+ throw DecodeError (N_("avcodec_receive_frame"), N_("FFmpeg::decode_and_process_video_packet"), r);
+ }
- process_video_frame ();
+ process_video_frame ();
+ }
return true;
}
void
FFmpegDecoder::process_video_frame ()
{
- /* We assume we'll only get one frame here, which I think is safe */
-
boost::mutex::scoped_lock lm (_filter_graphs_mutex);
shared_ptr<VideoFilterGraph> graph;
#include "lib/content.h"
#include "lib/content_factory.h"
#include "lib/dcpomatic_time.h"
+#include "lib/player.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
}
+
+BOOST_AUTO_TEST_CASE (check_exception_with_multiple_video_frames_per_packet)
+{
+ auto content = content_factory(TestPaths::private_data() / "chk.mkv").front();
+ auto film = new_test_film2 ("check_exception_with_multiple_video_frames_per_packet", { content });
+ auto player = std::make_shared<Player>(film, film->playlist());
+
+ while (!player->pass()) {}
+}
+
player->Audio.connect (bind (&audio, _1, _2));
video_frames = audio_frames = 0;
while (!player->pass ()) {
- BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) < 8);
+ BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) <= 8);
}
}