aa7335e610
The example encoder down-samples the input video frames a number of times with a down-sampling factor, and then encodes and outputs bitstreams with different resolutions. Support arbitrary down-sampling factor, and down-sampling factor can be different for each encoding level. For example, the encoder can be tested as follows. 1. Configure with multi-resolution encoding enabled: ../libvpx/configure --target=x86-linux-gcc --disable-codecs --enable-vp8 --enable-runtime_cpu_detect --enable-debug --disable-install-docs --enable-error-concealment --enable-multi-res-encoding 2. Run make 3. Encode: If input video is 1280x720, run: ./vp8_multi_resolution_encoder 1280 720 input.yuv 1.ivf 2.ivf 3.ivf 1 (output: 1.ivf(1280x720); 2.ivf(640x360); 3.ivf(320x180). The last parameter is set to 1/0 to show/not show PSNR.) 4. Decode: ./simple_decoder 1.ivf 1.yuv ./simple_decoder 2.ivf 2.yuv ./simple_decoder 3.ivf 3.yuv 5. View video: mplayer 1.yuv -demuxer rawvideo -rawvideo w=1280:h=720 -loop 0 -fps 30 mplayer 2.yuv -demuxer rawvideo -rawvideo w=640:h=360 -loop 0 -fps 30 mplayer 3.yuv -demuxer rawvideo -rawvideo w=320:h=180 -loop 0 -fps 30 The encoding parameters can be modified in vp8_multi_resolution_encoder.c, for example, target bitrate, frame rate... Modified API. John helped a lot with that. Thanks! Change-Id: I03be9a51167eddf94399f92d269599fb3f3d54f5
75 lines
2.0 KiB
C
75 lines
2.0 KiB
C
/*
|
|
* Copyright (c) 2011 The LibYuv project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "third_party/libyuv/include/libyuv/cpu_id.h"
|
|
#include "third_party/libyuv/include/libyuv/basic_types.h" // for CPU_X86
|
|
|
|
#ifdef _MSC_VER
|
|
#include <intrin.h>
|
|
#endif
|
|
|
|
// TODO(fbarchard): Use cpuid.h when gcc 4.4 is used on OSX and Linux.
|
|
#if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__)
|
|
static inline void __cpuid(int cpu_info[4], int info_type) {
|
|
__asm__ volatile (
|
|
"mov %%ebx, %%edi\n"
|
|
"cpuid\n"
|
|
"xchg %%edi, %%ebx\n"
|
|
: "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
|
|
: "a"(info_type)
|
|
);
|
|
}
|
|
#elif defined(__i386__) || defined(__x86_64__)
|
|
static inline void __cpuid(int cpu_info[4], int info_type) {
|
|
__asm__ volatile (
|
|
"cpuid\n"
|
|
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
|
|
: "a"(info_type)
|
|
);
|
|
}
|
|
#endif
|
|
|
|
//namespace libyuv {
|
|
|
|
// CPU detect function for SIMD instruction sets.
|
|
static int cpu_info_initialized_ = 0;
|
|
static int cpu_info_ = 0;
|
|
|
|
// Global lock for cpu initialization.
|
|
static void InitCpuFlags() {
|
|
#ifdef CPU_X86
|
|
int cpu_info[4];
|
|
__cpuid(cpu_info, 1);
|
|
cpu_info_ = (cpu_info[2] & 0x00000200 ? kCpuHasSSSE3 : 0) |
|
|
(cpu_info[3] & 0x04000000 ? kCpuHasSSE2 : 0);
|
|
#elif defined(__ARM_NEON__)
|
|
// gcc -mfpu=neon defines __ARM_NEON__
|
|
// if code is specifically built for Neon-only, enable the flag.
|
|
cpu_info_ |= kCpuHasNEON;
|
|
#else
|
|
cpu_info_ = 0;
|
|
#endif
|
|
cpu_info_initialized_ = 1;
|
|
}
|
|
|
|
void MaskCpuFlagsForTest(int enable_flags) {
|
|
InitCpuFlags();
|
|
cpu_info_ &= enable_flags;
|
|
}
|
|
|
|
int TestCpuFlag(int flag) {
|
|
if (!cpu_info_initialized_) {
|
|
InitCpuFlags();
|
|
}
|
|
return cpu_info_ & flag ? 1 : 0;
|
|
}
|
|
|
|
//} // namespace libyuv
|