History

lavfi: make request_frame() non-recursive.

Instead of calling the input filter request_frame() method, ff_request_frame() now marks the link and returns immediately. buffersink is changed to activate the marked filters until a frame is obtained.

Nicolas George committed 11 years ago

Commit 16557881 parent 108b4de5 files · +99 −5Browse files

Showing the changes to libavfilter/avfiltergraph.c (1 of 5 files). Show all

Unified · Split

libavfilter/avfiltergraph.c+54−4
@@ -1367,11 +1367,14 @@ void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link) · 1366 unmodified lines
1367 1367
1368int avfilter_graph_request_oldest(AVFilterGraph *graph)1368int avfilter_graph_request_oldest(AVFilterGraph *graph)
1369{1369{
1370 AVFilterLink *oldest = graph->sink_links[0];
1371 int r;
1372
1370 while (graph->sink_links_count) {1373 while (graph->sink_links_count) {
1371 AVFilterLink *oldest = graph->sink_links[0];1374 oldest = graph->sink_links[0];
1372 int r = ff_request_frame(oldest);1375 r = ff_request_frame(oldest);
1373 if (r != AVERROR_EOF)1376 if (r != AVERROR_EOF)
1374 return r;1377 break;
1375 av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",1378 av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",
1376 oldest->dst ? oldest->dst->name : "unknown",1379 oldest->dst ? oldest->dst->name : "unknown",
1377 oldest->dstpad ? oldest->dstpad->name : "unknown");1380 oldest->dstpad ? oldest->dstpad->name : "unknown");
@@ -1381,5 +1384,52 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph) · 3 unmodified lines
1381 oldest->age_index);1384 oldest->age_index);
1382 oldest->age_index = -1;1385 oldest->age_index = -1;
1383 }1386 }
1384 return AVERROR_EOF;1387 if (!graph->sink_links_count)
1388 return AVERROR_EOF;
1389 av_assert1(oldest->age_index >= 0);
1390 while (oldest->frame_wanted_out) {
1391 r = ff_filter_graph_run_once(graph);
1392 if (r < 0)
1393 return r;
1394 }
1395 return 0;
1396}
1397
1398static AVFilterLink *graph_run_once_find_filter(AVFilterGraph *graph)
1399{
1400 unsigned i, j;
1401 AVFilterContext *f;
1402
1403 /* TODO: replace scanning the graph with a priority list */
1404 for (i = 0; i < graph->nb_filters; i++) {
1405 f = graph->filters[i];
1406 for (j = 0; j < f->nb_outputs; j++)
1407 if (f->outputs[j]->frame_wanted_in)
1408 return f->outputs[j];
1409 }
1410 for (i = 0; i < graph->nb_filters; i++) {
1411 f = graph->filters[i];
1412 for (j = 0; j < f->nb_outputs; j++)
1413 if (f->outputs[j]->frame_wanted_out)
1414 return f->outputs[j];
1415 }
1416 return NULL;
1417}
1418
1419int ff_filter_graph_run_once(AVFilterGraph *graph)
1420{
1421 AVFilterLink *link;
1422 int ret;
1423
1424 link = graph_run_once_find_filter(graph);
1425 if (!link) {
1426 av_log(NULL, AV_LOG_WARNING, "Useless run of a filter graph\n");
1427 return AVERROR(EAGAIN);
1428 }
1429 ret = ff_request_frame_to_filter(link);
1430 if (ret == AVERROR_EOF)
1431 /* local EOF will be forwarded through request_frame() /
1432 set_status() until it reaches the sink */
1433 ret = 0;
1434 return ret < 0 ? ret : 1;
1385}1435}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t