[vlc-devel] [PATCH 07/17] Visualization: Audio frames are now vlc_frame_t
Denis Charmet
typx at dinauz.org
Mon Apr 22 19:10:36 CEST 2019
---
modules/visualization/glspectrum.c | 38 +++++++--------
modules/visualization/goom.c | 64 +++++++++++++-------------
modules/visualization/projectm.cpp | 4 +-
modules/visualization/visual/effects.c | 12 ++---
modules/visualization/visual/visual.c | 22 ++++-----
modules/visualization/visual/visual.h | 2 +-
modules/visualization/vsxu.cpp | 4 +-
7 files changed, 73 insertions(+), 73 deletions(-)
diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index 84fad8f036..192835b0c3 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -82,7 +82,7 @@ typedef struct
/* Audio data */
unsigned i_channels;
- block_fifo_t *fifo;
+ vlc_frame_fifo_t *fifo;
unsigned i_prev_nb_samples;
int16_t *p_prev_s16_buff;
@@ -97,7 +97,7 @@ typedef struct
} filter_sys_t;
-static block_t *DoWork(filter_t *, block_t *);
+static vlc_frame_t *DoWork(filter_t *, vlc_frame_t *);
static void *Thread(void *);
#define SPECTRUM_WIDTH 4.f
@@ -135,7 +135,7 @@ static int Open(vlc_object_t * p_this)
window_get_param( VLC_OBJECT( p_filter ), &p_sys->wind_param );
/* Create the FIFO for the audio data. */
- p_sys->fifo = block_FifoNew();
+ p_sys->fifo = vlc_frame_FifoNew();
if (p_sys->fifo == NULL)
goto error;
@@ -148,7 +148,7 @@ static int Open(vlc_object_t * p_this)
p_sys->gl = vlc_gl_surface_Create(p_this, &cfg, NULL);
if (p_sys->gl == NULL)
{
- block_FifoRelease(p_sys->fifo);
+ vlc_frame_FifoRelease(p_sys->fifo);
goto error;
}
@@ -184,7 +184,7 @@ static void Close(vlc_object_t *p_this)
/* Free the ressources */
vlc_gl_surface_Destroy(p_sys->gl);
- block_FifoRelease(p_sys->fifo);
+ vlc_frame_FifoRelease(p_sys->fifo);
free(p_sys->p_prev_s16_buff);
free(p_sys);
}
@@ -195,12 +195,12 @@ static void Close(vlc_object_t *p_this)
* @param p_filter: filter object
* @param p_in_buf: input buffer
*/
-static block_t *DoWork(filter_t *p_filter, block_t *p_in_buf)
+static vlc_frame_t *DoWork(filter_t *p_filter, vlc_frame_t *p_in_buf)
{
- block_t *block = block_Duplicate(p_in_buf);
+ vlc_frame_t *frame = vlc_frame_Duplicate(p_in_buf);
filter_sys_t *p_sys = p_filter->p_sys;
- if (likely(block != NULL))
- block_FifoPut(p_sys->fifo, block);
+ if (likely(frame != NULL))
+ vlc_frame_FifoPut(p_sys->fifo, frame);
return p_in_buf;
}
@@ -362,7 +362,7 @@ static void *Thread( void *p_data )
while (1)
{
- block_t *block = block_FifoGet(p_sys->fifo);
+ vlc_frame_t *frame = vlc_frame_FifoGet(p_sys->fifo);
int canc = vlc_savecancel();
unsigned win_width, win_height;
@@ -383,32 +383,32 @@ static void *Thread( void *p_data )
int16_t p_buffer1[FFT_BUFFER_SIZE]; /* Buffer on which we perform
the FFT (first channel) */
int16_t p_dest[FFT_BUFFER_SIZE]; /* Adapted FFT result */
- float *p_buffl = (float*)block->p_buffer; /* Original buffer */
+ float *p_buffl = (float*)frame->p_buffer; /* Original buffer */
int16_t *p_buffs; /* int16_t converted buffer */
int16_t *p_s16_buff; /* int16_t converted buffer */
- if (!block->i_nb_samples) {
+ if (!frame->i_nb_samples) {
msg_Err(p_filter, "no samples yet");
goto release;
}
/* Allocate the buffer only if the number of samples change */
- if (block->i_nb_samples != p_sys->i_prev_nb_samples)
+ if (frame->i_nb_samples != p_sys->i_prev_nb_samples)
{
free(p_sys->p_prev_s16_buff);
- p_sys->p_prev_s16_buff = malloc(block->i_nb_samples *
+ p_sys->p_prev_s16_buff = malloc(frame->i_nb_samples *
p_sys->i_channels *
sizeof(int16_t));
if (!p_sys->p_prev_s16_buff)
goto release;
- p_sys->i_prev_nb_samples = block->i_nb_samples;
+ p_sys->i_prev_nb_samples = frame->i_nb_samples;
}
p_buffs = p_s16_buff = p_sys->p_prev_s16_buff;
/* Convert the buffer to int16_t
Pasted from float32tos16.c */
- for (i = block->i_nb_samples * p_sys->i_channels; i--;)
+ for (i = frame->i_nb_samples * p_sys->i_channels; i--;)
{
union {float f; int32_t i;} u;
@@ -440,7 +440,7 @@ static void *Thread( void *p_data )
p_buffer1[i] = *p_buffs;
p_buffs += p_sys->i_channels;
- if (p_buffs >= &p_s16_buff[block->i_nb_samples * p_sys->i_channels])
+ if (p_buffs >= &p_s16_buff[frame->i_nb_samples * p_sys->i_channels])
p_buffs = p_s16_buff;
}
window_scale_in_place (p_buffer1, &wind_ctx);
@@ -487,14 +487,14 @@ static void *Thread( void *p_data )
glPopMatrix();
/* Wait to swapp the frame on time. */
- vlc_tick_wait(block->i_pts + (block->i_length / 2));
+ vlc_tick_wait(frame->i_pts + (frame->i_length / 2));
vlc_gl_Swap(gl);
release:
window_close(&wind_ctx);
fft_close(p_state);
vlc_gl_ReleaseCurrent(gl);
- block_Release(block);
+ vlc_frame_Release(frame);
vlc_restorecancel(canc);
}
diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c
index 3fa6203e1c..f9850bd1de 100644
--- a/modules/visualization/goom.c
+++ b/modules/visualization/goom.c
@@ -73,7 +73,7 @@ vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-#define MAX_BLOCKS 100
+#define MAX_FRAMES 100
#define GOOM_DELAY VLC_TICK_FROM_MS(400)
typedef struct
@@ -92,14 +92,14 @@ typedef struct
unsigned i_channels;
/* Audio samples queue */
- block_t *pp_blocks[MAX_BLOCKS];
- int i_blocks;
+ vlc_frame_t *pp_frames[MAX_FRAMES];
+ int i_frames;
date_t date;
} goom_thread_t;
-static block_t *DoWork ( filter_t *, block_t * );
+static vlc_frame_t *DoWork ( filter_t *, vlc_frame_t * );
static void Flush( filter_t * );
static void *Thread( void * );
@@ -138,7 +138,7 @@ static int Open( vlc_object_t *p_this )
vlc_mutex_init( &p_thread->lock );
vlc_cond_init( &p_thread->wait );
- p_thread->i_blocks = 0;
+ p_thread->i_frames = 0;
date_Init( &p_thread->date, p_filter->fmt_in.audio.i_rate, 1 );
date_Set( &p_thread->date, VLC_TICK_0 );
p_thread->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
@@ -166,29 +166,29 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************
* This function queues the audio buffer to be processed by the goom thread
*****************************************************************************/
-static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
+static vlc_frame_t *DoWork( filter_t *p_filter, vlc_frame_t *p_in_buf )
{
goom_thread_t *p_thread = p_filter->p_sys;
- block_t *p_block;
+ vlc_frame_t *p_frame;
/* Queue sample */
vlc_mutex_lock( &p_thread->lock );
- if( p_thread->i_blocks == MAX_BLOCKS )
+ if( p_thread->i_frames == MAX_FRAMES )
{
vlc_mutex_unlock( &p_thread->lock );
return p_in_buf;
}
- p_block = block_Alloc( p_in_buf->i_buffer );
- if( !p_block )
+ p_frame = vlc_frame_Alloc( p_in_buf->i_buffer );
+ if( !p_frame )
{
vlc_mutex_unlock( &p_thread->lock );
return p_in_buf;
}
- memcpy( p_block->p_buffer, p_in_buf->p_buffer, p_in_buf->i_buffer );
- p_block->i_pts = p_in_buf->i_pts;
+ memcpy( p_frame->p_buffer, p_in_buf->p_buffer, p_in_buf->i_buffer );
+ p_frame->i_pts = p_in_buf->i_pts;
- p_thread->pp_blocks[p_thread->i_blocks++] = p_block;
+ p_thread->pp_frames[p_thread->i_frames++] = p_frame;
vlc_cond_signal( &p_thread->wait );
vlc_mutex_unlock( &p_thread->lock );
@@ -223,47 +223,47 @@ static int FillBuffer( int16_t *p_data, int *pi_data,
goom_thread_t *p_this )
{
int i_samples = 0;
- block_t *p_block;
+ vlc_frame_t *p_frame;
while( *pi_data < 512 )
{
- if( !p_this->i_blocks ) return VLC_EGENERIC;
+ if( !p_this->i_frames ) return VLC_EGENERIC;
- p_block = p_this->pp_blocks[0];
+ p_frame = p_this->pp_frames[0];
i_samples = __MIN( (unsigned)(512 - *pi_data),
- p_block->i_buffer / sizeof(float) / p_this->i_channels );
+ p_frame->i_buffer / sizeof(float) / p_this->i_channels );
/* Date management */
- if( p_block->i_pts != VLC_TICK_INVALID &&
- p_block->i_pts != date_Get( pi_date_end ) )
+ if( p_frame->i_pts != VLC_TICK_INVALID &&
+ p_frame->i_pts != date_Get( pi_date_end ) )
{
- date_Set( pi_date_end, p_block->i_pts );
+ date_Set( pi_date_end, p_frame->i_pts );
}
- p_block->i_pts = VLC_TICK_INVALID;
+ p_frame->i_pts = VLC_TICK_INVALID;
date_Increment( pi_date_end, i_samples );
while( i_samples > 0 )
{
- float *p_float = (float *)p_block->p_buffer;
+ float *p_float = (float *)p_frame->p_buffer;
p_data[*pi_data] = FloatToInt16( p_float[0] );
if( p_this->i_channels > 1 )
p_data[512 + *pi_data] = FloatToInt16( p_float[1] );
(*pi_data)++;
- p_block->p_buffer += (sizeof(float) * p_this->i_channels);
- p_block->i_buffer -= (sizeof(float) * p_this->i_channels);
+ p_frame->p_buffer += (sizeof(float) * p_this->i_channels);
+ p_frame->i_buffer -= (sizeof(float) * p_this->i_channels);
i_samples--;
}
- if( !p_block->i_buffer )
+ if( !p_frame->i_buffer )
{
- block_Release( p_block );
- p_this->i_blocks--;
- if( p_this->i_blocks )
- memmove( p_this->pp_blocks, p_this->pp_blocks + 1,
- p_this->i_blocks * sizeof(block_t *) );
+ vlc_frame_Release( p_frame );
+ p_this->i_frames--;
+ if( p_this->i_frames )
+ memmove( p_this->pp_frames, p_this->pp_frames + 1,
+ p_this->i_frames * sizeof(vlc_frame_t *) );
}
}
@@ -356,9 +356,9 @@ static void Close( vlc_object_t *p_this )
vlc_mutex_destroy( &p_thread->lock );
vlc_cond_destroy( &p_thread->wait );
- while( p_thread->i_blocks-- )
+ while( p_thread->i_frames-- )
{
- block_Release( p_thread->pp_blocks[p_thread->i_blocks] );
+ vlc_frame_Release( p_thread->pp_frames[p_thread->i_frames] );
}
free( p_thread );
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index 219dfdac4e..d0092df2bc 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -154,7 +154,7 @@ struct filter_sys_t
} // namespace
-static block_t *DoWork( filter_t *, block_t * );
+static vlc_frame_t *DoWork( filter_t *, vlc_frame_t * );
static void *Thread( void * );
/**
@@ -243,7 +243,7 @@ static void Close( vlc_object_t *p_this )
* @param p_in_buf: input buffer
* @param p_out_buf: output buffer
*/
-static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
+static vlc_frame_t *DoWork( filter_t *p_filter, vlc_frame_t *p_in_buf )
{
filter_sys_t *p_sys = reinterpret_cast<filter_sys_t *>( p_filter->p_sys );
diff --git a/modules/visualization/visual/effects.c b/modules/visualization/visual/effects.c
index 06b9d0136e..da464b56af 100644
--- a/modules/visualization/visual/effects.c
+++ b/modules/visualization/visual/effects.c
@@ -30,7 +30,7 @@
#include <vlc_common.h>
#include <vlc_picture.h>
-#include <vlc_block.h>
+#include <vlc_frame.h>
#include "visual.h"
#include <math.h>
@@ -49,7 +49,7 @@
* dummy_Run
*****************************************************************************/
static int dummy_Run( visual_effect_t * p_effect, vlc_object_t *p_aout,
- const block_t * p_buffer , picture_t * p_picture)
+ const vlc_frame_t * p_buffer , picture_t * p_picture)
{
VLC_UNUSED(p_effect); VLC_UNUSED(p_aout); VLC_UNUSED(p_buffer);
VLC_UNUSED(p_picture);
@@ -77,7 +77,7 @@ typedef struct spectrum_data
} spectrum_data;
static int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
- const block_t * p_buffer , picture_t * p_picture)
+ const vlc_frame_t * p_buffer , picture_t * p_picture)
{
spectrum_data *p_data = p_effect->p_data;
float p_output[FFT_BUFFER_SIZE]; /* Raw FFT Result */
@@ -395,7 +395,7 @@ typedef struct
} spectrometer_data;
static int spectrometer_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
- const block_t * p_buffer , picture_t * p_picture)
+ const vlc_frame_t * p_buffer , picture_t * p_picture)
{
#define Y(R,G,B) ((uint8_t)( (R * .299) + (G * .587) + (B * .114) ))
#define U(R,G,B) ((uint8_t)( (R * -.169) + (G * -.332) + (B * .500) + 128 ))
@@ -881,7 +881,7 @@ static void spectrometer_Free( void *data )
* scope_Run: scope effect
*****************************************************************************/
static int scope_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
- const block_t * p_buffer , picture_t * p_picture)
+ const vlc_frame_t * p_buffer , picture_t * p_picture)
{
VLC_UNUSED(p_aout);
@@ -938,7 +938,7 @@ static int scope_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
* vuMeter_Run: vu meter effect
*****************************************************************************/
static int vuMeter_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
- const block_t * p_buffer , picture_t * p_picture)
+ const vlc_frame_t * p_buffer , picture_t * p_picture)
{
VLC_UNUSED(p_aout);
float i_value_l = 0;
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 1378129819..c75a77c7a8 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -173,13 +173,13 @@ vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static block_t *DoWork( filter_t *, block_t * );
+static vlc_frame_t *DoWork( filter_t *, vlc_frame_t * );
static void Flush( filter_t * );
static void *Thread( void *);
typedef struct
{
- block_fifo_t *fifo;
+ vlc_frame_fifo_t *fifo;
vout_thread_t *p_vout;
visual_effect_t **effect;
int i_effect;
@@ -309,7 +309,7 @@ static int Open( vlc_object_t *p_this )
goto error;
}
- p_sys->fifo = block_FifoNew();
+ p_sys->fifo = vlc_frame_FifoNew();
if( unlikely( p_sys->fifo == NULL ) )
{
vout_Close( p_sys->p_vout );
@@ -319,7 +319,7 @@ static int Open( vlc_object_t *p_this )
if( vlc_clone( &p_sys->thread, Thread, p_filter,
VLC_THREAD_PRIORITY_VIDEO ) )
{
- block_FifoRelease( p_sys->fifo );
+ vlc_frame_FifoRelease( p_sys->fifo );
vout_Close( p_sys->p_vout );
goto error;
}
@@ -338,7 +338,7 @@ error:
return VLC_EGENERIC;
}
-static block_t *DoRealWork( filter_t *p_filter, block_t *p_in_buf )
+static vlc_frame_t *DoRealWork( filter_t *p_filter, vlc_frame_t *p_in_buf )
{
filter_sys_t *p_sys = p_filter->p_sys;
@@ -380,21 +380,21 @@ static void *Thread( void *data )
for (;;)
{
- block_t *block = block_FifoGet( sys->fifo );
+ vlc_frame_t *block = vlc_frame_FifoGet( sys->fifo );
int canc = vlc_savecancel( );
- block_Release( DoRealWork( p_filter, block ) );
+ vlc_frame_Release( DoRealWork( p_filter, block ) );
vlc_restorecancel( canc );
}
vlc_assert_unreachable();
}
-static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
+static vlc_frame_t *DoWork( filter_t *p_filter, vlc_frame_t *p_in_buf )
{
- block_t *block = block_Duplicate( p_in_buf );
+ vlc_frame_t *block = vlc_frame_Duplicate( p_in_buf );
filter_sys_t *p_sys = p_filter->p_sys;
if( likely(block != NULL) )
- block_FifoPut( p_sys->fifo, block );
+ vlc_frame_FifoPut( p_sys->fifo, block );
return p_in_buf;
}
@@ -414,7 +414,7 @@ static void Close( vlc_object_t *p_this )
vlc_cancel( p_sys->thread );
vlc_join( p_sys->thread, NULL );
- block_FifoRelease( p_sys->fifo );
+ vlc_frame_FifoRelease( p_sys->fifo );
vout_Close( p_sys->p_vout );
/* Free the list */
diff --git a/modules/visualization/visual/visual.h b/modules/visualization/visual/visual.h
index 2df24b6523..3191defe55 100644
--- a/modules/visualization/visual/visual.h
+++ b/modules/visualization/visual/visual.h
@@ -22,7 +22,7 @@
typedef struct visual_effect_t visual_effect_t;
typedef int (*visual_run_t)(visual_effect_t *, vlc_object_t *,
- const block_t *, picture_t *);
+ const vlc_frame_t *, picture_t *);
typedef void (*visual_free_t)(void *);
struct visual_effect_t
diff --git a/modules/visualization/vsxu.cpp b/modules/visualization/vsxu.cpp
index 30239177d9..6e033a542a 100644
--- a/modules/visualization/vsxu.cpp
+++ b/modules/visualization/vsxu.cpp
@@ -94,7 +94,7 @@ struct filter_sys_t
} // namespace
-static block_t *DoWork( filter_t *, block_t * );
+static vlc_frame_t *DoWork( filter_t *, vlc_frame_t * );
static void *Thread( void * );
/**
@@ -180,7 +180,7 @@ static void Close( vlc_object_t *p_this )
* @param p_filter: filter object
* @param p_in_buf: input buffer
*/
-static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
+static vlc_frame_t *DoWork( filter_t *p_filter, vlc_frame_t *p_in_buf )
{
filter_sys_t *p_sys = p_filter->p_sys;
--
2.20.1
More information about the vlc-devel
mailing list