From patchwork Thu Nov 25 06:16:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaolei Yu X-Patchwork-Id: 31655 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp174555iob; Wed, 24 Nov 2021 22:16:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIQjiSwcBAiq8wVRzvo6CDH2pBsPAD/C6gfNtHT0LhmEe7/FOJo+HZFj44Ly7VkdHPq3aP X-Received: by 2002:aa7:dc14:: with SMTP id b20mr34812601edu.133.1637820984715; Wed, 24 Nov 2021 22:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637820984; cv=none; d=google.com; s=arc-20160816; b=o+cVGBmVyA2RVmuk4BWKfUEtvh06MNdJqSduzRGkNIRLp/YezYIkbsKl684O4+Me1x GlygfJJd4MafHptYSyP1vlodWpWEIiem1d/1f2TGOry46OaEFoAWuYd06Mw+LA2gQR7I e4+tKuCMKpGZfWRJENev/WAKvj3pt0zcvhaVVFSHk8IaktB1xCRgM3CZ5e1GyI79PAr3 y6kMkYTtWpnyY1nucjO/dIxaARS/78DMeJmF48Ju2vQqs0ckH7auFylhtjYLfbkjHy7C llwfRnUZvfc1h0SmPWVk0noIJjtbkHwMQEsD0zPfY42W4VJ7Nl4Jxks0NZ7lPmziE0c0 D8kA== 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:in-reply-to:content-language:references:to:from :user-agent:mime-version:date:message-id:dkim-signature:delivered-to; bh=qLsj/0zIiJbimSPpW3ZQAErThFLyPMYxevhzyMzi2UM=; b=C6AJ+3pK2TL5CVstfp+pYQuzRnRE4R/z4ethuWnfCXprlrO9FgdTWyIa+BDGne9Xde z+Ycc0AOFNTNmm1y4FGVadrE4mYMCTUS07WhkL1TMlYhs2l66t8FwqxsQ++UqpFD0SEN FcAtgXDkGtMRrdtrXA5W+UrAD9ITXJUwDvDfgt5Ct+DA0ih8lHOkFWjnxbLMru41nMTY a2zpkYRxc4Ga8mdAzW/QO15FxdU0zrK1hJDOTURVjtNanhyJ+G4FxUXbXymrUuorni0k ICJw9ntSmunk6cMubjWZo56KA1nzEzB8Qt+WPT9PuqbSiTK4X9Mh5q7/Oruxux+njbIA MfIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=GYhWbGaA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ak17si5148719ejc.6.2021.11.24.22.16.15; Wed, 24 Nov 2021 22:16:24 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=GYhWbGaA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0CAF7680967; Thu, 25 Nov 2021 08:16:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 86866680967 for ; Thu, 25 Nov 2021 08:16:05 +0200 (EET) Received: by mail-oi1-f180.google.com with SMTP id r26so10435034oiw.5 for ; Wed, 24 Nov 2021 22:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:references :content-language:in-reply-to:content-transfer-encoding; bh=e1RhKzZk1k/NJOjw5ypPgKBDUkl+aDo9Vj9ik2jMOEM=; b=GYhWbGaA7fXQ81IbXfvRd+JHlYQErPD3F/J8oc2Qy7asYssLlhxC6oeSY7rLHJxJc+ +UR1sFR3XdKaIGV+F4lpg44S0oaqc8J4N8i2GiUM4vZeOenSgecPHOZmedkAcukf8d1a aBpkvoH1nAOueL3KA1JIXaXGuhLAG/JQXg2Qi0HL0kbjBOES+ztqD7pXgMbs5wgVLsyo zUFVz0NEk4q+g/6IvKmdESjqFa6wfXfkBh22Cv6pHUsrQhTFMtTALTKEEsXNsmat4psu 5Ko8EtTpacKdv4e4YAoNvb13UwHDsxusz0Ja4S39JKUODYbZ3jyFQ2JGXX3B+RijbXYH PoCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:references:content-language:in-reply-to :content-transfer-encoding; bh=e1RhKzZk1k/NJOjw5ypPgKBDUkl+aDo9Vj9ik2jMOEM=; b=vaYjvXQBN/jksciyb6jTfKJ1aRsjgzEAzUyf2tZtaUcmN4ZaceZgsKjiTTgSRh5I1d HFc0OWn+OwptFvIomVbR3kKE6W083EkhMCJKb+yjoqs1tb+R2Xr9tF1ls7Y+EXKDPsxZ FshSG6rUSXzAoj2dbhI95c0eiGX0l+MqgmrF0knmJ9UfPCVffw0wY4XiwQrxbrMutD5D m+EofGnJXqUDurxtU+Hl9ru7CLUAnbedbXghcGG7iCPOnB5hQSEDZh3d0oN8BvI2sorY olHkpuoX9bbIjbOxmkR7Lb1yUUXFkawweNSRQ5yJiO2hsN1mjBC0JxQlroPQIDGjg1GB dU8A== X-Gm-Message-State: AOAM530H4xMlUhLQBZrBKjQq5OOpdkJYLN6+XGJv2DDz4kMHBw49T0eW grInmP6BAt34bIH61w8ScKZCsWkfnBU4qQ== X-Received: by 2002:a05:6808:1589:: with SMTP id t9mr13174778oiw.108.1637820963930; Wed, 24 Nov 2021 22:16:03 -0800 (PST) Received: from [192.168.218.212] ([205.204.117.8]) by smtp.gmail.com with ESMTPSA id g7sm379313oon.27.2021.11.24.22.16.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Nov 2021 22:16:03 -0800 (PST) Message-ID: <3e32a15d-d2c9-f2bb-9d2e-9a577df28182@gmail.com> Date: Thu, 25 Nov 2021 14:16:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 From: Xiaolei Yu To: ffmpeg-devel@ffmpeg.org References: <7c8ed096-18a6-e3b5-ce52-b9990485ad61@gmail.com> Content-Language: en-US In-Reply-To: <7c8ed096-18a6-e3b5-ce52-b9990485ad61@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 1/1] libavcodec/h264: always set video signal type fields 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: XsXWcY/rfdIV The color range and color description fields when not present shall be inferred to be LIMITED and UNSPECIFIED respectively. Relevant info from containers will always be overriden. This is consistent with the behavior of the hevc decoder. --- libavcodec/h264_ps.c | 4 +++- libavcodec/h264_slice.c | 18 +++++++----------- tests/ref/fate/flv-demux | 2 +- tests/ref/fate/h264-dts_5frames | 10 +++++----- tests/ref/fate/matroska-spherical-mono-remux | 14 +++++++------- tests/ref/fate/ts-small-demux | 2 +- 6 files changed, 24 insertions(+), 26 deletions(-) timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 format|filename=h264small.ts|nb_streams=1|nb_programs=1|format_name=mpegts|start_time=1.400000|duration=4.933333|size=16544|bit_rate=26828|probe_score=50 diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index e21c2b56ac..164e6ea0cc 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -378,7 +378,9 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); sps->scaling_matrix_present = 0; - sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED + sps->colorspace = AVCOL_SPC_UNSPECIFIED; + sps->color_trc = AVCOL_TRC_UNSPECIFIED; + sps->color_primaries = AVCOL_PRI_UNSPECIFIED; if (sps->profile_idc == 100 || // High profile sps->profile_idc == 110 || // High10 profile diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 89ea16a57f..b7f1dfc9ef 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1103,17 +1103,13 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl init_dimensions(h); - if (sps->video_signal_type_present_flag) { - h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG - : AVCOL_RANGE_MPEG; - if (sps->colour_description_present_flag) { - if (h->avctx->colorspace != sps->colorspace) - needs_reinit = 1; - h->avctx->color_primaries = sps->color_primaries; - h->avctx->color_trc = sps->color_trc; - h->avctx->colorspace = sps->colorspace; - } - } + h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG + : AVCOL_RANGE_MPEG; + if (h->avctx->colorspace != sps->colorspace) + needs_reinit = 1; + h->avctx->color_primaries = sps->color_primaries; + h->avctx->color_trc = sps->color_trc; + h->avctx->colorspace = sps->colorspace; if (h->sei.alternative_transfer.present && av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) && diff --git a/tests/ref/fate/flv-demux b/tests/ref/fate/flv-demux index 9daee0594e..f95eaba4cc 100644 --- a/tests/ref/fate/flv-demux +++ b/tests/ref/fate/flv-demux @@ -603,6 +603,6 @@ packet|codec_type=video|stream_index=0|pts=11612|pts_time=11.612000|dts=11612|dt packet|codec_type=video|stream_index=0|pts=11645|pts_time=11.645000|dts=11645|dts_time=11.645000|duration=33|duration_time=0.033000|size=2600|pos=507811|flags=__|data_hash=CRC32:d35f9e6f packet|codec_type=audio|stream_index=1|pts=11656|pts_time=11.656000|dts=11656|dts_time=11.656000|duration=46|duration_time=0.046000|size=346|pos=510431|flags=K_|data_hash=CRC32:4e6b44cb packet|codec_type=video|stream_index=0|pts=11678|pts_time=11.678000|dts=11678|dts_time=11.678000|duration=33|duration_time=0.033000|size=1190|pos=510794|flags=__|data_hash=CRC32:a0206c90 -stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=426|height=240|coded_width=426|coded_height=240|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=71:40|pix_fmt=yuv420p|level=21|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=30/1|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=393929|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=351|extradata_hash=CRC32:07b85ca9|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:ti med_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 +stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=426|height=240|coded_width=426|coded_height=240|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=71:40|pix_fmt=yuv420p|level=21|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=30/1|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=393929|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=351|extradata_hash=CRC32:07b85ca9|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_t humbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 stream|index=1|codec_name=aac|profile=1|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=22050|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=67874|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=252|extradata_hash=CRC32:d039c029|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.000000|duration=210.209999|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332|tag:hasAudio=true|tag:audiodelay=0|tag:videosize=10176110|tag:metadatadate=2011-02-27T11:00:33.125000Z|tag:metadatacreator=inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2|tag:hasCuePoints=false diff --git a/tests/ref/fate/h264-dts_5frames b/tests/ref/fate/h264-dts_5frames index 8c6e48de55..e1af469629 100644 --- a/tests/ref/fate/h264-dts_5frames +++ b/tests/ref/fate/h264-dts_5frames @@ -22,7 +22,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=tv color_space=unknown color_primaries=unknown color_transfer=unknown @@ -52,7 +52,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=tv color_space=unknown color_primaries=unknown color_transfer=unknown @@ -82,7 +82,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=tv color_space=unknown color_primaries=unknown color_transfer=unknown @@ -112,7 +112,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=tv color_space=unknown color_primaries=unknown color_transfer=unknown @@ -142,7 +142,7 @@ display_picture_number=0 interlaced_frame=0 top_field_first=0 repeat_pict=0 -color_range=unknown +color_range=tv color_space=unknown color_primaries=unknown color_transfer=unknown diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux index 24d4413a87..bcdc0df8fa 100644 --- a/tests/ref/fate/matroska-spherical-mono-remux +++ b/tests/ref/fate/matroska-spherical-mono-remux @@ -1,5 +1,5 @@ -9176856edc1ff2b401e323f422fd8e78 *tests/data/fate/matroska-spherical-mono-remux.matroska -161583 tests/data/fate/matroska-spherical-mono-remux.matroska +100bc9e43b751990f6053cf9062ab962 *tests/data/fate/matroska-spherical-mono-remux.matroska +161587 tests/data/fate/matroska-spherical-mono-remux.matroska #extradata 0: 43, 0x2b0e0d7b #extradata 1: 43, 0x2b0e0d7b #tb 0: 1/1000 @@ -17,7 +17,7 @@ 0, -40, 160, 40, 1103, 0x082a059f, F=0x0 1, -40, 160, 40, 1103, 0x082a059f, F=0x0 [STREAM] -color_range=unknown +color_range=tv color_space=unknown color_transfer=unknown color_primaries=unknown @@ -41,10 +41,10 @@ roll=15 [/SIDE_DATA] [/STREAM] [STREAM] -color_range=pc -color_space=bt2020c -color_transfer=smpte170m -color_primaries=bt709 +color_range=tv +color_space=unknown +color_transfer=unknown +color_primaries=unknown DISPOSITION:default=0 DISPOSITION:forced=0 [SIDE_DATA] diff --git a/tests/ref/fate/ts-small-demux b/tests/ref/fate/ts-small-demux index 264d878d5b..dd0f25b8cf 100644 --- a/tests/ref/fate/ts-small-demux +++ b/tests/ref/fate/ts-small-demux @@ -145,5 +145,5 @@ packet|codec_type=video|stream_index=0|pts=552000|pts_time=6.133333|dts=552000|d packet|codec_type=video|stream_index=0|pts=558000|pts_time=6.200000|dts=558000|dts_time=6.200000|duration=6000|duration_time=0.066667|size=16|pos=15792|flags=__side_data|side_data_type=MPEGTS Stream ID|id=224 |data_hash=CRC32:27b943ef packet|codec_type=video|stream_index=0|pts=564000|pts_time=6.266667|dts=564000|dts_time=6.266667|duration=6000|duration_time=0.066667|size=16|pos=16356|flags=__|data_hash=CRC32:f7116111 -stream|index=0|codec_name=h264|profile=578|codec_type=video|codec_tag_string=[27][0][0][0]|codec_tag=0x001b|width=82|height=144|coded_width=82|coded_height=144|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=41:72|pix_fmt=yuv420p|level=10|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=false|nal_length_size=0|id=0x100|r_frame_rate=15/1|avg_frame_rate=15/1|time_base=1/90000|start_pts=126000|start_time=1.400000|duration_ts=444000|duration=4.933333|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=74|extradata_hash=CRC32:e62cae27|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposi tion:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 +stream|index=0|codec_name=h264|profile=578|codec_type=video|codec_tag_string=[27][0][0][0]|codec_tag=0x001b|width=82|height=144|coded_width=82|coded_height=144|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=41:72|pix_fmt=yuv420p|level=10|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=false|nal_length_size=0|id=0x100|r_frame_rate=15/1|avg_frame_rate=15/1|time_base=1/90000|start_pts=126000|start_time=1.400000|duration_ts=444000|duration=4.933333|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=74|extradata_hash=CRC32:e62cae27|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition: