this thread gets the stream from the disk or the network */
| 2353 | |
| 2354 | /* this thread gets the stream from the disk or the network */ |
| 2355 | static int decode_thread(void *arg) |
| 2356 | { |
| 2357 | VideoState *is = arg; |
| 2358 | AVFormatContext *ic; |
| 2359 | int err, i, ret; |
| 2360 | int st_index[AVMEDIA_TYPE_NB]; |
| 2361 | int st_count[AVMEDIA_TYPE_NB]={0}; |
| 2362 | int st_best_packet_count[AVMEDIA_TYPE_NB]; |
| 2363 | AVPacket pkt1, *pkt = &pkt1; |
| 2364 | AVFormatParameters params, *ap = ¶ms; |
| 2365 | int eof=0; |
| 2366 | int pkt_in_play_range = 0; |
| 2367 | |
| 2368 | ic = avformat_alloc_context(); |
| 2369 | |
| 2370 | memset(st_index, -1, sizeof(st_index)); |
| 2371 | memset(st_best_packet_count, -1, sizeof(st_best_packet_count)); |
| 2372 | is->video_stream = -1; |
| 2373 | is->audio_stream = -1; |
| 2374 | is->subtitle_stream = -1; |
| 2375 | |
| 2376 | global_video_state = is; |
| 2377 | url_set_interrupt_cb(decode_interrupt_cb); |
| 2378 | |
| 2379 | memset(ap, 0, sizeof(*ap)); |
| 2380 | |
| 2381 | ap->prealloced_context = 1; |
| 2382 | ap->width = frame_width; |
| 2383 | ap->height= frame_height; |
| 2384 | ap->time_base= (AVRational){1, 25}; |
| 2385 | ap->pix_fmt = frame_pix_fmt; |
| 2386 | |
| 2387 | set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM); |
| 2388 | |
| 2389 | err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap); |
| 2390 | if (err < 0) { |
| 2391 | print_error(is->filename, err); |
| 2392 | ret = -1; |
| 2393 | goto fail; |
| 2394 | } |
| 2395 | is->ic = ic; |
| 2396 | |
| 2397 | if(genpts) |
| 2398 | ic->flags |= AVFMT_FLAG_GENPTS; |
| 2399 | |
| 2400 | err = av_find_stream_info(ic); |
| 2401 | if (err < 0) { |
| 2402 | fprintf(stderr, "%s: could not find codec parameters\n", is->filename); |
| 2403 | ret = -1; |
| 2404 | goto fail; |
| 2405 | } |
| 2406 | if(ic->pb) |
| 2407 | ic->pb->eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end |
| 2408 | |
| 2409 | if(seek_by_bytes<0) |
| 2410 | seek_by_bytes= !!(ic->iformat->flags & AVFMT_TS_DISCONT); |
| 2411 | |
| 2412 | /* if seeking requested, we execute it */ |
nothing calls this directly
no test coverage detected