[dvblast-devel] [PATCH] dvb/pes: Fix for PES payload offset

Vladimir Yakovlev nagos at inbox.ru
Sat Sep 15 18:16:55 CEST 2012


Size of optional header calculated as PES_header_data_length + 3
bytes. This 3 bytes is
(name  number of bits)
PES_scrambling_control  2
PES_priority    2
data_alignment_indicator        1
copyright       1
original_or_copy        1
PTS_DTS_flags   2
ESCR_flag       1
ES_rate_flag    1
DSM_trick_mode_flag     1
additional_copy_info_flag       1
PES_CRC_flag    1
PES_extension_flag      1
PES_header_data_length  8

PES_header_data_length is length of remainder of PES (PTS, DTS, stuffing).
In current version 3 bytes of this headers not accounted for.
I got this problem while tried to create a teletext PES stream.
Here is real PES packet from sattelite broadcast:

          0000:  00 00 01 bd 05 02 85 80  24 23 35 2f 4f 8b ff ff
........$#5/O...
          0010:  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
................
          0020:  ff ff ff ff ff ff ff ff  ff ff ff ff ff 10 02 2c
...............,
          0030:  e7 e4 85 1c 68 04 54 f4  f7 e0 23 4f ae e6 f7 04
....h.T...#O....
          0040:  b5 b5 b5 b5 b5 b5 b5 b5  b5 b5 b5 b5 b5 b5 b5 b5
................
          0050:  b5 b5 b5 b5 b5 7c 61 2c  ad 1c 04 04 02 2c e8 e4
.....|a,.....,..
          0060:  26 f4 68 04 54 f4 f4 e0  04 04 04 04 04 04 04 04
&.h.T...........
          0070:  04 04 04 04 04 04 04 04  04 04 04 04 04 04 04 04
................
          0080:  04 04 04 04 04 04 04 04  04 04 02 2c e9 e4 85 f4
...........,....
          0090:  68 54 54 f4 f7 e0 c2 86  76 d6 86 4f 57 a7 6e 04
hTT.....v..OW.n.
          00a0:  26 f7 b6 04 b5 b5 b5 b5  b5 b5 b5 b5 b5 b5 b5 b5
&...............
          00b0:  b5 7c 61 2c ad 9d 04 04                            .|a,....

PES_header_data_length: 36 (0x24)
PES_HEADER_SIZE + pes_get_headerlength(p_pes) = 6+36 = 42
while actual payload starts at 45 (bytes 10 02 2c).
You can get this TS file from
http://igorfuna.com/dvb-t/slovenia/multiplex-a-transport-stream-analysis
teletext on PID 162


2012/9/15 Georgi Chorbadzhiyski <gf at unixsol.org>:
> On 15.9.2012 г. 00:32, Vladimir Yakovlev wrote:
>>
>> In pes_payload was not accounted size of optional header,
>> only for actual data in PES_data_packet_header_length.
>> ---
>>   mpeg/pes.h |    3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mpeg/pes.h b/mpeg/pes.h
>> index 98a45f8..7aba4d4 100644
>> --- a/mpeg/pes.h
>> +++ b/mpeg/pes.h
>> @@ -49,6 +49,7 @@ extern "C"
>>   #define PES_HEADER_SIZE_NOPTS   9
>>   #define PES_HEADER_SIZE_PTS     14
>>   #define PES_HEADER_SIZE_PTSDTS  19
>> +#define PES_HEADER_OPTIONAL_SIZE   3
>>
>>   #define PES_STREAM_ID_MIN           0xbc
>>   #define PES_STREAM_ID_PRIVATE_1     0xbd
>> @@ -131,7 +132,7 @@ static inline bool pes_validate(const uint8_t *p_pes)
>>
>> *****************************************************************************/
>>   static inline uint8_t *pes_payload(uint8_t *p_pes)
>>   {
>> -    return p_pes + PES_HEADER_SIZE + pes_get_headerlength(p_pes);
>> +    return p_pes + PES_HEADER_SIZE + PES_HEADER_OPTIONAL_SIZE +
>> pes_get_headerlength(p_pes);
>>   }
>>
>>   #ifdef __cplusplus
>>
>
> Isn't optional size depending on a flag? I have to check the standard.
>
> --
> Georgi Chorbadzhiyski
> http://georgi.unixsol.org/
> _______________________________________________
> dvblast-devel mailing list
> dvblast-devel at videolan.org
> http://mailman.videolan.org/listinfo/dvblast-devel


More information about the dvblast-devel mailing list