Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, 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 | // Lightfield Encoder |
| 13 | // ================== |
| 14 | // |
| 15 | // This is an example of a simple lightfield encoder. It builds upon the |
| 16 | // twopass_encoder.c example. It takes an input file in YV12 format, |
| 17 | // treating it as a planar lightfield instead of a video. The img_width |
| 18 | // and img_height arguments are the dimensions of the lightfield images, |
| 19 | // while the lf_width and lf_height arguments are the number of |
| 20 | // lightfield images in each dimension. The lf_blocksize determines the |
| 21 | // number of reference images used for MCP. For example, 5 means that there |
| 22 | // is a reference image for every 5x5 lightfield image block. All images |
| 23 | // within a block will use the center image in that block as the reference |
| 24 | // image for MCP. |
| 25 | // Run "make test" to download lightfield test data: vase10x10.yuv. |
| 26 | // Run lightfield encoder to encode whole lightfield: |
Yunqing Wang | d417bb5 | 2018-06-03 14:13:38 -0700 | [diff] [blame] | 27 | // examples/lightfield_encoder 1024 1024 vase10x10.yuv vase10x10.ivf 10 10 5 |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 28 | |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 29 | // Note: In bitstream.c and encoder.c, define EXT_TILE_DEBUG as 1 will print |
| 30 | // out the uncompressed header and the frame contexts, which can be used to |
| 31 | // test the bit exactness of the headers and the frame contexts for large scale |
| 32 | // tile coded frames. |
| 33 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 34 | #include <stdio.h> |
| 35 | #include <stdlib.h> |
| 36 | #include <string.h> |
| 37 | |
| 38 | #include "aom/aom_encoder.h" |
| 39 | #include "aom/aomcx.h" |
Urvang Joshi | 6077b18 | 2018-08-21 11:49:38 -0700 | [diff] [blame] | 40 | #include "aom_scale/yv12config.h" |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 41 | #include "av1/common/enums.h" |
Tom Finegan | 7790213 | 2018-05-21 10:19:15 -0700 | [diff] [blame] | 42 | #include "common/tools_common.h" |
| 43 | #include "common/video_writer.h" |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 44 | |
| 45 | static const char *exec_name; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 46 | |
| 47 | void usage_exit(void) { |
| 48 | fprintf(stderr, |
| 49 | "Usage: %s <img_width> <img_height> <infile> <outfile> " |
| 50 | "<lf_width> <lf_height> <lf_blocksize>\n", |
| 51 | exec_name); |
| 52 | exit(EXIT_FAILURE); |
| 53 | } |
| 54 | |
Yaowu Xu | 413566e | 2019-05-17 09:36:48 -0700 | [diff] [blame] | 55 | static int img_size_bytes(aom_image_t *img) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 56 | int image_size_bytes = 0; |
| 57 | int plane; |
| 58 | for (plane = 0; plane < 3; ++plane) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 59 | const int w = aom_img_plane_width(img, plane) * |
| 60 | ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); |
| 61 | const int h = aom_img_plane_height(img, plane); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 62 | image_size_bytes += w * h; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 63 | } |
| 64 | return image_size_bytes; |
| 65 | } |
| 66 | |
| 67 | static int get_frame_stats(aom_codec_ctx_t *ctx, const aom_image_t *img, |
| 68 | aom_codec_pts_t pts, unsigned int duration, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 69 | aom_enc_frame_flags_t flags, |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 70 | aom_fixed_buf_t *stats) { |
| 71 | int got_pkts = 0; |
| 72 | aom_codec_iter_t iter = NULL; |
| 73 | const aom_codec_cx_pkt_t *pkt = NULL; |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 74 | const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 75 | if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to get frame stats."); |
| 76 | |
| 77 | while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) { |
| 78 | got_pkts = 1; |
| 79 | |
Debargha Mukherjee | 7118f42 | 2020-06-29 15:49:06 -0700 | [diff] [blame] | 80 | #if CONFIG_SINGLEPASS |
| 81 | (void)stats; |
| 82 | #else |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 83 | if (pkt->kind == AOM_CODEC_STATS_PKT) { |
| 84 | const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf; |
| 85 | const size_t pkt_size = pkt->data.twopass_stats.sz; |
| 86 | stats->buf = realloc(stats->buf, stats->sz + pkt_size); |
| 87 | memcpy((uint8_t *)stats->buf + stats->sz, pkt_buf, pkt_size); |
| 88 | stats->sz += pkt_size; |
| 89 | } |
Debargha Mukherjee | 7118f42 | 2020-06-29 15:49:06 -0700 | [diff] [blame] | 90 | #endif // !CONFIG_SINGLEPASS |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | return got_pkts; |
| 94 | } |
| 95 | |
| 96 | static int encode_frame(aom_codec_ctx_t *ctx, const aom_image_t *img, |
| 97 | aom_codec_pts_t pts, unsigned int duration, |
Yunqing Wang | b97cfae | 2018-05-11 14:19:05 -0700 | [diff] [blame] | 98 | aom_enc_frame_flags_t flags, AvxVideoWriter *writer) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 99 | int got_pkts = 0; |
| 100 | aom_codec_iter_t iter = NULL; |
| 101 | const aom_codec_cx_pkt_t *pkt = NULL; |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 102 | const aom_codec_err_t res = aom_codec_encode(ctx, img, pts, duration, flags); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 103 | if (res != AOM_CODEC_OK) die_codec(ctx, "Failed to encode frame."); |
| 104 | |
| 105 | while ((pkt = aom_codec_get_cx_data(ctx, &iter)) != NULL) { |
| 106 | got_pkts = 1; |
| 107 | if (pkt->kind == AOM_CODEC_CX_FRAME_PKT) { |
| 108 | const int keyframe = (pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0; |
| 109 | |
| 110 | if (!aom_video_writer_write_frame(writer, pkt->data.frame.buf, |
| 111 | pkt->data.frame.sz, |
| 112 | pkt->data.frame.pts)) |
| 113 | die_codec(ctx, "Failed to write compressed frame."); |
| 114 | printf(keyframe ? "K" : "."); |
| 115 | fflush(stdout); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return got_pkts; |
| 120 | } |
| 121 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 122 | static void get_raw_image(aom_image_t **frame_to_encode, aom_image_t *raw, |
| 123 | aom_image_t *raw_shift) { |
Jerome Jiang | 5fad3fb | 2019-08-14 10:16:12 -0700 | [diff] [blame] | 124 | if (FORCE_HIGHBITDEPTH_DECODING) { |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 125 | // Need to allocate larger buffer to use hbd internal. |
| 126 | int input_shift = 0; |
| 127 | aom_img_upshift(raw_shift, raw, input_shift); |
| 128 | *frame_to_encode = raw_shift; |
| 129 | } else { |
| 130 | *frame_to_encode = raw; |
| 131 | } |
| 132 | } |
| 133 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 134 | static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile, |
Elliott Karpilovsky | 67e84d4 | 2020-04-26 16:03:39 -0700 | [diff] [blame] | 135 | aom_codec_iface_t *encoder, |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 136 | const aom_codec_enc_cfg_t *cfg, int lf_width, |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 137 | int lf_height, int lf_blocksize, int flags, |
| 138 | aom_image_t *raw_shift) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 139 | aom_codec_ctx_t codec; |
| 140 | int frame_count = 0; |
Yaowu Xu | 413566e | 2019-05-17 09:36:48 -0700 | [diff] [blame] | 141 | int image_size_bytes = img_size_bytes(raw); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 142 | int u_blocks, v_blocks; |
| 143 | int bu, bv; |
| 144 | aom_fixed_buf_t stats = { NULL, 0 }; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 145 | aom_image_t *frame_to_encode; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 146 | |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 147 | if (aom_codec_enc_init(&codec, encoder, cfg, flags)) |
James Zern | dad374f | 2020-05-06 19:13:19 -0700 | [diff] [blame] | 148 | die("Failed to initialize encoder"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 149 | if (aom_codec_control(&codec, AOME_SET_ENABLEAUTOALTREF, 0)) |
| 150 | die_codec(&codec, "Failed to turn off auto altref"); |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 151 | if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 0)) |
| 152 | die_codec(&codec, "Failed to set frame parallel decoding"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 153 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 154 | // How many reference images we need to encode. |
| 155 | u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize; |
| 156 | v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 157 | |
| 158 | printf("\n First pass: "); |
| 159 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 160 | for (bv = 0; bv < v_blocks; ++bv) { |
| 161 | for (bu = 0; bu < u_blocks; ++bu) { |
| 162 | const int block_u_min = bu * lf_blocksize; |
| 163 | const int block_v_min = bv * lf_blocksize; |
| 164 | int block_u_end = (bu + 1) * lf_blocksize; |
| 165 | int block_v_end = (bv + 1) * lf_blocksize; |
| 166 | int u_block_size, v_block_size; |
| 167 | int block_ref_u, block_ref_v; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 168 | |
| 169 | block_u_end = block_u_end < lf_width ? block_u_end : lf_width; |
| 170 | block_v_end = block_v_end < lf_height ? block_v_end : lf_height; |
| 171 | u_block_size = block_u_end - block_u_min; |
| 172 | v_block_size = block_v_end - block_v_min; |
| 173 | block_ref_u = block_u_min + u_block_size / 2; |
| 174 | block_ref_v = block_v_min + v_block_size / 2; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 175 | |
| 176 | printf("A%d, ", (block_ref_u + block_ref_v * lf_width)); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 177 | fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes, |
| 178 | SEEK_SET); |
| 179 | aom_img_read(raw, infile); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 180 | get_raw_image(&frame_to_encode, raw, raw_shift); |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 181 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 182 | // Reference frames can be encoded encoded without tiles. |
| 183 | ++frame_count; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 184 | get_frame_stats(&codec, frame_to_encode, frame_count, 1, |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 185 | AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | |
| 186 | AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | |
| 187 | AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | |
| 188 | AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | |
| 189 | AOM_EFLAG_NO_UPD_ARF, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 190 | &stats); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 191 | } |
| 192 | } |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 193 | |
| 194 | if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 1)) |
| 195 | die_codec(&codec, "Failed to set frame parallel decoding"); |
| 196 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 197 | for (bv = 0; bv < v_blocks; ++bv) { |
| 198 | for (bu = 0; bu < u_blocks; ++bu) { |
| 199 | const int block_u_min = bu * lf_blocksize; |
| 200 | const int block_v_min = bv * lf_blocksize; |
| 201 | int block_u_end = (bu + 1) * lf_blocksize; |
| 202 | int block_v_end = (bv + 1) * lf_blocksize; |
| 203 | int u, v; |
| 204 | block_u_end = block_u_end < lf_width ? block_u_end : lf_width; |
| 205 | block_v_end = block_v_end < lf_height ? block_v_end : lf_height; |
| 206 | for (v = block_v_min; v < block_v_end; ++v) { |
| 207 | for (u = block_u_min; u < block_u_end; ++u) { |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 208 | printf("C%d, ", (u + v * lf_width)); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 209 | fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET); |
| 210 | aom_img_read(raw, infile); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 211 | get_raw_image(&frame_to_encode, raw, raw_shift); |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 212 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 213 | ++frame_count; |
| 214 | get_frame_stats(&codec, frame_to_encode, frame_count, 1, |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 215 | AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | |
| 216 | AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | |
| 217 | AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | |
| 218 | AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | |
| 219 | AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 220 | &stats); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | // Flush encoder. |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 226 | // No ARF, this should not be needed. |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 227 | while (get_frame_stats(&codec, NULL, frame_count, 1, 0, &stats)) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 230 | if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec."); |
| 231 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 232 | printf("\nFirst pass complete. Processed %d frames.\n", frame_count); |
| 233 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 234 | return stats; |
| 235 | } |
| 236 | |
| 237 | static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name, |
Elliott Karpilovsky | 67e84d4 | 2020-04-26 16:03:39 -0700 | [diff] [blame] | 238 | aom_codec_iface_t *encoder, aom_codec_enc_cfg_t *cfg, |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 239 | int lf_width, int lf_height, int lf_blocksize, int flags, |
| 240 | aom_image_t *raw_shift) { |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 241 | AvxVideoInfo info = { get_fourcc_by_aom_encoder(encoder), |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 242 | cfg->g_w, |
| 243 | cfg->g_h, |
Jonathan Matthews | a6e4f96 | 2018-07-13 16:01:28 +0100 | [diff] [blame] | 244 | { cfg->g_timebase.num, cfg->g_timebase.den }, |
| 245 | 0 }; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 246 | AvxVideoWriter *writer = NULL; |
| 247 | aom_codec_ctx_t codec; |
| 248 | int frame_count = 0; |
Yaowu Xu | 413566e | 2019-05-17 09:36:48 -0700 | [diff] [blame] | 249 | int image_size_bytes = img_size_bytes(raw); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 250 | int bu, bv; |
| 251 | int u_blocks, v_blocks; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 252 | aom_image_t *frame_to_encode; |
Yunqing Wang | 93b18f3 | 2018-06-08 21:08:29 -0700 | [diff] [blame] | 253 | aom_image_t reference_images[MAX_EXTERNAL_REFERENCES]; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 254 | int reference_image_num = 0; |
| 255 | int i; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 256 | |
| 257 | writer = aom_video_writer_open(outfile_name, kContainerIVF, &info); |
| 258 | if (!writer) die("Failed to open %s for writing", outfile_name); |
| 259 | |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 260 | if (aom_codec_enc_init(&codec, encoder, cfg, flags)) |
James Zern | dad374f | 2020-05-06 19:13:19 -0700 | [diff] [blame] | 261 | die("Failed to initialize encoder"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 262 | if (aom_codec_control(&codec, AOME_SET_ENABLEAUTOALTREF, 0)) |
| 263 | die_codec(&codec, "Failed to turn off auto altref"); |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 264 | if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 0)) |
| 265 | die_codec(&codec, "Failed to set frame parallel decoding"); |
Yunqing Wang | d8fd9e7 | 2019-12-26 15:36:31 -0800 | [diff] [blame] | 266 | if (aom_codec_control(&codec, AV1E_ENABLE_EXT_TILE_DEBUG, 1)) |
| 267 | die_codec(&codec, "Failed to enable encoder ext_tile debug"); |
Yaowu Xu | 8d9fecb | 2020-04-27 15:21:02 -0700 | [diff] [blame] | 268 | if (aom_codec_control(&codec, AOME_SET_CPUUSED, 3)) |
Yunqing Wang | d8fd9e7 | 2019-12-26 15:36:31 -0800 | [diff] [blame] | 269 | die_codec(&codec, "Failed to set cpu-used"); |
Yunqing Wang | d0f0d3b | 2019-12-23 12:15:44 -0800 | [diff] [blame] | 270 | |
Yunqing Wang | e3de2d8 | 2018-05-15 13:43:41 -0700 | [diff] [blame] | 271 | // Note: The superblock is a sequence parameter and has to be the same for 1 |
| 272 | // sequence. In lightfield application, must choose the superblock size(either |
| 273 | // 64x64 or 128x128) before the encoding starts. Otherwise, the default is |
| 274 | // AOM_SUPERBLOCK_SIZE_DYNAMIC, and the superblock size will be set to 64x64 |
| 275 | // internally. |
| 276 | if (aom_codec_control(&codec, AV1E_SET_SUPERBLOCK_SIZE, |
| 277 | AOM_SUPERBLOCK_SIZE_64X64)) |
| 278 | die_codec(&codec, "Failed to set SB size"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 279 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 280 | u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize; |
| 281 | v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 282 | |
| 283 | reference_image_num = u_blocks * v_blocks; |
Sarah Parker | 9feb158 | 2019-04-25 12:29:52 -0700 | [diff] [blame] | 284 | // Set the max gf group length so the references are guaranteed to be in |
| 285 | // a different gf group than any of the regular frames. This avoids using |
Sarah Parker | 48b46b4 | 2019-04-23 20:43:02 -0700 | [diff] [blame] | 286 | // both vbr and constant quality mode in a single group. The number of |
| 287 | // references now cannot surpass 17 because of the enforced MAX_GF_INTERVAL of |
| 288 | // 16. If it is necessary to exceed this reference frame limit, one will have |
| 289 | // to do some additional handling to ensure references are in separate gf |
| 290 | // groups from the regular frames. |
| 291 | if (aom_codec_control(&codec, AV1E_SET_MAX_GF_INTERVAL, |
| 292 | reference_image_num - 1)) |
| 293 | die_codec(&codec, "Failed to set max gf interval"); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 294 | aom_img_fmt_t ref_fmt = AOM_IMG_FMT_I420; |
Jerome Jiang | 5fad3fb | 2019-08-14 10:16:12 -0700 | [diff] [blame] | 295 | if (FORCE_HIGHBITDEPTH_DECODING) ref_fmt |= AOM_IMG_FMT_HIGHBITDEPTH; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 296 | // Allocate memory with the border so that it can be used as a reference. |
Satish Kumar Suman | 2990996 | 2019-01-09 10:31:21 +0530 | [diff] [blame] | 297 | int border_in_pixels = |
| 298 | (codec.config.enc->rc_resize_mode || codec.config.enc->rc_superres_mode) |
| 299 | ? AOM_BORDER_IN_PIXELS |
| 300 | : AOM_ENC_NO_SCALE_BORDER; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 301 | for (i = 0; i < reference_image_num; i++) { |
| 302 | if (!aom_img_alloc_with_border(&reference_images[i], ref_fmt, cfg->g_w, |
Satish Kumar Suman | 2990996 | 2019-01-09 10:31:21 +0530 | [diff] [blame] | 303 | cfg->g_h, 32, 8, border_in_pixels)) { |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 304 | die("Failed to allocate image."); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | printf("\n Second pass: "); |
| 309 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 310 | // Encode reference images first. |
| 311 | printf("Encoding Reference Images\n"); |
| 312 | for (bv = 0; bv < v_blocks; ++bv) { |
| 313 | for (bu = 0; bu < u_blocks; ++bu) { |
| 314 | const int block_u_min = bu * lf_blocksize; |
| 315 | const int block_v_min = bv * lf_blocksize; |
| 316 | int block_u_end = (bu + 1) * lf_blocksize; |
| 317 | int block_v_end = (bv + 1) * lf_blocksize; |
| 318 | int u_block_size, v_block_size; |
| 319 | int block_ref_u, block_ref_v; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 320 | |
| 321 | block_u_end = block_u_end < lf_width ? block_u_end : lf_width; |
| 322 | block_v_end = block_v_end < lf_height ? block_v_end : lf_height; |
| 323 | u_block_size = block_u_end - block_u_min; |
| 324 | v_block_size = block_v_end - block_v_min; |
| 325 | block_ref_u = block_u_min + u_block_size / 2; |
| 326 | block_ref_v = block_v_min + v_block_size / 2; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 327 | |
| 328 | printf("A%d, ", (block_ref_u + block_ref_v * lf_width)); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 329 | fseek(infile, (block_ref_u + block_ref_v * lf_width) * image_size_bytes, |
| 330 | SEEK_SET); |
| 331 | aom_img_read(raw, infile); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 332 | |
| 333 | get_raw_image(&frame_to_encode, raw, raw_shift); |
| 334 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 335 | // Reference frames may be encoded without tiles. |
| 336 | ++frame_count; |
| 337 | printf("Encoding reference image %d of %d\n", bv * u_blocks + bu, |
| 338 | u_blocks * v_blocks); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 339 | encode_frame(&codec, frame_to_encode, frame_count, 1, |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 340 | AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | |
| 341 | AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | |
| 342 | AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | |
| 343 | AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | |
| 344 | AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 345 | writer); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 346 | |
Yunqing Wang | 946ec2b | 2018-06-06 12:34:23 -0700 | [diff] [blame] | 347 | if (aom_codec_control(&codec, AV1_COPY_NEW_FRAME_IMAGE, |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 348 | &reference_images[frame_count - 1])) |
Yunqing Wang | 946ec2b | 2018-06-06 12:34:23 -0700 | [diff] [blame] | 349 | die_codec(&codec, "Failed to copy decoder reference frame"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 353 | cfg->large_scale_tile = 1; |
| 354 | // Fixed q encoding for camera frames. |
| 355 | cfg->rc_end_usage = AOM_Q; |
| 356 | if (aom_codec_enc_config_set(&codec, cfg)) |
| 357 | die_codec(&codec, "Failed to configure encoder"); |
| 358 | |
| 359 | // The fixed q value used in encoding. |
Urvang Joshi | 3d3535b | 2020-07-14 11:01:30 -0700 | [diff] [blame^] | 360 | if (aom_codec_control(&codec, AOME_SET_QP, 36)) |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 361 | die_codec(&codec, "Failed to set cq level"); |
| 362 | if (aom_codec_control(&codec, AV1E_SET_FRAME_PARALLEL_DECODING, 1)) |
| 363 | die_codec(&codec, "Failed to set frame parallel decoding"); |
| 364 | if (aom_codec_control(&codec, AV1E_SET_SINGLE_TILE_DECODING, 1)) |
| 365 | die_codec(&codec, "Failed to turn on single tile decoding"); |
Yunqing Wang | 75e20e8 | 2018-06-16 12:10:48 -0700 | [diff] [blame] | 366 | // Set tile_columns and tile_rows to MAX values, which guarantees the tile |
| 367 | // size of 64 x 64 pixels(i.e. 1 SB) for <= 4k resolution. |
| 368 | if (aom_codec_control(&codec, AV1E_SET_TILE_COLUMNS, 6)) |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 369 | die_codec(&codec, "Failed to set tile width"); |
Yunqing Wang | 75e20e8 | 2018-06-16 12:10:48 -0700 | [diff] [blame] | 370 | if (aom_codec_control(&codec, AV1E_SET_TILE_ROWS, 6)) |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 371 | die_codec(&codec, "Failed to set tile height"); |
| 372 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 373 | for (bv = 0; bv < v_blocks; ++bv) { |
| 374 | for (bu = 0; bu < u_blocks; ++bu) { |
| 375 | const int block_u_min = bu * lf_blocksize; |
| 376 | const int block_v_min = bv * lf_blocksize; |
| 377 | int block_u_end = (bu + 1) * lf_blocksize; |
| 378 | int block_v_end = (bv + 1) * lf_blocksize; |
| 379 | int u, v; |
| 380 | block_u_end = block_u_end < lf_width ? block_u_end : lf_width; |
| 381 | block_v_end = block_v_end < lf_height ? block_v_end : lf_height; |
| 382 | for (v = block_v_min; v < block_v_end; ++v) { |
| 383 | for (u = block_u_min; u < block_u_end; ++u) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 384 | av1_ref_frame_t ref; |
| 385 | ref.idx = 0; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 386 | ref.use_external_ref = 1; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 387 | ref.img = reference_images[bv * u_blocks + bu]; |
| 388 | if (aom_codec_control(&codec, AV1_SET_REFERENCE, &ref)) |
| 389 | die_codec(&codec, "Failed to set reference frame"); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 390 | |
| 391 | printf("C%d, ", (u + v * lf_width)); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 392 | fseek(infile, (u + v * lf_width) * image_size_bytes, SEEK_SET); |
| 393 | aom_img_read(raw, infile); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 394 | get_raw_image(&frame_to_encode, raw, raw_shift); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 395 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 396 | ++frame_count; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 397 | printf("Encoding image %d of %d\n", |
| 398 | frame_count - (u_blocks * v_blocks), lf_width * lf_height); |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 399 | encode_frame(&codec, frame_to_encode, frame_count, 1, |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 400 | AOM_EFLAG_NO_REF_LAST2 | AOM_EFLAG_NO_REF_LAST3 | |
| 401 | AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_REF_ARF | |
| 402 | AOM_EFLAG_NO_REF_BWD | AOM_EFLAG_NO_REF_ARF2 | |
| 403 | AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | |
| 404 | AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_ENTROPY, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 405 | writer); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 406 | } |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | // Flush encoder. |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 412 | // No ARF, this should not be needed. |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 413 | while (encode_frame(&codec, NULL, -1, 1, 0, writer)) { |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 416 | for (i = 0; i < reference_image_num; i++) aom_img_free(&reference_images[i]); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 417 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 418 | if (aom_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec."); |
Yunqing Wang | 3ae70c9 | 2019-01-25 17:34:07 -0800 | [diff] [blame] | 419 | |
| 420 | // Modify large_scale_file fourcc. |
| 421 | if (cfg->large_scale_tile == 1) |
| 422 | aom_video_writer_set_fourcc(writer, LST_FOURCC); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 423 | aom_video_writer_close(writer); |
| 424 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 425 | printf("\nSecond pass complete. Processed %d frames.\n", frame_count); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | int main(int argc, char **argv) { |
| 429 | FILE *infile = NULL; |
| 430 | int w, h; |
| 431 | // The number of lightfield images in the u and v dimensions. |
| 432 | int lf_width, lf_height; |
| 433 | // Defines how many images refer to the same reference image for MCP. |
| 434 | // lf_blocksize X lf_blocksize images will all use the reference image |
| 435 | // in the middle of the block of images. |
| 436 | int lf_blocksize; |
| 437 | aom_codec_ctx_t codec; |
| 438 | aom_codec_enc_cfg_t cfg; |
| 439 | aom_image_t raw; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 440 | aom_image_t raw_shift; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 441 | aom_codec_err_t res; |
| 442 | aom_fixed_buf_t stats; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 443 | int flags = 0; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 444 | |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 445 | const int fps = 30; |
| 446 | const int bitrate = 200; // kbit/s |
| 447 | const char *const width_arg = argv[1]; |
| 448 | const char *const height_arg = argv[2]; |
| 449 | const char *const infile_arg = argv[3]; |
| 450 | const char *const outfile_arg = argv[4]; |
| 451 | const char *const lf_width_arg = argv[5]; |
| 452 | const char *const lf_height_arg = argv[6]; |
| 453 | const char *lf_blocksize_arg = argv[7]; |
| 454 | exec_name = argv[0]; |
| 455 | |
| 456 | if (argc < 8) die("Invalid number of arguments"); |
| 457 | |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 458 | aom_codec_iface_t *encoder = get_aom_encoder_by_short_name("av1"); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 459 | if (!encoder) die("Unsupported codec."); |
| 460 | |
| 461 | w = (int)strtol(width_arg, NULL, 0); |
| 462 | h = (int)strtol(height_arg, NULL, 0); |
| 463 | lf_width = (int)strtol(lf_width_arg, NULL, 0); |
| 464 | lf_height = (int)strtol(lf_height_arg, NULL, 0); |
| 465 | lf_blocksize = (int)strtol(lf_blocksize_arg, NULL, 0); |
| 466 | lf_blocksize = lf_blocksize < lf_width ? lf_blocksize : lf_width; |
| 467 | lf_blocksize = lf_blocksize < lf_height ? lf_blocksize : lf_height; |
| 468 | |
| 469 | if (w <= 0 || h <= 0 || (w % 2) != 0 || (h % 2) != 0) |
| 470 | die("Invalid frame size: %dx%d", w, h); |
| 471 | if (lf_width <= 0 || lf_height <= 0) |
| 472 | die("Invalid lf_width and/or lf_height: %dx%d", lf_width, lf_height); |
| 473 | if (lf_blocksize <= 0) die("Invalid lf_blocksize: %d", lf_blocksize); |
| 474 | |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 475 | if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, w, h, 32)) { |
| 476 | die("Failed to allocate image."); |
| 477 | } |
Jerome Jiang | 5fad3fb | 2019-08-14 10:16:12 -0700 | [diff] [blame] | 478 | if (FORCE_HIGHBITDEPTH_DECODING) { |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 479 | // Need to allocate larger buffer to use hbd internal. |
| 480 | aom_img_alloc(&raw_shift, AOM_IMG_FMT_I420 | AOM_IMG_FMT_HIGHBITDEPTH, w, h, |
| 481 | 32); |
| 482 | } |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 483 | |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 484 | printf("Using %s\n", aom_codec_iface_name(encoder)); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 485 | |
| 486 | // Configuration |
Elliott Karpilovsky | cbe219b | 2020-04-22 16:21:06 -0700 | [diff] [blame] | 487 | res = aom_codec_enc_config_default(encoder, &cfg, 0); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 488 | if (res) die_codec(&codec, "Failed to get default codec config."); |
| 489 | |
| 490 | cfg.g_w = w; |
| 491 | cfg.g_h = h; |
| 492 | cfg.g_timebase.num = 1; |
| 493 | cfg.g_timebase.den = fps; |
| 494 | cfg.rc_target_bitrate = bitrate; |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 495 | cfg.g_error_resilient = 0; // This is required. |
| 496 | cfg.g_lag_in_frames = 0; // need to set this since default is 19. |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 497 | cfg.kf_mode = AOM_KF_DISABLED; |
Yunqing Wang | b041d8a | 2017-11-15 12:31:18 -0800 | [diff] [blame] | 498 | cfg.large_scale_tile = 0; // Only set it to 1 for camera frame encoding. |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 499 | cfg.g_bit_depth = AOM_BITS_8; |
Jerome Jiang | 5fad3fb | 2019-08-14 10:16:12 -0700 | [diff] [blame] | 500 | flags |= (cfg.g_bit_depth > AOM_BITS_8 || FORCE_HIGHBITDEPTH_DECODING) |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 501 | ? AOM_CODEC_USE_HIGHBITDEPTH |
| 502 | : 0; |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 503 | |
| 504 | if (!(infile = fopen(infile_arg, "rb"))) |
| 505 | die("Failed to open %s for reading", infile_arg); |
| 506 | |
| 507 | // Pass 0 |
| 508 | cfg.g_pass = AOM_RC_FIRST_PASS; |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 509 | stats = pass0(&raw, infile, encoder, &cfg, lf_width, lf_height, lf_blocksize, |
| 510 | flags, &raw_shift); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 511 | |
| 512 | // Pass 1 |
| 513 | rewind(infile); |
| 514 | cfg.g_pass = AOM_RC_LAST_PASS; |
| 515 | cfg.rc_twopass_stats_in = stats; |
| 516 | pass1(&raw, infile, outfile_arg, encoder, &cfg, lf_width, lf_height, |
Yunqing Wang | 17d9d43 | 2018-05-27 15:08:04 -0700 | [diff] [blame] | 517 | lf_blocksize, flags, &raw_shift); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 518 | free(stats.buf); |
| 519 | |
Jerome Jiang | 5fad3fb | 2019-08-14 10:16:12 -0700 | [diff] [blame] | 520 | if (FORCE_HIGHBITDEPTH_DECODING) aom_img_free(&raw_shift); |
Ryan Overbeck | a5fefa7 | 2017-09-19 11:39:10 -0700 | [diff] [blame] | 521 | aom_img_free(&raw); |
| 522 | fclose(infile); |
| 523 | |
| 524 | return EXIT_SUCCESS; |
| 525 | } |