Commit Graph

143 Commits

Author SHA1 Message Date
Martin Storsjö
0f7a958ce3 Move declarations of functions in mc_chroma/luma.asm into a header in common 2014-02-10 08:05:02 +02:00
Martin Storsjö
ad209c2d14 Move declarations of functions in expand_picture.asm into a header in common 2014-02-10 08:05:02 +02:00
Martin Storsjö
d0185ab253 Remove redundant /./ parts from pathnames in makefiles
This is mostly a cosmetic improvement for the quiet make output.
2014-02-08 18:46:52 +02:00
Martin Storsjö
e66ad9ab86 Remove the real32_t typedef
The float type is defined in standards and is portably available
on all supported compilers and platforms.
2014-02-08 14:12:03 +02:00
Martin Storsjö
ba6bf7da18 Consistently use inline instead of __inline
This seemed to have been missed in 109fecc.
2014-02-08 14:08:46 +02:00
Martin Storsjö
8ecdcc7172 Add a make option for silencing the commands run
Add "V=No" to the make command to silence the make output.

This makes it easier to spot warnings or other unexpected messages
in the build output.
2014-01-30 13:56:19 +02:00
Ethan Hugg
fbcd962169 Merge pull request #256 from mstorsjo/bigendian
Make the library work on big endian
2014-01-29 15:24:32 -08:00
Martin Storsjö
cadbec75d8 Fix shifting tricks in deblocking for big endian
The code interprets an array of 4 uint8_t values as one uint32_t
and does shifts on the value. The same optimization can be
kept in big endian as well, but the shift has to be done in the
other direction.

This code could be made truly independent of endianness, but
that could cause some minimal performance degradaion, at least
in theory.

This makes "make test" pass on big endian, assuming that
WORDS_BIGENDIAN is defined while building.
2014-01-29 22:30:33 +02:00
Martin Storsjö
47ec78843a Don't read an uint8_t array as an uint32_t
This makes the code work properly on big endian.

The MC case is similar to how it's done in the encoder.

Neither of these should have any significant performance
impact.
2014-01-29 22:27:55 +02:00
Martin Storsjö
66c39a4fd4 Remove the array_stack_align.h header from the encoder lib
All of these macros are already available in the common
macros.h header. Unify all the macros to be named ENFORCE_*
instead of mixed FORCE/ENFORCE.
2014-01-29 22:07:52 +02:00
Ethan Hugg
08638a9396 Merge pull request #252 from mstorsjo/share-processing-asm
Merge identical assembly code between the processing and encoder libs
2014-01-28 11:04:12 -08:00
Ethan Hugg
3c40261256 Merge pull request #251 from mstorsjo/crt-string-cleanup
Clean up the rest of the usage of crt_safe_util_x
2014-01-28 09:42:56 -08:00
Ethan Hugg
0d7bafcebc Merge pull request #248 from mstorsjo/msvc-proj-cleanup
MSVC project file warning cleanup
2014-01-28 09:40:17 -08:00
Martin Storsjö
3761901ed4 Remove sad.asm from the processing lib, move satd_sad from the encoder to the common lib
sad.asm as used in processing is an exact subset of the
code in satd_sad.asm in the encoder.
2014-01-28 13:54:57 +02:00
Martin Storsjö
208f033bcd Use WelsStrcat instead of the STRCAT macro 2014-01-28 12:43:22 +02:00
Martin Storsjö
903f265965 Fix a format string to use the correct type 2014-01-28 12:42:01 +02:00
Martin Storsjö
5c5dcfb14c Remove an unused global variable and commented out code 2014-01-28 12:36:54 +02:00
Martin Storsjö
9840f11784 Remove the now unused count parameter to WelsStrncpy
Also remove manual null termination as WelsStrncpy now always
takes care of it.
2014-01-28 12:13:11 +02:00
Martin Storsjö
215eb56453 Use WelsStrncpy instead of STRNCPY 2014-01-28 12:05:28 +02:00
Martin Storsjö
7791a6d28d Use WelsSnprintf instead of a combination of strlen and STRNCAT
This simplifies the code and makes the buffer size checks
more consistent. Additionally, the previous version wrote
the extra space character without checking if it actually fit
into the buffer.
2014-01-28 12:00:04 +02:00
Martin Storsjö
0318922654 Check the right pointer for being non-null in WelsLogDefault
In case the log level was invalid, GetLogTag returns null.
Checking pCtx doesn't make sense since nothing within the
if block uses pCtx.
2014-01-28 12:00:04 +02:00
Martin Storsjö
92fa4eb400 Use strlen instead of WelsStrnlen/STRNLEN for known null terminated strings
strlen is not dangerous if the string is known to be null
terminated (and MSVC does not warn about its use either).

