MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / process_frame

Function process_frame

fftools/ffprobe.c:1496–1567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1494}
1495
1496static av_always_inline int process_frame(AVTextFormatContext *tfc,
1497 InputFile *ifile,
1498 AVFrame *frame, const AVPacket *pkt,
1499 int *packet_new)
1500{
1501 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1502 AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx;
1503 AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
1504 AVSubtitle sub;
1505 int ret = 0, got_frame = 0;
1506
1507 clear_log(1);
1508 if (dec_ctx) {
1509 switch (par->codec_type) {
1510 case AVMEDIA_TYPE_VIDEO:
1511 case AVMEDIA_TYPE_AUDIO:
1512 if (*packet_new) {
1513 ret = avcodec_send_packet(dec_ctx, pkt);
1514 if (ret == AVERROR(EAGAIN)) {
1515 ret = 0;
1516 } else if (ret >= 0 || ret == AVERROR_EOF) {
1517 ret = 0;
1518 *packet_new = 0;
1519 }
1520 }
1521 if (ret >= 0) {
1522 ret = avcodec_receive_frame(dec_ctx, frame);
1523 if (ret >= 0) {
1524 got_frame = 1;
1525 } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
1526 ret = 0;
1527 }
1528 }
1529 break;
1530
1531 case AVMEDIA_TYPE_SUBTITLE:
1532 if (*packet_new)
1533 ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
1534 *packet_new = 0;
1535 break;
1536 default:
1537 *packet_new = 0;
1538 }
1539 } else {
1540 *packet_new = 0;
1541 }
1542
1543 if (ret < 0)
1544 return ret;
1545 if (got_frame) {
1546 int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
1547 nb_streams_frames[pkt->stream_index]++;
1548 if (do_show_frames)
1549 if (is_sub)
1550 show_subtitle(tfc, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
1551 else
1552 show_frame(tfc, frame, ifile->streams[pkt->stream_index].st, fmt_ctx);
1553

Callers 1

read_interval_packetsFunction · 0.70

Calls 7

clear_logFunction · 0.85
avcodec_send_packetFunction · 0.85
avcodec_receive_frameFunction · 0.85
avcodec_decode_subtitle2Function · 0.85
show_subtitleFunction · 0.85
show_frameFunction · 0.85
avsubtitle_freeFunction · 0.85

Tested by

no test coverage detected