Lines Matching refs:ist
176 static int sub2video_get_blank_frame(InputStream *ist)
179 AVFrame *frame = ist->sub2video.frame;
182 ist->sub2video.frame->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w;
183 ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
184 ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
222 static void sub2video_push_ref(InputStream *ist, int64_t pts)
224 AVFrame *frame = ist->sub2video.frame;
229 ist->sub2video.last_pts = frame->pts = pts;
230 for (i = 0; i < ist->nb_filters; i++) {
231 ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
240 void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub)
242 AVFrame *frame = ist->sub2video.frame;
252 AV_TIME_BASE_Q, ist->st->time_base);
254 AV_TIME_BASE_Q, ist->st->time_base);
261 pts = ist->sub2video.initialize ?
262 heartbeat_pts : ist->sub2video.end_pts;
266 if (sub2video_get_blank_frame(ist) < 0) {
267 av_log(ist->dec_ctx, AV_LOG_ERROR,
275 sub2video_push_ref(ist, pts);
276 ist->sub2video.end_pts = end_pts;
277 ist->sub2video.initialize = 0;
280 static void sub2video_heartbeat(InputStream *ist, int64_t pts)
282 InputFile *infile = input_files[ist->file_index];
296 pts2 = av_rescale_q(pts, ist->st->time_base, ist2->st->time_base) - 1;
312 static void sub2video_flush(InputStream *ist)
317 if (ist->sub2video.end_pts < INT64_MAX)
318 sub2video_update(ist, INT64_MAX, NULL);
319 for (i = 0; i < ist->nb_filters; i++) {
320 ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
528 struct InputStream *ist = ifilter->ist;
537 if (ist->sub2video.sub_queue) {
539 while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0)
541 av_fifo_freep2(&ist->sub2video.sub_queue);
614 InputStream *ist = input_streams[i];
616 av_frame_free(&ist->decoded_frame);
617 av_packet_free(&ist->pkt);
618 av_dict_free(&ist->decoder_opts);
619 avsubtitle_free(&ist->prev_sub.subtitle);
620 av_frame_free(&ist->sub2video.frame);
621 av_freep(&ist->filters);
622 av_freep(&ist->hwaccel_device);
623 av_freep(&ist->dts_buffer);
625 avcodec_free_context(&ist->dec_ctx);
1089 InputStream *ist = NULL;
1096 ist = input_streams[ost->source_index];
1102 if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
1109 ist &&
1110 lrintf(next_picture->pkt_duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
1111 duration = lrintf(next_picture->pkt_duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
1438 InputStream *ist = input_streams[f->ist_index + j];
1439 enum AVMediaType type = ist->dec_ctx->codec_type;
1441 total_size += ist->data_size;
1442 total_packets += ist->nb_packets;
1447 ist->nb_packets, ist->data_size);
1449 if (ist->decoding_needed) {
1451 ist->frames_decoded);
1453 av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded);
1761 ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar) < 0) {
1792 * Check whether a packet from ist should be written into ost at this time
1794 static int check_output_constraints(InputStream *ist, OutputStream *ost)
1797 int ist_index = input_files[ist->file_index]->ist_index + ist->st->index;
1805 if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
1811 static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
1814 InputFile *f = input_files [ist->file_index];
1835 ist->pts < comp_start :
1836 pkt->pts < av_rescale_q(comp_start, AV_TIME_BASE_Q, ist->st->time_base))
1841 ist->pts >= of->recording_time + start_time) {
1852 if (ist->pts >= f->recording_time + start_time) {
1862 opkt->pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time;
1865 opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
1867 int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size);
1869 duration = ist->dec_ctx->frame_size;
1870 opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts,
1871 (AVRational){1, ist->dec_ctx->sample_rate}, duration,
1872 &ist->filter_in_rescale_delta_last, ost->mux_timebase);
1876 opkt->dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase);
1879 opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
1888 int guess_input_channel_layout(InputStream *ist)
1890 AVCodecContext *dec = ist->dec_ctx;
1895 if (dec->ch_layout.nb_channels > ist->guess_layout_max)
1902 "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
1907 static void check_decode_result(InputStream *ist, int *got_output, int ret)
1915 if (*got_output && ist) {
1916 if (ist->decoded_frame->decode_error_flags || (ist->decoded_frame->flags & AV_FRAME_FLAG_CORRUPT)) {
1918 "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->url, ist->st->index);
1950 switch (ifilter->ist->st->codecpar->codec_type) {
1961 if (!ifilter->ist->reinit_filters && fg->graph)
2030 ret = ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar);
2035 av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);
2070 static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
2074 av_assert1(ist->nb_filters > 0); /* ensure ret is initialized */
2075 for (i = 0; i < ist->nb_filters; i++) {
2076 ret = ifilter_send_frame(ist->filters[i], decoded_frame, i < ist->nb_filters - 1);
2088 static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
2091 AVFrame *decoded_frame = ist->decoded_frame;
2092 AVCodecContext *avctx = ist->dec_ctx;
2098 update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index);
2108 check_decode_result(ist, got_output, ret);
2113 ist->samples_decoded += decoded_frame->nb_samples;
2114 ist->frames_decoded++;
2118 ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) /
2120 ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) /
2124 decoded_frame_tb = ist->st->time_base;
2127 decoded_frame_tb = ist->st->time_base;
2129 decoded_frame->pts = ist->dts;
2132 if (pkt && pkt->duration && ist->prev_pkt_pts != AV_NOPTS_VALUE &&
2133 pkt->pts != AV_NOPTS_VALUE && pkt->pts - ist->prev_pkt_pts > pkt->duration)
2134 ist->filter_in_rescale_delta_last = AV_NOPTS_VALUE;
2136 ist->prev_pkt_pts = pkt->pts;
2139 (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last,
2141 ist->nb_samples = decoded_frame->nb_samples;
2142 err = send_frame_to_filters(ist, decoded_frame);
2148 static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof,
2151 AVFrame *decoded_frame = ist->decoded_frame;
2162 if (ist->dts != AV_NOPTS_VALUE)
2163 dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
2171 void *new = av_realloc_array(ist->dts_buffer, ist->nb_dts_buffer + 1, sizeof(ist->dts_buffer[0]));
2174 ist->dts_buffer = new;
2175 ist->dts_buffer[ist->nb_dts_buffer++] = dts;
2179 ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt);
2180 update_benchmark("decode_video %d.%d", ist->file_index, ist->st->index);
2186 if (ist->st->codecpar->video_delay < ist->dec_ctx->has_b_frames) {
2187 if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) {
2188 ist->st->codecpar->video_delay = ist->dec_ctx->has_b_frames;
2190 av_log(ist->dec_ctx, AV_LOG_WARNING,
2195 ist->dec_ctx->has_b_frames,
2196 ist->st->codecpar->video_delay);
2200 check_decode_result(ist, got_output, ret);
2203 if (ist->dec_ctx->width != decoded_frame->width ||
2204 ist->dec_ctx->height != decoded_frame->height ||
2205 ist->dec_ctx->pix_fmt != decoded_frame->format) {
2210 ist->dec_ctx->width,
2211 ist->dec_ctx->height,
2212 ist->dec_ctx->pix_fmt);
2219 if(ist->top_field_first>=0)
2220 decoded_frame->top_field_first = ist->top_field_first;
2222 ist->frames_decoded++;
2224 if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) {
2225 err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame);
2229 ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
2234 if (ist->framerate.num)
2235 best_effort_timestamp = ist->cfr_next_pts++;
2237 if (eof && best_effort_timestamp == AV_NOPTS_VALUE && ist->nb_dts_buffer > 0) {
2238 best_effort_timestamp = ist->dts_buffer[0];
2240 for (i = 0; i < ist->nb_dts_buffer - 1; i++)
2241 ist->dts_buffer[i] = ist->dts_buffer[i + 1];
2242 ist->nb_dts_buffer--;
2246 int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
2249 ist->next_pts = ist->pts = ts;
2255 ist->st->index, av_ts2str(decoded_frame->pts),
2256 av_ts2timestr(decoded_frame->pts, &ist->st->time_base),
2258 av_ts2timestr(best_effort_timestamp, &ist->st->time_base),
2260 ist->st->time_base.num, ist->st->time_base.den);
2263 if (ist->st->sample_aspect_ratio.num)
2264 decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
2266 err = send_frame_to_filters(ist, decoded_frame);
2273 static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output,
2278 int i, ret = avcodec_decode_subtitle2(ist->dec_ctx,
2286 sub2video_flush(ist);
2290 if (ist->fix_sub_duration) {
2292 if (ist->prev_sub.got_output) {
2293 end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,
2295 if (end < ist->prev_sub.subtitle.end_display_time) {
2296 av_log(ist->dec_ctx, AV_LOG_DEBUG,
2298 ist->prev_sub.subtitle.end_display_time, end,
2300 ist->prev_sub.subtitle.end_display_time = end;
2303 FFSWAP(int, *got_output, ist->prev_sub.got_output);
2304 FFSWAP(int, ret, ist->prev_sub.ret);
2305 FFSWAP(AVSubtitle, subtitle, ist->prev_sub.subtitle);
2313 if (ist->sub2video.frame) {
2314 sub2video_update(ist, INT64_MIN, &subtitle);
2315 } else if (ist->nb_filters) {
2316 if (!ist->sub2video.sub_queue)
2317 ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW);
2318 if (!ist->sub2video.sub_queue)
2321 ret = av_fifo_write(ist->sub2video.sub_queue, &subtitle, 1);
2330 ist->frames_decoded++;
2335 if (!check_output_constraints(ist, ost) || !ost->encoding_needed
2348 static int send_filter_eof(InputStream *ist)
2352 int64_t pts = av_rescale_q_rnd(ist->pts, AV_TIME_BASE_Q, ist->st->time_base,
2355 for (i = 0; i < ist->nb_filters; i++) {
2356 ret = ifilter_send_eof(ist->filters[i], pts);
2364 static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
2370 AVPacket *avpkt = ist->pkt;
2372 if (!ist->saw_first_ts) {
2373 ist->first_dts =
2374 ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
2375 ist->pts = 0;
2376 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
2377 ist->first_dts =
2378 ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
2379 ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong
2381 ist->saw_first_ts = 1;
2384 if (ist->next_dts == AV_NOPTS_VALUE)
2385 ist->next_dts = ist->dts;
2386 if (ist->next_pts == AV_NOPTS_VALUE)
2387 ist->next_pts = ist->pts;
2397 ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
2398 if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed)
2399 ist->next_pts = ist->pts = ist->dts;
2403 while (ist->decoding_needed) {
2409 ist->pts = ist->next_pts;
2410 ist->dts = ist->next_dts;
2412 switch (ist->dec_ctx->codec_type) {
2414 ret = decode_audio (ist, repeating ? NULL : avpkt, &got_output,
2419 ret = decode_video (ist, repeating ? NULL : avpkt, &got_output, &duration_pts, !pkt,
2423 duration_dts = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
2424 } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) {
2425 int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame;
2427 ist->dec_ctx->framerate.den * ticks) /
2428 ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame;
2431 if(ist->dts != AV_NOPTS_VALUE && duration_dts) {
2432 ist->next_dts += duration_dts;
2434 ist->next_dts = AV_NOPTS_VALUE;
2439 ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q);
2441 ist->next_pts += duration_dts;
2449 ret = transcode_subtitles(ist, avpkt, &got_output, &decode_failed);
2466 ist->file_index, ist->st->index, av_err2str(ret));
2469 "data for stream #%d:%d\n", ist->file_index, ist->st->index);
2477 ist->got_output = 1;
2498 if (!pkt && ist->decoding_needed && eof_reached && !no_eof) {
2499 int ret = send_filter_eof(ist);
2507 if (!ist->decoding_needed && pkt) {
2508 ist->dts = ist->next_dts;
2509 switch (ist->dec_ctx->codec_type) {
2512 if (ist->dec_ctx->sample_rate) {
2513 ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
2514 ist->dec_ctx->sample_rate;
2516 ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
2520 if (ist->framerate.num) {
2523 int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate));
2524 ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);
2526 ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
2527 } else if(ist->dec_ctx->framerate.num != 0) {
2528 int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
2529 ist->next_dts += ((int64_t)AV_TIME_BASE *
2530 ist->dec_ctx->framerate.den * ticks) /
2531 ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame;
2535 ist->pts = ist->dts;
2536 ist->next_pts = ist->next_dts;
2537 } else if (!ist->decoding_needed)
2543 if (!check_output_constraints(ist, ost) || ost->encoding_needed)
2546 do_streamcopy(ist, ost, pkt);
2554 InputStream *ist = s->opaque;
2566 if (ist->hwaccel_id == HWACCEL_GENERIC ||
2567 ist->hwaccel_id == HWACCEL_AUTO) {
2579 if (config && config->device_type == ist->hwaccel_device_type) {
2582 if (ist->hwaccel_id == HWACCEL_GENERIC) {
2587 ist->file_index, ist->st->index);
2593 ist->hwaccel_pix_fmt = *p;
2604 InputStream *ist = input_streams[ist_index];
2606 if (ist->decoding_needed) {
2607 const AVCodec *codec = ist->dec;
2610 avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index);
2614 ist->dec_ctx->opaque = ist;
2615 ist->dec_ctx->get_format = get_format;
2618 ist->dec_ctx->thread_safe_callbacks = 1;
2622 if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
2623 (ist->decoding_needed & DECODING_FOR_OST)) {
2624 av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE);
2625 if (ist->decoding_needed & DECODING_FOR_FILTER)
2631 ist->dec_ctx->pkt_timebase = ist->st->time_base;
2633 if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
2634 av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
2636 if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
2637 av_dict_set(&ist->decoder_opts, "threads", "1", 0);
2639 ret = hw_device_setup_for_decode(ist);
2643 ist->file_index, ist->st->index, av_err2str(ret));
2647 if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) {
2654 ist->file_index, ist->st->index, av_err2str(ret));
2657 assert_avoptions(ist->decoder_opts);
2660 ist->next_pts = AV_NOPTS_VALUE;
2661 ist->next_dts = AV_NOPTS_VALUE;
2710 InputStream *ist = get_input_stream(ost);
2717 av_assert0(ist && !ost->filter);
2719 ret = avcodec_parameters_to_context(ost->enc_ctx, ist->st->codecpar);
2750 ost->frame_rate = ist->framerate;
2755 ost->st->avg_frame_rate = ist->st->avg_frame_rate;
2757 ret = avformat_transfer_internal_stream_timing_info(of->format, ost->st, ist->st, copy_tb);
2770 if (ost->st->duration <= 0 && ist->st->duration > 0)
2771 ost->st->duration = av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
2773 if (ist->st->nb_side_data) {
2774 for (i = 0; i < ist->st->nb_side_data; i++) {
2775 const AVPacketSideData *sd_src = &ist->st->side_data[i];
2811 else if (ist->st->sample_aspect_ratio.num)
2812 sar = ist->st->sample_aspect_ratio;
2816 ost->st->avg_frame_rate = ist->st->avg_frame_rate;
2817 ost->st->r_frame_rate = ist->st->r_frame_rate;
2821 ost->mux_timebase = ist->st->time_base;
2932 InputStream *ist = get_input_stream(ost);
2942 if (ist) {
2943 enc_ctx->time_base = ist->st->time_base;
2956 InputStream *ist = get_input_stream(ost);
2965 if (ist) {
2966 dec_ctx = ist->dec_ctx;
2972 if (ist && !ost->frame_rate.num && !ost->max_frame_rate.num) {
3125 InputStream *ist;
3131 if ((ist = get_input_stream(ost)))
3132 dec = ist->dec_ctx;
3152 if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) {
3217 if (ist) {
3219 for (i = 0; i < ist->st->nb_side_data; i++) {
3220 AVPacketSideData *sd = &ist->st->side_data[i];
3226 if (ist->autorotate && sd->type == AV_PKT_DATA_DISPLAYMATRIX)
3237 if (ost->st->duration <= 0 && ist && ist->st->duration > 0)
3238 ost->st->duration = av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
3281 InputStream *ist;
3293 if (fg->inputs[0]->ist == input_streams[k])
3367 ist = input_streams[i];
3369 for (j = 0; j < ist->nb_filters; j++) {
3370 if (!filtergraph_is_simple(ist->filters[j]->graph)) {
3372 ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
3373 ist->filters[j]->name);
3375 av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
3772 InputStream *ist = input_streams[f->ist_index + i];
3774 if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) continue;
3775 stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start);
3776 pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
3777 now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset;
3831 InputStream *ist;
3841 ist = input_streams[ifile->ist_index + i];
3842 avctx = ist->dec_ctx;
3847 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples)
3852 ist = input_streams[ifile->ist_index + i];
3853 avctx = ist->dec_ctx;
3856 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples) {
3859 duration = av_rescale_q(ist->nb_samples, sample_rate, ist->st->time_base);
3864 if (ist->framerate.num) {
3865 duration = av_rescale_q(1, av_inv_q(ist->framerate), ist->st->time_base);
3866 } else if (ist->st->avg_frame_rate.num) {
3867 duration = av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), ist->st->time_base);
3873 ifile->time_base = ist->st->time_base;
3876 if (ist->max_pts > ist->min_pts && ist->max_pts - (uint64_t)ist->min_pts < INT64_MAX - duration)
3877 duration += ist->max_pts - ist->min_pts;
3878 ifile->time_base = duration_max(duration, &ifile->duration, ist->st->time_base,
3899 InputStream *ist;
3916 ist = input_streams[ifile->ist_index + i];
3917 avctx = ist->dec_ctx;
3918 if (ist->processing_needed) {
3919 ret = process_input_packet(ist, NULL, 1);
3922 if (ist->decoding_needed)
3952 ist = input_streams[ifile->ist_index + i];
3953 if (ist->processing_needed) {
3954 ret = process_input_packet(ist, NULL, 0);
3986 ist = input_streams[ifile->ist_index + pkt->stream_index];
3988 ist->data_size += pkt->size;
3989 ist->nb_packets++;
3991 if (ist->discard)
4004 ifile->ist_index + pkt->stream_index, av_get_media_type_string(ist->dec_ctx->codec_type),
4005 av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
4006 av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
4007 av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base),
4008 av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base),
4009 av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base),
4010 av_ts2str(input_files[ist->file_index]->ts_offset),
4011 av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q));
4014 if(!ist->wrap_correction_done && is->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
4019 if ( ist->next_dts == AV_NOPTS_VALUE
4035 stime = av_rescale_q(is->start_time, AV_TIME_BASE_Q, ist->st->time_base);
4036 stime2= stime + (1ULL<<ist->st->pts_wrap_bits);
4037 ist->wrap_correction_done = 1;
4039 if(stime2 > stime && pkt->dts != AV_NOPTS_VALUE && pkt->dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
4040 pkt->dts -= 1ULL<<ist->st->pts_wrap_bits;
4041 ist->wrap_correction_done = 0;
4043 if(stime2 > stime && pkt->pts != AV_NOPTS_VALUE && pkt->pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
4044 pkt->pts -= 1ULL<<ist->st->pts_wrap_bits;
4045 ist->wrap_correction_done = 0;
4050 if (ist->nb_packets == 1) {
4051 for (i = 0; i < ist->st->nb_side_data; i++) {
4052 AVPacketSideData *src_sd = &ist->st->side_data[i];
4070 pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
4072 pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
4075 pkt->pts *= ist->ts_scale;
4077 pkt->dts *= ist->ts_scale;
4079 pkt_dts = av_rescale_q_rnd(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
4080 if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
4081 ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
4082 pkt_dts != AV_NOPTS_VALUE && ist->next_dts == AV_NOPTS_VALUE && !copy_ts
4091 pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
4093 pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
4097 duration = av_rescale_q(ifile->duration, ifile->time_base, ist->st->time_base);
4100 ist->max_pts = FFMAX(pkt->pts, ist->max_pts);
4101 ist->min_pts = FFMIN(pkt->pts, ist->min_pts);
4107 pkt_dts = av_rescale_q_rnd(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
4109 if (copy_ts && pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
4110 (is->iformat->flags & AVFMT_TS_DISCONT) && ist->st->pts_wrap_bits < 60) {
4111 int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits),
4112 ist->st->time_base, AV_TIME_BASE_Q,
4114 if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10)
4118 if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
4119 ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
4120 pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
4122 int64_t delta = pkt_dts - ist->next_dts;
4126 pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) {
4131 ist->file_index, ist->st->index, ist->st->id,
4132 av_get_media_type_string(ist->dec_ctx->codec_type),
4134 pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
4136 pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
4141 av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt->dts, ist->next_dts, pkt->stream_index);
4145 int64_t pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
4146 delta = pkt_pts - ist->next_dts;
4149 av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt->pts, ist->next_dts, pkt->stream_index);
4157 ifile->last_ts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
4161 ifile->ist_index + pkt->stream_index, av_get_media_type_string(ist->dec_ctx->codec_type),
4162 av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base),
4163 av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base),
4164 av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base),
4165 av_ts2str(input_files[ist->file_index]->ts_offset),
4166 av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q));
4169 sub2video_heartbeat(ist, pkt->pts);
4171 process_input_packet(ist, pkt, 0);
4196 InputStream *ist;
4214 ist = ifilter->ist;
4215 if (input_files[ist->file_index]->eagain ||
4216 input_files[ist->file_index]->eof_reached)
4221 *best_ist = ist;
4240 InputStream *ist = NULL;
4289 if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0)
4291 if (!ist)
4297 if (!ifilter->ist->got_output && !input_files[ifilter->ist->file_index]->eof_reached) {
4298 ist = ifilter->ist;
4302 if (!ist) {
4308 ist = input_streams[ost->source_index];
4311 ret = process_input(ist->file_index);
4313 if (input_files[ist->file_index]->eagain)
4332 InputStream *ist;
4380 ist = input_streams[i];
4381 if (!input_files[ist->file_index]->eof_reached) {
4382 process_input_packet(ist, NULL, 0);
4431 ist = input_streams[i];
4432 if (ist->decoding_needed) {
4433 avcodec_close(ist->dec_ctx);
4434 if (ist->hwaccel_uninit)
4435 ist->hwaccel_uninit(ist->dec_ctx);