Skip to content
Snippets Groups Projects
Commit def4dea4 authored by François Cartegnie's avatar François Cartegnie :fingers_crossed: Committed by Hugo Beauzée-Luyssen
Browse files

demux: ps: add workarounds for hik imkh recordings

refs #25864

* Non standard mappings
* Non synchronized audio stream
parent d717dae8
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,7 @@ typedef struct
MPEG_PS = 0,
CDXA_PS,
PSMF_PS,
IMKH_PS,
} format;
int current_title;
......@@ -154,6 +155,13 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
if( GetDWBE( &p_peek[86] ) > 0 )
i_length = vlc_tick_from_samples( GetDWBE( &p_peek[92] ), GetDWBE( &p_peek[86] ));
}
else if( !memcmp( p_peek, "IMKH", 4 ) )
{
msg_Info( p_demux, "Detected Hikvision PVA header");
i_skip = 40;
format = IMKH_PS;
i_max_packets = 0;
}
else if( !memcmp( p_peek, "RIFF", 4 ) && !memcmp( &p_peek[8], "CDXA", 4 ) )
{
format = CDXA_PS;
......@@ -538,6 +546,16 @@ static int Demux( demux_t *p_demux )
if( !ps_track_fill( tk, &p_sys->psm, i_id,
p_pkt->p_buffer, p_pkt->i_buffer, false ) )
{
if( p_sys->format == IMKH_PS )
{
if( ps_id_to_type( &p_sys->psm , i_id ) == 0x91 )
{
tk->fmt.i_codec = VLC_CODEC_MULAW;
tk->fmt.audio.i_channels = 1;
tk->fmt.audio.i_rate = 8000;
}
}
else
/* No PSM and no probing yet */
if( p_sys->format == PSMF_PS )
{
......@@ -573,6 +591,7 @@ static int Demux( demux_t *p_demux )
/* The popular VCD/SVCD subtitling WinSubMux does not
* renumber the SCRs when merging subtitles into the PES */
if( tk->b_seen && !p_sys->b_bad_scr &&
p_sys->format == MPEG_PS &&
( tk->fmt.i_codec == VLC_CODEC_OGT ||
tk->fmt.i_codec == VLC_CODEC_CVD ) )
{
......@@ -627,6 +646,17 @@ static int Demux( demux_t *p_demux )
es_out_SetPCR( p_demux->out, p_pkt->i_pts );
}
if( p_sys->format == IMKH_PS )
{
/* Synchronization on NVR is always broken */
if( llabs( p_pkt->i_dts - p_sys->i_scr ) > VLC_TICK_FROM_SEC(2) )
{
p_pkt->i_pts = p_pkt->i_pts - p_pkt->i_dts;
p_pkt->i_dts = p_sys->i_scr;
p_pkt->i_pts += p_sys->i_scr;
}
}
if( tk->fmt.i_codec == VLC_CODEC_TELETEXT &&
p_pkt->i_pts == VLC_TICK_INVALID && p_sys->i_scr != VLC_TICK_INVALID )
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment