@@ -94,8 +94,6 @@ static void torch_jpeg_set_source_mgr(
94
94
torch::Tensor decodeJPEG (const torch::Tensor& data) {
95
95
struct jpeg_decompress_struct cinfo;
96
96
struct torch_jpeg_error_mgr jerr;
97
- /* Output row buffer */
98
- JSAMPARRAY buffer;
99
97
100
98
auto datap = data.data_ptr <uint8_t >();
101
99
// Setup decompression structure
@@ -125,18 +123,12 @@ torch::Tensor decodeJPEG(const torch::Tensor& data) {
125
123
auto tensor = torch::empty (
126
124
{int64_t (height), int64_t (width), int64_t (components)}, torch::kU8 );
127
125
auto ptr = tensor.data_ptr <uint8_t >();
128
- /* Make a one-row-high sample array that will go away when done with image */
129
- buffer =
130
- (*cinfo.mem ->alloc_sarray )((j_common_ptr)&cinfo, JPOOL_IMAGE, stride, 1 );
131
-
132
126
while (cinfo.output_scanline < cinfo.output_height ) {
133
127
/* jpeg_read_scanlines expects an array of pointers to scanlines.
134
128
* Here the array is only one element long, but you could ask for
135
129
* more than one scanline at a time if that's more convenient.
136
130
*/
137
- jpeg_read_scanlines (&cinfo, buffer, 1 );
138
- JSAMPROW line = buffer[0 ];
139
- std::copy (&line[0 ], &line[stride - 1 ], ptr);
131
+ jpeg_read_scanlines (&cinfo, &ptr, 1 );
140
132
ptr += stride;
141
133
}
142
134
0 commit comments