blob: 5a2731d3ac9e8d90acc1669229d2356a8da8b853 [file] [log] [blame]
elliottk6e2aac22018-08-31 11:08:44 -07001/*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12#include "common/rawenc.h"
13
14void raw_write_image_file(const aom_image_t *img, const int *planes,
15 const int num_planes, FILE *file) {
16 const int bytes_per_sample = ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
17 for (int i = 0; i < num_planes; ++i) {
18 const int plane = planes[i];
19 const unsigned char *buf = img->planes[plane];
20 const int stride = img->stride[plane];
21 const int w = aom_img_plane_width(img, plane);
22 const int h = aom_img_plane_height(img, plane);
23 for (int y = 0; y < h; ++y) {
24 fwrite(buf, bytes_per_sample, w, file);
25 buf += stride;
26 }
27 }
28}
29
30void raw_update_image_md5(const aom_image_t *img, const int *planes,
31 const int num_planes, MD5Context *md5) {
32 for (int i = 0; i < num_planes; ++i) {
33 const int plane = planes[i];
34 const unsigned char *buf = img->planes[plane];
35 const int stride = img->stride[plane];
36 const int w = aom_img_plane_width(img, plane) *
37 ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
38 const int h = aom_img_plane_height(img, plane);
39 for (int y = 0; y < h; ++y) {
40 MD5Update(md5, buf, w);
41 buf += stride;
42 }
43 }
44}