libavformat/rtpdec.c:511: error: Null Dereference
  pointer `pkt->data` last assigned on line 510 could be null and is dereferenced by call to `memcpy()` at line 511, column 13.

libavformat/rtpdec.c:415:1: start of procedure rtp_parse_packet()
413.  * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
414.  */
415. int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
     ^
416.                      const uint8_t *buf, int len)
417. {

libavformat/rtpdec.c:419:5: 
417. {
418.     unsigned int ssrc, h;
419.     int payload_type, seq, ret, flags = 0;
         ^
420.     AVStream *st;
421.     uint32_t timestamp;

libavformat/rtpdec.c:422:5: 
420.     AVStream *st;
421.     uint32_t timestamp;
422.     int rv= 0;
         ^
423. 
424.     if (!buf) {

libavformat/rtpdec.c:424:10: Taking false branch
422.     int rv= 0;
423. 
424.     if (!buf) {
              ^
425.         /* return the next packets, if any */
426.         if(s->st && s->parse_packet) {

libavformat/rtpdec.c:450:9: Taking false branch
448.     }
449. 
450.     if (len < 12)
             ^
451.         return -1;
452. 

libavformat/rtpdec.c:453:9: Taking false branch
451.         return -1;
452. 
453.     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
             ^
454.         return -1;
455.     if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {

libavformat/rtpdec.c:455:9: Taking false branch
453.     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
454.         return -1;
455.     if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
             ^
456.         return rtcp_parse_packet(s, buf, len);
457.     }

libavformat/rtpdec.c:458:5: 
456.         return rtcp_parse_packet(s, buf, len);
457.     }
458.     payload_type = buf[1] & 0x7f;
         ^
459.     if (buf[1] & 0x80)
460.         flags |= RTP_FLAG_MARKER;

libavformat/rtpdec.c:459:9: Taking true branch
457.     }
458.     payload_type = buf[1] & 0x7f;
459.     if (buf[1] & 0x80)
             ^
460.         flags |= RTP_FLAG_MARKER;
461.     seq  = AV_RB16(buf + 2);

libavformat/rtpdec.c:460:9: 
458.     payload_type = buf[1] & 0x7f;
459.     if (buf[1] & 0x80)
460.         flags |= RTP_FLAG_MARKER;
             ^
461.     seq  = AV_RB16(buf + 2);
462.     timestamp = AV_RB32(buf + 4);

libavformat/rtpdec.c:461:5: 
459.     if (buf[1] & 0x80)
460.         flags |= RTP_FLAG_MARKER;
461.     seq  = AV_RB16(buf + 2);
         ^
462.     timestamp = AV_RB32(buf + 4);
463.     ssrc = AV_RB32(buf + 8);

libavutil/bswap.h:58:1: start of procedure av_bswap16()
  56. 
  57. #ifndef av_bswap16
  58. static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
      ^
  59. {
  60.     x= (x>>8) | (x<<8);

libavutil/bswap.h:60:5: 
  58. static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
  59. {
  60.     x= (x>>8) | (x<<8);
          ^
  61.     return x;
  62. }

libavutil/bswap.h:61:5: 
  59. {
  60.     x= (x>>8) | (x<<8);
  61.     return x;
          ^
  62. }
  63. #endif

libavutil/bswap.h:62:1: return from a call to av_bswap16
  60.     x= (x>>8) | (x<<8);
  61.     return x;
  62. }
      ^
  63. #endif
  64. 

libavformat/rtpdec.c:462:5: 
460.         flags |= RTP_FLAG_MARKER;
461.     seq  = AV_RB16(buf + 2);
462.     timestamp = AV_RB32(buf + 4);
         ^
463.     ssrc = AV_RB32(buf + 8);
464.     /* store the ssrc in the RTPDemuxContext */

libavutil/bswap.h:66:1: start of procedure av_bswap32()
  64. 
  65. #ifndef av_bswap32
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      ^
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:68:5: 
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  69.     x= (x>>16) | (x<<16);
  70.     return x;

libavutil/bswap.h:69:5: 
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
          ^
  70.     return x;
  71. }

libavutil/bswap.h:70:5: 
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
  70.     return x;
          ^
  71. }
  72. #endif

