[vlc-commits] [Git][videolan/vlc][master] 27 commits: codec: aom: refactor error path behind goto

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Jan 13 20:26:01 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
9f76d48b by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: aom: refactor error path behind goto

- - - - -
b0fda60b by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
stream_out: transcode: use designated initializer

Using designated initializer allows to split implementation of optional
callbacks from their addition to the struct.

- - - - -
4c2dd8da by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: dmo: move plugin manifest to the end

No functional changes. It will allow to split the activation functions
without forward-declaring them.

- - - - -
2ee61028 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: dmo: split activation function for encoders

Now that capabilities are separated by ES kind, we can just split the
activation function instead of checking the ES kind.

- - - - -
35fb600b by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: lpcm: move p_sys assignation

Move the assignation of p_enc->p_sys to the end of the function to
ensure it will never be set on error. There's currently no error
happening between both code location. No functional changes.

- - - - -
99e343d3 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: opus: move p_enc->p_sys assignment down

Ensure that the p_enc->p_sys value is not set on error by moving it
down.

- - - - -
a03fdfd9 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: qsv: move enc->p_sys assignment down

Ensure that the p_enc->p_sys value is not set on error by moving it
down.

- - - - -
56a24bbb by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: opus: fix memory leak on error

- - - - -
df63a0de by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: schroedinger: reset enc->p_sys to NULL

- - - - -
7142011d by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: shine: remove tautology

An audio encoder will always have its category set to AUDIO_ES.

- - - - -
fec3a81a by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: shine: reset busy state on error

Shine encoder can only be opened in one instance, but the codec won't be
busy if the encoder failed to open.

- - - - -
b676520e by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: substx3g: remove tautological statements

p_sys is supposed to be always NULL, and an SPU encoder will always have
a category of SPU_ES.

- - - - -
e943ddc9 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: t140: remove tautological statement TODO

p_sys is supposed to be always NULL, and an SPU encoder will always have
a category of SPU_ES.

- - - - -
ca9e64cb by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: theora: move p_sys assignment down

Ensure that p_sys is not set on the encoder on error by moving the
assignment down.

- - - - -
b36aed2e by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: theora: fix potential memory leak

- - - - -
94a5ae60 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: twolame: remove tautological assignment

An audio encoder will always have its category set to AUDIO_ES.

- - - - -
4637c1c9 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: twolame: move p_sys assignment down

Ensure that p_sys is not set on the encoder on error by moving the
assignment down.

- - - - -
e503d9a7 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: twolame: fix potential memory leak on error

- - - - -
08dce4f1 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: vorbis: refactor error path behind goto

- - - - -
778f37d3 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: vorbis: move p_sys assignment down

- - - - -
08ade19c by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: vpx: move p_sys assignment down

- - - - -
eacab1f3 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: vpx: move p_sys allocation after codec check

We don't need to allocate the module private data if the module doesn't
match the requested format.

- - - - -
8d4f4a24 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: vpx: refactor error path behind goto

- - - - -
d53f191d by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: webvtt: remove tautological assignment

- - - - -
17f0c401 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: x264: move p_sys assignment down

- - - - -
5915c95a by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
codec: x265: move p_sys assignment down

- - - - -
bb947981 by Alexandre Janniaux at 2023-01-13T20:10:04+00:00
test: adaptive: FakeEsOut: fix vlc_tick_t printing

Printing a vlc_tick_t should use PRId64.

- - - - -


18 changed files:

- modules/codec/aom.c
- modules/codec/dmo/dmo.c
- modules/codec/lpcm.c
- modules/codec/opus.c
- modules/codec/qsv.c
- modules/codec/schroedinger.c
- modules/codec/shine.c
- modules/codec/substx3g.c
- modules/codec/t140.c
- modules/codec/theora.c
- modules/codec/twolame.c
- modules/codec/vorbis.c
- modules/codec/vpx.c
- modules/codec/webvtt/encvtt.c
- modules/codec/x264.c
- modules/codec/x265.c
- modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
- modules/stream_out/transcode/video.c


Changes:

