#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common/tools_common.h"
#if CONFIG_AV1_ENCODER
#include "aom/aomcx.h"
#endif
#if CONFIG_AV1_DECODER
#include "aom/aomdx.h"
#endif
#if defined(_WIN32)
#include <io.h>
#include <fcntl.h>
#endif
#define LOG_ERROR(label) …
FILE *set_binary_mode(FILE *stream) { … }
void die(const char *fmt, ...) { … }
void fatal(const char *fmt, ...) { … }
void aom_tools_warn(const char *fmt, ...) { … }
void die_codec(aom_codec_ctx_t *ctx, const char *s) { … }
const char *image_format_to_string(aom_img_fmt_t fmt) { … }
int read_yuv_frame(struct AvxInputContext *input_ctx, aom_image_t *yuv_frame) { … }
struct CodecInfo { … };
#if CONFIG_AV1_ENCODER
static const struct CodecInfo aom_encoders[] = …;
int get_aom_encoder_count(void) { … }
aom_codec_iface_t *get_aom_encoder_by_index(int i) { … }
aom_codec_iface_t *get_aom_encoder_by_short_name(const char *name) { … }
uint32_t get_fourcc_by_aom_encoder(aom_codec_iface_t *iface) { … }
const char *get_short_name_by_aom_encoder(aom_codec_iface_t *iface) { … }
#endif
#if CONFIG_AV1_DECODER
static const struct CodecInfo aom_decoders[] = {
{ &aom_codec_av1_dx, "av1", AV1_FOURCC },
};
int get_aom_decoder_count(void) {
return sizeof(aom_decoders) / sizeof(aom_decoders[0]);
}
aom_codec_iface_t *get_aom_decoder_by_index(int i) {
assert(i >= 0 && i < get_aom_decoder_count());
return aom_decoders[i].interface();
}
aom_codec_iface_t *get_aom_decoder_by_short_name(const char *name) {
for (int i = 0; i < get_aom_decoder_count(); ++i) {
const struct CodecInfo *info = &aom_decoders[i];
if (strcmp(info->short_name, name) == 0) return info->interface();
}
return NULL;
}
aom_codec_iface_t *get_aom_decoder_by_fourcc(uint32_t fourcc) {
for (int i = 0; i < get_aom_decoder_count(); ++i) {
const struct CodecInfo *info = &aom_decoders[i];
if (info->fourcc == fourcc) return info->interface();
}
return NULL;
}
const char *get_short_name_by_aom_decoder(aom_codec_iface_t *iface) {
for (int i = 0; i < get_aom_decoder_count(); ++i) {
const struct CodecInfo *info = &aom_decoders[i];
if (info->interface() == iface) {
return info->short_name;
}
}
return NULL;
}
uint32_t get_fourcc_by_aom_decoder(aom_codec_iface_t *iface) {
for (int i = 0; i < get_aom_decoder_count(); ++i) {
const struct CodecInfo *info = &aom_decoders[i];
if (info->interface() == iface) {
return info->fourcc;
}
}
return 0;
}
#endif
void aom_img_write(const aom_image_t *img, FILE *file) { … }
bool aom_img_read(aom_image_t *img, FILE *file) { … }
double sse_to_psnr(double samples, double peak, double sse) { … }
static void highbd_img_upshift(aom_image_t *dst, const aom_image_t *src,
int input_shift) { … }
static void lowbd_img_upshift(aom_image_t *dst, const aom_image_t *src,
int input_shift) { … }
void aom_img_upshift(aom_image_t *dst, const aom_image_t *src,
int input_shift) { … }
void aom_img_truncate_16_to_8(aom_image_t *dst, const aom_image_t *src) { … }
static void highbd_img_downshift(aom_image_t *dst, const aom_image_t *src,
int down_shift) { … }
static void lowbd_img_downshift(aom_image_t *dst, const aom_image_t *src,
int down_shift) { … }
void aom_img_downshift(aom_image_t *dst, const aom_image_t *src,
int down_shift) { … }
static int img_shifted_realloc_required(const aom_image_t *img,
const aom_image_t *shifted,
aom_img_fmt_t required_fmt) { … }
bool aom_shift_img(unsigned int output_bit_depth, aom_image_t **img_ptr,
aom_image_t **img_shifted_ptr) { … }
void aom_img_write_nv12(const aom_image_t *img, FILE *file) { … }
size_t read_from_input(struct AvxInputContext *input_ctx, size_t n,
unsigned char *buf) { … }
size_t input_to_detect_buf(struct AvxInputContext *input_ctx, size_t n) { … }
size_t buffer_input(struct AvxInputContext *input_ctx, size_t n,
unsigned char *buf, bool buffered) { … }
void rewind_detect(struct AvxInputContext *input_ctx) { … }
bool input_eof(struct AvxInputContext *input_ctx) { … }