| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 src->planes[VPX_PLANE_V], src->stride[VPX_PLANE_V], | 162 src->planes[VPX_PLANE_V], src->stride[VPX_PLANE_V], |
| 163 src->d_w, src->d_h, | 163 src->d_w, src->d_h, |
| 164 dst->planes[VPX_PLANE_Y], dst->stride[VPX_PLANE_Y], | 164 dst->planes[VPX_PLANE_Y], dst->stride[VPX_PLANE_Y], |
| 165 dst->planes[VPX_PLANE_U], dst->stride[VPX_PLANE_U], | 165 dst->planes[VPX_PLANE_U], dst->stride[VPX_PLANE_U], |
| 166 dst->planes[VPX_PLANE_V], dst->stride[VPX_PLANE_V], | 166 dst->planes[VPX_PLANE_V], dst->stride[VPX_PLANE_V], |
| 167 dst->d_w, dst->d_h, | 167 dst->d_w, dst->d_h, |
| 168 mode); | 168 mode); |
| 169 } | 169 } |
| 170 #endif | 170 #endif |
| 171 | 171 |
| 172 void usage_exit() { | 172 void usage_exit(void) { |
| 173 int i; | 173 int i; |
| 174 | 174 |
| 175 fprintf(stderr, "Usage: %s <options> filename\n\n" | 175 fprintf(stderr, "Usage: %s <options> filename\n\n" |
| 176 "Options:\n", exec_name); | 176 "Options:\n", exec_name); |
| 177 arg_show_usage(stderr, all_args); | 177 arg_show_usage(stderr, all_args); |
| 178 #if CONFIG_VP8_DECODER | 178 #if CONFIG_VP8_DECODER |
| 179 fprintf(stderr, "\nVP8 Postprocessing Options:\n"); | 179 fprintf(stderr, "\nVP8 Postprocessing Options:\n"); |
| 180 arg_show_usage(stderr, vp8_pp_args); | 180 arg_show_usage(stderr, vp8_pp_args); |
| 181 #endif | 181 #endif |
| 182 fprintf(stderr, | 182 fprintf(stderr, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const int w = vpx_img_plane_width(img, plane); | 305 const int w = vpx_img_plane_width(img, plane); |
| 306 const int h = vpx_img_plane_height(img, plane); | 306 const int h = vpx_img_plane_height(img, plane); |
| 307 | 307 |
| 308 for (y = 0; y < h; ++y) { | 308 for (y = 0; y < h; ++y) { |
| 309 fwrite(buf, bytes_per_sample, w, file); | 309 fwrite(buf, bytes_per_sample, w, file); |
| 310 buf += stride; | 310 buf += stride; |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 int file_is_raw(struct VpxInputContext *input) { | 315 static int file_is_raw(struct VpxInputContext *input) { |
| 316 uint8_t buf[32]; | 316 uint8_t buf[32]; |
| 317 int is_raw = 0; | 317 int is_raw = 0; |
| 318 vpx_codec_stream_info_t si; | 318 vpx_codec_stream_info_t si; |
| 319 | 319 |
| 320 si.sz = sizeof(si); | 320 si.sz = sizeof(si); |
| 321 | 321 |
| 322 if (fread(buf, 1, 32, input->file) == 32) { | 322 if (fread(buf, 1, 32, input->file) == 32) { |
| 323 int i; | 323 int i; |
| 324 | 324 |
| 325 if (mem_get_le32(buf) < 256 * 1024 * 1024) { | 325 if (mem_get_le32(buf) < 256 * 1024 * 1024) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 336 break; | 336 break; |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 rewind(input->file); | 342 rewind(input->file); |
| 343 return is_raw; | 343 return is_raw; |
| 344 } | 344 } |
| 345 | 345 |
| 346 void show_progress(int frame_in, int frame_out, uint64_t dx_time) { | 346 static void show_progress(int frame_in, int frame_out, uint64_t dx_time) { |
| 347 fprintf(stderr, | 347 fprintf(stderr, |
| 348 "%d decoded frames/%d showed frames in %"PRId64" us (%.2f fps)\r", | 348 "%d decoded frames/%d showed frames in %"PRId64" us (%.2f fps)\r", |
| 349 frame_in, frame_out, dx_time, | 349 frame_in, frame_out, dx_time, |
| 350 (double)frame_out * 1000000.0 / (double)dx_time); | 350 (double)frame_out * 1000000.0 / (double)dx_time); |
| 351 } | 351 } |
| 352 | 352 |
| 353 struct ExternalFrameBuffer { | 353 struct ExternalFrameBuffer { |
| 354 uint8_t* data; | 354 uint8_t* data; |
| 355 size_t size; | 355 size_t size; |
| 356 int in_use; | 356 int in_use; |
| 357 }; | 357 }; |
| 358 | 358 |
| 359 struct ExternalFrameBufferList { | 359 struct ExternalFrameBufferList { |
| 360 int num_external_frame_buffers; | 360 int num_external_frame_buffers; |
| 361 struct ExternalFrameBuffer *ext_fb; | 361 struct ExternalFrameBuffer *ext_fb; |
| 362 }; | 362 }; |
| 363 | 363 |
| 364 // Callback used by libvpx to request an external frame buffer. |cb_priv| | 364 // Callback used by libvpx to request an external frame buffer. |cb_priv| |
| 365 // Application private data passed into the set function. |min_size| is the | 365 // Application private data passed into the set function. |min_size| is the |
| 366 // minimum size in bytes needed to decode the next frame. |fb| pointer to the | 366 // minimum size in bytes needed to decode the next frame. |fb| pointer to the |
| 367 // frame buffer. | 367 // frame buffer. |
| 368 int get_vp9_frame_buffer(void *cb_priv, size_t min_size, | 368 static int get_vp9_frame_buffer(void *cb_priv, size_t min_size, |
| 369 vpx_codec_frame_buffer_t *fb) { | 369 vpx_codec_frame_buffer_t *fb) { |
| 370 int i; | 370 int i; |
| 371 struct ExternalFrameBufferList *const ext_fb_list = | 371 struct ExternalFrameBufferList *const ext_fb_list = |
| 372 (struct ExternalFrameBufferList *)cb_priv; | 372 (struct ExternalFrameBufferList *)cb_priv; |
| 373 if (ext_fb_list == NULL) | 373 if (ext_fb_list == NULL) |
| 374 return -1; | 374 return -1; |
| 375 | 375 |
| 376 // Find a free frame buffer. | 376 // Find a free frame buffer. |
| 377 for (i = 0; i < ext_fb_list->num_external_frame_buffers; ++i) { | 377 for (i = 0; i < ext_fb_list->num_external_frame_buffers; ++i) { |
| 378 if (!ext_fb_list->ext_fb[i].in_use) | 378 if (!ext_fb_list->ext_fb[i].in_use) |
| 379 break; | 379 break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 396 ext_fb_list->ext_fb[i].in_use = 1; | 396 ext_fb_list->ext_fb[i].in_use = 1; |
| 397 | 397 |
| 398 // Set the frame buffer's private data to point at the external frame buffer. | 398 // Set the frame buffer's private data to point at the external frame buffer. |
| 399 fb->priv = &ext_fb_list->ext_fb[i]; | 399 fb->priv = &ext_fb_list->ext_fb[i]; |
| 400 return 0; | 400 return 0; |
| 401 } | 401 } |
| 402 | 402 |
| 403 // Callback used by libvpx when there are no references to the frame buffer. | 403 // Callback used by libvpx when there are no references to the frame buffer. |
| 404 // |cb_priv| user private data passed into the set function. |fb| pointer | 404 // |cb_priv| user private data passed into the set function. |fb| pointer |
| 405 // to the frame buffer. | 405 // to the frame buffer. |
| 406 int release_vp9_frame_buffer(void *cb_priv, | 406 static int release_vp9_frame_buffer(void *cb_priv, |
| 407 vpx_codec_frame_buffer_t *fb) { | 407 vpx_codec_frame_buffer_t *fb) { |
| 408 struct ExternalFrameBuffer *const ext_fb = | 408 struct ExternalFrameBuffer *const ext_fb = |
| 409 (struct ExternalFrameBuffer *)fb->priv; | 409 (struct ExternalFrameBuffer *)fb->priv; |
| 410 (void)cb_priv; | 410 (void)cb_priv; |
| 411 ext_fb->in_use = 0; | 411 ext_fb->in_use = 0; |
| 412 return 0; | 412 return 0; |
| 413 } | 413 } |
| 414 | 414 |
| 415 void generate_filename(const char *pattern, char *out, size_t q_len, | 415 static void generate_filename(const char *pattern, char *out, size_t q_len, |
| 416 unsigned int d_w, unsigned int d_h, | 416 unsigned int d_w, unsigned int d_h, |
| 417 unsigned int frame_in) { | 417 unsigned int frame_in) { |
| 418 const char *p = pattern; | 418 const char *p = pattern; |
| 419 char *q = out; | 419 char *q = out; |
| 420 | 420 |
| 421 do { | 421 do { |
| 422 char *next_pat = strchr(p, '%'); | 422 char *next_pat = strchr(p, '%'); |
| 423 | 423 |
| 424 if (p == next_pat) { | 424 if (p == next_pat) { |
| 425 size_t pat_len; | 425 size_t pat_len; |
| 426 | 426 |
| 427 /* parse the pattern */ | 427 /* parse the pattern */ |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 529 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
| 530 static int img_shifted_realloc_required(const vpx_image_t *img, | 530 static int img_shifted_realloc_required(const vpx_image_t *img, |
| 531 const vpx_image_t *shifted, | 531 const vpx_image_t *shifted, |
| 532 vpx_img_fmt_t required_fmt) { | 532 vpx_img_fmt_t required_fmt) { |
| 533 return img->d_w != shifted->d_w || | 533 return img->d_w != shifted->d_w || |
| 534 img->d_h != shifted->d_h || | 534 img->d_h != shifted->d_h || |
| 535 required_fmt != shifted->fmt; | 535 required_fmt != shifted->fmt; |
| 536 } | 536 } |
| 537 #endif | 537 #endif |
| 538 | 538 |
| 539 int main_loop(int argc, const char **argv_) { | 539 static int main_loop(int argc, const char **argv_) { |
| 540 vpx_codec_ctx_t decoder; | 540 vpx_codec_ctx_t decoder; |
| 541 char *fn = NULL; | 541 char *fn = NULL; |
| 542 int i; | 542 int i; |
| 543 uint8_t *buf = NULL; | 543 uint8_t *buf = NULL; |
| 544 size_t bytes_in_buffer = 0, buffer_size = 0; | 544 size_t bytes_in_buffer = 0, buffer_size = 0; |
| 545 FILE *infile; | 545 FILE *infile; |
| 546 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; | 546 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; |
| 547 int do_md5 = 0, progress = 0, frame_parallel = 0; | 547 int do_md5 = 0, progress = 0, frame_parallel = 0; |
| 548 int stop_after = 0, postproc = 0, summary = 0, quiet = 1; | 548 int stop_after = 0, postproc = 0, summary = 0, quiet = 1; |
| 549 int arg_skip = 0; | 549 int arg_skip = 0; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 if (arg_match(&arg, &looparg, argi)) { | 1145 if (arg_match(&arg, &looparg, argi)) { |
| 1146 loops = arg_parse_uint(&arg); | 1146 loops = arg_parse_uint(&arg); |
| 1147 break; | 1147 break; |
| 1148 } | 1148 } |
| 1149 } | 1149 } |
| 1150 free(argv); | 1150 free(argv); |
| 1151 for (i = 0; !error && i < loops; i++) | 1151 for (i = 0; !error && i < loops; i++) |
| 1152 error = main_loop(argc, argv_); | 1152 error = main_loop(argc, argv_); |
| 1153 return error; | 1153 return error; |
| 1154 } | 1154 } |
| OLD | NEW |