For the cases in the decoder welsCodecTrace.cpp, the string
passed to all WriteString instances is produced by WelsVsnprintf
which always null terminates the buffer nowadays.

Additionally, as the string was passed to OutputDebugStringA
without any length specifier before, it was already assumed to
be null terminated.

The file name parameter passed to DumpDependencyRec and
DumpRecFrame in encoder.cpp is always null terminated,
which was already assumed as it is passed to WelsFopen as is.

As for the encoder utils.cpp, the strings returned by GetLogPath
are string constants that are null terminated.
2014-01-28 11:40:54 +02:00
Martin Storsjö
082a986990 Use strlen() instead of WelsStrnlen/STRNLEN for string constants
A string constant is guaranteed to be null terminated, and thus
doesn't need to use a version of strlen with a fixed buffer size
limit.
2014-01-28 11:38:26 +02:00
Martin Storsjö
da7d3d9bad Remove an unused and unnecessary string length calculation
This is unused since 771ff739b.
2014-01-28 11:38:22 +02:00
Ethan Hugg
4334812eee Merge pull request #235 from mstorsjo/merge-ls-defines
Merge the ls_defines.h headers into the common sub-library
2014-01-27 14:10:00 -08:00
Ethan Hugg
00a76419b4 Merge pull request #237 from mstorsjo/simplify-make-lib-rules
Simplify the make rules for creating libraries
2014-01-27 14:09:20 -08:00
Ethan Hugg
5616ddb3a5 Merge pull request #242 from mstorsjo/simplify-debug-file-locations
Simplify debugging code by always writing trace files to the current directory
2014-01-27 13:04:29 -08:00
Martin Storsjö
3559f425b4 Consistently use the compat wrappers for file IO
As long as WelsFileHandle* is equal to FILE* this doesn't matter,
but for consistency use the WelsF* functions for all handles
opened by WelsFopen, and use WelsFileHandle* as type for it
instead of FILE*.
2014-01-27 22:49:41 +02:00
Martin Storsjö
98614924e2 Remove the now meaningless field sTracePath 2014-01-27 22:37:11 +02:00
Martin Storsjö
771ff739b6 Simplify debugging code - always write debug trace files to the cur directory
This reduces the amount of platform ifdefs.
2014-01-27 22:36:50 +02:00
Martin Storsjö
ec20ab58ef Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers 2014-01-27 20:00:15 +02:00
Martin Storsjö
2bcadff204 Use WelsGetTimeOfDay and WelsStrftime instead of LOCALTIME/FTIME/strftime 2014-01-27 19:20:45 +02:00
Martin Storsjö
3a5ff9b6c8 Use WelsVsnprintf instead of VSPRINTF 2014-01-27 19:18:36 +02:00
Martin Storsjö
f6fe4ddeaa Use WelsSnprintf instead of SNPRINTF 2014-01-27 19:18:36 +02:00
Ethan Hugg
6fea084a42 Merge pull request #234 from mstorsjo/merge-measure-time
Move the measure_time.h header to the common library
2014-01-27 08:57:16 -08:00
Ethan Hugg
2a55578a98 Merge pull request #208 from mstorsjo/remove-unused-mk-field
Remove an unnecessary field from generated makefiles
2014-01-27 08:55:23 -08:00
Ethan Hugg
d5affbaa3c Merge pull request #232 from mstorsjo/merge-fopen-wrappers
Remove the FOPEN macro, use WelsFopen instead
2014-01-27 08:54:20 -08:00
Ethan Hugg
f3afcd51ff Merge pull request #231 from mstorsjo/fix-msvc-build
Readd a removed include
2014-01-27 07:54:29 -08:00
Martin Storsjö
ea8a00278f Simplify the make rules for creating libraries 2014-01-27 14:45:18 +02:00
Martin Storsjö
a44808e276 Merge the ls_defines.h headers into the common sub-library 2014-01-27 14:14:41 +02:00
Martin Storsjö
11bdd8adad Move the measure_time.h header to the common library
Both encoder and decoder versions were functionally equivalent,
but I picked the decoder version (but added the static inline
keywords to it) since the encoder one was quite messy with a lot
of commented out code.
2014-01-27 12:58:23 +02:00
lyao2
00948873fb fix spell error of RcInitGoomParameters 2014-01-27 17:29:24 +08:00
Martin Storsjö
c174dcd652 Remove the FOPEN macro, use WelsFopen instead
This avoids ifdefs at each place the macro is used.
2014-01-27 10:29:05 +02:00
Martin Storsjö
febf6bb51e Readd a removed include
This fixes builds without NO_DYNAMIC_VP (such as with the MSVC
project files), the include was removed in d809b7e9.
2014-01-27 10:25:32 +02:00
volvet
33fe2b5883 Merge pull request #225 from mstorsjo/simplify-ifdefs
Simplify ifdefs in measure_time.h
2014-01-27 00:14:44 -08:00
volvet
cbe650a3e5 Merge pull request #227 from mstorsjo/snprintf-fixes
Fix handling of snprintf return values and buffer size calculations
2014-01-26 22:26:38 -08:00
Martin Storsjö
30bcfea6b8 Simplify ifdefs in measure_time.h
Instead of using "defined(MSC_VER) || defined(__MINGW32__)" to
indicate the windows platform, just check for the _WIN32 define
instead.

