Revision 0a63a676 libavformat/matroskaenc.c

View differences:

libavformat/matroskaenc.c
785 785
{
786 786
    MatroskaMuxContext *mkv = s->priv_data;
787 787
    ByteIOContext *pb = s->pb;
788
    AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
788 789

  
789 790
    av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
790 791
           "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n",
......
794 795
    put_byte(pb, 0x80 | (pkt->stream_index + 1));     // this assumes stream_index is less than 126
795 796
    put_be16(pb, pkt->pts - mkv->cluster_pts);
796 797
    put_byte(pb, flags);
798
    if (codec->codec_id == CODEC_ID_H264 &&
799
        codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
800
        /* from x264 or from bytestream h264 */
801
        /* nal reformating needed */
802
        ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
803
    } else {
797 804
    put_buffer(pb, pkt->data, pkt->size);
805
    }
798 806
}
799 807

  
800 808
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
......
822 830
        av_md5_update(mkv->md5_ctx, pkt->data, FFMIN(200, pkt->size));
823 831
    }
824 832

  
825
    if (codec->codec_id == CODEC_ID_H264 &&
826
        codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
827
        /* from x264 or from bytestream h264 */
828
        /* nal reformating needed */
829
        int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
830
        if (ret < 0)
831
            return ret;
832
        assert(pkt->size);
833
    }
834

  
835 833
    if (codec->codec_type != CODEC_TYPE_SUBTITLE) {
836 834
        mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);
837 835
    } else if (codec->codec_id == CODEC_ID_SSA) {

Also available in: Unified diff