History

lavfi: switch to _alt functions

Michael Niedermayer committed 14 years ago

Commit 47aae2b1 parent f8196754 files · +7 −101Browse files

Unified · Split

4 files
  1. libavfilter/audio.c +2 −76
  2. libavfilter/avcodec.c +2 −3
  3. libavfilter/avfilter.h +1 −20
  4. libavfilter/src_buffer.c +2 −2
libavfilter/audio.c+2−76
@@ -33,38 +33,6 @@ AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms, · 32 unmodified lines
3333 }
3434
3535 AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms,
36− int nb_samples)
37−{
38− AVFilterBufferRef *samplesref = NULL;
39− int linesize[8] = {0};
40− uint8_t *data[8] = {0};
41− int ch, nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
42−
43− /* right now we don't support more than 8 channels */
44− av_assert0(nb_channels <= 8);
45−
46− /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
47− if (av_samples_alloc(data, linesize,
48− nb_channels, nb_samples,
49− av_get_alt_sample_fmt(link->format, link->planar),
50− 16) < 0)
51− return NULL;
52−
53− for (ch = 1; link->planar && ch < nb_channels; ch++)
54− linesize[ch] = linesize[0];
55− samplesref =
56− avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
57− nb_samples, link->format,
58− link->channel_layout, link->planar);
59− if (!samplesref) {
60− av_free(data[0]);
61− return NULL;
62− }
63−
64− return samplesref;
65−}
66−
67−static AVFilterBufferRef *ff_default_get_audio_buffer_alt(AVFilterLink *link, int perms,
6836 int nb_samples)
6937 {
7038 AVFilterBufferRef *samplesref = NULL;
@@ -80,7 +48,7 @@ static AVFilterBufferRef *ff_default_get_audio_buffer_alt(AVFilterLink *link, in · 9 unmodified lines
8048 if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0)
8149 goto fail;
8250
83− samplesref = avfilter_get_audio_buffer_ref_from_arrays_alt(data, linesize, perms,
51+ samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
8452 nb_samples, link->format,
8553 link->channel_layout);
8654 if (!samplesref)
@@ -112,49 +80,7 @@ AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms, · 25 unmodified lines
11280 return ret;
11381 }
11482
115−AVFilterBufferRef *
116−avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
117− int nb_samples, enum AVSampleFormat sample_fmt,
118− uint64_t channel_layout, int planar)
119−{
120− AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
121− AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef));
122−
123− if (!samples || !samplesref)
124− goto fail;
125−
126− samplesref->buf = samples;
127− samplesref->buf->free = ff_avfilter_default_free_buffer;
128− if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps))))
129− goto fail;
130−
131− samplesref->audio->nb_samples = nb_samples;
132− samplesref->audio->channel_layout = channel_layout;
133− samplesref->audio->planar = planar;
134−
135− /* make sure the buffer gets read permission or it's useless for output */
136− samplesref->perms = perms | AV_PERM_READ;
137−
138− samples->refcount = 1;
139− samplesref->type = AVMEDIA_TYPE_AUDIO;
140− samplesref->format = sample_fmt;
141−
142− memcpy(samples->data, data, sizeof(samples->data));
143− memcpy(samples->linesize, linesize, sizeof(samples->linesize));
144− memcpy(samplesref->data, data, sizeof(samplesref->data));
145− memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize));
146−
147− return samplesref;
148−
149−fail:
150− if (samplesref && samplesref->audio)
151− av_freep(&samplesref->audio);
152− av_freep(&samplesref);
153− av_freep(&samples);
154− return NULL;
155−}
156−
157−AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data,
83+AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
15884 int linesize,int perms,
15985 int nb_samples,
16086 enum AVSampleFormat sample_fmt,
libavfilter/avcodec.c+2−3
@@ -112,10 +112,9 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame · 111 unmodified lines
112112 int perms)
113113 {
114114 AVFilterBufferRef *picref =
115− avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, (int *)frame->linesize, perms,
115+ avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms,
116116 frame->nb_samples, frame->format,
117− av_frame_get_channel_layout(frame),
118− av_sample_fmt_is_planar(frame->format));
117+ av_frame_get_channel_layout(frame));
119118 if (!picref)
120119 return NULL;
121120 avfilter_copy_frame_props(picref, frame);
libavfilter/avfilter.h+1−20
@@ -790,27 +790,8 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int lin · 789 unmodified lines
790790 * @param nb_samples number of samples per channel
791791 * @param sample_fmt the format of each sample in the buffer to allocate
792792 * @param channel_layout the channel layout of the buffer
793− * @param planar audio data layout - planar or packed
794793 */
795−AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8],
796− int linesize[8],
797− int perms,
798− int nb_samples,
799− enum AVSampleFormat sample_fmt,
800− uint64_t channel_layout,
801− int planar);
802−/**
803− * Create an audio buffer reference wrapped around an already
804− * allocated samples buffer.
805− *
806− * @param data pointers to the samples plane buffers
807− * @param linesize linesize for the samples plane buffers
808− * @param perms the required access permissions
809− * @param nb_samples number of samples per channel
810− * @param sample_fmt the format of each sample in the buffer to allocate
811− * @param channel_layout the channel layout of the buffer
812− */
813−AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data,
794+AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
814795 int linesize,
815796 int perms,
816797 int nb_samples,
libavfilter/src_buffer.c+2−2
@@ -597,9 +597,9 @@ int av_asrc_buffer_add_samples(AVFilterContext *ctx, · 596 unmodified lines
597597 AVFilterBufferRef *samplesref;
598598
599599 samplesref = avfilter_get_audio_buffer_ref_from_arrays(
600− data, linesize, AV_PERM_WRITE,
600+ data, linesize[0], AV_PERM_WRITE,
601601 nb_samples,
602− sample_fmt, channel_layout, planar);
602+ sample_fmt, channel_layout);
603603 if (!samplesref)
604604 return AVERROR(ENOMEM);
605605

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