33 #include "common/tools_common.h" 34 #include "common/video_reader.h" 36 #define MAX_EXTERNAL_REFERENCES 128 37 #define AOM_BORDER_IN_PIXELS 288 39 static const char *exec_name;
41 void usage_exit(
void) {
43 "Usage: %s <infile> <outfile> <lf_width> <lf_height> <lf_blocksize> " 49 int main(
int argc,
char **argv) {
52 AvxVideoReader *reader = NULL;
53 const AvxInterface *decoder = NULL;
54 const AvxVideoInfo *info = NULL;
55 const char *lf_width_arg;
56 const char *lf_height_arg;
57 const char *lf_blocksize_arg;
59 int lf_width, lf_height, lf_blocksize;
60 int u_blocks, v_blocks;
62 aom_image_t reference_images[MAX_EXTERNAL_REFERENCES];
63 size_t frame_size = 0;
64 const unsigned char *frame = NULL;
69 if (argc != 7) die(
"Invalid number of arguments.");
71 reader = aom_video_reader_open(argv[1]);
72 if (!reader) die(
"Failed to open %s for reading.", argv[1]);
74 if (!(outfile = fopen(argv[2],
"wb")))
75 die(
"Failed to open %s for writing.", argv[2]);
77 lf_width_arg = argv[3];
78 lf_height_arg = argv[4];
79 lf_blocksize_arg = argv[5];
80 lf_width = (int)strtol(lf_width_arg, NULL, 0);
81 lf_height = (int)strtol(lf_height_arg, NULL, 0);
82 lf_blocksize = (int)strtol(lf_blocksize_arg, NULL, 0);
83 num_tile_lists = (int)strtol(argv[6], NULL, 0);
85 info = aom_video_reader_get_info(reader);
86 width = info->frame_width;
87 height = info->frame_height;
89 decoder = get_aom_decoder_by_fourcc(info->codec_fourcc);
90 if (!decoder) die(
"Unknown input codec.");
94 die_codec(&codec,
"Failed to initialize decoder.");
97 u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
98 v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
100 int num_references = v_blocks * u_blocks;
106 for (i = 0; i < num_references; i++) {
107 unsigned int border = AOM_BORDER_IN_PIXELS;
110 die(
"Failed to allocate references.");
117 for (i = 0; i < num_references; ++i) {
118 aom_video_reader_read_frame(reader);
119 frame = aom_video_reader_get_frame(reader, &frame_size);
121 die_codec(&codec,
"Failed to decode frame.");
124 &reference_images[i]))
125 die_codec(&codec,
"Failed to copy decoded reference frame");
131 snprintf(name,
sizeof(name),
"ref_%d.yuv", i);
132 printf(
"writing ref image to %s, %d, %d\n", name, img->
d_w, img->
d_h);
133 FILE *ref_file = fopen(name,
"wb");
134 aom_img_write(img, ref_file);
147 aom_video_reader_read_frame(reader);
148 frame = aom_video_reader_get_frame(reader, &frame_size);
150 die_codec(&codec,
"Failed to decode the frame.");
153 for (n = 0; n < num_tile_lists; n++) {
154 aom_video_reader_read_frame(reader);
155 frame = aom_video_reader_get_frame(reader, &frame_size);
158 die_codec(&codec,
"Failed to decode the tile list.");
166 for (i = 0; i < num_references; i++)
aom_img_free(&reference_images[i]);
168 aom_video_reader_close(reader);
unsigned char * img_data
Definition: aom_image.h:188
unsigned int d_h
Definition: aom_image.h:157
aom_image_t * aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Decoded frames iterator.
enum aom_img_fmt aom_img_fmt_t
List of supported image formats.
Codec context structure.
Definition: aom_codec.h:204
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
Describes the decoder algorithm interface to applications.
Image Descriptor.
Definition: aom_image.h:141
aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data, size_t data_sz, void *user_priv)
Decode data.
aom_codec_err_t aom_codec_control_(aom_codec_ctx_t *ctx, int ctrl_id,...)
Control algorithm.
#define aom_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_dec_init_ver()
Definition: aom_decoder.h:142
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_image_t * aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align, unsigned int size_align, unsigned int border)
Open a descriptor, allocating storage for the underlying image with a border.
void aom_img_free(aom_image_t *img)
Close an image descriptor.
#define aom_codec_control(ctx, id, data)
aom_codec_control wrapper macro
Definition: aom_codec.h:423
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
size_t sz
Definition: aom_image.h:175
Structure to hold the external reference frame pointer.
Definition: aomdx.h:80
Provides definitions for using AOM or AV1 within the aom Decoder interface.
Definition: aom_image.h:45
unsigned int d_w
Definition: aom_image.h:156