Skip to content

Commit 8c4c019

Browse files
committed
from_planar: make it more pretty
porting improvements from to_planar
1 parent 20d6b5b commit 8c4c019

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/from_planar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ void
267267
decode_planar_parallel(decode_planar_func_t *dec,
268268
const struct from_planar_data d, int num_threads)
269269
{
270-
const unsigned cpu_count =
271-
num_threads == 0 ? get_cpu_core_count() : num_threads;
270+
const unsigned cpu_count = num_threads == FROM_PLANAR_THREADS_AUTO
271+
? get_cpu_core_count()
272+
: num_threads;
272273

273274
struct convert_task_data data[cpu_count];
274275
for (size_t i = 0; i < cpu_count; ++i) {

src/from_planar.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
extern "C" {
4646
#endif // __cplusplus
4747

48-
#define FROM_PLANAR_MAX_COMP 4
48+
enum {
49+
FROM_PLANAR_THREADS_AUTO = 0,
50+
FROM_PLANAR_MAX_COMP = 4,
51+
};
4952

5053
// defined also in pixfmt_conv.h
5154
#define DEFAULT_R_SHIFT 0
@@ -72,8 +75,8 @@ typedef void decode_planar_func_t(struct from_planar_data d);
7275
* run the @ref decode_planar_func_t in parallel
7376
* @param dec fn to run, must be to packed format (or set num_threads=1
7477
* if the conversion is to a planar format)
75-
* @param num_threads number of threads (0 = auto - use the number of logical
76-
* cores)
78+
* @param num_threads number of threads or FROM_PLANAR_THREADS_AUTO to use the
79+
* number of logical cores)
7780
*/
7881
void decode_planar_parallel(decode_planar_func_t *dec,
7982
struct from_planar_data d, int num_threads);

src/video_decompress/jpegxs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jpegxs_to_uv_convert(struct state_decompress_jpegxs *s,
141141
d.rgb_shift[0] = s->rshift;
142142
d.rgb_shift[1] = s->gshift;
143143
d.rgb_shift[2] = s->bshift;
144-
int num_threads = 0;
144+
int num_threads = FROM_PLANAR_THREADS_AUTO;
145145
if (conv->convert == yuv420_to_i420) {
146146
num_threads = 1; // no proper support for parallel decode
147147
}

0 commit comments

Comments
 (0)