KvpValue * gnc_scm_to_kvp_value_ptr(SCM val) { if (scm_is_rational(val)) { if (scm_is_exact(val) && (scm_is_signed_integer(val, INT64_MIN, INT64_MAX) || scm_is_unsigned_integer(val, INT64_MIN, INT64_MAX))) { return new KvpValue{scm_to_int64(val)}; } else if (scm_is_exact(val) && (scm_is_signed_integer(scm_numerator(val), INT64_MIN, INT64_MAX) || scm_is_unsigned_integer(scm_numerator(val), INT64_MIN, INT64_MAX)) && (scm_is_signed_integer(scm_denominator(val), INT64_MIN, INT64_MAX) || (scm_is_unsigned_integer(scm_denominator(val), INT64_MIN, INT64_MAX)))) { return new KvpValue{gnc_scm_to_numeric(val)}; } else { return new KvpValue{scm_to_double(val)}; } } else if (gnc_guid_p(val)) { auto guid = gnc_scm2guid(val); auto tmpguid = guid_copy(&guid); return new KvpValue{tmpguid}; } else if (gnc_timepair_p(val)) { Timespec ts = gnc_timepair2timespec(val); return new KvpValue{ts}; } else if (scm_is_string(val)) { return new KvpValue{gnc_scm_to_utf8_string(val)}; } else if (SWIG_IsPointerOfType(val, SWIG_TypeQuery("_p_KvpFrame"))) { #define FUNC_NAME G_STRFUNC auto vp_frame = SWIG_MustGetPtr(val, SWIG_TypeQuery("_p_KvpFrame"), 1, 0); KvpFrame *frame = static_cast<KvpFrame*>(vp_frame); #undef FUNC_NAME return new KvpValue{frame}; } /* FIXME: add list handler here */ return NULL; }
static AVCodecContext *configure_output_video_codec(AVStream *video_stream, enum AVCodecID video_codec_id, SCM scm_video_bit_rate, SCM scm_shape, SCM scm_frame_rate, SCM scm_aspect_ratio) { // Get codec context AVCodecContext *retval = video_stream->codec; // Set codec id retval->codec_id = video_codec_id; retval->codec_type = AVMEDIA_TYPE_VIDEO; // Set encoder bit rate retval->bit_rate = scm_to_int(scm_video_bit_rate); // Set video frame width and height retval->width = scm_to_int(scm_cadr(scm_shape)); retval->height = scm_to_int(scm_car(scm_shape)); // Set video frame rate video_stream->avg_frame_rate.num = scm_to_int(scm_numerator(scm_frame_rate)); video_stream->avg_frame_rate.den = scm_to_int(scm_denominator(scm_frame_rate)); video_stream->time_base.num = video_stream->avg_frame_rate.den; video_stream->time_base.den = video_stream->avg_frame_rate.num; retval->time_base = video_stream->time_base; // Set intra frame lower limit retval->gop_size = 12; // Set pixel format retval->pix_fmt = PIX_FMT; if (retval->codec_id == AV_CODEC_ID_MPEG1VIDEO) retval->mb_decision = 2; // Set aspect ratio video_stream->sample_aspect_ratio.num = scm_to_int(scm_numerator(scm_aspect_ratio)); video_stream->sample_aspect_ratio.den = scm_to_int(scm_denominator(scm_aspect_ratio)); retval->sample_aspect_ratio = video_stream->sample_aspect_ratio; return retval; }