Revision 1c4df2ab

View differences:

libavformat/mpegts.c
923 923
                    pes->header[2] == 0x01) {
924 924
                    /* it must be an mpeg2 PES stream */
925 925
                    code = pes->header[3] | 0x100;
926
                    dprintf(pes->stream, "pid=%x pes_code=%#x\n", pes->pid, code);
927

  
928
                    if ((pes->st && pes->st->discard == AVDISCARD_ALL) ||
929
                        code == 0x1be) /* padding_stream */
930
                        goto skip;
926 931

  
927 932
                    /* stream not present in PMT */
928 933
                    if (!pes->st)
......
930 935
                    if (!pes->st)
931 936
                        return AVERROR(ENOMEM);
932 937

  
933
                    if (pes->st->discard == AVDISCARD_ALL ||
934
                        !((code >= 0x1c0 && code <= 0x1df) ||
935
                          (code >= 0x1e0 && code <= 0x1ef) ||
936
                          (code == 0x1bd) || (code == 0x1fd)))
937
                        goto skip;
938
                    pes->state = MPEGTS_PESHEADER_FILL;
939 938
                    pes->total_size = AV_RB16(pes->header + 4);
940 939
                    /* NOTE: a zero total size means the PES size is
941 940
                       unbounded */
942
                    pes->pes_header_size = pes->header[8] + 9;
941
                    if (!pes->total_size)
942
                        pes->total_size = MAX_PES_PAYLOAD;
943

  
944
                    /* allocate pes buffer */
945
                    pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
946
                    if (!pes->buffer)
947
                        return AVERROR(ENOMEM);
948

  
949
                    if (code != 0x1bc && code != 0x1bf && /* program_stream_map, private_stream_2 */
950
                        code != 0x1f0 && code != 0x1f1 && /* ECM, EMM */
951
                        code != 0x1ff && code != 0x1f2 && /* program_stream_directory, DSMCC_stream */
952
                        code != 0x1f8) {                  /* ITU-T Rec. H.222.1 type E stream */
953
                        pes->state = MPEGTS_PESHEADER_FILL;
954
                        pes->pes_header_size = pes->header[8] + 9;
955
                    } else {
956
                        pes->state = MPEGTS_PAYLOAD;
957
                        pes->data_index = 0;
958
                    }
943 959
                } else {
944 960
                    /* otherwise, it should be a table */
945 961
                    /* skip packet */
......
979 995
                    r += 5;
980 996
                }
981 997

  
982
                if (pes->total_size > pes->data_index - 6)
983
                    pes->total_size -= pes->data_index - 6;
984
                else
985
                    pes->total_size = MAX_PES_PAYLOAD;
986
                /* allocate pes buffer */
987
                pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
988
                if (!pes->buffer)
989
                    return AVERROR(ENOMEM);
990

  
991 998
                /* we got the full header. We parse it and get the payload */
992 999
                pes->state = MPEGTS_PAYLOAD;
993 1000
                pes->data_index = 0;

Also available in: Unified diff