| 33 | #include "libavutil/frame.h" |
| 34 | |
| 35 | static int decode_read(DecodeContext *dc, int flush) |
| 36 | { |
| 37 | const int ret_done = flush ? AVERROR_EOF : AVERROR(EAGAIN); |
| 38 | int ret = 0; |
| 39 | |
| 40 | while (ret >= 0 && |
| 41 | (dc->max_frames == 0 || dc->decoder->frame_num < dc->max_frames)) { |
| 42 | ret = avcodec_receive_frame(dc->decoder, dc->frame); |
| 43 | if (ret < 0) { |
| 44 | if (ret == AVERROR_EOF) { |
| 45 | int err = dc->process_frame(dc, NULL); |
| 46 | if (err < 0) |
| 47 | return err; |
| 48 | } |
| 49 | |
| 50 | return (ret == ret_done) ? 0 : ret; |
| 51 | } |
| 52 | |
| 53 | ret = dc->process_frame(dc, dc->frame); |
| 54 | av_frame_unref(dc->frame); |
| 55 | if (ret < 0) |
| 56 | return ret; |
| 57 | |
| 58 | if (dc->max_frames && dc->decoder->frame_num == dc->max_frames) |
| 59 | return 1; |
| 60 | } |
| 61 | |
| 62 | return (dc->max_frames == 0 || dc->decoder->frame_num < dc->max_frames) ? 0 : 1; |
| 63 | } |
| 64 | |
| 65 | int ds_run(DecodeContext *dc) |
| 66 | { |
no test coverage detected