Merge commit 'cabb1681697555e2c319c37c1f30f149207e9434'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 6 Aug 2013 13:11:55 +0000 (15:11 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 6 Aug 2013 13:11:55 +0000 (15:11 +0200)
* commit 'cabb1681697555e2c319c37c1f30f149207e9434':
  mpegts: Remove one memcpy per packet

Conflicts:
libavformat/mpegts.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/mpegts.c

@@@ -1941,7 -1778,8 +1946,8 @@@ static void finished_reading_packet(AVF
  static int handle_packets(MpegTSContext *ts, int nb_packets)
  {
      AVFormatContext *s = ts->stream;
 -    uint8_t packet[TS_PACKET_SIZE+FF_INPUT_BUFFER_PADDING_SIZE];
 +    uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
+     uint8_t *data;
      int packet_num, ret = 0;
  
      if (avio_tell(s->pb) != ts->last_pos) {
      packet_num = 0;
      memset(packet + TS_PACKET_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
      for(;;) {
 -        if (ts->stop_parse>0)
 -            break;
          packet_num++;
 -        if (nb_packets != 0 && packet_num >= nb_packets)
 +        if (nb_packets != 0 && packet_num >= nb_packets ||
 +            ts->stop_parse > 1) {
 +            ret = AVERROR(EAGAIN);
 +            break;
 +        }
 +        if (ts->stop_parse > 0)
              break;
-         ret = read_packet(s, packet, ts->raw_packet_size);
 +
+         ret = read_packet(s, packet, ts->raw_packet_size, &data);
          if (ret != 0)
              break;
-         ret = handle_packet(ts, packet);
+         ret = handle_packet(ts, data);
+         finished_reading_packet(s, ts->raw_packet_size);
          if (ret != 0)
              break;
      }
@@@ -2117,12 -1932,13 +2125,13 @@@ static int mpegts_read_header(AVFormatC
          nb_pcrs = 0;
          nb_packets = 0;
          for(;;) {
-             ret = read_packet(s, packet, ts->raw_packet_size);
+             ret = read_packet(s, packet, ts->raw_packet_size, &data);
              if (ret < 0)
 -                return -1;
 +                goto fail;
-             pid = AV_RB16(packet + 1) & 0x1fff;
+             pid = AV_RB16(data + 1) & 0x1fff;
              if ((pcr_pid == -1 || pcr_pid == pid) &&
-                 parse_pcr(&pcr_h, &pcr_l, packet) == 0) {
+                 parse_pcr(&pcr_h, &pcr_l, data) == 0) {
+                 finished_reading_packet(s, ts->raw_packet_size);
                  pcr_pid = pid;
                  packet_count[nb_pcrs] = nb_packets;
                  pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;