[FFmpeg-devel] [PATCHv2] add signature filter for MPEG7 video signature

Michael Niedermayer michael at niedermayer.cc
Sun May 15 00:26:20 CEST 2016


On Tue, May 03, 2016 at 07:01:51PM +0200, Gerion Entrup wrote:
> On Sonntag, 24. April 2016 01:44:51 CEST Michael Niedermayer wrote:
> > On Tue, Apr 19, 2016 at 04:37:16PM +0200, Gerion Entrup wrote:
> > > On Dienstag, 19. April 2016 13:25:53 CEST Moritz Barsnick wrote:
> > > +static int request_frame(AVFilterLink *outlink)
> > > +{
> > > +    AVFilterContext *ctx = outlink->src;
> > > +    SignatureContext *sc = ctx->priv;
> > > +    int i, ret;
> > > +
> > > +    for (i = 0; i < sc->nb_inputs; i++){
> > > +        ret = ff_request_frame(ctx->inputs[i]);
> > > +        // TODO handle this in a better way?
> > > +        // Problem is the following:
> > > +        // Assuming two inputs, inputA with 50 frames, inputB with 100 frames
> > > +        // simply returning ret when < 0 would result in not filtering inputB
> > > +        // after 50 frames anymore, not wanted
> > > +        // only returning ret at the end would result in only respecting the error
> > > +        // values of the last input, please comment
> > > +        if (ret < 0 && ret != AVERROR_EOF)
> > > +            return ret;
> > > +    }
> > > +    return ret;
> > > +}
> > 
> > i dont know what exactly you want to happen when the inputs mismatch
> > but handling it like other dualinput filters might be an option
> vf_decimate, vf_fieldmatch: a main input exists, that dominates
> vf_mergeplanes, vf_stack, f_streamselect: return value of ff_framesync_request_frame is used
> af_amerge, af_join: as soon as one inputstream end, the filter quits, other said, the first error is returned
> af_amix: AVERROR_EOF is catched and things happen, could be a possible solution, but is audio related
> af_ladspa: beside other things, with multiinput the return value of ff_request_frame is returned
> avf_concat, f_interleave: only values except AVERROR_EOF are handled, in some way similar like my current solution but without the <0 check
> 
> I see not an analog usecase with any of these filters. If the inputs mismatch absolutely nothing should happen.
> The filter (the algorithm) does not require inputs of same length.

ok, so what is the problem ?
the return code from your request_frame() is about your filter only
really. That is it is EOF when you are at EOF, that may be different
from when the inputs EOF
isnt it fine already as is ?

> 
> 
> > 
> > 
> > [...]
> > > +static av_cold void uninit(AVFilterContext *ctx)
> > > +{
> > > +    SignatureContext *sic = ctx->priv;
> > > +    StreamContext *sc, *sc2;
> > > +    void* tmp;
> > > +    FineSignature* finsig;
> > > +    CourseSignature* cousig;
> > > +    MatchingInfo match;
> > > +    int i,j;
> > > +
> > > +    //TODO export and especially lookup_signature can have a return value to show some error etc.
> > > +    //How could this be handled in this function?
> > 
> > why does it need to happen in uninit ?
> > EOF could be detected before uninit if it doesnt work here
> What would be another good place to call export and lookup? The process chart would be something like:
> 
> [input1]-->[signature_computation with loop over all frames]-->[export]-.
>                                                                          -->[lookup]
> [input2]-->[signature_computation with loop over all frames]-->[export]-`
> 
> ATM signature_computation is done in filter_frame and export and lookup are in uninit.

If your goal is to do/return something at EOF, then one way to do that
should be to wait until your inputs are EOF and then do/return that
before you return EOF

the calling application cannot know if a filter will still return
something after all its inputs are EOF it thus must attempt to
request until EOF is signaled by some means
you should be able to detect that i request_frame

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160515/52dca177/attachment.sig>


More information about the ffmpeg-devel mailing list