UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
cineform.cpp File Reference
#include "debug.h"
#include "host.h"
#include "lib_common.h"
#include "module.h"
#include "tv.h"
#include "video_compress.h"
#include <CFHDTypes.h>
#include <CFHDEncoder.h>
#include "video.h"
#include "video_codec.h"
#include <memory>
#include <map>
#include <mutex>
#include <thread>
#include <vector>
#include <queue>
#include <condition_variable>
#include "utils/misc.h"
Include dependency graph for cineform.cpp:

Go to the source code of this file.

Classes

struct  state_video_compress_cineform
 

Macros

#define DEFAULT_POOL_SIZE   16
 
#define DEFAULT_THREAD_COUNT   8
 
#define MOD_NAME   "[cineform] "
 

Functions

static void cineform_compress_done (struct module *mod)
 
static struct module * cineform_compress_init (struct module *parent, const char *opts)
 
static std::shared_ptr< video_frame > cineform_compress_pop (struct module *state)
 
static void cineform_compress_push (struct module *state, std::shared_ptr< video_frame > tx)
 
static bool configure_with (struct state_video_compress_cineform *s, struct video_desc desc)
 
static compress_module_info get_cineform_module_info ()
 
static video_frame * get_copy (struct state_video_compress_cineform *s, video_frame *frame)
 
static int parse_fmt (struct state_video_compress_cineform *s, char *fmt)
 
 REGISTER_MODULE (cineform, &cineform_info, LIBRARY_CLASS_VIDEO_COMPRESS, VIDEO_COMPRESS_ABI_VERSION)
 
static void usage ()
 

Variables

const struct video_compress_info cineform_info
 
struct { 
 
   CFHD_EncodedFormat   cfhd_encoded_format 
 
   CFHD_PixelFormat   cfhd_pixel_format 
 
   codec_t   ug_codec 
 
} codecs [] 
 
struct { 
 
   const char *   description 
 
   const char *   key 
 
   const char *   label 
 
   const char *   opt_str 
 
   const char *   placeholder 
 
} usage_opts [] 
 

Detailed Description

Author
Martin Piatka piatk.nosp@m.a@ce.nosp@m.snet..nosp@m.cz

Definition in file cineform.cpp.

Macro Definition Documentation

◆ DEFAULT_POOL_SIZE

#define DEFAULT_POOL_SIZE   16

Definition at line 74 of file cineform.cpp.

Referenced by cineform_compress_init().

◆ DEFAULT_THREAD_COUNT

#define DEFAULT_THREAD_COUNT   8

Definition at line 75 of file cineform.cpp.

Referenced by cineform_compress_init().

◆ MOD_NAME

#define MOD_NAME   "[cineform] "

Definition at line 76 of file cineform.cpp.

Referenced by configure_with().

Function Documentation

◆ cineform_compress_done()

static void cineform_compress_done ( struct module * mod)
static

Definition at line 110 of file cineform.cpp.

110 {
112
113 s->mutex.lock();
114
115 CFHD_StopEncoderPool(s->encoderPoolRef);
116 CFHD_ReleaseEncoderPool(s->encoderPoolRef);
117 CFHD_MetadataClose(s->metadataRef);
118
119 s->mutex.unlock();
120 delete s;
121}
void * priv_data
Definition module.h:126

References state_video_compress_cineform::encoderPoolRef, state_video_compress_cineform::metadataRef, state_video_compress_cineform::mutex, and module::priv_data.

Referenced by cineform_compress_init().

◆ cineform_compress_init()

static struct module * cineform_compress_init ( struct module * parent,
const char * opts )
static

Definition at line 178 of file cineform.cpp.