libavutil/bswap.h:71:1: return from a call to av_bswap32
  69.     x= (x>>16) | (x<<16);
  70.     return x;
  71. }
      ^
  72. #endif
  73. 

libavformat/rtpdec.c:463:5: 
461.     seq  = AV_RB16(buf + 2);
462.     timestamp = AV_RB32(buf + 4);
463.     ssrc = AV_RB32(buf + 8);
         ^
464.     /* store the ssrc in the RTPDemuxContext */
465.     s->ssrc = ssrc;

libavutil/bswap.h:66:1: start of procedure av_bswap32()
  64. 
  65. #ifndef av_bswap32
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      ^
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:68:5: 
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  69.     x= (x>>16) | (x<<16);
  70.     return x;

libavutil/bswap.h:69:5: 
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
          ^
  70.     return x;
  71. }

libavutil/bswap.h:70:5: 
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
  70.     return x;
          ^
  71. }
  72. #endif

libavutil/bswap.h:71:1: return from a call to av_bswap32
  69.     x= (x>>16) | (x<<16);
  70.     return x;
  71. }
      ^
  72. #endif
  73. 

libavformat/rtpdec.c:465:5: 
463.     ssrc = AV_RB32(buf + 8);
464.     /* store the ssrc in the RTPDemuxContext */
465.     s->ssrc = ssrc;
         ^
466. 
467.     /* NOTE: we can handle only one payload type */

libavformat/rtpdec.c:468:9: Taking false branch
466. 
467.     /* NOTE: we can handle only one payload type */
468.     if (s->payload_type != payload_type)
             ^
469.         return -1;
470. 

libavformat/rtpdec.c:471:5: 
469.         return -1;
470. 
471.     st = s->st;
         ^
472.     // only do something with this if all the rtp checks pass...
473.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))

libavformat/rtpdec.c:473:9: 
471.     st = s->st;
472.     // only do something with this if all the rtp checks pass...
473.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))
             ^
474.     {
475.         av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",

libavformat/rtpdec.c:135:1: start of procedure rtp_valid_packet_in_sequence()
  133. * returns 1 if we should handle this packet.
  134. */
  135. static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
       ^
  136. {
  137.     uint16_t udelta= seq - s->max_seq;

libavformat/rtpdec.c:137:5: 
  135. static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
  136. {
  137.     uint16_t udelta= seq - s->max_seq;
           ^
  138.     const int MAX_DROPOUT= 3000;
  139.     const int MAX_MISORDER = 100;

libavformat/rtpdec.c:138:5: 
  136. {
  137.     uint16_t udelta= seq - s->max_seq;
  138.     const int MAX_DROPOUT= 3000;
           ^
  139.     const int MAX_MISORDER = 100;
  140.     const int MIN_SEQUENTIAL = 2;

libavformat/rtpdec.c:139:5: 
  137.     uint16_t udelta= seq - s->max_seq;
  138.     const int MAX_DROPOUT= 3000;
  139.     const int MAX_MISORDER = 100;
           ^
  140.     const int MIN_SEQUENTIAL = 2;
  141. 

libavformat/rtpdec.c:140:5: 
  138.     const int MAX_DROPOUT= 3000;
  139.     const int MAX_MISORDER = 100;
  140.     const int MIN_SEQUENTIAL = 2;
           ^
  141. 
  142.     /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */

libavformat/rtpdec.c:143:8: Taking false branch
  141. 
  142.     /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */
  143.     if(s->probation)
              ^
  144.     {
  145.         if(seq==s->max_seq + 1) {

libavformat/rtpdec.c:157:16: Taking false branch
  155.             s->max_seq = seq;
  156.         }
  157.     } else if (udelta < MAX_DROPOUT) {
                      ^
  158.         // in order, with permissible gap
  159.         if(seq < s->max_seq) {

libavformat/rtpdec.c:164:16: Taking false branch
  162.         }
  163.         s->max_seq= seq;
  164.     } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {
                      ^
  165.         // sequence made a large jump...
  166.         if(seq==s->bad_seq) {

libavformat/rtpdec.c:176:5: 
  174.         // duplicate or reordered packet...
  175.     }
  176.     s->received++;
           ^
  177.     return 1;
  178. }

libavformat/rtpdec.c:177:5: 
  175.     }
  176.     s->received++;
  177.     return 1;
           ^
  178. }
  179. 

libavformat/rtpdec.c:178:1: return from a call to rtp_valid_packet_in_sequence
  176.     s->received++;
  177.     return 1;
  178. }
       ^
  179. 
  180. #if 0

libavformat/rtpdec.c:473:9: Taking false branch
471.     st = s->st;
472.     // only do something with this if all the rtp checks pass...
473.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))
             ^
