19 #include "config/aom_config.h" 24 #elif !defined(STDOUT_FILENO) 25 #define STDOUT_FILENO 1 31 #include "aom_ports/aom_timer.h" 32 #include "aom_ports/mem_ops.h" 33 #include "common/args.h" 34 #include "common/ivfdec.h" 35 #include "common/md5_utils.h" 36 #include "common/obudec.h" 37 #include "common/tools_common.h" 40 #include "common/webmdec.h" 43 #include "common/rawenc.h" 44 #include "common/y4menc.h" 47 #include "third_party/libyuv/include/libyuv/scale.h" 50 static const char *exec_name;
52 struct AvxDecInputContext {
53 struct AvxInputContext *aom_input_ctx;
54 struct ObuDecInputContext *obu_ctx;
55 struct WebmInputContext *webm_ctx;
58 static const arg_def_t help =
59 ARG_DEF(NULL,
"help", 0,
"Show usage options and exit");
60 static const arg_def_t looparg =
61 ARG_DEF(NULL,
"loops", 1,
"Number of times to decode the file");
62 static const arg_def_t codecarg = ARG_DEF(NULL,
"codec", 1,
"Codec to use");
63 static const arg_def_t use_yv12 =
64 ARG_DEF(NULL,
"yv12", 0,
"Output raw YV12 frames");
65 static const arg_def_t use_i420 =
66 ARG_DEF(NULL,
"i420", 0,
"Output raw I420 frames");
67 static const arg_def_t flipuvarg =
68 ARG_DEF(NULL,
"flipuv", 0,
"Flip the chroma planes in the output");
69 static const arg_def_t rawvideo =
70 ARG_DEF(NULL,
"rawvideo", 0,
"Output raw YUV frames");
71 static const arg_def_t noblitarg =
72 ARG_DEF(NULL,
"noblit", 0,
"Don't process the decoded frames");
73 static const arg_def_t progressarg =
74 ARG_DEF(NULL,
"progress", 0,
"Show progress after each frame decodes");
75 static const arg_def_t limitarg =
76 ARG_DEF(NULL,
"limit", 1,
"Stop decoding after n frames");
77 static const arg_def_t skiparg =
78 ARG_DEF(NULL,
"skip", 1,
"Skip the first n input frames");
79 static const arg_def_t postprocarg =
80 ARG_DEF(NULL,
"postproc", 0,
"Postprocess decoded frames");
81 static const arg_def_t summaryarg =
82 ARG_DEF(NULL,
"summary", 0,
"Show timing summary");
83 static const arg_def_t outputfile =
84 ARG_DEF(
"o",
"output", 1,
"Output file name pattern (see below)");
85 static const arg_def_t threadsarg =
86 ARG_DEF(
"t",
"threads", 1,
"Max threads to use");
87 static const arg_def_t verbosearg =
88 ARG_DEF(
"v",
"verbose", 0,
"Show version string");
89 static const arg_def_t scalearg =
90 ARG_DEF(
"S",
"scale", 0,
"Scale output frames uniformly");
91 static const arg_def_t continuearg =
92 ARG_DEF(
"k",
"keep-going", 0,
"(debug) Continue decoding after error");
93 static const arg_def_t fb_arg =
94 ARG_DEF(NULL,
"frame-buffers", 1,
"Number of frame buffers to use");
95 static const arg_def_t md5arg =
96 ARG_DEF(NULL,
"md5", 0,
"Compute the MD5 sum of the decoded frame");
97 static const arg_def_t framestatsarg =
98 ARG_DEF(NULL,
"framestats", 1,
"Output per-frame stats (.csv format)");
99 static const arg_def_t outbitdeptharg =
100 ARG_DEF(NULL,
"output-bit-depth", 1,
"Output bit-depth for decoded frames");
101 static const arg_def_t isannexb =
102 ARG_DEF(NULL,
"annexb", 0,
"Bitstream is in Annex-B format");
103 static const arg_def_t oppointarg = ARG_DEF(
104 NULL,
"oppoint", 1,
"Select an operating point of a scalable bitstream");
105 static const arg_def_t outallarg = ARG_DEF(
106 NULL,
"all-layers", 0,
"Output all decoded frames of a scalable bitstream");
107 static const arg_def_t skipfilmgrain =
108 ARG_DEF(NULL,
"skip-film-grain", 0,
"Skip film grain application");
110 static const arg_def_t *all_args[] = {
111 &help, &codecarg, &use_yv12, &use_i420,
112 &flipuvarg, &rawvideo, &noblitarg, &progressarg,
113 &limitarg, &skiparg, &postprocarg, &summaryarg,
114 &outputfile, &threadsarg, &verbosearg, &scalearg,
115 &fb_arg, &md5arg, &framestatsarg, &continuearg,
116 &outbitdeptharg, &isannexb, &oppointarg, &outallarg,
122 FilterModeEnum mode) {
129 src->
d_w, src->
d_h, (uint16_t *)dst->
planes[AOM_PLANE_Y],
130 dst->
stride[AOM_PLANE_Y] / 2, (uint16_t *)dst->
planes[AOM_PLANE_U],
131 dst->
stride[AOM_PLANE_U] / 2, (uint16_t *)dst->
planes[AOM_PLANE_V],
132 dst->
stride[AOM_PLANE_V] / 2, dst->
d_w, dst->
d_h, mode);
146 static void show_help(FILE *fout,
int shorthelp) {
147 fprintf(fout,
"Usage: %s <options> filename\n\n", exec_name);
150 fprintf(fout,
"Use --help to see the full list of options.\n");
154 fprintf(fout,
"Options:\n");
155 arg_show_usage(fout, all_args);
157 "\nOutput File Patterns:\n\n" 158 " The -o argument specifies the name of the file(s) to " 159 "write to. If the\n argument does not include any escape " 160 "characters, the output will be\n written to a single file. " 161 "Otherwise, the filename will be calculated by\n expanding " 162 "the following escape characters:\n");
164 "\n\t%%w - Frame width" 165 "\n\t%%h - Frame height" 166 "\n\t%%<n> - Frame number, zero padded to <n> places (1..9)" 167 "\n\n Pattern arguments are only supported in conjunction " 168 "with the --yv12 and\n --i420 options. If the -o option is " 169 "not specified, the output will be\n directed to stdout.\n");
170 fprintf(fout,
"\nIncluded decoders:\n\n");
172 for (
int i = 0; i < get_aom_decoder_count(); ++i) {
173 const AvxInterface *
const decoder = get_aom_decoder_by_index(i);
174 fprintf(fout,
" %-6s - %s\n", decoder->name,
179 void usage_exit(
void) {
180 show_help(stderr, 1);
184 static int raw_read_frame(FILE *infile, uint8_t **buffer,
size_t *bytes_read,
185 size_t *buffer_size) {
186 char raw_hdr[RAW_FRAME_HDR_SZ];
187 size_t frame_size = 0;
189 if (fread(raw_hdr, RAW_FRAME_HDR_SZ, 1, infile) != 1) {
190 if (!feof(infile)) warn(
"Failed to read RAW frame size\n");
192 const size_t kCorruptFrameThreshold = 256 * 1024 * 1024;
193 const size_t kFrameTooSmallThreshold = 256 * 1024;
194 frame_size = mem_get_le32(raw_hdr);
196 if (frame_size > kCorruptFrameThreshold) {
197 warn(
"Read invalid frame size (%u)\n", (
unsigned int)frame_size);
201 if (frame_size < kFrameTooSmallThreshold) {
202 warn(
"Warning: Read invalid frame size (%u) - not a raw file?\n",
203 (
unsigned int)frame_size);
206 if (frame_size > *buffer_size) {
207 uint8_t *new_buf = realloc(*buffer, 2 * frame_size);
210 *buffer_size = 2 * frame_size;
212 warn(
"Failed to allocate compressed data buffer\n");
219 if (fread(*buffer, 1, frame_size, infile) != frame_size) {
220 warn(
"Failed to read full frame\n");
223 *bytes_read = frame_size;
229 static int read_frame(
struct AvxDecInputContext *input, uint8_t **buf,
230 size_t *bytes_in_buffer,
size_t *buffer_size) {
231 switch (input->aom_input_ctx->file_type) {
234 return webm_read_frame(input->webm_ctx, buf, bytes_in_buffer,
238 return raw_read_frame(input->aom_input_ctx->file, buf, bytes_in_buffer,
241 return ivf_read_frame(input->aom_input_ctx->file, buf, bytes_in_buffer,
244 return obudec_read_temporal_unit(input->obu_ctx, buf, bytes_in_buffer,
250 static int file_is_raw(
struct AvxInputContext *input) {
254 memset(&si, 0,
sizeof(si));
256 if (fread(buf, 1, 32, input->file) == 32) {
259 if (mem_get_le32(buf) < 256 * 1024 * 1024) {
260 for (i = 0; i < get_aom_decoder_count(); ++i) {
261 const AvxInterface *
const decoder = get_aom_decoder_by_index(i);
265 input->fourcc = decoder->fourcc;
267 input->height = si.
h;
268 input->framerate.numerator = 30;
269 input->framerate.denominator = 1;
280 static void show_progress(
int frame_in,
int frame_out, uint64_t dx_time) {
282 "%d decoded frames/%d showed frames in %" PRId64
" us (%.2f fps)\r",
283 frame_in, frame_out, dx_time,
284 (
double)frame_out * 1000000.0 / (
double)dx_time);
287 struct ExternalFrameBuffer {
293 struct ExternalFrameBufferList {
294 int num_external_frame_buffers;
295 struct ExternalFrameBuffer *ext_fb;
302 static int get_av1_frame_buffer(
void *cb_priv,
size_t min_size,
305 struct ExternalFrameBufferList *
const ext_fb_list =
306 (
struct ExternalFrameBufferList *)cb_priv;
307 if (ext_fb_list == NULL)
return -1;
310 for (i = 0; i < ext_fb_list->num_external_frame_buffers; ++i) {
311 if (!ext_fb_list->ext_fb[i].in_use)
break;
314 if (i == ext_fb_list->num_external_frame_buffers)
return -1;
316 if (ext_fb_list->ext_fb[i].size < min_size) {
317 free(ext_fb_list->ext_fb[i].data);
318 ext_fb_list->ext_fb[i].data = (uint8_t *)calloc(min_size,
sizeof(uint8_t));
319 if (!ext_fb_list->ext_fb[i].data)
return -1;
321 ext_fb_list->ext_fb[i].size = min_size;
324 fb->
data = ext_fb_list->ext_fb[i].data;
325 fb->
size = ext_fb_list->ext_fb[i].size;
326 ext_fb_list->ext_fb[i].in_use = 1;
329 fb->
priv = &ext_fb_list->ext_fb[i];
336 static int release_av1_frame_buffer(
void *cb_priv,
338 struct ExternalFrameBuffer *
const ext_fb =
339 (
struct ExternalFrameBuffer *)fb->
priv;
345 static void generate_filename(
const char *pattern,
char *out,
size_t q_len,
346 unsigned int d_w,
unsigned int d_h,
347 unsigned int frame_in) {
348 const char *p = pattern;
352 char *next_pat = strchr(p,
'%');
360 case 'w': snprintf(q, q_len - 1,
"%d", d_w);
break;
361 case 'h': snprintf(q, q_len - 1,
"%d", d_h);
break;
362 case '1': snprintf(q, q_len - 1,
"%d", frame_in);
break;
363 case '2': snprintf(q, q_len - 1,
"%02d", frame_in);
break;
364 case '3': snprintf(q, q_len - 1,
"%03d", frame_in);
break;
365 case '4': snprintf(q, q_len - 1,
"%04d", frame_in);
break;
366 case '5': snprintf(q, q_len - 1,
"%05d", frame_in);
break;
367 case '6': snprintf(q, q_len - 1,
"%06d", frame_in);
break;
368 case '7': snprintf(q, q_len - 1,
"%07d", frame_in);
break;
369 case '8': snprintf(q, q_len - 1,
"%08d", frame_in);
break;
370 case '9': snprintf(q, q_len - 1,
"%09d", frame_in);
break;
371 default: die(
"Unrecognized pattern %%%c\n", p[1]);
break;
375 if (pat_len >= q_len - 1) die(
"Output filename too long.\n");
384 copy_len = strlen(p);
386 copy_len = next_pat - p;
388 if (copy_len >= q_len - 1) die(
"Output filename too long.\n");
390 memcpy(q, p, copy_len);
399 static int is_single_file(
const char *outfile_pattern) {
400 const char *p = outfile_pattern;
404 if (p && p[1] >=
'1' && p[1] <=
'9')
412 static void print_md5(
unsigned char digest[16],
const char *filename) {
415 for (i = 0; i < 16; ++i) printf(
"%02x", digest[i]);
416 printf(
" %s\n", filename);
419 static FILE *open_outfile(
const char *name) {
420 if (strcmp(
"-", name) == 0) {
421 set_binary_mode(stdout);
424 FILE *file = fopen(name,
"wb");
425 if (!file) fatal(
"Failed to open output file '%s'", name);
430 static int img_shifted_realloc_required(
const aom_image_t *img,
433 return img->
d_w != shifted->
d_w || img->
d_h != shifted->
d_h ||
434 required_fmt != shifted->
fmt;
437 static int main_loop(
int argc,
const char **argv_) {
441 int ret = EXIT_FAILURE;
443 size_t bytes_in_buffer = 0, buffer_size = 0;
445 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0;
446 int do_md5 = 0, progress = 0;
447 int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
450 const AvxInterface *
interface = NULL;
451 const AvxInterface *fourcc_interface = NULL;
452 uint64_t dx_time = 0;
454 char **argv, **argi, **argj;
462 unsigned int output_bit_depth = 0;
463 unsigned int is_annexb = 0;
464 int frames_corrupted = 0;
467 int operating_point = 0;
468 int output_all_layers = 0;
469 int skip_film_grain = 0;
472 int frame_avail, got_data, flush_decoder = 0;
473 int num_external_frame_buffers = 0;
474 struct ExternalFrameBufferList ext_fb_list = { 0, NULL };
476 const char *outfile_pattern = NULL;
477 char outfile_name[PATH_MAX] = { 0 };
478 FILE *outfile = NULL;
480 FILE *framestats_file = NULL;
483 unsigned char md5_digest[16];
485 struct AvxDecInputContext input = { NULL, NULL, NULL };
486 struct AvxInputContext aom_input_ctx;
487 memset(&aom_input_ctx, 0,
sizeof(aom_input_ctx));
489 struct WebmInputContext webm_ctx;
490 memset(&webm_ctx, 0,
sizeof(webm_ctx));
491 input.webm_ctx = &webm_ctx;
493 struct ObuDecInputContext obu_ctx = { NULL, NULL, 0, 0, 0 };
495 obu_ctx.avx_ctx = &aom_input_ctx;
496 input.obu_ctx = &obu_ctx;
497 input.aom_input_ctx = &aom_input_ctx;
500 exec_name = argv_[0];
501 argv = argv_dup(argc - 1, argv_ + 1);
503 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
504 memset(&arg, 0,
sizeof(arg));
507 if (arg_match(&arg, &help, argi)) {
508 show_help(stdout, 0);
510 }
else if (arg_match(&arg, &codecarg, argi)) {
511 interface = get_aom_decoder_by_name(arg.val);
513 die(
"Error: Unrecognized argument (%s) to --codec\n", arg.val);
514 }
else if (arg_match(&arg, &looparg, argi)) {
516 }
else if (arg_match(&arg, &outputfile, argi)) {
517 outfile_pattern = arg.val;
518 }
else if (arg_match(&arg, &use_yv12, argi)) {
524 }
else if (arg_match(&arg, &use_i420, argi)) {
530 }
else if (arg_match(&arg, &rawvideo, argi)) {
535 }
else if (arg_match(&arg, &flipuvarg, argi)) {
537 }
else if (arg_match(&arg, &noblitarg, argi)) {
539 }
else if (arg_match(&arg, &progressarg, argi)) {
541 }
else if (arg_match(&arg, &limitarg, argi)) {
542 stop_after = arg_parse_uint(&arg);
543 }
else if (arg_match(&arg, &skiparg, argi)) {
544 arg_skip = arg_parse_uint(&arg);
545 }
else if (arg_match(&arg, &postprocarg, argi)) {
547 }
else if (arg_match(&arg, &md5arg, argi)) {
549 }
else if (arg_match(&arg, &framestatsarg, argi)) {
550 framestats_file = fopen(arg.val,
"w");
551 if (!framestats_file) {
552 die(
"Error: Could not open --framestats file (%s) for writing.\n",
555 }
else if (arg_match(&arg, &summaryarg, argi)) {
557 }
else if (arg_match(&arg, &threadsarg, argi)) {
558 cfg.
threads = arg_parse_uint(&arg);
559 #if !CONFIG_MULTITHREAD 561 die(
"Error: --threads=%d is not supported when CONFIG_MULTITHREAD = " 566 }
else if (arg_match(&arg, &verbosearg, argi)) {
568 }
else if (arg_match(&arg, &scalearg, argi)) {
570 }
else if (arg_match(&arg, &fb_arg, argi)) {
571 num_external_frame_buffers = arg_parse_uint(&arg);
572 }
else if (arg_match(&arg, &continuearg, argi)) {
574 }
else if (arg_match(&arg, &outbitdeptharg, argi)) {
575 output_bit_depth = arg_parse_uint(&arg);
576 }
else if (arg_match(&arg, &isannexb, argi)) {
578 input.obu_ctx->is_annexb = 1;
579 }
else if (arg_match(&arg, &oppointarg, argi)) {
580 operating_point = arg_parse_int(&arg);
581 }
else if (arg_match(&arg, &outallarg, argi)) {
582 output_all_layers = 1;
583 }
else if (arg_match(&arg, &skipfilmgrain, argi)) {
591 for (argi = argv; *argi; argi++)
592 if (argi[0][0] ==
'-' && strlen(argi[0]) > 1)
593 die(
"Error: Unrecognized option %s\n", *argi);
600 fprintf(stderr,
"No input file specified!\n");
604 infile = strcmp(fn,
"-") ? fopen(fn,
"rb") : set_binary_mode(stdin);
607 fatal(
"Failed to open input file '%s'", strcmp(fn,
"-") ? fn :
"stdin");
609 #if CONFIG_OS_SUPPORT 611 if (!outfile_pattern && isatty(STDOUT_FILENO) && !do_md5 && !noblit) {
613 "Not dumping raw video to your terminal. Use '-o -' to " 618 input.aom_input_ctx->filename = fn;
619 input.aom_input_ctx->file = infile;
620 if (file_is_ivf(input.aom_input_ctx))
621 input.aom_input_ctx->file_type = FILE_TYPE_IVF;
623 else if (file_is_webm(input.webm_ctx, input.aom_input_ctx))
624 input.aom_input_ctx->file_type = FILE_TYPE_WEBM;
626 else if (file_is_obu(&obu_ctx))
627 input.aom_input_ctx->file_type = FILE_TYPE_OBU;
628 else if (file_is_raw(input.aom_input_ctx))
629 input.aom_input_ctx->file_type = FILE_TYPE_RAW;
631 fprintf(stderr,
"Unrecognized input file type.\n");
633 fprintf(stderr,
"aomdec was built without WebM container support.\n");
638 outfile_pattern = outfile_pattern ? outfile_pattern :
"-";
639 single_file = is_single_file(outfile_pattern);
641 if (!noblit && single_file) {
642 generate_filename(outfile_pattern, outfile_name, PATH_MAX,
643 aom_input_ctx.width, aom_input_ctx.height, 0);
647 outfile = open_outfile(outfile_name);
650 if (use_y4m && !noblit) {
653 "YUV4MPEG2 not supported with output patterns," 654 " try --i420 or --yv12 or --rawvideo.\n");
659 if (aom_input_ctx.file_type == FILE_TYPE_WEBM) {
660 if (webm_guess_framerate(input.webm_ctx, input.aom_input_ctx)) {
662 "Failed to guess framerate -- error parsing " 670 fourcc_interface = get_aom_decoder_by_fourcc(aom_input_ctx.fourcc);
671 if (interface && fourcc_interface && interface != fourcc_interface)
672 warn(
"Header indicates codec: %s\n", fourcc_interface->name);
674 interface = fourcc_interface;
676 if (!interface)
interface = get_aom_decoder_by_index(0);
681 fprintf(stderr,
"Failed to initialize decoder: %s\n",
686 if (!quiet) fprintf(stderr,
"%s\n", decoder.
name);
689 fprintf(stderr,
"Failed to set is_annexb: %s\n",
aom_codec_error(&decoder));
694 fprintf(stderr,
"Failed to set operating_point: %s\n",
700 output_all_layers)) {
701 fprintf(stderr,
"Failed to set output_all_layers: %s\n",
707 fprintf(stderr,
"Failed to set skip_film_grain: %s\n",
712 if (arg_skip) fprintf(stderr,
"Skipping first %d frames.\n", arg_skip);
714 if (read_frame(&input, &buf, &bytes_in_buffer, &buffer_size))
break;
718 if (num_external_frame_buffers > 0) {
719 ext_fb_list.num_external_frame_buffers = num_external_frame_buffers;
720 ext_fb_list.ext_fb = (
struct ExternalFrameBuffer *)calloc(
721 num_external_frame_buffers,
sizeof(*ext_fb_list.ext_fb));
723 release_av1_frame_buffer,
725 fprintf(stderr,
"Failed to configure external frame buffers: %s\n",
734 if (framestats_file) fprintf(framestats_file,
"bytes,qp\r\n");
737 while (frame_avail || got_data) {
740 struct aom_usec_timer timer;
744 if (!stop_after || frame_in < stop_after) {
745 if (!read_frame(&input, &buf, &bytes_in_buffer, &buffer_size)) {
749 aom_usec_timer_start(&timer);
753 warn(
"Failed to decode frame %d: %s", frame_in,
756 if (detail) warn(
"Additional information: %s", detail);
757 if (!keep_going)
goto fail;
760 if (framestats_file) {
763 warn(
"Failed AOMD_GET_LAST_QUANTIZER: %s",
765 if (!keep_going)
goto fail;
767 fprintf(framestats_file,
"%d,%d\r\n", (
int)bytes_in_buffer, qp);
770 aom_usec_timer_mark(&timer);
771 dx_time += aom_usec_timer_elapsed(&timer);
779 aom_usec_timer_start(&timer);
788 aom_usec_timer_mark(&timer);
789 dx_time += aom_usec_timer_elapsed(&timer);
798 if (!keep_going)
goto fail;
800 frames_corrupted += corrupted;
802 if (progress) show_progress(frame_in, frame_out, dx_time);
807 const int *planes = flipuv ? PLANES_YVU : PLANES_YUV;
810 if (frame_out == 1) {
816 int render_width = aom_input_ctx.width;
817 int render_height = aom_input_ctx.height;
818 if (!render_width || !render_height) {
823 render_width = img->
d_w;
824 render_height = img->
d_h;
826 render_width = render_size[0];
827 render_height = render_size[1];
834 scaled_img->
csp = img->
csp;
837 if (img->
d_w != scaled_img->
d_w || img->
d_h != scaled_img->
d_h) {
839 libyuv_scale(img, scaled_img, kFilterBox);
844 "Failed to scale output frame: %s.\n" 845 "libyuv is required for scaling but is currently disabled.\n" 846 "Be sure to specify -DCONFIG_LIBYUV=1 when running cmake.\n",
853 if (!output_bit_depth && single_file && !do_md5) {
857 if (output_bit_depth != 0) {
862 if (shifted_fmt != img->
fmt || output_bit_depth != img->
bit_depth) {
864 img_shifted_realloc_required(img, img_shifted, shifted_fmt)) {
874 img_shifted->
bit_depth = output_bit_depth;
876 img_shifted->
csp = img->
csp;
879 aom_img_upshift(img_shifted, img,
882 aom_img_downshift(img_shifted, img,
889 aom_input_ctx.width = img->
d_w;
890 aom_input_ctx.height = img->
d_h;
892 int num_planes = (opt_raw && img->
monochrome) ? 1 : 3;
895 char y4m_buf[Y4M_BUFFER_SIZE] = { 0 };
897 if (frame_out == 1) {
899 len = y4m_write_file_header(
900 y4m_buf,
sizeof(y4m_buf), aom_input_ctx.width,
901 aom_input_ctx.height, &aom_input_ctx.framerate,
904 MD5Update(&md5_ctx, (md5byte *)y4m_buf, (
unsigned int)len);
906 fputs(y4m_buf, outfile);
911 len = y4m_write_frame_header(y4m_buf,
sizeof(y4m_buf));
913 MD5Update(&md5_ctx, (md5byte *)y4m_buf, (
unsigned int)len);
914 y4m_update_image_md5(img, planes, &md5_ctx);
916 fputs(y4m_buf, outfile);
917 y4m_write_image_file(img, planes, outfile);
920 if (frame_out == 1) {
927 "Cannot produce i420 output for bit-stream.\n");
936 "Cannot produce yv12 output for bit-stream.\n");
942 raw_update_image_md5(img, planes, num_planes, &md5_ctx);
944 raw_write_image_file(img, planes, num_planes, outfile);
948 generate_filename(outfile_pattern, outfile_name, PATH_MAX, img->
d_w,
953 y4m_update_image_md5(img, planes, &md5_ctx);
955 raw_update_image_md5(img, planes, num_planes, &md5_ctx);
957 MD5Final(md5_digest, &md5_ctx);
958 print_md5(md5_digest, outfile_name);
960 outfile = open_outfile(outfile_name);
962 y4m_write_image_file(img, planes, outfile);
964 raw_write_image_file(img, planes, num_planes, outfile);
973 if (summary || progress) {
974 show_progress(frame_in, frame_out, dx_time);
975 fprintf(stderr,
"\n");
978 if (frames_corrupted) {
979 fprintf(stderr,
"WARNING: %d frames corrupted.\n", frames_corrupted);
987 fprintf(stderr,
"Failed to destroy decoder: %s\n",
993 if (!noblit && single_file) {
995 MD5Final(md5_digest, &md5_ctx);
996 print_md5(md5_digest, outfile_name);
1003 if (input.aom_input_ctx->file_type == FILE_TYPE_WEBM)
1004 webm_free(input.webm_ctx);
1006 if (input.aom_input_ctx->file_type == FILE_TYPE_OBU)
1007 obudec_free(input.obu_ctx);
1009 if (input.aom_input_ctx->file_type != FILE_TYPE_WEBM) free(buf);
1014 for (i = 0; i < ext_fb_list.num_external_frame_buffers; ++i) {
1015 free(ext_fb_list.ext_fb[i].data);
1017 free(ext_fb_list.ext_fb);
1020 if (framestats_file) fclose(framestats_file);
1027 int main(
int argc,
const char **argv_) {
1028 unsigned int loops = 1, i;
1029 char **argv, **argi, **argj;
1033 argv = argv_dup(argc - 1, argv_ + 1);
1034 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
1035 memset(&arg, 0,
sizeof(arg));
1038 if (arg_match(&arg, &looparg, argi)) {
1039 loops = arg_parse_uint(&arg);
1044 for (i = 0; !error && i < loops; i++) error = main_loop(argc, argv_);
#define AOM_PLANE_U
Definition: aom_image.h:170
unsigned int d_h
Definition: aom_image.h:157
#define AOM_PLANE_V
Definition: aom_image.h:171
aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface, const uint8_t *data, size_t data_sz, aom_codec_stream_info_t *si)
Parse stream info from a buffer.
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.
const char * name
Definition: aom_codec.h:205
uint8_t * data
Definition: aom_frame_buffer.h:41
Codec context structure.
Definition: aom_codec.h:204
int stride[4]
Definition: aom_image.h:174
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
External frame buffer.
Definition: aom_frame_buffer.h:40
Describes the decoder algorithm interface to applications.
int monochrome
Definition: aom_image.h:146
Image Descriptor.
Definition: aom_image.h:141
aom_image_t * aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
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.
#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.
void * priv
Definition: aom_frame_buffer.h:43
void aom_img_free(aom_image_t *img)
Close an image descriptor.
unsigned int h
Definition: aom_decoder.h:85
Initialization Configurations.
Definition: aom_decoder.h:103
#define aom_codec_control(ctx, id, data)
aom_codec_control wrapper macro
Definition: aom_codec.h:414
Stream properties.
Definition: aom_decoder.h:83
unsigned int w
Definition: aom_decoder.h:84
aom_chroma_sample_position_t csp
Definition: aom_image.h:147
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
size_t size
Definition: aom_frame_buffer.h:42
const char * aom_codec_error(aom_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
Definition: aom_image.h:52
Provides definitions for using AOM or AV1 within the aom Decoder interface.
aom_codec_err_t aom_codec_set_frame_buffer_functions(aom_codec_ctx_t *ctx, aom_get_frame_buffer_cb_fn_t cb_get, aom_release_frame_buffer_cb_fn_t cb_release, void *cb_priv)
Pass in external frame buffers for the decoder to use.
Definition: aom_image.h:45
const char * aom_codec_error_detail(aom_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
unsigned int threads
Definition: aom_decoder.h:104
unsigned int bit_depth
Definition: aom_image.h:153
unsigned char * planes[4]
Definition: aom_image.h:173
unsigned int d_w
Definition: aom_image.h:156
Definition: aom_image.h:43
aom_img_fmt_t fmt
Definition: aom_image.h:142
#define AOM_CODEC_USE_POSTPROC
Definition: aom_decoder.h:73
#define AOM_PLANE_Y
Definition: aom_image.h:169