Revision 01d6bd52

View differences:

libavformat/mpegtsenc.c
775 775
static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
776 776
{
777 777
    AVStream *st = s->streams[pkt->stream_index];
778
    int len, size = pkt->size;
778
    int size = pkt->size;
779 779
    uint8_t *buf= pkt->data;
780 780
    uint8_t *data= NULL;
781 781
    MpegTSWriteStream *ts_st = st->priv_data;
......
818 818
        return 0;
819 819
    }
820 820

  
821
    if (ts_st->payload_pts == AV_NOPTS_VALUE) {
822
        ts_st->payload_dts = dts;
823
        ts_st->payload_pts = pts;
821
    if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) {
822
        mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
823
                         ts_st->payload_pts, ts_st->payload_dts);
824
        ts_st->payload_index = 0;
824 825
    }
825 826

  
826
    // audio
827
    while (size > 0) {
828
        len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index;
829
        if (len > size)
830
            len = size;
831
        memcpy(ts_st->payload + ts_st->payload_index, buf, len);
832
        buf += len;
833
        size -= len;
834
        ts_st->payload_index += len;
835
        if (ts_st->payload_index >= DEFAULT_PES_PAYLOAD_SIZE) {
836
            mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
837
                             ts_st->payload_pts, ts_st->payload_dts);
838
            ts_st->payload_pts = AV_NOPTS_VALUE;
839
            ts_st->payload_dts = AV_NOPTS_VALUE;
840
            ts_st->payload_index = 0;
841
        }
827
    if (!ts_st->payload_index) {
828
        ts_st->payload_pts = pts;
829
        ts_st->payload_dts = dts;
842 830
    }
843 831

  
832
    memcpy(ts_st->payload + ts_st->payload_index, buf, size);
833
    ts_st->payload_index += size;
834

  
844 835
    return 0;
845 836
}
846 837

  
tests/lavf.regression.ref
15 15
b3174e2db508564c1cce0b5e3c1bc1bd *./tests/data/b-lavf.mxf_d10
16 16
5330989 ./tests/data/b-lavf.mxf_d10
17 17
./tests/data/b-lavf.mxf_d10 CRC=0xc3f4f92e
18
da0d4fea54e7473e3cddb1607294c9e2 *./tests/data/b-lavf.ts
18
a1a799fe07b3b9944aad8455a9706c5f *./tests/data/b-lavf.ts
19 19
430144 ./tests/data/b-lavf.ts
20 20
./tests/data/b-lavf.ts CRC=0x133216c1
21 21
62c5aeb636fc82cf6ba6277d36e42cb5 *./tests/data/b-lavf.swf

Also available in: Unified diff