From patchwork Wed Aug 22 09:40:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 10053 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp621719jap; Wed, 22 Aug 2018 02:40:46 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbJ45jRoFAwv7HfAes1i0faKMDf7boh+ttS9a5PG78+KAHIH2rGWYmoRBblY9ZJMq4BmIZS X-Received: by 2002:a1c:5c4:: with SMTP id 187-v6mr1910622wmf.10.1534930846455; Wed, 22 Aug 2018 02:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930846; cv=none; d=google.com; s=arc-20160816; b=ARu1gm5aQ5gB6jYWwygE+HFSr/19EJMsdVUb07Ze9OVj6+uDZmwHn0ZK2UTlJBbheN xjwHmGOH7PRz6NbLcDHXZFgch7Hv0g9nyZlEvjmKJxLDrh50eRWp8ToYjzPvPNSJpJh6 V6TDbxL1DlkhUL+LAh08m2VINO2SuyS2xQmH7SyrqkVdpX4PAOcfVOKXNTE1vz0K0PGq oOp2DRRkCnnyW7HkavjPuc8ApiFVP5Rdq5d2lKeyJZ5Ns6qf7hKl9ek+E7DdaZaCqv+s wSAjLjMIAyL1+gzJtCMSispAJaCiVX6/ZLV+PhM8FWtld2aO7LRixGY+Ql3dtoNU01cm KTUg== 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 :feedback-id:content-language:in-reply-to:mime-version:user-agent :date:from:references:to:dkim-signature:delivered-to:message-id :arc-authentication-results; bh=hPs1ckEPqa+rY8EDGd8kxLMIl0R32su56w8NeMUBMl8=; b=hwV5q5siNPg8gjjG1qjk4NpbNLXN4zAN1V2Q7GdeIwlIqIM0+wgFROiPsaGMGbyscZ sMtasCngdcZxMv2G1IwOCJyHEwKElxhAci52MU/MwARVZz9REImf/JtH+9p5VSVBOQb+ FYDLtELqa6SiRJll2zzvbIg0uRKRUYQidMMkIcYp+p/+NcNT5NQmP4+8Dv/seTxnl/cj o1dXQhWfiDMooP084vTgrqnzQMZo1QsHxn7uhfniyNo3k0AvmyEwAGPP9EoT3IGN6+z9 4elkOqadwxGdZRbbi975h5uNBZIzVBUF6iIsA9hrA1JZc3heiSKQNtqE47aagQgz+N3C VEkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=d0a6FtXY; 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=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e123-v6si1139758wmg.44.2018.08.22.02.40.46; Wed, 22 Aug 2018 02:40:46 -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=@foxmail.com header.s=s201512 header.b=d0a6FtXY; 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=foxmail.com Message-ID: <5b7d2f9e.1c69fb81.9464f.b7d2SMTPIN_ADDED_BROKEN@mx.google.com> X-Google-Original-Message-ID: <16a60365-b3c1-a902-2cfe-b435dc016993@foxmail.com>+C081B469D4E8C71D Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 90947689A3C; Wed, 22 Aug 2018 12:40:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD6A26804F5 for ; Wed, 22 Aug 2018 12:40:35 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1534930809; bh=wMSrCqEIJLV7HkMwya4PmETQTwUimchuM+rlhcSMXB8=; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type; b=d0a6FtXYeqP6p4CZz5sFakLCYkTE9Rsyc70EzEICACR4uDG0dLV9GgVKccXqNkbnH oxpkXQ6waPLftHQbeHuedtvvhI5+6TSMZqldSqI25AFTjUXQvXkle1Wn+DRqSCmjnd TH9B7MB5tocPL5gbrSivaPBbZ5YBtadmhOLw6ymY= X-QQ-mid: esmtp3t1534930808t36x5b0zc Received: from [10.1.246.54] (unknown [119.145.5.45]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for ; Wed, 22 Aug 2018 17:40:08 +0800 (CST) X-QQ-SSF: 00000000000000F0F91004000000001 X-QQ-FEAT: 9bnv2N2HLTwguhUEcx0kXgnAXxypxJLjokeH/fRMw9xaoJb0pPTiPI3kEDTdh aaOJFsfBIq0/Q57Q3bWQOsP7HjruLqZnrlPgHg1kZVzwAOCIG7FGkxOE2rGpWYbZetQ4jKy y+obVRjc+Nr6F16oZXIxZexwzGvYNhTLlsNP/auK6sAJJbOAI6DhOBFv4EYpF/mh2uQIhxi LoTG6lHWSKxm1zulSmFLKNO3eD+tAtCcKqbDW1ZiNzHEx7B2I2sm3+V9a6RfoXySw5hNwTM 7O4vy7uGT/2fm0v7I4tFU3O5RtOF7+Fmxd4RjdmFy9vPvT X-QQ-GoodBg: 0 To: ffmpeg-devel@ffmpeg.org References: <20180817002336.GA19650@michaelspb> <20180817015257.7327-1-quinkblack@foxmail.com> <20180817213333.GJ19650@michaelspb> <20180822002647.GW19650@michaelspb> From: Zhao Zhili Date: Wed, 22 Aug 2018 17:40:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180822002647.GW19650@michaelspb> Content-Language: en-US X-QQ-SENDSIZE: 520 Feedback-ID: esmtp:foxmail.com:bgforeign:bgforeign2 X-QQ-Bgrelay: 1 Subject: Re: [FFmpeg-devel] [PATCH] lavc/hevc_ps: fix crop info for monochrome 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" On 2018年08月22日 08:26, Michael Niedermayer wrote: > On Mon, Aug 20, 2018 at 10:19:04AM +0800, Zhao Zhili wrote: >> >> On 2018年08月18日 05:33, Michael Niedermayer wrote: >>> On Fri, Aug 17, 2018 at 09:52:57AM +0800, Zhao Zhili wrote: >>>> The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The >>>> current code use the value of 2. >>>> --- >>>> libavcodec/hevc_ps.c | 16 ++++++++++++---- >>>> 1 file changed, 12 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c >>>> index fbd9fbf..b56b078 100644 >>>> --- a/libavcodec/hevc_ps.c >>>> +++ b/libavcodec/hevc_ps.c >>>> @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { >>>> { 2, 1 }, >>>> }; >>>> +static const unsigned hevc_sub_width_c[] = { >>> uint8_t saves a few bytes >>> >>> more important, the commit message should mention a ticket or test sample >>> also a fate test with a _small_ testsample would be usefull. Obviously >>> the existing tests do not cover this >>> >> The bug was found by reading the source code. There is no ticket >> related to the bug. I need some time to download the test suite >> and figure out how it work. Feel free to add the test if anyone >> has a suitable sample. > if theres no test sample, creating one would be a good idea so this > is tested. Because as is it would be a change that completely untested Updated patch and test sample are attached. Please review. > thx > > [...] > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From 74dd822640b359beff6c843143e878fe39fc92c5 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Wed, 22 Aug 2018 17:37:15 +0800 Subject: [PATCH] lavc/hevc_ps: fix crop info for monochrome The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The current code use the value of 2. --- libavcodec/hevc_ps.c | 16 ++++++++++++---- tests/fate/hevc.mak | 3 +++ tests/ref/fate/hevc-monochrome-crop | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/ref/fate/hevc-monochrome-crop diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index fbd9fbf..ea984af 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { { 2, 1 }, }; +static const uint8_t hevc_sub_width_c[] = { + 1, 2, 2, 1 +}; + +static const uint8_t hevc_sub_height_c[] = { + 1, 2, 1, 1 +}; + static void remove_pps(HEVCParamSets *s, int id) { if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data) @@ -628,8 +636,8 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, vui->default_display_window_flag = get_bits1(gb); if (vui->default_display_window_flag) { - int vert_mult = 1 + (sps->chroma_format_idc < 2); - int horiz_mult = 1 + (sps->chroma_format_idc < 3); + int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; + int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * horiz_mult; vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * horiz_mult; vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * vert_mult; @@ -923,8 +931,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return ret; if (get_bits1(gb)) { // pic_conformance_flag - int vert_mult = 1 + (sps->chroma_format_idc < 2); - int horiz_mult = 1 + (sps->chroma_format_idc < 3); + int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; + int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * horiz_mult; sps->pic_conf_win.right_offset = get_ue_golomb_long(gb) * horiz_mult; sps->pic_conf_win.top_offset = get_ue_golomb_long(gb) * vert_mult; diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak index 184349e..9c288fc 100644 --- a/tests/fate/hevc.mak +++ b/tests/fate/hevc.mak @@ -250,6 +250,9 @@ FATE_HEVC-$(call DEMDEC, MOV, HEVC) += fate-hevc-extradata-reload fate-hevc-extradata-reload: CMD = framemd5 -i $(TARGET_SAMPLES)/hevc/extradata-reload-multi-stsd.mov -sws_flags bitexact +fate-hevc-monochrome-crop: CMD = ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=width,height,coded_width,coded_height $(TARGET_SAMPLES)/hevc/hevc-monochrome.hevc +FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-monochrome-crop + FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes) FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes) diff --git a/tests/ref/fate/hevc-monochrome-crop b/tests/ref/fate/hevc-monochrome-crop new file mode 100644 index 0000000..531bfc8 --- /dev/null +++ b/tests/ref/fate/hevc-monochrome-crop @@ -0,0 +1,6 @@ +[STREAM] +width=384 +height=240 +coded_width=384 +coded_height=256 +[/STREAM] -- 2.9.5