sout: provide the structure size to allocate for the encoder
authorSteve Lhomme <robux4@ycbcr.xyz>
Fri, 20 Dec 2019 13:57:06 +0000 (14:57 +0100)
committerSteve Lhomme <robux4@ycbcr.xyz>
Wed, 8 Jan 2020 11:41:55 +0000 (12:41 +0100)
This allows encoder "owners" to allocate more to store extra data with the
object and use them in callbacks (using container_of).

include/vlc_sout.h
modules/stream_out/transcode/audio.c
modules/stream_out/transcode/encoder/audio.c
modules/stream_out/transcode/encoder/video.c
modules/stream_out/transcode/spu.c
modules/stream_out/transcode/video.c
src/misc/image.c
src/missing.c
src/stream_output/stream_output.c

index 484e91f..4bbf5b0 100644 (file)
@@ -263,8 +263,8 @@ static inline int sout_StreamControl( sout_stream_t *s, int i_query, ... )
  * Encoder
  ****************************************************************************/
 
-VLC_API encoder_t * sout_EncoderCreate( vlc_object_t *obj );
-#define sout_EncoderCreate(o) sout_EncoderCreate(VLC_OBJECT(o))
+VLC_API encoder_t * sout_EncoderCreate( vlc_object_t *, size_t );
+#define sout_EncoderCreate(o,s) sout_EncoderCreate(VLC_OBJECT(o),s)
 
 /****************************************************************************
  * Announce handler
index 8079424..1a8c6dd 100644 (file)
@@ -183,7 +183,7 @@ int transcode_audio_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
 
     vlc_mutex_unlock(&id->fifo.lock);
 
-    id->encoder = transcode_encoder_new( sout_EncoderCreate(p_stream), &encoder_tested_fmt_in );
+    id->encoder = transcode_encoder_new( sout_EncoderCreate(p_stream, sizeof(encoder_t)), &encoder_tested_fmt_in );
     if( !id->encoder )
     {
         module_unneed( id->p_decoder, id->p_decoder->p_module );
index bb21e15..5286ad5 100644 (file)
@@ -145,7 +145,7 @@ int transcode_encoder_audio_test( vlc_object_t *p_obj,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in )
 {
-    encoder_t *p_encoder = sout_EncoderCreate( p_obj );
+    encoder_t *p_encoder = sout_EncoderCreate( p_obj, sizeof(encoder_t) );
     if( !p_encoder )
         return VLC_EGENERIC;
 
index 670f5b8..c3f6b9a 100644 (file)
@@ -289,7 +289,7 @@ int transcode_encoder_video_test( vlc_object_t *p_obj,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in )
 {
-    encoder_t *p_encoder = sout_EncoderCreate( p_obj );
+    encoder_t *p_encoder = sout_EncoderCreate( p_obj, sizeof(encoder_t) );
     if( !p_encoder )
         return VLC_EGENERIC;
 
index c06fa76..832600d 100644 (file)
@@ -115,7 +115,7 @@ int transcode_spu_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
         /* Open encoder */
         /* Initialization of encoder format structures */
         assert(!id->encoder);
-        id->encoder = transcode_encoder_new( sout_EncoderCreate(p_stream), &id->p_decoder->fmt_in );
+        id->encoder = transcode_encoder_new( sout_EncoderCreate(p_stream, sizeof(encoder_t)), &id->p_decoder->fmt_in );
         if( !id->encoder )
         {
             module_unneed( id->p_decoder, id->p_decoder->p_module );
index db90a90..8d47662 100644 (file)
@@ -234,7 +234,7 @@ int transcode_video_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
         return VLC_EGENERIC;
     }
 
-    id->encoder = transcode_encoder_new( sout_EncoderCreate(VLC_OBJECT(p_stream)), &encoder_tested_fmt_in );
+    id->encoder = transcode_encoder_new( sout_EncoderCreate(VLC_OBJECT(p_stream), sizeof(encoder_t)), &encoder_tested_fmt_in );
     if( !id->encoder )
     {
         module_unneed( id->p_decoder, id->p_decoder->p_module );
index 15b2aee..cc432f6 100644 (file)
@@ -705,7 +705,7 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, const video_format_t *fmt
 {
     encoder_t *p_enc;
 
-    p_enc = sout_EncoderCreate( p_this );
+    p_enc = sout_EncoderCreate( p_this, sizeof(encoder_t) );
     if( p_enc == NULL )
         return NULL;
 
index 6769fa4..edfd458 100644 (file)
@@ -118,7 +118,7 @@ noreturn void sout_AnnounceUnRegister(vlc_object_t *obj,
 }
 
 #undef sout_EncoderCreate
-encoder_t *sout_EncoderCreate( vlc_object_t *p_this )
+encoder_t *sout_EncoderCreate( vlc_object_t *p_this, size_t owner_size )
 {
     msg_Err (p_this, "Encoding support not compiled-in!");
     return NULL;
index 4c8bba8..80daa2a 100644 (file)
@@ -1003,7 +1003,8 @@ rtp:
 }
 
 #undef sout_EncoderCreate
-encoder_t *sout_EncoderCreate( vlc_object_t *p_this )
+encoder_t *sout_EncoderCreate( vlc_object_t *p_this, size_t owner_size )
 {
-    return vlc_custom_create( p_this, sizeof( encoder_t ), "encoder" );
+    assert( owner_size >= sizeof(encoder_t) );
+    return vlc_custom_create( p_this, owner_size, "encoder" );
 }