Remove AVFilterBufferRefAudioProps.size, and use nb_samples in
avfilter_get_audio_buffer() and avfilter_default_get_audio_buffer() in
place of size.
This is required as the size in the audio buffer may be aligned, so it
may not contain a well defined number of samples.
| ... | ... |
@@ -13,6 +13,11 @@ libavutil: 2011-04-18 |
| 13 | 13 |
|
| 14 | 14 |
API changes, most recent first: |
| 15 | 15 |
|
| 16 |
+2011-06-06 - xxxxxx - lavfi 2.14.0 - AVFilterBufferRefAudioProps |
|
| 17 |
+ Remove AVFilterBufferRefAudioProps.size, and use nb_samples in |
|
| 18 |
+ avfilter_get_audio_buffer() and avfilter_default_get_audio_buffer() in |
|
| 19 |
+ place of size. |
|
| 20 |
+ |
|
| 16 | 21 |
2011-06-06 - xxxxxx - lavu 51.6.0 - av_samples_alloc() |
| 17 | 22 |
Switch nb_channels and nb_samples parameters order in |
| 18 | 23 |
av_samples_alloc(). |
| ... | ... |
@@ -305,10 +305,9 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) |
| 305 | 305 |
av_get_picture_type_char(ref->video->pict_type)); |
| 306 | 306 |
} |
| 307 | 307 |
if (ref->audio) {
|
| 308 |
- av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d", |
|
| 308 |
+ av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d p:%d", |
|
| 309 | 309 |
ref->audio->channel_layout, |
| 310 | 310 |
ref->audio->nb_samples, |
| 311 |
- ref->audio->size, |
|
| 312 | 311 |
ref->audio->sample_rate, |
| 313 | 312 |
ref->audio->planar); |
| 314 | 313 |
} |
| ... | ... |
@@ -405,16 +404,16 @@ fail: |
| 405 | 405 |
} |
| 406 | 406 |
|
| 407 | 407 |
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, |
| 408 |
- enum AVSampleFormat sample_fmt, int size, |
|
| 408 |
+ enum AVSampleFormat sample_fmt, int nb_samples, |
|
| 409 | 409 |
int64_t channel_layout, int planar) |
| 410 | 410 |
{
|
| 411 | 411 |
AVFilterBufferRef *ret = NULL; |
| 412 | 412 |
|
| 413 | 413 |
if (link->dstpad->get_audio_buffer) |
| 414 |
- ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
|
| 414 |
+ ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar); |
|
| 415 | 415 |
|
| 416 | 416 |
if (!ret) |
| 417 |
- ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); |
|
| 417 |
+ ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar); |
|
| 418 | 418 |
|
| 419 | 419 |
if (ret) |
| 420 | 420 |
ret->type = AVMEDIA_TYPE_AUDIO; |
| ... | ... |
@@ -545,6 +544,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
| 545 | 545 |
{
|
| 546 | 546 |
void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); |
| 547 | 547 |
AVFilterPad *dst = link->dstpad; |
| 548 |
+ int i; |
|
| 548 | 549 |
|
| 549 | 550 |
FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); |
| 550 | 551 |
|
| ... | ... |
@@ -561,14 +561,15 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
| 561 | 561 |
|
| 562 | 562 |
link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, |
| 563 | 563 |
samplesref->format, |
| 564 |
- samplesref->audio->size, |
|
| 564 |
+ samplesref->audio->nb_samples, |
|
| 565 | 565 |
samplesref->audio->channel_layout, |
| 566 | 566 |
samplesref->audio->planar); |
| 567 | 567 |
link->cur_buf->pts = samplesref->pts; |
| 568 | 568 |
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; |
| 569 | 569 |
|
| 570 | 570 |
/* Copy actual data into new samples buffer */ |
| 571 |
- memcpy(link->cur_buf->data[0], samplesref->data[0], samplesref->audio->size); |
|
| 571 |
+ for (i = 0; samplesref->data[i]; i++) |
|
| 572 |
+ memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); |
|
| 572 | 573 |
|
| 573 | 574 |
avfilter_unref_buffer(samplesref); |
| 574 | 575 |
} else |
| ... | ... |
@@ -26,7 +26,7 @@ |
| 26 | 26 |
#include "libavutil/samplefmt.h" |
| 27 | 27 |
|
| 28 | 28 |
#define LIBAVFILTER_VERSION_MAJOR 2 |
| 29 |
-#define LIBAVFILTER_VERSION_MINOR 13 |
|
| 29 |
+#define LIBAVFILTER_VERSION_MINOR 14 |
|
| 30 | 30 |
#define LIBAVFILTER_VERSION_MICRO 0 |
| 31 | 31 |
|
| 32 | 32 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| ... | ... |
@@ -98,8 +98,7 @@ typedef struct AVFilterBuffer {
|
| 98 | 98 |
*/ |
| 99 | 99 |
typedef struct AVFilterBufferRefAudioProps {
|
| 100 | 100 |
int64_t channel_layout; ///< channel layout of audio buffer |
| 101 |
- int nb_samples; ///< number of audio samples |
|
| 102 |
- int size; ///< audio buffer size |
|
| 101 |
+ int nb_samples; ///< number of audio samples per channel |
|
| 103 | 102 |
uint32_t sample_rate; ///< audio buffer sample rate |
| 104 | 103 |
int planar; ///< audio buffer - planar or packed |
| 105 | 104 |
} AVFilterBufferRefAudioProps; |
| ... | ... |
@@ -372,7 +371,7 @@ struct AVFilterPad {
|
| 372 | 372 |
* Input audio pads only. |
| 373 | 373 |
*/ |
| 374 | 374 |
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, |
| 375 |
- enum AVSampleFormat sample_fmt, int size, |
|
| 375 |
+ enum AVSampleFormat sample_fmt, int nb_samples, |
|
| 376 | 376 |
int64_t channel_layout, int planar); |
| 377 | 377 |
|
| 378 | 378 |
/** |
| ... | ... |
@@ -461,7 +460,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, |
| 461 | 461 |
|
| 462 | 462 |
/** default handler for get_audio_buffer() for audio inputs */ |
| 463 | 463 |
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, |
| 464 |
- enum AVSampleFormat sample_fmt, int size, |
|
| 464 |
+ enum AVSampleFormat sample_fmt, int nb_samples, |
|
| 465 | 465 |
int64_t channel_layout, int planar); |
| 466 | 466 |
|
| 467 | 467 |
/** |
| ... | ... |
@@ -684,14 +683,14 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int lin |
| 684 | 684 |
* be requested |
| 685 | 685 |
* @param perms the required access permissions |
| 686 | 686 |
* @param sample_fmt the format of each sample in the buffer to allocate |
| 687 |
- * @param size the buffer size in bytes |
|
| 687 |
+ * @param nb_samples the number of samples per channel |
|
| 688 | 688 |
* @param channel_layout the number and type of channels per sample in the buffer to allocate |
| 689 | 689 |
* @param planar audio data layout - planar or packed |
| 690 | 690 |
* @return A reference to the samples. This must be unreferenced with |
| 691 | 691 |
* avfilter_unref_buffer when you are finished with it. |
| 692 | 692 |
*/ |
| 693 | 693 |
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, |
| 694 |
- enum AVSampleFormat sample_fmt, int size, |
|
| 694 |
+ enum AVSampleFormat sample_fmt, int nb_samples, |
|
| 695 | 695 |
int64_t channel_layout, int planar); |
| 696 | 696 |
|
| 697 | 697 |
/** |
| ... | ... |
@@ -81,7 +81,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per |
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, |
| 84 |
- enum AVSampleFormat sample_fmt, int size, |
|
| 84 |
+ enum AVSampleFormat sample_fmt, int nb_samples, |
|
| 85 | 85 |
int64_t channel_layout, int planar) |
| 86 | 86 |
{
|
| 87 | 87 |
AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); |
| ... | ... |
@@ -100,7 +100,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per |
| 100 | 100 |
goto fail; |
| 101 | 101 |
|
| 102 | 102 |
ref->audio->channel_layout = channel_layout; |
| 103 |
- ref->audio->size = size; |
|
| 103 |
+ ref->audio->nb_samples = nb_samples; |
|
| 104 | 104 |
ref->audio->planar = planar; |
| 105 | 105 |
|
| 106 | 106 |
/* make sure the buffer gets read permission or it's useless for output */ |
| ... | ... |
@@ -112,8 +112,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per |
| 112 | 112 |
sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3; |
| 113 | 113 |
chans_nb = av_get_channel_layout_nb_channels(channel_layout); |
| 114 | 114 |
|
| 115 |
- per_channel_size = size/chans_nb; |
|
| 116 |
- ref->audio->nb_samples = per_channel_size/sample_size; |
|
| 115 |
+ per_channel_size = nb_samples * sample_size; |
|
| 117 | 116 |
|
| 118 | 117 |
/* Set the number of bytes to traverse to reach next sample of a particular channel: |
| 119 | 118 |
* For planar, this is simply the sample size. |
| ... | ... |
@@ -124,7 +123,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per |
| 124 | 124 |
memset(&samples->linesize[chans_nb], 0, (8-chans_nb) * sizeof(samples->linesize[0])); |
| 125 | 125 |
|
| 126 | 126 |
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */ |
| 127 |
- bufsize = (size + 15)&~15; |
|
| 127 |
+ bufsize = (nb_samples * chans_nb * sample_size + 15)&~15; |
|
| 128 | 128 |
buf = av_malloc(bufsize); |
| 129 | 129 |
if (!buf) |
| 130 | 130 |
goto fail; |
| ... | ... |
@@ -212,7 +211,7 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa |
| 212 | 212 |
|
| 213 | 213 |
if (outlink) {
|
| 214 | 214 |
outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, samplesref->format, |
| 215 |
- samplesref->audio->size, |
|
| 215 |
+ samplesref->audio->nb_samples, |
|
| 216 | 216 |
samplesref->audio->channel_layout, |
| 217 | 217 |
samplesref->audio->planar); |
| 218 | 218 |
outlink->out_buf->pts = samplesref->pts; |