From patchwork Mon Aug 16 09:01:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "rui.jiang" <229135609@qq.com> X-Patchwork-Id: 29561 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1851429iov; Mon, 16 Aug 2021 02:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW4pE2wQA1hODlOrTyGYZB0oQ92nmyl1lytuxvI8gTuS0MOOOscgk+1OMQJncy8tXbjsHu X-Received: by 2002:a05:6402:881:: with SMTP id e1mr19499807edy.53.1629104714919; Mon, 16 Aug 2021 02:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629104714; cv=none; d=google.com; s=arc-20160816; b=YSWIUnL1mmY0OrI63CgO/M9o3tV8X9Q4V4xQ5prSJQk/lNbxUxubr/XcdKokiSSCVA 01Axr8niZwcOMAT6tqGHY0jtfpZl2k0v3jniJ0g6BOeOcNet1MBJeLVJSkpKQjBA9n56 BHfmYCwzfuLp7FMZ+Cj3TZ3O10GLj8HYk7kekWTJegxTS61B7JNFAmGzxWqmwRAArB5z V/rhMxQsWpNKakOISYMqdj7XVjJWg8yqvxWkoq0rv/5FbI76RCL+Bnrwm0DNvPIsFC5F RyVySoI6JE8OIfvn0m+/qrQD6q5YG3N5ukEs5846VqwS3Oz/elohUU6CXJMPTPRZOc+c TQRw== 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:date:to:from:message-id :dkim-signature:delivered-to; bh=0DbD08mNdzraT+/wk3Phx+VPmewcjM7dGqC1E0kM2zw=; b=Bxmph8NsmuYU/CL5/gjyTu5EZWifow8UHL0CufVtdnAVqL+UMOaizAnqFPhcGNsdTA uo6z0AJ5hSUIJt3QRgU0UNsWZQWkjo2bg/Y3eLWTy9pozJc3MOVBvIkzWFYE2mv1cWzu GkVIhAUftDMml4QhwIfjmqKJ5OxvosEGhR+w18Y9O00+S4bw1QY0uEwQ+YyuzfX5sp0V 0MPEH+Sdr+sM9zPzPNhjXpBUsxNI5al6BEXDBccet6FshLiMyqnDQ1vW9R/XoypgTXvT fMC1xiJyNKEqR6P/3Z8o3LxhwsTFqJw5Nmm5WmRNCTByvBxFS8Ar+RATTHQi2CBrz3XH 3ghg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@qq.com header.s=s201512 header.b=Gxly6ix0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cq25si9413455edb.41.2021.08.16.02.05.14; Mon, 16 Aug 2021 02:05:14 -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=@qq.com header.s=s201512 header.b=Gxly6ix0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6275B68A32E; Mon, 16 Aug 2021 12:05:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-245.mail.qq.com (out203-205-221-245.mail.qq.com [203.205.221.245]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 846BC68A1D4 for ; Mon, 16 Aug 2021 12:05:01 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1629104696; bh=IzUtIjNaEYuFD2DOjtRgovXr6ogflnAumXL9YO7L+UY=; h=From:To:Cc:Subject:Date; b=Gxly6ix0tsgYbTY/4vUy6AYqlsKyfzxRs5W60R0c9Uc5amjyMtIKVgMgSsDG8hKaa GpYetu2wUPL03jVeqDBurusN7PixHLDu9JzOZhh7HI0FP+27dGvLXzujJKBUyqDnG4 /JAgsmRaoK0oZZam9sqjv0TsnhFGQW6A0P2Q91JA= Received: from localhost.localdomain ([117.131.104.22]) by newxmesmtplogicsvrszb7.qq.com (NewEsmtp) with SMTP id 136B48D3; Mon, 16 Aug 2021 17:04:54 +0800 X-QQ-mid: xmsmtpt1629104694t7c1dnzo9 Message-ID: X-QQ-XMAILINFO: Nip6yC9MT+Xlz9ISTaX9Z1hw+/ExryRPoX4S09r/MBMQ5p1CTvwNhNmYuGlaVQ m+C01Mj8SOhQuuPMQd4Ix9sefbhenVBdakMqlwE+QNutMz8cD+pmGQ/qvOVPaQ/jspzVH/in6NVM EE01ZqeTaJfMSmK4qMlpRucdu6Zlb5QvKqvLuKHlAnYh/BDq1WBK3JSTZTLCi61Ddd50dxixqlIt 2yZKhbEHuJBVhW8SO3oA/+IqlU8L6nN6r3MKvrNaMwxKsyKpNRiuDkcpOPjXWww1HA5hDfsGkBn1 dC/cRzoaV0BP0hdDt3WNIZ5e+NZsc3Y6RWCAGD0Mcn205BrOqrSbcnkqzIR3J8wOUlHfGz9mmZyl BsLI9ZT57Nkfw8I4byg9lZKkrTIM1qiYJraiwW3mAWR9Ek6Dff5xFuI2LUrXU3P3MyI4vxgH3osu 3exH1H295r9XeuWZmc7S++pIwuEMw8Ctw9oWqn5H1WQmHSDw5lOJAXzvIURmfMZce2zdUc/VEHZL U35OA/LevyZOZJGO1HPyWRD45H6X1T4yT7/qEyW/Pj9wqjNM9p/iGVOZ+qYJDxhWzZrD8nTlM2Gf u+DEMCg/9RRPMA4fVad3idzvRzI/ywMHQd75pWH7EiAyRUnJPJI38JQgtDMln4rTZrezj7OnWxUD QpStKtx6bmaaZ+nTl9ydakGNLbHue0j+SqiRYDLvKfWA2ya7CdHPASNOrkWJEGXaGXbFqocvUQXq LcjWhl/FiFXVl/Tw7vdR+et2DT33mKfbHus5CIKDnXSFBLPBojyc8Ua6CdAxlR3tbl13swo3xFmQ 5wQP6rxLvYmnVwlJ0QFX3sAbsgNVuuA0recLXW4rNtuncfT5lf2Vw+1cWqVGwEURYux+BvUqIpAy VVdPhdtraQ+uk62xoevhgpj0wl/wXCiQ== From: "rui.jiang" <229135609@qq.com> To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 17:01:14 +0800 X-OQ-MSGID: <20210816090112.5561-1-229135609@qq.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavformat/riffenc: support raw avi for raw PAL8 or Gray8 pixel data X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: "rui.jiang" <229135609@qq.com> Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OpKjgbW/0Eru add palette data in avi header when the input data is raw PAL8 or Gray8 pixel data and the output data is 8bit raw avi video; Signed-off-by: rui.jiang <229135609@qq.com> --- libavformat/riffenc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index 43c8bf957a..bc654b3cd3 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -228,7 +228,8 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, pal_avi = !for_asf && (pix_fmt == AV_PIX_FMT_PAL8 || pix_fmt == AV_PIX_FMT_MONOWHITE || - pix_fmt == AV_PIX_FMT_MONOBLACK); + pix_fmt == AV_PIX_FMT_MONOBLACK || + pix_fmt == AV_PIX_FMT_GRAY8); /* Size (not including the size of the color table or color masks) */ avio_wl32(pb, 40 + (ignore_extradata || pal_avi ? 0 : extradata_size)); @@ -263,6 +264,13 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, avio_wl32(pb, 0xffffff); else if (i == 1 && pix_fmt == AV_PIX_FMT_MONOBLACK) avio_wl32(pb, 0xffffff); + else if (pix_fmt == AV_PIX_FMT_PAL8 || pix_fmt == AV_PIX_FMT_GRAY8) { + /* Initialize palette */ + avio_w8(pb,i); + avio_w8(pb,i); + avio_w8(pb,i); + avio_w8(pb,0); + } else avio_wl32(pb, 0); }