[vlc-devel] [PATCH 23/26] transcode: don't check for VIDEO_ES on the encoder helper

Steve Lhomme robux4 at ycbcr.xyz
Mon Jan 18 08:33:02 UTC 2021


All the transcode_encoder_t calls are now only used by the video encoder.
---
 .../stream_out/transcode/encoder/encoder.c    | 79 ++++---------------
 1 file changed, 15 insertions(+), 64 deletions(-)

diff --git a/modules/stream_out/transcode/encoder/encoder.c b/modules/stream_out/transcode/encoder/encoder.c
index 1d6d36f0377..08666493bd9 100644
--- a/modules/stream_out/transcode/encoder/encoder.c
+++ b/modules/stream_out/transcode/encoder/encoder.c
@@ -46,11 +46,8 @@ void transcode_encoder_delete( transcode_encoder_t *p_enc )
 {
     if( p_enc->p_encoder )
     {
-        if( p_enc->p_encoder->fmt_in.i_cat == VIDEO_ES )
-        {
-            block_ChainRelease( p_enc->p_buffers );
-            picture_fifo_Delete( p_enc->pp_pics );
-        }
+        block_ChainRelease( p_enc->p_buffers );
+        picture_fifo_Delete( p_enc->pp_pics );
         sout_EncoderDelete( p_enc->p_encoder );
     }
     free( p_enc );
@@ -62,13 +59,7 @@ transcode_encoder_t * transcode_encoder_new( encoder_t *p_encoder,
     if( !p_encoder )
         return NULL;
 
-    switch( p_fmt->i_cat )
-    {
-        case VIDEO_ES:
-            break;
-        default:
-            return NULL;
-    }
+    assert( p_fmt->i_cat == VIDEO_ES);
 
     transcode_encoder_t *p_enc = calloc( 1, sizeof(*p_enc) );
     if( unlikely(!p_enc) )
@@ -80,21 +71,14 @@ transcode_encoder_t * transcode_encoder_new( encoder_t *p_encoder,
     p_enc->p_encoder = p_encoder;
     p_enc->p_encoder->p_module = NULL;
 
-    switch( p_fmt->i_cat )
+    p_enc->pp_pics = picture_fifo_New();
+    if( !p_enc->pp_pics )
     {
-        case VIDEO_ES:
-            p_enc->pp_pics = picture_fifo_New();
-            if( !p_enc->pp_pics )
-            {
-                sout_EncoderDelete( p_enc->p_encoder );
-                free( p_enc );
-                return NULL;
-            }
-            vlc_mutex_init( &p_enc->lock_out );
-            break;
-        default:
-            break;
+        sout_EncoderDelete( p_enc->p_encoder );
+        free( p_enc );
+        return NULL;
     }
+    vlc_mutex_init( &p_enc->lock_out );
 
     return p_enc;
 }
@@ -114,14 +98,8 @@ void transcode_encoder_update_format_in( transcode_encoder_t *p_enc, const es_fo
 {
     es_format_Clean( &p_enc->p_encoder->fmt_in );
     es_format_Copy( &p_enc->p_encoder->fmt_in, fmt );
-    switch (fmt->i_cat)
-    {
-        case VIDEO_ES:
-            transcode_encoder_video_set_src(p_enc->p_encoder, &fmt->video, p_cfg);
-            break;
-        default:
-            break;
-    }
+
+    transcode_encoder_video_set_src(p_enc->p_encoder, &fmt->video, p_cfg);
 }
 
 void transcode_encoder_update_format_out( transcode_encoder_t *p_enc, const es_format_t *fmt )
@@ -137,14 +115,7 @@ bool transcode_encoder_opened( const transcode_encoder_t *p_enc )
 
 block_t * transcode_encoder_encode( transcode_encoder_t *p_enc, void *in )
 {
-    switch( p_enc->p_encoder->fmt_in.i_cat )
-    {
-        case VIDEO_ES:
-            return transcode_encoder_video_encode( p_enc, in );
-        default:
-            vlc_assert_unreachable();
-            return NULL;
-    }
+    return transcode_encoder_video_encode( p_enc, in );
 }
 
 block_t * transcode_encoder_get_output_async( transcode_encoder_t *p_enc )
@@ -161,15 +132,7 @@ void transcode_encoder_close( transcode_encoder_t *p_enc )
     if( !p_enc->p_encoder->p_module )
         return;
 
-    switch( p_enc->p_encoder->fmt_in.i_cat )
-    {
-        case VIDEO_ES:
-            transcode_encoder_video_close( p_enc );
-            break;
-        default:
-            module_unneed( p_enc->p_encoder, p_enc->p_encoder->p_module );
-            break;
-    }
+    transcode_encoder_video_close( p_enc );
 
     p_enc->p_encoder->p_module = NULL;
 }
@@ -178,13 +141,7 @@ void transcode_encoder_close( transcode_encoder_t *p_enc )
 int transcode_encoder_open( transcode_encoder_t *p_enc,
                             const transcode_encoder_config_t *p_cfg )
 {
-    switch( p_enc->p_encoder->fmt_in.i_cat )
-    {
-        case VIDEO_ES:
-            return transcode_encoder_video_open( p_enc, p_cfg );
-        default:
-            return VLC_EGENERIC;
-    }
+    return transcode_encoder_video_open( p_enc, p_cfg );
 }
 
 int transcode_encoder_drain( transcode_encoder_t *p_enc, block_t **out )
@@ -192,11 +149,5 @@ int transcode_encoder_drain( transcode_encoder_t *p_enc, block_t **out )
     if( !transcode_encoder_opened( p_enc ) )
         return VLC_EGENERIC;
 
-    switch( p_enc->p_encoder->fmt_in.i_cat )
-    {
-        case VIDEO_ES:
-            return transcode_encoder_video_drain( p_enc, out );
-        default:
-            return VLC_EGENERIC;
-    }
+    return transcode_encoder_video_drain( p_enc, out );
 }
-- 
2.29.2



More information about the vlc-devel mailing list