Lines Matching refs:stream
182 static int jpeg_get_byte(struct jpeg_stream *stream) in jpeg_get_byte() argument
184 if (stream->curr >= stream->end) in jpeg_get_byte()
187 return *stream->curr++; in jpeg_get_byte()
191 static int jpeg_get_word_be(struct jpeg_stream *stream) in jpeg_get_word_be() argument
195 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_get_word_be()
198 word = get_unaligned_be16(stream->curr); in jpeg_get_word_be()
199 stream->curr += sizeof(__be16); in jpeg_get_word_be()
204 static int jpeg_skip(struct jpeg_stream *stream, size_t len) in jpeg_skip() argument
206 if (stream->curr + len > stream->end) in jpeg_skip()
209 stream->curr += len; in jpeg_skip()
214 static int jpeg_next_marker(struct jpeg_stream *stream) in jpeg_next_marker() argument
219 while ((byte = jpeg_get_byte(stream)) >= 0) { in jpeg_next_marker()
230 static int jpeg_reference_segment(struct jpeg_stream *stream, in jpeg_reference_segment() argument
235 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_reference_segment()
238 len = get_unaligned_be16(stream->curr); in jpeg_reference_segment()
239 if (stream->curr + len > stream->end) in jpeg_reference_segment()
242 segment->start = stream->curr; in jpeg_reference_segment()
271 static int jpeg_parse_frame_header(struct jpeg_stream *stream, u16 sof_marker, in jpeg_parse_frame_header() argument
274 int len = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
287 p = jpeg_get_byte(stream); in jpeg_parse_frame_header()
297 y = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
303 x = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
309 nf = jpeg_get_byte(stream); in jpeg_parse_frame_header()
330 c = jpeg_get_byte(stream); in jpeg_parse_frame_header()
334 h_v = jpeg_get_byte(stream); in jpeg_parse_frame_header()
349 tq = jpeg_get_byte(stream); in jpeg_parse_frame_header()
361 return jpeg_skip(stream, len - 2); in jpeg_parse_frame_header()
367 static int jpeg_parse_scan_header(struct jpeg_stream *stream, in jpeg_parse_scan_header() argument
371 int len = jpeg_get_word_be(stream); in jpeg_parse_scan_header()
383 ns = jpeg_get_byte(stream); in jpeg_parse_scan_header()
395 cs = jpeg_get_byte(stream); in jpeg_parse_scan_header()
399 td_ta = jpeg_get_byte(stream); in jpeg_parse_scan_header()
416 return jpeg_skip(stream, skip); in jpeg_parse_scan_header()
420 static int jpeg_parse_quantization_tables(struct jpeg_stream *stream, in jpeg_parse_quantization_tables() argument
424 int len = jpeg_get_word_be(stream); in jpeg_parse_quantization_tables()
436 int pq_tq = jpeg_get_byte(stream); in jpeg_parse_quantization_tables()
457 qk = stream->curr; in jpeg_parse_quantization_tables()
458 ret = jpeg_skip(stream, pq ? 128 : 64); in jpeg_parse_quantization_tables()
474 static int jpeg_parse_huffman_tables(struct jpeg_stream *stream, in jpeg_parse_huffman_tables() argument
478 int len = jpeg_get_word_be(stream); in jpeg_parse_huffman_tables()
488 int tc_th = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
506 table = stream->curr; in jpeg_parse_huffman_tables()
511 li = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
518 ret = jpeg_skip(stream, mt); in jpeg_parse_huffman_tables()
524 tables[(tc << 1) | th].length = stream->curr - table; in jpeg_parse_huffman_tables()
528 return jpeg_skip(stream, len - 2); in jpeg_parse_huffman_tables()
532 static int jpeg_parse_restart_interval(struct jpeg_stream *stream, in jpeg_parse_restart_interval() argument
535 int len = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
543 ri = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
552 static int jpeg_skip_segment(struct jpeg_stream *stream) in jpeg_skip_segment() argument
554 int len = jpeg_get_word_be(stream); in jpeg_skip_segment()
561 return jpeg_skip(stream, len - 2); in jpeg_skip_segment()
565 static int jpeg_parse_app14_data(struct jpeg_stream *stream, in jpeg_parse_app14_data() argument
572 lp = jpeg_get_word_be(stream); in jpeg_parse_app14_data()
577 if (stream->curr + 6 > stream->end || in jpeg_parse_app14_data()
578 strncmp(stream->curr, "Adobe\0", 6)) in jpeg_parse_app14_data()
579 return jpeg_skip(stream, lp - 2); in jpeg_parse_app14_data()
582 ret = jpeg_skip(stream, 11); in jpeg_parse_app14_data()
586 ret = jpeg_get_byte(stream); in jpeg_parse_app14_data()
594 return jpeg_skip(stream, skip); in jpeg_parse_app14_data()
612 struct jpeg_stream stream; in v4l2_jpeg_parse_header() local
616 stream.curr = buf; in v4l2_jpeg_parse_header()
617 stream.end = stream.curr + len; in v4l2_jpeg_parse_header()
623 if (jpeg_get_word_be(&stream) != SOI) in v4l2_jpeg_parse_header()
630 while ((marker = jpeg_next_marker(&stream)) >= 0) { in v4l2_jpeg_parse_header()
634 ret = jpeg_reference_segment(&stream, &out->sof); in v4l2_jpeg_parse_header()
637 ret = jpeg_parse_frame_header(&stream, marker, in v4l2_jpeg_parse_header()
652 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
657 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
660 ret = jpeg_parse_huffman_tables(&stream, in v4l2_jpeg_parse_header()
664 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
669 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
672 ret = jpeg_parse_quantization_tables(&stream, in v4l2_jpeg_parse_header()
677 ret = jpeg_parse_restart_interval(&stream, in v4l2_jpeg_parse_header()
681 ret = jpeg_parse_app14_data(&stream, in v4l2_jpeg_parse_header()
685 ret = jpeg_reference_segment(&stream, &out->sos); in v4l2_jpeg_parse_header()
688 ret = jpeg_parse_scan_header(&stream, out->scan); in v4l2_jpeg_parse_header()
693 out->ecs_offset = stream.curr - (u8 *)buf; in v4l2_jpeg_parse_header()
704 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
726 struct jpeg_stream stream; in v4l2_jpeg_parse_frame_header() local
728 stream.curr = buf; in v4l2_jpeg_parse_frame_header()
729 stream.end = stream.curr + len; in v4l2_jpeg_parse_frame_header()
730 return jpeg_parse_frame_header(&stream, SOF0, frame_header); in v4l2_jpeg_parse_frame_header()
745 struct jpeg_stream stream; in v4l2_jpeg_parse_scan_header() local
747 stream.curr = buf; in v4l2_jpeg_parse_scan_header()
748 stream.end = stream.curr + len; in v4l2_jpeg_parse_scan_header()
749 return jpeg_parse_scan_header(&stream, scan_header); in v4l2_jpeg_parse_scan_header()
766 struct jpeg_stream stream; in v4l2_jpeg_parse_quantization_tables() local
768 stream.curr = buf; in v4l2_jpeg_parse_quantization_tables()
769 stream.end = stream.curr + len; in v4l2_jpeg_parse_quantization_tables()
770 return jpeg_parse_quantization_tables(&stream, precision, q_tables); in v4l2_jpeg_parse_quantization_tables()
787 struct jpeg_stream stream; in v4l2_jpeg_parse_huffman_tables() local
789 stream.curr = buf; in v4l2_jpeg_parse_huffman_tables()
790 stream.end = stream.curr + len; in v4l2_jpeg_parse_huffman_tables()
791 return jpeg_parse_huffman_tables(&stream, huffman_tables); in v4l2_jpeg_parse_huffman_tables()