summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-20 00:21:23 +0100
committerwm4 <wm4@nowhere>2015-03-20 00:21:23 +0100
commit5f2a8474aee2a0353a07a6a74a0312f5e5f5ef23 (patch)
treeefbca333ddc28a1006b1507667e7b58008bd9eab /video/mp_image.c
parent145922a0700b50ffb38f20957c28020562f8d428 (diff)
downloadmpv-5f2a8474aee2a0353a07a6a74a0312f5e5f5ef23.tar.bz2
mpv-5f2a8474aee2a0353a07a6a74a0312f5e5f5ef23.tar.xz
video: uninline memcpy_pic functions
There's literally no reason why these functions have to be inline (they might be performance critical, but then the function call overhead isn't going to matter at all). Uninline them and move them to mp_image.c. Drop the header file and fix all uses of it.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index 20e246792d..3280fd86aa 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -35,7 +35,6 @@
#include "img_format.h"
#include "mp_image.h"
#include "sws_utils.h"
-#include "memcpy_pic.h"
#include "fmt-conversion.h"
#include "video/filter/vf.h"
@@ -723,3 +722,50 @@ struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img)
talloc_free(new_ref);
return frame;
}
+
+void memcpy_pic(void *dst, const void *src, int bytesPerLine, int height,
+ int dstStride, int srcStride)
+{
+ if (bytesPerLine == dstStride && dstStride == srcStride) {
+ if (srcStride < 0) {
+ src = (uint8_t*)src + (height - 1) * srcStride;
+ dst = (uint8_t*)dst + (height - 1) * dstStride;
+ srcStride = -srcStride;
+ }
+
+ memcpy(dst, src, srcStride * height);
+ } else {
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, bytesPerLine);
+ src = (uint8_t*)src + srcStride;
+ dst = (uint8_t*)dst + dstStride;
+ }
+ }
+}
+
+void memset_pic(void *dst, int fill, int bytesPerLine, int height, int stride)
+{
+ if (bytesPerLine == stride) {
+ memset(dst, fill, stride * height);
+ } else {
+ for (int i = 0; i < height; i++) {
+ memset(dst, fill, bytesPerLine);
+ dst = (uint8_t *)dst + stride;
+ }
+ }
+}
+
+void memset16_pic(void *dst, int fill, int unitsPerLine, int height, int stride)
+{
+ if (fill == 0) {
+ memset_pic(dst, 0, unitsPerLine * 2, height, stride);
+ } else {
+ for (int i = 0; i < height; i++) {
+ uint16_t *line = dst;
+ uint16_t *end = line + unitsPerLine;
+ while (line < end)
+ *line++ = fill;
+ dst = (uint8_t *)dst + stride;
+ }
+ }
+}