mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
Avoid memcpy.
BUG=176 TEST=NONE Review URL: https://webrtc-codereview.appspot.com/1081004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@552 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
573a883dd6
commit
9e4e12352a
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libyuv/mjpeg_decoder.h"
|
#include "libyuv/mjpeg_decoder.h"
|
||||||
|
#include "libyuv/planar_functions.h" // For CopyPlane().
|
||||||
|
|
||||||
#ifdef HAVE_JPEG
|
#ifdef HAVE_JPEG
|
||||||
// Must be included before jpeglib
|
// Must be included before jpeglib
|
||||||
@ -254,15 +255,6 @@ bool MJpegDecoder::UnloadFrame() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CopyRows(uint8* source, int source_stride,
|
|
||||||
uint8* dest, int pixels, int numrows) {
|
|
||||||
for (int i = 0; i < numrows; ++i) {
|
|
||||||
memcpy(dest, source, pixels);
|
|
||||||
dest += pixels;
|
|
||||||
source += source_stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(fbarchard): Allow rectangle to be specified: x, y, width, height.
|
// TODO(fbarchard): Allow rectangle to be specified: x, y, width, height.
|
||||||
bool MJpegDecoder::DecodeToBuffers(
|
bool MJpegDecoder::DecodeToBuffers(
|
||||||
uint8** planes, int dst_width, int dst_height) {
|
uint8** planes, int dst_width, int dst_height) {
|
||||||
@ -313,8 +305,9 @@ bool MJpegDecoder::DecodeToBuffers(
|
|||||||
int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i) -
|
int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i) -
|
||||||
rows_to_skip;
|
rows_to_skip;
|
||||||
int data_to_skip = rows_to_skip * GetComponentStride(i);
|
int data_to_skip = rows_to_skip * GetComponentStride(i);
|
||||||
CopyRows(databuf_[i] + data_to_skip, GetComponentStride(i),
|
CopyPlane(databuf_[i] + data_to_skip, GetComponentStride(i),
|
||||||
planes[i], GetComponentWidth(i), scanlines_to_copy);
|
planes[i], GetComponentWidth(i),
|
||||||
|
GetComponentWidth(i), scanlines_to_copy);
|
||||||
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
||||||
}
|
}
|
||||||
lines_left -= (GetImageScanlinesPerImcuRow() - skip);
|
lines_left -= (GetImageScanlinesPerImcuRow() - skip);
|
||||||
@ -330,8 +323,9 @@ bool MJpegDecoder::DecodeToBuffers(
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < num_outbufs_; ++i) {
|
for (int i = 0; i < num_outbufs_; ++i) {
|
||||||
int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i);
|
int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i);
|
||||||
CopyRows(databuf_[i], GetComponentStride(i),
|
CopyPlane(databuf_[i], GetComponentStride(i),
|
||||||
planes[i], GetComponentWidth(i), scanlines_to_copy);
|
planes[i], GetComponentWidth(i),
|
||||||
|
GetComponentWidth(i), scanlines_to_copy);
|
||||||
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,8 +339,9 @@ bool MJpegDecoder::DecodeToBuffers(
|
|||||||
for (int i = 0; i < num_outbufs_; ++i) {
|
for (int i = 0; i < num_outbufs_; ++i) {
|
||||||
int scanlines_to_copy =
|
int scanlines_to_copy =
|
||||||
DivideAndRoundUp(lines_left, GetVertSubSampFactor(i));
|
DivideAndRoundUp(lines_left, GetVertSubSampFactor(i));
|
||||||
CopyRows(databuf_[i], GetComponentStride(i),
|
CopyPlane(databuf_[i], GetComponentStride(i),
|
||||||
planes[i], GetComponentWidth(i), scanlines_to_copy);
|
planes[i], GetComponentWidth(i),
|
||||||
|
GetComponentWidth(i), scanlines_to_copy);
|
||||||
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user