Remove AVFilterBufferRefAudioProps.size, and use nb_samples in its place everywhere. This is required as the size in the audio buffer may be aligned, so it may not contain a well defined number of samples. Also remove the useless planar parameter, which can be deduced from the sample format. This is technically an API and ABI break, but since the audio part of lavfi is not usable now, this should not be a problem in practice.
Showing the changes to libavfilter/avfilter.c (1 of 3 files). Show all
Unified · Split
| @@ -265,10 +265,9 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) · 264 unmodified lines | |||
| 265 | av_get_picture_type_char(ref->video->pict_type)); | 265 | av_get_picture_type_char(ref->video->pict_type)); |
| 266 | } | 266 | } |
| 267 | if (ref->audio) { | 267 | if (ref->audio) { |
| 268 | av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d", | 268 | av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d p:%d", |
| 269 | ref->audio->channel_layout, | 269 | ref->audio->channel_layout, |
| 270 | ref->audio->nb_samples, | 270 | ref->audio->nb_samples, |
| 271 | ref->audio->size, | ||
| 272 | ref->audio->sample_rate, | 271 | ref->audio->sample_rate, |
| 273 | ref->audio->planar); | 272 | ref->audio->planar); |
| 274 | } | 273 | } |
| @@ -368,16 +367,16 @@ fail: · 93 unmodified lines | |||
| 368 | } | 367 | } |
| 369 | 368 | ||
| 370 | AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, | 369 | AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, |
| 371 | enum AVSampleFormat sample_fmt, int size, | 370 | enum AVSampleFormat sample_fmt, int nb_samples, |
| 372 | uint64_t channel_layout, int planar) | 371 | uint64_t channel_layout) |
| 373 | { | 372 | { |
| 374 | AVFilterBufferRef *ret = NULL; | 373 | AVFilterBufferRef *ret = NULL; |
| 375 | 374 | ||
| 376 | if (link->dstpad->get_audio_buffer) | 375 | if (link->dstpad->get_audio_buffer) |
| 377 | ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); | 376 | ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); |
| 378 | 377 | ||
| 379 | if (!ret) | 378 | if (!ret) |
| 380 | ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); | 379 | ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); |
| 381 | 380 | ||
| 382 | if (ret) | 381 | if (ret) |
| 383 | ret->type = AVMEDIA_TYPE_AUDIO; | 382 | ret->type = AVMEDIA_TYPE_AUDIO; |
| @@ -585,6 +584,9 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) · 201 unmodified lines | |||
| 585 | /* prepare to copy the samples if the buffer has insufficient permissions */ | 584 | /* prepare to copy the samples if the buffer has insufficient permissions */ |
| 586 | if ((dst->min_perms & samplesref->perms) != dst->min_perms || | 585 | if ((dst->min_perms & samplesref->perms) != dst->min_perms || |
| 587 | dst->rej_perms & samplesref->perms) { | 586 | dst->rej_perms & samplesref->perms) { |
| 587 | int i, planar = av_sample_fmt_is_planar(samplesref->format); | ||
| 588 | int planes = !planar ? 1: | ||
| 589 | av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); | ||
| 588 | 590 | ||
| 589 | av_log(link->dst, AV_LOG_DEBUG, | 591 | av_log(link->dst, AV_LOG_DEBUG, |
| 590 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", | 592 | "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", |
| @@ -592,14 +594,14 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) · 1 unmodified line | |||
| 592 | 594 | ||
| 593 | link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, | 595 | link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, |
| 594 | samplesref->format, | 596 | samplesref->format, |
| 595 | samplesref->audio->size, | 597 | samplesref->audio->nb_samples, |
| 596 | samplesref->audio->channel_layout, | 598 | samplesref->audio->channel_layout); |
| 597 | samplesref->audio->planar); | ||
| 598 | link->cur_buf->pts = samplesref->pts; | 599 | link->cur_buf->pts = samplesref->pts; |
| 599 | link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; | 600 | link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; |
| 600 | 601 | ||
| 601 | /* Copy actual data into new samples buffer */ | 602 | /* Copy actual data into new samples buffer */ |
| 602 | memcpy(link->cur_buf->data[0], samplesref->data[0], samplesref->audio->size); | 603 | for (i = 0; i < planes; i++) |
| 604 | memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]); | ||
| 603 | 605 | ||
| 604 | avfilter_unref_buffer(samplesref); | 606 | avfilter_unref_buffer(samplesref); |
| 605 | } else | 607 | } else |