/* * Copyright (c) 2021, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * 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.
*/
TEST(FirstpassTest, FirstpassInfoPushPop) {
FIRSTPASS_INFO firstpass_info;
av1_firstpass_info_init(&firstpass_info, nullptr, 0);
EXPECT_EQ(firstpass_info.stats_buf_size, FIRSTPASS_INFO_STATIC_BUF_SIZE); for (int i = 0; i < FIRSTPASS_INFO_STATIC_BUF_SIZE; ++i) {
FIRSTPASS_STATS stats;
av1_zero(stats);
stats.frame = i;
aom_codec_err_t ret = av1_firstpass_info_push(&firstpass_info, &stats);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
EXPECT_EQ(firstpass_info.stats_count, FIRSTPASS_INFO_STATIC_BUF_SIZE); constint pop_count = FIRSTPASS_INFO_STATIC_BUF_SIZE / 2; for (int i = 0; i < pop_count; ++i) { const FIRSTPASS_STATS *stats = av1_firstpass_info_peek(&firstpass_info, 0);
aom_codec_err_t ret =
av1_firstpass_info_move_cur_index_and_pop(&firstpass_info);
EXPECT_NE(stats, nullptr);
EXPECT_EQ(stats->frame, i);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
EXPECT_EQ(firstpass_info.stats_count,
FIRSTPASS_INFO_STATIC_BUF_SIZE - pop_count);
constint push_count = FIRSTPASS_INFO_STATIC_BUF_SIZE / 2; for (int i = 0; i < push_count; ++i) {
FIRSTPASS_STATS stats;
av1_zero(stats);
aom_codec_err_t ret = av1_firstpass_info_push(&firstpass_info, &stats);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
EXPECT_EQ(firstpass_info.stats_count, FIRSTPASS_INFO_STATIC_BUF_SIZE);
EXPECT_EQ(firstpass_info.stats_count, firstpass_info.stats_buf_size);
{ // Push the stats when the queue is full.
FIRSTPASS_STATS stats;
av1_zero(stats);
aom_codec_err_t ret = av1_firstpass_info_push(&firstpass_info, &stats);
EXPECT_EQ(ret, AOM_CODEC_ERROR);
}
}
TEST(FirstpassTest, FirstpassInfoMoveCurr) {
FIRSTPASS_INFO firstpass_info;
av1_firstpass_info_init(&firstpass_info, nullptr, 0); int frame_cnt = 0;
EXPECT_EQ(firstpass_info.stats_buf_size, FIRSTPASS_INFO_STATIC_BUF_SIZE); for (int i = 0; i < FIRSTPASS_INFO_STATIC_BUF_SIZE; ++i) {
FIRSTPASS_STATS stats;
av1_zero(stats);
stats.frame = frame_cnt;
++frame_cnt;
aom_codec_err_t ret = av1_firstpass_info_push(&firstpass_info, &stats);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
EXPECT_EQ(firstpass_info.cur_index, firstpass_info.start_index);
{
aom_codec_err_t ret = av1_firstpass_info_pop(&firstpass_info); // We cannot pop when cur_index == start_index
EXPECT_EQ(ret, AOM_CODEC_ERROR);
} int ref_frame_cnt = 0; constint move_count = FIRSTPASS_INFO_STATIC_BUF_SIZE * 2 / 3; for (int i = 0; i < move_count; ++i) { const FIRSTPASS_STATS *this_stats =
av1_firstpass_info_peek(&firstpass_info, 0);
EXPECT_EQ(this_stats->frame, ref_frame_cnt);
++ref_frame_cnt;
av1_firstpass_info_move_cur_index(&firstpass_info);
}
EXPECT_EQ(firstpass_info.future_stats_count,
FIRSTPASS_INFO_STATIC_BUF_SIZE - move_count);
EXPECT_EQ(firstpass_info.past_stats_count, move_count);
EXPECT_EQ(firstpass_info.stats_count, FIRSTPASS_INFO_STATIC_BUF_SIZE);
constint test_count = FIRSTPASS_INFO_STATIC_BUF_SIZE / 2; for (int i = 0; i < test_count; ++i) {
aom_codec_err_t ret = av1_firstpass_info_pop(&firstpass_info);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
// Pop #test_count stats for (int i = 0; i < test_count; ++i) {
FIRSTPASS_STATS stats;
av1_zero(stats);
stats.frame = frame_cnt;
++frame_cnt;
aom_codec_err_t ret = av1_firstpass_info_push(&firstpass_info, &stats);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
// peek and move #test_count stats for (int i = 0; i < test_count; ++i) { const FIRSTPASS_STATS *this_stats =
av1_firstpass_info_peek(&firstpass_info, 0);
EXPECT_EQ(this_stats->frame, ref_frame_cnt);
++ref_frame_cnt;
av1_firstpass_info_move_cur_index(&firstpass_info);
}
// pop #test_count stats for (int i = 0; i < test_count; ++i) {
aom_codec_err_t ret = av1_firstpass_info_pop(&firstpass_info);
EXPECT_EQ(ret, AOM_CODEC_OK);
}
}
} // namespace
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.