From patchwork Tue Aug 21 23:54:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hwren X-Patchwork-Id: 10051 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp166529jap; Tue, 21 Aug 2018 16:54:52 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb4h/GlawEzABMs9nHhaxMAnvay0BpPLG4ZFZp1zgMeZ+xEaPxADLR3lcjmAYI/0bQTK26s X-Received: by 2002:a1c:dc8b:: with SMTP id t133-v6mr955920wmg.50.1534895692828; Tue, 21 Aug 2018 16:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534895692; cv=none; d=google.com; s=arc-20160816; b=AIbeEFiiC5cmWmECR6OPsJZCuOs4T9Z9hMOdtx8ot8SPxjSLsX8D7R3qn7uVb5xVlH R2KqBU66onQ2eYt0z1WS9AQDXw/69CswHb1AC6jlLWwwJffW1qp1zWurILbx9w8hwkAH 7p+Gdk/8j40CxiOu92bHqF3adNMNjy0XVTMl4anPJbjTbrnG6C/IdKoGyTWD4dKA0eNd 2HNI5jQ9jP9Vn4VLIKI8VLYcMh+pRRPXrmrncdm1KdCS3M/wmT1y2gADvrn8hE6+YlSc EoF9ihXFRWf0mRBuMDRuExbECZbdsm5uS5YH/LbrXzMJhZnfx2Zi/Ma8+yUbj5wX0bjm 7EAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:message-id:mime-version:references:in-reply-to :to:from:date:dkim-signature:delivered-to:arc-authentication-results; bh=qicxjROXkCcoyisHJ8FDzjvDtlidZ4UXcHMp7ZoPUTY=; b=eru7syfJyeBkDiS8s06DA9xq59+GgNvum2hga16fP0oQZkg7ouZqLdV6QvvhhK02wK kZl7+g4vnwv1z2bcio1NQlUOL33W7DO6T+W8PHZBuxDbdq9DpyP30FLA+oD4cwGL8ePf s7xP2+H2/OSHJ2/Qewf8AbQpguKO5sIfMJqfoJn52T8VnVqXrQwjMhuObM6V9y4PeBhV ew3kr1IePyP6HN1N57M7QnNizJSbkOy6xIRCZjvVcDOHRUUx87fJ+1bqhFl6EVxe5/4K 2C2XvwH0ompfYFPHmP1CR7LfeNcUULs1oB5ismXTjF5r4IXYlClxvdTwwM82rfqBF/6w r9wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@126.com header.s=s110527 header.b=EECjVNWQ; 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=NONE dis=NONE) header.from=126.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e9-v6si98508wrc.392.2018.08.21.16.54.52; Tue, 21 Aug 2018 16:54:52 -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=@126.com header.s=s110527 header.b=EECjVNWQ; 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=NONE dis=NONE) header.from=126.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E23C2689B55; Wed, 22 Aug 2018 02:54:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from m15-201.126.com (m15-214.126.com [220.181.15.214]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D6144680AF5 for ; Wed, 22 Aug 2018 02:54:41 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=V/wBD YjeO+ZsS8XCID4hKmFEyDdmd9bktzMy3gNZ7SQ=; b=EECjVNWQ2iifbVCnX3Sl+ w7/SVTQpiv2YJfnQZcCJx5qxgYUqBpEtyxt4AuWKT9u1KxCW/R7ecrCe9wRMmb9D NbiPyE7Soxw/vIQAqC0sYWlgNzr497fQn6GZEoVc3y1p9n46jD/R8gJbZFLAoSBb ok/ZV1WWhAw7/jb/nnRuCo= Received: from hwrenx$126.com ( [61.148.245.47] ) by ajax-webmail-wmsvr79 (Coremail) ; Wed, 22 Aug 2018 07:54:39 +0800 (GMT+08:00) X-Originating-IP: [61.148.245.47] Date: Wed, 22 Aug 2018 07:54:39 +0800 (GMT+08:00) From: "Huiwen Ren" To: "ffmpeg-devel@ffmpeg.org" X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20150911(74783.7961) Copyright (c) 2002-2018 www.mailtech.cn 126com In-Reply-To: <1533295508-7869-1-git-send-email-hwrenx@126.com> References: <1533295508-7869-1-git-send-email-hwrenx@126.com> MIME-Version: 1.0 Message-ID: <7a44c616.1d5.1655ee9663c.Coremail.hwrenx@126.com> X-CM-TRANSID: dsqowAAHk7BApnxb+iSfAA--.4310W X-CM-SenderInfo: pkzuv0b06rjloofrz/1tbiZxep6VpD6P8DRAABs4 X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH v2] lavf: add raw AVS2 demuxer 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ping On 08/03/2018 19:25, hwren wrote: Signed-off-by: hwren --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/davs2.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 libavformat/davs2.c -- 2.7.4 diff --git a/libavformat/Makefile b/libavformat/Makefile index f2f3aab..c4534b8 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -110,6 +110,7 @@ OBJS-$(CONFIG_AST_DEMUXER) += ast.o astdec.o OBJS-$(CONFIG_AST_MUXER) += ast.o astenc.o OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o OBJS-$(CONFIG_AU_MUXER) += au.o rawenc.o +OBJS-$(CONFIG_AVS2_DEMUXER) += davs2.o rawdec.o OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o OBJS-$(CONFIG_AVI_MUXER) += avienc.o mpegtsenc.o avlanguage.o rawutils.o OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o swf.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index adcc8d9..38eaeea 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -76,6 +76,7 @@ extern AVInputFormat ff_avisynth_demuxer; extern AVOutputFormat ff_avm2_muxer; extern AVInputFormat ff_avr_demuxer; extern AVInputFormat ff_avs_demuxer; +extern AVInputFormat ff_avs2_demuxer; extern AVInputFormat ff_bethsoftvid_demuxer; extern AVInputFormat ff_bfi_demuxer; extern AVInputFormat ff_bintext_demuxer; diff --git a/libavformat/davs2.c b/libavformat/davs2.c new file mode 100644 index 0000000..73daa69 --- /dev/null +++ b/libavformat/davs2.c @@ -0,0 +1,71 @@ +/* + * AVS2 video stream probe. + * + * Copyright (C) 2018 Huiwen Ren, + * + * 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 "avformat.h" +#include "rawdec.h" +#include "libavcodec/internal.h" +#include "libavutil/intreadwrite.h" + +#define ISSQH(x) ((x) == 0xB0 ) +#define ISEND(x) ((x) == 0xB1 ) +#define ISPIC(x) ((x) == 0xB3 || (x) == 0xB6) +#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 0xB5 || (x) == 0xB7 ) +#define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 ) + +static int avs2_probe(AVProbeData *p) +{ + if (AV_RB32(p->buf) != 0x1B0){ + return 0; + } + uint32_t code= -1, hds=0, pic=0, seq=0; + uint8_t state=0; + const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0; + + while (ptr < end) { + ptr = avpriv_find_start_code(ptr, end, &code); + state = code & 0xFF; + if ((code & 0xffffff00) == 0x100) { + if (ISUNIT(state)) { + if (sqb && !hds) { + hds = ptr - sqb; + } + if (ISSQH(state)) { + if (!ISAVS2(*ptr)) + return 0; + sqb = ptr; + seq++; + } else if (ISPIC(state)) { + pic++; + } else if (ISEND(state)) { + break; + } + } + } + } + if (seq && hds >= 21 && pic){ + return AVPROBE_SCORE_EXTENSION + 2; // more than cavs + } + + return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(avs2, "raw AVS2-P2/IEEE1857.4", avs2_probe, "avs,avs2", AV_CODEC_ID_AVS2)