History

lavfi: implement avfilter_get_audio_buffer_ref_from_arrays()

Stefano Sabatini committed 15 years ago

Commit c3819601 parent c6d7fc23 files · +64 −2Browse files

Unified · Split

3 files
  1. doc/APIchanges +3 −0
  2. libavfilter/avfilter.c +42 −0
  3. libavfilter/avfilter.h +19 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-06-10 - xxxxxxx - lavfi 2.15.0 - avfilter_get_audio_buffer_ref_from_arrays
17+ Add avfilter_get_audio_buffer_ref_from_arrays() to avfilter.h.
18+
1619 2011-06-09 - d9f80ea - lavu 51.8.0 - AVMetadata
1720 Move AVMetadata from lavf to lavu and rename it to
1821 AVDictionary -- new installed header dict.h.
libavfilter/avfilter.c+42−0
@@ -421,6 +421,48 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, · 420 unmodified lines
421421 return ret;
422422 }
423423
424+AVFilterBufferRef *
425+avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
426+ int nb_samples, enum AVSampleFormat sample_fmt,
427+ int64_t channel_layout, int planar)
428+{
429+ AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
430+ AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef));
431+
432+ if (!samples || !samplesref)
433+ goto fail;
434+
435+ samplesref->buf = samples;
436+ samplesref->buf->free = ff_avfilter_default_free_buffer;
437+ if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps))))
438+ goto fail;
439+
440+ samplesref->audio->nb_samples = nb_samples;
441+ samplesref->audio->channel_layout = channel_layout;
442+ samplesref->audio->planar = planar;
443+
444+ /* make sure the buffer gets read permission or it's useless for output */
445+ samplesref->perms = perms | AV_PERM_READ;
446+
447+ samples->refcount = 1;
448+ samplesref->type = AVMEDIA_TYPE_AUDIO;
449+ samplesref->format = sample_fmt;
450+
451+ memcpy(samples->data, data, sizeof(samples->data));
452+ memcpy(samples->linesize, linesize, sizeof(samples->linesize));
453+ memcpy(samplesref->data, data, sizeof(samplesref->data));
454+ memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize));
455+
456+ return samplesref;
457+
458+fail:
459+ if (samplesref && samplesref->audio)
460+ av_freep(&samplesref->audio);
461+ av_freep(&samplesref);
462+ av_freep(&samples);
463+ return NULL;
464+}
465+
424466 int avfilter_request_frame(AVFilterLink *link)
425467 {
426468 FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1);
libavfilter/avfilter.h+19−2
@@ -26,8 +26,8 @@ · 25 unmodified lines
2626 #include "libavutil/samplefmt.h"
2727
2828 #define LIBAVFILTER_VERSION_MAJOR 2
29−#define LIBAVFILTER_VERSION_MINOR 14
30−#define LIBAVFILTER_VERSION_MICRO 1
29+#define LIBAVFILTER_VERSION_MINOR 15
30+#define LIBAVFILTER_VERSION_MICRO 0
3131
3232 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
3333 LIBAVFILTER_VERSION_MINOR, \
@@ -694,6 +694,23 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, · 660 unmodified lines
694694 enum AVSampleFormat sample_fmt, int nb_samples,
695695 int64_t channel_layout, int planar);
696696
697+/**
698+ * Create an audio buffer reference wrapped around an already
699+ * allocated samples buffer.
700+ *
701+ * @param data pointers to the samples plane buffers
702+ * @param linesize linesize for the samples plane buffers
703+ * @param perms the required access permissions
704+ * @param nb_samples number of samples per channel
705+ * @param sample_fmt the format of each sample in the buffer to allocate
706+ * @param channel_layout the channel layout of the buffer
707+ * @param planar audio data layout - planar or packed
708+ */
709+AVFilterBufferRef *
710+avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
711+ int nb_samples, enum AVSampleFormat sample_fmt,
712+ int64_t channel_layout, int planar);
713+
697714 /**
698715 * Request an input frame from the filter at the other end of the link.
699716 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t