[FFmpeg-devel,1/2] avfilter: add ff_inlink_queued_samples()

Submitted by Paul B Mahol on Oct. 2, 2018, 8:08 p.m.

Details

Message ID 20181002200845.24827-1-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Oct. 2, 2018, 8:08 p.m.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/avfilter.c | 6 ++++++
 libavfilter/filters.h  | 7 +++++++
 2 files changed, 13 insertions(+)

Comments

Paul B Mahol Oct. 3, 2018, 10:29 a.m.
On 10/2/18, Paul B Mahol <onemda@gmail.com> wrote:
> On 10/2/18, Paul B Mahol <onemda@gmail.com> wrote:
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavfilter/af_headphone.c | 46 ++++++++------------------------------
>>  1 file changed, 9 insertions(+), 37 deletions(-)
>>
>
> Unfortunately this asserts for unexplained reason.
>
> Is there way with filters with multiple inputs to not hang when not
> consuming
> all frames from some inputs?
>


Found it!

Patch hide | download patch | download mbox

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 85eff0aa1d..2dcaabf545 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -19,6 +19,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define ASSERT_LEVEL 5
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/buffer.h"
@@ -1453,6 +1454,11 @@  int ff_inlink_check_available_frame(AVFilterLink *link)
     return ff_framequeue_queued_frames(&link->fifo) > 0;
 }
 
+int ff_inlink_queued_samples(AVFilterLink *link)
+{
+    return ff_framequeue_queued_samples(&link->fifo);
+}
+
 int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
 {
     uint64_t samples = ff_framequeue_queued_samples(&link->fifo);
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 4e2652ebe5..06a0f5896b 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -66,6 +66,13 @@  int ff_inlink_evaluate_timeline_at_frame(AVFilterLink *link, const AVFrame *fram
  */
 int ff_inlink_check_available_frame(AVFilterLink *link);
 
+
+/***
+  * Get the number of samples available on the link.
+  * @retrun the numer of samples available on the link.
+  */
+int ff_inlink_queued_samples(AVFilterLink *link);
+
 /**
  * Test if enough samples are available on the link.
  * @return  >0 if enough samples are available