]> git.sesse.net Git - nageru/blobdiff - shared/mux.cpp
Add some asserts to track down pts/dts problems before we get crashes back from FFmpe...
[nageru] / shared / mux.cpp
index b9ca553ee1b2ac1731d1345cd7df8e0e162f308a..921605574d0a496841bc42215c4573b24faf3170 100644 (file)
@@ -59,9 +59,8 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
        avstream_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
        if (video_codec == CODEC_H264) {
                avstream_video->codecpar->codec_id = AV_CODEC_ID_H264;
-       } else if (video_codec == CODEC_NV12) {
-               avstream_video->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
-               avstream_video->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag(AV_PIX_FMT_NV12);
+       } else if (video_codec == CODEC_AV1) {
+               avstream_video->codecpar->codec_id = AV_CODEC_ID_AV1;
        } else {
                assert(video_codec == CODEC_MJPEG);
                avstream_video->codecpar->codec_id = AV_CODEC_ID_MJPEG;
@@ -84,7 +83,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
        avstream_video->codecpar->field_order = AV_FIELD_PROGRESSIVE;
 
        if (!video_extradata.empty()) {
-               avstream_video->codecpar->extradata = (uint8_t *)av_malloc(video_extradata.size());
+               avstream_video->codecpar->extradata = (uint8_t *)av_malloc(video_extradata.size() + AV_INPUT_BUFFER_PADDING_SIZE);
                avstream_video->codecpar->extradata_size = video_extradata.size();
                memcpy(avstream_video->codecpar->extradata, video_extradata.data(), video_extradata.size());
        }
@@ -165,6 +164,8 @@ Mux::~Mux()
 
 void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational timebase, int stream_index_override)
 {
+       assert(pts >= dts);
+
        AVPacket pkt_copy;
        av_init_packet(&pkt_copy);
        if (av_packet_ref(&pkt_copy, &pkt) < 0) {