Lines Matching +full:7 +full:- +full:segment

1 // SPDX-License-Identifier: MIT
25 //! * <https://github.com/kennytm/qrcode-rust>
36 const P7: [u8; 7] = [87, 229, 146, 149, 238, 102, 21];
69 /// - Error Correction polynomial.
70 /// - Number of blocks in group 1.
71 /// - Number of blocks in group 2.
72 /// - Block size in group 1.
98 VersionParameter(&P28, 2, 7, 111), // V22
105 VersionParameter(&P30, 7, 7, 116), // V29
111 VersionParameter(&P30, 12, 7, 121), // V35
166 /// Version information for format V7-V40.
211 fn from_segments(segments: &[&Segment<'_>]) -> Option<Version> { in from_segments()
217 fn width(&self) -> u8 { in width()
221 fn max_data(&self) -> usize { in max_data()
225 fn ec_size(&self) -> usize { in ec_size()
226 VPARAM[self.0 - 1].0.len() in ec_size()
229 fn g1_blocks(&self) -> usize { in g1_blocks()
230 VPARAM[self.0 - 1].1 as usize in g1_blocks()
233 fn g2_blocks(&self) -> usize { in g2_blocks()
234 VPARAM[self.0 - 1].2 as usize in g2_blocks()
237 fn g1_blk_size(&self) -> usize { in g1_blk_size()
238 VPARAM[self.0 - 1].3 as usize in g1_blk_size()
241 fn alignment_pattern(&self) -> &'static [u8] { in alignment_pattern()
242 ALIGNMENT_PATTERNS[self.0 - 1] in alignment_pattern()
245 fn poly(&self) -> &'static [u8] { in poly()
246 VPARAM[self.0 - 1].0 in poly()
249 fn version_info(&self) -> u32 { in version_info()
250 if *self >= Version(7) { in version_info()
251 VERSION_INFORMATION[self.0 - 7] in version_info()
269 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167,
283 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24,
292 // 4 bits segment header.
300 fn get_next_13b(data: &[u8], offset: usize) -> Option<(u16, usize)> { in get_next_13b()
302 let size = cmp::min(13, data.len() * 8 - offset); in get_next_13b()
305 // `b` is 20 at max (`bit_off` <= 7 and `size` <= 13). in get_next_13b()
311 0..=8 => first_byte >> (8 - b), in get_next_13b()
312 9..=16 => (first_byte << (b - 8)) + (data[byte_off + 1] >> (16 - b)) as u16, in get_next_13b()
314 (first_byte << (b - 8)) in get_next_13b()
315 + ((data[byte_off + 1] as u16) << (b - 16)) in get_next_13b()
316 + (data[byte_off + 2] >> (24 - b)) as u16 in get_next_13b()
326 const NUM_CHARS_BITS: [usize; 4] = [0, 4, 7, 10];
329 enum Segment<'a> { enum
334 impl Segment<'_> { impl
335 fn get_header(&self) -> (u16, usize) { in get_header()
337 Segment::Binary(_) => (MODE_BINARY, 4), in get_header()
338 Segment::Numeric(_) => (MODE_NUMERIC, 4), in get_header()
343 fn length_bits_count(&self, version: Version) -> usize { in length_bits_count()
346 Segment::Binary(_) => match v { in length_bits_count()
350 Segment::Numeric(_) => match v { in length_bits_count()
358 // Number of characters in the segment.
359 fn character_count(&self) -> usize { in character_count()
361 Segment::Binary(data) => data.len(), in character_count()
362 Segment::Numeric(data) => { in character_count()
374 fn get_length_field(&self, version: Version) -> (u16, usize) { in get_length_field()
381 fn total_size_bits(&self, version: Version) -> usize { in total_size_bits()
383 Segment::Binary(data) => data.len() * 8, in total_size_bits()
384 Segment::Numeric(_) => { in total_size_bits()
393 fn iter(&self) -> SegmentIterator<'_> { in iter()
395 segment: self, in iter()
404 segment: &'a Segment<'a>, field
413 fn next(&mut self) -> Option<Self::Item> { in next()
414 match self.segment { in next()
415 Segment::Binary(data) => { in next()
424 Segment::Numeric(data) => { in next()
437 self.carry_len = new_chars + self.carry_len - 3; in next()
439 self.carry * POW10[new_chars - self.carry_len] in next()
476 /// Data to be put in the QR code, with correct segment encoding, padding, and
479 fn new<'a>(segments: &[&Segment<'_>], data: &'a mut [u8]) -> Option<EncodedMsg<'a>> { in new()
514 self.data[byte_off] = (number << (8 - b)) as u8; in push()
517 self.data[byte_off] = (number >> (b - 8)) as u8; in push()
518 self.data[byte_off + 1] = (number << (16 - b)) as u8; in push()
521 self.data[byte_off] |= (number << (8 - b)) as u8; in push()
524 self.data[byte_off] |= (number >> (b - 8)) as u8; in push()
525 self.data[byte_off + 1] = (number << (16 - b)) as u8; in push()
528 self.data[byte_off] |= (number >> (b - 8)) as u8; in push()
529 self.data[byte_off + 1] = (number >> (b - 16)) as u8; in push()
530 self.data[byte_off + 2] = (number << (24 - b)) as u8; in push()
536 fn add_segments(&mut self, segments: &[&Segment<'_>]) { in add_segments()
588 fn encode(&mut self, segments: &[&Segment<'_>]) { in encode()
593 fn iter(&self) -> EncodedMsgIterator<'_> { in iter()
612 fn next(&mut self) -> Option<Self::Item> { in next()
630 g1_end + em.g2_blk_size * (blk - em.g1_blocks) + blk_off in next()
634 let blk2 = self.offset - blocks * em.g1_blk_size; in next()
635 em.g1_blk_size * em.g1_blocks + blk2 * em.g2_blk_size + em.g2_blk_size - 1 in next()
638 let ec_offset = self.offset - g2_end; in next()
660 fn new<'a, 'b>(em: &'b EncodedMsg<'b>, qrdata: &'a mut [u8]) -> QrImage<'a> { in new()
706 self.draw_square(self.width - 6, 1, 4); in draw_finders()
707 self.draw_square(1, self.width - 6, 4); in draw_finders()
709 self.set(k, 7); in draw_finders()
710 self.set(self.width - k - 1, 7); in draw_finders()
711 self.set(k, self.width - 8); in draw_finders()
713 for k in 0..7 { in draw_finders()
714 self.set(7, k); in draw_finders()
715 self.set(self.width - 8, k); in draw_finders()
716 self.set(7, self.width - 1 - k); in draw_finders()
720 fn is_finder(&self, x: u8, y: u8) -> bool { in is_finder()
721 let end = self.width - 8; in is_finder()
734 self.draw_square(x - 1, y - 1, 2); in draw_alignments()
740 fn is_alignment(&self, x: u8, y: u8) -> bool { in is_alignment()
747 if x >= ax - 2 && x <= ax + 2 && y >= ay - 2 && y <= ay + 2 { in is_alignment()
757 let end = self.width - 8; in draw_timing_patterns()
765 fn is_timing(&self, x: u8, y: u8) -> bool { in is_timing()
774 for k in 0..7 { in draw_maskinfo()
778 if info & (1 << (14 - k)) == 0 { in draw_maskinfo()
780 self.set(8, self.width - 1 - k); in draw_maskinfo()
788 if info & (1 << (7 - k)) == 0 { in draw_maskinfo()
789 self.set(8, 8 - skip - k); in draw_maskinfo()
790 self.set(self.width - 8 + k, 8); in draw_maskinfo()
795 fn is_maskinfo(&self, x: u8, y: u8) -> bool { in is_maskinfo()
796 let end = self.width - 8; in is_maskinfo()
804 let pos = self.width - 11; in draw_version_info()
818 fn is_version_info(&self, x: u8, y: u8) -> bool { in is_version_info()
820 let pos = self.width - 11; in is_version_info()
826 fn is_reserved(&self, x: u8, y: u8) -> bool { in is_reserved()
835 fn is_last(&self, x: u8, y: u8) -> bool { in is_last()
836 x == 0 && y == self.width - 1 in is_last()
841 fn next(&self, x: u8, y: u8) -> (u8, u8) { in next()
843 let column_type = (self.width - x_adj) % 4; in next()
846 2 if y > 0 => (x + 1, y - 1), in next()
847 0 if y < self.width - 1 => (x + 1, y + 1), in next()
848 0 | 2 if x == 7 => (x - 2, y), in next()
849 _ => (x - 1, y), in next()
854 fn next_available(&self, x: u8, y: u8) -> (u8, u8) { in next_available()
863 let (mut x, mut y) = (self.width - 1, self.width - 1); in draw_data()
872 // Set the remaining modules (0, 3 or 7 depending on version). in draw_data()
882 // Apply checkerboard mask to all non-reserved modules.
912 /// * `url`: The base URL of the QR code. It will be encoded as Binary segment.
914 /// will be encoded as binary segment, otherwise it will be encoded
915 /// efficiently as a numeric segment, and appended to the URL.
927 /// * `url` must be null or point at a nul-terminated string.
940 ) -> u8 { in drm_panic_qr_generate()
951 match EncodedMsg::new(&[&Segment::Binary(&data_slice[0..data_len])], tmp_slice) { in drm_panic_qr_generate()
960 // nul-terminated string. in drm_panic_qr_generate()
963 &Segment::Binary(url_cstr.as_bytes()), in drm_panic_qr_generate()
964 &Segment::Numeric(&data_slice[0..data_len]), in drm_panic_qr_generate()
977 /// * `version`: QR code version, between 1-40.
982 /// * If `url_len` = 0, only removes 3 bytes for 1 binary segment.
984 pub extern "C" fn drm_panic_qr_max_data_size(version: u8, url_len: usize) -> usize { in drm_panic_qr_max_data_size()
992 // Binary segment (URL) 4 + 16 bits, numeric segment (kmsg) 4 + 12 bits => 5 bytes. in drm_panic_qr_max_data_size()
996 let max = max_data - url_len - 5; in drm_panic_qr_max_data_size()
1000 // Remove 3 bytes for the binary segment (header 4 bits, length 16 bits, stop 4bits). in drm_panic_qr_max_data_size()
1001 max_data - 3 in drm_panic_qr_max_data_size()