Commit Graph

272 Commits

Author SHA1 Message Date
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ö
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
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
Martin Storsjö
2f5f25b7e3 Merge the encoder/decoder crt_util_safe_x.h into the common lib 2014-01-27 08:03:03 +02:00
Ethan Hugg
55336dee64 Merge pull request #221 from mstorsjo/freebsd
Update building on FreeBSD
2014-01-26 20:41:11 -08:00
Ethan Hugg
b401098a67 Merge pull request #216 from varunbpatil/processing_cleanup
Removed unused header files in processing src
2014-01-26 20:35:32 -08:00
Ethan Hugg
627c1558ae Merge pull request #215 from varunbpatil/dec_core_cleanup
Removed unused headers in decoder core
2014-01-26 20:09:19 -08:00
Ethan Hugg
36054ac2a2 Merge pull request #212 from varunbpatil/enc_core_cleanup
Removed unused header files in encoder core
2014-01-26 19:24:35 -08:00
kali2
fa91f77b1b Merge pull request #214 from licaiguo/fix-rpl
fix reference picture modification bug -- review #67
2014-01-26 19:24:25 -08:00
volvet
488cc4ec8e Merge pull request #228 from mstorsjo/remove-hardcoded-path
Remove a hardcoded debug path specific to somebody's environment
2014-01-26 18:17:31 -08:00
volvet
5ac52e31e9 Merge pull request #224 from mstorsjo/msvc2005
Fix building on MSVC 2005
2014-01-26 17:51:44 -08:00
Martin Storsjö
7394254fb5 Remove the legacy makefile based build system
The new one is much more flexible. The old one is unmaintained.
2014-01-26 16:28:58 +02:00
Martin Storsjö
2963f4ab6e Remove a hardcoded debug path specific to somebody's environment
Instead of using platform specific paths, just use the local
directory instead, reducing the amounts of ifdefs.
2014-01-26 15:22:41 +02:00
Martin Storsjö
e1d96aeaf3 Fix the old MSVC version of WelsGetTimeOfDay
The _ftime function returns void.

This fixes building on MSVC 2005.
2014-01-26 10:52:08 +02:00
volvet
d67fbe74ce Merge pull request #213 from licaiguo/update-resolution
change resolution update logic -- review #66
2014-01-26 00:51:35 -08:00
Martin Storsjö
8062596d23 Fix building threading for freebsd
FreeBSD (and at least NetBSD as well) still use hw.ncpu without
deprecating it, contrary to apple.
2014-01-26 10:40:24 +02:00
Varun B Patil
e459b91412 Removed unused headers in decoder core 2014-01-26 12:00:57 +05:30
Varun B Patil
d809b7e9ee Removed unused headers in encoder core 2014-01-26 11:28:17 +05:30
Varun B Patil
7dbdfbcef8 Use correct format specifier to avoid compiler warnings 2014-01-26 00:47:50 +05:30
Varun B Patil
77f47edf3b include ifdef guard 2014-01-25 18:08:15 +05:30
Varun B Patil
7c6445418b Removed unused header files in processing src 2014-01-25 15:39:05 +05:30
volvet
8420fd3454 Merge pull request #210 from mstorsjo/cleanup-macros
Cleanup the common/macros.h header
2014-01-25 01:05:27 -08:00
licaiguo
058ceb369f fix reference picture modification bug 2014-01-25 16:37:22 +08:00
licaiguo
1a2dd0c1f1 change resolution update logic 2014-01-25 16:12:52 +08:00
volvet
a1c491499f Merge pull request #204 from mstorsjo/remove-dynamic-load-trace
Remove code for dynamically loading a trace library
2014-01-24 22:32:58 -08:00