Opened 13 years ago

Closed 11 years ago

#375 closed defect (fixed)

earwax audio filter generates wrong pts and af_sox filter can not be applied.

Reported by: chinshou Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: earwax
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

Sorry, I do not know is it appropriate to report bug for audio filter branch at https://github.com/mnzaki/FFmpeg/commits/audio-filters-20110726 .

I just try the audio filter branch for a while and noticed that when i set -af earwax , the generated audio data pts always 0.
I added the avfilter_copy_buffer_ref_props(outref, insamples); call to copy original pts to new samplesref and it seems to fix the problem.

static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
{
    int16_t *taps, *endin, *in, *out;
    AVFilterBufferRef *outref =
        avfilter_get_audio_buffer(inlink, AV_PERM_WRITE,
                                  inlink->format,
                                  insamples->audio->nb_samples,
                                  inlink->channel_layout,
                                  0);
+   avfilter_copy_buffer_ref_props(outref, insamples);//<<--copy pts

    taps  = ((EarwaxContext*)inlink->dst->priv)->taps;
    out   = (int16_t*)outref->data[0];
    in    = (int16_t*)insamples->data[0];
    ...

second, I guess we should add packing negotiate code to af_sox filter's query_formats , 
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats = NULL;
    avfilter_add_format(&formats, AV_SAMPLE_FMT_S32);
    avfilter_set_common_sample_formats(ctx, formats);
    avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts());
+    avfilter_set_common_packing_formats(ctx, avfilter_all_packing_formats());// << ---- packing negotiation

    return 0;
}

otherwise avfilter_graph_config call will fail at 
static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
 ...
            else if (link->type == AVMEDIA_TYPE_AUDIO) {
                if (!link->in_chlayouts || !link->out_chlayouts ||
                    !link->in_packing   || !link->out_packing)
                    return AVERROR(EINVAL); <<------fail at here

                if (!avfilter_merge_formats(link->in_formats,
                                            link->out_formats)    ||
                    !avfilter_merge_formats(link->in_chlayouts,
                                            link->out_chlayouts)  ||
                    !avfilter_merge_formats(link->in_packing,
                                            link->out_packing))
...}

best regards
chinshou

Change History (7)

comment:1 by chinshou, 13 years ago

Besides above problems,

in ffmpeg.c configure_audio_filters function should change inputs context from ost->input_audio_filter to last_filter like following.

static int configure_audio_filters(InputStream *ist, OutputStream *ost)
{
...

if (afilters) {

AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));

*inputs = (AVFilterInOut){ av_strdup("out"), ost->output_audio_filter, 0, NULL };

*outputs = (AVFilterInOut){ av_strdup("in" ), ost->input_audio_filter, 0, NULL }; <<---remove this line

+ *outputs = (AVFilterInOut){ av_strdup("in" ), last_filter, 0, NULL }; <<--add this line

if ((ret = avfilter_graph_parse(ost->agraph, afilters, &inputs, &outputs, NULL)) < 0)

return ret;

av_freep(&afilters);

} else {

...
}

regards

Last edited 13 years ago by chinshou (previous) (diff)

comment:2 by chinshou, 13 years ago

another problem
in af_sox.c uninit will segfault when called, we should change it

static av_cold void uninit(AVFilterContext *ctx)
{

sox_effect_t *effect = ((SoxContext*)ctx->priv)->effect;
sox_delete_effect(effect);
sox_quit();
av_free(effect->in_encoding);

}

to
static av_cold void uninit(AVFilterContext *ctx)
{

sox_effect_t *effect = ((SoxContext*)ctx->priv)->effect;
av_free(effect->in_encoding);
sox_delete_effect(effect);
sox_quit();

}

comment:3 by Mina Nagy, 13 years ago

The packing negotiation is a new addition and it wasn't added to sox and earwax filter yet, ditto for the 'fail on missing negotiation data' behaviour, which might be changed...

copy_props and filter inputs/outputs will be fixed, thanks for the report!

comment:4 by Michael Niedermayer, 11 years ago

A long time has passed, earwax is now in git master, is anything from this ticket still relevant or can it be closed ?

in reply to:  4 comment:5 by chinshou, 11 years ago

Replying to michael:

A long time has passed, earwax is now in git master, is anything from this ticket still relevant or can it be closed ?

Hello,

Please close this problem. The current earwax is ok.

best regards

comment:6 by Carl Eugen Hoyos, 11 years ago

Description: modified (diff)

comment:7 by Carl Eugen Hoyos, 11 years ago

Keywords: earwax added
Resolution: fixed
Status: newclosed
Version: unspecifiedgit-master
Note: See TracTickets for help on using tickets.