Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#36 closed defect (fixed)

libavfilter: empty source buffer + yadif filters chain, polling for frames -> assertion failed

Reported by: Francesco Pretto Owned by: Michael Niedermayer
Priority: normal Component: avfilter
Version: Keywords: crash abort
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

NB: the "nullsink" filter is used improperly as the last filter in the chain.

The following self compiling sample gives:

Assertion failed!
Program: C:\Users\ceztko\Staging\target\Debug\Test.exe
File: libavfilter/vf_yadif.c, Line 277
Expression: yadif->next

Polling for frames with the empty source filter should, IMO, return 0, or be a specific switchable error (not a generic -1).

#include <stdio.h>

#include <libavfilter/avfilter.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/vsrc_buffer.h>

int main(int argc, char* argv[])
{
    avfilter_register_all();

    AVFilterGraph *filter_graph = avfilter_graph_alloc();
    if (filter_graph == NULL)
	    printf("error init");

    AVFilter *buffer_filter = avfilter_get_by_name("buffer");
    if (buffer_filter == NULL)
	    printf("error init");

    char args[256];
    snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", 720, 576,
	    PIX_FMT_YUV420P, 1, 25, 16, 15);

    int rv;

    // Buffer video source: the decoded frames from the codec will be inserted here
    AVFilterContext *buffer_filter_ctx;
    rv = avfilter_graph_create_filter(&buffer_filter_ctx, buffer_filter, "src",
	    args, NULL, filter_graph);
    if (rv != 0)
	    printf("error init");

    AVFilter *sink_filter = avfilter_get_by_name("nullsink");
    if (sink_filter == NULL)
	    printf("error init");

    // Null video sink: to terminate the filter chain
    AVFilterContext *sink_filter_ctx;
    rv = avfilter_graph_create_filter(&sink_filter_ctx, sink_filter, "out",
	    NULL, NULL, filter_graph);
    if (rv != 0)
	    printf("error init");

    // Endpoints for the filter graph
    AVFilterInOut *buffer_filter_outputs =
       (AVFilterInOut *)av_mallocz(sizeof(AVFilterInOut));
    if (buffer_filter_outputs == NULL)
	    printf("error init");

    buffer_filter_outputs->name = av_strdup("in");
    buffer_filter_outputs->filter_ctx = buffer_filter_ctx;
    buffer_filter_outputs->pad_idx = 0;
    buffer_filter_outputs->next = NULL;

    AVFilterInOut *sink_filter_inputs =
        (AVFilterInOut *)av_mallocz(sizeof(AVFilterInOut));
    if (sink_filter_inputs == NULL)
	    printf("error init");

    sink_filter_inputs->name = av_strdup("out");
    sink_filter_inputs->filter_ctx = sink_filter_ctx;
    sink_filter_inputs->pad_idx = 0;
    sink_filter_inputs->next = NULL;

    rv = avfilter_graph_parse(filter_graph, "yadif=1-1",
	    sink_filter_inputs, buffer_filter_outputs, NULL);
    if (rv != 0)
	    printf("error init");

    rv = avfilter_graph_config(filter_graph, NULL);
    if (rv != 0)
	    printf("error init");

    AVFilterLink *output_link = sink_filter_ctx->inputs[0];
    rv = avfilter_poll_frame(output_link);
    printf("%d", rv);

	return 0;
}

Change History (2)

comment:1 by Michael Niedermayer, 14 years ago

Analyzed by developer: set
Resolution: fixed
Status: newclosed

should be fixed
thx for the report

comment:2 by Carl Eugen Hoyos, 12 years ago

Keywords: crash abort added
Note: See TracTickets for help on using tickets.