[FFmpeg-soc] [soc]: r4716 - in afilters: Makefile.dummy avfilter.c avfilter.h defaults.c dummy.c
kdub
subversion at mplayerhq.hu
Wed Jul 15 18:10:17 CEST 2009
Author: kdub
Date: Wed Jul 15 18:10:17 2009
New Revision: 4716
Log:
Modifications to the avfilter.h to handle PCM format conversions
Modified:
afilters/Makefile.dummy
afilters/avfilter.c
afilters/avfilter.h
afilters/defaults.c
afilters/dummy.c
Modified: afilters/Makefile.dummy
==============================================================================
--- afilters/Makefile.dummy Tue Jul 14 10:22:53 2009 (r4715)
+++ afilters/Makefile.dummy Wed Jul 15 18:10:17 2009 (r4716)
@@ -1,2 +1,2 @@
all:
- gcc dummy.c -o dummy -I./ffmpeg -lm ./ffmpeg/libavfilter/libavfilter.a ffmpeg/libavcodec/libavcodec.a ffmpeg/libavformat/libavformat.a ffmpeg/libavutil/libavutil.a
+ gcc dummy.c -o dummy -I./ffmpeg -I./ffmpeg/libavcodec -lm ./ffmpeg/libavfilter/libavfilter.a ffmpeg/libavcodec/libavcodec.a ffmpeg/libavformat/libavformat.a ffmpeg/libavutil/libavutil.a
Modified: afilters/avfilter.c
==============================================================================
--- afilters/avfilter.c Tue Jul 14 10:22:53 2009 (r4715)
+++ afilters/avfilter.c Wed Jul 15 18:10:17 2009 (r4716)
@@ -20,6 +20,7 @@
*/
#include "libavcodec/imgconvert.h"
+#include "libavcodec/audioconvert.h"
#include "avfilter.h"
unsigned avfilter_version(void) {
@@ -95,7 +96,15 @@ int avfilter_link(AVFilterContext *src,
link->dstpad = dstpad;
- link->format = PIX_FMT_NONE;
+ link->v_format = PIX_FMT_NONE;
+
+ /* detect if input/output are the same pcm format*/
+ if (1)
+ {
+ link->av_conv = NULL;
+ } else {
+// link->conv = av_audio_convert_alloc(out, 1, in, 1, matrcx, 0);
+ }
/* FIXME shouldnt do static buffer alloc like this really, should be
variable */
@@ -253,6 +262,10 @@ void avfilter_filter_buffer(AVFilterLink
int input_func = 1, output_func = 1;
+ /* convert, if necessary */
+// if (link->av_conv)
+// av_audio_convert();
+
if (!(filter_output_buffer = dst->filter_buffer))
{
av_log(0,0,"LINK HAS NO OUTPUT?\n", 0);
@@ -304,7 +317,7 @@ void avfilter_draw_slice(AVFilterLink *l
/* copy the slice if needed for permission reasons */
if(link->srcpic) {
- avcodec_get_chroma_sub_sample(link->format, &hsub, &vsub);
+ avcodec_get_chroma_sub_sample(link->v_format, &hsub, &vsub);
for(i = 0; i < 4; i ++) {
if(link->srcpic->data[i]) {
@@ -318,7 +331,7 @@ void avfilter_draw_slice(AVFilterLink *l
for(i = 0; i < 4; i ++) {
int planew =
- ff_get_plane_bytewidth(link->format, link->cur_pic->w, i);
+ ff_get_plane_bytewidth(link->v_format, link->cur_pic->w, i);
if(!src[i]) continue;
Modified: afilters/avfilter.h
==============================================================================
--- afilters/avfilter.h Tue Jul 14 10:22:53 2009 (r4715)
+++ afilters/avfilter.h Wed Jul 15 18:10:17 2009 (r4716)
@@ -36,6 +36,7 @@
#include <stddef.h>
#include "libavcodec/avcodec.h"
+#include "libavcodec/audioconvert.h"
/**
* Returns the LIBAVFILTER_VERSION_INT constant.
@@ -128,11 +129,6 @@ typedef struct AVFilterBufferRef
}AVFilterBufferRef;
-
-
-
-
-
/**
* Adds a new reference to a picture.
* @param ref an existing reference to the picture
@@ -378,7 +374,6 @@ struct AVFilterPad
*/
int (*config_props)(AVFilterLink *link);
-
/**
* Process an audio buffer. Filters can hook into this function to do the
* actual audio processing
@@ -492,7 +487,8 @@ struct AVFilterLink
int w; ///< agreed upon image width
int h; ///< agreed upon image height
- enum PixelFormat format; ///< agreed upon image colorspace
+ enum PixelFormat v_format; ///< agreed upon image colorspace [for video]
+ enum SampleFormat a_format; ///< agreed upon sample format [for audio]
/**
* Lists of formats supported by the input and output filters respectively.
@@ -515,7 +511,10 @@ struct AVFilterLink
/** the audio buffer reference is sent accross the link by the source. */
AVFilterBufferRef *srcbuf;
+
int link_size; /* size of data sent accross link each time */
+ AVAudioConvert *av_conv; /*context for translating accross links */
+
AVFilterBufferRef *cur_buf;
AVFilterBufferRef *outbuf;
};
Modified: afilters/defaults.c
==============================================================================
--- afilters/defaults.c Tue Jul 14 10:22:53 2009 (r4715)
+++ afilters/defaults.c Wed Jul 15 18:10:17 2009 (r4716)
@@ -47,7 +47,7 @@ AVFilterPicRef *avfilter_default_get_vid
ref->perms = perms | AV_PERM_READ;
pic->refcount = 1;
- pic->format = link->format;
+ pic->format = link->v_format;
pic->free = avfilter_default_free_video_buffer;
ff_fill_linesize((AVPicture *)pic, pic->format, ref->w);
Modified: afilters/dummy.c
==============================================================================
--- afilters/dummy.c Tue Jul 14 10:22:53 2009 (r4715)
+++ afilters/dummy.c Wed Jul 15 18:10:17 2009 (r4716)
@@ -9,7 +9,7 @@
#include "af_null.c"
#include "af_vol.c"
-#if 1
+#if 0
int dump_avfiltlink(AVFilterLink *link)
{
if (!link)
@@ -84,13 +84,15 @@ int main()
tbuf[i] = i;
#endif
} // sine wave, period 1024/100, range, 100 -> -100
+
AVFilterBuffer samples;
+ AVFilterBufferRef sample_buf;
samples.n_samples = n_samples;
samples.data = tbuf;
samples.data_size = sizeof(int16_t);
- AVFilterBufferRef sample_buf;
- sample_buf.buffer = &samples;
+
sample_buf.sample_type = 10;
+ sample_buf.buffer = &samples;
sample_buf.sample_rate = 128000;
/* set up source filter */
@@ -129,9 +131,9 @@ int main()
avfilter_config_links(avfiltcont2);
- dump_avfiltcont(src_context);
+ /*dump_avfiltcont(src_context);
dump_avfiltcont(avfiltcont);
- dump_avfiltcont(avfiltcont2);
+ dump_avfiltcont(avfiltcont2);*/
/* load some samples in the source filter */
av_asrc_buffer_add_samples(src_context, &sample_buf);
More information about the FFmpeg-soc
mailing list