179{
181
183
184 memset(&s->saved_desc, 0, sizeof(s->saved_desc));
185 s->requested_quality = CFHD_ENCODING_QUALITY_DEFAULT;
188
189 char *fmt = strdup(opts);
190 int ret = parse_fmt(s, fmt);
191 free(fmt);
192 if(ret != 0) {
193 delete s;
194 return ret > 0 ? static_cast<module*>(INIT_NOERR) : nullptr;
195 }
196
197 log_msg(LOG_LEVEL_NOTICE, "[cineform] : Threads: %d.\n", s->requested_threads);
198 CFHD_Error status = CFHD_ERROR_OKAY;
199 status = CFHD_CreateEncoderPool(&s->encoderPoolRef,
202 nullptr);
203 if(status != CFHD_ERROR_OKAY){
204 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to create encoder pool\n");
205 delete s;
206 return nullptr;
207 }
208 status = CFHD_MetadataOpen(&s->metadataRef);
209 if(status != CFHD_ERROR_OKAY){
210 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to create metadataRef\n");
211 CFHD_ReleaseEncoderPool(s->encoderPoolRef);
212 delete s;
213 return nullptr;
214 }
215
216 s->frame_seq_in = 0;
217 s->frame_seq_out = 0;
218 s->started = false;
219 s->stop = false;
220
223 s->module_data.priv_data = s;
226
227 return &s->module_data;
228}
const char * fmt
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_NOTICE
information that may be interesting
Definition debug.h:61
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
void module_init_default(struct module *module_data)
Definition module.c:48
void module_register(struct module *module_data, struct module *parent)
Definition module.c:82
@ MODULE_CLASS_DATA
Definition module.h:86
#define INIT_NOERR
Definition host.h:73
const char * parent
Definition settings.cpp:198
enum module_class cls
Definition module.h:115
module_deleter_t deleter
Definition module.h:118
CFHD_MetadataRef metadataRef
Definition cineform.cpp:94
CFHD_EncodingQuality requested_quality
Definition cineform.cpp:89
struct video_desc saved_desc
Definition cineform.cpp:83
CFHD_EncoderPoolRef encoderPoolRef
Definition cineform.cpp:93
#define DEFAULT_POOL_SIZE
Definition cineform.cpp:74
static int parse_fmt(struct state_video_compress_cineform *s, char *fmt)
Definition cineform.cpp:144
#define DEFAULT_THREAD_COUNT
Definition cineform.cpp:75
static void cineform_compress_done(struct module *mod)
Definition cineform.cpp:110

References cineform_compress_done(), module::cls, DEFAULT_POOL_SIZE, DEFAULT_THREAD_COUNT, module::deleter, state_video_compress_cineform::encoderPoolRef, fmt, state_video_compress_cineform::frame_seq_in, state_video_compress_cineform::frame_seq_out, INIT_NOERR, LOG_LEVEL_ERROR, LOG_LEVEL_NOTICE, log_msg(), state_video_compress_cineform::metadataRef, MODULE_CLASS_DATA, state_video_compress_cineform::module_data, module_init_default(), module_register(), parent, parse_fmt(), module::priv_data, state_video_compress_cineform::requested_pool_size, state_video_compress_cineform::requested_quality, state_video_compress_cineform::requested_threads, state_video_compress_cineform::saved_desc, state_video_compress_cineform::started, and state_video_compress_cineform::stop.

Here is the call graph for this function:

◆ cineform_compress_pop()

static std::shared_ptr< video_frame > cineform_compress_pop ( struct module * state)
static

Definition at line 438 of file cineform.cpp.

