Skip to content

Commit 82539ca

Browse files
committed
Remove unnecessary memcpy
1 parent 10db492 commit 82539ca

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

torchvision/csrc/cpu/image/readjpeg_cpu.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ static void torch_jpeg_set_source_mgr(
9494
torch::Tensor decodeJPEG(const torch::Tensor& data) {
9595
struct jpeg_decompress_struct cinfo;
9696
struct torch_jpeg_error_mgr jerr;
97-
/* Output row buffer */
98-
JSAMPARRAY buffer;
9997

10098
auto datap = data.data_ptr<uint8_t>();
10199
// Setup decompression structure
@@ -125,18 +123,12 @@ torch::Tensor decodeJPEG(const torch::Tensor& data) {
125123
auto tensor = torch::empty(
126124
{int64_t(height), int64_t(width), int64_t(components)}, torch::kU8);
127125
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-
132126
while (cinfo.output_scanline < cinfo.output_height) {
133127
/* jpeg_read_scanlines expects an array of pointers to scanlines.
134128
* Here the array is only one element long, but you could ask for
135129
* more than one scanline at a time if that's more convenient.
136130
*/
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);
140132
ptr += stride;
141133
}
142134

0 commit comments

Comments
 (0)