474.     {
475.         av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",

libavformat/rtpdec.c:480:5: 
478.     }
479. 
480.     s->seq = seq;
         ^
481.     len -= 12;
482.     buf += 12;

libavformat/rtpdec.c:481:5: 
479. 
480.     s->seq = seq;
481.     len -= 12;
         ^
482.     buf += 12;
483. 

libavformat/rtpdec.c:482:5: 
480.     s->seq = seq;
481.     len -= 12;
482.     buf += 12;
         ^
483. 
484.     if (!st) {

libavformat/rtpdec.c:484:10: Taking false branch
482.     buf += 12;
483. 
484.     if (!st) {
              ^
485.         /* specific MPEG2TS demux support */
486.         ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);

libavformat/rtpdec.c:496:16: Taking false branch
494.         }
495.         return 0;
496.     } else if (s->parse_packet) {
                    ^
497.         rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
498.                              s->st, pkt, &timestamp, buf, len, flags);

libavformat/rtpdec.c:501:9: 
499.     } else {
500.         // at this point, the RTP header has been stripped;  This is ASSUMING that there is only 1 CSRC, which in't wise.
501.         switch(st->codec->codec_id) {
             ^
502.         case CODEC_ID_MP2:
503.         case CODEC_ID_MP3:

libavformat/rtpdec.c:502:9: Switch condition is true. Entering switch case
500.         // at this point, the RTP header has been stripped;  This is ASSUMING that there is only 1 CSRC, which in't wise.
501.         switch(st->codec->codec_id) {
502.         case CODEC_ID_MP2:
             ^
503.         case CODEC_ID_MP3:
504.             /* better than nothing: skip mpeg audio RTP header */

libavformat/rtpdec.c:505:17: Taking false branch
503.         case CODEC_ID_MP3:
504.             /* better than nothing: skip mpeg audio RTP header */
505.             if (len <= 4)
                     ^
506.                 return -1;
507.             h = AV_RB32(buf);

libavformat/rtpdec.c:507:13: 
505.             if (len <= 4)
506.                 return -1;
507.             h = AV_RB32(buf);
                 ^
508.             len -= 4;
509.             buf += 4;

libavutil/bswap.h:66:1: start of procedure av_bswap32()
  64. 
  65. #ifndef av_bswap32
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      ^
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:68:5: 
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  69.     x= (x>>16) | (x<<16);
  70.     return x;

libavutil/bswap.h:69:5: 
  67. {
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
          ^
  70.     return x;
  71. }

libavutil/bswap.h:70:5: 
  68.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  69.     x= (x>>16) | (x<<16);
  70.     return x;
          ^
  71. }
  72. #endif

libavutil/bswap.h:71:1: return from a call to av_bswap32
  69.     x= (x>>16) | (x<<16);
  70.     return x;
  71. }
      ^
  72. #endif
  73. 

libavformat/rtpdec.c:508:13: 
506.                 return -1;
507.             h = AV_RB32(buf);
508.             len -= 4;
                 ^
509.             buf += 4;
510.             av_new_packet(pkt, len);

libavformat/rtpdec.c:509:13: 
507.             h = AV_RB32(buf);
508.             len -= 4;
509.             buf += 4;
                 ^
510.             av_new_packet(pkt, len);
511.             memcpy(pkt->data, buf, len);

libavformat/rtpdec.c:510:13: 
508.             len -= 4;
509.             buf += 4;
510.             av_new_packet(pkt, len);
                 ^
511.             memcpy(pkt->data, buf, len);
512.             break;

libavcodec/avpacket.c:48:1: start of procedure av_new_packet()
  46. }
  47. 
  48. int av_new_packet(AVPacket *pkt, int size)
      ^
  49. {
  50.     uint8_t *data= NULL;

libavcodec/avpacket.c:50:5: 
  48. int av_new_packet(AVPacket *pkt, int size)
  49. {
  50.     uint8_t *data= NULL;
          ^
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:51:8: Taking true branch
  49. {
  50.     uint8_t *data= NULL;
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
             ^
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  53.     if (data){

libavcodec/avpacket.c:52:9: 
  50.     uint8_t *data= NULL;
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  53.     if (data){
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(unsigned int size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(unsigned int size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, unsigned int size)

libavcodec/avpacket.c:53:9: Taking false branch
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  53.     if (data){
              ^
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  55.     }else

libavcodec/avpacket.c:56:9: 
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  55.     }else
  56.         size=0;
              ^
  57. 
  58.     av_init_packet(pkt);

libavcodec/avpacket.c:58:5: 
  56.         size=0;
  57. 
  58.     av_init_packet(pkt);
          ^
  59.     pkt->data = data;
  60.     pkt->size = size;

libavcodec/avpacket.c:36:1: start of procedure av_init_packet()
    34. }
    35. 
    36. void av_init_packet(AVPacket *pkt)
        ^
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;

libavcodec/avpacket.c:38:5: 
    36. void av_init_packet(AVPacket *pkt)
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;
            ^
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;

libavcodec/avpacket.c:39:5: 
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;
    39.     pkt->dts   = AV_NOPTS_VALUE;
            ^
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;

libavcodec/avpacket.c:40:5: 
    38.     pkt->pts   = AV_NOPTS_VALUE;
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;
            ^
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:41:5: 
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;
            ^
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;

libavcodec/avpacket.c:42:5: 
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;
            ^
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;

libavcodec/avpacket.c:43:5: 
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;
            ^
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;

libavcodec/avpacket.c:44:5: 
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;
            ^
    45.     pkt->destruct= NULL;
    46. }

libavcodec/avpacket.c:45:5: 
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;
            ^
    46. }
    47. 

libavcodec/avpacket.c:46:1: return from a call to av_init_packet
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;
    46. }
        ^
    47. 
    48. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:59:5: 
  57. 
  58.     av_init_packet(pkt);
  59.     pkt->data = data;
          ^
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:60:5: 
  58.     av_init_packet(pkt);
  59.     pkt->data = data;
  60.     pkt->size = size;
          ^
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)

