diff options
author | hkuang <hkuang@google.com> | 2013-11-14 22:50:46 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-11-14 22:50:46 -0800 |
commit | aa43d6ba5f5fb7eaeca1d0573ecb16ea4d388197 (patch) | |
tree | 6ff3bfc5090953c49fa26fac842b924d88e0983d /libvpx/vpxenc.c | |
parent | a1b7a7bb1ccf3f479bbca69a52a76eb05789dbaf (diff) | |
parent | 9b35249446b07f40ac5fcc3205f2c048616efacc (diff) | |
download | android_external_libvpx-aa43d6ba5f5fb7eaeca1d0573ecb16ea4d388197.tar.gz android_external_libvpx-aa43d6ba5f5fb7eaeca1d0573ecb16ea4d388197.tar.bz2 android_external_libvpx-aa43d6ba5f5fb7eaeca1d0573ecb16ea4d388197.zip |
am 9b352494: Roll latest libvpx to fix scalling bug. Checkout is from master:Ib748eb287520c794631697204da6ebe19523ce95
* commit '9b35249446b07f40ac5fcc3205f2c048616efacc':
Roll latest libvpx to fix scalling bug. Checkout is from master:Ib748eb287520c794631697204da6ebe19523ce95
Diffstat (limited to 'libvpx/vpxenc.c')
-rw-r--r-- | libvpx/vpxenc.c | 186 |
1 files changed, 8 insertions, 178 deletions
diff --git a/libvpx/vpxenc.c b/libvpx/vpxenc.c index df75b85..b7897db 100644 --- a/libvpx/vpxenc.c +++ b/libvpx/vpxenc.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vpx_config.h" +#include "./vpx_config.h" #if defined(_WIN32) || defined(__OS2__) || !CONFIG_OS_SUPPORT #define USE_POSIX_MMAP 0 @@ -16,6 +16,7 @@ #define USE_POSIX_MMAP 1 #endif +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -43,36 +44,12 @@ #include "vpx/vp8dx.h" #endif +#include "./tools_common.h" #include "vpx_ports/mem_ops.h" #include "vpx_ports/vpx_timer.h" -#include "tools_common.h" -#include "webmenc.h" -#include "y4minput.h" - - -/* Need special handling of these functions on Windows */ -#if defined(_MSC_VER) -/* MSVS doesn't define off_t, and uses _f{seek,tell}i64 */ -typedef __int64 off_t; -#define fseeko _fseeki64 -#define ftello _ftelli64 -#elif defined(_WIN32) -/* MinGW defines off_t as long - and uses f{seek,tell}o64/off64_t for large files */ -#define fseeko fseeko64 -#define ftello ftello64 -#define off_t off64_t -#endif - -#define LITERALU64(hi,lo) ((((uint64_t)hi)<<32)|lo) - -/* We should use 32-bit file operations in WebM file format - * when building ARM executable file (.axf) with RVCT */ -#if !CONFIG_OS_SUPPORT -typedef long off_t; -#define fseeko fseek -#define ftello ftell -#endif +#include "./vpxstats.h" +#include "./webmenc.h" +#include "./y4minput.h" /* Swallow warnings about unused results of fread/fwrite */ static size_t wrap_fread(void *ptr, size_t size, size_t nmemb, @@ -141,126 +118,6 @@ static void warn_or_exit_on_error(vpx_codec_ctx_t *ctx, int fatal, va_end(ap); } -/* This structure is used to abstract the different ways of handling - * first pass statistics. - */ -typedef struct { - vpx_fixed_buf_t buf; - int pass; - FILE *file; - char *buf_ptr; - size_t buf_alloc_sz; -} stats_io_t; - -int stats_open_file(stats_io_t *stats, const char *fpf, int pass) { - int res; - - stats->pass = pass; - - if (pass == 0) { - stats->file = fopen(fpf, "wb"); - stats->buf.sz = 0; - stats->buf.buf = NULL, - res = (stats->file != NULL); - } else { -#if 0 -#elif USE_POSIX_MMAP - struct stat stat_buf; - int fd; - - fd = open(fpf, O_RDONLY); - stats->file = fdopen(fd, "rb"); - fstat(fd, &stat_buf); - stats->buf.sz = stat_buf.st_size; - stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE, - fd, 0); - res = (stats->buf.buf != NULL); -#else - size_t nbytes; - - stats->file = fopen(fpf, "rb"); - - if (fseek(stats->file, 0, SEEK_END)) - fatal("First-pass stats file must be seekable!"); - - stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file); - rewind(stats->file); - - stats->buf.buf = malloc(stats->buf_alloc_sz); - - if (!stats->buf.buf) - fatal("Failed to allocate first-pass stats buffer (%lu bytes)", - (unsigned long)stats->buf_alloc_sz); - - nbytes = fread(stats->buf.buf, 1, stats->buf.sz, stats->file); - res = (nbytes == stats->buf.sz); -#endif - } - - return res; -} - -int stats_open_mem(stats_io_t *stats, int pass) { - int res; - stats->pass = pass; - - if (!pass) { - stats->buf.sz = 0; - stats->buf_alloc_sz = 64 * 1024; - stats->buf.buf = malloc(stats->buf_alloc_sz); - } - - stats->buf_ptr = stats->buf.buf; - res = (stats->buf.buf != NULL); - return res; -} - - -void stats_close(stats_io_t *stats, int last_pass) { - if (stats->file) { - if (stats->pass == last_pass) { -#if 0 -#elif USE_POSIX_MMAP - munmap(stats->buf.buf, stats->buf.sz); -#else - free(stats->buf.buf); -#endif - } - - fclose(stats->file); - stats->file = NULL; - } else { - if (stats->pass == last_pass) - free(stats->buf.buf); - } -} - -void stats_write(stats_io_t *stats, const void *pkt, size_t len) { - if (stats->file) { - (void) fwrite(pkt, 1, len, stats->file); - } else { - if (stats->buf.sz + len > stats->buf_alloc_sz) { - size_t new_sz = stats->buf_alloc_sz + 64 * 1024; - char *new_ptr = realloc(stats->buf.buf, new_sz); - - if (new_ptr) { - stats->buf_ptr = new_ptr + (stats->buf_ptr - (char *)stats->buf.buf); - stats->buf.buf = new_ptr; - stats->buf_alloc_sz = new_sz; - } else - fatal("Failed to realloc firstpass stats buffer."); - } - - memcpy(stats->buf_ptr, pkt, len); - stats->buf.sz += len; - stats->buf_ptr += len; - } -} - -vpx_fixed_buf_t stats_get(stats_io_t *stats) { - return stats->buf; -} - enum video_file_type { FILE_TYPE_RAW, FILE_TYPE_IVF, @@ -288,7 +145,6 @@ struct input_state { int only_i420; }; - #define IVF_FRAME_HDR_SZ (4+8) /* 4 byte size + 8 byte timestamp */ static int read_frame(struct input_state *input, vpx_image_t *img) { FILE *f = input->file; @@ -503,22 +359,6 @@ static unsigned int murmur(const void *key, int len, unsigned int seed) { return h; } -#include "math.h" -#define MAX_PSNR 100 -static double vp8_mse2psnr(double Samples, double Peak, double Mse) { - double psnr; - - if ((double)Mse > 0.0) - psnr = 10.0 * log10(Peak * Peak * Samples / Mse); - else - psnr = MAX_PSNR; /* Limit to prevent / 0 */ - - if (psnr > MAX_PSNR) - psnr = MAX_PSNR; - - return psnr; -} - #include "args.h" static const arg_def_t debugmode = ARG_DEF("D", "debug", 0, @@ -1409,17 +1249,7 @@ void open_input_file(struct input_state *input) { } else fatal("Unsupported Y4M stream."); } else if (input->detect.buf_read == 4 && file_is_ivf(input, &fourcc)) { - input->file_type = FILE_TYPE_IVF; - switch (fourcc) { - case 0x32315659: - input->use_i420 = 0; - break; - case 0x30323449: - input->use_i420 = 1; - break; - default: - fatal("Unsupported fourcc (%08x) in IVF", fourcc); - } + fatal("IVF is not supported as input."); } else { input->file_type = FILE_TYPE_RAW; } @@ -1433,7 +1263,7 @@ static void close_input_file(struct input_state *input) { } static struct stream_state *new_stream(struct global_config *global, - struct stream_state *prev) { + struct stream_state *prev) { struct stream_state *stream; stream = calloc(1, sizeof(*stream)); |