From b2a865eac72ccac8827400e8f44d67b6fd7d095a Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Fri, 18 Mar 2022 12:21:39 +0100 Subject: [PATCH] avc_sps: Add chroma format name mapping --- format/matroska/testdata/avc.fqtest | 2 +- format/mp4/testdata/avc.fqtest | 2 +- format/mp4/testdata/dash.fqtest | 2 +- format/mp4/testdata/fragmented.fqtest | 2 +- format/mpeg/avc_sps.go | 9 ++++++++- format/mpeg/testdata/avc_annexb.fqtest | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/format/matroska/testdata/avc.fqtest b/format/matroska/testdata/avc.fqtest index 5ad35bbf..01f97aa4 100644 --- a/format/matroska/testdata/avc.fqtest +++ b/format/matroska/testdata/avc.fqtest @@ -263,7 +263,7 @@ $ fq -d matroska dv /avc.mkv 0x000| 00 | . | reserved_zero_2bits: 0 0x1.6-0x1.7 (0.2) 0x000| 0d | . | level_idc: "1.3" (13) 0x2-0x2.7 (1) 0x000| 91 | . | seq_parameter_set_id: 0 0x3-0x3 (0.1) - 0x000| 91 | . | chroma_format_idc: 3 0x3.1-0x3.5 (0.5) + 0x000| 91 | . | chroma_format_idc: "4:4:4" (3) 0x3.1-0x3.5 (0.5) 0x000| 91 | . | separate_colour_plane_flag: false 0x3.6-0x3.6 (0.1) 0x000| 91 | . | bit_depth_luma: 8 0x3.7-0x3.7 (0.1) 0x000| 9b | . | bit_depth_chroma: 8 0x4-0x4 (0.1) diff --git a/format/mp4/testdata/avc.fqtest b/format/mp4/testdata/avc.fqtest index 9ae04ddd..8c6d1ea4 100644 --- a/format/mp4/testdata/avc.fqtest +++ b/format/mp4/testdata/avc.fqtest @@ -246,7 +246,7 @@ $ fq -d mp4 dv /avc.mp4 0x000| 00 | . | reserved_zero_2bits: 0 0x1.6-0x1.7 (0.2) 0x000| 0d | . | level_idc: "1.3" (13) 0x2-0x2.7 (1) 0x000| 91 | . | seq_parameter_set_id: 0 0x3-0x3 (0.1) - 0x000| 91 | . | chroma_format_idc: 3 0x3.1-0x3.5 (0.5) + 0x000| 91 | . | chroma_format_idc: "4:4:4" (3) 0x3.1-0x3.5 (0.5) 0x000| 91 | . | separate_colour_plane_flag: false 0x3.6-0x3.6 (0.1) 0x000| 91 | . | bit_depth_luma: 8 0x3.7-0x3.7 (0.1) 0x000| 9b | . | bit_depth_chroma: 8 0x4-0x4 (0.1) diff --git a/format/mp4/testdata/dash.fqtest b/format/mp4/testdata/dash.fqtest index ad3bb859..48f15241 100644 --- a/format/mp4/testdata/dash.fqtest +++ b/format/mp4/testdata/dash.fqtest @@ -721,7 +721,7 @@ $ fq -d mp4 dv /dash_video_init.mp4 0x00| 10 | . | reserved_zero_2bits: 0 0x1.6-0x1.7 (0.2) 0x00| 0d | . | level_idc: "1.3" (13) 0x2-0x2.7 (1) 0x00| 91 | . | seq_parameter_set_id: 0 0x3-0x3 (0.1) - 0x00| 91 | . | chroma_format_idc: 3 0x3.1-0x3.5 (0.5) + 0x00| 91 | . | chroma_format_idc: "4:4:4" (3) 0x3.1-0x3.5 (0.5) 0x00| 91 | . | separate_colour_plane_flag: false 0x3.6-0x3.6 (0.1) 0x00| 91 | . | bit_depth_luma: 8 0x3.7-0x3.7 (0.1) 0x00| 97 | . | bit_depth_chroma: 8 0x4-0x4 (0.1) diff --git a/format/mp4/testdata/fragmented.fqtest b/format/mp4/testdata/fragmented.fqtest index 5e37d6bd..caddbd8c 100644 --- a/format/mp4/testdata/fragmented.fqtest +++ b/format/mp4/testdata/fragmented.fqtest @@ -205,7 +205,7 @@ $ fq -d mp4 dv /fragmented.mp4 0x000| 10 | . | reserved_zero_2bits: 0 0x1.6-0x1.7 (0.2) 0x000| 0d | . | level_idc: "1.3" (13) 0x2-0x2.7 (1) 0x000| 91 | . | seq_parameter_set_id: 0 0x3-0x3 (0.1) - 0x000| 91 | . | chroma_format_idc: 3 0x3.1-0x3.5 (0.5) + 0x000| 91 | . | chroma_format_idc: "4:4:4" (3) 0x3.1-0x3.5 (0.5) 0x000| 91 | . | separate_colour_plane_flag: false 0x3.6-0x3.6 (0.1) 0x000| 91 | . | bit_depth_luma: 8 0x3.7-0x3.7 (0.1) 0x000| 97 | . | bit_depth_chroma: 8 0x4-0x4 (0.1) diff --git a/format/mpeg/avc_sps.go b/format/mpeg/avc_sps.go index 29bdd474..5409bb00 100644 --- a/format/mpeg/avc_sps.go +++ b/format/mpeg/avc_sps.go @@ -46,6 +46,13 @@ var avcAspectRatioIdcMap = scalar.UToSymStr{ 16: "2:1", } +var chromaFormatMap = scalar.UToSymStr{ + 0: "monochrome", + 1: "4:2:0", + 2: "4:2:2", + 3: "4:4:4", +} + func avcVuiParameters(d *decode.D) { aspectRatioInfoPresentFlag := d.FieldBool("aspect_ratio_info_present_flag") if aspectRatioInfoPresentFlag { @@ -142,7 +149,7 @@ func avcSPSDecode(d *decode.D, in interface{}) interface{} { switch profileIdc { // TODO: ffmpeg has some more (legacy values?) case 100, 110, 122, 244, 44, 83, 86, 118, 128, 138, 139, 134, 135: - chromaFormatIdc := d.FieldUFn("chroma_format_idc", uEV) + chromaFormatIdc := d.FieldUFn("chroma_format_idc", uEV, chromaFormatMap) if chromaFormatIdc == 3 { d.FieldBool("separate_colour_plane_flag") } diff --git a/format/mpeg/testdata/avc_annexb.fqtest b/format/mpeg/testdata/avc_annexb.fqtest index e455b9e1..d8819a39 100644 --- a/format/mpeg/testdata/avc_annexb.fqtest +++ b/format/mpeg/testdata/avc_annexb.fqtest @@ -14,7 +14,7 @@ $ fq -d avc_annexb dv /avc_annexb 0x000| 00 | . | reserved_zero_2bits: 0 0x1.6-0x1.7 (0.2) 0x000| 0d | . | level_idc: "1.3" (13) 0x2-0x2.7 (1) 0x000| 91 | . | seq_parameter_set_id: 0 0x3-0x3 (0.1) - 0x000| 91 | . | chroma_format_idc: 3 0x3.1-0x3.5 (0.5) + 0x000| 91 | . | chroma_format_idc: "4:4:4" (3) 0x3.1-0x3.5 (0.5) 0x000| 91 | . | separate_colour_plane_flag: false 0x3.6-0x3.6 (0.1) 0x000| 91 | . | bit_depth_luma: 8 0x3.7-0x3.7 (0.1) 0x000| 9b | . | bit_depth_chroma: 8 0x4-0x4 (0.1)