Merge commit '8dca0877e3e1457e9ec79ffa1ead1135aabb791c'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 10 Aug 2014 18:34:28 +0000 (20:34 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 10 Aug 2014 18:34:28 +0000 (20:34 +0200)
* commit '8dca0877e3e1457e9ec79ffa1ead1135aabb791c':
  mpegts: Return proper error code on invalid input data

Conflicts:
libavformat/mpegtsenc.c

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

index 6ae2391480ec401aa6493bfad88eae3930ad6b07,b210b02b7510810fddd016ceb5365f3d38318dd3..1a54c1ad026c713708f3b3bde118aa69bdbde65c
@@@ -1155,33 -967,12 +1155,33 @@@ static void mpegts_write_pes(AVFormatCo
                  }
              }
          }
 -        memcpy(buf + TS_PACKET_SIZE - len, payload, len);
 +
 +        if (is_dvb_subtitle && payload_size == len) {
 +            memcpy(buf + TS_PACKET_SIZE - len, payload, len - 1);
 +            buf[TS_PACKET_SIZE - 1] = 0xff; /* end_of_PES_data_field_marker: an 8-bit field with fixed contents 0xff for DVB subtitle */
 +        } else {
 +            memcpy(buf + TS_PACKET_SIZE - len, payload, len);
 +        }
 +
          payload      += len;
          payload_size -= len;
 +        mpegts_prefix_m2ts_header(s);
          avio_write(s->pb, buf, TS_PACKET_SIZE);
      }
 -    avio_flush(s->pb);
 +    ts_st->prev_payload_key = key;
 +}
 +
 +int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
 +{
 +    if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
 +        if (!st->nb_frames) {
 +            av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
 +                   "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
-             return AVERROR(EINVAL);
++            return AVERROR_INVALIDDATA;
 +        }
 +        av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
 +    }
 +    return 0;
  }
  
  static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)