Skip to content

Commit

Permalink
fixed VLAs in C++ files
Browse files Browse the repository at this point in the history
see commit @{2} description
  • Loading branch information
MartinPulec committed Mar 25, 2024
1 parent a02d606 commit 3708bd7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/utils/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@
#define OPTIMIZED_FOR for
#endif

/// the following limits are used mostly for static array allocations
enum {
STR_LEN = 2048, ///< "standard" string length placeholder
MAX_CPU_CORES = 256, ///< maximal expected CPU core count
STR_LEN = 2048, ///< "standard" string length placeholder
};

/// expands to true value if <k> from tok in format <k>=<v> is prefix of key
Expand Down
4 changes: 2 additions & 2 deletions src/utils/video_pattern_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,12 @@ struct gray_video_pattern_generator : public video_pattern_generator {
int col = 0;
while (col < 0xFF) {
int pixels = get_pf_block_pixels(color_spec);
unsigned char rgba[pixels * 4];
unsigned char rgba[MAX_PFB_SIZE * 4];
for (int i = 0; i < pixels * 4; ++i) {
rgba[i] = (i + 1) % 4 != 0 ? col : 0xFFU; // handle alpha
}
int dst_bs = get_pf_block_bytes(color_spec);
unsigned char dst[dst_bs];
unsigned char dst[MAX_PFB_SIZE];
testcard_convert_buffer(RGBA, color_spec, dst, rgba, pixels, 1);

auto next_frame = vector<unsigned char>(data_len);
Expand Down
8 changes: 5 additions & 3 deletions src/utils/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
#include <set>
#include <vector>

#include "utils/misc.h" // get_cpu_core_count
#include "utils/macros.h" // for MAX_CPU_CORES
#include "utils/misc.h" // get_cpu_core_count
#include "utils/thread.h"
#include "utils/worker.h"

using std::min;
using std::queue;
using std::set;
using std::vector;
Expand Down Expand Up @@ -329,8 +331,8 @@ static void *respawn_parallel_task(void *arg) {
*/
void respawn_parallel(void *in, void *out, size_t nmemb, size_t size, respawn_parallel_callback_t c, void *udata)
{
int threads = get_cpu_core_count();
struct respawn_parallel_data data[threads];
const int threads = min<int>(get_cpu_core_count(), MAX_CPU_CORES);
struct respawn_parallel_data data[MAX_CPU_CORES];

for (int i = 0; i < threads; ++i) {
data[i].c = c;
Expand Down
1 change: 1 addition & 0 deletions src/video_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extern "C" {
#define MAX_BPS 8 /* for Y416 */ ///< maximal (average) number of pixels per know pixel formats (up-round if needed)
#define MAX_PADDING 64 ///< maximal padding in bytes that may be needed to align to pixfmt block size for Y416->R12L:
///< 64 = vc_linesize(8 /*maximal block pix count (R12L)*/, Y416 /*codec with maximal lenght of 1st arg-sized block*/)
#define MAX_PFB_SIZE 8 ///< maximal pixfmt block size (R12L - 8 B)
#define PIX_BLOCK_LCM 24 ///< least common multiple of all pixfmt block sizes in pixels (codec_info_t::block_size/codec_info_t::bpp). "contributors:" 8 R12L, 6 v210

/// Prints list of suppored codecs for video module
Expand Down

0 comments on commit 3708bd7

Please sign in to comment.