nx_h264_pmb.nx source
↩ module page · 49 lines · 1741 B
1// nx_h264_pmb.nx -- P-macroblock type layer (ITU-T H.264 Tables 7-13 + 7-18).
2// The shape/partition data the P entropy parse needs to know how many ref_idx + mvd
3// to read per macroblock. Inter only (mb_type 0..4); mb_type>=5 = intra (use I path on mb_type-5).
4// P mb_type: 0=P_L0_16x16 1=P_L0_L0_16x8 2=P_L0_L0_8x16 3=P_8x8 4=P_8x8ref0
5// sub_mb_type (P_8x8): 0=8x8 1=8x4 2=4x8 3=4x4
6// genealogy_id: itu_t_h264_table7_13_mb_type_p + table7_18_sub_mb_type_p
7// lineage_id: p_mb_partition_shape + sub_partition_count
8// license_tier: ORIGINAL
9import "nx_syscalls.nx"
10
11// kind: 0=16x16, 1=16x8, 2=8x16, 3=P8x8, 4=P8x8ref0, -1 = intra (mb_type>=5)
12func nx_h264_pmb_kind(mb_type: i64) -> i64 {
13 if mb_type < 0 { return 0 - 1 }
14 if mb_type <= 4 { return mb_type }
15 return 0 - 1
16}
17
18// number of top-level motion partitions: 16x16->1, 16x8->2, 8x16->2, P8x8(+ref0)->4
19func nx_h264_pmb_nparts(kind: i64) -> i64 {
20 if kind == 0 { return 1 }
21 if kind == 1 { return 2 }
22 if kind == 2 { return 2 }
23 if kind == 3 { return 4 }
24 if kind == 4 { return 4 }
25 return 0
26}
27
28// is this kind a P_8x8 variant (needs sub_mb_type x4)?
29func nx_h264_pmb_is_8x8(kind: i64) -> i64 {
30 if kind == 3 { return 1 }
31 if kind == 4 { return 1 }
32 return 0
33}
34
35// does this kind code ref_idx per partition? (P_8x8ref0 forces ref 0 -> not coded)
36func nx_h264_pmb_codes_ref(kind: i64) -> i64 {
37 if kind == 4 { return 0 }
38 if kind < 0 { return 0 }
39 return 1
40}
41
42// sub_mb_type -> number of sub-partitions (MVs) within one 8x8: 8x8->1 8x4->2 4x8->2 4x4->4
43func nx_h264_psub_nparts(sub: i64) -> i64 {
44 if sub == 0 { return 1 }
45 if sub == 1 { return 2 }
46 if sub == 2 { return 2 }
47 if sub == 3 { return 4 }
48 return 0
49}