code wiki / (root) / nx_h264_mb.nx

nx_h264_mb.nx source

↩ module page · 40 lines · 1454 B

1// nx_h264_mb.nx -- H.264 I-slice macroblock type layer (rung 4d, spec 7.3.5 / 7.4.5). 2// mb_type (ue) for an I slice: 3// 0 = I_NxN (Intra_4x4 / Intra_8x8; needs pred-mode signalling + me(v) CBP) 4// 1..24 = I_16x16 (prediction mode + coded_block_pattern derive ARITHMETICALLY) 5// 25 = I_PCM 6// For I_16x16 (mt = mb_type-1, Table 7-11): 7// Intra16x16PredMode = mt % 4 (0 V, 1 H, 2 DC, 3 Plane) 8// CodedBlockPatternChroma = (mt / 4) % 3 (0,1,2) 9// CodedBlockPatternLuma = (mt / 12) * 15 (0 or 15) 10// mb_type itself = ue(v) via the already-gated nx_h264_bits reader. 11// 12// genealogy_id: itu_t_h264_sec7_4_5_mb_pred + table7_11_i16x16 13// lineage_id: mb_type_classify + i16x16_arith_derive 14// license_tier: ORIGINAL 15import "nx_syscalls.nx" 16import "nx_h264_bits.nx" 17 18const NX_MB_I_NXN: i64 = 0 19const NX_MB_I_16X16: i64 = 1 20const NX_MB_I_PCM: i64 = 2 21 22func nx_h264_mb_type_class(mb_type: i64) -> i64 { 23 if mb_type == 0 { return NX_MB_I_NXN } 24 if mb_type == 25 { return NX_MB_I_PCM } 25 return NX_MB_I_16X16 26} 27 28// out[0]=Intra16x16PredMode out[1]=cbp_chroma out[2]=cbp_luma (valid for mb_type 1..24) 29func nx_h264_i16x16_derive(mb_type: i64, out: *i64) -> i64 { 30 let mt: i64 = mb_type - 1 31 out[0] = mt % 4 32 out[1] = (mt / 4) % 3 33 out[2] = (mt / 12) * 15 34 return 0 35} 36 37// read an I-slice mb_type from the bitstream (ue) 38func nx_h264_mb_parse_itype(br: *BitReader) -> i64 { 39 return br_read_ue(br) 40}