=====================================
modules/codec/aom.c
=====================================
@@ -517,8 +517,7 @@ static int OpenEncoder(vlc_object_t *p_this)
                     break;
                 default:
                     msg_Err( p_enc, "%d bit is unsupported for profile %d", i_bit_depth, i_profile );
-                    free( p_sys );
-                    return VLC_EGENERIC;
+                    goto error_nocontext;
             }
             enccfg.g_bit_depth = i_bit_depth;
             break;
@@ -531,8 +530,7 @@ static int OpenEncoder(vlc_object_t *p_this)
             /* fallthrough */
         default:
             msg_Err( p_enc, "Unsupported profile %d", i_profile );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error_nocontext;
     }
 
     msg_Dbg(p_this, "AV1: using libaom version %s (build options %s)",
@@ -542,26 +540,21 @@ static int OpenEncoder(vlc_object_t *p_this)
     if (aom_codec_enc_init(ctx, iface, &enccfg, enc_flags) != AOM_CODEC_OK)
     {
         AOM_ERR(p_this, ctx, "Failed to initialize encoder");
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error_nocontext;
     }
 
     if (i_tile_rows >= 0 &&
         aom_codec_control(ctx, AV1E_SET_TILE_ROWS, i_tile_rows))
     {
         AOM_ERR(p_this, ctx, "Failed to set tile rows");
-        destroy_context(p_this, ctx);
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 
     if (i_tile_columns >= 0 &&
         aom_codec_control(ctx, AV1E_SET_TILE_COLUMNS, i_tile_columns))
     {
         AOM_ERR(p_this, ctx, "Failed to set tile columns");
-        destroy_context(p_this, ctx);
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 
 #ifdef AOM_CTRL_AV1E_SET_ROW_MT
@@ -569,9 +562,7 @@ static int OpenEncoder(vlc_object_t *p_this)
         aom_codec_control(ctx, AV1E_SET_ROW_MT, b_row_mt))
     {
         AOM_ERR(p_this, ctx, "Failed to set row-multithreading");
-        destroy_context(p_this, ctx);
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 #endif
 
@@ -579,9 +570,7 @@ static int OpenEncoder(vlc_object_t *p_this)
     if (aom_codec_control(ctx, AOME_SET_CPUUSED, i_cpu_used))
     {
         AOM_ERR(p_this, ctx, "Failed to set cpu-used");
-        destroy_context(p_this, ctx);
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 
     static const struct vlc_encoder_operations ops =
@@ -592,6 +581,12 @@ static int OpenEncoder(vlc_object_t *p_this)
     p_enc->ops = &ops;
 
     return VLC_SUCCESS;
+
+error:
+    destroy_context(p_this, ctx);
+error_nocontext:
+    free(p_sys);
+    return VLC_EGENERIC;
 }
 
 /****************************************************************************


=====================================
modules/codec/dmo/dmo.c
=====================================
@@ -67,33 +67,6 @@ static int LoadDMO( vlc_object_t *, HINSTANCE *, IMediaObject **,
                     const es_format_t *, bool );
 static void CopyPicture( picture_t *, uint8_t * );
 
-vlc_module_begin ()
-    set_description( N_("DirectMedia Object decoder") )
-    add_shortcut( "dmo" )
-    set_capability( "video decoder", 1 )
-    set_callbacks( DecoderOpen, DecoderClose )
-    set_subcategory( SUBCAT_INPUT_VCODEC )
-
-    add_submodule()
-    add_shortcut("dmo")
-    set_capability( "audio decoder", 1 )
-    set_callbacks(DecoderOpen, DecoderClose)
-
-    add_submodule ()
-    set_description( N_("DirectMedia Object encoder") )
-    add_shortcut( "dmo" )
-    set_capability( "video encoder", 10 )
-    set_callback( EncoderOpen )
-
-    add_submodule ()
-    set_description( N_("DirectMedia Object encoder") )
-    add_shortcut( "dmo" )
-    set_capability( "audio encoder", 10 )
-    set_callback( EncoderOpen )
-
-
-vlc_module_end ()
-
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -1041,40 +1014,42 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *samples )
     { return EncodeBlock( p_enc, samples ); }
 
 /*****************************************************************************
- * EncoderOpen: open dmo codec
+ * EncoderOpenAudio: open audio dmo codec
  *****************************************************************************/
-static int EncoderOpen( vlc_object_t *p_this )
+static int EncoderOpenAudio(vlc_object_t *p_this)
 {
     encoder_t *p_enc = (encoder_t*)p_this;
 
     int i_ret = EncOpen( p_this );
     if( i_ret != VLC_SUCCESS ) return i_ret;
 
-    static const struct vlc_encoder_operations video_ops =
-    {
-        .close = EncoderClose,
-        .encode_video = EncodeVideo,
-    };
 
     static const struct vlc_encoder_operations audio_ops =
     {
         .close = EncoderClose,
         .encode_audio = EncodeAudio,
     };
+    p_enc->ops = &audio_ops;
 
-    switch( p_enc->fmt_in.i_cat )
-    {
-        case VIDEO_ES:
-            p_enc->ops = &video_ops;
-            break;
+    return VLC_SUCCESS;
+}
 
-        case AUDIO_ES:
-            p_enc->ops = &audio_ops;
-            break;
+/*****************************************************************************
+ * EncoderOpenVideo: open video dmo codec
+ *****************************************************************************/
+static int EncoderOpenVideo(vlc_object_t *p_this)
+{
+    encoder_t *p_enc = (encoder_t*)p_this;
 
-        default:
-            vlc_assert_unreachable();
-    }
+    int i_ret = EncOpen( p_this );
+    if( i_ret != VLC_SUCCESS ) return i_ret;
+
+    static const struct vlc_encoder_operations video_ops =
+    {
+        .close = EncoderClose,
+        .encode_video = EncodeVideo,
+    };
+    p_enc->ops = &video_ops;
 
     return VLC_SUCCESS;
 }
@@ -1639,3 +1614,28 @@ void EncoderClose( encoder_t *p_enc )
 
     free( p_sys );
 }
+
+vlc_module_begin ()
+    set_description( N_("DirectMedia Object decoder") )
+    add_shortcut( "dmo" )
+    set_capability( "video decoder", 1 )
+    set_callbacks( DecoderOpen, DecoderClose )
+    set_subcategory( SUBCAT_INPUT_VCODEC )
+
+    add_submodule()
+    add_shortcut("dmo")
+    set_capability( "audio decoder", 1 )
+    set_callbacks(DecoderOpen, DecoderClose)
+
+    add_submodule ()
+    set_description( N_("DirectMedia Object encoder") )
+    add_shortcut( "dmo" )
+    set_capability( "video encoder", 10 )
+    set_callback( EncoderOpenVideo )
+
+    add_submodule ()
+    set_description( N_("DirectMedia Object encoder") )
+    add_shortcut( "dmo" )
+    set_capability( "audio encoder", 10 )
+    set_callback( EncoderOpenAudio )
+vlc_module_end ()


=====================================
modules/codec/lpcm.c
=====================================
@@ -537,7 +537,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     }
 
     /* Allocate the memory needed to store the encoder's structure */
-    if( ( p_enc->p_sys = p_sys =
+    if( ( p_sys =
           (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
 
@@ -570,6 +570,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     };
 
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
 
     return VLC_SUCCESS;
 }


=====================================
modules/codec/opus.c
=====================================
@@ -793,7 +793,6 @@ static int OpenEncoder(vlc_object_t *p_this)
 
     /* Buffer for incoming audio, since opus only accepts frame sizes that are
        multiples of 2.5ms */
-    enc->p_sys = sys;
     sys->buffer = vlc_alloc(header.channels, sizeof(float) * OPUS_FRAME_SIZE);
     if (!sys->buffer) {
         status = VLC_ENOMEM;
@@ -841,7 +840,12 @@ static int OpenEncoder(vlc_object_t *p_this)
     opus_header_clean(&header);
 
     if (status != VLC_SUCCESS)
+    {
+        free(sys->buffer);
+        opus_multistream_encoder_destroy(sys->enc);
+        free(sys);
         return status;
+    }
 
     static const struct vlc_encoder_operations ops =
     {
@@ -849,6 +853,8 @@ static int OpenEncoder(vlc_object_t *p_this)
         .encode_audio = Encode,
     };
     enc->ops = &ops;
+    enc->p_sys = sys;
+
     return VLC_SUCCESS;
 
 error:


=====================================
modules/codec/qsv.c
=====================================
@@ -432,8 +432,6 @@ static int Open(vlc_object_t *this)
         return VLC_EGENERIC;
     }
 
-    enc->p_sys = sys;
-
     vlc_list_init(&sys->packets);
 
     config_ChainParse(enc, SOUT_CFG_PREFIX, sout_options, enc->p_cfg);
@@ -625,16 +623,15 @@ static int Open(vlc_object_t *this)
         .encode_video = Encode,
     };
     enc->ops = &ops;
+    enc->p_sys = sys;
 
     return VLC_SUCCESS;
 
  error:
     Close(enc);
-    enc->p_sys = NULL;
     return VLC_EGENERIC;
  nomem:
     Close(enc);
-    enc->p_sys = NULL;
     return VLC_ENOMEM;
 }
 


=====================================
modules/codec/schroedinger.c
=====================================
@@ -1605,4 +1605,6 @@ static void CloseEncoder( encoder_t *p_enc )
     block_ChainRelease( p_sys->p_chain );
 
     free( p_sys );
+    /* We need to reset p_sys since CloseEncoder is also called during error. */
+    p_enc->p_sys = NULL;
 }


=====================================
modules/codec/shine.c
=====================================
@@ -121,6 +121,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     cfg.mpeg.bitr = p_enc->fmt_out.i_bitrate / 1000;
 
     if (shine_check_config(cfg.wave.samplerate, cfg.mpeg.bitr) == -1) {
+        atomic_store(&busy, false);
         msg_Err(p_enc, "Invalid bitrate %d\n", cfg.mpeg.bitr);
         free(p_sys);
         return VLC_EGENERIC;
@@ -129,8 +130,6 @@ static int OpenEncoder( vlc_object_t *p_this )
     p_sys->s = shine_initialise(&cfg);
     p_sys->samples_per_frame = shine_samples_per_pass(p_sys->s);
 
-    p_enc->fmt_out.i_cat = AUDIO_ES;
-
     p_enc->fmt_in.i_codec = VLC_CODEC_S16N;
 
     static const struct vlc_encoder_operations ops =


=====================================
modules/codec/substx3g.c
=====================================
@@ -613,10 +613,6 @@ static int OpenEncoder( vlc_object_t *p_this )
 
     p_enc->fmt_in.i_codec = VLC_CODEC_TEXT;
 
-    p_enc->p_sys = NULL;
-
-    p_enc->fmt_out.i_cat = SPU_ES;
-
     if( !p_enc->fmt_out.i_extra )
         FillExtradataTx3g( &p_enc->fmt_out.p_extra, &p_enc->fmt_out.i_extra );
 


=====================================
modules/codec/t140.c
=====================================
@@ -64,10 +64,6 @@ static int Open( vlc_object_t *p_this )
             p_enc->fmt_out.i_codec = VLC_CODEC_ITU_T140;
     }
 
-    p_enc->p_sys = NULL;
-
-    p_enc->fmt_out.i_cat = SPU_ES;
-
     static const struct vlc_encoder_operations ops =
         { .encode_sub = Encode };
     p_enc->ops = &ops;


=====================================
modules/codec/theora.c
=====================================
@@ -687,7 +687,6 @@ static int OpenEncoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the encoder's structure */
     if( ( p_sys = malloc(sizeof(encoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
-    p_enc->p_sys = p_sys;
 
     p_enc->fmt_in.i_codec = VLC_CODEC_I420;
     p_enc->fmt_out.i_codec = VLC_CODEC_THEORA;
@@ -783,7 +782,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     /* Create and store headers */
     while ( ( status = th_encode_flushheader( p_sys->tcx, &p_sys->tc, &header ) ) )
     {
-        if ( status < 0 ) return VLC_EGENERIC;
+        if ( status < 0 ) goto error;
         if( xiph_AppendHeaders( &p_enc->fmt_out.i_extra, &p_enc->fmt_out.p_extra,
                                 header.bytes, header.packet ) )
         {
@@ -798,7 +797,15 @@ static int OpenEncoder( vlc_object_t *p_this )
         .encode_video = Encode,
     };
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
+
     return VLC_SUCCESS;
+error:
+    th_info_clear(&p_sys->ti);
+    th_comment_clear(&p_sys->tc);
+    th_encode_free(p_sys->tcx);
+    free(p_sys);
+    return VLC_EGENERIC;
 }
 
 /****************************************************************************


=====================================
modules/codec/twolame.c
=====================================
@@ -157,11 +157,8 @@ static int OpenEncoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
-    p_enc->p_sys = p_sys;
 
     p_enc->fmt_in.i_codec = VLC_CODEC_S16N;
-
-    p_enc->fmt_out.i_cat = AUDIO_ES;
     p_enc->fmt_out.i_codec = VLC_CODEC_MPGA;
 
     config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
@@ -232,7 +229,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     if ( twolame_init_params( p_sys->p_twolame ) )
     {
         msg_Err( p_enc, "twolame initialization failed" );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     static const struct vlc_encoder_operations ops =
@@ -241,10 +238,15 @@ static int OpenEncoder( vlc_object_t *p_this )
         .encode_audio = Encode,
     };
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
 
     p_sys->i_nb_samples = 0;
 
     return VLC_SUCCESS;
+error:
+    twolame_close( &p_sys->p_twolame );
+    free(p_sys);
+    return VLC_EGENERIC;
 }
 
 /****************************************************************************


=====================================
modules/codec/vorbis.c
=====================================
@@ -768,7 +768,6 @@ static int OpenEncoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
-    p_enc->p_sys = p_sys;
 
     p_enc->fmt_in.i_codec  = VLC_CODEC_FL32;
     p_enc->fmt_out.i_codec = VLC_CODEC_VORBIS;
@@ -798,12 +797,10 @@ static int OpenEncoder( vlc_object_t *p_this )
               p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.audio.i_rate,
               i_quality * 0.1 ) )
         {
-            vorbis_info_clear( &p_sys->vi );
-            free( p_enc->p_sys );
             msg_Err( p_enc, "VBR mode initialisation failed %"PRIu8"x(%uHz,q=%d)",
                      p_enc->fmt_in.audio.i_channels,
                      p_enc->fmt_in.audio.i_rate, i_quality );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         /* Do we have optional hard quality restrictions? */
@@ -833,13 +830,11 @@ static int OpenEncoder( vlc_object_t *p_this )
               p_enc->fmt_out.i_bitrate,
               i_max_bitrate > 0 ? i_max_bitrate * 1000: -1 ) )
           {
-              vorbis_info_clear( &p_sys->vi );
               msg_Err( p_enc, "CBR mode initialisation failed %"PRIu8"x(%uHz,r=%u)",
                        p_enc->fmt_in.audio.i_channels,
                        p_enc->fmt_in.audio.i_rate,
                        p_enc->fmt_out.i_bitrate);
-              free( p_enc->p_sys );
-              return VLC_EGENERIC;
+              goto error;
           }
     }
 
@@ -887,8 +882,13 @@ static int OpenEncoder( vlc_object_t *p_this )
         .encode_audio = Encode,
     };
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
 
     return VLC_SUCCESS;
+error:
+    vorbis_info_clear( &p_sys->vi );
+    free(p_sys);
+    return VLC_EGENERIC;
 }
 
 /****************************************************************************


=====================================
modules/codec/vpx.c
=====================================
@@ -394,12 +394,6 @@ static int OpenEncoder(vlc_object_t *p_this)
     encoder_t *p_enc = (encoder_t *)p_this;
     encoder_sys_t *p_sys;
 
-    /* Allocate the memory needed to store the encoder's structure */
-    p_sys = malloc(sizeof(*p_sys));
-    if (p_sys == NULL)
-        return VLC_ENOMEM;
-    p_enc->p_sys = p_sys;
-
     const struct vpx_codec_iface *iface;
     int vp_version;
 
