-
- if (!pkt->size) {
- if (movie->eof) {
- if (movie->st[out_id].done) {
- if (movie->loop_count != 1) {
- ret = rewind_file(ctx);
- if (ret < 0)
- return ret;
- movie->loop_count -= movie->loop_count > 1;
- av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
- return 0; /* retry */
- }
- return AVERROR_EOF;
- }
- pkt->stream_index = movie->st[out_id].st->index;
- /* packet is already ready for flushing */
- } else {
- ret = av_read_frame(movie->format_ctx, &movie->pkt0);
- if (ret < 0) {
- av_init_packet(&movie->pkt0); /* ready for flushing */
- *pkt = movie->pkt0;
- if (ret == AVERROR_EOF) {
- movie->eof = 1;
- return 0; /* start flushing */
- }
- return ret;
- }
- *pkt = movie->pkt0;
- }
- }
-
- pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
- movie->out_index[pkt->stream_index];
- if (pkt_out_id < 0) {
- av_packet_unref(&movie->pkt0);
- pkt->size = 0; /* ready for next run */
- pkt->data = NULL;
- return 0;
- }
- st = &movie->st[pkt_out_id];
- outlink = ctx->outputs[pkt_out_id];