summaryrefslogtreecommitdiff
path: root/tools_common.c
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-02-07 11:37:39 -0800
committerDmitry Kovalev <dkovalev@google.com>2014-02-07 11:37:39 -0800
commit592936b4970582ee59cf3764188813b9ee5d7c46 (patch)
treebb1ceb21ecacd63e2e6d4d2bd8030a684fee24a9 /tools_common.c
parent9e41de4d615907809cba089a5206a9155301285d (diff)
downloadlibvpx-592936b4970582ee59cf3764188813b9ee5d7c46.tar
libvpx-592936b4970582ee59cf3764188813b9ee5d7c46.tar.gz
libvpx-592936b4970582ee59cf3764188813b9ee5d7c46.tar.bz2
libvpx-592936b4970582ee59cf3764188813b9ee5d7c46.zip
Cleaning up {simple, twopass}_encoder examples.
Change-Id: Ide9c408f4cee7408741ef8c0ffac01645a5a67ca
Diffstat (limited to 'tools_common.c')
-rw-r--r--tools_common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools_common.c b/tools_common.c
index 85bedc99d..53546878b 100644
--- a/tools_common.c
+++ b/tools_common.c
@@ -168,9 +168,31 @@ void vpx_img_write(const vpx_image_t *img, FILE *file) {
const int stride = img->stride[plane];
const int w = plane ? (img->d_w + 1) >> 1 : img->d_w;
const int h = plane ? (img->d_h + 1) >> 1 : img->d_h;
+
for (y = 0; y < h; ++y) {
fwrite(buf, 1, w, file);
buf += stride;
}
}
}
+
+int vpx_img_read(vpx_image_t *img, FILE *file) {
+ int plane;
+
+ for (plane = 0; plane < 3; ++plane) {
+ unsigned char *buf = img->planes[plane];
+ const int stride = img->stride[plane];
+ const int w = plane ? (img->d_w + 1) >> 1 : img->d_w;
+ const int h = plane ? (img->d_h + 1) >> 1 : img->d_h;
+ int y;
+
+ for (y = 0; y < h; ++y) {
+ if (fread(buf, 1, w, file) != w)
+ return 0;
+ buf += stride;
+ }
+ }
+
+ return 1;
+}
+