Commit 17b6b0ee authored by clang-format's avatar clang-format Committed by Yaowu Xu

apply clang-format

this was missed in the resurrected examples/aom_cx_set_ref.c and the
accompanying fix in av1/decoder/decoder.c as well as in:
2a10c91b rdopt,rd_pick_intra4x4block: port tsan fix from libvpx

Change-Id: Ie47eabf7869f629ffb82257f09665165083aef96
parent 85d0e1da
......@@ -197,8 +197,7 @@ aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
} else if (ref_frame_flag == AOM_ALT_FLAG) {
idx = cm->ref_frame_map[2];
} else {
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
"Invalid reference frame");
aom_internal_error(&cm->error, AOM_CODEC_ERROR, "Invalid reference frame");
return cm->error.error_code;
}
......
......@@ -1035,11 +1035,10 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(AV1_COMP *cpi, MACROBLOCK *mb,
bmode_costs = cpi->y_mode_costs[A][L];
}
this_rd = rd_pick_intra4x4block(cpi, mb, idy, idx, &best_mode,
bmode_costs,
xd->plane[0].above_context + idx,
xd->plane[0].left_context + idy,
&r, &ry, &d, bsize, best_rd - total_rd);
this_rd = rd_pick_intra4x4block(
cpi, mb, idy, idx, &best_mode, bmode_costs,
xd->plane[0].above_context + idx, xd->plane[0].left_context + idy, &r,
&ry, &d, bsize, best_rd - total_rd);
if (this_rd >= best_rd - total_rd) return INT64_MAX;
total_rd += this_rd;
......
......@@ -61,7 +61,8 @@
static const char *exec_name;
void usage_exit() {
fprintf(stderr, "Usage: %s <codec> <width> <height> <infile> <outfile> "
fprintf(stderr,
"Usage: %s <codec> <width> <height> <infile> <outfile> "
"<frame> <limit(optional)>\n",
exec_name);
exit(EXIT_FAILURE);
......@@ -70,8 +71,7 @@ void usage_exit() {
static int compare_img(const aom_image_t *const img1,
const aom_image_t *const img2) {
uint32_t l_w = img1->d_w;
uint32_t c_w =
(img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift;
uint32_t c_w = (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift;
const uint32_t c_h =
(img1->d_h + img1->y_chroma_shift) >> img1->y_chroma_shift;
uint32_t i;
......@@ -99,10 +99,10 @@ static int compare_img(const aom_image_t *const img1,
return match;
}
#define mmin(a, b) ((a) < (b) ? (a) : (b))
#define mmin(a, b) ((a) < (b) ? (a) : (b))
static void find_mismatch(const aom_image_t *const img1,
const aom_image_t *const img2,
int yloc[4], int uloc[4], int vloc[4]) {
const aom_image_t *const img2, int yloc[4],
int uloc[4], int vloc[4]) {
const uint32_t bsize = 64;
const uint32_t bsizey = bsize >> img1->y_chroma_shift;
const uint32_t bsizex = bsize >> img1->x_chroma_shift;
......@@ -190,21 +190,18 @@ static void find_mismatch(const aom_image_t *const img1,
}
}
static void testing_decode(aom_codec_ctx_t *encoder,
aom_codec_ctx_t *decoder,
aom_codec_enc_cfg_t *cfg,
unsigned int frame_out,
static void testing_decode(aom_codec_ctx_t *encoder, aom_codec_ctx_t *decoder,
aom_codec_enc_cfg_t *cfg, unsigned int frame_out,
int *mismatch_seen) {
aom_image_t enc_img, dec_img;
struct av1_ref_frame ref_enc, ref_dec;
if (*mismatch_seen)
return;
if (*mismatch_seen) return;
ref_enc.idx = 0;
ref_dec.idx = 0;
if (aom_codec_control(encoder, AV1_GET_REFERENCE, &ref_enc))
die_codec(encoder, "Failed to get encoder reference frame");
die_codec(encoder, "Failed to get encoder reference frame");
enc_img = ref_enc.img;
if (aom_codec_control(decoder, AV1_GET_REFERENCE, &ref_dec))
die_codec(decoder, "Failed to get decoder reference frame");
......@@ -216,37 +213,31 @@ static void testing_decode(aom_codec_ctx_t *encoder,
*mismatch_seen = 1;
find_mismatch(&enc_img, &dec_img, y, u, v);
printf("Encode/decode mismatch on frame %d at"
" Y[%d, %d] {%d/%d},"
" U[%d, %d] {%d/%d},"
" V[%d, %d] {%d/%d}",
frame_out,
y[0], y[1], y[2], y[3],
u[0], u[1], u[2], u[3],
v[0], v[1], v[2], v[3]);
printf(
"Encode/decode mismatch on frame %d at"
" Y[%d, %d] {%d/%d},"
" U[%d, %d] {%d/%d},"
" V[%d, %d] {%d/%d}",
frame_out, y[0], y[1], y[2], y[3], u[0], u[1], u[2], u[3], v[0], v[1],
v[2], v[3]);
}
aom_img_free(&enc_img);
aom_img_free(&dec_img);
}
static int encode_frame(aom_codec_ctx_t *ecodec,
aom_codec_enc_cfg_t *cfg,
aom_image_t *img,
unsigned int frame_in,
AvxVideoWriter *writer,
int test_decode,
aom_codec_ctx_t *dcodec,
unsigned int *frame_out,
static int encode_frame(aom_codec_ctx_t *ecodec, aom_codec_enc_cfg_t *cfg,
aom_image_t *img, unsigned int frame_in,
AvxVideoWriter *writer, int test_decode,
aom_codec_ctx_t *dcodec, unsigned int *frame_out,
int *mismatch_seen) {
int got_pkts = 0;
aom_codec_iter_t iter = NULL;
const aom_codec_cx_pkt_t *pkt = NULL;
int got_data;
const aom_codec_err_t res = aom_codec_encode(ecodec, img, frame_in, 1,
0, AOM_DL_GOOD_QUALITY);
if (res != AOM_CODEC_OK)
die_codec(ecodec, "Failed to encode frame");
const aom_codec_err_t res =
aom_codec_encode(ecodec, img, frame_in, 1, 0, AOM_DL_GOOD_QUALITY);
if (res != AOM_CODEC_OK) die_codec(ecodec, "Failed to encode frame");
got_data = 0;
......@@ -257,11 +248,10 @@ static int encode_frame(aom_codec_ctx_t *ecodec,
const int keyframe = (pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0;
if (!(pkt->data.frame.flags & AOM_FRAME_IS_FRAGMENT)) {
*frame_out += 1;
}
*frame_out += 1;
}
if (!aom_video_writer_write_frame(writer,
pkt->data.frame.buf,
if (!aom_video_writer_write_frame(writer, pkt->data.frame.buf,
pkt->data.frame.sz,
pkt->data.frame.pts)) {
die_codec(ecodec, "Failed to write compressed frame");
......@@ -290,12 +280,12 @@ static int encode_frame(aom_codec_ctx_t *ecodec,
int main(int argc, char **argv) {
FILE *infile = NULL;
// Encoder
aom_codec_ctx_t ecodec = {0};
aom_codec_enc_cfg_t cfg = {0};
aom_codec_ctx_t ecodec = { 0 };
aom_codec_enc_cfg_t cfg = { 0 };
unsigned int frame_in = 0;
aom_image_t raw;
aom_codec_err_t res;
AvxVideoInfo info = {0};
AvxVideoInfo info = { 0 };
AvxVideoWriter *writer = NULL;
const AvxInterface *encoder = NULL;
......@@ -320,8 +310,7 @@ int main(int argc, char **argv) {
int limit = 0;
exec_name = argv[0];
if (argc < 7)
die("Invalid number of arguments");
if (argc < 7) die("Invalid number of arguments");
codec_arg = argv[1];
width_arg = argv[2];
......@@ -330,15 +319,13 @@ int main(int argc, char **argv) {
outfile_arg = argv[5];
encoder = get_aom_encoder_by_name(codec_arg);
if (!encoder)
die("Unsupported codec.");
if (!encoder) die("Unsupported codec.");
update_frame_num = atoi(argv[6]);
// In AV1, the reference buffers (cm->buffer_pool->frame_bufs[i].buf) are
// allocated while calling aom_codec_encode(), thus, setting reference for
// 1st frame isn't supported.
if (update_frame_num <= 1)
die("Couldn't parse frame number '%s'\n", argv[6]);
if (update_frame_num <= 1) die("Couldn't parse frame number '%s'\n", argv[6]);
if (argc > 7) {
limit = atoi(argv[7]);
......@@ -352,23 +339,20 @@ int main(int argc, char **argv) {
info.time_base.numerator = 1;
info.time_base.denominator = fps;
if (info.frame_width <= 0 ||
info.frame_height <= 0 ||
(info.frame_width % 2) != 0 ||
(info.frame_height % 2) != 0) {
if (info.frame_width <= 0 || info.frame_height <= 0 ||
(info.frame_width % 2) != 0 || (info.frame_height % 2) != 0) {
die("Invalid frame size: %dx%d", info.frame_width, info.frame_height);
}
if (!aom_img_alloc(&raw, AOM_IMG_FMT_I420, info.frame_width,
info.frame_height, 1)) {
info.frame_height, 1)) {
die("Failed to allocate image.");
}
printf("Using %s\n", aom_codec_iface_name(encoder->codec_interface()));
res = aom_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
if (res)
die_codec(&ecodec, "Failed to get default codec config.");
if (res) die_codec(&ecodec, "Failed to get default codec config.");
cfg.g_w = info.frame_width;
cfg.g_h = info.frame_height;
......@@ -378,8 +362,7 @@ int main(int argc, char **argv) {
cfg.g_lag_in_frames = 3;
writer = aom_video_writer_open(outfile_arg, kContainerIVF, &info);
if (!writer)
die("Failed to open %s for writing.", outfile_arg);
if (!writer) die("Failed to open %s for writing.", outfile_arg);
if (!(infile = fopen(infile_arg, "rb")))
die("Failed to open %s for reading.", infile_arg);
......@@ -392,15 +375,14 @@ int main(int argc, char **argv) {
die_codec(&ecodec, "Failed to set enable auto alt ref");
if (test_decode) {
const AvxInterface *decoder = get_aom_decoder_by_name(codec_arg);
if (aom_codec_dec_init(&dcodec, decoder->codec_interface(), NULL, 0))
die_codec(&dcodec, "Failed to initialize decoder.");
const AvxInterface *decoder = get_aom_decoder_by_name(codec_arg);
if (aom_codec_dec_init(&dcodec, decoder->codec_interface(), NULL, 0))
die_codec(&dcodec, "Failed to initialize decoder.");
}
// Encode frames.
while (aom_img_read(&raw, infile)) {
if (limit && frame_in >= limit)
break;
if (limit && frame_in >= limit) break;
if (update_frame_num > 1 && frame_out + 1 == update_frame_num) {
aom_ref_frame_t ref;
ref.frame_type = AOM_LAST_FRAME;
......@@ -418,17 +400,17 @@ int main(int argc, char **argv) {
}
}
encode_frame(&ecodec, &cfg, &raw, frame_in, writer, test_decode,
&dcodec, &frame_out, &mismatch_seen);
encode_frame(&ecodec, &cfg, &raw, frame_in, writer, test_decode, &dcodec,
&frame_out, &mismatch_seen);
frame_in++;
if (mismatch_seen)
break;
if (mismatch_seen) break;
}
// Flush encoder.
if (!mismatch_seen)
while (encode_frame(&ecodec, &cfg, NULL, frame_in, writer, test_decode,
&dcodec, &frame_out, &mismatch_seen)) {}
&dcodec, &frame_out, &mismatch_seen)) {
}
printf("\n");
fclose(infile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment