[vlc-devel] [PATCH 21/26] transcode: don't use the generic transcode structure for SPU
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 18 08:33:00 UTC 2021
None of the fields or helpers are necessary.
transcode_encoder_close is equivalent to sout_EncoderDelete for SPU.
Don't use transcode_encoder_delete now that there is no transcode_encoder_t.
---
modules/stream_out/Makefile.am | 1 -
.../stream_out/transcode/encoder/encoder.c | 7 ---
.../transcode/encoder/encoder_priv.h | 4 --
modules/stream_out/transcode/encoder/spu.c | 49 -------------------
modules/stream_out/transcode/spu.c | 30 ++++++------
modules/stream_out/transcode/transcode.h | 5 +-
6 files changed, 18 insertions(+), 78 deletions(-)
delete mode 100644 modules/stream_out/transcode/encoder/spu.c
diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/Makefile.am
index 6cc77a33500..a2ee3b22bd0 100644
--- a/modules/stream_out/Makefile.am
+++ b/modules/stream_out/Makefile.am
@@ -24,7 +24,6 @@ libstream_out_transcode_plugin_la_SOURCES = \
stream_out/transcode/encoder/encoder.h \
stream_out/transcode/encoder/encoder_priv.h \
stream_out/transcode/encoder/audio.c \
- stream_out/transcode/encoder/spu.c \
stream_out/transcode/encoder/video.c \
stream_out/transcode/spu.c \
stream_out/transcode/audio.c stream_out/transcode/video.c
diff --git a/modules/stream_out/transcode/encoder/encoder.c b/modules/stream_out/transcode/encoder/encoder.c
index 71698a01298..84a30b5b454 100644
--- a/modules/stream_out/transcode/encoder/encoder.c
+++ b/modules/stream_out/transcode/encoder/encoder.c
@@ -66,7 +66,6 @@ transcode_encoder_t * transcode_encoder_new( encoder_t *p_encoder,
{
case VIDEO_ES:
case AUDIO_ES:
- case SPU_ES:
break;
default:
return NULL;
@@ -145,8 +144,6 @@ block_t * transcode_encoder_encode( transcode_encoder_t *p_enc, void *in )
return transcode_encoder_video_encode( p_enc, in );
case AUDIO_ES:
return transcode_encoder_audio_encode( p_enc, in );
- case SPU_ES:
- return transcode_encoder_spu_encode( p_enc, in );
default:
vlc_assert_unreachable();
return NULL;
@@ -186,8 +183,6 @@ int transcode_encoder_open( transcode_encoder_t *p_enc,
{
switch( p_enc->p_encoder->fmt_in.i_cat )
{
- case SPU_ES:
- return transcode_encoder_spu_open( p_enc, p_cfg );
case AUDIO_ES:
return transcode_encoder_audio_open( p_enc, p_cfg );
case VIDEO_ES:
@@ -208,8 +203,6 @@ int transcode_encoder_drain( transcode_encoder_t *p_enc, block_t **out )
return transcode_encoder_video_drain( p_enc, out );
case AUDIO_ES:
return transcode_encoder_audio_drain( p_enc, out );
- case SPU_ES:
- return VLC_SUCCESS;
default:
return VLC_EGENERIC;
}
diff --git a/modules/stream_out/transcode/encoder/encoder_priv.h b/modules/stream_out/transcode/encoder/encoder_priv.h
index 7559fc4fb64..ccbd405d90c 100644
--- a/modules/stream_out/transcode/encoder/encoder_priv.h
+++ b/modules/stream_out/transcode/encoder/encoder_priv.h
@@ -37,14 +37,10 @@ int transcode_encoder_audio_open( transcode_encoder_t *p_enc,
const transcode_encoder_config_t *p_cfg );
int transcode_encoder_video_open( transcode_encoder_t *p_enc,
const transcode_encoder_config_t *p_cfg );
-int transcode_encoder_spu_open( transcode_encoder_t *p_enc,
- const transcode_encoder_config_t *p_cfg );
-
void transcode_encoder_video_close( transcode_encoder_t *p_enc );
block_t * transcode_encoder_video_encode( transcode_encoder_t *p_enc, picture_t *p_pic );
block_t * transcode_encoder_audio_encode( transcode_encoder_t *p_enc, block_t *p_block );
-block_t * transcode_encoder_spu_encode( transcode_encoder_t *p_enc, subpicture_t *p_spu );
int transcode_encoder_audio_drain( transcode_encoder_t *p_enc, block_t **out );
int transcode_encoder_video_drain( transcode_encoder_t *p_enc, block_t **out );
diff --git a/modules/stream_out/transcode/encoder/spu.c b/modules/stream_out/transcode/encoder/spu.c
deleted file mode 100644
index d7d8af87f4b..00000000000
--- a/modules/stream_out/transcode/encoder/spu.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*****************************************************************************
- * spu.c: transcoding spu encoder
- *****************************************************************************
- * Copyright (C) 2003-2009 VLC authors and VideoLAN
- * 2018 VideoLabs, VideoLAN and VLC authors
- *
- * Authors: Laurent Aimar <fenrir at via.ecp.fr>
- * Gildas Bazin <gbazin at videolan.org>
- * Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
- * Antoine Cellerier <dionoea at videolan dot org>
- * Ilkka Ollakka <ileoo at videolan dot org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, If not, see https://www.gnu.org/licenses/
- *****************************************************************************/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc_common.h>
-#include <vlc_modules.h>
-#include <vlc_codec.h>
-#include <vlc_sout.h>
-
-#include "encoder.h"
-#include "encoder_priv.h"
-
-int transcode_encoder_spu_open( transcode_encoder_t *p_enc,
- const transcode_encoder_config_t *p_cfg )
-{
- p_enc->p_encoder->fmt_out.i_codec = p_cfg->i_codec;
-
- return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain);
-}
-
-block_t * transcode_encoder_spu_encode( transcode_encoder_t *p_enc, subpicture_t *p_spu )
-{
- return p_enc->p_encoder->pf_encode_sub( p_enc->p_encoder, p_spu );
-}
diff --git a/modules/stream_out/transcode/spu.c b/modules/stream_out/transcode/spu.c
index 6c0c67c50e0..2d3400ac413 100644
--- a/modules/stream_out/transcode/spu.c
+++ b/modules/stream_out/transcode/spu.c
@@ -114,21 +114,23 @@ 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, sizeof(encoder_t),
- &id->p_decoder->fmt_in),
- &id->p_decoder->fmt_in );
- if( !id->encoder )
+ assert(!id->spu_encoder);
+ id->spu_encoder = sout_EncoderCreate(p_stream, sizeof(encoder_t),
+ &id->p_decoder->fmt_in);
+ if( !id->spu_encoder )
{
module_unneed( id->p_decoder, id->p_decoder->p_module );
id->p_decoder->p_module = NULL;
return VLC_EGENERIC;
}
- if( transcode_encoder_open( id->encoder, id->p_enccfg ) )
+ id->spu_encoder->fmt_out.i_codec = id->p_enccfg->i_codec;
+
+ if( sout_EncoderOpen(id->spu_encoder, id->p_enccfg->psz_name, true,
+ id->p_enccfg->p_config_chain) != VLC_SUCCESS )
{
msg_Err( p_stream, "cannot find spu encoder (%s)", id->p_enccfg->psz_name );
- transcode_encoder_delete( id->encoder );
+ sout_EncoderDelete( id->spu_encoder );
module_unneed( id->p_decoder, id->p_decoder->p_module );
id->p_decoder->p_module = NULL;
return VLC_EGENERIC;
@@ -138,13 +140,12 @@ int transcode_spu_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
id->downstream_id =
id->pf_transcode_downstream_add( p_stream,
&id->p_decoder->fmt_in,
- transcode_encoder_format_out( id->encoder ) );
+ &id->spu_encoder->fmt_out );
if( !id->downstream_id )
{
msg_Err( p_stream, "cannot output transcoded stream %4.4s",
(char *) &id->p_enccfg->i_codec );
- transcode_encoder_close( id->encoder );
- transcode_encoder_delete( id->encoder );
+ sout_EncoderDelete( id->spu_encoder );
module_unneed( id->p_decoder, id->p_decoder->p_module );
id->p_decoder->p_module = NULL;
return VLC_EGENERIC;
@@ -163,11 +164,8 @@ void transcode_spu_clean( sout_stream_t *p_stream, sout_stream_id_sys_t *id)
VLC_UNUSED(p_stream);
/* Close encoder */
- if( id->encoder )
- {
- transcode_encoder_close( id->encoder );
- transcode_encoder_delete( id->encoder );
- }
+ if( id->spu_encoder )
+ sout_EncoderDelete( id->spu_encoder );
}
int transcode_spu_process( sout_stream_t *p_stream,
@@ -243,7 +241,7 @@ int transcode_spu_process( sout_stream_t *p_stream,
subpicture_Update( p_subpic, &fmt.video, &fmt.video, p_subpic->i_start );
es_format_Clean( &fmt );
- p_block = transcode_encoder_encode( id->encoder, p_subpic );
+ p_block = id->spu_encoder->pf_encode_sub( id->spu_encoder, p_subpic );
subpicture_Delete( p_subpic );
if( p_block )
block_ChainAppend( out, p_block );
diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
index 1be5c8c1274..d10b4ace1ee 100644
--- a/modules/stream_out/transcode/transcode.h
+++ b/modules/stream_out/transcode/transcode.h
@@ -140,7 +140,10 @@ struct sout_stream_id_sys_t
/* Encoder */
const transcode_encoder_config_t *p_enccfg;
- transcode_encoder_t *encoder;
+ union {
+ transcode_encoder_t *encoder;
+ encoder_t *spu_encoder;
+ };
/* Sync */
date_t next_input_pts; /**< Incoming calculated PTS */
--
2.29.2
More information about the vlc-devel
mailing list