libdvbpsi: decoding video stream descriptor bug
As it is written in the ISO/IEC 13818-1 standard the video stream descriptor has the following format:
video_stream_descriptor(){
//field number of bits
descriptor_tag 8
descriptor_length 8
multiple_frame_rate_flag 1
frame_rate_code 4
MPEG_1_only_flag 1
constrained_parameter_flag 1
still_picture_flag 1
if (MPEG_1_only_flag = = '0'){
profile_and_level_indication 8
chroma_format 2
frame_rate_extension_flag 1
reserved 5
}
}
The libdvbpsi function dvbpsi_DecodeVStreamDr decodes that descriptor, but here the field MPEG_1_only_flag is called b_mpeg2.
The problem is that b_mpeg2 must be inverse the MPEG_1_only_flag, but in the source
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? 1 : 0; which is in fact MPEG_1_only_flag.
The condition for aditional fields in the standard is if (MPEG_1_only_flag = = '0'){},
but in the source it is if((!p_decoded->b_mpeg2 && (p_descriptor->i_length != 1) || (p_decoded->b_mpeg2 && (p_descriptor->i_length != 3))) which causes an error in decoding a correct descriptor;
So dvbpsi cannot decode a video stream descriptor.
The bug could be corrected by replacing:
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? 1 : 0;
with
p_decoded->b_mpeg2 = !((p_descriptor->p_data[0] & 0x04) ? 1 : 0);