Lines Matching refs:stream
66 static int jpeg_get_byte(struct jpeg_stream *stream) in jpeg_get_byte() argument
68 if (stream->curr >= stream->end) in jpeg_get_byte()
71 return *stream->curr++; in jpeg_get_byte()
75 static int jpeg_get_word_be(struct jpeg_stream *stream) in jpeg_get_word_be() argument
79 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_get_word_be()
82 word = get_unaligned_be16(stream->curr); in jpeg_get_word_be()
83 stream->curr += sizeof(__be16); in jpeg_get_word_be()
88 static int jpeg_skip(struct jpeg_stream *stream, size_t len) in jpeg_skip() argument
90 if (stream->curr + len > stream->end) in jpeg_skip()
93 stream->curr += len; in jpeg_skip()
98 static int jpeg_next_marker(struct jpeg_stream *stream) in jpeg_next_marker() argument
103 while ((byte = jpeg_get_byte(stream)) >= 0) { in jpeg_next_marker()
114 static int jpeg_reference_segment(struct jpeg_stream *stream, in jpeg_reference_segment() argument
119 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_reference_segment()
122 len = get_unaligned_be16(stream->curr); in jpeg_reference_segment()
123 if (stream->curr + len > stream->end) in jpeg_reference_segment()
126 segment->start = stream->curr; in jpeg_reference_segment()
155 static int jpeg_parse_frame_header(struct jpeg_stream *stream, u16 sof_marker, in jpeg_parse_frame_header() argument
158 int len = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
171 p = jpeg_get_byte(stream); in jpeg_parse_frame_header()
181 y = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
187 x = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
193 nf = jpeg_get_byte(stream); in jpeg_parse_frame_header()
214 c = jpeg_get_byte(stream); in jpeg_parse_frame_header()
218 h_v = jpeg_get_byte(stream); in jpeg_parse_frame_header()
233 tq = jpeg_get_byte(stream); in jpeg_parse_frame_header()
245 return jpeg_skip(stream, len - 2); in jpeg_parse_frame_header()
251 static int jpeg_parse_scan_header(struct jpeg_stream *stream, in jpeg_parse_scan_header() argument
255 int len = jpeg_get_word_be(stream); in jpeg_parse_scan_header()
267 ns = jpeg_get_byte(stream); in jpeg_parse_scan_header()
279 cs = jpeg_get_byte(stream); in jpeg_parse_scan_header()
283 td_ta = jpeg_get_byte(stream); in jpeg_parse_scan_header()
300 return jpeg_skip(stream, skip); in jpeg_parse_scan_header()
304 static int jpeg_parse_quantization_tables(struct jpeg_stream *stream, in jpeg_parse_quantization_tables() argument
308 int len = jpeg_get_word_be(stream); in jpeg_parse_quantization_tables()
320 int pq_tq = jpeg_get_byte(stream); in jpeg_parse_quantization_tables()
341 qk = stream->curr; in jpeg_parse_quantization_tables()
342 ret = jpeg_skip(stream, pq ? 128 : 64); in jpeg_parse_quantization_tables()
358 static int jpeg_parse_huffman_tables(struct jpeg_stream *stream, in jpeg_parse_huffman_tables() argument
362 int len = jpeg_get_word_be(stream); in jpeg_parse_huffman_tables()
372 int tc_th = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
390 table = stream->curr; in jpeg_parse_huffman_tables()
395 li = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
402 ret = jpeg_skip(stream, mt); in jpeg_parse_huffman_tables()
408 tables[(tc << 1) | th].length = stream->curr - table; in jpeg_parse_huffman_tables()
412 return jpeg_skip(stream, len - 2); in jpeg_parse_huffman_tables()
416 static int jpeg_parse_restart_interval(struct jpeg_stream *stream, in jpeg_parse_restart_interval() argument
419 int len = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
427 ri = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
436 static int jpeg_skip_segment(struct jpeg_stream *stream) in jpeg_skip_segment() argument
438 int len = jpeg_get_word_be(stream); in jpeg_skip_segment()
445 return jpeg_skip(stream, len - 2); in jpeg_skip_segment()
449 static int jpeg_parse_app14_data(struct jpeg_stream *stream, in jpeg_parse_app14_data() argument
456 lp = jpeg_get_word_be(stream); in jpeg_parse_app14_data()
461 if (stream->curr + 6 > stream->end || in jpeg_parse_app14_data()
462 strncmp(stream->curr, "Adobe\0", 6)) in jpeg_parse_app14_data()
463 return jpeg_skip(stream, lp - 2); in jpeg_parse_app14_data()
466 ret = jpeg_skip(stream, 11); in jpeg_parse_app14_data()
470 ret = jpeg_get_byte(stream); in jpeg_parse_app14_data()
478 return jpeg_skip(stream, skip); in jpeg_parse_app14_data()
496 struct jpeg_stream stream; in v4l2_jpeg_parse_header() local
500 stream.curr = buf; in v4l2_jpeg_parse_header()
501 stream.end = stream.curr + len; in v4l2_jpeg_parse_header()
507 if (jpeg_get_word_be(&stream) != SOI) in v4l2_jpeg_parse_header()
514 while ((marker = jpeg_next_marker(&stream)) >= 0) { in v4l2_jpeg_parse_header()
518 ret = jpeg_reference_segment(&stream, &out->sof); in v4l2_jpeg_parse_header()
521 ret = jpeg_parse_frame_header(&stream, marker, in v4l2_jpeg_parse_header()
536 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
541 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
544 ret = jpeg_parse_huffman_tables(&stream, in v4l2_jpeg_parse_header()
548 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
553 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
556 ret = jpeg_parse_quantization_tables(&stream, in v4l2_jpeg_parse_header()
561 ret = jpeg_parse_restart_interval(&stream, in v4l2_jpeg_parse_header()
565 ret = jpeg_parse_app14_data(&stream, in v4l2_jpeg_parse_header()
569 ret = jpeg_reference_segment(&stream, &out->sos); in v4l2_jpeg_parse_header()
572 ret = jpeg_parse_scan_header(&stream, out->scan); in v4l2_jpeg_parse_header()
577 out->ecs_offset = stream.curr - (u8 *)buf; in v4l2_jpeg_parse_header()
588 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
610 struct jpeg_stream stream; in v4l2_jpeg_parse_frame_header() local
612 stream.curr = buf; in v4l2_jpeg_parse_frame_header()
613 stream.end = stream.curr + len; in v4l2_jpeg_parse_frame_header()
614 return jpeg_parse_frame_header(&stream, SOF0, frame_header); in v4l2_jpeg_parse_frame_header()
629 struct jpeg_stream stream; in v4l2_jpeg_parse_scan_header() local
631 stream.curr = buf; in v4l2_jpeg_parse_scan_header()
632 stream.end = stream.curr + len; in v4l2_jpeg_parse_scan_header()
633 return jpeg_parse_scan_header(&stream, scan_header); in v4l2_jpeg_parse_scan_header()
650 struct jpeg_stream stream; in v4l2_jpeg_parse_quantization_tables() local
652 stream.curr = buf; in v4l2_jpeg_parse_quantization_tables()
653 stream.end = stream.curr + len; in v4l2_jpeg_parse_quantization_tables()
654 return jpeg_parse_quantization_tables(&stream, precision, q_tables); in v4l2_jpeg_parse_quantization_tables()
671 struct jpeg_stream stream; in v4l2_jpeg_parse_huffman_tables() local
673 stream.curr = buf; in v4l2_jpeg_parse_huffman_tables()
674 stream.end = stream.curr + len; in v4l2_jpeg_parse_huffman_tables()
675 return jpeg_parse_huffman_tables(&stream, huffman_tables); in v4l2_jpeg_parse_huffman_tables()