[Mplayer-cvslog] CVS: main/libaf af.c,1.5,1.6 af.h,1.4,1.5
Anders Johansson
anders at mplayerhq.hu
Sat Oct 5 13:02:51 CEST 2002
- Previous message: [Mplayer-cvslog] CVS: main/DOCS/Chinese bugreports.html,NONE,1.1 cd-dvd.html,NONE,1.1 codecs.html,NONE,1.1 default.css,NONE,1.1 documentation.html,NONE,1.1 encoding.html,NONE,1.1 faq.html,NONE,1.1 formats.html,NONE,1.1 skin-zh.html,NONE,1.1 sound.html,NONE,1.1 users_against_developers.html,NONE,1.1 video.html,NONE,1.1
- Next message: [Mplayer-cvslog] CVS: main/libaf af.c,1.6,1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main/libaf
In directory mail:/var/tmp.root/cvs-serv10145
Modified Files:
af.c af.h
Log Message:
Adding function for estimating required buffer length
Index: af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- af.c 3 Oct 2002 12:43:39 -0000 1.5
+++ af.c 5 Oct 2002 11:02:39 -0000 1.6
@@ -408,6 +408,54 @@
return t * (((len/t) * mul.d - 1)/mul.n);
}
+/* Calculate how long the input IN to the filters should be to produce
+ a certain output length OUT but with the following three constraints:
+ 1. IN <= max_insize, where max_insize is the maximum possible input
+ block length
+ 2. OUT <= max_outsize, where max_outsize is the maximum possible
+ output block length
+ 3. If possible OUT >= len.
+ Return -1 in case of error */
+int af_calc_insize_constrained(af_stream_t* s, int len,
+ int max_outsize,int max_insize)
+{
+ int t = s->input.bps*s->input.nch;
+ int in = 0;
+ int out = 0;
+ af_instance_t* af=s->first;
+ register frac_t mul = {1,1};
+ // Iterate through all filters and calculate total multiplication factor
+ do{
+ mul.n *= af->mul.n;
+ mul.d *= af->mul.d;
+ af=af->next;
+ }while(af);
+ in = t * (((len/t) * mul.d)/mul.n);
+
+ // Try to meet constraint nr 3.
+ out = t * (((in/t)*mul.n + 1)/mul.d);
+ while(in <= max_insize && out <= max_outsize){
+ printf("debug in = %i out = %i \n",in,out);
+
+ if(out > len)
+ return in;
+ out = t * (((in/t)*mul.n + 1)/mul.d);
+ in+=t;
+ }
+
+ // Could no meet constraint nr 3.
+ while((out > max_outsize || in > max_insize) && in > 1)
+ {
+ in-=t;
+ out = t * (((in/t)*mul.n + 1)/mul.d);
+ }
+ if(in > 1)
+ return in;
+
+ // Input parameters are probably incorrect
+ return -1;
+}
+
/* Helper function called by the macro with the same name this
function should not be called directly */
inline int af_resize_local_buffer(af_instance_t* af, af_data_t* data)
Index: af.h
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- af.h 3 Oct 2002 12:44:58 -0000 1.4
+++ af.h 5 Oct 2002 11:02:39 -0000 1.5
@@ -146,7 +146,16 @@
the input length required to produce the output length "len". The
calculated length is <= the actual length */
int af_inputlen(af_stream_t* s, int len);
-
+/* Calculate how long the input IN to the filters should be to produce
+ a certain output length OUT but with the following three constraints:
+ 1. IN <= max_insize, where max_insize is the maximum possible input
+ block length
+ 2. OUT <= max_outsize, where max_outsize is the maximum possible
+ output block length
+ 3. If possible OUT >= len.
+ Return -1 in case of error */
+int af_calc_insize_constrained(af_stream_t* s, int len,
+ int max_outsize,int max_insize);
// Helper functions and macros used inside the audio filters
- Previous message: [Mplayer-cvslog] CVS: main/DOCS/Chinese bugreports.html,NONE,1.1 cd-dvd.html,NONE,1.1 codecs.html,NONE,1.1 default.css,NONE,1.1 documentation.html,NONE,1.1 encoding.html,NONE,1.1 faq.html,NONE,1.1 formats.html,NONE,1.1 skin-zh.html,NONE,1.1 sound.html,NONE,1.1 users_against_developers.html,NONE,1.1 video.html,NONE,1.1
- Next message: [Mplayer-cvslog] CVS: main/libaf af.c,1.6,1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list