439{
440 struct state_video_compress_cineform *s = (struct state_video_compress_cineform *) state->priv_data;
441
442 std::unique_lock<std::mutex> lock(s->mutex);
443
444 if(s->stop){
445 CFHD_SampleBufferRef buf;
446 uint32_t frame_num;
447 while(CFHD_TestForSample(s->encoderPoolRef, &frame_num, &buf) == CFHD_ERROR_OKAY){
448 CFHD_ReleaseSampleBuffer(s->encoderPoolRef, buf);
449 }
450 return {};
451 }
452
453 const auto& started = s->started;
454 while(!started)
455 s->cv.wait(lock, [&started](){return started;});
456
457 lock.unlock();
458
459 CFHD_Error status = CFHD_ERROR_OKAY;
460 uint32_t frame_num;
461 CFHD_SampleBufferRef buf;
462 status = CFHD_WaitForSample(s->encoderPoolRef,
463 &frame_num,
464 &buf);
465#if MEASUREMENT
466 struct timespec t_0, t_1, t_res;
467 clock_gettime(CLOCK_MONOTONIC_RAW, &t_1);
468 t_0 = s->times_map[frame_num];
469
470 timespec_diff(&t_0, &t_1, &t_res);
471
472 printf("[cineform] Encoding %u frame took %f miliseconds.\n", frame_num, t_res.tv_nsec / 1000000.0);
473#endif
474 if(status != CFHD_ERROR_OKAY){
475 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to wait for sample %d\n", status);
476 return {};
477 }
478
479 static auto dispose = [](struct video_frame *frame) {
480 std::tuple<CFHD_EncoderPoolRef, CFHD_SampleBufferRef> *t =
481 static_cast<std::tuple<CFHD_EncoderPoolRef, CFHD_SampleBufferRef> *>(frame->callbacks.dispose_udata);
482 if(t)
483 CFHD_ReleaseSampleBuffer(std::get<0>(*t), std::get<1>(*t));
484 vf_free(frame);
485 };
486
487 std::shared_ptr<video_frame> out = std::shared_ptr<video_frame>(vf_alloc_desc(s->compressed_desc), dispose);
488 size_t encoded_len;
489 status = CFHD_GetEncodedSample(buf,
490 (void **) &out->tiles[0].data,
491 &encoded_len);
492 out->tiles[0].data_len = encoded_len;
493 if(status != CFHD_ERROR_OKAY){
494 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to get sample data\n");
495 return {};
496 }
497 out->callbacks.dispose_udata = new std::tuple<CFHD_EncoderPoolRef, CFHD_SampleBufferRef>(s->encoderPoolRef, buf);
498 out->seq = frame_num;
499
500 lock.lock();
501 if(s->frame_queue.empty()){
502 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to pop\n");
503 } else {
504 auto &src = s->frame_queue.front();
505 vf_copy_metadata(out.get(), src.get());
506 }
507 s->frame_queue.pop();
508
509 out->compress_end = get_time_in_ns();
510
511 return out;
512}
void ** state
struct video_frame * frame
void vf_free(struct video_frame *buf)
Frees video_frame structure.
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
Struct video_frame represents a video frame and contains video description.
Definition types.h:305
struct video_frame_callbacks callbacks
Definition types.h:324
static time_ns_t get_time_in_ns()
Definition tv.h:101
void vf_copy_metadata(struct video_frame *dest, const struct video_frame *src)

References lock::lock(), video_frame::callbacks, state_video_compress_cineform::compressed_desc, state_video_compress_cineform::cv, video_frame_callbacks::dispose_udata, state_video_compress_cineform::encoderPoolRef, frame, state_video_compress_cineform::frame_queue, get_time_in_ns(), LOG_LEVEL_ERROR, log_msg(), state_video_compress_cineform::mutex, state_video_compress_cineform::started, state, state_video_compress_cineform::stop, vf_alloc_desc(), vf_copy_metadata(), and vf_free().

Here is the call graph for this function:

◆ cineform_compress_push()

static void cineform_compress_push ( struct module * state,
std::shared_ptr< video_frame > tx )
static

Definition at line 352 of file cineform.cpp.

