+ *got_frame = 1;
+ return 0;
+}
+
+static void davs2_flush(AVCodecContext *avctx)
+{
+ DAVS2Context *cad = avctx->priv_data;
+ int ret = DAVS2_GOT_FRAME;
+
+ while (ret == DAVS2_GOT_FRAME) {
+ ret = davs2_decoder_flush(cad->decoder, &cad->headerset, &cad->out_frame);
+ davs2_decoder_frame_unref(cad->decoder, &cad->out_frame);
+ }
+
+ if (ret == DAVS2_ERROR) {
+ av_log(avctx, AV_LOG_WARNING, "Decoder flushing failed.\n");
+ }
+}
+
+static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
+{
+ DAVS2Context *cad = avctx->priv_data;
+ int ret = DAVS2_DEFAULT;
+
+ ret = davs2_decoder_flush(cad->decoder, &cad->headerset, &cad->out_frame);
+ if (ret == DAVS2_ERROR) {
+ av_log(avctx, AV_LOG_ERROR, "Decoder error: can't flush delayed frame\n");
+ return AVERROR_EXTERNAL;
+ }
+ if (ret == DAVS2_GOT_FRAME) {
+ ret = davs2_dump_frames(avctx, &cad->out_frame, got_frame, &cad->headerset, ret, frame);
+ davs2_decoder_frame_unref(cad->decoder, &cad->out_frame);
+ }
+ return ret;