MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / process_input_packet

Function process_input_packet

ffmpeg-single-cmd/src/main/cpp/ffmpeg_mod.c:2591–2764  ·  view source on GitHub ↗

pkt = NULL means EOF (needed to flush decoder buffers) */

Source from the content-addressed store, hash-verified

2589
2590/* pkt = NULL means EOF (needed to flush decoder buffers) */
2591static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
2592{
2593 int ret = 0, i;
2594 int repeating = 0;
2595 int eof_reached = 0;
2596
2597 AVPacket avpkt;
2598 if (!ist->saw_first_ts) {
2599 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;
2600 ist->pts = 0;
2601 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
2602 ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
2603 ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong
2604 }
2605 ist->saw_first_ts = 1;
2606 }
2607
2608 if (ist->next_dts == AV_NOPTS_VALUE)
2609 ist->next_dts = ist->dts;
2610 if (ist->next_pts == AV_NOPTS_VALUE)
2611 ist->next_pts = ist->pts;
2612
2613 if (!pkt) {
2614 /* EOF handling */
2615 av_init_packet(&avpkt);
2616 avpkt.data = NULL;
2617 avpkt.size = 0;
2618 } else {
2619 avpkt = *pkt;
2620 }
2621
2622 if (pkt && pkt->dts != AV_NOPTS_VALUE) {
2623 ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
2624 if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed)
2625 ist->next_pts = ist->pts = ist->dts;
2626 }
2627
2628 // while we have more to decode or while the decoder did output something on EOF
2629 while (ist->decoding_needed) {
2630 int duration = 0;
2631 int got_output = 0;
2632 int decode_failed = 0;
2633
2634 ist->pts = ist->next_pts;
2635 ist->dts = ist->next_dts;
2636
2637 switch (ist->dec_ctx->codec_type) {
2638 case AVMEDIA_TYPE_AUDIO:
2639 ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output,
2640 &decode_failed);
2641 break;
2642 case AVMEDIA_TYPE_VIDEO:
2643 ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, !pkt,
2644 &decode_failed);
2645 if (!repeating || !pkt || got_output) {
2646 if (pkt && pkt->duration) {
2647 duration = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
2648 } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) {

Callers 3

seek_to_startFunction · 0.85
process_inputFunction · 0.85
transcodeFunction · 0.85

Calls 8

decode_audioFunction · 0.85
decode_videoFunction · 0.85
transcode_subtitlesFunction · 0.85
exit_programFunction · 0.85
send_filter_eofFunction · 0.85
check_output_constraintsFunction · 0.85
do_streamcopyFunction · 0.85
av_q2dFunction · 0.50

Tested by

no test coverage detected