353{
354 struct state_video_compress_cineform *s = (struct state_video_compress_cineform *) state->priv_data;
355
356 CFHD_Error status = CFHD_ERROR_OKAY;
357 std::unique_lock<std::mutex> lock(s->mutex);
358
359 if(s->stop)
360 return;
361
362 if(!tx){
363 if (!s->started) {
364 video_desc desc{1920, 1080, UYVY, 25.0, PROGRESSIVE, 1};
366 }
367 std::unique_ptr<video_frame, decltype(&vf_free)> dummy(vf_alloc_desc_data(s->precompress_desc), vf_free);
368 video_frame *dummy_ptr = dummy.get();
369 vf_clear(dummy_ptr);
370
371 s->stop = true;
372 s->frame_queue.push(std::move(dummy));
373 lock.unlock();
374
375 status = CFHD_EncodeAsyncSample(s->encoderPoolRef,
376 s->frame_seq_in++,
377 dummy_ptr->tiles[0].data,
378 vc_get_linesize(s->precompress_desc.width, s->precompress_desc.color_spec),
379 nullptr);
380 if(status != CFHD_ERROR_OKAY){
381 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to push null %i pool\n", status);
382 }
383 return;
384 }
385
386 assert(tx->tile_count == 1); // TODO
387
389 s->saved_desc, PARAM_TILE_COUNT))
390 {
391 //cleanup(s);
392 int ret = configure_with(s, video_desc_from_frame(tx.get()));
393 if(!ret) {
394 return;
395 }
396 }
397
398 std::unique_ptr<video_frame, decltype(&vf_free)> frame_copy(get_copy(s, tx.get()), vf_free);
399 video_frame *frame_ptr = frame_copy.get();
400
401 s->frame_queue.push(std::move(frame_copy));
402
403#ifdef MEASUREMENT
404 struct timespec t_0;
405 clock_gettime(CLOCK_MONOTONIC_RAW, &t_0);
406
407 s->times_map[s->frame_seq_in] = t_0;
408#endif
409 lock.unlock();
410
411 status = CFHD_EncodeAsyncSample(s->encoderPoolRef,
412 s->frame_seq_in++,
413 frame_ptr->tiles[0].data,
414 vc_get_linesize(s->precompress_desc.width, s->precompress_desc.color_spec),
415 nullptr);
416
417 if(status != CFHD_ERROR_OKAY){
418 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to push sample to encode pool\n");
419 return;
420 }
421}
struct video_desc desc
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
int vc_get_linesize(unsigned int width, codec_t codec)
struct video_frame * vf_alloc_desc_data(struct video_desc desc)
char * data
Raw tile data. Pointer must be at least 4B aligned.
Definition types.h:287
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
Definition types.h:345
@ PROGRESSIVE
progressive frame
Definition types.h:164
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
Definition types.h:71
static video_frame * get_copy(struct state_video_compress_cineform *s, video_frame *frame)
Definition cineform.cpp:333
static bool configure_with(struct state_video_compress_cineform *s, struct video_desc desc)
Definition cineform.cpp:243
void vf_clear(struct video_frame *f)
bool video_desc_eq_excl_param(struct video_desc a, struct video_desc b, unsigned int excluded_params)
Compares two video descriptions.
#define PARAM_TILE_COUNT
Definition video_frame.h:68

References video_desc::color_spec, configure_with(), tile::data, desc, state_video_compress_cineform::encoderPoolRef, state_video_compress_cineform::frame_queue, state_video_compress_cineform::frame_seq_in, get_copy(), LOG_LEVEL_ERROR, log_msg(), state_video_compress_cineform::mutex, PARAM_TILE_COUNT, state_video_compress_cineform::precompress_desc, PROGRESSIVE, state_video_compress_cineform::saved_desc, state_video_compress_cineform::started, state, state_video_compress_cineform::stop, video_frame::tiles, UYVY, vc_get_linesize(), vf_alloc_desc_data(), vf_clear(), vf_free(), video_desc_eq_excl_param(), video_desc_from_frame(), and video_desc::width.

Here is the call graph for this function:

◆ configure_with()

static bool configure_with ( struct state_video_compress_cineform * s,
struct video_desc desc )
static

Definition at line 243 of file cineform.cpp.

