[vlc-commits] [Git][videolan/vlc][master] 2 commits: spudec: allocate the SPU packet buffer dynamically
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Jan 28 08:24:19 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3ad00952 by Steve Lhomme at 2025-01-28T08:08:40+00:00
spudec: allocate the SPU packet buffer dynamically
- - - - -
6d94600f by Steve Lhomme at 2025-01-28T08:08:40+00:00
spudec: use a SPU updater to set the original dimensions
It avoids the warning in the core that uses whatever default it expects.
A SPU with absolute coordinates should always tell what dimensions it's
referring to.
For DVD SPU we know it has to correspond to the visible video area.
- - - - -
3 changed files:
- modules/codec/spudec/parse.c
- modules/codec/spudec/spudec.c
- modules/codec/spudec/spudec.h
Changes:
=====================================
modules/codec/spudec/parse.c
=====================================
@@ -184,6 +184,13 @@ static void ParsePXCTLI( decoder_t *p_dec, const subpicture_data_t *p_spu_data,
}
}
+static void UpdateDvdSpu(subpicture_t * p_spu,
+ const struct vlc_spu_updater_configuration * cfg)
+{
+ p_spu->i_original_picture_width = cfg->video_src->i_visible_width;
+ p_spu->i_original_picture_height = cfg->video_src->i_visible_height;
+}
+
/*****************************************************************************
* OutputPicture:
*****************************************************************************
@@ -198,7 +205,15 @@ static void OutputPicture( decoder_t *p_dec,
uint16_t *p_pixeldata;
/* Allocate the subpicture internal data. */
- p_spu = decoder_NewSubpicture( p_dec, NULL );
+ static const struct vlc_spu_updater_ops spu_ops =
+ {
+ .update = UpdateDvdSpu,
+ };
+
+ static const subpicture_updater_t updater = {
+ .ops = &spu_ops,
+ };
+ p_spu = decoder_NewSubpicture( p_dec, &updater );
if( !p_spu ) return;
p_spu->i_original_picture_width =
=====================================
modules/codec/spudec/spudec.c
=====================================
@@ -82,6 +82,8 @@ static int OpenCommon( vlc_object_t *p_this, bool b_packetizer )
p_sys->b_packetizer = b_packetizer;
p_sys->b_disabletrans = var_InheritBool( p_dec, "dvdsub-transparency" );
p_sys->i_spu_size = 0;
+ p_sys->buffer = NULL;
+ p_sys->buffer_size = 0;
p_sys->i_spu = 0;
p_sys->p_block = NULL;
@@ -123,6 +125,7 @@ static void Close( vlc_object_t *p_this )
block_ChainRelease( p_sys->p_block );
}
+ free( p_sys->buffer );
free( p_sys );
}
@@ -143,8 +146,19 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
return VLCDEC_SUCCESS;
}
- /* FIXME: what the, we shouldn’t need to allocate 64k of buffer --sam. */
- p_sys->i_spu = block_ChainExtract( p_spu_block, p_sys->buffer, sizeof(p_sys->buffer) );
+ size_t block_size;
+ vlc_frame_ChainProperties( p_spu_block, NULL, &block_size, NULL );
+ if ( p_sys->buffer_size < block_size )
+ {
+ void *bigger = realloc( p_sys->buffer, block_size );
+ if ( unlikely(bigger == NULL) )
+ {
+ return VLCDEC_ECRITICAL;
+ }
+ p_sys->buffer = bigger;
+ p_sys->buffer_size = block_size;
+ }
+ p_sys->i_spu = block_ChainExtract( p_spu_block, p_sys->buffer, block_size );
p_sys->i_pts = p_spu_block->i_pts;
block_ChainRelease( p_spu_block );
=====================================
modules/codec/spudec/spudec.h
=====================================
@@ -34,8 +34,8 @@ typedef struct
block_t *p_block;
- /* We will never overflow */
- uint8_t buffer[65536];
+ uint8_t *buffer;
+ size_t buffer_size;
} decoder_sys_t;
/*****************************************************************************
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fbbd68f8cfcba72cfa8031b6539dc7a4445df7e2...6d94600fb6333ccdb8ac771becd433e9f471c364
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fbbd68f8cfcba72cfa8031b6539dc7a4445df7e2...6d94600fb6333ccdb8ac771becd433e9f471c364
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