From patchwork Thu Sep 27 19:18:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alx.sukhanov@gmail.com X-Patchwork-Id: 10506 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp2383818jap; Thu, 27 Sep 2018 12:58:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZhwqHlIaP7MJeK2RUXQn/S1qCfNN3KHaZ2AeKxubnqf60jJ7H71G5k8VS+FZuF9yAeoOR X-Received: by 2002:adf:ad65:: with SMTP id p92-v6mr9379027wrc.7.1538078339472; Thu, 27 Sep 2018 12:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538078339; cv=none; d=google.com; s=arc-20160816; b=nQw16Px7KKTBSTP4eASt+hc4MxrXv6giGXKkudapg9Vcsv/y7tmDjzMQh/sqU7GheU cHATcvJd23aoff594fABWTknqg69/OkNlthvmL8uviUC3yoEu8P7iV7JwHawvT97oiCq vmMsj5vRg99MqwUU4+27BfSiLK79fPwCxhswAw9NUyciZCitGJRv2h8DrEymcsMt0znu GiQYj1eBgTRbs1F/4vDiIb1PxjTvKgstjMhGH733oUuVB2bDZ4y3nlA+JkG/jf5mH8+6 c7fUz0A87TIeBXTx7UFzKYXe3gavy15JwQhp0lrvbjjF6h1K44xYup0c/dlEPxome+jB j/ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=ZknPSR7FRduskryHZGDINIsMt3km2zQB9TuG/FF1sZo=; b=hS5tax75f/fWwf0Il3rSuNTrZ+cEpQqVlhuTeMwE+9qwSG+knwQhAD58+tq+sRO24X dZBO+7T6hQyrNH1GGvnw9CLeDeKwbmJNf/zFqnvXC1IWX7YAcil7EHkbKb3LyUCkWmuJ 0gBqaAM6BqNqGWIvf1jCvOQ6pBYTY5CboRjmos3/3Z78J564ZFZVfIDgO7LevRS7lqBw E8caf+xiDZ/BZbCIuV9JUw3o6nMDglFKwVykhgYnIUlgxY7CP6TNltxQCog/+WpMUuYV Sw1afXsDhqDdFvmGlAi83zDf6Hwfkbwxr0N1hY+LfSAwM2Hq1MNHlyEmvMHeQEmCAllh LOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=hJlll7AY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e12-v6si1261711wrq.414.2018.09.27.12.58.59; Thu, 27 Sep 2018 12:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=hJlll7AY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 408C568A551; Thu, 27 Sep 2018 22:58:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 20D7B689F35 for ; Thu, 27 Sep 2018 22:18:34 +0300 (EEST) Received: by mail-pf1-f195.google.com with SMTP id p12-v6so2592387pfh.2 for ; Thu, 27 Sep 2018 12:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jNY6GHZ0HTHfeEqYjagxqtKaSahDeQCssuhvHXgShiQ=; b=hJlll7AYzAdOsCMbvuBSGzrEL/wTqKus9sy6geso5j0l/if92KfqxrfnaIQZsdHvtp gVaqrwy5WezgOmSTtD9cypcW23poBbmlu0/f1ap6WsIRfyeei3kCtL3zJx8ndKW/srwO B7BmAZ197TC9Ow+oEekjtPjQ6ieCj/qfEz7o7zDCoVqvhzajGBP3g/qOs2cUX/bG8DXo iEjGAxLjWQL4pXMOyj/X/BccsEpxZpSPm4UCZbuiykelkJh6O9fGGV8uMpuAK9asgU48 NYDPpLLrPHHBf4XEYetJV1N5snCrmvmSZW+L9k/4vV7bTBrJPaLzAR/RnG8oVus790RD j1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jNY6GHZ0HTHfeEqYjagxqtKaSahDeQCssuhvHXgShiQ=; b=Gd45P10V6JSJMrAU3PiZZMXKX0qlvy9XAR8Qw4wWDY9DZ/Yi+hQWCdPW1xjniw4V8G elEFfbTBHBHqV03GCYeDuWfPb8M7nARq9TmDkAKYEZoUo88Dgpkxf948bMncv3KZYUJ2 R3XhX/6C3qajNQLeBKG0uf0h9oHyNz8yC0EbGpwwQLFZtua8ME2engeFxRfqIH8sIWB8 08zKhyBkrQ0ptUB9GK9M1KEvxx0llGS9vGaylZc4p7+eapzKq55fecCYTqh/9bPyDitO PIKAfWbmRu4gks13c/ibS7KJxBZSO8nmEYlBNLE/kaUZS6lfPIQFNpkbgt+0DQ67vPtp ykbg== X-Gm-Message-State: ABuFfoiWsi3UJiJ9wAbxHT+a3yYLwMjjrwTK209FW/2YRenNiLqqTqNC qYSCr7eJo+4BMKUqhOun0j2vgZIN X-Received: by 2002:a17:902:bd97:: with SMTP id q23-v6mr9097005pls.266.1538075928911; Thu, 27 Sep 2018 12:18:48 -0700 (PDT) Received: from asukhanov3.mtv.corp.google.com ([2620:0:1000:2100:c9c9:3b4c:c6b7:7c22]) by smtp.gmail.com with ESMTPSA id n80-v6sm7591414pfh.166.2018.09.27.12.18.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 12:18:47 -0700 (PDT) From: alx.sukhanov@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Sep 2018 12:18:42 -0700 Message-Id: <20180927191842.128159-1-alx.sukhanov@gmail.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 27 Sep 2018 22:58:40 +0300 Subject: [FFmpeg-devel] [PATCH] avformat: add H264 and HEVC support in IVF muxer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Alex Sukhanov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Alex Sukhanov --- libavformat/ivfenc.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index 66441a2a43..9ff7894b88 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -38,17 +38,31 @@ static int ivf_write_header(AVFormatContext *s) par = s->streams[0]->codecpar; if (par->codec_type != AVMEDIA_TYPE_VIDEO || !(par->codec_id == AV_CODEC_ID_AV1 || + par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_VP8 || par->codec_id == AV_CODEC_ID_VP9)) { - av_log(s, AV_LOG_ERROR, "Currently only VP8, VP9 and AV1 are supported!\n"); + av_log(s, AV_LOG_ERROR, "Currently only H264, VP8, VP9 and AV1 are supported!\n"); return AVERROR(EINVAL); } avio_write(pb, "DKIF", 4); avio_wl16(pb, 0); // version avio_wl16(pb, 32); // header length - avio_wl32(pb, - par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") : - par->codec_id == AV_CODEC_ID_VP8 ? AV_RL32("VP80") : AV_RL32("AV01")); + switch (par->codec_id) { + case AV_CODEC_ID_AV1: + avio_wl32(pb, AV_RL32("AV01")); + break; + case AV_CODEC_ID_H264: + avio_wl32(pb, AV_RL32("H264")); + break; + case AV_CODEC_ID_VP8: + avio_wl32(pb, AV_RL32("VP80")); + break; + case AV_CODEC_ID_VP9: + avio_wl32(pb, AV_RL32("VP90")); + break; + default: + break; + } avio_wl16(pb, par->width); avio_wl16(pb, par->height); avio_wl32(pb, s->streams[0]->time_base.den); @@ -95,8 +109,21 @@ static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) int ret = 1; AVStream *st = s->streams[pkt->stream_index]; - if (st->codecpar->codec_id == AV_CODEC_ID_VP9) + if (st->codecpar->codec_id == AV_CODEC_ID_H264) { + if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 && + (AV_RB24(pkt->data) != 0x000001 || + (st->codecpar->extradata_size > 0 && + st->codecpar->extradata[0] == 1))) + ret = ff_stream_add_bitstream_filter(st, "h264_mp4toannexb", NULL); + } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { + if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 && + (AV_RB24(pkt->data) != 0x000001 || + (st->codecpar->extradata_size > 0 && + st->codecpar->extradata[0] == 1))) + ret = ff_stream_add_bitstream_filter(st, "hevc_mp4toannexb", NULL); + } else if (st->codecpar->codec_id == AV_CODEC_ID_VP9) { ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL); + } return ret; }