diff options
Diffstat (limited to 'third_party/aom/apps')
-rw-r--r-- | third_party/aom/apps/aomdec.c | 143 | ||||
-rw-r--r-- | third_party/aom/apps/aomenc.c | 77 | ||||
-rw-r--r-- | third_party/aom/apps/aomenc.h | 7 |
3 files changed, 91 insertions, 136 deletions
diff --git a/third_party/aom/apps/aomdec.c b/third_party/aom/apps/aomdec.c index 48952586f..ff13b6f50 100644 --- a/third_party/aom/apps/aomdec.c +++ b/third_party/aom/apps/aomdec.c @@ -40,6 +40,7 @@ #include "common/webmdec.h" #endif +#include "common/rawenc.h" #include "common/y4menc.h" #if CONFIG_LIBYUV @@ -83,8 +84,6 @@ static const arg_def_t outputfile = ARG_DEF("o", "output", 1, "Output file name pattern (see below)"); static const arg_def_t threadsarg = ARG_DEF("t", "threads", 1, "Max threads to use"); -static const arg_def_t rowmtarg = - ARG_DEF(NULL, "row-mt", 1, "Enable row based multi-threading"); static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, "Show version string"); static const arg_def_t scalearg = @@ -99,29 +98,23 @@ static const arg_def_t framestatsarg = ARG_DEF(NULL, "framestats", 1, "Output per-frame stats (.csv format)"); static const arg_def_t outbitdeptharg = ARG_DEF(NULL, "output-bit-depth", 1, "Output bit-depth for decoded frames"); -static const arg_def_t tilem = ARG_DEF(NULL, "tile-mode", 1, - "Tile coding mode " - "(0 for normal tile coding mode)"); -static const arg_def_t tiler = ARG_DEF(NULL, "tile-row", 1, - "Row index of tile to decode " - "(-1 for all rows)"); -static const arg_def_t tilec = ARG_DEF(NULL, "tile-column", 1, - "Column index of tile to decode " - "(-1 for all columns)"); static const arg_def_t isannexb = ARG_DEF(NULL, "annexb", 0, "Bitstream is in Annex-B format"); static const arg_def_t oppointarg = ARG_DEF( NULL, "oppoint", 1, "Select an operating point of a scalable bitstream"); static const arg_def_t outallarg = ARG_DEF( NULL, "all-layers", 0, "Output all decoded frames of a scalable bitstream"); +static const arg_def_t skipfilmgrain = + ARG_DEF(NULL, "skip-film-grain", 0, "Skip film grain application"); static const arg_def_t *all_args[] = { - &help, &codecarg, &use_yv12, &use_i420, &flipuvarg, - &rawvideo, &noblitarg, &progressarg, &limitarg, &skiparg, - &postprocarg, &summaryarg, &outputfile, &threadsarg, &rowmtarg, - &verbosearg, &scalearg, &fb_arg, &md5arg, &framestatsarg, - &continuearg, &outbitdeptharg, &tilem, &tiler, &tilec, - &isannexb, &oppointarg, &outallarg, NULL + &help, &codecarg, &use_yv12, &use_i420, + &flipuvarg, &rawvideo, &noblitarg, &progressarg, + &limitarg, &skiparg, &postprocarg, &summaryarg, + &outputfile, &threadsarg, &verbosearg, &scalearg, + &fb_arg, &md5arg, &framestatsarg, &continuearg, + &outbitdeptharg, &isannexb, &oppointarg, &outallarg, + &skipfilmgrain, NULL }; #if CONFIG_LIBYUV @@ -254,44 +247,6 @@ static int read_frame(struct AvxDecInputContext *input, uint8_t **buf, } } -static void update_image_md5(const aom_image_t *img, const int planes[3], - MD5Context *md5) { - int i, y; - - for (i = 0; i < 3; ++i) { - const int plane = planes[i]; - const unsigned char *buf = img->planes[plane]; - const int stride = img->stride[plane]; - const int w = aom_img_plane_width(img, plane) * - ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); - const int h = aom_img_plane_height(img, plane); - - for (y = 0; y < h; ++y) { - MD5Update(md5, buf, w); - buf += stride; - } - } -} - -static void write_image_file(const aom_image_t *img, const int *planes, - const int num_planes, FILE *file) { - int i, y; - const int bytes_per_sample = ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); - - for (i = 0; i < num_planes; ++i) { - const int plane = planes[i]; - const unsigned char *buf = img->planes[plane]; - const int stride = img->stride[plane]; - const int w = aom_img_plane_width(img, plane); - const int h = aom_img_plane_height(img, plane); - - for (y = 0; y < h; ++y) { - fwrite(buf, bytes_per_sample, w, file); - buf += stride; - } - } -} - static int file_is_raw(struct AvxInputContext *input) { uint8_t buf[32]; int is_raw = 0; @@ -505,16 +460,13 @@ static int main_loop(int argc, const char **argv_) { int opt_raw = 0; aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH, { 1 } }; unsigned int output_bit_depth = 0; - unsigned int tile_mode = 0; unsigned int is_annexb = 0; - int tile_row = -1; - int tile_col = -1; int frames_corrupted = 0; int dec_flags = 0; int do_scale = 0; int operating_point = 0; int output_all_layers = 0; - unsigned int row_mt = 0; + int skip_film_grain = 0; aom_image_t *scaled_img = NULL; aom_image_t *img_shifted = NULL; int frame_avail, got_data, flush_decoder = 0; @@ -611,8 +563,6 @@ static int main_loop(int argc, const char **argv_) { cfg.threads); } #endif - } else if (arg_match(&arg, &rowmtarg, argi)) { - row_mt = arg_parse_uint(&arg); } else if (arg_match(&arg, &verbosearg, argi)) { quiet = 0; } else if (arg_match(&arg, &scalearg, argi)) { @@ -623,19 +573,15 @@ static int main_loop(int argc, const char **argv_) { keep_going = 1; } else if (arg_match(&arg, &outbitdeptharg, argi)) { output_bit_depth = arg_parse_uint(&arg); - } else if (arg_match(&arg, &tilem, argi)) { - tile_mode = arg_parse_int(&arg); } else if (arg_match(&arg, &isannexb, argi)) { is_annexb = 1; input.obu_ctx->is_annexb = 1; - } else if (arg_match(&arg, &tiler, argi)) { - tile_row = arg_parse_int(&arg); - } else if (arg_match(&arg, &tilec, argi)) { - tile_col = arg_parse_int(&arg); } else if (arg_match(&arg, &oppointarg, argi)) { operating_point = arg_parse_int(&arg); } else if (arg_match(&arg, &outallarg, argi)) { output_all_layers = 1; + } else if (arg_match(&arg, &skipfilmgrain, argi)) { + skip_film_grain = 1; } else { argj++; } @@ -739,30 +685,11 @@ static int main_loop(int argc, const char **argv_) { if (!quiet) fprintf(stderr, "%s\n", decoder.name); -#if CONFIG_AV1_DECODER - if (aom_codec_control(&decoder, AV1_SET_TILE_MODE, tile_mode)) { - fprintf(stderr, "Failed to set decode_tile_mode: %s\n", - aom_codec_error(&decoder)); - goto fail; - } - if (aom_codec_control(&decoder, AV1D_SET_IS_ANNEXB, is_annexb)) { fprintf(stderr, "Failed to set is_annexb: %s\n", aom_codec_error(&decoder)); goto fail; } - if (aom_codec_control(&decoder, AV1_SET_DECODE_TILE_ROW, tile_row)) { - fprintf(stderr, "Failed to set decode_tile_row: %s\n", - aom_codec_error(&decoder)); - goto fail; - } - - if (aom_codec_control(&decoder, AV1_SET_DECODE_TILE_COL, tile_col)) { - fprintf(stderr, "Failed to set decode_tile_col: %s\n", - aom_codec_error(&decoder)); - goto fail; - } - if (aom_codec_control(&decoder, AV1D_SET_OPERATING_POINT, operating_point)) { fprintf(stderr, "Failed to set operating_point: %s\n", aom_codec_error(&decoder)); @@ -776,11 +703,11 @@ static int main_loop(int argc, const char **argv_) { goto fail; } - if (aom_codec_control(&decoder, AV1D_SET_ROW_MT, row_mt)) { - fprintf(stderr, "Failed to set row_mt: %s\n", aom_codec_error(&decoder)); + if (aom_codec_control(&decoder, AV1D_SET_SKIP_FILM_GRAIN, skip_film_grain)) { + fprintf(stderr, "Failed to set skip_film_grain: %s\n", + aom_codec_error(&decoder)); goto fail; } -#endif if (arg_skip) fprintf(stderr, "Skipping first %d frames.\n", arg_skip); while (arg_skip) { @@ -903,6 +830,8 @@ static int main_loop(int argc, const char **argv_) { scaled_img = aom_img_alloc(NULL, img->fmt, render_width, render_height, 16); scaled_img->bit_depth = img->bit_depth; + scaled_img->monochrome = img->monochrome; + scaled_img->csp = img->csp; } if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) { @@ -936,11 +865,15 @@ static int main_loop(int argc, const char **argv_) { aom_img_free(img_shifted); img_shifted = NULL; } + if (img_shifted) { + img_shifted->monochrome = img->monochrome; + } if (!img_shifted) { img_shifted = aom_img_alloc(NULL, shifted_fmt, img->d_w, img->d_h, 16); img_shifted->bit_depth = output_bit_depth; img_shifted->monochrome = img->monochrome; + img_shifted->csp = img->csp; } if (output_bit_depth > img->bit_depth) { aom_img_upshift(img_shifted, img, @@ -956,8 +889,7 @@ static int main_loop(int argc, const char **argv_) { aom_input_ctx.width = img->d_w; aom_input_ctx.height = img->d_h; - int num_planes = (!use_y4m && opt_raw && img->monochrome) ? 1 : 3; - + int num_planes = (opt_raw && img->monochrome) ? 1 : 3; if (single_file) { if (use_y4m) { char y4m_buf[Y4M_BUFFER_SIZE] = { 0 }; @@ -966,8 +898,8 @@ static int main_loop(int argc, const char **argv_) { // Y4M file header len = y4m_write_file_header( y4m_buf, sizeof(y4m_buf), aom_input_ctx.width, - aom_input_ctx.height, &aom_input_ctx.framerate, img->fmt, - img->bit_depth); + aom_input_ctx.height, &aom_input_ctx.framerate, + img->monochrome, img->csp, img->fmt, img->bit_depth); if (do_md5) { MD5Update(&md5_ctx, (md5byte *)y4m_buf, (unsigned int)len); } else { @@ -979,8 +911,10 @@ static int main_loop(int argc, const char **argv_) { len = y4m_write_frame_header(y4m_buf, sizeof(y4m_buf)); if (do_md5) { MD5Update(&md5_ctx, (md5byte *)y4m_buf, (unsigned int)len); + y4m_update_image_md5(img, planes, &md5_ctx); } else { fputs(y4m_buf, outfile); + y4m_write_image_file(img, planes, outfile); } } else { if (frame_out == 1) { @@ -1004,24 +938,31 @@ static int main_loop(int argc, const char **argv_) { } } } - } - - if (do_md5) { - update_image_md5(img, planes, &md5_ctx); - } else { - write_image_file(img, planes, num_planes, outfile); + if (do_md5) { + raw_update_image_md5(img, planes, num_planes, &md5_ctx); + } else { + raw_write_image_file(img, planes, num_planes, outfile); + } } } else { generate_filename(outfile_pattern, outfile_name, PATH_MAX, img->d_w, img->d_h, frame_in); if (do_md5) { MD5Init(&md5_ctx); - update_image_md5(img, planes, &md5_ctx); + if (use_y4m) { + y4m_update_image_md5(img, planes, &md5_ctx); + } else { + raw_update_image_md5(img, planes, num_planes, &md5_ctx); + } MD5Final(md5_digest, &md5_ctx); print_md5(md5_digest, outfile_name); } else { outfile = open_outfile(outfile_name); - write_image_file(img, planes, num_planes, outfile); + if (use_y4m) { + y4m_write_image_file(img, planes, outfile); + } else { + raw_write_image_file(img, planes, num_planes, outfile); + } fclose(outfile); } } diff --git a/third_party/aom/apps/aomenc.c b/third_party/aom/apps/aomenc.c index 31cb662e4..2e5d35cfe 100644 --- a/third_party/aom/apps/aomenc.c +++ b/third_party/aom/apps/aomenc.c @@ -180,9 +180,6 @@ static const arg_def_t use_webm = ARG_DEF(NULL, "webm", 0, "Output WebM (default when WebM IO is enabled)"); static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, "Output IVF"); static const arg_def_t use_obu = ARG_DEF(NULL, "obu", 0, "Output OBU"); -static const arg_def_t out_part = - ARG_DEF("P", "output-partitions", 0, - "Makes encoder output partitions. Requires IVF output!"); static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)"); static const arg_def_t rate_hist_n = @@ -203,6 +200,12 @@ static const arg_def_t bitdeptharg = ARG_DEF_ENUM( bitdepth_enum); static const arg_def_t inbitdeptharg = ARG_DEF(NULL, "input-bit-depth", 1, "Bit depth of input"); + +static const arg_def_t input_chroma_subsampling_x = ARG_DEF( + NULL, "input-chroma-subsampling-x", 1, "chroma subsampling x value."); +static const arg_def_t input_chroma_subsampling_y = ARG_DEF( + NULL, "input-chroma-subsampling-y", 1, "chroma subsampling y value."); + static const arg_def_t *main_args[] = { &help, #if CONFIG_FILEOPTIONS &use_cfg, @@ -222,7 +225,6 @@ static const arg_def_t *main_args[] = { &help, &use_webm, &use_ivf, &use_obu, - &out_part, &q_hist_n, &rate_hist_n, &disable_warnings, @@ -411,16 +413,13 @@ static const arg_def_t max_intra_rate_pct = #if CONFIG_AV1_ENCODER static const arg_def_t cpu_used_av1 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (0..8)"); -static const arg_def_t dev_sf_av1 = - ARG_DEF(NULL, "dev-sf", 1, "Dev Speed (0..255)"); -static const arg_def_t single_tile_decoding = - ARG_DEF(NULL, "single-tile-decoding", 1, - "Single tile decoding (0: off (default), 1: on)"); +static const arg_def_t rowmtarg = + ARG_DEF(NULL, "row-mt", 1, + "Enable row based multi-threading (0: off (default), 1: on)"); static const arg_def_t tile_cols = ARG_DEF(NULL, "tile-columns", 1, "Number of tile columns to use, log2"); static const arg_def_t tile_rows = - ARG_DEF(NULL, "tile-rows", 1, - "Number of tile rows to use, log2 (set to 0 while threads > 1)"); + ARG_DEF(NULL, "tile-rows", 1, "Number of tile rows to use, log2"); static const arg_def_t tile_width = ARG_DEF(NULL, "tile-width", 1, "Tile widths (comma separated)"); static const arg_def_t tile_height = @@ -619,11 +618,10 @@ static const arg_def_t superblock_size = ARG_DEF_ENUM( NULL, "sb-size", 1, "Superblock size to use", superblock_size_enum); static const arg_def_t *av1_args[] = { &cpu_used_av1, - &dev_sf_av1, &auto_altref, &sharpness, &static_thresh, - &single_tile_decoding, + &rowmtarg, &tile_cols, &tile_rows, &arnr_maxframes, @@ -670,16 +668,17 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1, &enable_ref_frame_mvs, &bitdeptharg, &inbitdeptharg, + &input_chroma_subsampling_x, + &input_chroma_subsampling_y, &sframe_dist, &sframe_mode, &save_as_annexb, NULL }; static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED, - AOME_SET_DEVSF, AOME_SET_ENABLEAUTOALTREF, AOME_SET_SHARPNESS, AOME_SET_STATIC_THRESHOLD, - AV1E_SET_SINGLE_TILE_DECODING, + AV1E_SET_ROW_MT, AV1E_SET_TILE_COLUMNS, AV1E_SET_TILE_ROWS, AOME_SET_ARNR_MAXFRAMES, @@ -830,6 +829,8 @@ struct stream_state { struct aom_image *img; aom_codec_ctx_t decoder; int mismatch_seen; + unsigned int chroma_subsampling_x; + unsigned int chroma_subsampling_y; }; static void validate_positive_rational(const char *msg, @@ -927,9 +928,7 @@ static void parse_global_config(struct AvxEncoderConfig *global, int *argc, global->framerate = arg_parse_rational(&arg); validate_positive_rational(arg.name, &global->framerate); global->have_framerate = 1; - } else if (arg_match(&arg, &out_part, argi)) - global->out_part = 1; - else if (arg_match(&arg, &debugmode, argi)) + } else if (arg_match(&arg, &debugmode, argi)) global->debug = 1; else if (arg_match(&arg, &q_hist_n, argi)) global->show_q_hist_buckets = arg_parse_uint(&arg); @@ -1087,6 +1086,11 @@ static void set_config_arg_ctrls(struct stream_config *config, int key, assert(j < (int)ARG_CTRL_CNT_MAX); config->arg_ctrls[j][0] = key; config->arg_ctrls[j][1] = arg_parse_enum_or_int(arg); + + if (key == AOME_SET_ENABLEAUTOALTREF && config->arg_ctrls[j][1] > 1) { + warn("auto-alt-ref > 1 is deprecated... setting auto-alt-ref=1\n"); + config->arg_ctrls[j][1] = 1; + } if (j == config->arg_ctrl_cnt) config->arg_ctrl_cnt++; } @@ -1174,6 +1178,10 @@ static int parse_stream_params(struct AvxEncoderConfig *global, config->cfg.g_bit_depth = arg_parse_enum_or_int(&arg); } else if (arg_match(&arg, &inbitdeptharg, argi)) { config->cfg.g_input_bit_depth = arg_parse_uint(&arg); + } else if (arg_match(&arg, &input_chroma_subsampling_x, argi)) { + stream->chroma_subsampling_x = arg_parse_uint(&arg); + } else if (arg_match(&arg, &input_chroma_subsampling_y, argi)) { + stream->chroma_subsampling_y = arg_parse_uint(&arg); #if CONFIG_WEBM_IO } else if (arg_match(&arg, &stereo_mode, argi)) { config->stereo_fmt = arg_parse_enum_or_int(&arg); @@ -1531,7 +1539,6 @@ static void initialize_encoder(struct stream_state *stream, int flags = 0; flags |= global->show_psnr ? AOM_CODEC_USE_PSNR : 0; - flags |= global->out_part ? AOM_CODEC_USE_OUTPUT_PARTITION : 0; flags |= stream->config.use_16bit_internal ? AOM_CODEC_USE_HIGHBITDEPTH : 0; /* Construct Encoder Context */ @@ -1609,14 +1616,14 @@ static void encode_frame(struct stream_state *stream, aom_img_alloc(NULL, AOM_IMG_FMT_I42016, cfg->g_w, cfg->g_h, 16); } I420Scale_16( - (uint16 *)img->planes[AOM_PLANE_Y], img->stride[AOM_PLANE_Y] / 2, - (uint16 *)img->planes[AOM_PLANE_U], img->stride[AOM_PLANE_U] / 2, - (uint16 *)img->planes[AOM_PLANE_V], img->stride[AOM_PLANE_V] / 2, - img->d_w, img->d_h, (uint16 *)stream->img->planes[AOM_PLANE_Y], + (uint16_t *)img->planes[AOM_PLANE_Y], img->stride[AOM_PLANE_Y] / 2, + (uint16_t *)img->planes[AOM_PLANE_U], img->stride[AOM_PLANE_U] / 2, + (uint16_t *)img->planes[AOM_PLANE_V], img->stride[AOM_PLANE_V] / 2, + img->d_w, img->d_h, (uint16_t *)stream->img->planes[AOM_PLANE_Y], stream->img->stride[AOM_PLANE_Y] / 2, - (uint16 *)stream->img->planes[AOM_PLANE_U], + (uint16_t *)stream->img->planes[AOM_PLANE_U], stream->img->stride[AOM_PLANE_U] / 2, - (uint16 *)stream->img->planes[AOM_PLANE_V], + (uint16_t *)stream->img->planes[AOM_PLANE_V], stream->img->stride[AOM_PLANE_V] / 2, stream->img->d_w, stream->img->d_h, kFilterBox); img = stream->img; @@ -2043,17 +2050,25 @@ int main(int argc, const char **argv_) { input.fmt == AOM_IMG_FMT_I42016)) { stream->config.cfg.g_profile = 0; profile_updated = 1; + } else if (input.bit_depth == 12 && + input.file_type == FILE_TYPE_Y4M) { + // Note that here the input file values for chroma subsampling + // are used instead of those from the command line. + aom_codec_control(&stream->encoder, AV1E_SET_CHROMA_SUBSAMPLING_X, + input.y4m.dst_c_dec_h >> 1); + aom_codec_control(&stream->encoder, AV1E_SET_CHROMA_SUBSAMPLING_Y, + input.y4m.dst_c_dec_v >> 1); + } else if (input.bit_depth == 12 && + input.file_type == FILE_TYPE_RAW) { + aom_codec_control(&stream->encoder, AV1E_SET_CHROMA_SUBSAMPLING_X, + stream->chroma_subsampling_x); + aom_codec_control(&stream->encoder, AV1E_SET_CHROMA_SUBSAMPLING_Y, + stream->chroma_subsampling_y); } break; default: break; } } - /* Automatically set the codec bit depth to match the input bit depth. - * Upgrade the profile if required. */ - if (stream->config.cfg.g_input_bit_depth > - (unsigned int)stream->config.cfg.g_bit_depth) { - stream->config.cfg.g_bit_depth = stream->config.cfg.g_input_bit_depth; - } if (stream->config.cfg.g_bit_depth > 10) { switch (stream->config.cfg.g_profile) { case 0: diff --git a/third_party/aom/apps/aomenc.h b/third_party/aom/apps/aomenc.h index 976079d74..7c23df006 100644 --- a/third_party/aom/apps/aomenc.h +++ b/third_party/aom/apps/aomenc.h @@ -8,8 +8,8 @@ * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ -#ifndef AOMENC_H_ -#define AOMENC_H_ +#ifndef AOM_APPS_AOMENC_H_ +#define AOM_APPS_AOMENC_H_ #include "aom/aom_encoder.h" @@ -47,7 +47,6 @@ struct AvxEncoderConfig { enum TestDecodeFatality test_decode; int have_framerate; struct aom_rational framerate; - int out_part; int debug; int show_q_hist_buckets; int show_rate_hist_buckets; @@ -60,4 +59,4 @@ struct AvxEncoderConfig { } // extern "C" #endif -#endif // AOMENC_H_ +#endif // AOM_APPS_AOMENC_H_ |