Lines Matching refs:stream

65 static int jpeg_get_byte(struct jpeg_stream *stream)  in jpeg_get_byte()  argument
67 if (stream->curr >= stream->end) in jpeg_get_byte()
70 return *stream->curr++; in jpeg_get_byte()
74 static int jpeg_get_word_be(struct jpeg_stream *stream) in jpeg_get_word_be() argument
78 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_get_word_be()
81 word = get_unaligned_be16(stream->curr); in jpeg_get_word_be()
82 stream->curr += sizeof(__be16); in jpeg_get_word_be()
87 static int jpeg_skip(struct jpeg_stream *stream, size_t len) in jpeg_skip() argument
89 if (stream->curr + len > stream->end) in jpeg_skip()
92 stream->curr += len; in jpeg_skip()
97 static int jpeg_next_marker(struct jpeg_stream *stream) in jpeg_next_marker() argument
102 while ((byte = jpeg_get_byte(stream)) >= 0) { in jpeg_next_marker()
113 static int jpeg_reference_segment(struct jpeg_stream *stream, in jpeg_reference_segment() argument
118 if (stream->curr + sizeof(__be16) > stream->end) in jpeg_reference_segment()
121 len = get_unaligned_be16(stream->curr); in jpeg_reference_segment()
122 if (stream->curr + len > stream->end) in jpeg_reference_segment()
125 segment->start = stream->curr; in jpeg_reference_segment()
154 static int jpeg_parse_frame_header(struct jpeg_stream *stream, u16 sof_marker, in jpeg_parse_frame_header() argument
157 int len = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
170 p = jpeg_get_byte(stream); in jpeg_parse_frame_header()
180 y = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
186 x = jpeg_get_word_be(stream); in jpeg_parse_frame_header()
192 nf = jpeg_get_byte(stream); in jpeg_parse_frame_header()
213 c = jpeg_get_byte(stream); in jpeg_parse_frame_header()
217 h_v = jpeg_get_byte(stream); in jpeg_parse_frame_header()
232 tq = jpeg_get_byte(stream); in jpeg_parse_frame_header()
244 return jpeg_skip(stream, len - 2); in jpeg_parse_frame_header()
250 static int jpeg_parse_scan_header(struct jpeg_stream *stream, in jpeg_parse_scan_header() argument
254 int len = jpeg_get_word_be(stream); in jpeg_parse_scan_header()
266 ns = jpeg_get_byte(stream); in jpeg_parse_scan_header()
278 cs = jpeg_get_byte(stream); in jpeg_parse_scan_header()
282 td_ta = jpeg_get_byte(stream); in jpeg_parse_scan_header()
299 return jpeg_skip(stream, skip); in jpeg_parse_scan_header()
303 static int jpeg_parse_quantization_tables(struct jpeg_stream *stream, in jpeg_parse_quantization_tables() argument
307 int len = jpeg_get_word_be(stream); in jpeg_parse_quantization_tables()
319 int pq_tq = jpeg_get_byte(stream); in jpeg_parse_quantization_tables()
340 qk = stream->curr; in jpeg_parse_quantization_tables()
341 ret = jpeg_skip(stream, pq ? 128 : 64); in jpeg_parse_quantization_tables()
357 static int jpeg_parse_huffman_tables(struct jpeg_stream *stream, in jpeg_parse_huffman_tables() argument
361 int len = jpeg_get_word_be(stream); in jpeg_parse_huffman_tables()
371 int tc_th = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
389 table = stream->curr; in jpeg_parse_huffman_tables()
394 li = jpeg_get_byte(stream); in jpeg_parse_huffman_tables()
401 ret = jpeg_skip(stream, mt); in jpeg_parse_huffman_tables()
407 tables[(tc << 1) | th].length = stream->curr - table; in jpeg_parse_huffman_tables()
411 return jpeg_skip(stream, len - 2); in jpeg_parse_huffman_tables()
415 static int jpeg_parse_restart_interval(struct jpeg_stream *stream, in jpeg_parse_restart_interval() argument
418 int len = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
426 ri = jpeg_get_word_be(stream); in jpeg_parse_restart_interval()
435 static int jpeg_skip_segment(struct jpeg_stream *stream) in jpeg_skip_segment() argument
437 int len = jpeg_get_word_be(stream); in jpeg_skip_segment()
444 return jpeg_skip(stream, len - 2); in jpeg_skip_segment()
462 struct jpeg_stream stream; in v4l2_jpeg_parse_header() local
466 stream.curr = buf; in v4l2_jpeg_parse_header()
467 stream.end = stream.curr + len; in v4l2_jpeg_parse_header()
473 marker = jpeg_next_marker(&stream); in v4l2_jpeg_parse_header()
480 while ((marker = jpeg_next_marker(&stream)) >= 0) { in v4l2_jpeg_parse_header()
484 ret = jpeg_reference_segment(&stream, &out->sof); in v4l2_jpeg_parse_header()
487 ret = jpeg_parse_frame_header(&stream, marker, in v4l2_jpeg_parse_header()
502 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
506 ret = jpeg_parse_huffman_tables(&stream, in v4l2_jpeg_parse_header()
510 ret = jpeg_reference_segment(&stream, in v4l2_jpeg_parse_header()
514 ret = jpeg_parse_quantization_tables(&stream, in v4l2_jpeg_parse_header()
519 ret = jpeg_parse_restart_interval(&stream, in v4l2_jpeg_parse_header()
524 ret = jpeg_reference_segment(&stream, &out->sos); in v4l2_jpeg_parse_header()
527 ret = jpeg_parse_scan_header(&stream, out->scan); in v4l2_jpeg_parse_header()
532 out->ecs_offset = stream.curr - (u8 *)buf; in v4l2_jpeg_parse_header()
543 ret = jpeg_skip_segment(&stream); in v4l2_jpeg_parse_header()
565 struct jpeg_stream stream; in v4l2_jpeg_parse_frame_header() local
567 stream.curr = buf; in v4l2_jpeg_parse_frame_header()
568 stream.end = stream.curr + len; in v4l2_jpeg_parse_frame_header()
569 return jpeg_parse_frame_header(&stream, SOF0, frame_header); in v4l2_jpeg_parse_frame_header()
584 struct jpeg_stream stream; in v4l2_jpeg_parse_scan_header() local
586 stream.curr = buf; in v4l2_jpeg_parse_scan_header()
587 stream.end = stream.curr + len; in v4l2_jpeg_parse_scan_header()
588 return jpeg_parse_scan_header(&stream, scan_header); in v4l2_jpeg_parse_scan_header()
605 struct jpeg_stream stream; in v4l2_jpeg_parse_quantization_tables() local
607 stream.curr = buf; in v4l2_jpeg_parse_quantization_tables()
608 stream.end = stream.curr + len; in v4l2_jpeg_parse_quantization_tables()
609 return jpeg_parse_quantization_tables(&stream, precision, q_tables); in v4l2_jpeg_parse_quantization_tables()
626 struct jpeg_stream stream; in v4l2_jpeg_parse_huffman_tables() local
628 stream.curr = buf; in v4l2_jpeg_parse_huffman_tables()
629 stream.end = stream.curr + len; in v4l2_jpeg_parse_huffman_tables()
630 return jpeg_parse_huffman_tables(&stream, huffman_tables); in v4l2_jpeg_parse_huffman_tables()