[vlc-devel] [PATCH] smem

Jean-Baptiste Kempf jb at videolan.org
Sat Apr 24 17:31:53 CEST 2010


Ping?

On Tue, Apr 13, 2010 at 10:37:09AM +0200, Sébastien Escudier wrote :
> 
> 
> Hi,
> 
> Two patches attached :
> 1- A simplification
> 2- I need to get compressed video frames so I modified smem stream output to
> allow this.
> 
> Regards,
> 
> Seb.

> From ffbf6654367b7324ed9afa90118fd50fb95c9e37 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?S=C3=A9bastien=20Escudier?= <sebastien-devel at celeos.eu>
> Date: Tue, 13 Apr 2010 09:27:25 +0200
> Subject: [PATCH] smem : move p_data into sout_stream_sys_t.
>  No need to store the same option for each stream id.
> 
> ---
>  modules/stream_out/smem.c |   24 +++++++++---------------
>  1 files changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/modules/stream_out/smem.c b/modules/stream_out/smem.c
> index 9d317ea..414290c 100644
> --- a/modules/stream_out/smem.c
> +++ b/modules/stream_out/smem.c
> @@ -139,7 +139,6 @@ static int SendAudio( sout_stream_t *p_stream, sout_stream_id_t *id,
>  struct sout_stream_id_t
>  {
>      es_format_t* format;
> -    void *p_data;
>  };
>  
>  struct sout_stream_sys_t
> @@ -149,6 +148,7 @@ struct sout_stream_sys_t
>      void ( *pf_audio_prerender_callback ) ( void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size );
>      void ( *pf_video_postrender_callback ) ( void* p_video_data, uint8_t* p_pixel_buffer, int width, int height, int pixel_pitch, int size, mtime_t pts );
>      void ( *pf_audio_postrender_callback ) ( void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, mtime_t pts );
> +    void *p_data;
>      bool time_sync;
>  };
>  
> @@ -187,6 +187,10 @@ static int Open( vlc_object_t *p_this )
>      p_sys->pf_audio_postrender_callback = (void (*) (void*, uint8_t*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, mtime_t))(intptr_t)atoll( psz_tmp );
>      free( psz_tmp );
>  
> +    psz_tmp = var_GetString( p_stream, SOUT_PREFIX_VIDEO "data" );
> +    p_sys->p_data = (void *)( intptr_t )atoll( psz_tmp );
> +    free( psz_tmp );
> +
>      /* Setting stream out module callbacks */
>      p_stream->pf_add    = Add;
>      p_stream->pf_del    = Del;
> @@ -223,7 +227,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
>  
>  static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
>  {
> -    char* psz_tmp;
>      sout_stream_id_t    *id;
>      int i_bits_per_pixel;
>  
> @@ -258,10 +261,6 @@ static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
>      if( !id )
>          return NULL;
>  
> -    psz_tmp = var_GetString( p_stream, SOUT_PREFIX_VIDEO "data" );
> -    id->p_data = (void *)( intptr_t )atoll( psz_tmp );
> -    free( psz_tmp );
> -
>      id->format = p_fmt;
>      id->format->video.i_bits_per_pixel = i_bits_per_pixel;
>      return id;
> @@ -269,7 +268,6 @@ static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
>  
>  static sout_stream_id_t *AddAudio( sout_stream_t *p_stream, es_format_t *p_fmt )
>  {
> -    char* psz_tmp;
>      sout_stream_id_t* id;
>      int i_bits_per_sample;
>  
> @@ -309,10 +307,6 @@ static sout_stream_id_t *AddAudio( sout_stream_t *p_stream, es_format_t *p_fmt )
>      if( !id )
>          return NULL;
>  
> -    psz_tmp = var_GetString( p_stream, SOUT_PREFIX_AUDIO "data" );
> -    id->p_data = (void *)( intptr_t )atoll( psz_tmp );
> -    free( psz_tmp );
> -
>      id->format = p_fmt;
>      id->format->audio.i_bitspersample = i_bits_per_sample;
>      return id;
> @@ -347,12 +341,12 @@ static int SendVideo( sout_stream_t *p_stream, sout_stream_id_t *id,
>      i_line_size = i_pixel_pitch * id->format->video.i_width;
>      i_size = i_line * i_line_size;
>      /* Calling the prerender callback to get user buffer */
> -    p_sys->pf_video_prerender_callback( id->p_data, &p_pixels , i_size );
> +    p_sys->pf_video_prerender_callback( p_sys->p_data, &p_pixels , i_size );
>      /* Copying data into user buffer */
>      for ( int line = 0; line < i_line; line++, p_pixels += i_line_size )
>          vlc_memcpy( p_pixels, p_buffer->p_buffer + i_line_size * line , i_line_size );
>      /* Calling the postrender callback to tell the user his buffer is ready */
> -    p_sys->pf_video_postrender_callback( id->p_data, p_pixels,
> +    p_sys->pf_video_postrender_callback( p_sys->p_data, p_pixels,
>                                           id->format->video.i_width, id->format->video.i_height,
>                                           id->format->video.i_bits_per_pixel, i_size, p_buffer->i_pts );
>      block_ChainRelease( p_buffer );
> @@ -370,11 +364,11 @@ static int SendAudio( sout_stream_t *p_stream, sout_stream_id_t *id,
>      i_size = p_buffer->i_buffer;
>      i_samples = i_size / ( ( id->format->audio.i_bitspersample / 8 ) * id->format->audio.i_channels );
>      /* Calling the prerender callback to get user buffer */
> -    p_sys->pf_audio_prerender_callback( id->p_data, &p_pcm_buffer, i_size );
> +    p_sys->pf_audio_prerender_callback( p_sys->p_data, &p_pcm_buffer, i_size );
>      /* Copying data into user buffer */
>      vlc_memcpy( p_pcm_buffer, p_buffer->p_buffer, i_size );
>      /* Calling the postrender callback to tell the user his buffer is ready */
> -    p_sys->pf_audio_postrender_callback( id->p_data, p_pcm_buffer,
> +    p_sys->pf_audio_postrender_callback( p_sys->p_data, p_pcm_buffer,
>                                           id->format->audio.i_channels, id->format->audio.i_rate, i_samples,
>                                           id->format->audio.i_bitspersample, i_size, p_buffer->i_pts );
>      block_ChainRelease( p_buffer );
> -- 
> 1.5.6.3
> 

> From 5f65453afc2342a0c235d73beeaab56997d718f5 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?S=C3=A9bastien=20Escudier?= <sebastien-devel at celeos.eu>
> Date: Thu, 18 Mar 2010 14:06:07 +0100
> Subject: [PATCH] smem : support non raw video format.
>  In this case we copy compressed data into user buffer.
> 
> ---
>  modules/stream_out/smem.c |   31 +++++++++++++++++++++++--------
>  1 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/modules/stream_out/smem.c b/modules/stream_out/smem.c
> index 414290c..014d7fe 100644
> --- a/modules/stream_out/smem.c
> +++ b/modules/stream_out/smem.c
> @@ -253,8 +253,9 @@ static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
>              i_bits_per_pixel = 8;
>              break;
>          default:
> -            msg_Err( p_stream, "Smem does only support raw video format" );
> -            return NULL;
> +            i_bits_per_pixel = 0;
> +            msg_Dbg( p_stream, "non raw video format detected (%4.4s), buffers will contain compressed video", (char *)&p_fmt->i_codec );
> +            break;
>      }
>  
>      id = calloc( 1, sizeof( sout_stream_id_t ) );
> @@ -336,15 +337,29 @@ static int SendVideo( sout_stream_t *p_stream, sout_stream_id_t *id,
>      int i_line, i_line_size, i_size, i_pixel_pitch;
>      uint8_t* p_pixels;
>  
> -    i_line = id->format->video.i_height;
> -    i_pixel_pitch = id->format->video.i_bits_per_pixel / 8;
> -    i_line_size = i_pixel_pitch * id->format->video.i_width;
> -    i_size = i_line * i_line_size;
> +    if( id->format->video.i_bits_per_pixel > 0 )
> +    {
> +        i_line = id->format->video.i_height;
> +        i_pixel_pitch = id->format->video.i_bits_per_pixel / 8;
> +        i_line_size = i_pixel_pitch * id->format->video.i_width;
> +        i_size = i_line * i_line_size;
> +    }
> +    else
> +    {
> +        i_size = p_buffer->i_buffer;
> +    }
>      /* Calling the prerender callback to get user buffer */
>      p_sys->pf_video_prerender_callback( p_sys->p_data, &p_pixels , i_size );
>      /* Copying data into user buffer */
> -    for ( int line = 0; line < i_line; line++, p_pixels += i_line_size )
> -        vlc_memcpy( p_pixels, p_buffer->p_buffer + i_line_size * line , i_line_size );
> +    if( id->format->video.i_bits_per_pixel > 0 )
> +    {
> +        for ( int line = 0; line < i_line; line++, p_pixels += i_line_size )
> +            vlc_memcpy( p_pixels, p_buffer->p_buffer + i_line_size * line , i_line_size );
> +    }
> +    else
> +    {
> +        vlc_memcpy( p_pixels, p_buffer->p_buffer, i_size );
> +    }
>      /* Calling the postrender callback to tell the user his buffer is ready */
>      p_sys->pf_video_postrender_callback( p_sys->p_data, p_pixels,
>                                           id->format->video.i_width, id->format->video.i_height,
> -- 
> 1.5.6.3
> 

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel


-- 
Best Regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/



More information about the vlc-devel mailing list