Merge "clean up unused files"
This commit is contained in:
commit
c764c2a20f
@ -16,7 +16,6 @@
|
||||
#include "findnearmv.h"
|
||||
#include "entropymode.h"
|
||||
#include "systemdependent.h"
|
||||
#include "vpxerrors.h"
|
||||
|
||||
|
||||
extern void vp8_init_scan_order_mask();
|
||||
@ -71,7 +70,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
|
||||
if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0)
|
||||
{
|
||||
vp8_de_alloc_frame_buffers(oci);
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,13 +87,13 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
|
||||
if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, VP8BORDERINPIXELS) < 0)
|
||||
{
|
||||
vp8_de_alloc_frame_buffers(oci);
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0)
|
||||
{
|
||||
vp8_de_alloc_frame_buffers(oci);
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
oci->mb_rows = height >> 4;
|
||||
@ -106,7 +105,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
|
||||
if (!oci->mip)
|
||||
{
|
||||
vp8_de_alloc_frame_buffers(oci);
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
oci->mi = oci->mip + oci->mode_info_stride + 1;
|
||||
@ -117,7 +116,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
|
||||
if (!oci->above_context)
|
||||
{
|
||||
vp8_de_alloc_frame_buffers(oci);
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
vp8_update_mode_info_border(oci->mi, oci->mb_rows, oci->mb_cols);
|
||||
|
@ -1,570 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef bool_coder_h
|
||||
#define bool_coder_h 1
|
||||
|
||||
/* Arithmetic bool coder with largish probability range.
|
||||
Timothy S Murphy 6 August 2004 */
|
||||
|
||||
/* So as not to force users to drag in too much of my idiosyncratic C++ world,
|
||||
I avoid fancy storage management. */
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef unsigned char vp8bc_index_t; // probability index
|
||||
|
||||
/* There are a couple of slight variants in the details of finite-precision
|
||||
arithmetic coding. May be safely ignored by most users. */
|
||||
|
||||
enum vp8bc_rounding
|
||||
{
|
||||
vp8bc_down = 0, // just like VP8
|
||||
vp8bc_down_full = 1, // handles minimum probability correctly
|
||||
vp8bc_up = 2
|
||||
};
|
||||
|
||||
#if _MSC_VER
|
||||
|
||||
/* Note that msvc by default does not inline _anything_ (regardless of the
|
||||
setting of inline_depth) and that a command-line option (-Ob1 or -Ob2)
|
||||
is required to inline even the smallest functions. */
|
||||
|
||||
# pragma inline_depth( 255) // I mean it when I inline something
|
||||
# pragma warning( disable : 4099) // No class vs. struct harassment
|
||||
# pragma warning( disable : 4250) // dominance complaints
|
||||
# pragma warning( disable : 4284) // operator-> in templates
|
||||
# pragma warning( disable : 4800) // bool conversion
|
||||
|
||||
// don't let prefix ++,-- stand in for postfix, disaster would ensue
|
||||
|
||||
# pragma warning( error : 4620 4621)
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
|
||||
#if __cplusplus
|
||||
|
||||
// Sometimes one wishes to be definite about integer lengths.
|
||||
|
||||
struct int_types
|
||||
{
|
||||
typedef const bool cbool;
|
||||
typedef const signed char cchar;
|
||||
typedef const short cshort;
|
||||
typedef const int cint;
|
||||
typedef const int clong;
|
||||
|
||||
typedef const double cdouble;
|
||||
typedef const size_t csize_t;
|
||||
|
||||
typedef unsigned char uchar; // 8 bits
|
||||
typedef const uchar cuchar;
|
||||
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef const int16 cint16;
|
||||
typedef const uint16 cuint16;
|
||||
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef const int32 cint32;
|
||||
typedef const uint32 cuint32;
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned int ulong;
|
||||
typedef const uint cuint;
|
||||
typedef const ulong culong;
|
||||
|
||||
|
||||
// All structs consume space, may as well have a vptr.
|
||||
|
||||
virtual ~int_types();
|
||||
};
|
||||
|
||||
|
||||
struct bool_coder_spec;
|
||||
struct bool_coder;
|
||||
struct bool_writer;
|
||||
struct bool_reader;
|
||||
|
||||
|
||||
struct bool_coder_namespace : int_types
|
||||
{
|
||||
typedef vp8bc_index_t Index;
|
||||
typedef bool_coder_spec Spec;
|
||||
typedef const Spec c_spec;
|
||||
|
||||
enum Rounding
|
||||
{
|
||||
Down = vp8bc_down,
|
||||
down_full = vp8bc_down_full,
|
||||
Up = vp8bc_up
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Archivable specification of a bool coder includes rounding spec
|
||||
// and probability mapping table. The latter replaces a uchar j
|
||||
// (0 <= j < 256) with an arbitrary uint16 tbl[j] = p.
|
||||
// p/65536 is then the probability of a zero.
|
||||
|
||||
struct bool_coder_spec : bool_coder_namespace
|
||||
{
|
||||
friend struct bool_coder;
|
||||
friend struct bool_writer;
|
||||
friend struct bool_reader;
|
||||
friend struct bool_coder_spec_float;
|
||||
friend struct bool_coder_spec_explicit_table;
|
||||
friend struct bool_coder_spec_exponential_table;
|
||||
friend struct BPsrc;
|
||||
private:
|
||||
uint w; // precision
|
||||
Rounding r;
|
||||
|
||||
uint ebits, mbits, ebias;
|
||||
uint32 mmask;
|
||||
|
||||
Index max_index, half_index;
|
||||
|
||||
uint32 mantissa(Index i) const
|
||||
{
|
||||
assert(i < half_index);
|
||||
return (1 << mbits) + (i & mmask);
|
||||
}
|
||||
uint exponent(Index i) const
|
||||
{
|
||||
assert(i < half_index);
|
||||
return ebias - (i >> mbits);
|
||||
}
|
||||
|
||||
uint16 Ptbl[256]; // kinda clunky, but so is storage management.
|
||||
|
||||
/* Cost in bits of encoding a zero at every probability, scaled by 2^20.
|
||||
Assumes that index is at most 8 bits wide. */
|
||||
|
||||
uint32 Ctbl[256];
|
||||
|
||||
uint32 split(Index i, uint32 R) const // 1 <= split <= max( 1, R-1)
|
||||
{
|
||||
if (!ebias)
|
||||
return 1 + (((R - 1) * Ptbl[i]) >> 16);
|
||||
|
||||
if (i >= half_index)
|
||||
return R - split(max_index - i, R);
|
||||
|
||||
return 1 + (((R - 1) * mantissa(i)) >> exponent(i));
|
||||
}
|
||||
|
||||
uint32 max_range() const
|
||||
{
|
||||
return (1 << w) - (r == down_full ? 0 : 1);
|
||||
}
|
||||
uint32 min_range() const
|
||||
{
|
||||
return (1 << (w - 1)) + (r == down_full ? 1 : 0);
|
||||
}
|
||||
uint32 Rinc() const
|
||||
{
|
||||
return r == Up ? 1 : 0;
|
||||
}
|
||||
|
||||
void check_prec() const;
|
||||
|
||||
bool float_init(uint Ebits, uint Mbits);
|
||||
|
||||
void cost_init();
|
||||
|
||||
bool_coder_spec(
|
||||
uint prec, Rounding rr, uint Ebits = 0, uint Mbits = 0
|
||||
)
|
||||
: w(prec), r(rr)
|
||||
{
|
||||
float_init(Ebits, Mbits);
|
||||
}
|
||||
public:
|
||||
// Read complete spec from file.
|
||||
bool_coder_spec(FILE *);
|
||||
|
||||
// Write spec to file.
|
||||
void dump(FILE *) const;
|
||||
|
||||
// return probability index best approximating prob.
|
||||
Index operator()(double prob) const;
|
||||
|
||||
// probability corresponding to index
|
||||
double operator()(Index i) const;
|
||||
|
||||
Index complement(Index i) const
|
||||
{
|
||||
return max_index - i;
|
||||
}
|
||||
|
||||
Index max_index() const
|
||||
{
|
||||
return max_index;
|
||||
}
|
||||
Index half_index() const
|
||||
{
|
||||
return half_index;
|
||||
}
|
||||
|
||||
uint32 cost_zero(Index i) const
|
||||
{
|
||||
return Ctbl[i];
|
||||
}
|
||||
uint32 cost_one(Index i) const
|
||||
{
|
||||
return Ctbl[ max_index - i];
|
||||
}
|
||||
uint32 cost_bit(Index i, bool b) const
|
||||
{
|
||||
return Ctbl[b? max_index-i:i];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Pseudo floating-point probability specification.
|
||||
|
||||
At least one of Ebits and Mbits must be nonzero.
|
||||
|
||||
Since all arithmetic is done at 32 bits, Ebits is at most 5.
|
||||
|
||||
Total significant bits in index is Ebits + Mbits + 1.
|
||||
|
||||
Below the halfway point (i.e. when the top significant bit is 0),
|
||||
the index is (e << Mbits) + m.
|
||||
|
||||
The exponent e is between 0 and (2**Ebits) - 1,
|
||||
the mantissa m is between 0 and (2**Mbits) - 1.
|
||||
|
||||
Prepending an implicit 1 to the mantissa, the probability is then
|
||||
|
||||
(2**Mbits + m) >> (e - 2**Ebits - 1 - Mbits),
|
||||
|
||||
which has (1/2)**(2**Ebits + 1) as a minimum
|
||||
and (1/2) * [1 - 2**(Mbits + 1)] as a maximum.
|
||||
|
||||
When the index is above the halfway point, the probability is the
|
||||
complement of the probability associated to the complement of the index.
|
||||
|
||||
Note that the probability increases with the index and that, because of
|
||||
the symmetry, we cannot encode probability exactly 1/2; though we
|
||||
can get as close to 1/2 as we like, provided we have enough Mbits.
|
||||
|
||||
The latter is of course not a problem in practice, one never has
|
||||
exact probabilities and entropy errors are second order, that is, the
|
||||
"overcoding" of a zero will be largely compensated for by the
|
||||
"undercoding" of a one (or vice-versa).
|
||||
|
||||
Compared to arithmetic probability specs (a la VP8), this will do better
|
||||
at very high and low probabilities and worse at probabilities near 1/2,
|
||||
as well as facilitating the usage of wider or narrower probability indices.
|
||||
*/
|
||||
|
||||
struct bool_coder_spec_float : bool_coder_spec
|
||||
{
|
||||
bool_coder_spec_float(
|
||||
uint Ebits = 3, uint Mbits = 4, Rounding rr = down_full, uint prec = 12
|
||||
)
|
||||
: bool_coder_spec(prec, rr, Ebits, Mbits)
|
||||
{
|
||||
cost_init();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct bool_coder_spec_explicit_table : bool_coder_spec
|
||||
{
|
||||
bool_coder_spec_explicit_table(
|
||||
cuint16 probability_table[256] = 0, // default is tbl[i] = i << 8.
|
||||
Rounding = down_full,
|
||||
uint precision = 16
|
||||
);
|
||||
};
|
||||
|
||||
// Contruct table via multiplicative interpolation between
|
||||
// p[128] = 1/2 and p[0] = (1/2)^x.
|
||||
// Since we are working with 16-bit precision, x is at most 16.
|
||||
// For probabilities to increase with i, we must have x > 1.
|
||||
// For 0 <= i <= 128, p[i] = (1/2)^{ 1 + [1 - (i/128)]*[x-1] }.
|
||||
// Finally, p[128+i] = 1 - p[128 - i].
|
||||
|
||||
struct bool_coder_spec_exponential_table : bool_coder_spec
|
||||
{
|
||||
bool_coder_spec_exponential_table(uint x, Rounding = down_full, uint prec = 16);
|
||||
};
|
||||
|
||||
|
||||
// Commonalities between writer and reader.
|
||||
|
||||
struct bool_coder : bool_coder_namespace
|
||||
{
|
||||
friend struct bool_writer;
|
||||
friend struct bool_reader;
|
||||
friend struct BPsrc;
|
||||
private:
|
||||
uint32 Low, Range;
|
||||
cuint32 min_range;
|
||||
cuint32 rinc;
|
||||
c_spec spec;
|
||||
|
||||
void _reset()
|
||||
{
|
||||
Low = 0;
|
||||
Range = spec.max_range();
|
||||
}
|
||||
|
||||
bool_coder(c_spec &s)
|
||||
: min_range(s.min_range()),
|
||||
rinc(s.Rinc()),
|
||||
spec(s)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
||||
uint32 half() const
|
||||
{
|
||||
return 1 + ((Range - 1) >> 1);
|
||||
}
|
||||
public:
|
||||
c_spec &Spec() const
|
||||
{
|
||||
return spec;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct bool_writer : bool_coder
|
||||
{
|
||||
friend struct BPsrc;
|
||||
private:
|
||||
uchar *Bstart, *Bend, *B;
|
||||
int bit_lag;
|
||||
bool is_toast;
|
||||
void carry();
|
||||
void reset()
|
||||
{
|
||||
_reset();
|
||||
bit_lag = 32 - spec.w;
|
||||
is_toast = 0;
|
||||
}
|
||||
void raw(bool value, uint32 split);
|
||||
public:
|
||||
bool_writer(c_spec &, uchar *Dest, size_t Len);
|
||||
virtual ~bool_writer();
|
||||
|
||||
void operator()(Index p, bool v)
|
||||
{
|
||||
raw(v, spec.split(p, Range));
|
||||
}
|
||||
|
||||
uchar *buf() const
|
||||
{
|
||||
return Bstart;
|
||||
}
|
||||
size_t bytes_written() const
|
||||
{
|
||||
return B - Bstart;
|
||||
}
|
||||
|
||||
// Call when done with input, flushes internal state.
|
||||
// DO NOT write any more data after calling this.
|
||||
|
||||
bool_writer &flush();
|
||||
|
||||
void write_bits(int n, uint val)
|
||||
{
|
||||
if (n)
|
||||
{
|
||||
uint m = 1 << (n - 1);
|
||||
|
||||
do
|
||||
{
|
||||
raw((bool)(val & m), half());
|
||||
}
|
||||
while (m >>= 1);
|
||||
}
|
||||
}
|
||||
|
||||
# if 0
|
||||
// We are agnostic about storage management.
|
||||
// By default, overflows throw an assert but user can
|
||||
// override to provide an expanding buffer using ...
|
||||
|
||||
virtual void overflow(uint Len) const;
|
||||
|
||||
// ... this function copies already-written data into new buffer
|
||||
// and retains new buffer location.
|
||||
|
||||
void new_buffer(uchar *dest, uint Len);
|
||||
|
||||
// Note that storage management is the user's responsibility.
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
// This could be adjusted to use a little less lookahead.
|
||||
|
||||
struct bool_reader : bool_coder
|
||||
{
|
||||
friend struct BPsrc;
|
||||
private:
|
||||
cuchar *const Bstart; // for debugging
|
||||
cuchar *B;
|
||||
cuchar *const Bend;
|
||||
cuint shf;
|
||||
uint bct;
|
||||
bool raw(uint32 split);
|
||||
public:
|
||||
bool_reader(c_spec &s, cuchar *src, size_t Len);
|
||||
|
||||
bool operator()(Index p)
|
||||
{
|
||||
return raw(spec.split(p, Range));
|
||||
}
|
||||
|
||||
uint read_bits(int num_bits)
|
||||
{
|
||||
uint v = 0;
|
||||
|
||||
while (--num_bits >= 0)
|
||||
v += v + (raw(half()) ? 1 : 0);
|
||||
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* C interface */
|
||||
|
||||
typedef struct bool_coder_spec bool_coder_spec;
|
||||
typedef struct bool_writer bool_writer;
|
||||
typedef struct bool_reader bool_reader;
|
||||
|
||||
typedef const bool_coder_spec c_bool_coder_spec;
|
||||
typedef const bool_writer c_bool_writer;
|
||||
typedef const bool_reader c_bool_reader;
|
||||
|
||||
|
||||
/* Optionally override default precision when constructing coder_specs.
|
||||
Just pass a zero pointer if you don't care.
|
||||
Precision is at most 16 bits for table specs, at most 23 otherwise. */
|
||||
|
||||
struct vp8bc_prec
|
||||
{
|
||||
enum vp8bc_rounding r; /* see top header file for def */
|
||||
unsigned int prec; /* range precision in bits */
|
||||
};
|
||||
|
||||
typedef const struct vp8bc_prec vp8bc_c_prec;
|
||||
|
||||
/* bool_coder_spec contains mapping of uchars to actual probabilities
|
||||
(16 bit uints) as well as (usually immaterial) selection of
|
||||
exact finite-precision algorithm used (for now, the latter can only
|
||||
be overridden using the C++ interface).
|
||||
See comments above the corresponding C++ constructors for discussion,
|
||||
especially of exponential probability table generation. */
|
||||
|
||||
bool_coder_spec *vp8bc_vp8spec(); // just like vp8
|
||||
|
||||
bool_coder_spec *vp8bc_literal_spec(
|
||||
const unsigned short prob_map[256], // 0 is like vp8 w/more precision
|
||||
vp8bc_c_prec*
|
||||
);
|
||||
|
||||
bool_coder_spec *vp8bc_float_spec(
|
||||
unsigned int exponent_bits, unsigned int mantissa_bits, vp8bc_c_prec*
|
||||
);
|
||||
|
||||
bool_coder_spec *vp8bc_exponential_spec(unsigned int min_exp, vp8bc_c_prec *);
|
||||
|
||||
bool_coder_spec *vp8bc_spec_from_file(FILE *);
|
||||
|
||||
|
||||
void vp8bc_destroy_spec(c_bool_coder_spec *);
|
||||
|
||||
void vp8bc_spec_to_file(c_bool_coder_spec *, FILE *);
|
||||
|
||||
|
||||
/* Nearest index to supplied probability of zero, 0 <= prob <= 1. */
|
||||
|
||||
vp8bc_index_t vp8bc_index(c_bool_coder_spec *, double prob);
|
||||
|
||||
vp8bc_index_t vp8bc_index_from_counts(
|
||||
c_bool_coder_spec *p, unsigned int zero_ct, unsigned int one_ct
|
||||
);
|
||||
|
||||
/* In case you want to look */
|
||||
|
||||
double vp8bc_probability(c_bool_coder_spec *, vp8bc_index_t);
|
||||
|
||||
/* Opposite index */
|
||||
|
||||
vp8bc_index_t vp8bc_complement(c_bool_coder_spec *, vp8bc_index_t);
|
||||
|
||||
/* Cost in bits of encoding a zero at given probability, scaled by 2^20.
|
||||
(assumes that an int holds at least 32 bits). */
|
||||
|
||||
unsigned int vp8bc_cost_zero(c_bool_coder_spec *, vp8bc_index_t);
|
||||
|
||||
unsigned int vp8bc_cost_one(c_bool_coder_spec *, vp8bc_index_t);
|
||||
unsigned int vp8bc_cost_bit(c_bool_coder_spec *, vp8bc_index_t, int);
|
||||
|
||||
|
||||
/* bool_writer interface */
|
||||
|
||||
/* Length = 0 disables checking for writes beyond buffer end. */
|
||||
|
||||
bool_writer *vp8bc_create_writer(
|
||||
c_bool_coder_spec *, unsigned char *Destination, size_t Length
|
||||
);
|
||||
|
||||
/* Flushes out any buffered data and returns total # of bytes written. */
|
||||
|
||||
size_t vp8bc_destroy_writer(bool_writer *);
|
||||
|
||||
void vp8bc_write_bool(bool_writer *, int boolean_val, vp8bc_index_t false_prob);
|
||||
|
||||
void vp8bc_write_bits(
|
||||
bool_writer *, unsigned int integer_value, int number_of_bits
|
||||
);
|
||||
|
||||
c_bool_coder_spec *vp8bc_writer_spec(c_bool_writer *);
|
||||
|
||||
|
||||
/* bool_reader interface */
|
||||
|
||||
/* Length = 0 disables checking for reads beyond buffer end. */
|
||||
|
||||
bool_reader *vp8bc_create_reader(
|
||||
c_bool_coder_spec *, const unsigned char *Source, size_t Length
|
||||
);
|
||||
void vp8bc_destroy_reader(bool_reader *);
|
||||
|
||||
int vp8bc_read_bool(bool_reader *, vp8bc_index_t false_prob);
|
||||
|
||||
unsigned int vp8bc_read_bits(bool_reader *, int number_of_bits);
|
||||
|
||||
c_bool_coder_spec *vp8bc_reader_spec(c_bool_reader *);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* bool_coder_h */
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
#ifndef CODEC_COMMON_INTERFACE_H
|
||||
#define CODEC_COMMON_INTERFACE_H
|
||||
|
||||
#define __export
|
||||
#define _export
|
||||
#define dll_export __declspec( dllexport )
|
||||
#define dll_import __declspec( dllimport )
|
||||
|
||||
// Playback ERROR Codes.
|
||||
#define NO_DECODER_ERROR 0
|
||||
#define REMOTE_DECODER_ERROR -1
|
||||
|
||||
#define DFR_BAD_DCT_COEFF -100
|
||||
#define DFR_ZERO_LENGTH_FRAME -101
|
||||
#define DFR_FRAME_SIZE_INVALID -102
|
||||
#define DFR_OUTPUT_BUFFER_OVERFLOW -103
|
||||
#define DFR_INVALID_FRAME_HEADER -104
|
||||
#define FR_INVALID_MODE_TOKEN -110
|
||||
#define ETR_ALLOCATION_ERROR -200
|
||||
#define ETR_INVALID_ROOT_PTR -201
|
||||
#define SYNCH_ERROR -400
|
||||
#define BUFFER_UNDERFLOW_ERROR -500
|
||||
#define PB_IB_OVERFLOW_ERROR -501
|
||||
|
||||
// External error triggers
|
||||
#define PB_HEADER_CHECKSUM_ERROR -601
|
||||
#define PB_DATA_CHECKSUM_ERROR -602
|
||||
|
||||
// DCT Error Codes
|
||||
#define DDCT_EXPANSION_ERROR -700
|
||||
#define DDCT_INVALID_TOKEN_ERROR -701
|
||||
|
||||
// exception_errors
|
||||
#define GEN_EXCEPTIONS -800
|
||||
#define EX_UNQUAL_ERROR -801
|
||||
|
||||
// Unrecoverable error codes
|
||||
#define FATAL_PLAYBACK_ERROR -1000
|
||||
#define GEN_ERROR_CREATING_CDC -1001
|
||||
#define GEN_THREAD_CREATION_ERROR -1002
|
||||
#define DFR_CREATE_BMP_FAILED -1003
|
||||
|
||||
// YUV buffer configuration structure
|
||||
typedef struct
|
||||
{
|
||||
int y_width;
|
||||
int y_height;
|
||||
int y_stride;
|
||||
|
||||
int uv_width;
|
||||
int uv_height;
|
||||
int uv_stride;
|
||||
|
||||
unsigned char *y_buffer;
|
||||
unsigned char *u_buffer;
|
||||
unsigned char *v_buffer;
|
||||
|
||||
} YUV_BUFFER_CONFIG;
|
||||
typedef enum
|
||||
{
|
||||
C_SET_KEY_FRAME,
|
||||
C_SET_FIXED_Q,
|
||||
C_SET_FIRSTPASS_FILE,
|
||||
C_SET_EXPERIMENTAL_MIN,
|
||||
C_SET_EXPERIMENTAL_MAX = C_SET_EXPERIMENTAL_MIN + 255,
|
||||
C_SET_CHECKPROTECT,
|
||||
C_SET_TESTMODE,
|
||||
C_SET_INTERNAL_SIZE,
|
||||
C_SET_RECOVERY_FRAME,
|
||||
C_SET_REFERENCEFRAME,
|
||||
C_SET_GOLDENFRAME
|
||||
|
||||
#ifndef VP50_COMP_INTERFACE
|
||||
// Specialist test facilities.
|
||||
// C_VCAP_PARAMS, // DO NOT USE FOR NOW WITH VFW CODEC
|
||||
#endif
|
||||
|
||||
} C_SETTING;
|
||||
|
||||
typedef unsigned long C_SET_VALUE;
|
||||
|
||||
|
||||
#endif
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FOURCC_HPP
|
||||
#define FOURCC_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#if defined(__POWERPC__) || defined(__APPLE__) || defined(__MERKS__)
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
class four_cc
|
||||
{
|
||||
public:
|
||||
|
||||
four_cc();
|
||||
four_cc(const char*);
|
||||
explicit four_cc(unsigned long);
|
||||
|
||||
bool operator==(const four_cc&) const;
|
||||
bool operator!=(const four_cc&) const;
|
||||
|
||||
bool operator==(const char*) const;
|
||||
bool operator!=(const char*) const;
|
||||
|
||||
operator unsigned long() const;
|
||||
unsigned long as_long() const;
|
||||
|
||||
four_cc& operator=(unsigned long);
|
||||
|
||||
char operator[](int) const;
|
||||
|
||||
std::ostream& put(std::ostream&) const;
|
||||
|
||||
bool printable() const;
|
||||
|
||||
private:
|
||||
|
||||
union
|
||||
{
|
||||
char code[4];
|
||||
unsigned long code_as_long;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline four_cc::four_cc()
|
||||
{
|
||||
}
|
||||
|
||||
inline four_cc::four_cc(unsigned long x)
|
||||
: code_as_long(x)
|
||||
{
|
||||
}
|
||||
|
||||
inline four_cc::four_cc(const char* str)
|
||||
{
|
||||
memcpy(code, str, 4);
|
||||
}
|
||||
|
||||
|
||||
inline bool four_cc::operator==(const four_cc& rhs) const
|
||||
{
|
||||
return code_as_long == rhs.code_as_long;
|
||||
}
|
||||
|
||||
inline bool four_cc::operator!=(const four_cc& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
inline bool four_cc::operator==(const char* rhs) const
|
||||
{
|
||||
return (memcmp(code, rhs, 4) == 0);
|
||||
}
|
||||
|
||||
inline bool four_cc::operator!=(const char* rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
inline four_cc::operator unsigned long() const
|
||||
{
|
||||
return code_as_long;
|
||||
}
|
||||
|
||||
inline unsigned long four_cc::as_long() const
|
||||
{
|
||||
return code_as_long;
|
||||
}
|
||||
|
||||
inline char four_cc::operator[](int i) const
|
||||
{
|
||||
return code[i];
|
||||
}
|
||||
|
||||
inline four_cc& four_cc::operator=(unsigned long val)
|
||||
{
|
||||
code_as_long = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const four_cc& rhs)
|
||||
{
|
||||
return rhs.put(os);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(_mac_specs_h)
|
||||
#define _mac_specs_h
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned int vp8_read_tsc();
|
||||
|
||||
extern unsigned int vp8_get_processor_freq();
|
||||
|
||||
extern unsigned int vpx_has_altivec();
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __INC_PARTIALGFUPDATE_H
|
||||
#define __INC_PARTIALGFUPDATE_H
|
||||
|
||||
#include "onyxc_int.h"
|
||||
|
||||
extern void update_gf_selective(ONYX_COMMON *cm, MACROBLOCKD *x);
|
||||
|
||||
#endif
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
typedef struct core_codec *codec_ptr;
|
||||
typedef struct interface_table *interface_ptr;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Initialize)();
|
||||
void (*Shutdown)();
|
||||
codec_ptr(*Create)();
|
||||
int (*compress_frame)(codec_ptr, unsigned int *frame_flags, YV12_BUFFER_CONFIG *sd, unsigned long *size, char *dest, INT64 time_stamp);
|
||||
int (*show_frame)(codec_ptr , YV12_BUFFER_CONFIG *dest, int deblock_level, int noise_level, int flags);
|
||||
void (*Remove)(codec_ptr *comp);
|
||||
interface_ptr(*get_interface)(unsigned int id);
|
||||
|
||||
} core_codec;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int (*set_bitrate)(codec_ptr, END_USAGE usage, int Datarate);
|
||||
int (*get_bitrate)(codec_ptr, END_USAGE *usage, int *Datarate);
|
||||
int (*set_mode)(codec_ptr, MODE mode, int Speed, char *File);
|
||||
int (*get_mode)(codec_ptr, MODE *mode, int *Speed, char **File);
|
||||
} codec_settings_basic;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int (*set_bitrate)(codec_ptr, END_USAGE usage, int Datarate);
|
||||
int (*get_bitrate)(codec_ptr, END_USAGE *usage, int *Datarate);
|
||||
int (*set_mode)(codec_ptr, MODE mode, int Speed, char *File);
|
||||
int (*get_mode)(codec_ptr, MODE *mode, int *Speed, char **File);
|
||||
int (*set_denoise)(codec_ptr, int Level);
|
||||
int (*get_denoise)(codec_ptr, int *Level);
|
||||
int (*set_sharpness)(codec_ptr, int sharpness);
|
||||
int (*get_sharpness)(codec_ptr, int *sharpness);
|
||||
int (*set_keyframing)(codec_ptr, int Auto, int max_distance);
|
||||
int (*get_keyframing)(codec_ptr, int *Auto, int *max_distance);
|
||||
int (*set_buffering)(codec_ptr, int buffer_level, int max_buffer_level);
|
||||
int (*get_buffering)(codec_ptr, int *buffer_level, int *max_buffer_level);
|
||||
int (*set_adjust_frame_rate)(codec_ptr, int Allowed, int at_buffer_level_pct);
|
||||
int (*get_adjust_frame_rate)(codec_ptr, int *Allowed, int *at_buffer_level_pct);
|
||||
int (*set_adjust_frame_size)(codec_ptr, int Allowed, int down_at_buffer_level_pct, int up_at_buffer_level_pct);
|
||||
int (*get_adjust_frame_size)(codec_ptr, int *Allowed, int *down_at_buffer_level_pct, int *up_at_buffer_level_pct);
|
||||
int (*set_adjust_quality)(codec_ptr, int Allowed, int min_quantizer, int max_quantizer);
|
||||
int (*get_adjust_quality)(codec_ptr, int *Allowed, int *min_quantizer, int *max_quantizer);
|
||||
int (*set_vbrparms)(codec_ptr, int Bias, int Min, int Max);
|
||||
int (*get_vbrparms)(codec_ptr, int *Bias, int *Min, int *Max);
|
||||
|
||||
} codec_settings_v1;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int (*request_recovery)(codec_ptr);
|
||||
int (*request_droppable)(codec_ptr);
|
||||
int (*internal_size)(codec_ptr, VPX_SCALING Vertical, VPX_SCALING Horizontal);
|
||||
int (*update_last)(codec_ptr);
|
||||
int (*update_gold)(codec_ptr);
|
||||
int (*use_only_last)(codec_ptr);
|
||||
int (*use_only_gold)(codec_ptr);
|
||||
int (*update_entropy)(codec_ptr);
|
||||
|
||||
} codec_realtime_requests;
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(VFWSETTING_HPP)
|
||||
#define VFWSETTING_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// VFWSetting.hpp
|
||||
//
|
||||
|
||||
#include "four_cc.hpp"
|
||||
#include <iosfwd>
|
||||
|
||||
namespace vpxvp
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
class VFWSetting
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const VFWSetting& vfws);
|
||||
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
m_setting,
|
||||
m_config
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
header_size = 8,
|
||||
Size = 16
|
||||
};
|
||||
|
||||
VFWSetting(four_cc fcc);
|
||||
~VFWSetting();
|
||||
|
||||
four_cc fcc() const;
|
||||
Mode mode() const;
|
||||
|
||||
int setting() const;
|
||||
int value() const;
|
||||
void setting_value(int i_setting, int i_value); // Sets mode to m_setting
|
||||
|
||||
long size() const;
|
||||
const void* data() const;
|
||||
int data(const void* p_data, unsigned long ul_size);
|
||||
|
||||
private:
|
||||
|
||||
VFWSetting(const VFWSetting& vfws); // Not implemented
|
||||
VFWSetting& operator=(const VFWSetting& vfws); // Not implemented
|
||||
|
||||
int extract_(const void* p_data, unsigned long ul_size);
|
||||
void update_() const;
|
||||
|
||||
four_cc m_fcc;
|
||||
Mode m_mode;
|
||||
int m_i_setting;
|
||||
int m_i_value;
|
||||
|
||||
mutable unsigned char m_p_data[Size];
|
||||
};
|
||||
|
||||
} // namespace vpxvp
|
||||
|
||||
#endif // VFWSETTING_HPP
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VPX_REF_BUILD_PREFIX_h
|
||||
#define _VPX_REF_BUILD_PREFIX_h
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* include guards */
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VPXBLIT_H_INCL
|
||||
#define VPXBLIT_H_INCL
|
||||
/*==============================================================================
|
||||
Includes
|
||||
==============================================================================*/
|
||||
|
||||
/*==============================================================================
|
||||
Defines
|
||||
==============================================================================*/
|
||||
|
||||
|
||||
#ifdef VPX_BIG_ENDIAN
|
||||
#define BYTE_ZERO(X) ((X & 0xFF000000) >> (24 - 2) )
|
||||
#define BYTE_ONE(X) ((X & 0x00FF0000) >> (16 - 2) )
|
||||
#define BYTE_TWO(X) ((X & 0x0000FF00) >> (8 - 2) )
|
||||
#define BYTE_THREE(X) ((X & 0x000000FF) << (0 + 2) )
|
||||
|
||||
#define BYTE_ZERO_UV(X) ((X & 0x0000FF00) >> (8 - 2) )
|
||||
#define BYTE_ONE_UV(X) ((X & 0x000000FF) << (0 + 2) )
|
||||
|
||||
#define REREFERENCE(X) (*((int *) &(X)))
|
||||
|
||||
#else
|
||||
|
||||
#define BYTE_THREE(X) ((X & 0xFF000000) >> (24 - 2) )
|
||||
#define BYTE_TWO(X) ((X & 0x00FF0000) >> (16 - 2) )
|
||||
#define BYTE_ONE(X) ((X & 0x0000FF00) >> (8 - 2) )
|
||||
#define BYTE_ZERO(X) ((X & 0x000000FF) << (0 + 2) )
|
||||
|
||||
#define BYTE_ONE_UV(X) ((X & 0x0000FF00) >> (8 - 2) )
|
||||
#define BYTE_ZERO_UV(X) ((X & 0x000000FF) << (0 + 2) )
|
||||
|
||||
#define REREFERENCE(X) (*((int *) &(X)))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
Type Definitions
|
||||
==============================================================================*/
|
||||
typedef struct // YUV buffer configuration structure
|
||||
{
|
||||
int y_width;
|
||||
int y_height;
|
||||
int y_stride;
|
||||
|
||||
int uv_width;
|
||||
int uv_height;
|
||||
int uv_stride;
|
||||
|
||||
char *y_buffer;
|
||||
char *u_buffer;
|
||||
char *v_buffer;
|
||||
|
||||
char *uv_start;
|
||||
int uv_dst_area;
|
||||
int uv_used_area;
|
||||
|
||||
} VPX_BLIT_CONFIG;
|
||||
|
||||
typedef struct tx86_params
|
||||
{
|
||||
unsigned int pushed_registers[6];
|
||||
unsigned int return_address;
|
||||
unsigned int dst;
|
||||
unsigned int scrn_pitch;
|
||||
VPX_BLIT_CONFIG *buff_config;
|
||||
} x86_params;
|
||||
|
||||
/*=============================================================================
|
||||
Enums
|
||||
==============================================================================*/
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
Structures
|
||||
==============================================================================*/
|
||||
|
||||
/*==============================================================================
|
||||
Constants
|
||||
==============================================================================*/
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
Variables
|
||||
==============================================================================*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
Function Protoypes/MICROS
|
||||
==============================================================================*/
|
||||
int vpx_get_size_of_pixel(unsigned int bd);
|
||||
void *vpx_get_blitter(unsigned int bd);
|
||||
void vpx_set_blit(void);
|
||||
void vpx_destroy_blit(void);
|
||||
|
||||
|
||||
|
||||
#endif //VPXBLIT_H_INCL
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VPX_BLIT_C64_h
|
||||
#define _VPX_BLIT_C64_h
|
||||
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct // YUV buffer configuration structure
|
||||
{
|
||||
int y_width;
|
||||
int y_height;
|
||||
int y_stride;
|
||||
|
||||
int uv_width;
|
||||
int uv_height;
|
||||
int uv_stride;
|
||||
|
||||
unsigned char *y_buffer;
|
||||
unsigned char *u_buffer;
|
||||
unsigned char *v_buffer;
|
||||
|
||||
unsigned char *y_ptr_scrn;
|
||||
unsigned char *u_ptr_scrn;
|
||||
unsigned char *v_ptr_scrn;
|
||||
|
||||
} DXV_YUV_BUFFER_CONFIG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *rgbptr_scrn;
|
||||
unsigned char *y_ptr_scrn;
|
||||
unsigned char *u_ptr_scrn;
|
||||
unsigned char *v_ptr_scrn;
|
||||
unsigned char *rgbptr_scrn2;
|
||||
} DXV_FINAL_VIDEO;
|
||||
|
||||
#endif /* include guards */
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define ALLOC_FAILURE -2
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,6 @@
|
||||
#include "vp8/common/swapyv12buffer.h"
|
||||
#include "vp8/common/threading.h"
|
||||
#include "vpx_ports/vpx_timer.h"
|
||||
#include "vp8/common/vpxerrors.h"
|
||||
#include "temporal_filter.h"
|
||||
#if ARCH_ARM
|
||||
#include "vpx_ports/arm.h"
|
||||
@ -1305,7 +1304,7 @@ static int vp8_alloc_partition_data(VP8_COMP *cpi)
|
||||
(cpi->common.mb_rows + 1),
|
||||
sizeof(PARTITION_INFO));
|
||||
if(!cpi->mb.pip)
|
||||
return ALLOC_FAILURE;
|
||||
return 1;
|
||||
|
||||
cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "vp8/common/swapyv12buffer.h"
|
||||
#include "vp8/common/threading.h"
|
||||
#include "vpx_ports/vpx_timer.h"
|
||||
#include "vp8/common/vpxerrors.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
@ -11,7 +11,6 @@
|
||||
VP8_COMMON_SRCS-yes += vp8_common.mk
|
||||
VP8_COMMON_SRCS-yes += common/type_aliases.h
|
||||
VP8_COMMON_SRCS-yes += common/pragmas.h
|
||||
VP8_COMMON_SRCS-yes += common/vpxerrors.h
|
||||
VP8_COMMON_SRCS-yes += common/ppflags.h
|
||||
VP8_COMMON_SRCS-yes += common/onyx.h
|
||||
VP8_COMMON_SRCS-yes += common/onyxd.h
|
||||
|
@ -1,951 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#define __VPX_MEM_C__
|
||||
|
||||
#include "vpx_mem.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef CONFIG_MEM_MANAGER
|
||||
# if defined(VXWORKS)
|
||||
# define CONFIG_MEM_MANAGER 1 //include heap manager functionality,
|
||||
//default: enabled on vxworks
|
||||
# else
|
||||
# define CONFIG_MEM_MANAGER 0 //include heap manager functionality
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MEM_TRACKER
|
||||
# define CONFIG_MEM_TRACKER 1 //include xvpx_* calls in the lib
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MEM_CHECKS
|
||||
# define CONFIG_MEM_CHECKS 0 //include some basic safety checks in
|
||||
//vpx_memcpy, _memset, and _memmove
|
||||
#endif
|
||||
|
||||
#ifndef USE_GLOBAL_FUNCTION_POINTERS
|
||||
# define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions.
|
||||
#endif
|
||||
|
||||
#if CONFIG_MEM_TRACKER
|
||||
# include "vpx_mem_tracker.h"
|
||||
# if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5
|
||||
# error "vpx_mem requires memory tracker version 2.5 to track memory usage"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define ADDRESS_STORAGE_SIZE sizeof(size_t)
|
||||
|
||||
#ifndef DEFAULT_ALIGNMENT
|
||||
# if defined(VXWORKS)
|
||||
# define DEFAULT_ALIGNMENT 32 //default addr alignment to use in
|
||||
//calls to vpx_* functions other
|
||||
//than vpx_memalign
|
||||
# else
|
||||
# define DEFAULT_ALIGNMENT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if DEFAULT_ALIGNMENT < 1
|
||||
# error "DEFAULT_ALIGNMENT must be >= 1!"
|
||||
#endif
|
||||
|
||||
#if CONFIG_MEM_TRACKER
|
||||
# define TRY_BOUNDS_CHECK 1 //when set to 1 pads each allocation,
|
||||
//integrity can be checked using
|
||||
//vpx_memory_tracker_check_integrity
|
||||
//or on free by defining
|
||||
//TRY_BOUNDS_CHECK_ON_FREE
|
||||
static unsigned long g_alloc_count = 0;
|
||||
|
||||
#else
|
||||
# define TRY_BOUNDS_CHECK 0
|
||||
#endif
|
||||
|
||||
#if TRY_BOUNDS_CHECK
|
||||
# define TRY_BOUNDS_CHECK_ON_FREE 0 //checks mem integrity on every
|
||||
//free, very expensive
|
||||
# define BOUNDS_CHECK_VALUE 0xdeadbeef //value stored before/after ea.
|
||||
//mem addr for bounds checking
|
||||
# define BOUNDS_CHECK_PAD_SIZE 32 //size of the padding before and
|
||||
//after ea allocation to be filled
|
||||
//with BOUNDS_CHECK_VALUE.
|
||||
//this should be a multiple of 4
|
||||
#else
|
||||
# define BOUNDS_CHECK_VALUE 0
|
||||
# define BOUNDS_CHECK_PAD_SIZE 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_MEM_MANAGER
|
||||
# include "heapmm.h"
|
||||
# include "hmm_intrnl.h"
|
||||
|
||||
# define SHIFT_HMM_ADDR_ALIGN_UNIT 5
|
||||
# define TOTAL_MEMORY_TO_ALLOCATE 20971520 // 20 * 1024 * 1024
|
||||
|
||||
# define MM_DYNAMIC_MEMORY 1
|
||||
# if MM_DYNAMIC_MEMORY
|
||||
static unsigned char *g_p_mng_memory_raw = NULL;
|
||||
static unsigned char *g_p_mng_memory = NULL;
|
||||
# else
|
||||
static unsigned char g_p_mng_memory[TOTAL_MEMORY_TO_ALLOCATE];
|
||||
# endif
|
||||
|
||||
static size_t g_mm_memory_size = TOTAL_MEMORY_TO_ALLOCATE;
|
||||
|
||||
static hmm_descriptor hmm_d;
|
||||
static int g_mng_memory_allocated = 0;
|
||||
|
||||
static int vpx_mm_create_heap_memory();
|
||||
static void *vpx_mm_realloc(void *memblk, size_t size);
|
||||
#endif //CONFIG_MEM_MANAGER
|
||||
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
struct GLOBAL_FUNC_POINTERS
|
||||
{
|
||||
g_malloc_func g_malloc;
|
||||
g_calloc_func g_calloc;
|
||||
g_realloc_func g_realloc;
|
||||
g_free_func g_free;
|
||||
g_memcpy_func g_memcpy;
|
||||
g_memset_func g_memset;
|
||||
g_memmove_func g_memmove;
|
||||
};
|
||||
struct GLOBAL_FUNC_POINTERS *g_func = 0;
|
||||
|
||||
# define VPX_MALLOC_L g_func->g_malloc
|
||||
# define VPX_REALLOC_L g_func->g_realloc
|
||||
# define VPX_FREE_L g_func->g_free
|
||||
# define VPX_MEMCPY_L g_func->g_memcpy
|
||||
# define VPX_MEMSET_L g_func->g_memset
|
||||
# define VPX_MEMMOVE_L g_func->g_memmove
|
||||
|
||||
#else
|
||||
# define VPX_MALLOC_L malloc
|
||||
# define VPX_REALLOC_L realloc
|
||||
# define VPX_FREE_L free
|
||||
# define VPX_MEMCPY_L memcpy
|
||||
# define VPX_MEMSET_L memset
|
||||
# define VPX_MEMMOVE_L memmove
|
||||
#endif // USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
/* Should probably use a vpx_mem logger function. */
|
||||
#define __REMOVE_PRINTFS
|
||||
#ifdef __REMOVE_PRINTFS
|
||||
#define _P(x)
|
||||
#else
|
||||
#define _P(x) x
|
||||
#endif
|
||||
|
||||
/*returns an addr aligned to the byte boundary specified by align*/
|
||||
#define align_addr(addr,align) \
|
||||
(void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
|
||||
|
||||
unsigned int vpx_mem_get_version()
|
||||
{
|
||||
unsigned int ver = ((unsigned int)(unsigned char)VPX_MEM_VERSION_CHIEF << 24 |
|
||||
(unsigned int)(unsigned char)VPX_MEM_VERSION_MAJOR << 16 |
|
||||
(unsigned int)(unsigned char)VPX_MEM_VERSION_MINOR << 8 |
|
||||
(unsigned int)(unsigned char)VPX_MEM_VERSION_PATCH);
|
||||
return ver;
|
||||
}
|
||||
|
||||
int vpx_mem_set_heap_size(size_t size)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
#if CONFIG_MEM_MANAGER
|
||||
#if MM_DYNAMIC_MEMORY
|
||||
|
||||
if (!g_mng_memory_allocated && size)
|
||||
{
|
||||
g_mm_memory_size = size;
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
ret = -3;
|
||||
|
||||
#else
|
||||
ret = -2;
|
||||
#endif
|
||||
#else
|
||||
(void)size;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *vpx_memalign(size_t align, size_t size)
|
||||
{
|
||||
void *addr,
|
||||
* x = NULL;
|
||||
|
||||
#if CONFIG_MEM_MANAGER
|
||||
int number_aau;
|
||||
|
||||
if (vpx_mm_create_heap_memory() < 0)
|
||||
{
|
||||
_P(printf("[vpx][mm] ERROR vpx_memalign() Couldn't create memory for Heap.\n");)
|
||||
}
|
||||
|
||||
number_aau = ((size + align - 1 + ADDRESS_STORAGE_SIZE) >>
|
||||
SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
|
||||
|
||||
addr = hmm_alloc(&hmm_d, number_aau);
|
||||
#else
|
||||
addr = VPX_MALLOC_L(size + align - 1 + ADDRESS_STORAGE_SIZE);
|
||||
#endif //CONFIG_MEM_MANAGER
|
||||
|
||||
if (addr)
|
||||
{
|
||||
x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
|
||||
/* save the actual malloc address */
|
||||
((size_t *)x)[-1] = (size_t)addr;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void *vpx_malloc(size_t size)
|
||||
{
|
||||
return vpx_memalign(DEFAULT_ALIGNMENT, size);
|
||||
}
|
||||
|
||||
void *vpx_calloc(size_t num, size_t size)
|
||||
{
|
||||
void *x;
|
||||
|
||||
x = vpx_memalign(DEFAULT_ALIGNMENT, num * size);
|
||||
|
||||
if (x)
|
||||
VPX_MEMSET_L(x, 0, num * size);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void *vpx_realloc(void *memblk, size_t size)
|
||||
{
|
||||
void *addr,
|
||||
* new_addr = NULL;
|
||||
int align = DEFAULT_ALIGNMENT;
|
||||
|
||||
/*
|
||||
The realloc() function changes the size of the object pointed to by
|
||||
ptr to the size specified by size, and returns a pointer to the
|
||||
possibly moved block. The contents are unchanged up to the lesser
|
||||
of the new and old sizes. If ptr is null, realloc() behaves like
|
||||
malloc() for the specified size. If size is zero (0) and ptr is
|
||||
not a null pointer, the object pointed to is freed.
|
||||
*/
|
||||
if (!memblk)
|
||||
new_addr = vpx_malloc(size);
|
||||
else if (!size)
|
||||
vpx_free(memblk);
|
||||
else
|
||||
{
|
||||
addr = (void *)(((size_t *)memblk)[-1]);
|
||||
memblk = NULL;
|
||||
|
||||
#if CONFIG_MEM_MANAGER
|
||||
new_addr = vpx_mm_realloc(addr, size + align + ADDRESS_STORAGE_SIZE);
|
||||
#else
|
||||
new_addr = VPX_REALLOC_L(addr, size + align + ADDRESS_STORAGE_SIZE);
|
||||
#endif
|
||||
|
||||
if (new_addr)
|
||||
{
|
||||
addr = new_addr;
|
||||
new_addr = (void *)(((size_t)
|
||||
((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) &
|
||||
(size_t) - align);
|
||||
/* save the actual malloc address */
|
||||
((size_t *)new_addr)[-1] = (size_t)addr;
|
||||
}
|
||||
}
|
||||
|
||||
return new_addr;
|
||||
}
|
||||
|
||||
void vpx_free(void *memblk)
|
||||
{
|
||||
if (memblk)
|
||||
{
|
||||
void *addr = (void *)(((size_t *)memblk)[-1]);
|
||||
#if CONFIG_MEM_MANAGER
|
||||
hmm_free(&hmm_d, addr);
|
||||
#else
|
||||
VPX_FREE_L(addr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void *vpx_mem_alloc(int id, size_t size, size_t align)
|
||||
{
|
||||
#if defined CHIP_DM642 || defined __uClinux__
|
||||
void *mem = (void *)mem_alloc(id, size, align);
|
||||
|
||||
if (!mem)
|
||||
{
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"*********************************************************\n"
|
||||
"WARNING: mem_alloc returned 0 for id=%p size=%u align=%u.\n"
|
||||
"*********************************************************\n",
|
||||
mem, size, align));
|
||||
// should no longer need this. Softier says it's fixed. 2005-01-21 tjf
|
||||
//#if defined __uClinux__
|
||||
//while(1)usleep(1000000);
|
||||
//#endif
|
||||
}
|
||||
|
||||
#if defined __uClinux__
|
||||
else if (mem == (void *)0xFFFFFFFF)
|
||||
{
|
||||
// out of memory/error
|
||||
mem = (void *)0;
|
||||
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"******************************************************\n"
|
||||
"ERROR: mem_alloc id=%p size=%u align=%u OUT OF MEMORY.\n"
|
||||
"******************************************************\n",
|
||||
mem, size, align));
|
||||
}
|
||||
|
||||
#endif // __uClinux__
|
||||
|
||||
return mem;
|
||||
#else
|
||||
(void)id;
|
||||
(void)size;
|
||||
(void)align;
|
||||
return (void *)0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void vpx_mem_free(int id, void *mem, size_t size)
|
||||
{
|
||||
#if defined CHIP_DM642 || defined __uClinux__
|
||||
|
||||
if (!mem)
|
||||
{
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"**************************************\n"
|
||||
"WARNING: 0 being free'd id=%p size=%u.\n"
|
||||
"**************************************\n",
|
||||
id, size));
|
||||
|
||||
// should no longer need this. Softier says it's fixed. 2005-01-21 tjf
|
||||
//#if defined __uClinux__
|
||||
//while(1)usleep(1000000);
|
||||
//#endif
|
||||
}
|
||||
|
||||
mem_free(id, mem, size);
|
||||
#else
|
||||
(void)id;
|
||||
(void)mem;
|
||||
(void)size;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_MEM_TRACKER
|
||||
|
||||
void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line)
|
||||
{
|
||||
void *mem = vpx_mem_alloc(id, size, align);
|
||||
|
||||
vpx_memory_tracker_add((size_t)mem, size, file, line, 0);
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line)
|
||||
{
|
||||
if (vpx_memory_tracker_remove((size_t)mem) == -2)
|
||||
{
|
||||
#if REMOVE_PRINTFS
|
||||
(void)file;
|
||||
(void)line;
|
||||
#endif
|
||||
_P(fprintf(stderr, "[vpx_mem][xvpx_mem_free] addr: %p (id=%p size=%u) "
|
||||
"not found in list; freed from file:%s"
|
||||
" line:%d\n", mem, id, size, file, line));
|
||||
}
|
||||
|
||||
vpx_mem_free(id, mem, size);
|
||||
}
|
||||
|
||||
void *xvpx_memalign(size_t align, size_t size, char *file, int line)
|
||||
{
|
||||
#if TRY_BOUNDS_CHECK
|
||||
unsigned char *x_bounds;
|
||||
#endif
|
||||
|
||||
void *x;
|
||||
|
||||
if (g_alloc_count == 0)
|
||||
{
|
||||
#if TRY_BOUNDS_CHECK
|
||||
int i_rv = vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE);
|
||||
#else
|
||||
int i_rv = vpx_memory_tracker_init(0, 0);
|
||||
#endif
|
||||
|
||||
if (i_rv < 0)
|
||||
{
|
||||
_P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
|
||||
}
|
||||
}
|
||||
|
||||
#if TRY_BOUNDS_CHECK
|
||||
{
|
||||
int i;
|
||||
unsigned int tempme = BOUNDS_CHECK_VALUE;
|
||||
|
||||
x_bounds = vpx_memalign(align, size + (BOUNDS_CHECK_PAD_SIZE * 2));
|
||||
|
||||
if (x_bounds)
|
||||
{
|
||||
/*we're aligning the address twice here but to keep things
|
||||
consistent we want to have the padding come before the stored
|
||||
address so no matter what free function gets called we will
|
||||
attempt to free the correct address*/
|
||||
x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
|
||||
x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
|
||||
(int)align);
|
||||
/* save the actual malloc address */
|
||||
((size_t *)x)[-1] = (size_t)x_bounds;
|
||||
|
||||
for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int))
|
||||
{
|
||||
VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
|
||||
VPX_MEMCPY_L((unsigned char *)x + size + i,
|
||||
&tempme, sizeof(unsigned int));
|
||||
}
|
||||
}
|
||||
else
|
||||
x = NULL;
|
||||
}
|
||||
#else
|
||||
x = vpx_memalign(align, size);
|
||||
#endif //TRY_BOUNDS_CHECK
|
||||
|
||||
g_alloc_count++;
|
||||
|
||||
vpx_memory_tracker_add((size_t)x, size, file, line, 1);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void *xvpx_malloc(size_t size, char *file, int line)
|
||||
{
|
||||
return xvpx_memalign(DEFAULT_ALIGNMENT, size, file, line);
|
||||
}
|
||||
|
||||
void *xvpx_calloc(size_t num, size_t size, char *file, int line)
|
||||
{
|
||||
void *x = xvpx_memalign(DEFAULT_ALIGNMENT, num * size, file, line);
|
||||
|
||||
if (x)
|
||||
VPX_MEMSET_L(x, 0, num * size);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void *xvpx_realloc(void *memblk, size_t size, char *file, int line)
|
||||
{
|
||||
struct mem_block *p = NULL;
|
||||
int orig_size = 0,
|
||||
orig_line = 0;
|
||||
char *orig_file = NULL;
|
||||
|
||||
#if TRY_BOUNDS_CHECK
|
||||
unsigned char *x_bounds = memblk ?
|
||||
(unsigned char *)(((size_t *)memblk)[-1]) :
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
void *x;
|
||||
|
||||
if (g_alloc_count == 0)
|
||||
{
|
||||
#if TRY_BOUNDS_CHECK
|
||||
|
||||
if (!vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE))
|
||||
#else
|
||||
if (!vpx_memory_tracker_init(0, 0))
|
||||
#endif
|
||||
{
|
||||
_P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");)
|
||||
}
|
||||
}
|
||||
|
||||
if (p = vpx_memory_tracker_find((size_t)memblk))
|
||||
{
|
||||
orig_size = p->size;
|
||||
orig_file = p->file;
|
||||
orig_line = p->line;
|
||||
}
|
||||
|
||||
#if TRY_BOUNDS_CHECK_ON_FREE
|
||||
vpx_memory_tracker_check_integrity(file, line);
|
||||
#endif
|
||||
|
||||
//have to do this regardless of success, because
|
||||
//the memory that does get realloc'd may change
|
||||
//the bounds values of this block
|
||||
vpx_memory_tracker_remove((size_t)memblk);
|
||||
|
||||
#if TRY_BOUNDS_CHECK
|
||||
{
|
||||
int i;
|
||||
unsigned int tempme = BOUNDS_CHECK_VALUE;
|
||||
|
||||
x_bounds = vpx_realloc(memblk, size + (BOUNDS_CHECK_PAD_SIZE * 2));
|
||||
|
||||
if (x_bounds)
|
||||
{
|
||||
x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]);
|
||||
x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE,
|
||||
(int)DEFAULT_ALIGNMENT);
|
||||
/* save the actual malloc address */
|
||||
((size_t *)x)[-1] = (size_t)x_bounds;
|
||||
|
||||
for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int))
|
||||
{
|
||||
VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int));
|
||||
VPX_MEMCPY_L((unsigned char *)x + size + i,
|
||||
&tempme, sizeof(unsigned int));
|
||||
}
|
||||
}
|
||||
else
|
||||
x = NULL;
|
||||
}
|
||||
#else
|
||||
x = vpx_realloc(memblk, size);
|
||||
#endif //TRY_BOUNDS_CHECK
|
||||
|
||||
if (x)
|
||||
vpx_memory_tracker_add((size_t)x, size, file, line, 1);
|
||||
else
|
||||
vpx_memory_tracker_add((size_t)memblk, orig_size, orig_file, orig_line, 1);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void xvpx_free(void *p_address, char *file, int line)
|
||||
{
|
||||
#if TRY_BOUNDS_CHECK
|
||||
unsigned char *p_bounds_address = (unsigned char *)p_address;
|
||||
//p_bounds_address -= BOUNDS_CHECK_PAD_SIZE;
|
||||
#endif
|
||||
|
||||
#if !TRY_BOUNDS_CHECK_ON_FREE
|
||||
(void)file;
|
||||
(void)line;
|
||||
#endif
|
||||
|
||||
if (p_address)
|
||||
{
|
||||
#if TRY_BOUNDS_CHECK_ON_FREE
|
||||
vpx_memory_tracker_check_integrity(file, line);
|
||||
#endif
|
||||
|
||||
//if the addr isn't found in the list, assume it was allocated via
|
||||
//vpx_ calls not xvpx_, therefore it does not contain any padding
|
||||
if (vpx_memory_tracker_remove((size_t)p_address) == -2)
|
||||
{
|
||||
p_bounds_address = p_address;
|
||||
_P(fprintf(stderr, "[vpx_mem][xvpx_free] addr: %p not found in"
|
||||
" list; freed from file:%s"
|
||||
" line:%d\n", p_address, file, line));
|
||||
}
|
||||
else
|
||||
--g_alloc_count;
|
||||
|
||||
#if TRY_BOUNDS_CHECK
|
||||
vpx_free(p_bounds_address);
|
||||
#else
|
||||
vpx_free(p_address);
|
||||
#endif
|
||||
|
||||
if (!g_alloc_count)
|
||||
vpx_memory_tracker_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*CONFIG_MEM_TRACKER*/
|
||||
|
||||
#if CONFIG_MEM_CHECKS
|
||||
#if defined(VXWORKS)
|
||||
#include <task_lib.h> //for task_delay()
|
||||
/* This function is only used to get a stack trace of the player
|
||||
object so we can se where we are having a problem. */
|
||||
static int get_my_tt(int task)
|
||||
{
|
||||
tt(task);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vx_sleep(int msec)
|
||||
{
|
||||
int ticks_to_sleep = 0;
|
||||
|
||||
if (msec)
|
||||
{
|
||||
int msec_per_tick = 1000 / sys_clk_rate_get();
|
||||
|
||||
if (msec < msec_per_tick)
|
||||
ticks_to_sleep++;
|
||||
else
|
||||
ticks_to_sleep = msec / msec_per_tick;
|
||||
}
|
||||
|
||||
task_delay(ticks_to_sleep);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void *vpx_memcpy(void *dest, const void *source, size_t length)
|
||||
{
|
||||
#if CONFIG_MEM_CHECKS
|
||||
|
||||
if (((int)dest < 0x4000) || ((int)source < 0x4000))
|
||||
{
|
||||
_P(printf("WARNING: vpx_memcpy dest:0x%x source:0x%x len:%d\n", (int)dest, (int)source, length);)
|
||||
|
||||
#if defined(VXWORKS)
|
||||
sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
vx_sleep(10000);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return VPX_MEMCPY_L(dest, source, length);
|
||||
}
|
||||
|
||||
void *vpx_memset(void *dest, int val, size_t length)
|
||||
{
|
||||
#if CONFIG_MEM_CHECKS
|
||||
|
||||
if ((int)dest < 0x4000)
|
||||
{
|
||||
_P(printf("WARNING: vpx_memset dest:0x%x val:%d len:%d\n", (int)dest, val, length);)
|
||||
|
||||
#if defined(VXWORKS)
|
||||
sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
vx_sleep(10000);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return VPX_MEMSET_L(dest, val, length);
|
||||
}
|
||||
|
||||
void *vpx_memmove(void *dest, const void *src, size_t count)
|
||||
{
|
||||
#if CONFIG_MEM_CHECKS
|
||||
|
||||
if (((int)dest < 0x4000) || ((int)src < 0x4000))
|
||||
{
|
||||
_P(printf("WARNING: vpx_memmove dest:0x%x src:0x%x count:%d\n", (int)dest, (int)src, count);)
|
||||
|
||||
#if defined(VXWORKS)
|
||||
sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
vx_sleep(10000);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return VPX_MEMMOVE_L(dest, src, count);
|
||||
}
|
||||
|
||||
#if CONFIG_MEM_MANAGER
|
||||
|
||||
static int vpx_mm_create_heap_memory()
|
||||
{
|
||||
int i_rv = 0;
|
||||
|
||||
if (!g_mng_memory_allocated)
|
||||
{
|
||||
#if MM_DYNAMIC_MEMORY
|
||||
g_p_mng_memory_raw =
|
||||
(unsigned char *)malloc(g_mm_memory_size + HMM_ADDR_ALIGN_UNIT);
|
||||
|
||||
if (g_p_mng_memory_raw)
|
||||
{
|
||||
g_p_mng_memory = (unsigned char *)((((unsigned int)g_p_mng_memory_raw) +
|
||||
HMM_ADDR_ALIGN_UNIT - 1) &
|
||||
-(int)HMM_ADDR_ALIGN_UNIT);
|
||||
|
||||
_P(printf("[vpx][mm] total memory size:%d g_p_mng_memory_raw:0x%x g_p_mng_memory:0x%x\n"
|
||||
, g_mm_memory_size + HMM_ADDR_ALIGN_UNIT
|
||||
, (unsigned int)g_p_mng_memory_raw
|
||||
, (unsigned int)g_p_mng_memory);)
|
||||
}
|
||||
else
|
||||
{
|
||||
_P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
|
||||
, g_mm_memory_size);)
|
||||
|
||||
i_rv = -1;
|
||||
}
|
||||
|
||||
if (g_p_mng_memory)
|
||||
#endif
|
||||
{
|
||||
int chunk_size = 0;
|
||||
|
||||
g_mng_memory_allocated = 1;
|
||||
|
||||
hmm_init(&hmm_d);
|
||||
|
||||
chunk_size = g_mm_memory_size >> SHIFT_HMM_ADDR_ALIGN_UNIT;
|
||||
|
||||
chunk_size -= DUMMY_END_BLOCK_BAUS;
|
||||
|
||||
_P(printf("[vpx][mm] memory size:%d for vpx memory manager. g_p_mng_memory:0x%x chunk_size:%d\n"
|
||||
, g_mm_memory_size
|
||||
, (unsigned int)g_p_mng_memory
|
||||
, chunk_size);)
|
||||
|
||||
hmm_new_chunk(&hmm_d, (void *)g_p_mng_memory, chunk_size);
|
||||
}
|
||||
|
||||
#if MM_DYNAMIC_MEMORY
|
||||
else
|
||||
{
|
||||
_P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n"
|
||||
, g_mm_memory_size);)
|
||||
|
||||
i_rv = -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return i_rv;
|
||||
}
|
||||
|
||||
static void *vpx_mm_realloc(void *memblk, size_t size)
|
||||
{
|
||||
void *p_ret = NULL;
|
||||
|
||||
if (vpx_mm_create_heap_memory() < 0)
|
||||
{
|
||||
_P(printf("[vpx][mm] ERROR vpx_mm_realloc() Couldn't create memory for Heap.\n");)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i_rv = 0;
|
||||
int old_num_aaus;
|
||||
int new_num_aaus;
|
||||
|
||||
old_num_aaus = hmm_true_size(memblk);
|
||||
new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
|
||||
|
||||
if (old_num_aaus == new_num_aaus)
|
||||
{
|
||||
p_ret = memblk;
|
||||
}
|
||||
else
|
||||
{
|
||||
i_rv = hmm_resize(&hmm_d, memblk, new_num_aaus);
|
||||
|
||||
if (i_rv == 0)
|
||||
{
|
||||
p_ret = memblk;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Error. Try to malloc and then copy data. */
|
||||
void *p_from_malloc;
|
||||
|
||||
new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1;
|
||||
p_from_malloc = hmm_alloc(&hmm_d, new_num_aaus);
|
||||
|
||||
if (p_from_malloc)
|
||||
{
|
||||
vpx_memcpy(p_from_malloc, memblk, size);
|
||||
hmm_free(&hmm_d, memblk);
|
||||
|
||||
p_ret = p_from_malloc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p_ret;
|
||||
}
|
||||
#endif //CONFIG_MEM_MANAGER
|
||||
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
# if CONFIG_MEM_TRACKER
|
||||
extern int vpx_memory_tracker_set_functions(g_malloc_func g_malloc_l
|
||||
, g_calloc_func g_calloc_l
|
||||
, g_realloc_func g_realloc_l
|
||||
, g_free_func g_free_l
|
||||
, g_memcpy_func g_memcpy_l
|
||||
, g_memset_func g_memset_l
|
||||
, g_memmove_func g_memmove_l);
|
||||
# endif
|
||||
#endif
|
||||
int vpx_mem_set_functions(g_malloc_func g_malloc_l
|
||||
, g_calloc_func g_calloc_l
|
||||
, g_realloc_func g_realloc_l
|
||||
, g_free_func g_free_l
|
||||
, g_memcpy_func g_memcpy_l
|
||||
, g_memset_func g_memset_l
|
||||
, g_memmove_func g_memmove_l)
|
||||
{
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
/* If use global functions is turned on then the
|
||||
application must set the global functions before
|
||||
it does anything else or vpx_mem will have
|
||||
unpredictable results. */
|
||||
if (!g_func)
|
||||
{
|
||||
g_func = (struct GLOBAL_FUNC_POINTERS *)g_malloc_l(sizeof(struct GLOBAL_FUNC_POINTERS));
|
||||
|
||||
if (!g_func)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_MEM_TRACKER
|
||||
{
|
||||
int rv = 0;
|
||||
rv = vpx_memory_tracker_set_functions(g_malloc_l
|
||||
, g_calloc_l
|
||||
, g_realloc_l
|
||||
, g_free_l
|
||||
, g_memcpy_l
|
||||
, g_memset_l
|
||||
, g_memmove_l);
|
||||
|
||||
if (rv < 0)
|
||||
{
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_malloc_l)
|
||||
g_func->g_malloc = g_malloc_l;
|
||||
else
|
||||
g_func->g_malloc = 0;
|
||||
|
||||
if (g_calloc_l)
|
||||
g_func->g_calloc = g_calloc_l;
|
||||
else
|
||||
g_func->g_calloc = 0;
|
||||
|
||||
if (g_realloc_l)
|
||||
g_func->g_realloc = g_realloc_l;
|
||||
else
|
||||
g_func->g_realloc = 0;
|
||||
|
||||
if (g_free_l)
|
||||
g_func->g_free = g_free_l;
|
||||
else
|
||||
g_func->g_free = 0;
|
||||
|
||||
if (g_memcpy_l)
|
||||
g_func->g_memcpy = g_memcpy_l;
|
||||
else
|
||||
g_func->g_memcpy = 0;
|
||||
|
||||
if (g_memset_l)
|
||||
g_func->g_memset = g_memset_l;
|
||||
else
|
||||
g_func->g_memset = 0;
|
||||
|
||||
if (g_memmove_l)
|
||||
g_func->g_memmove = g_memmove_l;
|
||||
else
|
||||
g_func->g_memmove = 0;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)g_malloc_l;
|
||||
(void)g_calloc_l;
|
||||
(void)g_realloc_l;
|
||||
(void)g_free_l;
|
||||
(void)g_memcpy_l;
|
||||
(void)g_memset_l;
|
||||
(void)g_memmove_l;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int vpx_mem_unset_functions()
|
||||
{
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
if (g_func)
|
||||
{
|
||||
g_free_func temp_free;
|
||||
|
||||
temp_free = g_func->g_free;
|
||||
|
||||
temp_free(g_func);
|
||||
g_func = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _INTEL_LINUX
|
||||
void *_intel_fast_memcpy(void *dest, const void *src, size_t count)
|
||||
{
|
||||
|
||||
//memcpy(dest, src, count);
|
||||
char *dst8 = (char *)dest;
|
||||
char *src8 = (char *)src;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
*dst8++ = *src8++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *_intel_fast_memset(void *dest, int c, size_t count)
|
||||
{
|
||||
memset(dest, c, count);
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *_VEC_memzero(void *dest, int c, size_t count)
|
||||
{
|
||||
memset(dest, 0, count);
|
||||
return dest;
|
||||
}
|
||||
|
||||
#endif //_ICC
|
@ -1,812 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
vpx_mem_tracker.c
|
||||
|
||||
jwz 2003-09-30:
|
||||
Stores a list of addreses, their size, and file and line they came from.
|
||||
All exposed lib functions are prefaced by vpx_ and allow the global list
|
||||
to be thread safe.
|
||||
Current supported platforms are:
|
||||
Linux, Win32, win_ce and vx_works
|
||||
Further support can be added by defining the platform specific mutex
|
||||
in the memory_tracker struct as well as calls to create/destroy/lock/unlock
|
||||
the mutex in vpx_memory_tracker_init/Destroy and memory_tracker_lock_mutex/unlock_mutex
|
||||
*/
|
||||
|
||||
#define NO_MUTEX
|
||||
|
||||
#if defined(__uClinux__)
|
||||
# include <lddk.h>
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) || defined(__uClinux__)
|
||||
# include <pthread.h>
|
||||
#elif defined(WIN32) || defined(_WIN32_WCE)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# include <winbase.h>
|
||||
#elif defined(VXWORKS)
|
||||
# include <sem_lib.h>
|
||||
#elif defined(NDS_NITRO)
|
||||
# include <nitro.h>
|
||||
# include <nitro/os.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> //VXWORKS doesn't have a malloc/memory.h file,
|
||||
//this should pull in malloc,free,etc.
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "vpx_mem_tracker.h"
|
||||
|
||||
#undef vpx_malloc //undefine any vpx_mem macros that may affect calls to
|
||||
#undef vpx_free //memory functions in this file
|
||||
#undef vpx_memcpy
|
||||
#undef vpx_memset
|
||||
|
||||
|
||||
#ifndef USE_GLOBAL_FUNCTION_POINTERS
|
||||
# define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions.
|
||||
#endif
|
||||
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
static mem_track_malloc_func g_malloc = malloc;
|
||||
static mem_track_calloc_func g_calloc = calloc;
|
||||
static mem_track_realloc_func g_realloc = realloc;
|
||||
static mem_track_free_func g_free = free;
|
||||
static mem_track_memcpy_func g_memcpy = memcpy;
|
||||
static mem_track_memset_func g_memset = memset;
|
||||
static mem_track_memmove_func g_memmove = memmove;
|
||||
# define MEM_TRACK_MALLOC g_malloc
|
||||
# define MEM_TRACK_FREE g_free
|
||||
# define MEM_TRACK_MEMCPY g_memcpy
|
||||
# define MEM_TRACK_MEMSET g_memset
|
||||
#else
|
||||
# define MEM_TRACK_MALLOC vpx_malloc
|
||||
# define MEM_TRACK_FREE vpx_free
|
||||
# define MEM_TRACK_MEMCPY vpx_memcpy
|
||||
# define MEM_TRACK_MEMSET vpx_memset
|
||||
#endif // USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
|
||||
struct memory_tracker
|
||||
{
|
||||
struct mem_block *head,
|
||||
* tail;
|
||||
int len,
|
||||
totalsize;
|
||||
unsigned int current_allocated,
|
||||
max_allocated;
|
||||
|
||||
#if defined(LINUX) || defined(__uClinux__)
|
||||
pthread_mutex_t mutex;
|
||||
#elif defined(WIN32) || defined(_WIN32_WCE)
|
||||
HANDLE mutex;
|
||||
#elif defined(VXWORKS)
|
||||
SEM_ID mutex;
|
||||
#elif defined(NDS_NITRO)
|
||||
OSMutex mutex;
|
||||
#elif defined(NO_MUTEX)
|
||||
#else
|
||||
#error "No mutex type defined for this platform!"
|
||||
#endif
|
||||
|
||||
int padding_size,
|
||||
pad_value;
|
||||
};
|
||||
|
||||
/* prototypes for internal library functions */
|
||||
static void memtrack_log(const char *fmt, ...);
|
||||
static void memory_tracker_dump();
|
||||
static void memory_tracker_check_integrity(char *file, unsigned int line);
|
||||
static void memory_tracker_add(size_t addr, unsigned int size,
|
||||
char *file, unsigned int line,
|
||||
int padded);
|
||||
static int memory_tracker_remove(size_t addr);
|
||||
static struct mem_block *memory_tracker_find(size_t addr);
|
||||
|
||||
#if defined(NO_MUTEX)
|
||||
# define memory_tracker_lock_mutex() (!g_b_mem_tracker_inited)
|
||||
# define memory_tracker_unlock_mutex()
|
||||
#else
|
||||
static int memory_tracker_lock_mutex();
|
||||
static int memory_tracker_unlock_mutex();
|
||||
#endif
|
||||
|
||||
static struct memory_tracker memtrack; //our global memory allocation list
|
||||
static int g_b_mem_tracker_inited = 0; //indicates whether the global list has
|
||||
//been initialized (1:yes/0:no)
|
||||
static struct
|
||||
{
|
||||
FILE *file;
|
||||
int type;
|
||||
void (*func)(void *userdata, const char *fmt, va_list args);
|
||||
void *userdata;
|
||||
} g_logging = {0};
|
||||
|
||||
extern void *vpx_malloc(size_t size);
|
||||
extern void vpx_free(void *memblk);
|
||||
extern void *vpx_memcpy(void *dest, const void *src, size_t length);
|
||||
extern void *vpx_memset(void *dest, int val, size_t length);
|
||||
|
||||
/*
|
||||
*
|
||||
* Exposed library functions
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_init(int padding_size, int pad_value)
|
||||
padding_size - the size of the padding before and after each mem addr.
|
||||
Values > 0 indicate that integrity checks can be performed
|
||||
by inspecting these areas.
|
||||
pad_value - the initial value within the padding area before and after
|
||||
each mem addr.
|
||||
|
||||
Initializes global memory tracker structure
|
||||
Allocates the head of the list
|
||||
*/
|
||||
int vpx_memory_tracker_init(int padding_size, int pad_value)
|
||||
{
|
||||
if (!g_b_mem_tracker_inited)
|
||||
{
|
||||
if (memtrack.head = (struct mem_block *)MEM_TRACK_MALLOC(sizeof(struct mem_block)))
|
||||
{
|
||||
int ret;
|
||||
|
||||
MEM_TRACK_MEMSET(memtrack.head, 0, sizeof(struct mem_block));
|
||||
|
||||
memtrack.tail = memtrack.head;
|
||||
|
||||
memtrack.current_allocated = 0;
|
||||
memtrack.max_allocated = 0;
|
||||
|
||||
memtrack.padding_size = padding_size;
|
||||
memtrack.pad_value = pad_value;
|
||||
|
||||
#if defined(LINUX) || defined(__uClinux__)
|
||||
ret = pthread_mutex_init(&memtrack.mutex,
|
||||
NULL); /*mutex attributes (NULL=default)*/
|
||||
#elif defined(WIN32) || defined(_WIN32_WCE)
|
||||
memtrack.mutex = create_mutex(NULL, /*security attributes*/
|
||||
FALSE, /*we don't want initial ownership*/
|
||||
NULL); /*mutex name*/
|
||||
ret = !memtrack.mutex;
|
||||
#elif defined(VXWORKS)
|
||||
memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority based mutex*/
|
||||
SEM_FULL); /*SEM_FULL initial state is unlocked*/
|
||||
ret = !memtrack.mutex;
|
||||
#elif defined(NDS_NITRO)
|
||||
os_init_mutex(&memtrack.mutex);
|
||||
ret = 0;
|
||||
#elif defined(NO_MUTEX)
|
||||
ret = 0;
|
||||
#endif
|
||||
|
||||
if (ret)
|
||||
{
|
||||
memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n");
|
||||
|
||||
MEM_TRACK_FREE(memtrack.head);
|
||||
memtrack.head = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrack_log("Memory Tracker init'd, v."vpx_mem_tracker_version" pad_size:%d pad_val:0x%x %d\n"
|
||||
, padding_size
|
||||
, pad_value
|
||||
, pad_value);
|
||||
g_b_mem_tracker_inited = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return g_b_mem_tracker_inited;
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_destroy()
|
||||
If our global struct was initialized zeros out all its members,
|
||||
frees memory and destroys it's mutex
|
||||
*/
|
||||
void vpx_memory_tracker_destroy()
|
||||
{
|
||||
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
struct mem_block *p = memtrack.head,
|
||||
* p2 = memtrack.head;
|
||||
|
||||
memory_tracker_dump();
|
||||
|
||||
while (p)
|
||||
{
|
||||
p2 = p;
|
||||
p = p->next;
|
||||
|
||||
MEM_TRACK_FREE(p2);
|
||||
}
|
||||
|
||||
memtrack.head = NULL;
|
||||
memtrack.tail = NULL;
|
||||
memtrack.len = 0;
|
||||
memtrack.current_allocated = 0;
|
||||
memtrack.max_allocated = 0;
|
||||
|
||||
if ((g_logging.type == 0) && (g_logging.file != 0)) //&& (g_logging.file != stderr) )
|
||||
{
|
||||
#if !defined(NDS_NITRO)
|
||||
fclose(g_logging.file);
|
||||
#endif
|
||||
g_logging.file = NULL;
|
||||
}
|
||||
|
||||
memory_tracker_unlock_mutex();
|
||||
|
||||
g_b_mem_tracker_inited = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_add(size_t addr, unsigned int size,
|
||||
char * file, unsigned int line)
|
||||
addr - memory address to be added to list
|
||||
size - size of addr
|
||||
file - the file addr was referenced from
|
||||
line - the line in file addr was referenced from
|
||||
Adds memory address addr, it's size, file and line it came from
|
||||
to the global list via the thread safe internal library function
|
||||
*/
|
||||
void vpx_memory_tracker_add(size_t addr, unsigned int size,
|
||||
char *file, unsigned int line,
|
||||
int padded)
|
||||
{
|
||||
memory_tracker_add(addr, size, file, line, padded);
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_remove(size_t addr)
|
||||
addr - memory address to be removed from list
|
||||
Removes addr from the global list via the thread safe
|
||||
internal remove function
|
||||
Return:
|
||||
Same as described for memory_tracker_remove
|
||||
*/
|
||||
int vpx_memory_tracker_remove(size_t addr)
|
||||
{
|
||||
return memory_tracker_remove(addr);
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_find(size_t addr)
|
||||
addr - address to be found in list
|
||||
Return:
|
||||
If found, pointer to the memory block that matches addr
|
||||
NULL otherwise
|
||||
*/
|
||||
struct mem_block *vpx_memory_tracker_find(size_t addr)
|
||||
{
|
||||
struct mem_block *p = NULL;
|
||||
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
p = memory_tracker_find(addr);
|
||||
memory_tracker_unlock_mutex();
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_dump()
|
||||
Locks the memory tracker's mutex and calls the internal
|
||||
library function to dump the current contents of the
|
||||
global memory allocation list
|
||||
*/
|
||||
void vpx_memory_tracker_dump()
|
||||
{
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
memory_tracker_dump();
|
||||
memory_tracker_unlock_mutex();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_check_integrity(char* file, unsigned int line)
|
||||
file - The file name where the check was placed
|
||||
line - The line in file where the check was placed
|
||||
Locks the memory tracker's mutex and calls the internal
|
||||
integrity check function to inspect every address in the global
|
||||
memory allocation list
|
||||
*/
|
||||
void vpx_memory_tracker_check_integrity(char *file, unsigned int line)
|
||||
{
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
memory_tracker_check_integrity(file, line);
|
||||
memory_tracker_unlock_mutex();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_set_log_type
|
||||
Sets the logging type for the memory tracker. Based on the value it will
|
||||
direct its output to the appropriate place.
|
||||
Return:
|
||||
0: on success
|
||||
-1: if the logging type could not be set, because the value was invalid
|
||||
or because a file could not be opened
|
||||
*/
|
||||
int vpx_memory_tracker_set_log_type(int type, char *option)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
g_logging.type = 0;
|
||||
|
||||
if (!option)
|
||||
{
|
||||
// g_logging.file = stderr;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
#if !defined(NDS_NITRO)
|
||||
else
|
||||
{
|
||||
if (g_logging.file = fopen((char *)option, "w"))
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
break;
|
||||
#if defined(WIN32) && !defined(_WIN32_WCE)
|
||||
case 1:
|
||||
g_logging.type = type;
|
||||
ret = 0;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//output the version to the new logging destination
|
||||
if (!ret)
|
||||
memtrack_log("Memory Tracker logging initialized, "
|
||||
"Memory Tracker v."vpx_mem_tracker_version"\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_set_log_func
|
||||
Sets a logging function to be used by the memory tracker.
|
||||
Return:
|
||||
0: on success
|
||||
-1: if the logging type could not be set because logfunc was NULL
|
||||
*/
|
||||
int vpx_memory_tracker_set_log_func(void *userdata,
|
||||
void(*logfunc)(void *userdata,
|
||||
const char *fmt, va_list args))
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (logfunc)
|
||||
{
|
||||
g_logging.type = -1;
|
||||
g_logging.userdata = userdata;
|
||||
g_logging.func = logfunc;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
//output the version to the new logging destination
|
||||
if (!ret)
|
||||
memtrack_log("Memory Tracker logging initialized, "
|
||||
"Memory Tracker v."vpx_mem_tracker_version"\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* END - Exposed library functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Internal library functions
|
||||
*
|
||||
*/
|
||||
|
||||
static void memtrack_log(const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
|
||||
switch (g_logging.type)
|
||||
{
|
||||
case -1:
|
||||
|
||||
if (g_logging.func)
|
||||
g_logging.func(g_logging.userdata, fmt, list);
|
||||
|
||||
break;
|
||||
case 0:
|
||||
|
||||
if (g_logging.file)
|
||||
{
|
||||
vfprintf(g_logging.file, fmt, list);
|
||||
fflush(g_logging.file);
|
||||
}
|
||||
|
||||
break;
|
||||
#if defined(WIN32) && !defined(_WIN32_WCE)
|
||||
case 1:
|
||||
{
|
||||
char temp[1024];
|
||||
_vsnprintf(temp, sizeof(temp) / sizeof(char) - 1, fmt, list);
|
||||
output_debug_string(temp);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_dump()
|
||||
Dumps the current contents of the global memory allocation list
|
||||
*/
|
||||
static void memory_tracker_dump()
|
||||
{
|
||||
int i = 0;
|
||||
struct mem_block *p = (memtrack.head ? memtrack.head->next : NULL);
|
||||
|
||||
memtrack_log("\n_currently Allocated= %d; Max allocated= %d\n",
|
||||
memtrack.current_allocated, memtrack.max_allocated);
|
||||
|
||||
while (p)
|
||||
{
|
||||
#if defined(WIN32) && !defined(_WIN32_WCE)
|
||||
|
||||
/*when using outputdebugstring, output filenames so they
|
||||
can be clicked to be opened in visual studio*/
|
||||
if (g_logging.type == 1)
|
||||
memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file:\n"
|
||||
" %s(%d):\n", i,
|
||||
p->addr, i, p->size,
|
||||
p->file, p->line);
|
||||
else
|
||||
#endif
|
||||
memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file: %s, line: %d\n", i,
|
||||
p->addr, i, p->size,
|
||||
p->file, p->line);
|
||||
|
||||
p = p->next;
|
||||
++i;
|
||||
}
|
||||
|
||||
memtrack_log("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_check_integrity(char* file, unsigned int file)
|
||||
file - the file name where the check was placed
|
||||
line - the line in file where the check was placed
|
||||
If a padding_size was supplied to vpx_memory_tracker_init()
|
||||
this function will check ea. addr in the list verifying that
|
||||
addr-padding_size and addr+padding_size is filled with pad_value
|
||||
*/
|
||||
static void memory_tracker_check_integrity(char *file, unsigned int line)
|
||||
{
|
||||
if (memtrack.padding_size)
|
||||
{
|
||||
int i,
|
||||
index = 0;
|
||||
unsigned char *p_show_me,
|
||||
* p_show_me2;
|
||||
unsigned int tempme = memtrack.pad_value,
|
||||
dead1,
|
||||
dead2;
|
||||
unsigned char *x_bounds;
|
||||
struct mem_block *p = memtrack.head->next;
|
||||
|
||||
while (p)
|
||||
{
|
||||
//x_bounds = (unsigned char*)p->addr;
|
||||
//back up VPX_BYTE_ALIGNMENT
|
||||
//x_bounds -= memtrack.padding_size;
|
||||
|
||||
if (p->padded) // can the bounds be checked?
|
||||
{
|
||||
/*yes, move to the address that was actually allocated
|
||||
by the vpx_* calls*/
|
||||
x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]);
|
||||
|
||||
for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int))
|
||||
{
|
||||
p_show_me = (x_bounds + i);
|
||||
p_show_me2 = (unsigned char *)(p->addr + p->size + i);
|
||||
|
||||
MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int));
|
||||
MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int));
|
||||
|
||||
if ((dead1 != tempme) || (dead2 != tempme))
|
||||
{
|
||||
memtrack_log("\n[vpx_mem integrity check failed]:\n"
|
||||
" index[%d] {%s:%d} addr=0x%x, size=%d,"
|
||||
" file: %s, line: %d c0:0x%x c1:0x%x\n",
|
||||
index, file, line, p->addr, p->size, p->file,
|
||||
p->line, dead1, dead2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++index;
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_add(size_t addr, unsigned int size,
|
||||
char * file, unsigned int line)
|
||||
Adds an address (addr), it's size, file and line number to our list.
|
||||
Adjusts the total bytes allocated and max bytes allocated if necessary.
|
||||
If memory cannot be allocated the list will be destroyed.
|
||||
*/
|
||||
void memory_tracker_add(size_t addr, unsigned int size,
|
||||
char *file, unsigned int line,
|
||||
int padded)
|
||||
{
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
struct mem_block *p;
|
||||
|
||||
p = MEM_TRACK_MALLOC(sizeof(struct mem_block));
|
||||
|
||||
if (p)
|
||||
{
|
||||
p->prev = memtrack.tail;
|
||||
p->prev->next = p;
|
||||
p->addr = addr;
|
||||
p->size = size;
|
||||
p->line = line;
|
||||
p->file = file;
|
||||
p->padded = padded;
|
||||
p->next = NULL;
|
||||
|
||||
memtrack.tail = p;
|
||||
|
||||
memtrack.current_allocated += size;
|
||||
|
||||
if (memtrack.current_allocated > memtrack.max_allocated)
|
||||
memtrack.max_allocated = memtrack.current_allocated;
|
||||
|
||||
//memtrack_log("memory_tracker_add: added addr=0x%.8x\n", addr);
|
||||
|
||||
memory_tracker_unlock_mutex();
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrack_log("memory_tracker_add: error allocating memory!\n");
|
||||
memory_tracker_unlock_mutex();
|
||||
vpx_memory_tracker_destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_remove(size_t addr)
|
||||
Removes an address and its corresponding size (if they exist)
|
||||
from the memory tracker list and adjusts the current number
|
||||
of bytes allocated.
|
||||
Return:
|
||||
0: on success
|
||||
-1: if the mutex could not be locked
|
||||
-2: if the addr was not found in the list
|
||||
*/
|
||||
int memory_tracker_remove(size_t addr)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!memory_tracker_lock_mutex())
|
||||
{
|
||||
struct mem_block *p;
|
||||
|
||||
if (p = memory_tracker_find(addr))
|
||||
{
|
||||
memtrack.current_allocated -= p->size;
|
||||
|
||||
p->prev->next = p->next;
|
||||
|
||||
if (p->next)
|
||||
p->next->prev = p->prev;
|
||||
else
|
||||
memtrack.tail = p->prev;
|
||||
|
||||
ret = 0;
|
||||
MEM_TRACK_FREE(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrack_log("memory_tracker_remove(): addr not found in list, 0x%.8x\n", addr);
|
||||
ret = -2;
|
||||
}
|
||||
|
||||
memory_tracker_unlock_mutex();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_find(size_t addr)
|
||||
Finds an address in our addrs list
|
||||
NOTE: the mutex MUST be locked in the other internal
|
||||
functions before calling this one. This avoids
|
||||
the need for repeated locking and unlocking as in Remove
|
||||
Returns: pointer to the mem block if found, NULL otherwise
|
||||
*/
|
||||
static struct mem_block *memory_tracker_find(size_t addr)
|
||||
{
|
||||
struct mem_block *p = NULL;
|
||||
|
||||
if (memtrack.head)
|
||||
{
|
||||
p = memtrack.head->next;
|
||||
|
||||
while (p && (p->addr != addr))
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(NO_MUTEX)
|
||||
/*
|
||||
memory_tracker_lock_mutex()
|
||||
Locks the memory tracker mutex with a platform specific call
|
||||
Returns:
|
||||
0: Success
|
||||
<0: Failure, either the mutex was not initialized
|
||||
or the call to lock the mutex failed
|
||||
*/
|
||||
static int memory_tracker_lock_mutex()
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (g_b_mem_tracker_inited)
|
||||
{
|
||||
|
||||
#if defined(LINUX) || defined(__uClinux__)
|
||||
ret = pthread_mutex_lock(&memtrack.mutex);
|
||||
#elif defined(WIN32) || defined(_WIN32_WCE)
|
||||
ret = WaitForSingleObject(memtrack.mutex, INFINITE);
|
||||
#elif defined(VXWORKS)
|
||||
ret = sem_take(memtrack.mutex, WAIT_FOREVER);
|
||||
#elif defined(NDS_NITRO)
|
||||
os_lock_mutex(&memtrack.mutex);
|
||||
ret = 0;
|
||||
#endif
|
||||
|
||||
if (ret)
|
||||
{
|
||||
memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
memory_tracker_unlock_mutex()
|
||||
Unlocks the memory tracker mutex with a platform specific call
|
||||
Returns:
|
||||
0: Success
|
||||
<0: Failure, either the mutex was not initialized
|
||||
or the call to unlock the mutex failed
|
||||
*/
|
||||
static int memory_tracker_unlock_mutex()
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (g_b_mem_tracker_inited)
|
||||
{
|
||||
|
||||
#if defined(LINUX) || defined(__uClinux__)
|
||||
ret = pthread_mutex_unlock(&memtrack.mutex);
|
||||
#elif defined(WIN32) || defined(_WIN32_WCE)
|
||||
ret = !release_mutex(memtrack.mutex);
|
||||
#elif defined(VXWORKS)
|
||||
ret = sem_give(memtrack.mutex);
|
||||
#elif defined(NDS_NITRO)
|
||||
os_unlock_mutex(&memtrack.mutex);
|
||||
ret = 0;
|
||||
#endif
|
||||
|
||||
if (ret)
|
||||
{
|
||||
memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
vpx_memory_tracker_set_functions
|
||||
|
||||
Sets the function pointers for the standard library functions.
|
||||
|
||||
Return:
|
||||
0: on success
|
||||
-1: if the use global function pointers is not set.
|
||||
*/
|
||||
int vpx_memory_tracker_set_functions(mem_track_malloc_func g_malloc_l
|
||||
, mem_track_calloc_func g_calloc_l
|
||||
, mem_track_realloc_func g_realloc_l
|
||||
, mem_track_free_func g_free_l
|
||||
, mem_track_memcpy_func g_memcpy_l
|
||||
, mem_track_memset_func g_memset_l
|
||||
, mem_track_memmove_func g_memmove_l)
|
||||
{
|
||||
#if USE_GLOBAL_FUNCTION_POINTERS
|
||||
|
||||
if (g_malloc_l)
|
||||
g_malloc = g_malloc_l;
|
||||
|
||||
if (g_calloc_l)
|
||||
g_calloc = g_calloc_l;
|
||||
|
||||
if (g_realloc_l)
|
||||
g_realloc = g_realloc_l;
|
||||
|
||||
if (g_free_l)
|
||||
g_free = g_free_l;
|
||||
|
||||
if (g_memcpy_l)
|
||||
g_memcpy = g_memcpy_l;
|
||||
|
||||
if (g_memset_l)
|
||||
g_memset = g_memset_l;
|
||||
|
||||
if (g_memmove_l)
|
||||
g_memmove = g_memmove_l;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)g_malloc_l;
|
||||
(void)g_calloc_l;
|
||||
(void)g_realloc_l;
|
||||
(void)g_free_l;
|
||||
(void)g_memcpy_l;
|
||||
(void)g_memset_l;
|
||||
(void)g_memmove_l;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#define __VPX_MEM_C__
|
||||
#include "vpx_mem.h"
|
||||
#include <nitro.h>
|
||||
#include "vpx_mem_intrnl.h"
|
||||
|
||||
// Allocate memory from the Arena specified by id. Align it to
|
||||
// the value specified by align.
|
||||
void *vpx_mem_nds_alloc(osarena_id id, osheap_handle handle, size_t size, size_t align)
|
||||
{
|
||||
void *addr,
|
||||
* x = NULL;
|
||||
|
||||
addr = os_alloc_from_heap((osarena_id) id, handle,
|
||||
size + align - 1 + ADDRESS_STORAGE_SIZE);
|
||||
|
||||
if (addr)
|
||||
{
|
||||
x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
|
||||
|
||||
// save the actual malloc address
|
||||
((size_t *)x)[-1] = (size_t)addr;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
// Free them memory allocated by vpx_mem_nds_alloc
|
||||
void vpx_mem_nds_free(osarena_id id, osheap_handle handle, void *mem)
|
||||
{
|
||||
if (mem)
|
||||
{
|
||||
void *addr = (void *)(((size_t *)mem)[-1]);
|
||||
os_free_to_heap(id, handle, addr);
|
||||
}
|
||||
}
|
||||
|
||||
int vpx_nds_alloc_heap(osarena_id id, u32 size)
|
||||
{
|
||||
osheap_handle arena_handle;
|
||||
void *nstart;
|
||||
void *heap_start;
|
||||
|
||||
nstart = os_init_alloc(id, os_get_arena_lo(id), os_get_arena_hi(id), 1);
|
||||
os_set_arena_lo(id, nstart);
|
||||
|
||||
heap_start = os_alloc_from_arena_lo(id, size, 32);
|
||||
arena_handle = os_create_heap(id, heap_start, (void *)((u32)heap_start + size));
|
||||
|
||||
if (os_check_heap(id, arena_handle) == -1)
|
||||
return -1; //ERROR: DTCM heap is not consistent
|
||||
|
||||
(void)os_set_current_heap(id, arena_handle);
|
||||
|
||||
return arena_handle;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
#define __VPX_MEM_C__
|
||||
|
||||
#include "..\include\vpx_mem.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "..\include\vpx_mem_intrnl.h"
|
||||
|
||||
void *vpx_mem_alloc(int id, size_t size, size_t align)
|
||||
{
|
||||
#if defined CHIP_DM642 || defined __uClinux__
|
||||
void *mem = (void *)mem_alloc(id, size, align);
|
||||
|
||||
if (!mem)
|
||||
{
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"*********************************************************\n"
|
||||
"WARNING: mem_alloc returned 0 for id=%p size=%u align=%u.\n"
|
||||
"*********************************************************\n",
|
||||
mem, size, align));
|
||||
// should no longer need this. Softier says it's fixed. 2005-01-21 tjf
|
||||
//#if defined __uClinux__
|
||||
//while(1)usleep(1000000);
|
||||
//#endif
|
||||
}
|
||||
|
||||
#if defined __uClinux__
|
||||
else if (mem == (void *)0xFFFFFFFF)
|
||||
{
|
||||
// out of memory/error
|
||||
mem = (void *)0;
|
||||
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"******************************************************\n"
|
||||
"ERROR: mem_alloc id=%p size=%u align=%u OUT OF MEMORY.\n"
|
||||
"******************************************************\n",
|
||||
mem, size, align));
|
||||
}
|
||||
|
||||
#endif // __uClinux__
|
||||
|
||||
return mem;
|
||||
#else
|
||||
(void)id;
|
||||
(void)size;
|
||||
(void)align;
|
||||
return (void *)0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void vpx_mem_free(int id, void *mem, size_t size)
|
||||
{
|
||||
#if defined CHIP_DM642 || defined __uClinux__
|
||||
|
||||
if (!mem)
|
||||
{
|
||||
_P(fprintf(stderr,
|
||||
"\n"
|
||||
"**************************************\n"
|
||||
"WARNING: 0 being free'd id=%p size=%u.\n"
|
||||
"**************************************\n",
|
||||
id, size));
|
||||
|
||||
// should no longer need this. Softier says it's fixed. 2005-01-21 tjf
|
||||
//#if defined __uClinux__
|
||||
//while(1)usleep(1000000);
|
||||
//#endif
|
||||
}
|
||||
|
||||
mem_free(id, mem, size);
|
||||
#else
|
||||
(void)id;
|
||||
(void)mem;
|
||||
(void)size;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_MEM_TRACKER
|
||||
void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line)
|
||||
{
|
||||
void *mem = vpx_mem_alloc(id, size, align);
|
||||
|
||||
vpx_memory_tracker_add((size_t)mem, size, file, line, 0);
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line)
|
||||
{
|
||||
if (vpx_memory_tracker_remove((size_t)mem) == -2)
|
||||
{
|
||||
#if REMOVE_PRINTFS
|
||||
(void)file;
|
||||
(void)line;
|
||||
#endif
|
||||
_P(fprintf(stderr, "[vpx_mem][xvpx_mem_free] addr: %p (id=%p size=%u) "
|
||||
"not found in list; freed from file:%s"
|
||||
" line:%d\n", mem, id, size, file, line));
|
||||
}
|
||||
|
||||
vpx_mem_free(id, mem, size);
|
||||
}
|
||||
#endif /*CONFIG_MEM_TRACKER*/
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : yv12config.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
#include <cdef_bf533.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
****************************************************************************/
|
||||
void
|
||||
extend_memset(void *dst, unsigned char value, unsigned int size);
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
int
|
||||
vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
if (ybf)
|
||||
{
|
||||
duck_free(ybf->buffer_alloc);
|
||||
|
||||
ybf->buffer_alloc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
int
|
||||
vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border)
|
||||
{
|
||||
//NOTE:
|
||||
|
||||
int yplane_size = (height + 2 * border) * (width + 2 * border);
|
||||
int uvplane_size = (height / 2 + border) * (width / 2 + border);
|
||||
|
||||
if (ybf)
|
||||
{
|
||||
vp8_yv12_de_alloc_frame_buffer(ybf);
|
||||
|
||||
ybf->y_width = width;
|
||||
ybf->y_height = height;
|
||||
ybf->y_stride = width + 2 * border;
|
||||
|
||||
ybf->uv_width = width / 2;
|
||||
ybf->uv_height = height / 2;
|
||||
ybf->uv_stride = ybf->uv_width + border;
|
||||
|
||||
ybf->border = border;
|
||||
|
||||
// Added 2 extra lines to framebuffer so that copy12x12 doesn't fail
|
||||
// when we have a large motion vector in V on the last v block.
|
||||
// Note : We never use these pixels anyway so this doesn't hurt.
|
||||
ybf->buffer_alloc = (unsigned char *) duck_memalign(32, (yplane_size * 3 / 2) + ybf->y_stride , 0);
|
||||
|
||||
if (ybf->buffer_alloc == NULL)
|
||||
return -1;
|
||||
|
||||
ybf->y_buffer = ybf->buffer_alloc + border * ybf->y_stride + border;
|
||||
ybf->u_buffer = ybf->buffer_alloc + yplane_size + border / 2 * ybf->uv_stride + border / 2;
|
||||
ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + border / 2 * ybf->uv_stride + border / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
int
|
||||
vp8_yv12_black_frame_buffer(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
if (ybf)
|
||||
{
|
||||
if (ybf->buffer_alloc)
|
||||
{
|
||||
extend_memset(ybf->y_buffer, 0x0, ybf->y_stride *(ybf->y_height + 2 * ybf->border));
|
||||
extend_memset(ybf->u_buffer, 0x80, ybf->uv_stride *(ybf->uv_height + ybf->border));
|
||||
extend_memset(ybf->v_buffer, 0x80, ybf->uv_stride *(ybf->uv_height + ybf->border));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
@ -1,350 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : yv12extend.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include <cdef_bf533.h>
|
||||
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
extend_memset(void *dst, unsigned char value, unsigned int size)
|
||||
{
|
||||
#if 0
|
||||
unsigned int quad_value;
|
||||
|
||||
quad_value = (unsigned int) value;
|
||||
quad_value |= (unsigned int) value << 8;
|
||||
quad_value |= (unsigned int) value << 16;
|
||||
quad_value |= (unsigned int) value << 24;
|
||||
#else
|
||||
unsigned short quad_value;
|
||||
|
||||
quad_value = (unsigned int) value;
|
||||
quad_value |= (unsigned int) value << 8;
|
||||
#endif
|
||||
|
||||
|
||||
if (size / 2 >= 64 * 1024)
|
||||
printf("_Extend_memset__________ dma memset is broken\n");
|
||||
|
||||
*p_mdma_s1_start_addr = &quad_value;
|
||||
*p_mdma_s1_x_count = size / 2;
|
||||
*p_mdma_s1_x_modify = 0x0;
|
||||
*p_mdma_d1_start_addr = dst;
|
||||
*p_mdma_d1_x_count = size / 2;
|
||||
*p_mdma_d1_x_modify = 2;
|
||||
|
||||
*p_mdma_s1_config = DMAEN | WDSIZE_16;
|
||||
asm("ssync;");
|
||||
|
||||
*p_mdma_d1_config = DI_EN | DMAEN | WNR | WDSIZE_16;
|
||||
asm("ssync;");
|
||||
|
||||
while ((*p_mdma_d1_irq_status & DMA_DONE) == 0);
|
||||
|
||||
*p_mdma_d1_irq_status |= DMA_DONE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
extend_memcpy(void *dst, void *src, unsigned int size)
|
||||
{
|
||||
if (size / 2 >= 64 * 1024)
|
||||
printf("_Extend_memcpy__________ dma memcpy is broken\n");
|
||||
|
||||
|
||||
if ((size & 0x3))
|
||||
printf("_)__________ size not a multiple of 4\n");
|
||||
|
||||
//32 bit dma here caused some data to be corrupted --- WHY ??????
|
||||
|
||||
*p_mdma_s1_start_addr = src;
|
||||
*p_mdma_s1_x_count = size / 2;
|
||||
*p_mdma_s1_x_modify = 2;
|
||||
*p_mdma_d1_start_addr = dst;
|
||||
*p_mdma_d1_x_count = size / 2;
|
||||
*p_mdma_d1_x_modify = 2;
|
||||
|
||||
*p_mdma_s1_config = DMAEN | WDSIZE_16;
|
||||
asm("ssync;");
|
||||
|
||||
*p_mdma_d1_config = DI_EN | DMAEN | WNR | WDSIZE_16;
|
||||
asm("ssync;");
|
||||
|
||||
while ((*p_mdma_d1_irq_status & DMA_DONE) == 0);
|
||||
|
||||
*p_mdma_d1_irq_status |= DMA_DONE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
#if 1
|
||||
int i;
|
||||
unsigned char *src_ptr1, *src_ptr2;
|
||||
unsigned char *dest_ptr1, *dest_ptr2;
|
||||
|
||||
unsigned int Border;
|
||||
int plane_stride;
|
||||
int plane_height;
|
||||
int plane_width;
|
||||
|
||||
unsigned int quad_sample;
|
||||
unsigned int sample;
|
||||
|
||||
/***********/
|
||||
/* Y Plane */
|
||||
/***********/
|
||||
Border = ybf->border;
|
||||
plane_stride = ybf->y_stride;
|
||||
plane_height = ybf->y_height;
|
||||
plane_width = ybf->y_width;
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->y_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
extend_memset(dest_ptr1, src_ptr1[0], Border);
|
||||
extend_memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->y_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)Border; i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)Border; i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
plane_stride /= 2;
|
||||
plane_height /= 2;
|
||||
plane_width /= 2;
|
||||
Border /= 2;
|
||||
|
||||
/***********/
|
||||
/* U Plane */
|
||||
/***********/
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->u_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
extend_memset(dest_ptr1, src_ptr1[0], Border);
|
||||
extend_memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->u_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* V Plane */
|
||||
/***********/
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->v_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
extend_memset(dest_ptr1, src_ptr1[0], Border);
|
||||
extend_memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->v_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
extend_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_yv12_copy_frame
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies the source image into the destination image and
|
||||
* updates the destination's UMV borders.
|
||||
*
|
||||
* SPECIAL NOTES : The frames are assumed to be identical in size.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
|
||||
{
|
||||
#if 1
|
||||
int row;
|
||||
unsigned char *source, *dest;
|
||||
|
||||
source = src_ybc->y_buffer;
|
||||
dest = dst_ybc->y_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->y_height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, src_ybc->y_width);
|
||||
source += src_ybc->y_stride;
|
||||
dest += dst_ybc->y_stride;
|
||||
}
|
||||
|
||||
source = src_ybc->u_buffer;
|
||||
dest = dst_ybc->u_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->uv_height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, src_ybc->uv_width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
source = src_ybc->v_buffer;
|
||||
dest = dst_ybc->v_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->uv_height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, src_ybc->uv_width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
vp8_yv12_extend_frame_borders(dst_ybc);
|
||||
|
||||
#else
|
||||
int row;
|
||||
char *source, *dest;
|
||||
int height;
|
||||
int width;
|
||||
|
||||
height = src_ybc->y_height + (src_ybc->border * 2);
|
||||
width = src_ybc->y_width + (src_ybc->border * 2);
|
||||
source = src_ybc->y_buffer;
|
||||
dest = dst_ybc->y_buffer;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, width);
|
||||
source += src_ybc->y_stride;
|
||||
dest += dst_ybc->y_stride;
|
||||
}
|
||||
|
||||
height = src_ybc->uv_height + (src_ybc->border);
|
||||
width = src_ybc->uv_width + (src_ybc->border);
|
||||
|
||||
source = src_ybc->u_buffer;
|
||||
dest = dst_ybc->u_buffer;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
source = src_ybc->v_buffer;
|
||||
dest = dst_ybc->v_buffer;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
extend_memcpy(dest, source, width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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 <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vpxscale_arbitrary.h"
|
||||
|
||||
extern BICUBIC_SCALER_STRUCT g_b_scaler;
|
||||
|
||||
int bicubic_scale_c64(int in_width, int in_height, int in_stride,
|
||||
int out_width, int out_height, int out_stride,
|
||||
unsigned char *input_image, unsigned char *output_image)
|
||||
{
|
||||
short *restrict l_w, * restrict l_h;
|
||||
short *restrict c_w, * restrict c_h;
|
||||
unsigned char *restrict ip, * restrict op, *restrict op_w;
|
||||
unsigned char *restrict hbuf;
|
||||
int h, w, lw, lh;
|
||||
int phase_offset_w, phase_offset_h;
|
||||
double coeff;
|
||||
int max_phase;
|
||||
|
||||
c_w = g_b_scaler.c_w;
|
||||
c_h = g_b_scaler.c_h;
|
||||
|
||||
op = output_image;
|
||||
|
||||
l_w = g_b_scaler.l_w;
|
||||
l_h = g_b_scaler.l_h;
|
||||
|
||||
phase_offset_h = 0;
|
||||
|
||||
for (h = 0; h < out_height; h++)
|
||||
{
|
||||
// select the row to work on
|
||||
lh = l_h[h];
|
||||
ip = input_image + (in_stride * lh);
|
||||
|
||||
coeff = _memd8_const(&c_h[phase_offset_h*4]);
|
||||
|
||||
// vp8_filter the row vertically into an temporary buffer.
|
||||
// If the phase offset == 0 then all the multiplication
|
||||
// is going to result in the output equalling the input.
|
||||
// So instead point the temporary buffer to the input.
|
||||
// Also handle the boundry condition of not being able to
|
||||
// filter that last lines.
|
||||
if (phase_offset_h && (lh < in_height - 2))
|
||||
{
|
||||
hbuf = g_b_scaler.hbuf;
|
||||
|
||||
for (w = 0; w < in_width; w += 4)
|
||||
{
|
||||
int ip1, ip2, ip3, ip4;
|
||||
int y13_12, y11_10, y23_22, y21_20, y33_32, y31_30, y43_42, y41_40;
|
||||
int y10_20, y11_21, y12_22, y13_23, y30_40, y31_41, y32_42, y33_43;
|
||||
int s1, s2, s3, s4;
|
||||
|
||||
ip1 = _mem4_const(&ip[w - in_stride]);
|
||||
ip2 = _mem4_const(&ip[w]);
|
||||
ip3 = _mem4_const(&ip[w + in_stride]);
|
||||
ip4 = _mem4_const(&ip[w + 2*in_stride]);
|
||||
|
||||
// realignment of data. Unpack the data so that it is in short
|
||||
// format instead of bytes.
|
||||
y13_12 = _unpkhu4(ip1);
|
||||
y11_10 = _unpklu4(ip1);
|
||||
y23_22 = _unpkhu4(ip2);
|
||||
y21_20 = _unpklu4(ip2);
|
||||
y33_32 = _unpkhu4(ip3);
|
||||
y31_30 = _unpklu4(ip3);
|
||||
y43_42 = _unpkhu4(ip4);
|
||||
y41_40 = _unpklu4(ip4);
|
||||
|
||||
// repack the data so that elements 1 and 2 are together. this
|
||||
// lines up so that a dot product with the coefficients can be
|
||||
// done.
|
||||
y10_20 = _pack2(y11_10, y21_20);
|
||||
y11_21 = _packh2(y11_10, y21_20);
|
||||
y12_22 = _pack2(y13_12, y23_22);
|
||||
y13_23 = _packh2(y13_12, y23_22);
|
||||
|
||||
s1 = _dotp2(_hi(coeff), y10_20);
|
||||
s2 = _dotp2(_hi(coeff), y11_21);
|
||||
s3 = _dotp2(_hi(coeff), y12_22);
|
||||
s4 = _dotp2(_hi(coeff), y13_23);
|
||||
|
||||
y30_40 = _pack2(y31_30, y41_40);
|
||||
y31_41 = _packh2(y31_30, y41_40);
|
||||
y32_42 = _pack2(y33_32, y43_42);
|
||||
y33_43 = _packh2(y33_32, y43_42);
|
||||
|
||||
// now repack elements 3 and 4 together.
|
||||
s1 += _dotp2(_lo(coeff), y30_40);
|
||||
s2 += _dotp2(_lo(coeff), y31_41);
|
||||
s3 += _dotp2(_lo(coeff), y32_42);
|
||||
s4 += _dotp2(_lo(coeff), y33_43);
|
||||
|
||||
s1 = s1 >> 12;
|
||||
s2 = s2 >> 12;
|
||||
s3 = s3 >> 12;
|
||||
s4 = s4 >> 12;
|
||||
|
||||
s1 = _pack2(s2, s1);
|
||||
s2 = _pack2(s4, s3);
|
||||
|
||||
_amem4(&hbuf[w]) = _spacku4(s2, s1);
|
||||
}
|
||||
}
|
||||
else
|
||||
hbuf = ip;
|
||||
|
||||
// increase the phase offset for the next time around.
|
||||
if (++phase_offset_h >= g_b_scaler.nh)
|
||||
phase_offset_h = 0;
|
||||
|
||||
op_w = op;
|
||||
|
||||
// will never be able to interpolate first pixel, so just copy it
|
||||
// over here.
|
||||
phase_offset_w = 1;
|
||||
*op_w++ = hbuf[0];
|
||||
|
||||
if (1 >= g_b_scaler.nw) phase_offset_w = 0;
|
||||
|
||||
max_phase = g_b_scaler.nw;
|
||||
|
||||
for (w = 1; w < out_width; w++)
|
||||
{
|
||||
double coefficients;
|
||||
int hbuf_high, hbuf_low, hbuf_both;
|
||||
int sum_high, sum_low, sum;
|
||||
|
||||
// get the index to use to expand the image
|
||||
lw = l_w[w];
|
||||
coefficients = _amemd8_const(&c_w[phase_offset_w*4]);
|
||||
hbuf_both = _mem4_const(&hbuf[lw-1]);
|
||||
|
||||
hbuf_high = _unpkhu4(hbuf_both);
|
||||
hbuf_low = _unpklu4(hbuf_both);
|
||||
|
||||
sum_high = _dotp2(_hi(coefficients), hbuf_high);
|
||||
sum_low = _dotp2(_lo(coefficients), hbuf_low);
|
||||
|
||||
sum = (sum_high + sum_low) >> 12;
|
||||
|
||||
if (++phase_offset_w >= max_phase)
|
||||
phase_offset_w = 0;
|
||||
|
||||
if ((lw + 2) >= in_width)
|
||||
sum = hbuf[lw];
|
||||
|
||||
*op_w++ = sum;
|
||||
}
|
||||
|
||||
op += out_stride;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bicubic_scale_frame_c64(YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
|
||||
int new_width, int new_height)
|
||||
{
|
||||
|
||||
dst->y_width = new_width;
|
||||
dst->y_height = new_height;
|
||||
dst->uv_width = new_width / 2;
|
||||
dst->uv_height = new_height / 2;
|
||||
|
||||
dst->y_stride = dst->y_width;
|
||||
dst->uv_stride = dst->uv_width;
|
||||
|
||||
bicubic_scale_c64(src->y_width, src->y_height, src->y_stride,
|
||||
new_width, new_height, dst->y_stride,
|
||||
src->y_buffer, dst->y_buffer);
|
||||
|
||||
bicubic_scale_c64(src->uv_width, src->uv_height, src->uv_stride,
|
||||
new_width / 2, new_height / 2, dst->uv_stride,
|
||||
src->u_buffer, dst->u_buffer);
|
||||
|
||||
bicubic_scale_c64(src->uv_width, src->uv_height, src->uv_stride,
|
||||
new_width / 2, new_height / 2, dst->uv_stride,
|
||||
src->v_buffer, dst->v_buffer);
|
||||
}
|
@ -1,608 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : gen_scalers.c
|
||||
*
|
||||
* Description : Generic image scaling functions.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : horizontal_line_4_5_scale_c4
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 4 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void horizontal_line_4_5_scale_c64
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned int ba, cb, dc, ed;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned int *restrict src = (unsigned int *)source;
|
||||
unsigned int const_51_205, const_102_154,
|
||||
const_205_51, const_154_102;
|
||||
|
||||
unsigned int src_current, src_next;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
// Constants that are to be used for the filtering. For
|
||||
// best speed we are going to want to right shift by 16.
|
||||
// In the generic version they were shift by 8, so put
|
||||
// an extra 8 in now so that 16 will come out later.
|
||||
const_51_205 = 0x3300CD00; //_pack2 (51 << 8, 205 << 8);
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_102_154 = 0x66009A00; //_pack2 (102 << 8, 154 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
// 5 points are needed to filter to give 5 output points.
|
||||
// A load can pull up 4 at a time, and one needs to be
|
||||
// "borrowed" from the next set of data. So instead of
|
||||
// loading those 5 points each time, "steal" a point from
|
||||
// the next set and only load up 4 each time through.
|
||||
src_current = _mem4(src);
|
||||
|
||||
for (i = 0; i < source_width - 4; i += 4)
|
||||
{
|
||||
src_next = _mem4(src++);
|
||||
|
||||
// Reorder the data so that it is ready for the
|
||||
// dot product.
|
||||
ba = _unpklu4(src_current);
|
||||
cb = _unpkhu4(_rotl(src_current, 8));
|
||||
dc = _unpkhu4(src_current);
|
||||
ed = _unpkhu4(_shrmb(src_next, src_current));
|
||||
|
||||
// Use the dot product with round and shift.
|
||||
des [0] = src_current & 0xff;
|
||||
des [1] = _dotprsu2(ba, const_205_51);
|
||||
des [2] = _dotprsu2(cb, const_154_102);
|
||||
des [3] = _dotprsu2(dc, const_102_154);
|
||||
des [4] = _dotprsu2(ed, const_51_205);
|
||||
|
||||
des += 5;
|
||||
|
||||
// reuse loaded vales next time around.
|
||||
src_current = src_next;
|
||||
}
|
||||
|
||||
// vp8_filter the last set of points. Normally a point from the next set
|
||||
// would be used, but there is no next set, so just fill.
|
||||
ba = _unpklu4(src_current);
|
||||
cb = _unpkhu4(_rotl(src_current, 8));
|
||||
dc = _unpkhu4(src_current);
|
||||
|
||||
des [0] = src_current & 0xff;
|
||||
des [1] = _dotprsu2(ba, const_205_51);
|
||||
des [2] = _dotprsu2(cb, const_154_102);
|
||||
des [3] = _dotprsu2(dc, const_102_154);
|
||||
des [4] = src_current & 0xff;
|
||||
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vertical_band_4_5_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vertical_band_4_5_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d, e;
|
||||
unsigned int ba, cb, dc, ed;
|
||||
unsigned char *restrict src = dest;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned int const_51_205, const_102_154,
|
||||
const_205_51, const_154_102;
|
||||
|
||||
const_51_205 = 0x3300CD00; //_pack2 (51 << 8, 205 << 8);
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_102_154 = 0x66009A00; //_pack2 (102 << 8, 154 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
// Force a loop unroll here so that there is not such a
|
||||
// dependancy.
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*3];
|
||||
e = src [dest_pitch*5];
|
||||
src ++;
|
||||
|
||||
for (i = 0; i < dest_width; i++)
|
||||
{
|
||||
ba = _pack2(b, a);
|
||||
cb = _pack2(c, b);
|
||||
dc = _pack2(d, c);
|
||||
ed = _pack2(e, d);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*3];
|
||||
e = src [dest_pitch*5];
|
||||
src ++;
|
||||
|
||||
des [dest_pitch] = _dotprsu2(ba, const_205_51);
|
||||
des [dest_pitch*2] = _dotprsu2(cb, const_154_102);
|
||||
des [dest_pitch*3] = _dotprsu2(dc, const_102_154);
|
||||
des [dest_pitch*4] = _dotprsu2(ed, const_51_205);
|
||||
|
||||
des ++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : last_vertical_band_4_5_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void last_vertical_band_4_5_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned int ba, cb, dc;
|
||||
unsigned char *restrict src = dest;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned int const_102_154, const_205_51, const_154_102;
|
||||
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_102_154 = 0x66009A00; //_pack2 (102 << 8, 154 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*3];
|
||||
src ++;
|
||||
|
||||
for (i = 0; i < dest_width; ++i)
|
||||
{
|
||||
ba = _pack2(b, a);
|
||||
cb = _pack2(c, b);
|
||||
dc = _pack2(d, c);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*3];
|
||||
src ++;
|
||||
|
||||
des [dest_pitch] = _dotprsu2(ba, const_205_51);
|
||||
des [dest_pitch*2] = _dotprsu2(cb, const_154_102);
|
||||
des [dest_pitch*3] = _dotprsu2(dc, const_102_154);
|
||||
des [dest_pitch*4] = (unsigned char) d;
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : horizontal_line_3_5_scale_c64
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 3 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void horizontal_line_3_5_scale_c64
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int ba, cb, dc;
|
||||
unsigned int src_current;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned char *restrict src = (unsigned char *)source;
|
||||
unsigned int const_51_205, const_102_154,
|
||||
const_205_51, const_154_102;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
const_51_205 = 0x3300CD00; //_pack2 (51 << 8, 205 << 8);
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_102_154 = 0x66009A00; //_pack2 (102 << 8, 154 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
for (i = 0; i < source_width - 3; i += 3)
|
||||
{
|
||||
src_current = _mem4(src);
|
||||
|
||||
// Reorder the data so that it is ready for the
|
||||
// dot product.
|
||||
ba = _unpklu4(src_current);
|
||||
cb = _unpkhu4(_rotl(src_current, 8));
|
||||
dc = _unpkhu4(src_current);
|
||||
|
||||
des [0] = src_current & 0xff;
|
||||
des [1] = _dotprsu2(ba, const_154_102);
|
||||
des [2] = _dotprsu2(cb, const_51_205);
|
||||
des [3] = _dotprsu2(cb, const_205_51);
|
||||
des [4] = _dotprsu2(dc, const_102_154);
|
||||
|
||||
src += 3;
|
||||
des += 5;
|
||||
}
|
||||
|
||||
src_current = _mem4(src);
|
||||
|
||||
ba = _unpklu4(src_current);
|
||||
cb = _unpkhu4(_rotl(src_current, 8));
|
||||
dc = _unpkhu4(src_current);
|
||||
|
||||
|
||||
des [0] = src_current & 0xff;
|
||||
des [1] = _dotprsu2(ba, const_154_102);
|
||||
des [2] = _dotprsu2(cb, const_51_205);
|
||||
des [3] = _dotprsu2(cb, const_205_51);
|
||||
des [4] = dc & 0xff;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vertical_band_3_5_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vertical_band_3_5_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned int ba, cb, dc;
|
||||
unsigned char *restrict src = dest;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned int const_51_205, const_102_154,
|
||||
const_205_51, const_154_102;
|
||||
|
||||
const_51_205 = 0x3300CD00; //_pack2 (51 << 8, 205 << 8);
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_102_154 = 0x66009A00; //_pack2 (102 << 8, 154 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*5];
|
||||
src ++;
|
||||
|
||||
for (i = 0; i < dest_width; i++)
|
||||
{
|
||||
ba = _pack2(b, a);
|
||||
cb = _pack2(c, b);
|
||||
dc = _pack2(d, c);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
d = src [dest_pitch*5];
|
||||
src ++;
|
||||
|
||||
des [dest_pitch] = _dotprsu2(ba, const_154_102);
|
||||
des [dest_pitch*2] = _dotprsu2(cb, const_51_205);
|
||||
des [dest_pitch*3] = _dotprsu2(cb, const_205_51);
|
||||
des [dest_pitch*4] = _dotprsu2(dc, const_102_154);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : last_vertical_band_3_5_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void last_vertical_band_3_5_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned int ba, cb;
|
||||
unsigned char *restrict src = dest;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned int const_51_205, const_205_51, const_154_102;
|
||||
|
||||
const_51_205 = 0x3300CD00; //_pack2 (51 << 8, 205 << 8);
|
||||
const_205_51 = 0xCD003300; //_pack2 (205 << 8, 51 << 8);
|
||||
const_154_102 = 0x9A006600; //_pack2 (154 << 8, 102 << 8);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
src ++;
|
||||
|
||||
for (i = 0; i < dest_width; ++i)
|
||||
{
|
||||
ba = _pack2(b, a);
|
||||
cb = _pack2(c, b);
|
||||
|
||||
a = src [0];
|
||||
b = src [dest_pitch];
|
||||
c = src [dest_pitch*2];
|
||||
src ++;
|
||||
|
||||
des [dest_pitch] = _dotprsu2(ba, const_154_102);
|
||||
des [dest_pitch*2] = _dotprsu2(cb, const_51_205);
|
||||
des [dest_pitch*3] = _dotprsu2(cb, const_205_51);
|
||||
des [dest_pitch*4] = (unsigned char)(c) ;
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : horizontal_line_1_2_scale_c64
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 1 to 2.
|
||||
*
|
||||
* SPECIAL NOTES : source width must be a multiple of 4.
|
||||
*
|
||||
****************************************************************************/
|
||||
void horizontal_line_1_2_scale_c64
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *restrict des = dest;
|
||||
unsigned char *restrict src = (unsigned char *)source;
|
||||
unsigned int src7_4i, src4_1i, src3_0i;
|
||||
unsigned int a4_0i, ahi, alo;
|
||||
double src7_0d, src3_0d;
|
||||
const unsigned int k01 = 0x01010101;
|
||||
|
||||
for (i = 0; i < source_width / 4; i += 1)
|
||||
{
|
||||
// Load up the data from src. Here a wide load is
|
||||
// used to get 8 bytes at once, only 5 will be used
|
||||
// for the actual computation.
|
||||
src7_0d = _memd8(src);
|
||||
src3_0i = _lo(src7_0d);
|
||||
src7_4i = _hi(src7_0d);
|
||||
|
||||
// Need to average between points. Shift byte 5 into
|
||||
// the lower word. This will result in bytes 5-1
|
||||
// averaged with 4-0.
|
||||
src4_1i = _shrmb(src7_4i, src3_0i);
|
||||
a4_0i = _avgu4(src4_1i, src3_0i);
|
||||
|
||||
// Expand the data out. Could do an unpack, however
|
||||
// all but the multiply units are getting pretty hard
|
||||
// here the multiply unit can take some of the computations.
|
||||
src3_0d = _mpyu4(src3_0i, k01);
|
||||
|
||||
// The averages need to be unpacked so that they are in 16
|
||||
// bit form and will be able to be interleaved with the
|
||||
// original data
|
||||
ahi = _unpkhu4(a4_0i);
|
||||
alo = _unpklu4(a4_0i);
|
||||
|
||||
ahi = _swap4(ahi);
|
||||
alo = _swap4(alo);
|
||||
|
||||
// Mix the average result in with the orginal data.
|
||||
ahi = _hi(src3_0d) | ahi;
|
||||
alo = _lo(src3_0d) | alo;
|
||||
|
||||
_memd8(des) = _itod(ahi, alo);
|
||||
|
||||
des += 8;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vertical_band_1_2_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
* Destination width must be a multiple of 4. Because the
|
||||
* intput must be, therefore the output must be.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vertical_band_1_2_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned int *restrict line_a = (unsigned int *)dest;
|
||||
unsigned int *restrict line_b = (unsigned int *)(dest + (dest_pitch * 2));
|
||||
unsigned int *restrict des = (unsigned int *)(dest + dest_pitch);
|
||||
|
||||
for (i = 0; i < dest_width / 4; i++)
|
||||
{
|
||||
a = _mem4(line_a++);
|
||||
b = _mem4(line_b++);
|
||||
|
||||
_mem4(des++) = _avgu4(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : last_vertical_band_1_2_scale_c64
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band. Again, width must be a multiple of 4.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void last_vertical_band_1_2_scale_c64(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int *restrict src = (unsigned int *)dest;
|
||||
unsigned int *restrict des = (unsigned int *)(dest + dest_pitch);
|
||||
|
||||
for (i = 0; i < dest_width / 4; ++i)
|
||||
{
|
||||
_mem4(des++) = _mem4(src++);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
register_generic_scalers(void)
|
||||
{
|
||||
vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_c64;
|
||||
vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_c64;
|
||||
vp8_last_vertical_band_1_2_scale = last_vertical_band_1_2_scale_c64;
|
||||
vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_c64;
|
||||
vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_c64;
|
||||
vp8_last_vertical_band_3_5_scale = last_vertical_band_3_5_scale_c64;
|
||||
vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_c64;
|
||||
vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_c64;
|
||||
vp8_last_vertical_band_4_5_scale = last_vertical_band_4_5_scale_c64;
|
||||
}
|
@ -1,446 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : yv12extend.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
//#include <stdlib.h>
|
||||
#include "csl_dat.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
#define UINT8 unsigned char
|
||||
#define UINT32 unsigned int
|
||||
|
||||
|
||||
static inline
|
||||
void copy_yleft_right_border(
|
||||
UINT8 *restrict src_ptr1,
|
||||
UINT8 *restrict src_ptr2,
|
||||
UINT8 *restrict dest_ptr1,
|
||||
UINT8 *restrict dest_ptr2,
|
||||
UINT32 plane_height,
|
||||
UINT32 plane_stride
|
||||
)
|
||||
{
|
||||
UINT32 left, right, left2, left4, right2, right4;
|
||||
double dl, dr;
|
||||
int i;
|
||||
|
||||
#pragma MUST_ITERATE(16,16,16)
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
left = src_ptr1[0];
|
||||
right = src_ptr2[0];
|
||||
|
||||
left2 = _pack2(left, left);
|
||||
left4 = _packl4(left2, left2);
|
||||
|
||||
right2 = _pack2(right, right);
|
||||
right4 = _packl4(right2, right2);
|
||||
|
||||
dl = _itod(left4, left4);
|
||||
dr = _itod(right4, right4);
|
||||
|
||||
_amemd8(&dest_ptr1[ 0]) = dl;
|
||||
_amemd8(&dest_ptr2[ 0]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[ 8]) = dl;
|
||||
_amemd8(&dest_ptr2[ 8]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[16]) = dl;
|
||||
_amemd8(&dest_ptr2[16]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[24]) = dl;
|
||||
_amemd8(&dest_ptr2[24]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[32]) = dl;
|
||||
_amemd8(&dest_ptr2[32]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[40]) = dl;
|
||||
_amemd8(&dest_ptr2[40]) = dr;
|
||||
|
||||
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void copy_uvleft_right_border(
|
||||
UINT8 *restrict src_ptr1,
|
||||
UINT8 *restrict src_ptr2,
|
||||
UINT8 *restrict dest_ptr1,
|
||||
UINT8 *restrict dest_ptr2,
|
||||
UINT32 plane_height,
|
||||
UINT32 plane_stride
|
||||
)
|
||||
{
|
||||
UINT32 left, right, left2, left4, right2, right4;
|
||||
double dl, dr;
|
||||
int i;
|
||||
|
||||
#pragma MUST_ITERATE(8,8 ,8)
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
left = src_ptr1[0];
|
||||
right = src_ptr2[0];
|
||||
|
||||
left2 = _pack2(left, left);
|
||||
left4 = _packl4(left2, left2);
|
||||
|
||||
right2 = _pack2(right, right);
|
||||
right4 = _packl4(right2, right2);
|
||||
|
||||
dl = _itod(left4, left4);
|
||||
dr = _itod(right4, right4);
|
||||
|
||||
_amemd8(&dest_ptr1[ 0]) = dl;
|
||||
_amemd8(&dest_ptr2[ 0]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[ 8]) = dl;
|
||||
_amemd8(&dest_ptr2[ 8]) = dr;
|
||||
|
||||
_amemd8(&dest_ptr1[16]) = dl;
|
||||
_amemd8(&dest_ptr2[16]) = dr;
|
||||
|
||||
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
int i;
|
||||
unsigned char *src_ptr1, *src_ptr2;
|
||||
unsigned char *dest_ptr1, *dest_ptr2;
|
||||
|
||||
unsigned int Border;
|
||||
int plane_stride;
|
||||
int plane_height;
|
||||
int plane_width;
|
||||
|
||||
/***********/
|
||||
/* Y Plane */
|
||||
/***********/
|
||||
Border = ybf->border;
|
||||
plane_stride = ybf->y_stride;
|
||||
plane_height = ybf->y_height;
|
||||
plane_width = ybf->y_width;
|
||||
|
||||
#if 1
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->y_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
copy_yleft_right_border(src_ptr1, src_ptr2, dest_ptr1, dest_ptr2, plane_height, plane_stride);
|
||||
#endif
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->y_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)Border; i++)
|
||||
{
|
||||
vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
plane_stride /= 2;
|
||||
plane_height /= 2;
|
||||
plane_width /= 2;
|
||||
Border /= 2;
|
||||
|
||||
/***********/
|
||||
/* U Plane */
|
||||
/***********/
|
||||
#if 1
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->u_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
copy_uvleft_right_border(src_ptr1, src_ptr2, dest_ptr1, dest_ptr2, plane_height, plane_stride);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->u_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* V Plane */
|
||||
/***********/
|
||||
#if 1
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->v_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
copy_uvleft_right_border(src_ptr1, src_ptr2, dest_ptr1, dest_ptr2, plane_height, plane_stride);
|
||||
|
||||
#endif
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->v_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
vpx_memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
vpx_memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vpxyv12_extend_frame_tbborders(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
int i;
|
||||
unsigned char *src_ptr1, *src_ptr2;
|
||||
unsigned char *dest_ptr1, *dest_ptr2;
|
||||
int tid1, tid2;
|
||||
|
||||
unsigned int Border;
|
||||
int plane_stride;
|
||||
int plane_height;
|
||||
int plane_width;
|
||||
|
||||
/***********/
|
||||
/* Y Plane */
|
||||
/***********/
|
||||
Border = ybf->border;
|
||||
plane_stride = ybf->y_stride;
|
||||
plane_height = ybf->y_height;
|
||||
plane_width = ybf->y_width;
|
||||
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->y_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
|
||||
for (i = 0; i < (int)Border; i++)
|
||||
{
|
||||
dat_copy(src_ptr1, dest_ptr1, plane_stride);
|
||||
dat_copy(src_ptr2, dest_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
plane_stride /= 2;
|
||||
plane_height /= 2;
|
||||
plane_width /= 2;
|
||||
Border /= 2;
|
||||
|
||||
/***********/
|
||||
/* U Plane */
|
||||
/***********/
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->u_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
dat_copy(src_ptr1, dest_ptr1, plane_stride);
|
||||
dat_copy(src_ptr2, dest_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* V Plane */
|
||||
/***********/
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->v_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
tid1 = dat_copy(src_ptr1, dest_ptr1, plane_stride);
|
||||
tid2 = dat_copy(src_ptr2, dest_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
dat_wait(tid1);
|
||||
dat_wait(tid2);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_yv12_copy_frame
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies the source image into the destination image and
|
||||
* updates the destination's UMV borders. Because the
|
||||
* borders have been update prior to this so the whole frame
|
||||
* is copied, borders and all. This is also to circumvent
|
||||
* using copy_left_right Border functions when copying data
|
||||
* between L2 and main memory. When that occurs a cache
|
||||
* clean needs to be done, which would require invalidating
|
||||
* an entire frame.
|
||||
*
|
||||
* SPECIAL NOTES : The frames are assumed to be identical in size.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vpxyv12_copy_frame_dma(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
|
||||
{
|
||||
int yheight, uv_height;
|
||||
int ystride, uv_stride;
|
||||
int border;
|
||||
int yoffset, uvoffset;
|
||||
|
||||
border = src_ybc->border;
|
||||
yheight = src_ybc->y_height;
|
||||
uv_height = src_ybc->uv_height;
|
||||
|
||||
ystride = src_ybc->y_stride;
|
||||
uv_stride = src_ybc->uv_stride;
|
||||
|
||||
yoffset = border * (ystride + 1);
|
||||
uvoffset = border / 2 * (uv_stride + 1);
|
||||
|
||||
dat_copy2d(DAT_2D2D,
|
||||
src_ybc->y_buffer - yoffset,
|
||||
dst_ybc->y_buffer - yoffset,
|
||||
ystride,
|
||||
yheight + 2 * border,
|
||||
ystride);
|
||||
dat_copy2d(DAT_2D2D,
|
||||
src_ybc->u_buffer - uvoffset,
|
||||
dst_ybc->u_buffer - uvoffset,
|
||||
uv_stride,
|
||||
uv_height + border,
|
||||
uv_stride);
|
||||
dat_copy2d(DAT_2D2D,
|
||||
src_ybc->v_buffer - uvoffset,
|
||||
dst_ybc->v_buffer - uvoffset,
|
||||
uv_stride,
|
||||
uv_height + border,
|
||||
uv_stride);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_yv12_copy_frame
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies the source image into the destination image and
|
||||
* updates the destination's UMV borders.
|
||||
*
|
||||
* SPECIAL NOTES : The frames are assumed to be identical in size.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
|
||||
{
|
||||
int row;
|
||||
unsigned char *source, *dest;
|
||||
|
||||
source = src_ybc->y_buffer;
|
||||
dest = dst_ybc->y_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->y_height; row++)
|
||||
{
|
||||
vpx_memcpy(dest, source, src_ybc->y_width);
|
||||
source += src_ybc->y_stride;
|
||||
dest += dst_ybc->y_stride;
|
||||
}
|
||||
|
||||
source = src_ybc->u_buffer;
|
||||
dest = dst_ybc->u_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->uv_height; row++)
|
||||
{
|
||||
vpx_memcpy(dest, source, src_ybc->uv_width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
source = src_ybc->v_buffer;
|
||||
dest = dst_ybc->v_buffer;
|
||||
|
||||
for (row = 0; row < src_ybc->uv_height; row++)
|
||||
{
|
||||
vpx_memcpy(dest, source, src_ybc->uv_width);
|
||||
source += src_ybc->uv_stride;
|
||||
dest += dst_ybc->uv_stride;
|
||||
}
|
||||
|
||||
vp8_yv12_extend_frame_borders(dst_ybc);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : postp.h
|
||||
*
|
||||
* Description : Post processor interface
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef VPXSCALE_H
|
||||
#define VPXSCALE_H
|
||||
|
||||
|
||||
// fwg 2004-10-14
|
||||
typedef void (*vpxvertical_band_4_5_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
typedef void (*vpxlast_vertical_band_4_5_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
typedef void (*vpxvertical_band_3_5_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
typedef void (*vpxlast_vertical_band_3_5_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
typedef void (*vpxhorizontal_line_1_2_scale_lf)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
typedef void (*vpxhorizontal_line_3_5_scale_lf)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
typedef void (*vpxhorizontal_line_4_5_scale_lf)(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
|
||||
typedef void (*vpxvertical_band_1_2_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
typedef void (*vpxlast_vertical_band_1_2_scale_lf)(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width);
|
||||
|
||||
|
||||
typedef struct vpxglobal_scalling_ptrs_t
|
||||
{
|
||||
vpxvertical_band_4_5_scale_lf vpxvertical_band_4_5_scale_t;
|
||||
vpxlast_vertical_band_4_5_scale_lf vpxlast_vertical_band_4_5_scale_t;
|
||||
vpxvertical_band_3_5_scale_lf vpxvertical_band_3_5_scale_t;
|
||||
vpxlast_vertical_band_3_5_scale_lf vpxlast_vertical_band_3_5_scale_t;
|
||||
vpxhorizontal_line_1_2_scale_lf vpxhorizontal_line_1_2_scale_t;
|
||||
vpxhorizontal_line_3_5_scale_lf vpxhorizontal_line_3_5_scale_t;
|
||||
vpxhorizontal_line_4_5_scale_lf vpxhorizontal_line_4_5_scale_t;
|
||||
vpxvertical_band_1_2_scale_lf vpxvertical_band_1_2_scale_t;
|
||||
vpxlast_vertical_band_1_2_scale_lf vpxlast_vertical_band_1_2_scale_t;
|
||||
} vpxglobal_scalling_ptrs;
|
||||
|
||||
extern struct vpxglobal_scalling_ptrs_t *g_scaling_ptrs;
|
||||
|
||||
/*
|
||||
extern void (*vp8_vertical_band_4_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_4_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
extern void (*vp8_vertical_band_3_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_3_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_1_2_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_3_5_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
extern void (*vp8_horizontal_line_4_5_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
extern void (*vp8_vertical_band_1_2_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
extern void (*vp8_last_vertical_band_1_2_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
*/
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : system_dependant.c
|
||||
*
|
||||
* Description : Miscellaneous system dependant functions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "cpuidlib.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
*****************************************************************************/
|
||||
extern void register_generic_scalers(void);
|
||||
extern void register_mmxscalers(void);
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : post_proc_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_scale_machine_specific_config(void)
|
||||
{
|
||||
// If MMX supported then set to use MMX versions of functions else
|
||||
// use original 'C' versions.
|
||||
int mmx_enabled;
|
||||
int xmm_enabled;
|
||||
int wmt_enabled;
|
||||
|
||||
vpx_get_processor_flags(&mmx_enabled, &xmm_enabled, &wmt_enabled);
|
||||
|
||||
if (mmx_enabled || xmm_enabled || wmt_enabled)
|
||||
{
|
||||
register_mmxscalers();
|
||||
}
|
||||
else
|
||||
{
|
||||
vp8_horizontal_line_1_2_scale = vp8cx_horizontal_line_1_2_scale_c;
|
||||
vp8_vertical_band_1_2_scale = vp8cx_vertical_band_1_2_scale_c;
|
||||
vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
vp8_horizontal_line_3_5_scale = vp8cx_horizontal_line_3_5_scale_c;
|
||||
vp8_vertical_band_3_5_scale = vp8cx_vertical_band_3_5_scale_c;
|
||||
vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
vp8_horizontal_line_3_4_scale = vp8cx_horizontal_line_3_4_scale_c;
|
||||
vp8_vertical_band_3_4_scale = vp8cx_vertical_band_3_4_scale_c;
|
||||
vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
|
||||
vp8_horizontal_line_2_3_scale = vp8cx_horizontal_line_2_3_scale_c;
|
||||
vp8_vertical_band_2_3_scale = vp8cx_vertical_band_2_3_scale_c;
|
||||
vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
|
||||
vp8_horizontal_line_4_5_scale = vp8cx_horizontal_line_4_5_scale_c;
|
||||
vp8_vertical_band_4_5_scale = vp8cx_vertical_band_4_5_scale_c;
|
||||
vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
|
||||
|
||||
vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
|
||||
vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
|
||||
vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
|
||||
vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
|
||||
vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
|
||||
vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
|
||||
vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
|
||||
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : system_dependant.c
|
||||
*
|
||||
* Description : Miscellaneous system dependant functions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
*****************************************************************************/
|
||||
extern int register_generic_scalers(void);
|
||||
extern int de_register_generic_scalers(void);
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_scale_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
int
|
||||
vp8_scale_machine_specific_config()
|
||||
{
|
||||
return register_generic_scalers();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_scale_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int
|
||||
*
|
||||
* FUNCTION : Resets the funtion pointers and deallocates memory.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
int
|
||||
scale_machine_specific_de_config()
|
||||
{
|
||||
return de_register_generic_scalers();
|
||||
}
|
@ -1,522 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : gen_scalers.c
|
||||
*
|
||||
* Description : Generic image scaling functions.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_horizontal_line_4_5_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 4 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_horizontal_line_4_5_scale_c
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 4; i += 4)
|
||||
{
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char) a;
|
||||
des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
c = src[2] * 154;
|
||||
a = src[3];
|
||||
des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
|
||||
b = src[4];
|
||||
des [4] = (unsigned char)((a * 205 + 51 * b + 128) >> 8);
|
||||
|
||||
src += 4;
|
||||
des += 5;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
c = src[2] * 154;
|
||||
a = src[3];
|
||||
des [2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [3] = (unsigned char)((c + 102 * a + 128) >> 8);
|
||||
des [4] = (unsigned char)(a);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_vertical_band_4_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++)
|
||||
{
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch*2] * 154;
|
||||
d = des[dest_pitch*3];
|
||||
|
||||
des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
|
||||
|
||||
// First line in next band
|
||||
a = des [dest_pitch * 5];
|
||||
des [dest_pitch * 4] = (unsigned char)((d * 205 + 51 * a + 128) >> 8);
|
||||
|
||||
des ++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_last_vertical_band_4_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 4 to 5. The
|
||||
* height of the band scaled is 4-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_last_vertical_band_4_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c, d;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i)
|
||||
{
|
||||
a = des[0];
|
||||
b = des[dest_pitch];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a * 51 + 205 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch*2] * 154;
|
||||
d = des[dest_pitch*3];
|
||||
|
||||
des [dest_pitch*2] = (unsigned char)((b * 102 + c + 128) >> 8);
|
||||
des [dest_pitch*3] = (unsigned char)((c + 102 * d + 128) >> 8);
|
||||
|
||||
// No other line for interplation of this line, so ..
|
||||
des[dest_pitch*4] = (unsigned char) d;
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_horizontal_line_3_5_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 3 to 5.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_horizontal_line_3_5_scale_c
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 3; i += 3)
|
||||
{
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = src[2] ;
|
||||
des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
a = src[3];
|
||||
des [4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
|
||||
|
||||
src += 3;
|
||||
des += 5;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
|
||||
des [1] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
c = src[2] ;
|
||||
des [2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
des [4] = (unsigned char)(c);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_vertical_band_3_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++)
|
||||
{
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
des [dest_pitch] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch*2];
|
||||
des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
// First line in next band...
|
||||
a = des [dest_pitch * 5];
|
||||
des [dest_pitch * 4] = (unsigned char)((c * 154 + a * 102 + 128) >> 8);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_last_vertical_band_3_5_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 3 to 5. The
|
||||
* height of the band scaled is 3-pixels.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_last_vertical_band_3_5_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b, c;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i)
|
||||
{
|
||||
a = des [0];
|
||||
b = des [dest_pitch];
|
||||
|
||||
des [ dest_pitch ] = (unsigned char)((a * 102 + 154 * b + 128) >> 8);
|
||||
|
||||
c = des[dest_pitch*2];
|
||||
des [dest_pitch*2] = (unsigned char)((b * 205 + c * 51 + 128) >> 8);
|
||||
des [dest_pitch*3] = (unsigned char)((b * 51 + c * 205 + 128) >> 8);
|
||||
|
||||
// No other line for interplation of this line, so ..
|
||||
des [ dest_pitch * 4 ] = (unsigned char)(c) ;
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_horizontal_line_1_2_scale_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to source data.
|
||||
* unsigned int source_width : Stride of source.
|
||||
* unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_width : Stride of destination (NOT USED).
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies horizontal line of pixels from source to
|
||||
* destination scaling up by 1 to 2.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_horizontal_line_1_2_scale_c
|
||||
(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned char *des = dest;
|
||||
const unsigned char *src = source;
|
||||
|
||||
(void) dest_width;
|
||||
|
||||
for (i = 0; i < source_width - 1; i += 1)
|
||||
{
|
||||
a = src[0];
|
||||
b = src[1];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)((a + b + 1) >> 1);
|
||||
src += 1;
|
||||
des += 2;
|
||||
}
|
||||
|
||||
a = src[0];
|
||||
des [0] = (unsigned char)(a);
|
||||
des [1] = (unsigned char)(a);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_vertical_band_1_2_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine uses the first line of the band below
|
||||
* the current band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int a, b;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; i++)
|
||||
{
|
||||
a = des [0];
|
||||
b = des [dest_pitch * 2];
|
||||
|
||||
des[dest_pitch] = (unsigned char)((a + b + 1) >> 1);
|
||||
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8cx_last_vertical_band_1_2_scale_c
|
||||
*
|
||||
* INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
* unsigned int dest_pitch : Stride of destination data.
|
||||
* unsigned int dest_width : Width of destination data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Scales last vertical band of pixels by scale 1 to 2. The
|
||||
* height of the band scaled is 1-pixel.
|
||||
*
|
||||
* SPECIAL NOTES : The routine does not have available the first line of
|
||||
* the band below the current band, since this is the
|
||||
* last band.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void vp8cx_last_vertical_band_1_2_scale_c(unsigned char *dest, unsigned int dest_pitch, unsigned int dest_width)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *des = dest;
|
||||
|
||||
for (i = 0; i < dest_width; ++i)
|
||||
{
|
||||
des[dest_pitch] = des[0];
|
||||
des++;
|
||||
}
|
||||
}
|
||||
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
struct vpxglobal_scalling_ptrs_t *g_scaling_ptrs = 0;
|
||||
|
||||
int
|
||||
register_generic_scalers(void)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
g_scaling_ptrs = (struct vpxglobal_scalling_ptrs_t *)vpx_malloc(sizeof(struct vpxglobal_scalling_ptrs_t));
|
||||
|
||||
if (g_scaling_ptrs)
|
||||
{
|
||||
g_scaling_ptrs->vpxhorizontal_line_1_2_scale_t = vp8cx_horizontal_line_1_2_scale_c;
|
||||
g_scaling_ptrs->vpxvertical_band_1_2_scale_t = vp8cx_vertical_band_1_2_scale_c;
|
||||
g_scaling_ptrs->vpxlast_vertical_band_1_2_scale_t = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
g_scaling_ptrs->vpxhorizontal_line_3_5_scale_t = vp8cx_horizontal_line_3_5_scale_c;
|
||||
g_scaling_ptrs->vpxvertical_band_3_5_scale_t = vp8cx_vertical_band_3_5_scale_c;
|
||||
g_scaling_ptrs->vpxlast_vertical_band_3_5_scale_t = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
g_scaling_ptrs->vpxhorizontal_line_4_5_scale_t = vp8cx_horizontal_line_4_5_scale_c;
|
||||
g_scaling_ptrs->vpxvertical_band_4_5_scale_t = vp8cx_vertical_band_4_5_scale_c;
|
||||
g_scaling_ptrs->vpxlast_vertical_band_4_5_scale_t = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
vp8_horizontal_line_1_2_scale = vp8cx_horizontal_line_1_2_scale_c;
|
||||
vp8_vertical_band_1_2_scale = vp8cx_vertical_band_1_2_scale_c;
|
||||
vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
vp8_horizontal_line_3_5_scale = vp8cx_horizontal_line_3_5_scale_c;
|
||||
vp8_vertical_band_3_5_scale = vp8cx_vertical_band_3_5_scale_c;
|
||||
vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
vp8_horizontal_line_4_5_scale = vp8cx_horizontal_line_4_5_scale_c;
|
||||
vp8_vertical_band_4_5_scale = vp8cx_vertical_band_4_5_scale_c;
|
||||
vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
*/
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
de_register_generic_scalers(void)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
if (g_scaling_ptrs)
|
||||
{
|
||||
vpx_free(g_scaling_ptrs);
|
||||
g_scaling_ptrs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
@ -1,891 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : scale.c
|
||||
*
|
||||
* Description : Image scaling functions.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "stdlib.h"
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "codec_common_interface.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
/*
|
||||
void (*vp8_vertical_band_4_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
void (*vp8_last_vertical_band_4_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
void (*vp8_vertical_band_3_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
void (*vp8_last_vertical_band_3_5_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
void (*vp8_horizontal_line_1_2_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
void (*vp8_horizontal_line_3_5_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
void (*vp8_horizontal_line_4_5_scale)(const unsigned char * source,unsigned int source_width,unsigned char * dest,unsigned int dest_width);
|
||||
void (*vp8_vertical_band_1_2_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
void (*vp8_last_vertical_band_1_2_scale)(unsigned char * dest,unsigned int dest_pitch,unsigned int dest_width);
|
||||
*/
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int expanded_frame_width;
|
||||
int expanded_frame_height;
|
||||
|
||||
int HScale;
|
||||
int HRatio;
|
||||
int VScale;
|
||||
int VRatio;
|
||||
|
||||
YV12_BUFFER_CONFIG *src_yuv_config;
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config;
|
||||
|
||||
} SCALE_VARS;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : horizontal_line_copy
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None
|
||||
*
|
||||
* FUNCTION : 1 to 1 scaling up for a horizontal line of pixles
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void horizontal_line_copy(
|
||||
const unsigned char *source,
|
||||
unsigned int source_width,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
duck_memcpy(dest, source, source_width);
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : null_scale
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None
|
||||
*
|
||||
* FUNCTION : 1 to 1 scaling up for a vertical band
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void null_scale(
|
||||
unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale1d_2t1_i
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to data to be scaled.
|
||||
* int source_step : Number of pixels to step on in source.
|
||||
* unsigned int source_scale : Scale for source (UNUSED).
|
||||
* unsigned int source_length : Length of source (UNUSED).
|
||||
* unsigned char *dest : Pointer to output data array.
|
||||
* int dest_step : Number of pixels to step on in destination.
|
||||
* unsigned int dest_scale : Scale for destination (UNUSED).
|
||||
* unsigned int dest_length : Length of destination.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Performs 2-to-1 interpolated scaling.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void scale1d_2t1_i
|
||||
(
|
||||
const unsigned char *source,
|
||||
int source_step,
|
||||
unsigned int source_scale,
|
||||
unsigned int source_length,
|
||||
unsigned char *dest,
|
||||
int dest_step,
|
||||
unsigned int dest_scale,
|
||||
unsigned int dest_length
|
||||
)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int temp;
|
||||
|
||||
(void) source_length;
|
||||
(void) source_scale;
|
||||
(void) dest_scale;
|
||||
|
||||
source_step *= 2;
|
||||
dest[0] = source[0];
|
||||
|
||||
for (i = dest_step, j = source_step; i < dest_length * dest_step; i += dest_step, j += source_step)
|
||||
{
|
||||
temp = 8;
|
||||
temp += 3 * source[j-source_step];
|
||||
temp += 10 * source[j];
|
||||
temp += 3 * source[j+source_step];
|
||||
temp >>= 4;
|
||||
dest[i] = (char)(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale1d_2t1_ps
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to data to be scaled.
|
||||
* int source_step : Number of pixels to step on in source.
|
||||
* unsigned int source_scale : Scale for source (UNUSED).
|
||||
* unsigned int source_length : Length of source (UNUSED).
|
||||
* unsigned char *dest : Pointer to output data array.
|
||||
* int dest_step : Number of pixels to step on in destination.
|
||||
* unsigned int dest_scale : Scale for destination (UNUSED).
|
||||
* unsigned int dest_length : Length of destination.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Performs 2-to-1 point subsampled scaling.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void scale1d_2t1_ps
|
||||
(
|
||||
const unsigned char *source,
|
||||
int source_step,
|
||||
unsigned int source_scale,
|
||||
unsigned int source_length,
|
||||
unsigned char *dest,
|
||||
int dest_step,
|
||||
unsigned int dest_scale,
|
||||
unsigned int dest_length
|
||||
)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
(void) source_length;
|
||||
(void) source_scale;
|
||||
(void) dest_scale;
|
||||
|
||||
source_step *= 2;
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i < dest_length * dest_step; i += dest_step, j += source_step)
|
||||
dest[i] = source[j];
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale1d_c
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to data to be scaled.
|
||||
* int source_step : Number of pixels to step on in source.
|
||||
* unsigned int source_scale : Scale for source.
|
||||
* unsigned int source_length : Length of source (UNUSED).
|
||||
* unsigned char *dest : Pointer to output data array.
|
||||
* int dest_step : Number of pixels to step on in destination.
|
||||
* unsigned int dest_scale : Scale for destination.
|
||||
* unsigned int dest_length : Length of destination.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Performs linear interpolation in one dimension.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void scale1d_c
|
||||
(
|
||||
const unsigned char *source,
|
||||
int source_step,
|
||||
unsigned int source_scale,
|
||||
unsigned int source_length,
|
||||
unsigned char *dest,
|
||||
int dest_step,
|
||||
unsigned int dest_scale,
|
||||
unsigned int dest_length
|
||||
)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int round_value = dest_scale / 2;
|
||||
unsigned int left_modifier = dest_scale;
|
||||
unsigned int right_modifier = 0;
|
||||
unsigned char left_pixel = *source;
|
||||
unsigned char right_pixel = *(source + source_step);
|
||||
|
||||
(void) source_length;
|
||||
|
||||
// These asserts are needed if there are boundary issues...
|
||||
//assert ( dest_scale > source_scale );
|
||||
//assert ( (source_length-1) * dest_scale >= (dest_length-1) * source_scale );
|
||||
|
||||
for (i = 0; i < dest_length * dest_step; i += dest_step)
|
||||
{
|
||||
dest[i] = (char)((left_modifier * left_pixel + right_modifier * right_pixel + round_value) / dest_scale);
|
||||
|
||||
right_modifier += source_scale;
|
||||
|
||||
while (right_modifier > dest_scale)
|
||||
{
|
||||
right_modifier -= dest_scale;
|
||||
source += source_step;
|
||||
left_pixel = *source;
|
||||
right_pixel = *(source + source_step);
|
||||
}
|
||||
|
||||
left_modifier = dest_scale - right_modifier;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : Scale2D
|
||||
*
|
||||
* INPUTS : const unsigned char *source : Pointer to data to be scaled.
|
||||
* int source_pitch : Stride of source image.
|
||||
* unsigned int source_width : Width of input image.
|
||||
* unsigned int source_height : Height of input image.
|
||||
* unsigned char *dest : Pointer to output data array.
|
||||
* int dest_pitch : Stride of destination image.
|
||||
* unsigned int dest_width : Width of destination image.
|
||||
* unsigned int dest_height : Height of destination image.
|
||||
* unsigned char *temp_area : Pointer to temp work area.
|
||||
* unsigned char temp_area_height : Height of temp work area.
|
||||
* unsigned int hscale : Horizontal scale factor numerator.
|
||||
* unsigned int hratio : Horizontal scale factor denominator.
|
||||
* unsigned int vscale : Vertical scale factor numerator.
|
||||
* unsigned int vratio : Vertical scale factor denominator.
|
||||
* unsigned int interlaced : Interlace flag.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Performs 2-tap linear interpolation in two dimensions.
|
||||
*
|
||||
* SPECIAL NOTES : Expansion is performed one band at a time to help with
|
||||
* caching.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
void Scale2D
|
||||
(
|
||||
const unsigned char *source,
|
||||
int source_pitch,
|
||||
unsigned int source_width,
|
||||
unsigned int source_height,
|
||||
unsigned char *dest,
|
||||
int dest_pitch,
|
||||
unsigned int dest_width,
|
||||
unsigned int dest_height,
|
||||
unsigned char *temp_area,
|
||||
unsigned char temp_area_height,
|
||||
unsigned int hscale,
|
||||
unsigned int hratio,
|
||||
unsigned int vscale,
|
||||
unsigned int vratio,
|
||||
unsigned int interlaced
|
||||
)
|
||||
{
|
||||
unsigned int i, j, k;
|
||||
unsigned int bands;
|
||||
unsigned int dest_band_height;
|
||||
unsigned int source_band_height;
|
||||
|
||||
typedef void (*Scale1D)(const unsigned char * source, int source_step, unsigned int source_scale, unsigned int source_length,
|
||||
unsigned char * dest, int dest_step, unsigned int dest_scale, unsigned int dest_length);
|
||||
|
||||
Scale1D Scale1Dv = scale1d_c;
|
||||
Scale1D Scale1Dh = scale1d_c;
|
||||
|
||||
if (hscale == 2 && hratio == 1)
|
||||
Scale1Dh = scale1d_2t1_ps;
|
||||
|
||||
if (vscale == 2 && vratio == 1)
|
||||
{
|
||||
if (interlaced)
|
||||
Scale1Dv = scale1d_2t1_ps;
|
||||
else
|
||||
Scale1Dv = scale1d_2t1_i;
|
||||
}
|
||||
|
||||
if (source_height == dest_height)
|
||||
{
|
||||
// for each band of the image
|
||||
for (k = 0; k < dest_height; k++)
|
||||
{
|
||||
Scale1Dh(source, 1, hscale, source_width + 1, dest, 1, hratio, dest_width);
|
||||
source += source_pitch;
|
||||
dest += dest_pitch;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest_height > source_height)
|
||||
{
|
||||
dest_band_height = temp_area_height - 1;
|
||||
source_band_height = dest_band_height * source_height / dest_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
source_band_height = temp_area_height - 1;
|
||||
dest_band_height = source_band_height * vratio / vscale;
|
||||
}
|
||||
|
||||
// first row needs to be done so that we can stay one row ahead for vertical zoom
|
||||
Scale1Dh(source, 1, hscale, source_width + 1, temp_area, 1, hratio, dest_width);
|
||||
|
||||
// for each band of the image
|
||||
bands = (dest_height + dest_band_height - 1) / dest_band_height;
|
||||
|
||||
for (k = 0; k < bands; k++)
|
||||
{
|
||||
// scale one band horizontally
|
||||
for (i = 1; i < source_band_height + 1; i++)
|
||||
{
|
||||
if (k * source_band_height + i < source_height)
|
||||
{
|
||||
Scale1Dh(source + i * source_pitch, 1, hscale, source_width + 1,
|
||||
temp_area + i * dest_pitch, 1, hratio, dest_width);
|
||||
}
|
||||
else // Duplicate the last row
|
||||
{
|
||||
// copy temp_area row 0 over from last row in the past
|
||||
duck_memcpy(temp_area + i * dest_pitch, temp_area + (i - 1)*dest_pitch, dest_pitch);
|
||||
}
|
||||
}
|
||||
|
||||
// scale one band vertically
|
||||
for (j = 0; j < dest_width; j++)
|
||||
{
|
||||
Scale1Dv(&temp_area[j], dest_pitch, vscale, source_band_height + 1,
|
||||
&dest[j], dest_pitch, vratio, dest_band_height);
|
||||
}
|
||||
|
||||
// copy temp_area row 0 over from last row in the past
|
||||
duck_memcpy(temp_area, temp_area + source_band_height * dest_pitch, dest_pitch);
|
||||
|
||||
// move to the next band
|
||||
source += source_band_height * source_pitch;
|
||||
dest += dest_band_height * dest_pitch;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_scale_frame
|
||||
*
|
||||
* INPUTS : YV12_BUFFER_CONFIG *src : Pointer to frame to be scaled.
|
||||
* YV12_BUFFER_CONFIG *dst : Pointer to buffer to hold scaled frame.
|
||||
* unsigned char *temp_area : Pointer to temp work area.
|
||||
* unsigned char temp_area_height : Height of temp work area.
|
||||
* unsigned int hscale : Horizontal scale factor numerator.
|
||||
* unsigned int hratio : Horizontal scale factor denominator.
|
||||
* unsigned int vscale : Vertical scale factor numerator.
|
||||
* unsigned int vratio : Vertical scale factor denominator.
|
||||
* unsigned int interlaced : Interlace flag.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Performs 2-tap linear interpolation in two dimensions.
|
||||
*
|
||||
* SPECIAL NOTES : Expansion is performed one band at a time to help with
|
||||
* caching.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_scale_frame
|
||||
(
|
||||
YV12_BUFFER_CONFIG *src,
|
||||
YV12_BUFFER_CONFIG *dst,
|
||||
unsigned char *temp_area,
|
||||
unsigned char temp_height,
|
||||
unsigned int hscale,
|
||||
unsigned int hratio,
|
||||
unsigned int vscale,
|
||||
unsigned int vratio,
|
||||
unsigned int interlaced
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int dw = (hscale - 1 + src->y_width * hratio) / hscale;
|
||||
int dh = (vscale - 1 + src->y_height * vratio) / vscale;
|
||||
|
||||
// call our internal scaling routines!!
|
||||
Scale2D((unsigned char *) src->y_buffer, src->y_stride, src->y_width, src->y_height,
|
||||
(unsigned char *) dst->y_buffer, dst->y_stride, dw, dh,
|
||||
temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
|
||||
|
||||
if (dw < (int)dst->y_width)
|
||||
for (i = 0; i < dh; i++)
|
||||
duck_memset(dst->y_buffer + i * dst->y_stride + dw - 1, dst->y_buffer[i*dst->y_stride+dw-2], dst->y_width - dw + 1);
|
||||
|
||||
if (dh < (int)dst->y_height)
|
||||
for (i = dh - 1; i < (int)dst->y_height; i++)
|
||||
duck_memcpy(dst->y_buffer + i * dst->y_stride, dst->y_buffer + (dh - 2) * dst->y_stride, dst->y_width + 1);
|
||||
|
||||
Scale2D((unsigned char *) src->u_buffer, src->uv_stride, src->uv_width, src->uv_height,
|
||||
(unsigned char *) dst->u_buffer, dst->uv_stride, dw / 2, dh / 2,
|
||||
temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
|
||||
|
||||
if (dw / 2 < (int)dst->uv_width)
|
||||
for (i = 0; i < dst->uv_height; i++)
|
||||
duck_memset(dst->u_buffer + i * dst->uv_stride + dw / 2 - 1, dst->u_buffer[i*dst->uv_stride+dw/2-2], dst->uv_width - dw / 2 + 1);
|
||||
|
||||
if (dh / 2 < (int)dst->uv_height)
|
||||
for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
|
||||
duck_memcpy(dst->u_buffer + i * dst->uv_stride, dst->u_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
|
||||
|
||||
Scale2D((unsigned char *) src->v_buffer, src->uv_stride, src->uv_width, src->uv_height,
|
||||
(unsigned char *) dst->v_buffer, dst->uv_stride, dw / 2, dh / 2,
|
||||
temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced);
|
||||
|
||||
if (dw / 2 < (int)dst->uv_width)
|
||||
for (i = 0; i < dst->uv_height; i++)
|
||||
duck_memset(dst->v_buffer + i * dst->uv_stride + dw / 2 - 1, dst->v_buffer[i*dst->uv_stride+dw/2-2], dst->uv_width - dw / 2 + 1);
|
||||
|
||||
if (dh / 2 < (int) dst->uv_height)
|
||||
for (i = dh / 2 - 1; i < (int)dst->y_height / 2; i++)
|
||||
duck_memcpy(dst->v_buffer + i * dst->uv_stride, dst->v_buffer + (dh / 2 - 2)*dst->uv_stride, dst->uv_width);
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : any_ratio_2d_scale
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance (NOT USED).
|
||||
* const unsigned char *source : Pointer to source image.
|
||||
* unsigned int source_pitch : Stride of source image.
|
||||
* unsigned int source_width : Width of source image.
|
||||
* unsigned int source_height : Height of source image (NOT USED).
|
||||
* unsigned char *dest : Pointer to destination image.
|
||||
* unsigned int dest_pitch : Stride of destination image.
|
||||
* unsigned int dest_width : Width of destination image.
|
||||
* unsigned int dest_height : Height of destination image.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int: 1 if image scaled, 0 if image could not be scaled.
|
||||
*
|
||||
* FUNCTION : Scale the image with changing apect ratio.
|
||||
*
|
||||
* SPECIAL NOTES : This scaling is a bi-linear scaling. Need to re-work the
|
||||
* whole function for new scaling algorithm.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
int any_ratio_2d_scale
|
||||
(
|
||||
SCALE_VARS *si,
|
||||
const unsigned char *source,
|
||||
unsigned int source_pitch,
|
||||
unsigned int source_width,
|
||||
unsigned int source_height,
|
||||
unsigned char *dest,
|
||||
unsigned int dest_pitch,
|
||||
unsigned int dest_width,
|
||||
unsigned int dest_height
|
||||
)
|
||||
{
|
||||
unsigned int i, k;
|
||||
unsigned int src_band_height = 0;
|
||||
unsigned int dest_band_height = 0;
|
||||
|
||||
// suggested scale factors
|
||||
int hs = si->HScale;
|
||||
int hr = si->HRatio;
|
||||
int vs = si->VScale;
|
||||
int vr = si->VRatio;
|
||||
|
||||
// assume the ratios are scalable instead of should be centered
|
||||
int ratio_scalable = 1;
|
||||
|
||||
void (*horiz_line_scale)(const unsigned char *, unsigned int, unsigned char *, unsigned int) = NULL;
|
||||
void (*vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
|
||||
void (*last_vert_band_scale)(unsigned char *, unsigned int, unsigned int) = NULL;
|
||||
|
||||
(void) si;
|
||||
|
||||
// find out the ratio for each direction
|
||||
switch (hr * 10 / hs)
|
||||
{
|
||||
case 8:
|
||||
// 4-5 Scale in Width direction
|
||||
horiz_line_scale = g_scaling_ptrs->vpxhorizontal_line_4_5_scale_t;
|
||||
break;
|
||||
case 6:
|
||||
// 3-5 Scale in Width direction
|
||||
horiz_line_scale = g_scaling_ptrs->vpxhorizontal_line_3_5_scale_t;
|
||||
break;
|
||||
case 5:
|
||||
// 1-2 Scale in Width direction
|
||||
horiz_line_scale = g_scaling_ptrs->vpxhorizontal_line_1_2_scale_t;
|
||||
break;
|
||||
case 10:
|
||||
// no scale in Width direction
|
||||
horiz_line_scale = horizontal_line_copy;
|
||||
break;
|
||||
default:
|
||||
// The ratio is not acceptable now
|
||||
// throw("The ratio is not acceptable for now!");
|
||||
ratio_scalable = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (vr * 10 / vs)
|
||||
{
|
||||
case 8:
|
||||
// 4-5 Scale in vertical direction
|
||||
vert_band_scale = g_scaling_ptrs->vpxvertical_band_4_5_scale_t;
|
||||
last_vert_band_scale = g_scaling_ptrs->vpxlast_vertical_band_4_5_scale_t;
|
||||
src_band_height = 4;
|
||||
dest_band_height = 5;
|
||||
break;
|
||||
case 6:
|
||||
// 3-5 Scale in vertical direction
|
||||
vert_band_scale = g_scaling_ptrs->vpxvertical_band_3_5_scale_t;
|
||||
last_vert_band_scale = g_scaling_ptrs->vpxlast_vertical_band_3_5_scale_t;
|
||||
src_band_height = 3;
|
||||
dest_band_height = 5;
|
||||
break;
|
||||
case 5:
|
||||
// 1-2 Scale in vertical direction
|
||||
vert_band_scale = g_scaling_ptrs->vpxvertical_band_1_2_scale_t;
|
||||
last_vert_band_scale = g_scaling_ptrs->vpxlast_vertical_band_1_2_scale_t;
|
||||
src_band_height = 1;
|
||||
dest_band_height = 2;
|
||||
break;
|
||||
case 10:
|
||||
// no scale in Width direction
|
||||
vert_band_scale = null_scale;
|
||||
last_vert_band_scale = null_scale;
|
||||
src_band_height = 4;
|
||||
dest_band_height = 4;
|
||||
break;
|
||||
default:
|
||||
// The ratio is not acceptable now
|
||||
// throw("The ratio is not acceptable for now!");
|
||||
ratio_scalable = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ratio_scalable == 0)
|
||||
return ratio_scalable;
|
||||
|
||||
horiz_line_scale(source, source_width, dest, dest_width);
|
||||
|
||||
// except last band
|
||||
for (k = 0; k < (dest_height + dest_band_height - 1) / dest_band_height - 1; k++)
|
||||
{
|
||||
// scale one band horizontally
|
||||
for (i = 1; i < src_band_height; i++)
|
||||
{
|
||||
horiz_line_scale(source + i * source_pitch,
|
||||
source_width,
|
||||
dest + i * dest_pitch,
|
||||
dest_width);
|
||||
}
|
||||
|
||||
// first line of next band
|
||||
horiz_line_scale(source + src_band_height * source_pitch,
|
||||
source_width,
|
||||
dest + dest_band_height * dest_pitch,
|
||||
dest_width);
|
||||
|
||||
// Vertical scaling is in place
|
||||
vert_band_scale(dest, dest_pitch, dest_width);
|
||||
|
||||
// Next band...
|
||||
source += src_band_height * source_pitch;
|
||||
dest += dest_band_height * dest_pitch;
|
||||
}
|
||||
|
||||
// scale one band horizontally
|
||||
for (i = 1; i < src_band_height; i++)
|
||||
{
|
||||
horiz_line_scale(source + i * source_pitch,
|
||||
source_width,
|
||||
dest + i * dest_pitch,
|
||||
dest_width);
|
||||
}
|
||||
|
||||
// Vertical scaling is in place
|
||||
last_vert_band_scale(dest, dest_pitch, dest_width);
|
||||
|
||||
return ratio_scalable;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : any_ratio_frame_scale
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance (NOT USED).
|
||||
* unsigned char *frame_buffer : Pointer to source image.
|
||||
* int YOffset : Offset from start of buffer to Y samples.
|
||||
* int UVOffset : Offset from start of buffer to UV samples.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : int: 1 if image scaled, 0 if image could not be scaled.
|
||||
*
|
||||
* FUNCTION : Scale the image with changing apect ratio.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static
|
||||
int any_ratio_frame_scale(SCALE_VARS *scale_vars, int YOffset, int UVOffset)
|
||||
{
|
||||
int i;
|
||||
int ew;
|
||||
int eh;
|
||||
|
||||
// suggested scale factors
|
||||
int hs = scale_vars->HScale;
|
||||
int hr = scale_vars->HRatio;
|
||||
int vs = scale_vars->VScale;
|
||||
int vr = scale_vars->VRatio;
|
||||
|
||||
int ratio_scalable = 1;
|
||||
|
||||
int sw = (scale_vars->expanded_frame_width * hr + hs - 1) / hs;
|
||||
int sh = (scale_vars->expanded_frame_height * vr + vs - 1) / vs;
|
||||
int dw = scale_vars->expanded_frame_width;
|
||||
int dh = scale_vars->expanded_frame_height;
|
||||
YV12_BUFFER_CONFIG *src_yuv_config = scale_vars->src_yuv_config;
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config = scale_vars->dst_yuv_config;
|
||||
|
||||
if (hr == 3)
|
||||
ew = (sw + 2) / 3 * 3 * hs / hr;
|
||||
else
|
||||
ew = (sw + 7) / 8 * 8 * hs / hr;
|
||||
|
||||
if (vr == 3)
|
||||
eh = (sh + 2) / 3 * 3 * vs / vr;
|
||||
else
|
||||
eh = (sh + 7) / 8 * 8 * vs / vr;
|
||||
|
||||
ratio_scalable = any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->y_buffer,
|
||||
src_yuv_config->y_stride, sw, sh,
|
||||
(unsigned char *) dst_yuv_config->y_buffer + YOffset,
|
||||
dst_yuv_config->y_stride, dw, dh);
|
||||
|
||||
for (i = 0; i < eh; i++)
|
||||
duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride + dw, 0, ew - dw);
|
||||
|
||||
for (i = dh; i < eh; i++)
|
||||
duck_memset(dst_yuv_config->y_buffer + YOffset + i * dst_yuv_config->y_stride, 0, ew);
|
||||
|
||||
if (ratio_scalable == 0)
|
||||
return ratio_scalable;
|
||||
|
||||
sw = (sw + 1) >> 1;
|
||||
sh = (sh + 1) >> 1;
|
||||
dw = (dw + 1) >> 1;
|
||||
dh = (dh + 1) >> 1;
|
||||
|
||||
any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->u_buffer,
|
||||
src_yuv_config->y_stride / 2, sw, sh,
|
||||
(unsigned char *)dst_yuv_config->u_buffer + UVOffset,
|
||||
dst_yuv_config->uv_stride, dw, dh);
|
||||
|
||||
any_ratio_2d_scale(scale_vars,
|
||||
(const unsigned char *)src_yuv_config->v_buffer,
|
||||
src_yuv_config->y_stride / 2, sw, sh,
|
||||
(unsigned char *)dst_yuv_config->v_buffer + UVOffset,
|
||||
dst_yuv_config->uv_stride, dw, dh);
|
||||
|
||||
return ratio_scalable;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : center_image
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Centers the image without scaling in the output buffer.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static void
|
||||
center_image(YV12_BUFFER_CONFIG *src_yuv_config, YV12_BUFFER_CONFIG *dst_yuv_config)
|
||||
{
|
||||
int i;
|
||||
int row_offset, col_offset;
|
||||
char *src_data_pointer;
|
||||
char *dst_data_pointer;
|
||||
|
||||
// center values
|
||||
row_offset = (dst_yuv_config->y_height - src_yuv_config->y_height) / 2;
|
||||
col_offset = (dst_yuv_config->y_width - src_yuv_config->y_width) / 2;
|
||||
|
||||
// Y's
|
||||
src_data_pointer = src_yuv_config->y_buffer;
|
||||
dst_data_pointer = (char *)dst_yuv_config->y_buffer + (row_offset * dst_yuv_config->y_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->y_height; i++)
|
||||
{
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->y_width);
|
||||
dst_data_pointer += dst_yuv_config->y_stride;
|
||||
src_data_pointer += src_yuv_config->y_stride;
|
||||
}
|
||||
|
||||
row_offset /= 2;
|
||||
col_offset /= 2;
|
||||
|
||||
// U's
|
||||
src_data_pointer = src_yuv_config->u_buffer;
|
||||
dst_data_pointer = (char *)dst_yuv_config->u_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->uv_height; i++)
|
||||
{
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
|
||||
dst_data_pointer += dst_yuv_config->uv_stride;
|
||||
src_data_pointer += src_yuv_config->uv_stride;
|
||||
}
|
||||
|
||||
// V's
|
||||
src_data_pointer = src_yuv_config->v_buffer;
|
||||
dst_data_pointer = (char *)dst_yuv_config->v_buffer + (row_offset * dst_yuv_config->uv_stride) + col_offset;
|
||||
|
||||
for (i = 0; i < src_yuv_config->uv_height; i++)
|
||||
{
|
||||
duck_memcpy(dst_data_pointer, src_data_pointer, src_yuv_config->uv_width);
|
||||
dst_data_pointer += dst_yuv_config->uv_stride;
|
||||
src_data_pointer += src_yuv_config->uv_stride;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : scale_or_center
|
||||
*
|
||||
* INPUTS : SCALE_INSTANCE *si : Pointer to post-processor instance.
|
||||
*
|
||||
*
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Decides to scale or center image in scale buffer for blit
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_scale_or_center
|
||||
(
|
||||
YV12_BUFFER_CONFIG *src_yuv_config,
|
||||
YV12_BUFFER_CONFIG *dst_yuv_config,
|
||||
int expanded_frame_width,
|
||||
int expanded_frame_height,
|
||||
int scaling_mode,
|
||||
int HScale,
|
||||
int HRatio,
|
||||
int VScale,
|
||||
int VRatio
|
||||
)
|
||||
{
|
||||
// if ( ppi->post_processing_level )
|
||||
// update_umvborder ( ppi, frame_buffer );
|
||||
|
||||
|
||||
switch (scaling_mode)
|
||||
{
|
||||
case SCALE_TO_FIT:
|
||||
case MAINTAIN_ASPECT_RATIO:
|
||||
{
|
||||
SCALE_VARS scale_vars;
|
||||
// center values
|
||||
#if 1
|
||||
int row = (dst_yuv_config->y_height - expanded_frame_height) / 2;
|
||||
int col = (dst_yuv_config->y_width - expanded_frame_width) / 2;
|
||||
// int YOffset = row * dst_yuv_config->y_width + col;
|
||||
// int UVOffset = (row>>1) * dst_yuv_config->uv_width + (col>>1);
|
||||
int YOffset = row * dst_yuv_config->y_stride + col;
|
||||
int UVOffset = (row >> 1) * dst_yuv_config->uv_stride + (col >> 1);
|
||||
#else
|
||||
int row = (src_yuv_config->y_height - expanded_frame_height) / 2;
|
||||
int col = (src_yuv_config->y_width - expanded_frame_width) / 2;
|
||||
int YOffset = row * src_yuv_config->y_width + col;
|
||||
int UVOffset = (row >> 1) * src_yuv_config->uv_width + (col >> 1);
|
||||
#endif
|
||||
|
||||
scale_vars.dst_yuv_config = dst_yuv_config;
|
||||
scale_vars.src_yuv_config = src_yuv_config;
|
||||
scale_vars.HScale = HScale;
|
||||
scale_vars.HRatio = HRatio;
|
||||
scale_vars.VScale = VScale;
|
||||
scale_vars.VRatio = VRatio;
|
||||
scale_vars.expanded_frame_width = expanded_frame_width;
|
||||
scale_vars.expanded_frame_height = expanded_frame_height;
|
||||
|
||||
// perform center and scale
|
||||
any_ratio_frame_scale(&scale_vars, YOffset, UVOffset);
|
||||
|
||||
break;
|
||||
}
|
||||
case CENTER:
|
||||
center_image(src_yuv_config, dst_yuv_config);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : yv12extend.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
//#include <stdlib.h>
|
||||
#include "vpx_scale/yv12config.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf)
|
||||
{
|
||||
int i;
|
||||
char *src_ptr1, *src_ptr2;
|
||||
char *dest_ptr1, *dest_ptr2;
|
||||
|
||||
unsigned int Border;
|
||||
int plane_stride;
|
||||
int plane_height;
|
||||
int plane_width;
|
||||
|
||||
/***********/
|
||||
/* Y Plane */
|
||||
/***********/
|
||||
Border = ybf->border;
|
||||
plane_stride = ybf->y_stride;
|
||||
plane_height = ybf->y_height;
|
||||
plane_width = ybf->y_width;
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->y_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
memset(dest_ptr1, src_ptr1[0], Border);
|
||||
memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->y_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)Border; i++)
|
||||
{
|
||||
memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
plane_stride /= 2;
|
||||
plane_height /= 2;
|
||||
plane_width /= 2;
|
||||
Border /= 2;
|
||||
|
||||
/***********/
|
||||
/* U Plane */
|
||||
/***********/
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->u_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
memset(dest_ptr1, src_ptr1[0], Border);
|
||||
memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->u_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* V Plane */
|
||||
/***********/
|
||||
|
||||
// copy the left and right most columns out
|
||||
src_ptr1 = ybf->v_buffer;
|
||||
src_ptr2 = src_ptr1 + plane_width - 1;
|
||||
dest_ptr1 = src_ptr1 - Border;
|
||||
dest_ptr2 = src_ptr2 + 1;
|
||||
|
||||
for (i = 0; i < plane_height; i++)
|
||||
{
|
||||
memset(dest_ptr1, src_ptr1[0], Border);
|
||||
memset(dest_ptr2, src_ptr2[0], Border);
|
||||
src_ptr1 += plane_stride;
|
||||
src_ptr2 += plane_stride;
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
|
||||
// Now copy the top and bottom source lines into each line of the respective borders
|
||||
src_ptr1 = ybf->v_buffer - Border;
|
||||
src_ptr2 = src_ptr1 + (plane_height * plane_stride) - plane_stride;
|
||||
dest_ptr1 = src_ptr1 - (Border * plane_stride);
|
||||
dest_ptr2 = src_ptr2 + plane_stride;
|
||||
|
||||
for (i = 0; i < (int)(Border); i++)
|
||||
{
|
||||
memcpy(dest_ptr1, src_ptr1, plane_stride);
|
||||
memcpy(dest_ptr2, src_ptr2, plane_stride);
|
||||
dest_ptr1 += plane_stride;
|
||||
dest_ptr2 += plane_stride;
|
||||
}
|
||||
}
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_yv12_copy_frame
|
||||
*
|
||||
* INPUTS :
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Copies the source image into the destination image and
|
||||
* updates the destination's UMV borders.
|
||||
*
|
||||
* SPECIAL NOTES : The frames are assumed to be identical in size.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc)
|
||||
{
|
||||
int row;
|
||||
int i;
|
||||
unsigned int *source;
|
||||
_Uncached unsigned int *dest;
|
||||
int height;
|
||||
int width;
|
||||
|
||||
height = src_ybc->y_height + (src_ybc->border * 2);
|
||||
width = src_ybc->y_width + (src_ybc->border * 2);
|
||||
width /= 4;
|
||||
source = (unsigned int *)(src_ybc->y_buffer - (src_ybc->border * src_ybc->y_stride) - src_ybc->border);
|
||||
dest = (_Uncached unsigned int *)(dst_ybc->y_buffer - (dst_ybc->border * dst_ybc->y_stride) - dst_ybc->border);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
dest[i] = source[i];
|
||||
}
|
||||
|
||||
source += width;
|
||||
dest += width;
|
||||
}
|
||||
|
||||
height = src_ybc->uv_height + (src_ybc->border);
|
||||
width = src_ybc->uv_width + (src_ybc->border);
|
||||
width /= 4;
|
||||
|
||||
source = (unsigned int *)(src_ybc->u_buffer - (src_ybc->border / 2 * src_ybc->uv_stride) - src_ybc->border / 2);
|
||||
dest = (_Uncached unsigned int *)(dst_ybc->u_buffer - (dst_ybc->border / 2 * dst_ybc->uv_stride) - dst_ybc->border / 2);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
dest[i] = source[i];
|
||||
}
|
||||
|
||||
source += width;
|
||||
dest += width;
|
||||
}
|
||||
|
||||
source = (unsigned int *)(src_ybc->v_buffer - (src_ybc->border / 2 * src_ybc->uv_stride) - src_ybc->border / 2);
|
||||
dest = (_Uncached unsigned int *)(dst_ybc->v_buffer - (dst_ybc->border / 2 * dst_ybc->uv_stride) - dst_ybc->border / 2);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
dest[i] = source[i];
|
||||
}
|
||||
|
||||
source += width;
|
||||
dest += width;
|
||||
}
|
||||
|
||||
}
|
@ -1,774 +0,0 @@
|
||||
;
|
||||
; Copyright (c) 2010 The WebM 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.
|
||||
;
|
||||
|
||||
|
||||
EXPORT |horizontal_line_4_5_scale_armv4|
|
||||
EXPORT |vertical_band_4_5_scale_armv4|
|
||||
EXPORT |horizontal_line_2_3_scale_armv4|
|
||||
EXPORT |vertical_band_2_3_scale_armv4|
|
||||
EXPORT |horizontal_line_3_5_scale_armv4|
|
||||
EXPORT |vertical_band_3_5_scale_armv4|
|
||||
EXPORT |horizontal_line_3_4_scale_armv4|
|
||||
EXPORT |vertical_band_3_4_scale_armv4|
|
||||
EXPORT |horizontal_line_1_2_scale_armv4|
|
||||
EXPORT |vertical_band_1_2_scale_armv4|
|
||||
|
||||
AREA |.text|, CODE, READONLY ; name this block of code
|
||||
|
||||
src RN r0
|
||||
srcw RN r1
|
||||
dest RN r2
|
||||
mask RN r12
|
||||
c51_205 RN r10
|
||||
c102_154 RN r11
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_4_5_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 4 to 5.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *source
|
||||
; r1 = UINT32 source_width
|
||||
; r2 = UINT8 *dest
|
||||
; r3 = UINT32 dest_width
|
||||
;)
|
||||
|horizontal_line_4_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
mov mask, #255 ; mask for selection
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldr r3, [src], #4
|
||||
|
||||
hl45_loop
|
||||
|
||||
and r4, r3, mask ; a = src[0]
|
||||
and r5, mask, r3, lsr #8 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
and r7, mask, r3, lsr #16 ; c = src[2]
|
||||
mul r6, c51_205, r6 ; a * 51 + 205 * b
|
||||
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5 ; b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsr #24 ; d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mul r7, c102_154, r7 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
ldr r3, [src], #4
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
and r9, mask, r3 ; e = src[4]
|
||||
orr r9, r9, r8, lsl #16 ; d | e
|
||||
mul r9, c51_205, r9 ; d * 205 + 51 * e
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #4
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bne hl45_loop
|
||||
|
||||
and r4, r3, mask
|
||||
and r5, mask, r3, lsl #8
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c51_205, r6
|
||||
|
||||
and r7, mask, r3, lsl #16
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsl #24
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mul r7, c102_154, r7
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldrb r3, [src]
|
||||
strb r3, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_4_5_scale_c|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_4_5_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
; * height of the band scaled is 4-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_4_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl45_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c51_205, r6 ; a * 51 + 205 * b
|
||||
|
||||
ldrb r8, [r3], r1 ; d = des[dest_pitch*3]
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5 ; b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
ldrb r9, [r3, r1] ; e = des [dest_pitch * 5]
|
||||
mul r7, c102_154, r7 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
orr r9, r9, r8, lsl #16 ; d | e
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
mul r9, c51_205, r9 ; d * 205 + 51 * e
|
||||
add r7, r7, #0x8000
|
||||
add src, src, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
bne vl45_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_4_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_2_3_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 2 to 3.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_2_3_scale_armv4
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_2_3_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
|
||||
hl23_loop
|
||||
|
||||
ldrb r3, [src], #1 ; a
|
||||
ldrb r4, [src], #1 ; b
|
||||
ldrb r5, [src] ; c
|
||||
|
||||
strb r3, [dest], #1
|
||||
mul r4, r12, r4 ; b * 171
|
||||
mla r6, lr, r3, r4 ; a * 85
|
||||
mla r7, lr, r5, r4 ; c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest], #1
|
||||
|
||||
add r7, r7, #128
|
||||
mov r7, r7, lsr #8
|
||||
strb r7, [dest], #1
|
||||
|
||||
subs srcw, srcw, #2
|
||||
bne hl23_loop
|
||||
|
||||
ldrb r4, [src, #1] ; b
|
||||
strb r5, [dest], #1
|
||||
strb r4, [dest, #1]
|
||||
|
||||
mul r4, r12, r4 ; b * 171
|
||||
mla r6, lr, r5, r4 ; a * 85 + b *171
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|horizontal_line_2_3_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_2_3_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 2 to 3. The
|
||||
; * height of the band scaled is 2-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_2_3_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_2_3_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r8, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
add r3, r1, r1, lsl #1 ; 3 * dest_pitch
|
||||
|
||||
vl23_loop
|
||||
ldrb r4, [src] ; a = des [0]
|
||||
ldrb r5, [src, r1] ; b = des [dest_pitch]
|
||||
ldrb r7, [src, r3] ; c = des [dest_pitch*3]
|
||||
subs r2, r2, #1
|
||||
|
||||
mul r5, r12, r5 ; b * 171
|
||||
mla r6, lr, r4, r5 ; a * 85
|
||||
mla r8, lr, r7, r5 ; c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [src, r1]
|
||||
|
||||
add r8, r8, #128
|
||||
mov r8, r8, lsr #8
|
||||
strb r8, [src, r1, lsl #1]
|
||||
|
||||
add src, src, #1
|
||||
|
||||
bne vl23_loop
|
||||
|
||||
ldmia sp!, {r4 - r8, pc}
|
||||
ENDP ;|vertical_band_2_3_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_horizontal_line_3_5_scale_c
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 3 to 5.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_horizontal_line_3_5_scale_c
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_3_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldrb r4, [src], #1 ; a = src[0]
|
||||
|
||||
hl35_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 ; b | a
|
||||
ldrb r9, [src], #1 ; c = src[2]
|
||||
mul r6, c102_154, r6 ; a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 ; b | c
|
||||
mul r5, c51_205, r5 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
ldrb r4, [src], #1 ; d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 ; c | b
|
||||
mul r7, c51_205, r7 ; c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
orr r9, r4, r9, lsl #16 ; c | d
|
||||
mul r9, c102_154, r9 ; c * 154 + 102 * d
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #3
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bpl hl35_loop
|
||||
|
||||
ldrb r5, [src], #1 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 ; b | a
|
||||
ldrb r9, [src], #1 ; c = src[2]
|
||||
mul r6, c102_154, r6 ; a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 ; b | c
|
||||
mul r5, c51_205, r5 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 ; c | b
|
||||
mul r7, c51_205, r7 ; c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
strb r9, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_3_5_scale_c|
|
||||
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_vertical_band_3_5_scale_c
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
; * height of the band scaled is 3-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_3_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl35_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r8, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c102_154, r8 ; a * 102 + 154 * b
|
||||
|
||||
ldrb r8, [r3, r1, lsl #1] ; d = des[dest_pitch*5]
|
||||
orr r3, r7, r5, lsl #16 ; b | c
|
||||
mul r9, c51_205, r3 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r3, r5, r7, lsl #16 ; c | b
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
mul r5, c51_205, r3 ; c * 205 + 154 * b
|
||||
add r9, r9, #0x8000
|
||||
orr r3, r8, r7, lsl #16 ; c | d
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
mul r7, c102_154, r3 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
add src, src, #1
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
|
||||
bne vl35_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_3_4_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 3 to 4.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_3_4_scale_armv4
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_3_4_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
ldrb r4, [src], #1 ; a = src[0]
|
||||
|
||||
hl34_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
ldrb r7, [src], #1 ; c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r8, r4 ; a*64 + b*192 + 1
|
||||
|
||||
add r8, r8, #1 ; b + 1
|
||||
add r8, r8, r7 ; b + c + 1
|
||||
mov r8, r8, asr #1 ; (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
strb r8, [dest], #1
|
||||
|
||||
ldrb r4, [src], #1 ; [a+1]
|
||||
|
||||
mla r7, r11, r7, r9 ; c*192 + 128
|
||||
mla r7, r4, r10, r7 ; a*64 + b*192 + 128
|
||||
|
||||
subs srcw, srcw, #3
|
||||
|
||||
mov r7, r7, asr #8 ; (a*64 + b*192 + 128) >> 8
|
||||
strb r7, [dest], #1
|
||||
|
||||
bpl hl34_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
ldrb r7, [src], #1 ; c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r8, r4 ; a*64 + b*192 + 1
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
add r8, r8, #1 ; b + 1
|
||||
add r8, r8, r7 ; b + c + 1
|
||||
mov r8, r8, asr #1 ; (b + c + 1) >> 1
|
||||
strb r8, [dest], #1
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_3_4_scale_c|
|
||||
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_3_4_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 3 to 4. The
|
||||
; * height of the band scaled is 3-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_3_4_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_3_4_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
; ldr r1,[r1]
|
||||
vl34_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des [dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r5, r4 ; a*64 + b*192 + 1
|
||||
|
||||
add r5, r5, #1 ; b + 1
|
||||
add r5, r5, r7 ; b + c + 1
|
||||
mov r5, r5, asr #1 ; (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [lr], r1
|
||||
|
||||
ldrb r4, [r3, r1] ; a = des [dest_pitch*4]
|
||||
|
||||
strb r5, [lr], r1
|
||||
|
||||
mla r7, r11, r7, r9 ; c*192 + 128
|
||||
mla r7, r4, r10, r7 ; a*64 + b*192 + 128
|
||||
mov r7, r7, asr #8 ; (a*64 + b*192 + 128) >> 8
|
||||
|
||||
add src, src, #1
|
||||
subs r2, r2, #1
|
||||
|
||||
strb r7, [lr]
|
||||
|
||||
bne vl34_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_3_4_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_horizontal_line_1_2_scale_c
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 1 to 2.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_horizontal_line_1_2_scale_c
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_1_2_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r5, lr}
|
||||
|
||||
sub srcw, srcw, #1
|
||||
|
||||
ldrb r3, [src], #1
|
||||
ldrb r4, [src], #1
|
||||
hl12_loop
|
||||
subs srcw, srcw, #1
|
||||
|
||||
add r5, r3, r4
|
||||
add r5, r5, #1
|
||||
mov r5, r5, lsr #1
|
||||
|
||||
orr r5, r3, r5, lsl #8
|
||||
strh r5, [dest], #2
|
||||
|
||||
mov r3, r4
|
||||
|
||||
ldrneb r4, [src], #1
|
||||
bne hl12_loop
|
||||
|
||||
orr r5, r4, r4, lsl #8
|
||||
strh r5, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r5, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_vertical_band_1_2_scale_c
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
; * height of the band scaled is 1-pixel.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_vertical_band_1_2_scale_c
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_1_2_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r7, lr}
|
||||
|
||||
ldr mask, =0xff00ff ; mask for selection
|
||||
ldr lr, = 0x010001
|
||||
|
||||
vl12_loop
|
||||
mov r3, src
|
||||
ldr r4, [r3], r1
|
||||
ldr r5, [r3, r1]
|
||||
|
||||
add src, src, #4
|
||||
subs r2, r2, #4
|
||||
|
||||
and r6, r4, mask
|
||||
and r7, r5, mask
|
||||
|
||||
add r6, r7, r6
|
||||
add r6, r6, lr
|
||||
|
||||
and r4, mask, r4, lsr #8
|
||||
and r5, mask, r5, lsr #8
|
||||
|
||||
mov r6, r6, lsr #1
|
||||
and r6, r6, mask
|
||||
|
||||
add r4, r5, r4
|
||||
add r4, r4, lr
|
||||
|
||||
mov r4, r4, lsr #1
|
||||
and r4, r4, mask
|
||||
|
||||
orr r5, r6, r4, lsl #8
|
||||
|
||||
str r5, [r3]
|
||||
|
||||
bpl vl12_loop
|
||||
|
||||
ldmia sp!, {r4 - r7, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
END
|
@ -1,808 +0,0 @@
|
||||
@ This file was created from a .asm file
|
||||
@ using the ads2gas.pl script.
|
||||
|
||||
.equ WIDE_REFERENCE, 0
|
||||
.ifndef ARCHITECTURE
|
||||
.equ ARCHITECTURE, 5
|
||||
.endif
|
||||
.global horizontal_line_4_5_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type horizontal_line_4_5_scale_armv4, function
|
||||
.endif
|
||||
.global vertical_band_4_5_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type vertical_band_4_5_scale_armv4, function
|
||||
.endif
|
||||
.global horizontal_line_2_3_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type horizontal_line_2_3_scale_armv4, function
|
||||
.endif
|
||||
.global vertical_band_2_3_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type vertical_band_2_3_scale_armv4, function
|
||||
.endif
|
||||
.global horizontal_line_3_5_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type horizontal_line_3_5_scale_armv4, function
|
||||
.endif
|
||||
.global vertical_band_3_5_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type vertical_band_3_5_scale_armv4, function
|
||||
.endif
|
||||
.global horizontal_line_3_4_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type horizontal_line_3_4_scale_armv4, function
|
||||
.endif
|
||||
.global vertical_band_3_4_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type vertical_band_3_4_scale_armv4, function
|
||||
.endif
|
||||
.global horizontal_line_1_2_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type horizontal_line_1_2_scale_armv4, function
|
||||
.endif
|
||||
.global vertical_band_1_2_scale_armv4
|
||||
.ifndef NO_TYPE_PSEUDO_OP
|
||||
.type vertical_band_1_2_scale_armv4, function
|
||||
.endif
|
||||
|
||||
.text
|
||||
|
||||
src .req r0
|
||||
srcw .req r1
|
||||
dest .req r2
|
||||
mask .req r12
|
||||
c51_205 .req r10
|
||||
c102_154 .req r11
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : horizontal_line_4_5_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
@ * unsigned int source_width : Stride of source.
|
||||
@ * unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Copies horizontal line of pixels from source to
|
||||
@ * destination scaling up by 4 to 5.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : None.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void horizontal_line_4_5_scale_armv4
|
||||
@(
|
||||
@ r0 = UINT8 *source
|
||||
@ r1 = UINT32 source_width
|
||||
@ r2 = UINT8 *dest
|
||||
@ r3 = UINT32 dest_width
|
||||
@)
|
||||
_HorizontalLine_4_5_Scale_ARMv4:
|
||||
horizontal_line_4_5_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
mov mask, #255 @ mask for selection
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldr r3, [src], #4
|
||||
|
||||
hl45_loop:
|
||||
|
||||
and r4, r3, mask @ a = src[0]
|
||||
and r5, mask, r3, lsr #8 @ b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 @ b | a
|
||||
and r7, mask, r3, lsr #16 @ c = src[2]
|
||||
mul r6, c51_205, r6 @ a * 51 + 205 * b
|
||||
|
||||
orr r5, r5, r7, lsl #16 @ c | b
|
||||
mul r5, c102_154, r5 @ b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsr #24 @ d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 @ c | d
|
||||
mul r7, c102_154, r7 @ c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
ldr r3, [src], #4
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
and r9, mask, r3 @ e = src[4]
|
||||
orr r9, r9, r8, lsl #16 @ d | e
|
||||
mul r9, c51_205, r9 @ d * 205 + 51 * e
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #4
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bne hl45_loop
|
||||
|
||||
and r4, r3, mask
|
||||
and r5, mask, r3, lsl #8
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 @ b | a
|
||||
mul r6, c51_205, r6
|
||||
|
||||
and r7, mask, r3, lsl #16
|
||||
orr r5, r5, r7, lsl #16 @ c | b
|
||||
mul r5, c102_154, r5
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsl #24
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 @ c | d
|
||||
mul r7, c102_154, r7
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldrb r3, [src]
|
||||
strb r3, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vp8cx_horizontal_line_4_5_scale_c|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vertical_band_4_5_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_pitch : Stride of destination data.
|
||||
@ * unsigned int dest_width : Width of destination data.
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
@ * height of the band scaled is 4-pixels.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
@ * the current band.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vertical_band_4_5_scale_armv4
|
||||
@(
|
||||
@ r0 = UINT8 *dest
|
||||
@ r1 = UINT32 dest_pitch
|
||||
@ r2 = UINT32 dest_width
|
||||
@)
|
||||
_VerticalBand_4_5_Scale_ARMv4:
|
||||
vertical_band_4_5_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl45_loop:
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 @ a = des [0]
|
||||
ldrb r5, [r3], r1 @ b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 @ c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r6, r4, r5, lsl #16 @ b | a
|
||||
mul r6, c51_205, r6 @ a * 51 + 205 * b
|
||||
|
||||
ldrb r8, [r3], r1 @ d = des[dest_pitch*3]
|
||||
orr r5, r5, r7, lsl #16 @ c | b
|
||||
mul r5, c102_154, r5 @ b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r7, r8, r7, lsl #16 @ c | d
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
ldrb r9, [r3, r1] @ e = des [dest_pitch * 5]
|
||||
mul r7, c102_154, r7 @ c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
orr r9, r9, r8, lsl #16 @ d | e
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
mul r9, c51_205, r9 @ d * 205 + 51 * e
|
||||
add r7, r7, #0x8000
|
||||
add src, src, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
bne vl45_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vertical_band_4_5_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : horizontal_line_2_3_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
@ * unsigned int source_width : Stride of source.
|
||||
@ * unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Copies horizontal line of pixels from source to
|
||||
@ * destination scaling up by 2 to 3.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : None.
|
||||
@ *
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void horizontal_line_2_3_scale_armv4
|
||||
@(
|
||||
@ const unsigned char *source,
|
||||
@ unsigned int source_width,
|
||||
@ unsigned char *dest,
|
||||
@ unsigned int dest_width
|
||||
@)
|
||||
_HorizontalLine_2_3_Scale_ARMv4:
|
||||
horizontal_line_2_3_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
|
||||
hl23_loop:
|
||||
|
||||
ldrb r3, [src], #1 @ a
|
||||
ldrb r4, [src], #1 @ b
|
||||
ldrb r5, [src] @ c
|
||||
|
||||
strb r3, [dest], #1
|
||||
mul r4, r12, r4 @ b * 171
|
||||
mla r6, lr, r3, r4 @ a * 85
|
||||
mla r7, lr, r5, r4 @ c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest], #1
|
||||
|
||||
add r7, r7, #128
|
||||
mov r7, r7, lsr #8
|
||||
strb r7, [dest], #1
|
||||
|
||||
subs srcw, srcw, #2
|
||||
bne hl23_loop
|
||||
|
||||
ldrb r4, [src, #1] @ b
|
||||
strb r5, [dest], #1
|
||||
strb r4, [dest, #1]
|
||||
|
||||
mul r4, r12, r4 @ b * 171
|
||||
mla r6, lr, r5, r4 @ a * 85 + b *171
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|horizontal_line_2_3_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vertical_band_2_3_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_pitch : Stride of destination data.
|
||||
@ * unsigned int dest_width : Width of destination data.
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Scales vertical band of pixels by scale 2 to 3. The
|
||||
@ * height of the band scaled is 2-pixels.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
@ * the current band.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vertical_band_2_3_scale_armv4
|
||||
@(
|
||||
@ r0 = UINT8 *dest
|
||||
@ r1 = UINT32 dest_pitch
|
||||
@ r2 = UINT32 dest_width
|
||||
@)
|
||||
_VerticalBand_2_3_Scale_ARMv4:
|
||||
vertical_band_2_3_scale_armv4: @
|
||||
stmdb sp!, {r4 - r8, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
add r3, r1, r1, lsl #1 @ 3 * dest_pitch
|
||||
|
||||
vl23_loop:
|
||||
ldrb r4, [src] @ a = des [0]
|
||||
ldrb r5, [src, r1] @ b = des [dest_pitch]
|
||||
ldrb r7, [src, r3] @ c = des [dest_pitch*3]
|
||||
subs r2, r2, #1
|
||||
|
||||
mul r5, r12, r5 @ b * 171
|
||||
mla r6, lr, r4, r5 @ a * 85
|
||||
mla r8, lr, r7, r5 @ c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [src, r1]
|
||||
|
||||
add r8, r8, #128
|
||||
mov r8, r8, lsr #8
|
||||
strb r8, [src, r1, lsl #1]
|
||||
|
||||
add src, src, #1
|
||||
|
||||
bne vl23_loop
|
||||
|
||||
ldmia sp!, {r4 - r8, pc}
|
||||
@ @|vertical_band_2_3_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vp8cx_horizontal_line_3_5_scale_c
|
||||
@ *
|
||||
@ * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
@ * unsigned int source_width : Stride of source.
|
||||
@ * unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Copies horizontal line of pixels from source to
|
||||
@ * destination scaling up by 3 to 5.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : None.
|
||||
@ *
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vp8cx_horizontal_line_3_5_scale_c
|
||||
@(
|
||||
@ const unsigned char *source,
|
||||
@ unsigned int source_width,
|
||||
@ unsigned char *dest,
|
||||
@ unsigned int dest_width
|
||||
@)
|
||||
_HorizontalLine_3_5_Scale_ARMv4:
|
||||
horizontal_line_3_5_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldrb r4, [src], #1 @ a = src[0]
|
||||
|
||||
hl35_loop:
|
||||
|
||||
ldrb r8, [src], #1 @ b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 @ b | a
|
||||
ldrb r9, [src], #1 @ c = src[2]
|
||||
mul r6, c102_154, r6 @ a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 @ b | c
|
||||
mul r5, c51_205, r5 @ b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
ldrb r4, [src], #1 @ d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 @ c | b
|
||||
mul r7, c51_205, r7 @ c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
orr r9, r4, r9, lsl #16 @ c | d
|
||||
mul r9, c102_154, r9 @ c * 154 + 102 * d
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #3
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bpl hl35_loop
|
||||
|
||||
ldrb r5, [src], #1 @ b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 @ b | a
|
||||
ldrb r9, [src], #1 @ c = src[2]
|
||||
mul r6, c102_154, r6 @ a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 @ b | c
|
||||
mul r5, c51_205, r5 @ b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 @ c | b
|
||||
mul r7, c51_205, r7 @ c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
strb r9, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vp8cx_horizontal_line_3_5_scale_c|
|
||||
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vp8cx_vertical_band_3_5_scale_c
|
||||
@ *
|
||||
@ * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_pitch : Stride of destination data.
|
||||
@ * unsigned int dest_width : Width of destination data.
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
@ * height of the band scaled is 3-pixels.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
@ * the current band.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vertical_band_4_5_scale_armv4
|
||||
@(
|
||||
@ r0 = UINT8 *dest
|
||||
@ r1 = UINT32 dest_pitch
|
||||
@ r2 = UINT32 dest_width
|
||||
@)
|
||||
_VerticalBand_3_5_Scale_ARMv4:
|
||||
vertical_band_3_5_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl35_loop:
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 @ a = des [0]
|
||||
ldrb r5, [r3], r1 @ b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 @ c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r8, r4, r5, lsl #16 @ b | a
|
||||
mul r6, c102_154, r8 @ a * 102 + 154 * b
|
||||
|
||||
ldrb r8, [r3, r1, lsl #1] @ d = des[dest_pitch*5]
|
||||
orr r3, r7, r5, lsl #16 @ b | c
|
||||
mul r9, c51_205, r3 @ b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r3, r5, r7, lsl #16 @ c | b
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
mul r5, c51_205, r3 @ c * 205 + 154 * b
|
||||
add r9, r9, #0x8000
|
||||
orr r3, r8, r7, lsl #16 @ c | d
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
mul r7, c102_154, r3 @ c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
add src, src, #1
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
|
||||
bne vl35_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vertical_band_3_5_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : horizontal_line_3_4_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
@ * unsigned int source_width : Stride of source.
|
||||
@ * unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Copies horizontal line of pixels from source to
|
||||
@ * destination scaling up by 3 to 4.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : None.
|
||||
@ *
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void horizontal_line_3_4_scale_armv4
|
||||
@(
|
||||
@ const unsigned char *source,
|
||||
@ unsigned int source_width,
|
||||
@ unsigned char *dest,
|
||||
@ unsigned int dest_width
|
||||
@)
|
||||
_HorizontalLine_3_4_Scale_ARMv4:
|
||||
horizontal_line_3_4_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
ldrb r4, [src], #1 @ a = src[0]
|
||||
|
||||
hl34_loop:
|
||||
|
||||
ldrb r8, [src], #1 @ b = src[1]
|
||||
ldrb r7, [src], #1 @ c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 @ a*64 + 128
|
||||
mla r4, r11, r8, r4 @ a*64 + b*192 + 1
|
||||
|
||||
add r8, r8, #1 @ b + 1
|
||||
add r8, r8, r7 @ b + c + 1
|
||||
mov r8, r8, asr #1 @ (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 @ (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
strb r8, [dest], #1
|
||||
|
||||
ldrb r4, [src], #1 @ [a+1]
|
||||
|
||||
mla r7, r11, r7, r9 @ c*192 + 128
|
||||
mla r7, r4, r10, r7 @ a*64 + b*192 + 128
|
||||
|
||||
subs srcw, srcw, #3
|
||||
|
||||
mov r7, r7, asr #8 @ (a*64 + b*192 + 128) >> 8
|
||||
strb r7, [dest], #1
|
||||
|
||||
bpl hl34_loop
|
||||
|
||||
ldrb r8, [src], #1 @ b = src[1]
|
||||
ldrb r7, [src], #1 @ c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 @ a*64 + 128
|
||||
mla r4, r11, r8, r4 @ a*64 + b*192 + 1
|
||||
mov r4, r4, asr #8 @ (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
add r8, r8, #1 @ b + 1
|
||||
add r8, r8, r7 @ b + c + 1
|
||||
mov r8, r8, asr #1 @ (b + c + 1) >> 1
|
||||
strb r8, [dest], #1
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vp8cx_horizontal_line_3_4_scale_c|
|
||||
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vertical_band_3_4_scale_armv4
|
||||
@ *
|
||||
@ * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_pitch : Stride of destination data.
|
||||
@ * unsigned int dest_width : Width of destination data.
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Scales vertical band of pixels by scale 3 to 4. The
|
||||
@ * height of the band scaled is 3-pixels.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
@ * the current band.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vertical_band_3_4_scale_armv4
|
||||
@(
|
||||
@ r0 = UINT8 *dest
|
||||
@ r1 = UINT32 dest_pitch
|
||||
@ r2 = UINT32 dest_width
|
||||
@)
|
||||
_VerticalBand_3_4_Scale_ARMv4:
|
||||
vertical_band_3_4_scale_armv4: @
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
@ ldr r1,[r1]
|
||||
vl34_loop:
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 @ a = des [0]
|
||||
ldrb r5, [r3], r1 @ b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 @ c = des [dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
mla r4, r10, r4, r9 @ a*64 + 128
|
||||
mla r4, r11, r5, r4 @ a*64 + b*192 + 1
|
||||
|
||||
add r5, r5, #1 @ b + 1
|
||||
add r5, r5, r7 @ b + c + 1
|
||||
mov r5, r5, asr #1 @ (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 @ (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [lr], r1
|
||||
|
||||
ldrb r4, [r3, r1] @ a = des [dest_pitch*4]
|
||||
|
||||
strb r5, [lr], r1
|
||||
|
||||
mla r7, r11, r7, r9 @ c*192 + 128
|
||||
mla r7, r4, r10, r7 @ a*64 + b*192 + 128
|
||||
mov r7, r7, asr #8 @ (a*64 + b*192 + 128) >> 8
|
||||
|
||||
add src, src, #1
|
||||
subs r2, r2, #1
|
||||
|
||||
strb r7, [lr]
|
||||
|
||||
bne vl34_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
@ @|vertical_band_3_4_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vp8cx_horizontal_line_1_2_scale_c
|
||||
@ *
|
||||
@ * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
@ * unsigned int source_width : Stride of source.
|
||||
@ * unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Copies horizontal line of pixels from source to
|
||||
@ * destination scaling up by 1 to 2.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : None.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vp8cx_horizontal_line_1_2_scale_c
|
||||
@(
|
||||
@ const unsigned char *source,
|
||||
@ unsigned int source_width,
|
||||
@ unsigned char *dest,
|
||||
@ unsigned int dest_width
|
||||
@)
|
||||
_HorizontalLine_1_2_Scale_ARMv4:
|
||||
horizontal_line_1_2_scale_armv4: @
|
||||
stmdb sp!, {r4 - r5, lr}
|
||||
|
||||
sub srcw, srcw, #1
|
||||
|
||||
ldrb r3, [src], #1
|
||||
ldrb r4, [src], #1
|
||||
hl12_loop:
|
||||
subs srcw, srcw, #1
|
||||
|
||||
add r5, r3, r4
|
||||
add r5, r5, #1
|
||||
mov r5, r5, lsr #1
|
||||
|
||||
orr r5, r3, r5, lsl #8
|
||||
strh r5, [dest], #2
|
||||
|
||||
mov r3, r4
|
||||
|
||||
ldrneb r4, [src], #1
|
||||
bne hl12_loop
|
||||
|
||||
orr r5, r4, r4, lsl #8
|
||||
strh r5, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r5, pc}
|
||||
@ @|vertical_band_3_5_scale_armv4|
|
||||
|
||||
@/****************************************************************************
|
||||
@ *
|
||||
@ * ROUTINE : vp8cx_vertical_band_1_2_scale_c
|
||||
@ *
|
||||
@ * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
@ * unsigned int dest_pitch : Stride of destination data.
|
||||
@ * unsigned int dest_width : Width of destination data.
|
||||
@ *
|
||||
@ * OUTPUTS : None.
|
||||
@ *
|
||||
@ * RETU.req_s : void
|
||||
@ *
|
||||
@ * FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
@ * height of the band scaled is 1-pixel.
|
||||
@ *
|
||||
@ * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
@ * the current band.
|
||||
@ *
|
||||
@ ****************************************************************************/
|
||||
@void vp8cx_vertical_band_1_2_scale_c
|
||||
@(
|
||||
@ r0 = UINT8 *dest
|
||||
@ r1 = UINT32 dest_pitch
|
||||
@ r2 = UINT32 dest_width
|
||||
@)
|
||||
_VerticalBand_1_2_Scale_ARMv4:
|
||||
vertical_band_1_2_scale_armv4: @
|
||||
stmdb sp!, {r4 - r7, lr}
|
||||
|
||||
ldr mask, =0xff00ff @ mask for selection
|
||||
ldr lr, = 0x010001
|
||||
|
||||
vl12_loop:
|
||||
mov r3, src
|
||||
ldr r4, [r3], r1
|
||||
ldr r5, [r3, r1]
|
||||
|
||||
add src, src, #4
|
||||
subs r2, r2, #4
|
||||
|
||||
and r6, r4, mask
|
||||
and r7, r5, mask
|
||||
|
||||
add r6, r7, r6
|
||||
add r6, r6, lr
|
||||
|
||||
and r4, mask, r4, lsr #8
|
||||
and r5, mask, r5, lsr #8
|
||||
|
||||
mov r6, r6, lsr #1
|
||||
and r6, r6, mask
|
||||
|
||||
add r4, r5, r4
|
||||
add r4, r4, lr
|
||||
|
||||
mov r4, r4, lsr #1
|
||||
and r4, r4, mask
|
||||
|
||||
orr r5, r6, r4, lsl #8
|
||||
|
||||
str r5, [r3]
|
||||
|
||||
bpl vl12_loop
|
||||
|
||||
ldmia sp!, {r4 - r7, pc}
|
||||
@ @|vertical_band_3_5_scale_armv4|
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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 "vpx_scale/vpxscale.h"
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_scale_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_scale_machine_specific_config()
|
||||
{
|
||||
#ifndef VPX_NO_GLOBALS
|
||||
vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_armv4;
|
||||
vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_armv4;
|
||||
vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_armv4;
|
||||
vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_armv4;
|
||||
vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
vp8_horizontal_line_3_4_scale = horizontal_line_3_4_scale_armv4;
|
||||
vp8_vertical_band_3_4_scale = vertical_band_3_4_scale_armv4;
|
||||
vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
|
||||
vp8_horizontal_line_2_3_scale = horizontal_line_2_3_scale_armv4;
|
||||
vp8_vertical_band_2_3_scale = vertical_band_2_3_scale_armv4;
|
||||
vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
|
||||
vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_armv4;
|
||||
vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_armv4;
|
||||
vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
|
||||
|
||||
vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
|
||||
vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
|
||||
vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
|
||||
vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
|
||||
vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
|
||||
vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
|
||||
vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
|
||||
#endif
|
||||
}
|
@ -1,774 +0,0 @@
|
||||
;
|
||||
; Copyright (c) 2010 The WebM 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.
|
||||
;
|
||||
|
||||
|
||||
EXPORT |horizontal_line_4_5_scale_armv4|
|
||||
EXPORT |vertical_band_4_5_scale_armv4|
|
||||
EXPORT |horizontal_line_2_3_scale_armv4|
|
||||
EXPORT |vertical_band_2_3_scale_armv4|
|
||||
EXPORT |horizontal_line_3_5_scale_armv4|
|
||||
EXPORT |vertical_band_3_5_scale_armv4|
|
||||
EXPORT |horizontal_line_3_4_scale_armv4|
|
||||
EXPORT |vertical_band_3_4_scale_armv4|
|
||||
EXPORT |horizontal_line_1_2_scale_armv4|
|
||||
EXPORT |vertical_band_1_2_scale_armv4|
|
||||
|
||||
AREA |.text|, CODE, READONLY ; name this block of code
|
||||
|
||||
src RN r0
|
||||
srcw RN r1
|
||||
dest RN r2
|
||||
mask RN r12
|
||||
c51_205 RN r10
|
||||
c102_154 RN r11
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_4_5_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 4 to 5.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *source
|
||||
; r1 = UINT32 source_width
|
||||
; r2 = UINT8 *dest
|
||||
; r3 = UINT32 dest_width
|
||||
;)
|
||||
|horizontal_line_4_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
mov mask, #255 ; mask for selection
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldr r3, [src], #4
|
||||
|
||||
hl45_loop
|
||||
|
||||
and r4, r3, mask ; a = src[0]
|
||||
and r5, mask, r3, lsr #8 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
and r7, mask, r3, lsr #16 ; c = src[2]
|
||||
mul r6, c51_205, r6 ; a * 51 + 205 * b
|
||||
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5 ; b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsr #24 ; d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mul r7, c102_154, r7 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
ldr r3, [src], #4
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
and r9, mask, r3 ; e = src[4]
|
||||
orr r9, r9, r8, lsl #16 ; d | e
|
||||
mul r9, c51_205, r9 ; d * 205 + 51 * e
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #4
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bne hl45_loop
|
||||
|
||||
and r4, r3, mask
|
||||
and r5, mask, r3, lsl #8
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c51_205, r6
|
||||
|
||||
and r7, mask, r3, lsl #16
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5
|
||||
add r6, r6, #0x8000
|
||||
and r8, mask, r3, lsl #24
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mul r7, c102_154, r7
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldrb r3, [src]
|
||||
strb r3, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_4_5_scale_c|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_4_5_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 4 to 5. The
|
||||
; * height of the band scaled is 4-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_4_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl45_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r6, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c51_205, r6 ; a * 51 + 205 * b
|
||||
|
||||
ldrb r8, [r3], r1 ; d = des[dest_pitch*3]
|
||||
orr r5, r5, r7, lsl #16 ; c | b
|
||||
mul r5, c102_154, r5 ; b * 102 + 154 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r7, r8, r7, lsl #16 ; c | d
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
ldrb r9, [r3, r1] ; e = des [dest_pitch * 5]
|
||||
mul r7, c102_154, r7 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
orr r9, r9, r8, lsl #16 ; d | e
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
mul r9, c51_205, r9 ; d * 205 + 51 * e
|
||||
add r7, r7, #0x8000
|
||||
add src, src, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
bne vl45_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_4_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_2_3_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 2 to 3.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_2_3_scale_armv4
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_2_3_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
|
||||
hl23_loop
|
||||
|
||||
ldrb r3, [src], #1 ; a
|
||||
ldrb r4, [src], #1 ; b
|
||||
ldrb r5, [src] ; c
|
||||
|
||||
strb r3, [dest], #1
|
||||
mul r4, r12, r4 ; b * 171
|
||||
mla r6, lr, r3, r4 ; a * 85
|
||||
mla r7, lr, r5, r4 ; c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest], #1
|
||||
|
||||
add r7, r7, #128
|
||||
mov r7, r7, lsr #8
|
||||
strb r7, [dest], #1
|
||||
|
||||
subs srcw, srcw, #2
|
||||
bne hl23_loop
|
||||
|
||||
ldrb r4, [src, #1] ; b
|
||||
strb r5, [dest], #1
|
||||
strb r4, [dest, #1]
|
||||
|
||||
mul r4, r12, r4 ; b * 171
|
||||
mla r6, lr, r5, r4 ; a * 85 + b *171
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|horizontal_line_2_3_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_2_3_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 2 to 3. The
|
||||
; * height of the band scaled is 2-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_2_3_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_2_3_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r8, lr}
|
||||
ldr lr, =85
|
||||
ldr r12, =171
|
||||
add r3, r1, r1, lsl #1 ; 3 * dest_pitch
|
||||
|
||||
vl23_loop
|
||||
ldrb r4, [src] ; a = des [0]
|
||||
ldrb r5, [src, r1] ; b = des [dest_pitch]
|
||||
ldrb r7, [src, r3] ; c = des [dest_pitch*3]
|
||||
subs r2, r2, #1
|
||||
|
||||
mul r5, r12, r5 ; b * 171
|
||||
mla r6, lr, r4, r5 ; a * 85
|
||||
mla r8, lr, r7, r5 ; c * 85
|
||||
|
||||
add r6, r6, #128
|
||||
mov r6, r6, lsr #8
|
||||
strb r6, [src, r1]
|
||||
|
||||
add r8, r8, #128
|
||||
mov r8, r8, lsr #8
|
||||
strb r8, [src, r1, lsl #1]
|
||||
|
||||
add src, src, #1
|
||||
|
||||
bne vl23_loop
|
||||
|
||||
ldmia sp!, {r4 - r8, pc}
|
||||
ENDP ;|vertical_band_2_3_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_horizontal_line_3_5_scale_c
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 3 to 5.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_horizontal_line_3_5_scale_c
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_3_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
ldrb r4, [src], #1 ; a = src[0]
|
||||
|
||||
hl35_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 ; b | a
|
||||
ldrb r9, [src], #1 ; c = src[2]
|
||||
mul r6, c102_154, r6 ; a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 ; b | c
|
||||
mul r5, c51_205, r5 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
ldrb r4, [src], #1 ; d = src[3]
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 ; c | b
|
||||
mul r7, c51_205, r7 ; c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
orr r9, r4, r9, lsl #16 ; c | d
|
||||
mul r9, c102_154, r9 ; c * 154 + 102 * d
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
|
||||
add r9, r9, #0x8000
|
||||
subs srcw, srcw, #3
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [dest], #1
|
||||
|
||||
bpl hl35_loop
|
||||
|
||||
ldrb r5, [src], #1 ; b = src[1]
|
||||
strb r4, [dest], #1
|
||||
|
||||
orr r6, r4, r8, lsl #16 ; b | a
|
||||
ldrb r9, [src], #1 ; c = src[2]
|
||||
mul r6, c102_154, r6 ; a * 102 + 154 * b
|
||||
|
||||
orr r5, r9, r8, lsl #16 ; b | c
|
||||
mul r5, c51_205, r5 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [dest], #1
|
||||
|
||||
orr r7, r8, r9, lsl #16 ; c | b
|
||||
mul r7, c51_205, r7 ; c * 205 + 154 * b
|
||||
add r5, r5, #0x8000
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [dest], #1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [dest], #1
|
||||
strb r9, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_3_5_scale_c|
|
||||
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_vertical_band_3_5_scale_c
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 3 to 5. The
|
||||
; * height of the band scaled is 3-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_4_5_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_3_5_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr c51_205, =0x3300cd
|
||||
ldr c102_154, =0x66009a
|
||||
|
||||
vl35_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des[dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
orr r8, r4, r5, lsl #16 ; b | a
|
||||
mul r6, c102_154, r8 ; a * 102 + 154 * b
|
||||
|
||||
ldrb r8, [r3, r1, lsl #1] ; d = des[dest_pitch*5]
|
||||
orr r3, r7, r5, lsl #16 ; b | c
|
||||
mul r9, c51_205, r3 ; b * 205 + 51 * c
|
||||
add r6, r6, #0x8000
|
||||
orr r3, r5, r7, lsl #16 ; c | b
|
||||
mov r6, r6, lsr #24
|
||||
strb r6, [lr], r1
|
||||
|
||||
mul r5, c51_205, r3 ; c * 205 + 154 * b
|
||||
add r9, r9, #0x8000
|
||||
orr r3, r8, r7, lsl #16 ; c | d
|
||||
mov r9, r9, lsr #24
|
||||
strb r9, [lr], r1
|
||||
|
||||
mul r7, c102_154, r3 ; c * 154 + 102 * d
|
||||
add r5, r5, #0x8000
|
||||
add src, src, #1
|
||||
mov r5, r5, lsr #24
|
||||
strb r5, [lr], r1
|
||||
|
||||
add r7, r7, #0x8000
|
||||
subs r2, r2, #1
|
||||
mov r7, r7, lsr #24
|
||||
strb r7, [lr], r1
|
||||
|
||||
|
||||
bne vl35_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : horizontal_line_3_4_scale_armv4
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 3 to 4.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void horizontal_line_3_4_scale_armv4
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_3_4_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
ldrb r4, [src], #1 ; a = src[0]
|
||||
|
||||
hl34_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
ldrb r7, [src], #1 ; c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r8, r4 ; a*64 + b*192 + 1
|
||||
|
||||
add r8, r8, #1 ; b + 1
|
||||
add r8, r8, r7 ; b + c + 1
|
||||
mov r8, r8, asr #1 ; (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
strb r8, [dest], #1
|
||||
|
||||
ldrb r4, [src], #1 ; [a+1]
|
||||
|
||||
mla r7, r11, r7, r9 ; c*192 + 128
|
||||
mla r7, r4, r10, r7 ; a*64 + b*192 + 128
|
||||
|
||||
subs srcw, srcw, #3
|
||||
|
||||
mov r7, r7, asr #8 ; (a*64 + b*192 + 128) >> 8
|
||||
strb r7, [dest], #1
|
||||
|
||||
bpl hl34_loop
|
||||
|
||||
ldrb r8, [src], #1 ; b = src[1]
|
||||
ldrb r7, [src], #1 ; c = src[2]
|
||||
strb r4, [dest], #1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r8, r4 ; a*64 + b*192 + 1
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [dest], #1
|
||||
|
||||
add r8, r8, #1 ; b + 1
|
||||
add r8, r8, r7 ; b + c + 1
|
||||
mov r8, r8, asr #1 ; (b + c + 1) >> 1
|
||||
strb r8, [dest], #1
|
||||
strb r7, [dest], #1
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vp8cx_horizontal_line_3_4_scale_c|
|
||||
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vertical_band_3_4_scale_armv4
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 3 to 4. The
|
||||
; * height of the band scaled is 3-pixels.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vertical_band_3_4_scale_armv4
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_3_4_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r11, lr}
|
||||
|
||||
ldr r10, =64
|
||||
ldr r11, =192
|
||||
mov r9, #128
|
||||
|
||||
; ldr r1,[r1]
|
||||
vl34_loop
|
||||
mov r3, src
|
||||
ldrb r4, [r3], r1 ; a = des [0]
|
||||
ldrb r5, [r3], r1 ; b = des [dest_pitch]
|
||||
ldrb r7, [r3], r1 ; c = des [dest_pitch*2]
|
||||
add lr, src, r1
|
||||
|
||||
mla r4, r10, r4, r9 ; a*64 + 128
|
||||
mla r4, r11, r5, r4 ; a*64 + b*192 + 1
|
||||
|
||||
add r5, r5, #1 ; b + 1
|
||||
add r5, r5, r7 ; b + c + 1
|
||||
mov r5, r5, asr #1 ; (b + c + 1) >> 1
|
||||
|
||||
mov r4, r4, asr #8 ; (a*64 + b*192 + 1) >> 8
|
||||
strb r4, [lr], r1
|
||||
|
||||
ldrb r4, [r3, r1] ; a = des [dest_pitch*4]
|
||||
|
||||
strb r5, [lr], r1
|
||||
|
||||
mla r7, r11, r7, r9 ; c*192 + 128
|
||||
mla r7, r4, r10, r7 ; a*64 + b*192 + 128
|
||||
mov r7, r7, asr #8 ; (a*64 + b*192 + 128) >> 8
|
||||
|
||||
add src, src, #1
|
||||
subs r2, r2, #1
|
||||
|
||||
strb r7, [lr]
|
||||
|
||||
bne vl34_loop
|
||||
|
||||
ldmia sp!, {r4 - r11, pc}
|
||||
ENDP ;|vertical_band_3_4_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_horizontal_line_1_2_scale_c
|
||||
; *
|
||||
; * INPUTS : const unsigned char *source : Pointer to source data.
|
||||
; * unsigned int source_width : Stride of source.
|
||||
; * unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_width : Stride of destination (NOT USED).
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Copies horizontal line of pixels from source to
|
||||
; * destination scaling up by 1 to 2.
|
||||
; *
|
||||
; * SPECIAL NOTES : None.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_horizontal_line_1_2_scale_c
|
||||
;(
|
||||
; const unsigned char *source,
|
||||
; unsigned int source_width,
|
||||
; unsigned char *dest,
|
||||
; unsigned int dest_width
|
||||
;)
|
||||
|horizontal_line_1_2_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r5, lr}
|
||||
|
||||
sub srcw, srcw, #1
|
||||
|
||||
ldrb r3, [src], #1
|
||||
ldrb r4, [src], #1
|
||||
hl12_loop
|
||||
subs srcw, srcw, #1
|
||||
|
||||
add r5, r3, r4
|
||||
add r5, r5, #1
|
||||
mov r5, r5, lsr #1
|
||||
|
||||
orr r5, r3, r5, lsl #8
|
||||
strh r5, [dest], #2
|
||||
|
||||
mov r3, r4
|
||||
|
||||
ldrneb r4, [src], #1
|
||||
bne hl12_loop
|
||||
|
||||
orr r5, r4, r4, lsl #8
|
||||
strh r5, [dest]
|
||||
|
||||
ldmia sp!, {r4 - r5, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
;/****************************************************************************
|
||||
; *
|
||||
; * ROUTINE : vp8cx_vertical_band_1_2_scale_c
|
||||
; *
|
||||
; * INPUTS : unsigned char *dest : Pointer to destination data.
|
||||
; * unsigned int dest_pitch : Stride of destination data.
|
||||
; * unsigned int dest_width : Width of destination data.
|
||||
; *
|
||||
; * OUTPUTS : None.
|
||||
; *
|
||||
; * RETURNS : void
|
||||
; *
|
||||
; * FUNCTION : Scales vertical band of pixels by scale 1 to 2. The
|
||||
; * height of the band scaled is 1-pixel.
|
||||
; *
|
||||
; * SPECIAL NOTES : The routine uses the first line of the band below
|
||||
; * the current band.
|
||||
; *
|
||||
; ****************************************************************************/
|
||||
;void vp8cx_vertical_band_1_2_scale_c
|
||||
;(
|
||||
; r0 = UINT8 *dest
|
||||
; r1 = UINT32 dest_pitch
|
||||
; r2 = UINT32 dest_width
|
||||
;)
|
||||
|vertical_band_1_2_scale_armv4| PROC
|
||||
stmdb sp!, {r4 - r7, lr}
|
||||
|
||||
ldr mask, =0xff00ff ; mask for selection
|
||||
ldr lr, = 0x010001
|
||||
|
||||
vl12_loop
|
||||
mov r3, src
|
||||
ldr r4, [r3], r1
|
||||
ldr r5, [r3, r1]
|
||||
|
||||
add src, src, #4
|
||||
subs r2, r2, #4
|
||||
|
||||
and r6, r4, mask
|
||||
and r7, r5, mask
|
||||
|
||||
add r6, r7, r6
|
||||
add r6, r6, lr
|
||||
|
||||
and r4, mask, r4, lsr #8
|
||||
and r5, mask, r5, lsr #8
|
||||
|
||||
mov r6, r6, lsr #1
|
||||
and r6, r6, mask
|
||||
|
||||
add r4, r5, r4
|
||||
add r4, r4, lr
|
||||
|
||||
mov r4, r4, lsr #1
|
||||
and r4, r4, mask
|
||||
|
||||
orr r5, r6, r4, lsl #8
|
||||
|
||||
str r5, [r3]
|
||||
|
||||
bpl vl12_loop
|
||||
|
||||
ldmia sp!, {r4 - r7, pc}
|
||||
ENDP ;|vertical_band_3_5_scale_armv4|
|
||||
|
||||
END
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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 "vpx_scale/vpxscale.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : vp8_scale_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void vp8_scale_machine_specific_config()
|
||||
{
|
||||
vp8_horizontal_line_1_2_scale = horizontal_line_1_2_scale_armv4;
|
||||
vp8_vertical_band_1_2_scale = vertical_band_1_2_scale_armv4;
|
||||
vp8_last_vertical_band_1_2_scale = vp8cx_last_vertical_band_1_2_scale_c;
|
||||
vp8_horizontal_line_3_5_scale = horizontal_line_3_5_scale_armv4;
|
||||
vp8_vertical_band_3_5_scale = vertical_band_3_5_scale_armv4;
|
||||
vp8_last_vertical_band_3_5_scale = vp8cx_last_vertical_band_3_5_scale_c;
|
||||
vp8_horizontal_line_3_4_scale = horizontal_line_3_4_scale_armv4;
|
||||
vp8_vertical_band_3_4_scale = vertical_band_3_4_scale_armv4;
|
||||
vp8_last_vertical_band_3_4_scale = vp8cx_last_vertical_band_3_4_scale_c;
|
||||
vp8_horizontal_line_2_3_scale = horizontal_line_2_3_scale_armv4;
|
||||
vp8_vertical_band_2_3_scale = vertical_band_2_3_scale_armv4;
|
||||
vp8_last_vertical_band_2_3_scale = vp8cx_last_vertical_band_2_3_scale_c;
|
||||
vp8_horizontal_line_4_5_scale = horizontal_line_4_5_scale_armv4;
|
||||
vp8_vertical_band_4_5_scale = vertical_band_4_5_scale_armv4;
|
||||
vp8_last_vertical_band_4_5_scale = vp8cx_last_vertical_band_4_5_scale_c;
|
||||
|
||||
|
||||
vp8_vertical_band_5_4_scale = vp8cx_vertical_band_5_4_scale_c;
|
||||
vp8_vertical_band_5_3_scale = vp8cx_vertical_band_5_3_scale_c;
|
||||
vp8_vertical_band_2_1_scale = vp8cx_vertical_band_2_1_scale_c;
|
||||
vp8_vertical_band_2_1_scale_i = vp8cx_vertical_band_2_1_scale_i_c;
|
||||
vp8_horizontal_line_2_1_scale = vp8cx_horizontal_line_2_1_scale_c;
|
||||
vp8_horizontal_line_5_3_scale = vp8cx_horizontal_line_5_3_scale_c;
|
||||
vp8_horizontal_line_5_4_scale = vp8cx_horizontal_line_5_4_scale_c;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 The WebM 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.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : system_dependant.c
|
||||
*
|
||||
* Description : Miscellaneous system dependant functions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "vpx_scale/vpxscale.h"
|
||||
#include "cpuidlib.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Imports
|
||||
*****************************************************************************/
|
||||
extern void register_generic_scalers(void);
|
||||
extern void register_mmxscalers(void);
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : post_proc_machine_specific_config
|
||||
*
|
||||
* INPUTS : UINT32 Version : Codec version number.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : void
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets appropriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void
|
||||
vp8_scale_machine_specific_config(void)
|
||||
{
|
||||
int wmt_enabled = 1;
|
||||
|
||||
if (wmt_enabled)
|
||||
{
|
||||
register_mmxscalers();
|
||||
}
|
||||
else
|
||||
{
|
||||
register_generic_scalers();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user