[vlc-commits] [Git][videolan/vlc][3.0.x] 11 commits: demux: ps: add defines for packet ID values
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Sep 8 07:29:30 UTC 2025
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
f03f3b29 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: add defines for packet ID values
(cherry picked from commit 8c2f94fd30497473a3a04c8ad79051223e8751c0)
- - - - -
83934933 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use the packet ID mask to check track IDs
(cherry picked from commit db15b02d8d92dba07e3b923f10c4ddbdfbb400c8)
- - - - -
ad9c14bb by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use packet ID mask to check for type of track
(cherry picked from commit 0669884799d9bc2715a01523bd004f2fb6e946f7)
- - - - -
c8c6b4d1 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use MLP packet IDs to check detect AOB or VOB
(cherry picked from commit c0e2a4ad7fccda0b3d771dfb0bc62eabbc773363)
- - - - -
39916c7e by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use packet ID masks based on the stream type
(cherry picked from commit ee6f973d6d0a2be7f49f737411dd94d13733d707) (edited)
edited:
- 3.0 use p_pkt->p_buffer in ps_pkt_id()
- - - - -
3bf1baa2 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use stream ID defines to check packet header type
(cherry picked from commit 1c7d2fe048810d29e1b2aa4e144b7945d29b3615) (edited)
edited:
- 3.0 has different names for the defines
- - - - -
6b668629 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: use VOB/AOB MLP packet IDs for detection
(cherry picked from commit f7fd7a0b159c5270818e6781622da399d2b85bdf) (edited)
edited:
- 3.0 had the tests on the same line
- - - - -
c9fd3684 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: pes: document magic value
(cherry picked from commit 6c8f9130b3c804f24d443493d4688ff18316f9fd)
- - - - -
ebf9dde3 by Steve Lhomme at 2025-09-08T06:24:47+00:00
dvdread: use VOB packet ID mask to get stream ID
(cherry picked from commit a7ff6e36163a421e788bfddda7c961d62a39a9b7)
- - - - -
f84aaa42 by Steve Lhomme at 2025-09-08T06:24:47+00:00
demux: ps: simplify else after return
(cherry picked from commit b3e2686885822234e477626d230f3779677c3ea5) (edited)
edited:
- the code around is slightly different
- - - - -
52607b44 by Steve Lhomme at 2025-09-08T06:24:47+00:00
access: dvd: don't pass 0 as a pointer
(cherry picked from commit 49636827b8b95a396e94a8ebc0aa236dad4afa32) (edited)
edited:
- 3.0 has one less parameter
- - - - -
5 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
Changes:
=====================================
modules/access/dvdnav.c
=====================================
@@ -1518,7 +1518,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, true ) )
+ if( ps_track_fill( tk, NULL, i_id, NULL, true ) )
{
msg_Warn( p_demux, "unknown codec for id=0x%x", i_id );
return;
=====================================
modules/access/dvdread.c
=====================================
@@ -696,7 +696,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, true ) )
+ if( ps_track_fill( tk, NULL, i_id, NULL, true ) )
{
msg_Warn( p_demux, "unknown codec for id=0x%x", i_id );
return;
@@ -968,17 +968,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;
@@ -1034,7 +1034,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
i_position = ( 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
=====================================
@@ -84,6 +84,8 @@ static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size
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;
if( pb_pes_scambling )
=====================================
modules/demux/mpeg/ps.c
=====================================
@@ -524,16 +524,16 @@ static int Demux( demux_t *p_demux )
{
int i_id = ps_pkt_id( p_pkt, 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
=====================================
@@ -35,24 +35,32 @@
#define PS_STREAM_ID_EXTENDED 0xFD
#define PS_STREAM_ID_DIRECTORY 0xFF
+#define PS_PACKET_ID_MASK_VOB 0xBD00
+#define PS_PACKET_ID_MASK_AOB 0xA000
+#define PS_PACKET_ID_MASK_EXTENDED 0xFD00
+
+#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 int ps_id_to_tk( unsigned i_id )
{
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;
@@ -131,7 +139,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 */
@@ -198,7 +206,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 */
@@ -212,7 +220,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 )
@@ -324,7 +332,7 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm,
/* return the id of a PES (should be valid) */
static inline int ps_pkt_id( block_t *p_pkt, enum ps_source source )
{
- if( p_pkt->p_buffer[3] == 0xbd )
+ if( p_pkt->p_buffer[3] == PS_STREAM_ID_PRIVATE_STREAM1 )
{
uint8_t i_sub_id = 0;
if( p_pkt->i_buffer >= 9 &&
@@ -338,21 +346,21 @@ static inline int ps_pkt_id( block_t *p_pkt, enum ps_source source )
p_pkt->p_buffer[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( p_pkt->p_buffer[3] == 0xfd &&
+ if( p_pkt->p_buffer[3] == PS_STREAM_ID_EXTENDED &&
p_pkt->i_buffer >= 9 &&
(p_pkt->p_buffer[6]&0xC0) == 0x80 && /* mpeg2 */
(p_pkt->p_buffer[7]&0x01) == 0x01 ) /* extension_flag */
@@ -401,7 +409,7 @@ static inline int ps_pkt_id( block_t *p_pkt, enum ps_source source )
{
int i_stream_id_extension_flag = (p_pkt->p_buffer[i_skip+1] >> 7)&0x1;
if( i_stream_id_extension_flag == 0 )
- return 0xfd00 | (p_pkt->p_buffer[i_skip+1]&0x7f);
+ return PS_PACKET_ID_MASK_EXTENDED | (p_pkt->p_buffer[i_skip+1]&0x7f);
}
}
}
@@ -425,7 +433,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;
@@ -520,7 +528,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, PS_SOURCE_AOB ) == 0xa001 || ps_pkt_id( p_pes, PS_SOURCE_VOB ) == 0xbda1 ) )
+ ( ps_pkt_id( p_pes, PS_SOURCE_AOB ) == PS_AOB_PACKET_ID_MLP ||
+ ps_pkt_id( p_pes, 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 )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6999a3c99ee8a335f3d3c72f884f4099a6a9b27d...52607b44a1ac1ecdcc847a35d2b075d669ab7c45
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6999a3c99ee8a335f3d3c72f884f4099a6a9b27d...52607b44a1ac1ecdcc847a35d2b075d669ab7c45
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