Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1 fix a few transport stream bugs

open
nobody
None
5
2001-02-26
2001-02-26
Jens Rosenboom
No

This patch should help to read transport stream files
with the library. (I used it for mpeg2divx DVB-streams
:-)

Discussion

  • Jens Rosenboom
    Jens Rosenboom
    2001-02-26

    Logged In: YES
    user_id=153859

    diff -r libmpeg3-1.2.3/mpeg3demux.c
    libmpeg3-1.2.3a/mpeg3demux.c
    81,84c81
    < /* get first byte */
    < pcr_flag = (mpeg3packet_read_char(demuxer) >> 4) &
    1;
    <
    < if(pcr_flag)
    ---
    > if (length>0)
    86,87c83,84
    < unsigned long clk_ref_base =
    mpeg3packet_read_int32(demuxer);
    < unsigned int clk_ref_ext =
    mpeg3packet_read_int16(demuxer);
    ---
    > /* get first byte */
    > pcr_flag = (mpeg3packet_read_char(demuxer) >> 4) &
    1;
    89,94c86
    < if (clk_ref_base > 0x7fffffff)
    < { /* correct for invalid numbers */
    < clk_ref_base = 0; /* ie. longer than 32
    bits when multiplied by 2 */
    < clk_ref_ext = 0; /* multiplied by 2
    corresponds to shift left 1 (<<=1) */
    < }
    < else
    ---
    > if(pcr_flag)
    96,98c88,103
    < clk_ref_base <<= 1; /* Create space for bit */
    < clk_ref_base |= (clk_ref_ext >> 15); /* Take
    bit */
    < clk_ref_ext &= 0x01ff; /* Only
    lower 9 bits */
    ---
    > unsigned long clk_ref_base =
    mpeg3packet_read_int32(demuxer);
    > unsigned int clk_ref_ext =
    mpeg3packet_read_int16(demuxer);
    >
    > if (clk_ref_base > 0x7fffffff)
    > { /* correct for invalid numbers */
    > clk_ref_base = 0; /* ie. longer than 32
    bits when multiplied by 2 */
    > clk_ref_ext = 0; /* multiplied by 2
    corresponds to shift left 1 (<<=1) */
    > }
    > else
    > {
    > clk_ref_base <<= 1; /* Create space for bit */
    > clk_ref_base |= (clk_ref_ext >> 15); /* Take
    bit */
    > clk_ref_ext &= 0x01ff; /* Only
    lower 9 bits */
    > }
    > demuxer->time = clk_ref_base + clk_ref_ext / 300;
    > if(length) mpeg3packet_skip(demuxer, length - 7);
    100,101c105,106
    < demuxer->time = clk_ref_base + clk_ref_ext / 300;
    < if(length) mpeg3packet_skip(demuxer, length - 7);
    ---
    > else
    > mpeg3packet_skip(demuxer, length - 1);
    103,104d107
    < else
    < mpeg3packet_skip(demuxer, length - 1);
    181a185,187
    > if(demuxer->read_all)
    > demuxer->astream_table[stream_id & 0x0f] = AUDIO_MPEG;
    > else
    196a203,205
    > if(demuxer->read_all)
    > demuxer->vstream_table[stream_id & 0x0f] = 1;
    > else
    223d231
    < stream_id = mpeg3packet_read_char(demuxer);
    225a234
    > stream_id = mpeg3packet_read_char(demuxer);
    diff -r libmpeg3-1.2.3/mpeg3title.c
    libmpeg3-1.2.3a/mpeg3title.c
    246c246
    < result = mpeg3io_seek(title->fs, title->total_bytes);
    ---
    > result = mpeg3io_seek(title->fs,
    title->total_bytes-(title->total_bytes%demuxer->packet_size));
    diff -r libmpeg3-1.2.3/video/getpicture.c
    libmpeg3-1.2.3a/video/getpicture.c
    581c581,582
    < mpeg3bits_showbits32_noptr(vstream) <=
    MPEG3_SLICE_MAX_START)
    ---
    > mpeg3bits_showbits32_noptr(vstream) <=
    MPEG3_SLICE_MAX_START &&
    > video->total_slice_buffers < MPEG3_MAX_CPUS)