Commit Graph

471 Commits

Author SHA1 Message Date
Ethan Hugg
d9cbe19110 Merge pull request #240 from mstorsjo/simplify-inline-asm
Unify the fallback codepath for getting prefix bits into a macro
2014-01-27 13:07:38 -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
Ethan Hugg
990a71dce7 Merge pull request #244 from mstorsjo/remove-unused-files
Removed an unused pair of files generated by MSVC project wizards
2014-01-27 13:03:17 -08:00
Ethan Hugg
b00523329f Merge pull request #243 from mstorsjo/use-stdio-wrappers
Consistently use the compat wrappers for file IO
2014-01-27 13:02:51 -08:00
Ethan Hugg
9be2b1a9a8 Merge pull request #241 from mstorsjo/remove-unused-function
Remove an unused function for byte order swapping
2014-01-27 13:02:00 -08:00
Martin Storsjö
d36939580a Removed an unused pair of files generated by MSVC project wizards
These files aren't actually even referenced by the MSVC project
files.
2014-01-27 22:55:33 +02: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ö
60e0255677 Unify the fallback codepath for getting prefix bits into a macro
This avoids having to know the details about when the optimized
codepath is available at the place where it's used.
2014-01-27 22:30:00 +02:00
Martin Storsjö
55717d3fb8 Remove an unused function for byte order swapping 2014-01-27 22:18:23 +02:00
Ethan Hugg
e17e664e1a Merge pull request #239 from mstorsjo/remove-unnecessary-calls
Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers
2014-01-27 11:50:19 -08:00
Ethan Hugg
e05b607daa Merge pull request #223 from mstorsjo/typedef-cleanup
Clean up typedefs within the libraries
2014-01-27 11:46:44 -08:00
Martin Storsjö
ec20ab58ef Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers 2014-01-27 20:00:15 +02:00
Ethan Hugg
783adb9afe Merge pull request #238 from mstorsjo/merge-snprintf-strftime-wrappers
Use WelsSnprintf/WelsVsnprintf/WelsGetTimeOfDay/WelsStrftime instead of inconsistent macros
2014-01-27 09:44:51 -08:00
Martin Storsjö
2bcadff204 Use WelsGetTimeOfDay and WelsStrftime instead of LOCALTIME/FTIME/strftime 2014-01-27 19:20:45 +02:00
Martin Storsjö
0439392a79 Fix a typo Millsecond -> Millisecond 2014-01-27 19:20:27 +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
5a8f5f9ad1 Merge pull request #233 from mstorsjo/snprintf-fixes
Make the *snprintf (and similar) functions always null terminate the buffer properly on all platforms
2014-01-27 08:52:37 -08:00
Ethan Hugg
dacd6735fb Merge pull request #230 from mstorsjo/remove-legacy-make
Remove the legacy makefile based build system
2014-01-27 07:59:03 -08:00
Ethan Hugg
fbf7836b8d Merge pull request #236 from mstorsjo/msvc-proj-moved-headers
Update the MSVC project files for earlier moved/removed files
2014-01-27 07:56:25 -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ö
ea333863ee Update the MSVC project files for earlier moved/removed files 2014-01-27 14:23:22 +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
Martin Storsjö
c7b74b2b12 Make sure the buffer is null terminated after strftime
If the buffer is too small, there's no guarantee that it is
null terminated. The docs (on both unix and MSVC) say explicitly
that the function returns 0 and the buffer contents are
indeterminate in this case.
2014-01-27 12:07:00 +02:00
Martin Storsjö
7884e77b2d Make sure the buffer always is null terminated in the *snprintf calls for old MSVC
These functions leave the buffer unterminated in case it was too
small.
2014-01-27 12:06:24 +02:00
Martin Storsjö
4a8f54d767 Use vsnprintf in the old MSVC version of WelsSnprintf as well 2014-01-27 12:06:08 +02:00
Martin Storsjö
0ce42ffb89 Rename WelsVsprintf to WelsVsnprintf, to indicate that it actually checks the length 2014-01-27 12:05:53 +02:00
Martin Storsjö
e42e82aa1f Make WelsVsprintf use vsnprintf, to check the buffer size
Otherwise builds on platforms other than MSVC might be
insecure.

Use vsnprintf_s with the _TRUNCATE flag instead of vsprintf_s
when using MSVC - this truncates the buffer instead of aborting
the whole process in case it's too small.
2014-01-27 12:05:39 +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
Martin Storsjö
b468ed3c0b Unify the declaration of int8_t within the processing lib with the rest
int8_t in general should to be defined as signed char, since there
are actual envrionments where a plain 'char' is unsigned.

This also reduces the differences between the typedef headers of
the different sub-libraries.
2014-01-27 08:44:48 +02:00
Martin Storsjö
a24fd5e120 Make the bool_t typedef in the processing lib match the others
There is no specific reason to use int32_t for this type.
2014-01-27 08:44:48 +02:00
Martin Storsjö
09f0254d5e Remove the now unused long_t typedef 2014-01-27 08:44:48 +02:00
Martin Storsjö
cc4507462b Use int32_t instead of long_t in WELS_SIGN/WELS_ABS in the processing lib
This makes them match the same macros in the main decoder/encoder
libraries. long_t (which is typedeffed to long) actually is 64
bit on 64 bit unix platforms, which might not be what was
intended.
2014-01-27 08:44:48 +02:00
Martin Storsjö
0339cd51c5 Unify the definition of WELS_THREAD_ERROR_CODE between libraries
This simplifies the code base, reduces the risk for mixups and
gets rid of the use of a local nonstandard typedef.
2014-01-27 08:44:48 +02:00
Martin Storsjö
109fecc547 Consistently use inline instead of __inline 2014-01-27 08:44:48 +02:00
Martin Storsjö
98dd2d91d9 Use 'inline' instead of 'inline_t' in the processing lib
Just use the standard inline keyword with sufficient backwards
compatibility defines, similar to how it is done in the main decoder
and encoder libraries.
2014-01-27 08:44:48 +02: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
volvet
4d22d91692 Merge pull request #226 from mstorsjo/crt-safe-merge
Merge the encoder/decoder crt_util_safe_x.h into the common lib
2014-01-26 22:26:24 -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