[vlc-commits] [Git][videolan/vlc][master] 14 commits: demux: ps: add defines for packet ID values
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sat Sep 6 08:59:44 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
8c2f94fd by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: add defines for packet ID values
- - - - -
db15b02d by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use the packet ID mask to check track IDs
- - - - -
06698847 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use packet ID mask to check for type of track
- - - - -
c0e2a4ad by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use MLP packet IDs to check detect AOB or VOB
- - - - -
ee6f973d by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use packet ID masks based on the stream type
- - - - -
1c7d2fe0 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use stream ID defines to check packet header type
- - - - -
f7fd7a0b by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use VOB/AOB MLP packet IDs for detection
- - - - -
6c8f9130 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: pes: document magic value
- - - - -
a7ff6e36 by Steve Lhomme at 2025-09-06T08:21:18+00:00
dvdread: use VOB packet ID mask to get stream ID
- - - - -
abfa46e8 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: share PS_SPU_ID_OFFSET
- - - - -
3408ae0c by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: make the SPU offset explictely shifted for VOB
- - - - -
aae31257 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: use the mask to shift extended streams IDs
- - - - -
b3e26868 by Steve Lhomme at 2025-09-06T08:21:18+00:00
demux: ps: simplify else after return
- - - - -
49636827 by Steve Lhomme at 2025-09-06T08:21:18+00:00
access: dvd: don't pass 0 as a pointer
- - - - -
6 changed files:
- modules/access/dvdnav.c
- modules/access/dvdread.c
- modules/demux/mpeg/pes.h
- modules/demux/mpeg/ps.c
- modules/demux/mpeg/ps.h
- modules/demux/vobsub.c
Changes:
=====================================
modules/access/dvdnav.c
=====================================
@@ -66,8 +66,6 @@ dvdnav_status_t dvdnav_jump_to_sector_by_time(dvdnav_t *, uint64_t, int32_t);
#include "disc_helper.h"
-#define PS_SPU_ID_OFFSET 0xbd20
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
@@ -1595,7 +1593,7 @@ static void ESNew( demux_t *p_demux, int i_id )
if( tk->b_configured ) return;
- if( ps_track_fill( tk, 0, i_id, NULL, 0, true ) )
+ if( ps_track_fill( tk, NULL, i_id, NULL, 0, true ) )
{
msg_Warn( p_demux, "unknown codec for id=0x%x", i_id );
return;
=====================================
modules/access/dvdread.c
=====================================
@@ -821,7 +821,7 @@ static void ESNew( demux_t *p_demux, int i_id, int i_lang )
if( tk->b_configured ) return;
- if( ps_track_fill( tk, 0, i_id, NULL, 0, true ) )
+ if( ps_track_fill( tk, NULL, i_id, NULL, 0, true ) )
{
msg_Warn( p_demux, "unknown codec for id=0x%x", i_id );
return;
@@ -1092,17 +1092,17 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
switch( p_vts->vtsi_mat->vts_audio_attr[i - 1].audio_format )
{
case 0x00: /* A52 */
- i_id = (0x80 + i_position) | 0xbd00;
+ i_id = (0x80 + i_position) | PS_PACKET_ID_MASK_VOB;
break;
case 0x02:
case 0x03: /* MPEG audio */
i_id = 0xc000 + i_position;
break;
case 0x04: /* LPCM */
- i_id = (0xa0 + i_position) | 0xbd00;
+ i_id = (0xa0 + i_position) | PS_PACKET_ID_MASK_VOB;
break;
case 0x06: /* DTS */
- i_id = (0x88 + i_position) | 0xbd00;
+ i_id = (0x88 + i_position) | PS_PACKET_ID_MASK_VOB;
break;
default:
i_id = 0;
@@ -1154,7 +1154,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
i_position = ( i_spu_control >> 24 ) & 0x7F;
}
- i_id = (0x20 + i_position) | 0xbd00;
+ i_id = (0x20 + i_position) | PS_PACKET_ID_MASK_VOB;
ESNew( p_demux, i_id, p_sys->p_vts_file->vtsi_mat->
vts_subp_attr[i - 1].lang_code );
=====================================
modules/demux/mpeg/pes.h
=====================================
@@ -125,6 +125,8 @@ static int ParsePESHeader( struct vlc_logger *p_logger, const uint8_t *p_header,
if( ( p_header[6]&0xC0 ) == 0x80 )
{
/* mpeg2 PES */
+ // 9 = syncword(3), stream ID(1), length(2), MPEG2 PES(1), flags(1), header_len(1)
+ // p_header[8] = header_len(1)
i_skip = p_header[8] + 9;
h->b_scrambling = p_header[6]&0x30;
=====================================
modules/demux/mpeg/ps.c
=====================================
@@ -544,16 +544,16 @@ static int Demux( demux_t *p_demux )
{
int i_id = ps_pkt_id( p_pkt->p_buffer, p_pkt->i_buffer, p_sys->source );
/* Small heuristic to improve MLP detection from AOB */
- if( i_id == 0xa001 &&
+ if( i_id == PS_AOB_PACKET_ID_MLP &&
p_sys->i_aob_mlp_count < 500 )
{
p_sys->i_aob_mlp_count++;
}
- else if( i_id == 0xbda1 &&
+ else if( i_id == PS_VOB_PACKET_ID_MLP &&
p_sys->i_aob_mlp_count > 0 )
{
p_sys->i_aob_mlp_count--;
- i_id = 0xa001;
+ i_id = PS_AOB_PACKET_ID_MLP;
}
bool b_new = false;
=====================================
modules/demux/mpeg/ps.h
=====================================
@@ -28,27 +28,38 @@
#define PS_STREAM_ID_PACK_HEADER 0xBA
#define PS_STREAM_ID_SYSTEM_HEADER 0xBB
+#define PS_PACKET_ID_MASK_VOB 0xBD00
+#define PS_PACKET_ID_MASK_AOB 0xA000
+#define PS_PACKET_ID_MASK_EXTENDED 0xFD00
+
+/* 0xBD20 + 0x00 to 0x1f */
+#define PS_SPU_ID_OFFSET (PS_PACKET_ID_MASK_VOB | 0x20)
+
+#define PS_AOB_PACKET_ID_LPCM (PS_PACKET_ID_MASK_AOB | 0x00)
+#define PS_AOB_PACKET_ID_MLP (PS_PACKET_ID_MASK_AOB | 0x01)
+#define PS_VOB_PACKET_ID_MLP (PS_PACKET_ID_MASK_VOB | 0xA1)
+
enum ps_source {
PS_SOURCE_UNKNOWN, // any PS/PES source
PS_SOURCE_VOB, // when reading a DVD-Video
PS_SOURCE_AOB, // when reading a DVD-Audio
};
-/* 256-0xC0 for normal stream, 256 for 0xbd stream, 256 for 0xfd stream, 8 for 0xa0 AOB stream */
+/* 256-0xC0 for normal stream, 256 for VOB stream, 256 for EVOB stream, 8 for AOB stream */
#define PS_TK_COUNT (256+256+256+8 - 0xc0)
static inline unsigned ps_id_to_tk( unsigned i_id )
{
assert(i_id >= 0xc0);
if(unlikely(i_id < 0xc0))
return 0;
- else if( i_id <= 0xff )
+ if( i_id <= 0xff )
return i_id - 0xc0;
- else if( (i_id & 0xff00) == 0xbd00 )
+ if( (i_id & 0xff00) == PS_PACKET_ID_MASK_VOB )
return 256-0xC0 + (i_id & 0xff);
- else if( (i_id & 0xff00) == 0xfd00 )
+ if( (i_id & 0xff00) == PS_PACKET_ID_MASK_EXTENDED )
return 512-0xc0 + (i_id & 0xff);
- else
- return 768-0xc0 + (i_id & 0x07);
+ assert( (i_id & 0xff00) == PS_PACKET_ID_MASK_AOB );
+ return 768-0xc0 + (i_id & 0x07);
}
typedef struct ps_psm_t ps_psm_t;
@@ -138,7 +149,7 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm,
tk->i_skip = 0;
tk->i_id = i_id;
- if( ( i_id&0xff00 ) == 0xbd00 ) /* 0xBD00 -> 0xBDFF, Private Stream 1 */
+ if( ( i_id&0xff00 ) == PS_PACKET_ID_MASK_VOB ) /* 0xBD00 -> 0xBDFF, VOB Private Stream 1 */
{
if( ( i_id&0xf8 ) == 0x88 || /* 0x88 -> 0x8f - Can be DTS-HD primary audio in evob */
( i_id&0xf8 ) == 0x98 ) /* 0x98 -> 0x9f - Can be DTS-HD secondary audio in evob */
@@ -201,7 +212,7 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm,
return VLC_EGENERIC;
}
}
- else if( (i_id&0xff00) == 0xfd00 ) /* 0xFD00 -> 0xFDFF */
+ else if( (i_id&0xff00) == PS_PACKET_ID_MASK_EXTENDED ) /* EVOB: 0xFD00 -> 0xFDFF */
{
uint8_t i_sub_id = i_id & 0xff;
if( ( i_sub_id >= 0x55 && i_sub_id <= 0x5f ) || /* Can be primary VC-1 in evob */
@@ -215,7 +226,7 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm,
return VLC_EGENERIC;
}
}
- else if( (i_id&0xff00) == 0xa000 ) /* 0xA000 -> 0xA0FF */
+ else if( (i_id&0xff00) == PS_PACKET_ID_MASK_AOB ) /* AOB: 0xA000 -> 0xA0FF */
{
uint8_t i_sub_id = i_id & 0x07;
if( i_sub_id == 0 )
@@ -333,7 +344,7 @@ static inline int ps_pkt_id( const uint8_t *p_pkt, size_t i_pkt, enum ps_source
{
if(unlikely(i_pkt < 4))
return 0;
- if( p_pkt[3] == 0xbd )
+ if( p_pkt[3] == STREAM_ID_PRIVATE_STREAM_1 )
{
uint8_t i_sub_id = 0;
if( i_pkt >= 9 &&
@@ -347,22 +358,22 @@ static inline int ps_pkt_id( const uint8_t *p_pkt, size_t i_pkt, enum ps_source
p_pkt[i_start + 6] != 0x80 )
{
/* AOB LPCM extension */
- return 0xa000 | (i_sub_id & 0x01);
+ return PS_PACKET_ID_MASK_AOB | (i_sub_id & 0x01);
}
if( i_sub_id == 0xa1 &&
source == PS_SOURCE_AOB )
{
/* AOB MLP extension */
- return 0xa000 | (i_sub_id & 0x01);
+ return PS_PACKET_ID_MASK_AOB | (i_sub_id & 0x01);
}
}
/* VOB extension */
- return 0xbd00 | i_sub_id;
+ return PS_PACKET_ID_MASK_VOB | i_sub_id;
}
- else if( i_pkt >= 9 &&
- p_pkt[3] == 0xfd &&
+ if( i_pkt >= 9 &&
+ p_pkt[3] == STREAM_ID_EXTENDED_STREAM_ID &&
(p_pkt[6]&0xC0) == 0x80 && /* mpeg2 */
(p_pkt[7]&0x01) == 0x01 ) /* extension_flag */
{
@@ -410,7 +421,7 @@ static inline int ps_pkt_id( const uint8_t *p_pkt, size_t i_pkt, enum ps_source
{
int i_stream_id_extension_flag = (p_pkt[i_skip+1] >> 7)&0x1;
if( i_stream_id_extension_flag == 0 )
- return 0xfd00 | (p_pkt[i_skip+1]&0x7f);
+ return PS_PACKET_ID_MASK_EXTENDED | (p_pkt[i_skip+1]&0x7f);
}
}
}
@@ -434,7 +445,7 @@ static inline int ps_pkt_size( const uint8_t *p, int i_peek )
{
if( i_peek >= 14 && (p[4] >> 6) == 0x01 )
return 14 + (p[13]&0x07);
- else if( i_peek >= 12 && (p[4] >> 4) == 0x02 )
+ if( i_peek >= 12 && (p[4] >> 4) == 0x02 )
return 12;
}
break;
@@ -492,7 +503,7 @@ static inline int ps_pkt_parse_system( const uint8_t *p_pkt, size_t i_pkt,
case 0xB7:
if( p_pktend - p < 6 )
return VLC_EGENERIC;
- i_id = ((int)STREAM_ID_EXTENDED_STREAM_ID << 8) | (p[2] & 0x7F);
+ i_id = PS_PACKET_ID_MASK_EXTENDED | (p[2] & 0x7F);
p += 6;
break;
default:
@@ -530,8 +541,8 @@ static inline int ps_pkt_parse_pes( vlc_object_t *p_object, block_t *p_pes, int
if( i_skip_extra >= 0 )
i_skip += i_skip_extra;
else if( p_pes->i_buffer > i_skip + 3 &&
- ( ps_pkt_id( p_pes->p_buffer, p_pes->i_buffer, PS_SOURCE_AOB ) == 0xa001 ||
- ps_pkt_id( p_pes->p_buffer, p_pes->i_buffer, PS_SOURCE_VOB ) == 0xbda1 ) )
+ ( ps_pkt_id( p_pes->p_buffer, p_pes->i_buffer, PS_SOURCE_AOB ) == PS_AOB_PACKET_ID_MLP ||
+ ps_pkt_id( p_pes->p_buffer, p_pes->i_buffer, PS_SOURCE_VOB ) == PS_VOB_PACKET_ID_MLP ) )
i_skip += 4 + p_pes->p_buffer[i_skip+3];
if( p_pes->i_buffer <= i_skip )
=====================================
modules/demux/vobsub.c
=====================================
@@ -653,7 +653,7 @@ static int DemuxVobSub( demux_t *p_demux, block_t *p_bk )
}
i_id = ps_pkt_id( p, i_size, PS_SOURCE_VOB );
- if( (i_id&0xffe0) != 0xbd20 )
+ if( (i_id&0xffe0) != PS_SPU_ID_OFFSET )
{
/* msg_Dbg( p_demux, "we don't need these ps packets (id=0x1%2.2x)", p[3] ); */
p += i_size;
@@ -672,7 +672,7 @@ static int DemuxVobSub( demux_t *p_demux, block_t *p_bk )
block_Release( p_pkt );
continue;
}
- i_spu = i_id&0x1f;
+ i_spu = i_id & ~PS_SPU_ID_OFFSET;
/* msg_Dbg( p_demux, "SPU track %d size %d", i_spu, i_size ); */
for( i = 0; i < p_sys->i_tracks; i++ )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ee40fe3eea7b442ba29cad14d6addb0f78126d29...49636827b8b95a396e94a8ebc0aa236dad4afa32
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ee40fe3eea7b442ba29cad14d6addb0f78126d29...49636827b8b95a396e94a8ebc0aa236dad4afa32
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