@@ -419,10 +413,14 @@ static int OpenEncoder(vlc_object_t *p_this)
         break;
 #endif
     default:
-        free(p_sys);
         return VLC_EGENERIC;
     }
 
+    /* Allocate the memory needed to store the encoder's structure */
+    p_sys = malloc(sizeof(*p_sys));
+    if (p_sys == NULL)
+        return VLC_ENOMEM;
+
     struct vpx_codec_enc_cfg enccfg = {0};
     vpx_codec_enc_config_default(iface, &enccfg, 0);
     enccfg.g_threads = __MIN(vlc_GetCPUCount(), 4);
@@ -435,8 +433,7 @@ static int OpenEncoder(vlc_object_t *p_this)
     struct vpx_codec_ctx *ctx = &p_sys->ctx;
     if (vpx_codec_enc_init(ctx, iface, &enccfg, 0) != VPX_CODEC_OK) {
         VPX_ERR(p_this, ctx, "Failed to initialize encoder");
-        free(p_sys);
-        return VLC_EGENERIC;
+        goto error;
     }
 
     p_enc->fmt_in.i_codec = VLC_CODEC_I420;
@@ -462,8 +459,12 @@ static int OpenEncoder(vlc_object_t *p_this)
         .encode_video = Encode,
     };
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
 
     return VLC_SUCCESS;
+error:
+    free(p_sys);
+    return VLC_EGENERIC;
 }
 
 /****************************************************************************


=====================================
modules/codec/webvtt/encvtt.c
=====================================
@@ -38,9 +38,6 @@ int webvtt_OpenEncoder( vlc_object_t *p_this )
     if( p_enc->fmt_out.i_codec != VLC_CODEC_WEBVTT )
         return VLC_EGENERIC;
 
-    p_enc->p_sys = NULL;
-
-    p_enc->fmt_out.i_cat = SPU_ES;
 
     static const struct vlc_encoder_operations ops =
         { .encode_sub = Encode };


=====================================
modules/codec/x264.c
=====================================
@@ -790,7 +790,7 @@ static int  Open ( vlc_object_t *p_this )
 #else
     p_enc->fmt_out.i_codec = VLC_CODEC_H264;
 #endif
-    p_enc->p_sys = p_sys = vlc_obj_malloc( p_this, sizeof( encoder_sys_t ) );
+    p_sys = vlc_obj_malloc( p_this, sizeof( encoder_sys_t ) );
     if( !p_sys )
         return VLC_ENOMEM;
 
@@ -1404,6 +1404,8 @@ static int  Open ( vlc_object_t *p_this )
     };
 
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
+
     return VLC_SUCCESS;
 }
 


=====================================
modules/codec/x265.c
=====================================
@@ -143,7 +143,7 @@ static int  Open (vlc_object_t *p_this)
 
     p_enc->fmt_out.i_cat = VIDEO_ES;
     p_enc->fmt_out.i_codec = VLC_CODEC_HEVC;
-    p_enc->p_sys = p_sys = malloc(sizeof(encoder_sys_t));
+    p_sys = malloc(sizeof(encoder_sys_t));
     if (!p_sys)
         return VLC_ENOMEM;
 
@@ -232,6 +232,7 @@ static int  Open (vlc_object_t *p_this)
         .encode_video = Encode,
     };
     p_enc->ops = &ops;
+    p_enc->p_sys = p_sys;
 
     return VLC_SUCCESS;
 }


=====================================
modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
=====================================
@@ -159,9 +159,9 @@ static int check2(es_out_t *out, struct context *, FakeESOut *fakees)
         SEND(TMS(100000));
 
         first = fakees->commandsQueue()->getFirstTimes();
-        fprintf(stderr,"first.continuous %ld", first.continuous);
+        fprintf(stderr,"first.continuous %" PRId64 "\n", first.continuous);
         Expect(first.continuous == TMS(100000));
-        fprintf(stderr,"first.segment.demux %ld", first.segment.demux);
+        fprintf(stderr,"first.segment.demux %" PRId64 "\n", first.segment.demux);
         Expect(first.segment.demux == TMS(100000));
 
         fakees->resetTimestamps();
@@ -175,7 +175,7 @@ static int check2(es_out_t *out, struct context *, FakeESOut *fakees)
         SEND(TMS(100000 + 5000));
         PCR(TMS(100000 + 5000));
         first = fakees->commandsQueue()->getFirstTimes();
-        fprintf(stderr,"first %ld\n", first.continuous);
+        fprintf(stderr,"first %" PRId64 "\n", first.continuous);
         Expect(first.continuous == TMS(60000));
 
         fakees->resetTimestamps();
@@ -188,7 +188,7 @@ static int check2(es_out_t *out, struct context *, FakeESOut *fakees)
         SEND(TMS(500000));
         PCR(TMS(500000));
         first = fakees->commandsQueue()->getFirstTimes();
-        fprintf(stderr,"first %ld\n", first.continuous);
+        fprintf(stderr,"first %" PRId64 "\n", first.continuous);
         Expect(first.continuous == TMS(60000));
 
         /* setAssociatedTimestamp check explicit rolled MPEGTS timestamp mapping (WebVTT) */
