From patchwork Wed Mar 7 15:53:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Martinez X-Patchwork-Id: 7852 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp5119045jaj; Wed, 7 Mar 2018 07:53:52 -0800 (PST) X-Google-Smtp-Source: AG47ELsf9iKS0NisG1ns0vRG8u+cVpNyJv/VuckmA6rTz8eY9g6i1B5wrNoVHWh7+9UvzTRR/JHV X-Received: by 10.28.66.130 with SMTP id k2mr13679527wmi.15.1520438032416; Wed, 07 Mar 2018 07:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520438032; cv=none; d=google.com; s=arc-20160816; b=ClYIe2mB7SnJNsB9N4avQJaXs+SVFFRobb+tsZ8L6Ra9ZpPRfbJj6UbM6/SBsekKKJ Alu/7oeDMVxkk+6OHoiFU34fxdrECreqyYYLi2EBUjY/SD21da9LpV7yrQKWZ56gx8Zt DcbGWWouNX35giZqO9HAA3m4ji+WRlgorxkSPseGz1eXLegmgWkINDPtfOp84zeBj3hU DgVxHkcyCHWIx7ewo4pvAIHh1pcMmpwBCoRjIsqiwM609ZoULd92hk0NMjeoTKS2eVyG deBSwTEH+lBLuaQ+n07ekRnX/G32MiQb2nsEaS4N9ZYaSG90cwKFhhyddL2OvbNw79ME qfMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:delivered-to :arc-authentication-results; bh=T8hzk4daZ3MRCab74aUJFsI1uDzizTofySbOwI1Mfy8=; b=F6uOvTxJieDD3HJfiHZ5FlsWnedxBMhhOlHJd0s7ekAmZpmbot7adk1ordY9SRxXjl 8BE8mYiXQxILQB8Ri50aQUp7KKsp4hPhRVX6EN0jZGa8LoPsUc8FsRpzLjdQUNyDp0Z4 M7/a8IGNpr/wE4xog/u3iXVJ7g333zftQrNio5FrTrBUqTHz4TEHOMg+KxQHyxj8ScTs tfYpMWmWs+fIQElHzS3h7iXM+G+tZ7vfsEtAbUAIi9Bl+b52BZXAcDk1MbuAuIPH7paa acz+8xtUH522rUA0XMGKbxvcv7Sp9hpsYyxO4nOgXvOrpkDGRwlyq7Sn7bBBUKb2F5i3 52Gg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 9si4275461wra.490.2018.03.07.07.53.51; Wed, 07 Mar 2018 07:53:52 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC04A68A55A; Wed, 7 Mar 2018 17:53:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from 8.mo2.mail-out.ovh.net (8.mo2.mail-out.ovh.net [188.165.52.147]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1132268A540 for ; Wed, 7 Mar 2018 17:53:36 +0200 (EET) Received: from player778.ha.ovh.net (unknown [10.109.105.13]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id B20C81206D0 for ; Wed, 7 Mar 2018 16:53:42 +0100 (CET) Received: from [192.168.2.120] (p5DDB6D89.dip0.t-ipconnect.de [93.219.109.137]) (Authenticated sender: zen-lists@mediaarea.net) by player778.ha.ovh.net (Postfix) with ESMTPSA id 5C8791800AE for ; Wed, 7 Mar 2018 16:53:42 +0100 (CET) To: ffmpeg-devel@ffmpeg.org References: <4b0efe51-d6c0-9a37-ce34-155387d1a8e8@mediaarea.net> From: Jerome Martinez Message-ID: Date: Wed, 7 Mar 2018 16:53:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <4b0efe51-d6c0-9a37-ce34-155387d1a8e8@mediaarea.net> Content-Language: en-GB X-Ovh-Tracer-Id: 794322386677338301 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtfedrkedvgdekfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu Subject: [FFmpeg-devel] [PATCH 6/7] avcodec/ffv1: support of more pix_fmt 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" With some sources having specific pix_fmt (9/10/12/14 bit), the source is padded to 16-bit when the pix_fmt is not supported natively by the FFV1 encoder. Nothing is lost ("cutting" to the source bitdepth permits to retrieve the exact source), but the source bitdepth is not indicated so it is not possible to retrieve the exact source without having the source bitdepth by another channel. It also makes FATE tests (framemd5 comparison) a bit more complicated (bitdepth reduction). This patch adds native support of the pix_fmt being padded, so there is no more padding and the FFV1 bitdepth is same as source bitdepth. From 8efae7dd23ac30a84161e3d5a46b38350703a7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= Date: Wed, 7 Mar 2018 11:19:03 +0100 Subject: [PATCH 6/7] avcodec/ffv1: support of more pix_fmt Without direct support of such pix_fmt, content is padded to 16-bit and it is not possible to know that the source file was with a smaller bit depth so framemd5 is different --- libavcodec/ffv1dec.c | 14 +++++++++++++- libavcodec/ffv1enc.c | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 94bd60ad2b..9f26d48b03 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -594,7 +594,10 @@ static int read_header(FFV1Context *f) if (!f->transparency && !f->chroma_planes) { if (f->avctx->bits_per_raw_sample <= 8) f->avctx->pix_fmt = AV_PIX_FMT_GRAY8; - else if (f->avctx->bits_per_raw_sample == 10) { + else if (f->avctx->bits_per_raw_sample == 9) { + f->packed_at_lsb = 1; + f->avctx->pix_fmt = AV_PIX_FMT_GRAY9; + } else if (f->avctx->bits_per_raw_sample == 10) { f->packed_at_lsb = 1; f->avctx->pix_fmt = AV_PIX_FMT_GRAY10; } else if (f->avctx->bits_per_raw_sample == 12) { @@ -645,6 +648,7 @@ static int read_header(FFV1Context *f) f->packed_at_lsb = 1; switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P10; break; + case 0x01: f->avctx->pix_fmt = AV_PIX_FMT_YUV440P10; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P10; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P10; break; } @@ -659,9 +663,17 @@ static int read_header(FFV1Context *f) f->packed_at_lsb = 1; switch(16 * f->chroma_h_shift + f->chroma_v_shift) { case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P12; break; + case 0x01: f->avctx->pix_fmt = AV_PIX_FMT_YUV440P12; break; case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P12; break; case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P12; break; } + } else if (f->avctx->bits_per_raw_sample == 14 && !f->transparency) { + f->packed_at_lsb = 1; + switch(16 * f->chroma_h_shift + f->chroma_v_shift) { + case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P14; break; + case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P14; break; + case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P14; break; + } } else if (f->avctx->bits_per_raw_sample == 16 && !f->transparency){ f->packed_at_lsb = 1; switch(16 * f->chroma_h_shift + f->chroma_v_shift) { diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 262821abab..f0f9eaba79 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -559,6 +559,7 @@ FF_ENABLE_DEPRECATION_WARNINGS s->plane_count = 3; switch(avctx->pix_fmt) { + case AV_PIX_FMT_GRAY9: case AV_PIX_FMT_YUV444P9: case AV_PIX_FMT_YUV422P9: case AV_PIX_FMT_YUV420P9: @@ -569,6 +570,7 @@ FF_ENABLE_DEPRECATION_WARNINGS s->bits_per_raw_sample = 9; case AV_PIX_FMT_GRAY10: case AV_PIX_FMT_YUV444P10: + case AV_PIX_FMT_YUV440P10: case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_YUV422P10: case AV_PIX_FMT_YUVA444P10: @@ -578,11 +580,17 @@ FF_ENABLE_DEPRECATION_WARNINGS s->bits_per_raw_sample = 10; case AV_PIX_FMT_GRAY12: case AV_PIX_FMT_YUV444P12: + case AV_PIX_FMT_YUV440P12: case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV422P12: - s->packed_at_lsb = 1; if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) s->bits_per_raw_sample = 12; + case AV_PIX_FMT_YUV444P14: + case AV_PIX_FMT_YUV420P14: + case AV_PIX_FMT_YUV422P14: + if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) + s->bits_per_raw_sample = 14; + s->packed_at_lsb = 1; case AV_PIX_FMT_GRAY16: case AV_PIX_FMT_YUV444P16: case AV_PIX_FMT_YUV422P16: @@ -1343,10 +1351,13 @@ AVCodec ff_ffv1_encoder = { AV_PIX_FMT_GRAY16, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, - AV_PIX_FMT_YA8, + AV_PIX_FMT_YA8, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GBRP16, AV_PIX_FMT_RGB48, AV_PIX_FMT_GBRAP16, AV_PIX_FMT_RGBA64, + AV_PIX_FMT_GRAY9, + AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, + AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12, AV_PIX_FMT_NONE },