Also remove an unused codepath - the removed codepath would
only be used under the condition
"(defined(MSC_VER) || defined(__MINGW32__)) && !defined(_WIN32)",
and I'm not aware of any environment with MSVC or MinGW that
doesn't define _WIN32, thus this codepath never was used.
2014-01-27 08:08:23 +02:00
Martin Storsjö
076b1116d6 Fix calculating buffer positions when appending with SNPRINTF/WelsSnprintf
This fixes two separate issues.

First, with the MSVC _snprintf implementations, the return value
is negative if the buffer wasn't large enough - this would in
the worst case lead to making iBufferUsed negative, writing before
the start of the buffer.

Secondly, when both iBufferUsed and iBufferLeft are accumulated,
one can't do "iBufferLeft -= iBufferUsed;". As an example,
say the buffer is 100 bytes in total and iBufferLeft is 40 and
iBufferUsed is 60. If SNPRINTF then writes 5 more bytes to the
buffer, iBufferUsed would be 65, but if we now do
"iBufferLeft -= iBufferUsed;" then iBufferLeft would end up as
-25 even though there's 35 bytes left in the buffer to use.

Therefore, we use a separate variable to store the return value
from the latest SNPRINTF call. This is checked to make sure it
wasn't negative, and only this amount is added to iBufferUsed
and subtracted from iBufferLeft.

This is the same pattern used in codec/encoder/core/src/utils.cpp.

strftime never returns negative numbers, so those calls don't
need as much checking.
2014-01-27 08:03:56 +02:00
Martin Storsjö
a344d100ae Fix buffer size checks when appending using SNPRINTF/WelsSnprintf
Checking iBufferLeft > iBufferUsed does not make sense, since
this would stop writing into the buffer alredy after the buffer
is half full, when there is less space left than has been used.

The right check is iBufferLeft > 0.
2014-01-27 08:03:56 +02:00
Martin Storsjö
98bad4f2b3 Don't manually null terminate after calling SNPRINTF
The following pattern is unsafe on all platforms:
 n = SNPRINTF(buf, ...);
 buf[n] = '\0';

On windows, the _snprintf variants return a negative number
if the buffer was too small, thus buf[n] would be outside
of (before the start of) the buffer.

On other platforms, the C99 snprintf function returns the
total number of characters which would have been written if
the buffer had been large enough, which can be larger than
the buffer size itself, and thus buf[n] would be beyond the
end of the buffer.

The C99 snprintf function always null terminate the buffer.
These invocations of SNPRINTF are within !WIN32, so we can
be sure that the SNPRINTF call itself already null terminated
the buffer.
2014-01-27 08:03:56 +02:00