Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Nov 16, 2023
1 parent cfd18e7 commit 92c16af
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 61 deletions.
4 changes: 3 additions & 1 deletion format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ var (
MP3_Frame_XING = &decode.Group{Name: "mp3_frame_xing"}
MP4 = &decode.Group{Name: "mp4"}
MPEG_ASC = &decode.Group{Name: "mpeg_asc"}
MPEG_CC_Data = &decode.Group{Name: "mpeg_cc_data"}
MPEG_ES = &decode.Group{Name: "mpeg_es"}
MPES_PES = &decode.Group{Name: "mpeg_pes"}
MPEG_ITU_T35 = &decode.Group{Name: "mpeg_itu_t35"}
MPEG_PES_Packet = &decode.Group{Name: "mpeg_pes_packet"}
MPEG_SPU = &decode.Group{Name: "mpeg_spu"}
MPEG_TS = &decode.Group{Name: "mpeg_ts"}
MPES_PES = &decode.Group{Name: "mpeg_pes"}
MsgPack = &decode.Group{Name: "msgpack"}
Ogg = &decode.Group{Name: "ogg"}
Ogg_Page = &decode.Group{Name: "ogg_page"}
Expand Down
130 changes: 70 additions & 60 deletions format/mpeg/avc_sei.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,84 @@ import (
"github.com/wader/fq/pkg/scalar"
)

var avcSeiMpegItuT35Group decode.Group

func init() {
interp.RegisterFormat(
format.AVC_SEI,
&decode.Format{
Description: "H.264/AVC Supplemental Enhancement Information",
DecodeFn: avcSEIDecode,
Dependencies: []decode.Dependency{
{Groups: []*decode.Group{format.MPEG_ITU_T35}, Out: &avcSeiMpegItuT35Group},
},
})
}

const (
avcSEIUserDataUnregistered = 5
avcSEIUserDataRegisteredItuTT35 = 4
avcSEIUserDataUnregistered = 5
)

var seiNames = scalar.UintMapSymStr{
0: "buffering_period",
1: "pic_timing",
2: "pan_scan_rect",
3: "filler_payload",
4: "user_data_registered_itu_t_t35",
avcSEIUserDataUnregistered: "user_data_unregistered",
6: "recovery_point",
7: "dec_ref_pic_marking_repetition",
8: "spare_pic",
9: "scene_info",
10: "sub_seq_info",
11: "sub_seq_layer_characteristics",
12: "sub_seq_characteristics",
13: "full_frame_freeze",
14: "full_frame_freeze_release",
15: "full_frame_snapshot",
16: "progressive_refinement_segment_start",
17: "progressive_refinement_segment_end",
18: "motion_constrained_slice_group_set",
19: "film_grain_characteristics",
20: "deblocking_filter_display_preference",
21: "stereo_video_info",
22: "post_filter_hint",
23: "tone_mapping_info",
24: "scalability_info",
25: "sub_pic_scalable_layer",
26: "non_required_layer_rep",
27: "priority_layer_info",
28: "layers_not_present",
29: "layer_dependency_change",
30: "scalable_nesting",
31: "base_layer_temporal_hrd",
32: "quality_layer_integrity_check",
33: "redundant_pic_property",
34: "tl0_dep_rep_index",
35: "tl_switching_point",
36: "parallel_decoding_info",
37: "mvc_scalable_nesting",
38: "view_scalability_info",
39: "multiview_scene_info",
40: "multiview_acquisition_info",
41: "non_required_view_component",
42: "view_dependency_change",
43: "operation_points_not_present",
44: "base_view_temporal_hrd",
45: "frame_packing_arrangement",
46: "multiview_view_position",
47: "display_orientation",
48: "mvcd_scalable_nesting",
49: "mvcd_view_scalability_info",
50: "depth_representation_info",
51: "three_dimensional_reference_displays_info",
52: "depth_timing",
53: "depth_sampling_info",
54: "constrained_depth_parameter_set_identifier",
56: "green_metadata",
137: "mastering_display_colour_volume",
181: "alternative_depth_info",
0: "buffering_period",
1: "pic_timing",
2: "pan_scan_rect",
3: "filler_payload",
avcSEIUserDataRegisteredItuTT35: "user_data_registered_itu_t_t35",
avcSEIUserDataUnregistered: "user_data_unregistered",
6: "recovery_point",
7: "dec_ref_pic_marking_repetition",
8: "spare_pic",
9: "scene_info",
10: "sub_seq_info",
11: "sub_seq_layer_characteristics",
12: "sub_seq_characteristics",
13: "full_frame_freeze",
14: "full_frame_freeze_release",
15: "full_frame_snapshot",
16: "progressive_refinement_segment_start",
17: "progressive_refinement_segment_end",
18: "motion_constrained_slice_group_set",
19: "film_grain_characteristics",
20: "deblocking_filter_display_preference",
21: "stereo_video_info",
22: "post_filter_hint",
23: "tone_mapping_info",
24: "scalability_info",
25: "sub_pic_scalable_layer",
26: "non_required_layer_rep",
27: "priority_layer_info",
28: "layers_not_present",
29: "layer_dependency_change",
30: "scalable_nesting",
31: "base_layer_temporal_hrd",
32: "quality_layer_integrity_check",
33: "redundant_pic_property",
34: "tl0_dep_rep_index",
35: "tl_switching_point",
36: "parallel_decoding_info",
37: "mvc_scalable_nesting",
38: "view_scalability_info",
39: "multiview_scene_info",
40: "multiview_acquisition_info",
41: "non_required_view_component",
42: "view_dependency_change",
43: "operation_points_not_present",
44: "base_view_temporal_hrd",
45: "frame_packing_arrangement",
46: "multiview_view_position",
47: "display_orientation",
48: "mvcd_scalable_nesting",
49: "mvcd_view_scalability_info",
50: "depth_representation_info",
51: "three_dimensional_reference_displays_info",
52: "depth_timing",
53: "depth_sampling_info",
54: "constrained_depth_parameter_set_identifier",
56: "green_metadata",
137: "mastering_display_colour_volume",
181: "alternative_depth_info",
}

var (
Expand Down Expand Up @@ -108,10 +114,14 @@ func avcSEIDecode(d *decode.D) any {

d.FramedFn(int64(payloadSize)*8, func(d *decode.D) {
switch payloadType {
case avcSEIUserDataRegisteredItuTT35:
d.FieldFormat("data", &avcSeiMpegItuT35Group, nil)
case avcSEIUserDataUnregistered:
d.FieldRawLen("uuid", 16*8, userDataUnregisteredNames)
d.FieldRawLen("data", d.BitsLeft())
default:
d.FieldRawLen("data", d.BitsLeft())
}
d.FieldRawLen("data", d.BitsLeft())
})

d.FieldRawLen("rbsp_trailing_bits", d.BitsLeft())
Expand Down
42 changes: 42 additions & 0 deletions format/mpeg/mpeg_cc_data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package mpeg

// TODO: rename? eia something?
// EIA-708 cc_data
// https://shop.cta.tech/products/digital-television-dtv-closed-captioning

import (
"github.com/wader/fq/format"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
)

func init() {
interp.RegisterFormat(
format.MPEG_CC_Data,
&decode.Format{
Description: "EIA-708 cc_data closed captioning data",
DecodeFn: mpegCcDataDecode,
})
}

func mpegCcDataDecode(d *decode.D) any {
d.FieldU1("reserved0")
d.FieldBool("process_cc_data_flag")
d.FieldU1("zero_bit")
ccCount := d.FieldU5("cc_count")
d.FieldU8("reserved1")
d.FieldArray("cc", func(d *decode.D) {
for i := 0; i < int(ccCount); i++ {
d.FieldStruct("cc", func(d *decode.D) {
d.FieldU1("one_bit")
d.FieldU4("reserved0")
d.FieldBool("cc_valid")
d.FieldU2("cc_type")
d.FieldU8("cc_data_1")
d.FieldU8("cc_data_2")
})
}
})

return nil
}
Loading

0 comments on commit 92c16af

Please sign in to comment.