From patchwork Sat Jan 9 07:34:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 24852 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6F4CF44A8AC for ; Sat, 9 Jan 2021 09:34:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5509268A5CC; Sat, 9 Jan 2021 09:34:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C1CB368A5B4 for ; Sat, 9 Jan 2021 09:34:51 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id j1so6894646pld.3 for ; Fri, 08 Jan 2021 23:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FzvXwFq3ACbLYFlJ1fyDQ9BVhIXMdAAZSYLpXDYBdz0=; b=mPhDviFRpQhEeUMz62yx0GJFx8op7pfZBH0aFmNF1AjO+FMWfHWcyrG5z75a0ZbFZe 2Dsmo51qK2ELQPyRTzz5hRKigfr6T9ZP85ktI2xAPbsEY6RZB1IGw8GYCpmig2qdIfdP wJ86vmLd+o2l+wbkT/S1B59gzBTvZlBzGyYqSnMwE59fl1hj0Rzwu9q8HD0J32bNTVDN +YIobyPbRz5E2m9nJ7oyCiVgvgOQnfadlIfqn8Agz8Guae4FNVHysCmTO7crl943oyTj +C7bTQvoM6YRzwKh/NAG0arswF0wWfWpUxKWWebaX5aKlWuy7lUEoO3zNYm3jLBgNnAu dVkg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=FzvXwFq3ACbLYFlJ1fyDQ9BVhIXMdAAZSYLpXDYBdz0=; b=uWuM2/TqauT8ZoCIRObgnDxqQ1mpe9r32INBFJqSJO++7Q9LciJI5EX6ZjRxy5fKLQ ghBOYSy7ojmbn0ro46UWOwPSKGW763b1el12TePpL/crU+5XEPTY0gyk4cgt9Ezu+xsj JlheBBKz8/tWfsv++WlFB3UgbPiZB3ItjYQ9VFqBU8A5EQZ0l9ePnh+591EnE57EqMil imUzmR2vQ4nBdRt9+k+C3i2+E0eoUGA0mCrhh2JOX7XqOb3Vn1SB3ciJiuGn9yRbgHQZ 6KESVY/p85dfajGngm6z4b1XDZbNi99Lsv9CBkJVw/aXlcOdPRGnv+HbZpNqdFttzMWI oAVQ== X-Gm-Message-State: AOAM532uQcH0+PdvYKAYOuoZ7P1WZieVGgUojkdwYRbPNsPyJxBuFzGY h2Qqva5BY2UrRdYFgV0UZAKr1RJFvr5oiQ== X-Google-Smtp-Source: ABdhPJxsXO4IjKxeF/DtWbJyc34MWffVKGItHQwcIE03wrFJmHTQbjViyKYVZaP6F2DJX2sh/46PcA== X-Received: by 2002:a17:90a:5298:: with SMTP id w24mr7583374pjh.182.1610177690058; Fri, 08 Jan 2021 23:34:50 -0800 (PST) Received: from Guangxin-PC.localdomain (23.83.245.51.16clouds.com. [23.83.245.51]) by smtp.gmail.com with ESMTPSA id m15sm11640120pfa.72.2021.01.08.23.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 23:34:49 -0800 (PST) From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Jan 2021 15:34:13 +0800 Message-Id: <20210109073421.23721-4-nuomi2021@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109073421.23721-1-nuomi2021@gmail.com> References: <20210109073421.23721-1-nuomi2021@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 03/11] avformat: add vvc raw demux 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: Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/vvcdec.c | 61 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 libavformat/vvcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 3a8fbcbe5f..4a5406da38 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -563,6 +563,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o OBJS-$(CONFIG_VPK_DEMUXER) += vpk.o OBJS-$(CONFIG_VPLAYER_DEMUXER) += vplayerdec.o subtitles.o OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o +OBJS-$(CONFIG_VVC_DEMUXER) += vvcdec.o rawdec.o OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0e0caaad39..fdbf424e31 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -462,6 +462,7 @@ extern AVOutputFormat ff_voc_muxer; extern AVInputFormat ff_vpk_demuxer; extern AVInputFormat ff_vplayer_demuxer; extern AVInputFormat ff_vqf_demuxer; +extern AVInputFormat ff_vvc_demuxer; extern AVInputFormat ff_w64_demuxer; extern AVOutputFormat ff_w64_muxer; extern AVInputFormat ff_wav_demuxer; diff --git a/libavformat/vvcdec.c b/libavformat/vvcdec.c new file mode 100644 index 0000000000..149f39f28e --- /dev/null +++ b/libavformat/vvcdec.c @@ -0,0 +1,61 @@ +/* + * RAW VVC video demuxer + * Copyright (c) 2020 Nuo Mi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vvc.h" + +#include "avformat.h" +#include "rawdec.h" + +static int vvc_probe(const AVProbeData *p) +{ + uint32_t code = -1; + int sps = 0, pps = 0, irap = 0; + int i; + + for (i = 0; i < p->buf_size - 1; i++) { + code = (code << 8) + p->buf[i]; + if ((code & 0xffffff00) == 0x100) { + uint8_t nal2 = p->buf[i + 1]; + int type = (nal2 & 0xF8) >> 3; + + if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit + return 0; + + if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1 + return 0; + + switch (type) { + case VVC_SPS_NUT: sps++; break; + case VVC_PPS_NUT: pps++; break; + case VVC_IDR_N_LP: + case VVC_IDR_W_RADL: + case VVC_CRA_NUT: + case VVC_GDR_NUT: irap++; break; + } + } + } + + if (sps && pps && irap) + return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg + return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe, "h266,266,vvc", AV_CODEC_ID_VVC)