244{
245 CFHD_Error status = CFHD_ERROR_OKAY;
246
247 if(s->started){
248 status = CFHD_StopEncoderPool(s->encoderPoolRef);
249 if(status != CFHD_ERROR_OKAY){
250 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to stop encoder pool\n");
251 return false;
252 }
253 }
254
256 int i = 0;
257 for(const auto &codec : codecs) {
258 to_convs[i++] = codec.ug_codec;
259 }
262 LOG(LOG_LEVEL_VERBOSE) << MOD_NAME << "Using " << get_codec_name(s->precompress_desc.color_spec) << " as intermediate.\n";
263
264 CFHD_PixelFormat pix_fmt = CFHD_PIXEL_FORMAT_UNKNOWN;
265 CFHD_EncodedFormat enc_fmt = CFHD_ENCODED_FORMAT_UNKNOWN;
266 for(const auto &codec : codecs){
267 if (codec.ug_codec == s->precompress_desc.color_spec){
268 pix_fmt = codec.cfhd_pixel_format;
269 enc_fmt = codec.cfhd_encoded_format;
270 break;
271 }
272 }
273
274 if(pix_fmt == CFHD_PIXEL_FORMAT_UNKNOWN){
275 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to find suitable pixel format\n");
276 return false;
277 }
278
279 status = CFHD_PrepareEncoderPool(s->encoderPoolRef,
280 desc.width,
281 desc.height,
282 pix_fmt,
283 enc_fmt,
284 CFHD_ENCODING_FLAGS_NONE,
286
287 if(status != CFHD_ERROR_OKAY){
288 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to prepare to encode\n");
289 return false;
290 }
291
295
296 s->saved_desc = desc;
297
298 status = CFHD_AttachEncoderPoolMetadata(s->encoderPoolRef, s->metadataRef);
299 if(status != CFHD_ERROR_OKAY){
300 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to attach metadata to encoder pool\n");
301 }
302
303 uint32_t fcc_tag = to_fourcc('U', 'G', 'P', 'F');
304 uint32_t val = desc.color_spec;
305 status = CFHD_MetadataAdd(s->metadataRef,
306 fcc_tag,
307 METADATATYPE_UINT32,
308 sizeof(uint32_t),
309 &val,
310 false);
311 if(status != CFHD_ERROR_OKAY){
312 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to add metadata %u\n", status);
313 }
314
315 status = CFHD_AttachEncoderPoolMetadata(s->encoderPoolRef, s->metadataRef);
316 if(status != CFHD_ERROR_OKAY){
317 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to attach metadata to encoder pool\n");
318 }
319
320 log_msg(LOG_LEVEL_INFO, "[cineform] start encoder pool\n");
321 status = CFHD_StartEncoderPool(s->encoderPoolRef);
322 if(status != CFHD_ERROR_OKAY){
323 log_msg(LOG_LEVEL_ERROR, "[cineform] Failed to start encoder pool\n");
324 return false;
325 }
326
327 s->started = true;
328 s->cv.notify_all();
329
330 return true;
331}
int void * val
const char * get_codec_name(codec_t codec)
#define LOG_LEVEL_INFO
normal reporting
Definition debug.h:62
#define LOG_LEVEL_VERBOSE
Definition debug.h:63
#define LOG(level)
Definition debug.h:313
#define to_fourcc(a, b, c, d)
Creates FourCC word.
Definition macros.h:114
decoder_t get_best_decoder_from(codec_t in, const codec_t *out_candidates, codec_t *out)
struct video_desc compressed_desc
Definition cineform.cpp:85
struct video_desc precompress_desc
Definition cineform.cpp:84
std::condition_variable cv
Definition cineform.cpp:103
unsigned int tile_count
Definition types.h:185
codec_t color_spec
Definition types.h:182
unsigned int width
width of every tile (!)
Definition types.h:179
unsigned int height
height of every tile (!)
Definition types.h:180
codec_t
Definition types.h:65
@ VIDEO_CODEC_NONE
dummy color spec
Definition types.h:66
@ CFHD
Cineform.
Definition types.h:94
@ VIDEO_CODEC_COUNT
count of known video codecs (including VIDEO_CODEC_NONE)
Definition types.h:108
#define MOD_NAME
Definition cineform.cpp:76
static struct @76 codecs[]

References CFHD, codecs, video_desc::color_spec, state_video_compress_cineform::compressed_desc, state_video_compress_cineform::cv, state_video_compress_cineform::dec, desc, state_video_compress_cineform::encoderPoolRef, get_best_decoder_from(), get_codec_name(), video_desc::height, LOG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_VERBOSE, log_msg(), state_video_compress_cineform::metadataRef, MOD_NAME, state_video_compress_cineform::precompress_desc, state_video_compress_cineform::requested_quality, state_video_compress_cineform::saved_desc, state_video_compress_cineform::started, video_desc::tile_count, to_fourcc, val, VIDEO_CODEC_COUNT, VIDEO_CODEC_NONE, and video_desc::width.

Referenced by cineform_compress_push(), and cineform_decompress_reconfigure().

Here is the call graph for this function:

◆ get_cineform_module_info()

static compress_module_info get_cineform_module_info ( )
static

Definition at line 514 of file cineform.cpp.

514 {
515 compress_module_info module_info;
516 module_info.name = "cineform";
517
518 for(const auto& opt : usage_opts){
519 module_info.opts.emplace_back(module_option{opt.label,
520 opt.description, opt.placeholder, opt.key, opt.opt_str, false});
521 }
522
524 codec_info.name = "Cineform";
525 codec_info.priority = 400;
526 codec_info.encoders.emplace_back(encoder{"default", ""});
527
528 module_info.codecs.emplace_back(std::move(codec_info));
529
530 return module_info;
531}
const char * name
displayed name
std::vector< codec > codecs
std::vector< module_option > opts
static const struct codec_info_t codec_info[]
struct @75 usage_opts[]

References codec_info, compress_module_info::codecs, codec_info_t::name, compress_module_info::name, compress_module_info::opts, and usage_opts.

◆ get_copy()

static video_frame * get_copy ( struct state_video_compress_cineform * s,
video_frame * frame )
static

Definition at line 333 of file cineform.cpp.

333 {
335 vf_copy_metadata(ret, frame); // seq and compress_start
336 int src_linesize = vc_get_linesize(frame->tiles[0].width, frame->color_spec);
337 int dst_linesize = vc_get_linesize(frame->tiles[0].width, ret->color_spec);
338 auto *dst = (unsigned char *) ret->tiles[0].data;
339 int dst_sign = 1;
340 if (s->precompress_desc.color_spec == RGB) { // upside down
341 dst += static_cast<size_t>(dst_linesize) *
342 (frame->tiles[0].height - 1);
343 dst_sign = -1;
344 }
345 for (long int i = 0; i < (long int) frame->tiles[0].height; ++i) {
346 s->dec(dst + dst_sign * i * dst_linesize, (unsigned char *) frame->tiles[0].data + i * src_linesize, dst_linesize, 16, 8, 0);
347 }
348
349 return ret;
350}
unsigned int width
Definition types.h:280
unsigned int height
Definition types.h:281
codec_t color_spec
Definition types.h:306
@ RGB
RGB 8-bit (packed into 24-bit word)
Definition types.h:80

References video_desc::color_spec, video_frame::color_spec, tile::data, state_video_compress_cineform::dec, frame, tile::height, state_video_compress_cineform::precompress_desc, RGB, video_frame::tiles, vc_get_linesize(), vf_alloc_desc_data(), vf_copy_metadata(), and tile::width.

Referenced by cineform_compress_push().

Here is the call graph for this function:

◆ parse_fmt()

static int parse_fmt ( struct state_video_compress_cineform * s,
char * fmt )
static

Definition at line 144 of file cineform.cpp.

144 {
145 char *item, *save_ptr = NULL;
146 if(fmt) {
147 while((item = strtok_r(fmt, ":", &save_ptr)) != NULL) {
148 if(strncasecmp("help", item, strlen("help")) == 0) {
149 usage();
150 return 1;
151 } else if(strncasecmp("quality=", item, strlen("quality=")) == 0) {
152 char *quality = item + strlen("quality=");
153 int qual = atoi(quality);
154 if(qual >= 1 && qual <= 6){
155 s->requested_quality = static_cast<CFHD_EncodingQuality>(qual);
156 } else {
157 log_msg(LOG_LEVEL_ERROR, "[cineform] Error: Quality must be in range 1-6.\n");
158 return -1;
159 }
160 } else if(strncasecmp("threads=", item, strlen("threads=")) == 0) {
161 char *threads = item + strlen("threads=");
162 s->requested_threads = atoi(threads);
163 } else if(strncasecmp("pool_size=", item, strlen("pool_size=")) == 0) {
164 char *pool_size = item + strlen("pool_size=");
165 s->requested_pool_size = atoi(pool_size);
166 } else {
167 log_msg(LOG_LEVEL_ERROR, "[cineform] Error: unknown option %s.\n",
168 item);
169 return -1;
170 }
171 fmt = NULL;
172 }
173 }
174
175 return 0;
176}
Definition hd-rum.c:27
static void usage()
Definition cineform.cpp:135

References fmt, LOG_LEVEL_ERROR, log_msg(), state_video_compress_cineform::requested_pool_size, state_video_compress_cineform::requested_quality, state_video_compress_cineform::requested_threads, and usage().

Referenced by cineform_compress_init().

Here is the call graph for this function:

◆ REGISTER_MODULE()

REGISTER_MODULE ( cineform ,
& cineform_info,
LIBRARY_CLASS_VIDEO_COMPRESS ,
VIDEO_COMPRESS_ABI_VERSION  )

◆ usage()

static void usage ( void )
static

Definition at line 135 of file cineform.cpp.

135 {
136 printf("Cineform encoder usage:\n");
137 printf("\t-c cineform[:quality=<quality>][:threads=<num_threads>][:pool_size=<pool_size>]\n");
138
139 for(const auto& opt : usage_opts){
140 printf("\t\t<%s> %s\n", opt.key, opt.description);
141 }
142}

References usage_opts.

Referenced by parse_fmt().

Variable Documentation

◆ cfhd_encoded_format

CFHD_EncodedFormat cfhd_encoded_format

Definition at line 233 of file cineform.cpp.

◆ cfhd_pixel_format

CFHD_PixelFormat cfhd_pixel_format

Definition at line 232 of file cineform.cpp.

◆ cineform_info

const struct video_compress_info cineform_info
Initial value:
= {
"cineform",
NULL,
NULL,
NULL,
NULL,
}
static void cineform_compress_push(struct module *state, std::shared_ptr< video_frame > tx)
Definition cineform.cpp:352
static struct module * cineform_compress_init(struct module *parent, const char *opts)
Definition cineform.cpp:178
static std::shared_ptr< video_frame > cineform_compress_pop(struct module *state)
Definition cineform.cpp:438
static compress_module_info get_cineform_module_info()
Definition cineform.cpp:514

Definition at line 533 of file cineform.cpp.

533 {
534 "cineform",
536 NULL,
537 NULL,
538 NULL,
539 NULL,
543};

◆ [struct]

struct { ... } codecs[]
Initial value:
= {
{UYVY, CFHD_PIXEL_FORMAT_2VUY, CFHD_ENCODED_FORMAT_YUV_422},
{RGB, CFHD_PIXEL_FORMAT_RG24, CFHD_ENCODED_FORMAT_RGB_444},
{RGBA, CFHD_PIXEL_FORMAT_BGRa, CFHD_ENCODED_FORMAT_RGBA_4444},
{v210, CFHD_PIXEL_FORMAT_V210, CFHD_ENCODED_FORMAT_YUV_422},
{R10k, CFHD_PIXEL_FORMAT_DPX0, CFHD_ENCODED_FORMAT_RGB_444},
{RG48, CFHD_PIXEL_FORMAT_RG48, CFHD_ENCODED_FORMAT_RGB_444},
}
@ R10k
RGB 10-bit packed - RGBX, big-endian (2 bit padding)
Definition types.h:73
@ RG48
16-bit RGB little-endian (RlRhGl...)
Definition types.h:95
@ RGBA
RGBA 8-bit, big-endian.
Definition types.h:70
@ v210
YCbCr 422 10-bit - xVY0U|xY2UY1|xUY3V|xY5VY4, little-endian (2 bit padding /'x'/),...
Definition types.h:75

Referenced by codec_list_to_str(), configure_with(), delay_get_property(), display_aggregate_get_property(), display_aja_get_property(), display_bluefish444_get_property(), display_conference_get_property(), display_decklink_get_property(), display_deltacast_get_property(), display_dump_get_property(), display_dvs_get_property(), display_file_get_property(), display_ndi_get_property(), display_panogl_get_property(), display_pw_get_property(), display_sage_get_property(), display_sdl2_get_property(), display_sdl_get_property(), display_unix_sock_get_property(), display_v4l2_get_property(), display_xrgl_get_property(), get_supported_pfs(), parse_codecs(), and print_capabilities().

◆ description

◆ key

◆ label

const char* label

Definition at line 124 of file cineform.cpp.

Referenced by SettingsUi::addDeviceTabs(), and SettingsUi::fillFormOptions().

◆ opt_str

const char* opt_str

Definition at line 127 of file cineform.cpp.

Referenced by dev_add_option().

◆ placeholder

const char* placeholder

Definition at line 128 of file cineform.cpp.

Referenced by LineEditUi::setPlaceholder(), and videoCompressBitrateCallback().

◆ ug_codec

codec_t ug_codec

Definition at line 231 of file cineform.cpp.

◆ [struct]

struct { ... } usage_opts[]
Initial value:
= {
{"Quality", "quality", "specifies encode quality, range 1-6 (default: 4)", ":quality=", "4"},
{"Threads", "num_threads", "specifies number of threads for encoding (default: " TOSTRING(DEFAULT_THREAD_COUNT) ")", ":num_threads=", ""},
{"Pool size", "pool_size", "specifies the size of encoding pool (default: " TOSTRING(DEFAULT_POOL_SIZE) ")", ":pool_size=", ""},
}
#define TOSTRING(A)
Definition macros.h:49

Referenced by get_cineform_module_info(), and usage().