twopass_encoder: sample and test script fixed.
Added a limit function and removed a todo and fixed script so that it can actually be run on av1. cherry-picked #1801d35d from aom/master Change-Id: Ib8d1d1b5c7dbe0169e4e6c7d89d28801d7699c37
This commit is contained in:
@@ -62,7 +62,7 @@ static const char *exec_name;
|
|||||||
void usage_exit(void) {
|
void usage_exit(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s <codec> <width> <height> <infile> <outfile> "
|
"Usage: %s <codec> <width> <height> <infile> <outfile> "
|
||||||
"<frame limit>\n",
|
"<limit(optional)>\n",
|
||||||
exec_name);
|
exec_name);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ static int encode_frame(aom_codec_ctx_t *ctx, const aom_image_t *img,
|
|||||||
|
|
||||||
static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
|
static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
|
||||||
const AvxInterface *encoder,
|
const AvxInterface *encoder,
|
||||||
const aom_codec_enc_cfg_t *cfg, int max_frames) {
|
const aom_codec_enc_cfg_t *cfg, int limit) {
|
||||||
aom_codec_ctx_t codec;
|
aom_codec_ctx_t codec;
|
||||||
int frame_count = 0;
|
int frame_count = 0;
|
||||||
aom_fixed_buf_t stats = { NULL, 0 };
|
aom_fixed_buf_t stats = { NULL, 0 };
|
||||||
@@ -132,11 +132,10 @@ static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
|
|||||||
die_codec(&codec, "Failed to initialize encoder");
|
die_codec(&codec, "Failed to initialize encoder");
|
||||||
|
|
||||||
// Calculate frame statistics.
|
// Calculate frame statistics.
|
||||||
while (aom_img_read(raw, infile)) {
|
while (aom_img_read(raw, infile) && frame_count < limit) {
|
||||||
++frame_count;
|
++frame_count;
|
||||||
get_frame_stats(&codec, raw, frame_count, 1, 0, AOM_DL_GOOD_QUALITY,
|
get_frame_stats(&codec, raw, frame_count, 1, 0, AOM_DL_GOOD_QUALITY,
|
||||||
&stats);
|
&stats);
|
||||||
if (max_frames > 0 && frame_count >= max_frames) break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush encoder.
|
// Flush encoder.
|
||||||
@@ -152,7 +151,7 @@ static aom_fixed_buf_t pass0(aom_image_t *raw, FILE *infile,
|
|||||||
|
|
||||||
static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
|
static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
|
||||||
const AvxInterface *encoder, const aom_codec_enc_cfg_t *cfg,
|
const AvxInterface *encoder, const aom_codec_enc_cfg_t *cfg,
|
||||||
int max_frames) {
|
int limit) {
|
||||||
AvxVideoInfo info = { encoder->fourcc,
|
AvxVideoInfo info = { encoder->fourcc,
|
||||||
cfg->g_w,
|
cfg->g_w,
|
||||||
cfg->g_h,
|
cfg->g_h,
|
||||||
@@ -168,11 +167,9 @@ static void pass1(aom_image_t *raw, FILE *infile, const char *outfile_name,
|
|||||||
die_codec(&codec, "Failed to initialize encoder");
|
die_codec(&codec, "Failed to initialize encoder");
|
||||||
|
|
||||||
// Encode frames.
|
// Encode frames.
|
||||||
while (aom_img_read(raw, infile)) {
|
while (aom_img_read(raw, infile) && frame_count < limit) {
|
||||||
++frame_count;
|
++frame_count;
|
||||||
encode_frame(&codec, raw, frame_count, 1, 0, AOM_DL_GOOD_QUALITY, writer);
|
encode_frame(&codec, raw, frame_count, 1, 0, AOM_DL_GOOD_QUALITY, writer);
|
||||||
|
|
||||||
if (max_frames > 0 && frame_count >= max_frames) break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush encoder.
|
// Flush encoder.
|
||||||
@@ -205,12 +202,14 @@ int main(int argc, char **argv) {
|
|||||||
const char *const height_arg = argv[3];
|
const char *const height_arg = argv[3];
|
||||||
const char *const infile_arg = argv[4];
|
const char *const infile_arg = argv[4];
|
||||||
const char *const outfile_arg = argv[5];
|
const char *const outfile_arg = argv[5];
|
||||||
int max_frames = 0;
|
int limit = 0;
|
||||||
exec_name = argv[0];
|
exec_name = argv[0];
|
||||||
|
|
||||||
if (argc != 7) die("Invalid number of arguments.");
|
if (argc < 6) die("Invalid number of arguments");
|
||||||
|
|
||||||
max_frames = strtol(argv[6], NULL, 0);
|
if (argc > 6) limit = strtol(argv[6], NULL, 0);
|
||||||
|
|
||||||
|
if (limit == 0) limit = 100;
|
||||||
|
|
||||||
encoder = get_aom_encoder_by_name(codec_arg);
|
encoder = get_aom_encoder_by_name(codec_arg);
|
||||||
if (!encoder) die("Unsupported codec.");
|
if (!encoder) die("Unsupported codec.");
|
||||||
@@ -241,13 +240,13 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Pass 0
|
// Pass 0
|
||||||
cfg.g_pass = AOM_RC_FIRST_PASS;
|
cfg.g_pass = AOM_RC_FIRST_PASS;
|
||||||
stats = pass0(&raw, infile, encoder, &cfg, max_frames);
|
stats = pass0(&raw, infile, encoder, &cfg, limit);
|
||||||
|
|
||||||
// Pass 1
|
// Pass 1
|
||||||
rewind(infile);
|
rewind(infile);
|
||||||
cfg.g_pass = AOM_RC_LAST_PASS;
|
cfg.g_pass = AOM_RC_LAST_PASS;
|
||||||
cfg.rc_twopass_stats_in = stats;
|
cfg.rc_twopass_stats_in = stats;
|
||||||
pass1(&raw, infile, outfile_arg, encoder, &cfg, max_frames);
|
pass1(&raw, infile, outfile_arg, encoder, &cfg, limit);
|
||||||
free(stats.buf);
|
free(stats.buf);
|
||||||
|
|
||||||
aom_img_free(&raw);
|
aom_img_free(&raw);
|
||||||
|
@@ -29,6 +29,7 @@ twopass_encoder() {
|
|||||||
local encoder="${LIBAOM_BIN_PATH}/twopass_encoder${AOM_TEST_EXE_SUFFIX}"
|
local encoder="${LIBAOM_BIN_PATH}/twopass_encoder${AOM_TEST_EXE_SUFFIX}"
|
||||||
local codec="$1"
|
local codec="$1"
|
||||||
local output_file="${AOM_TEST_OUTPUT_DIR}/twopass_encoder_${codec}.ivf"
|
local output_file="${AOM_TEST_OUTPUT_DIR}/twopass_encoder_${codec}.ivf"
|
||||||
|
local limit=7
|
||||||
|
|
||||||
if [ ! -x "${encoder}" ]; then
|
if [ ! -x "${encoder}" ]; then
|
||||||
elog "${encoder} does not exist or is not executable."
|
elog "${encoder} does not exist or is not executable."
|
||||||
@@ -36,28 +37,18 @@ twopass_encoder() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
eval "${AOM_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
|
eval "${AOM_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
|
||||||
"${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" 100 \
|
"${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" "${limit}" \
|
||||||
${devnull}
|
${devnull}
|
||||||
|
|
||||||
[ -e "${output_file}" ] || return 1
|
[ -e "${output_file}" ] || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
twopass_encoder_aom() {
|
twopass_encoder_av1() {
|
||||||
if [ "$(aom_encode_available)" = "yes" ]; then
|
|
||||||
twopass_encoder aom || return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO(tomfinegan): Add a frame limit param to twopass_encoder and enable this
|
|
||||||
# test. AV1 is just too slow right now: This test takes 31m16s+ on a fast
|
|
||||||
# machine.
|
|
||||||
DISABLED_twopass_encoder_av1() {
|
|
||||||
if [ "$(av1_encode_available)" = "yes" ]; then
|
if [ "$(av1_encode_available)" = "yes" ]; then
|
||||||
twopass_encoder av1 || return 1
|
twopass_encoder av1 || return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
twopass_encoder_tests="twopass_encoder_aom
|
twopass_encoder_tests="twopass_encoder_av1"
|
||||||
DISABLED_twopass_encoder_av1"
|
|
||||||
|
|
||||||
run_tests twopass_encoder_verify_environment "${twopass_encoder_tests}"
|
run_tests twopass_encoder_verify_environment "${twopass_encoder_tests}"
|
||||||
|
Reference in New Issue
Block a user