Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Apr 13, 2023
1 parent 23d980d commit 316fda1
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 61 deletions.
2 changes: 2 additions & 0 deletions format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ const (
MP3_FRAME_XING = "mp3_frame_xing"
MP4 = "mp4"
MPEG_ASC = "mpeg_asc"
MPEG_CC_DATA = "mpeg_cc_data"
MPEG_ES = "mpeg_es"
MPEG_ITU_T35 = "mpeg_itu_t35"
MPEG_PES = "mpeg_pes"
MPEG_PES_PACKET = "mpeg_pes_packet"
MPEG_SPU = "mpeg_spu"
Expand Down
132 changes: 71 additions & 61 deletions format/mpeg/avc_sei.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,83 @@ import (
"github.com/wader/fq/pkg/scalar"
)

var avcSeiMpegItuT35Format decode.Group

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

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 @@ -107,10 +113,14 @@ func avcSEIDecode(d *decode.D) any {

d.FramedFn(int64(payloadSize)*8, func(d *decode.D) {
switch payloadType {
case avcSEIUserDataRegisteredItuTT35:
d.FieldFormat("data", avcSeiMpegItuT35Format, 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
41 changes: 41 additions & 0 deletions format/mpeg/mpeg_cc_data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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(decode.Format{
Name: format.MPEG_CC_DATA,
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 316fda1

Please sign in to comment.