libavcodec/avpacket.c:61:5: 
  59.     pkt->data = data;
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;
          ^
  62.     if(!data)
  63.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:62:9: Taking true branch
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)
              ^
  63.         return AVERROR(ENOMEM);
  64.     return 0;

libavcodec/avpacket.c:63:9: 
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)
  63.         return AVERROR(ENOMEM);
              ^
  64.     return 0;
  65. }

libavcodec/avpacket.c:65:1: return from a call to av_new_packet
  63.         return AVERROR(ENOMEM);
  64.     return 0;
  65. }
      ^
  66. 
  67. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/rtpdec.c:511:13: 
509.             buf += 4;
510.             av_new_packet(pkt, len);
511.             memcpy(pkt->data, buf, len);
                 ^
512.             break;
513.         case CODEC_ID_MPEG1VIDEO:

int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
                     const uint8_t *buf, int len)
{
    unsigned int ssrc, h;
    int payload_type, seq, ret, flags = 0;
    AVStream *st;
    uint32_t timestamp;
    int rv= 0;
    if (!buf) {
        if(s->st && s->parse_packet) {
            timestamp = RTP_NOTS_VALUE;
            rv= s->parse_packet(s->ic, s->dynamic_protocol_context,
                                s->st, pkt, &timestamp, NULL, 0, flags);
            finalize_packet(s, pkt, timestamp);
            return rv;
        } else {
            if (s->read_buf_index >= s->read_buf_size)
                return -1;
            ret = ff_mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,
                                      s->read_buf_size - s->read_buf_index);
            if (ret < 0)
                return -1;
            s->read_buf_index += ret;
            if (s->read_buf_index < s->read_buf_size)
                return 1;
            else
                return 0;
        }
    }
    if (len < 12)
        return -1;
    if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
        return -1;
    if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
        return rtcp_parse_packet(s, buf, len);
    }
    payload_type = buf[1] & 0x7f;
    if (buf[1] & 0x80)
        flags |= RTP_FLAG_MARKER;
    seq  = AV_RB16(buf + 2);
    timestamp = AV_RB32(buf + 4);
    ssrc = AV_RB32(buf + 8);
    s->ssrc = ssrc;
    if (s->payload_type != payload_type)
        return -1;
    st = s->st;
    if(!rtp_valid_packet_in_sequence(&s->statistics, seq))
    {
        av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
               payload_type, seq, ((s->seq + 1) & 0xffff));
        return -1;
    }
    s->seq = seq;
    len -= 12;
    buf += 12;
    if (!st) {
        ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);
        if (ret < 0)
            return -1;
        if (ret < len) {
            s->read_buf_size = len - ret;
            memcpy(s->buf, buf + ret, s->read_buf_size);
            s->read_buf_index = 0;
            return 1;
        }
        return 0;
    } else if (s->parse_packet) {
        rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
                             s->st, pkt, &timestamp, buf, len, flags);
    } else {
        switch(st->codec->codec_id) {
        case CODEC_ID_MP2:
        case CODEC_ID_MP3:
            if (len <= 4)
                return -1;
            h = AV_RB32(buf);
            len -= 4;
            buf += 4;
            av_new_packet(pkt, len);
            memcpy(pkt->data, buf, len);
            break;
        case CODEC_ID_MPEG1VIDEO:
        case CODEC_ID_MPEG2VIDEO:
            if (len <= 4)
                return -1;
            h = AV_RB32(buf);
            buf += 4;
            len -= 4;
            if (h & (1 << 26)) {
                if (len <= 4)
                    return -1;
                buf += 4;
                len -= 4;
            }
            av_new_packet(pkt, len);
            memcpy(pkt->data, buf, len);
            break;
        default:
            av_new_packet(pkt, len);
            memcpy(pkt->data, buf, len);
            break;
        }
        pkt->stream_index = st->index;
    }
    finalize_packet(s, pkt, timestamp);
    return rv;
}
['int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,\n                     const uint8_t *buf, int len)\n{\n    unsigned int ssrc, h;\n    int payload_type, seq, ret, flags = 0;\n    AVStream *st;\n    uint32_t timestamp;\n    int rv= 0;\n    if (!buf) {\n        if(s->st && s->parse_packet) {\n            timestamp = RTP_NOTS_VALUE;\n            rv= s->parse_packet(s->ic, s->dynamic_protocol_context,\n                                s->st, pkt, &timestamp, NULL, 0, flags);\n            finalize_packet(s, pkt, timestamp);\n            return rv;\n        } else {\n            if (s->read_buf_index >= s->read_buf_size)\n                return -1;\n            ret = ff_mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,\n                                      s->read_buf_size - s->read_buf_index);\n            if (ret < 0)\n                return -1;\n            s->read_buf_index += ret;\n            if (s->read_buf_index < s->read_buf_size)\n                return 1;\n            else\n                return 0;\n        }\n    }\n    if (len < 12)\n        return -1;\n    if ((buf[0] & 0xc0) != (RTP_VERSION << 6))\n        return -1;\n    if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {\n        return rtcp_parse_packet(s, buf, len);\n    }\n    payload_type = buf[1] & 0x7f;\n    if (buf[1] & 0x80)\n        flags |= RTP_FLAG_MARKER;\n    seq  = AV_RB16(buf + 2);\n    timestamp = AV_RB32(buf + 4);\n    ssrc = AV_RB32(buf + 8);\n    s->ssrc = ssrc;\n    if (s->payload_type != payload_type)\n        return -1;\n    st = s->st;\n    if(!rtp_valid_packet_in_sequence(&s->statistics, seq))\n    {\n        av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\\n",\n               payload_type, seq, ((s->seq + 1) & 0xffff));\n        return -1;\n    }\n    s->seq = seq;\n    len -= 12;\n    buf += 12;\n    if (!st) {\n        ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);\n        if (ret < 0)\n            return -1;\n        if (ret < len) {\n            s->read_buf_size = len - ret;\n            memcpy(s->buf, buf + ret, s->read_buf_size);\n            s->read_buf_index = 0;\n            return 1;\n        }\n        return 0;\n    } else if (s->parse_packet) {\n        rv = s->parse_packet(s->ic, s->dynamic_protocol_context,\n                             s->st, pkt, &timestamp, buf, len, flags);\n    } else {\n        switch(st->codec->codec_id) {\n        case CODEC_ID_MP2:\n        case CODEC_ID_MP3:\n            if (len <= 4)\n                return -1;\n            h = AV_RB32(buf);\n            len -= 4;\n            buf += 4;\n            av_new_packet(pkt, len);\n            memcpy(pkt->data, buf, len);\n            break;\n        case CODEC_ID_MPEG1VIDEO:\n        case CODEC_ID_MPEG2VIDEO:\n            if (len <= 4)\n                return -1;\n            h = AV_RB32(buf);\n            buf += 4;\n            len -= 4;\n            if (h & (1 << 26)) {\n                if (len <= 4)\n                    return -1;\n                buf += 4;\n                len -= 4;\n            }\n            av_new_packet(pkt, len);\n            memcpy(pkt->data, buf, len);\n            break;\n        default:\n            av_new_packet(pkt, len);\n            memcpy(pkt->data, buf, len);\n            break;\n        }\n        pkt->stream_index = st->index;\n    }\n    finalize_packet(s, pkt, timestamp);\n    return rv;\n}', 'static av_always_inline av_const uint16_t av_bswap16(uint16_t x)\n{\n    x= (x>>8) | (x<<8);\n    return x;\n}', 'static av_always_inline av_const uint32_t av_bswap32(uint32_t x)\n{\n    x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);\n    x= (x>>16) | (x<<16);\n    return x;\n}', 'static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)\n{\n    uint16_t udelta= seq - s->max_seq;\n    const int MAX_DROPOUT= 3000;\n    const int MAX_MISORDER = 100;\n    const int MIN_SEQUENTIAL = 2;\n    if(s->probation)\n    {\n        if(seq==s->max_seq + 1) {\n            s->probation--;\n            s->max_seq= seq;\n            if(s->probation==0) {\n                rtp_init_sequence(s, seq);\n                s->received++;\n                return 1;\n            }\n        } else {\n            s->probation= MIN_SEQUENTIAL - 1;\n            s->max_seq = seq;\n        }\n    } else if (udelta < MAX_DROPOUT) {\n        if(seq < s->max_seq) {\n            s->cycles += RTP_SEQ_MOD;\n        }\n        s->max_seq= seq;\n    } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {\n        if(seq==s->bad_seq) {\n            rtp_init_sequence(s, seq);\n        } else {\n            s->bad_seq= (seq + 1) & (RTP_SEQ_MOD-1);\n            return 0;\n        }\n    } else {\n    }\n    s->received++;\n    return 1;\n}', 'int av_new_packet(AVPacket *pkt, int size)\n{\n    uint8_t *data= NULL;\n    if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)\n        data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);\n    if (data){\n        memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);\n    }else\n        size=0;\n    av_init_packet(pkt);\n    pkt->data = data;\n    pkt->size = size;\n    pkt->destruct = av_destruct_packet;\n    if(!data)\n        return AVERROR(ENOMEM);\n    return 0;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'void av_init_packet(AVPacket *pkt)\n{\n    pkt->pts   = AV_NOPTS_VALUE;\n    pkt->dts   = AV_NOPTS_VALUE;\n    pkt->pos   = -1;\n    pkt->duration = 0;\n    pkt->convergence_duration = 0;\n    pkt->flags = 0;\n    pkt->stream_index = 0;\n    pkt->destruct= NULL;\n}']