@@ -198,7 +198,7 @@ static int check2(es_out_t *out, struct context *, FakeESOut *fakees)
         SEND(TMS(500000));
         PCR(TMS(500000));
         first = fakees->commandsQueue()->getFirstTimes();
-        fprintf(stderr,"first %ld\n", first.continuous);
+        fprintf(stderr,"first %" PRId64 "\n", first.continuous);
         Expect(first.continuous == TMS(60000));
 
     } catch (...) {
@@ -247,7 +247,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
         Expect(fakees->commandsQueue()->getBufferingLevel().continuous == reference);
         vlc_tick_t ts = TMS(1000) + FROM_MPEGTS(0x1FFFFFFFF);
         ts = fakees->applyTimestampContinuity(ts);
-        fprintf(stderr, "timestamp %ld\n", ts);
+        fprintf(stderr, "timestamp %" PRId64 "\n", ts);
         Expect(ts == reference + DMS(1000));
 
         /* Reference has local multiple rolled timestamp < multiple rolled ts */
@@ -259,7 +259,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
         PCR(reference);
         ts = TMS(1000) + FROM_MPEGTS(0x1FFFFFFFF) * 5;
         ts = fakees->applyTimestampContinuity(ts);
-        fprintf(stderr, "timestamp %ld\n", ts);
+        fprintf(stderr, "timestamp %" PRId64 "\n", ts);
         Expect(ts == reference + DMS(1000));
 
 
@@ -273,7 +273,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
         Expect(fakees->commandsQueue()->getBufferingLevel().continuous == reference);
         ts = VLC_TICK_0 + 1;
         ts = fakees->applyTimestampContinuity(ts);
-        fprintf(stderr, "timestamp %ld\n", ts);
+        fprintf(stderr, "timestamp %" PRId64 "\n", ts);
         Expect(ts == reference + 1);
 
         /* Reference has local timestamp mutiple rolled > multiple rolled ts */
@@ -286,7 +286,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
         Expect(fakees->commandsQueue()->getBufferingLevel().continuous == reference);
         ts = VLC_TICK_0 + 1 + FROM_MPEGTS(0x1FFFFFFFF) * 2;
         ts = fakees->applyTimestampContinuity(ts);
-        fprintf(stderr, "timestamp %ld\n", ts);
+        fprintf(stderr, "timestamp %" PRId64 "\n", ts);
         Expect(ts == reference + 1);
 
         /* Do not trigger unwanted roll on long playbacks due to


=====================================
modules/stream_out/transcode/video.c
=====================================
@@ -68,7 +68,7 @@ static vlc_decoder_device *video_get_encoder_device( encoder_t *enc )
 }
 
 static const struct encoder_owner_callbacks encoder_video_transcode_cbs = {
-    { video_get_encoder_device, }
+    .video.get_device = video_get_encoder_device
 };
 
 static vlc_decoder_device * video_get_decoder_device( decoder_t *p_dec )



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e88c7160aa5a1aa7cef38c3f427daee578c42fc...bb9479813439f7247c03513e84378e565d422c16

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e88c7160aa5a1aa7cef38c3f427daee578c42fc...bb9479813439f7247c03513e84378e565d422c16
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list