- int frame_finished;
-DCPOMATIC_DISABLE_WARNINGS
- if (avcodec_decode_video2 (context, _frame, &frame_finished, &_packet) < 0 || !frame_finished) {
+ int r = avcodec_send_packet (context, packet);
+ if (r < 0 && !(r == AVERROR_EOF && !packet)) {
+ /* We could cope with AVERROR(EAGAIN) and re-send the packet but I think it should never happen.
+ * AVERROR_EOF can happen during flush if we've already sent a flush packet.
+ */
+ throw DecodeError (N_("avcodec_send_packet"), N_("FFmpegExaminer::video_packet"), r);
+ }
+
+ r = avcodec_receive_frame (context, _video_frame);
+ if (r == AVERROR(EAGAIN)) {
+ /* More input is required */
+ return true;
+ } else if (r == AVERROR_EOF) {
+ /* No more output is coming */