* Return * - 0 -- one packet was read and processed * - AVERROR(EAGAIN) -- no packets were available for selected file, * this function should be called again * - AVERROR_EOF -- this function should not be called again */
| 4183 | * - AVERROR_EOF -- this function should not be called again |
| 4184 | */ |
| 4185 | static int process_input(int file_index) |
| 4186 | { |
| 4187 | InputFile *ifile = input_files[file_index]; |
| 4188 | AVFormatContext *is; |
| 4189 | InputStream *ist; |
| 4190 | AVPacket pkt; |
| 4191 | int ret, i, j; |
| 4192 | int64_t duration; |
| 4193 | int64_t pkt_dts; |
| 4194 | |
| 4195 | is = ifile->ctx; |
| 4196 | ret = get_input_packet(ifile, &pkt); |
| 4197 | |
| 4198 | if (ret == AVERROR(EAGAIN)) { |
| 4199 | ifile->eagain = 1; |
| 4200 | return ret; |
| 4201 | } |
| 4202 | if (ret < 0 && ifile->loop) { |
| 4203 | if ((ret = seek_to_start(ifile, is)) < 0) |
| 4204 | return ret; |
| 4205 | ret = get_input_packet(ifile, &pkt); |
| 4206 | if (ret == AVERROR(EAGAIN)) { |
| 4207 | ifile->eagain = 1; |
| 4208 | return ret; |
| 4209 | } |
| 4210 | } |
| 4211 | if (ret < 0) { |
| 4212 | if (ret != AVERROR_EOF) { |
| 4213 | print_error(is->filename, ret); |
| 4214 | if (exit_on_error) |
| 4215 | exit_program(1); |
| 4216 | } |
| 4217 | |
| 4218 | for (i = 0; i < ifile->nb_streams; i++) { |
| 4219 | ist = input_streams[ifile->ist_index + i]; |
| 4220 | if (ist->decoding_needed) { |
| 4221 | ret = process_input_packet(ist, NULL, 0); |
| 4222 | if (ret>0) |
| 4223 | return 0; |
| 4224 | } |
| 4225 | |
| 4226 | /* mark all outputs that don't go through lavfi as finished */ |
| 4227 | for (j = 0; j < nb_output_streams; j++) { |
| 4228 | OutputStream *ost = output_streams[j]; |
| 4229 | |
| 4230 | if (ost->source_index == ifile->ist_index + i && |
| 4231 | (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) |
| 4232 | finish_output_stream(ost); |
| 4233 | } |
| 4234 | } |
| 4235 | |
| 4236 | ifile->eof_reached = 1; |
| 4237 | return AVERROR(EAGAIN); |
| 4238 | } |
| 4239 | |
| 4240 | reset_eagain(); |
| 4241 | |
| 4242 | if (do_pkt_dump) { |
no test coverage detected