<commit_before>#lang racket/base

#|
   Copyright 2016-2017 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

;; Library to initialize the MLT framework.
;; Alternatively your program can just call `mlt-factory-init` on its own.
;;   If you do this though, do make sure to shut things down with mlt-factory-init

(require ffi/unsafe
         ffi/unsafe/define
         ffi/unsafe/global
         "ffmpeg.rkt"
         "threading.rkt")

(define video-key #"VIDEO-FFMPEG-INIT")

(define-ffi-definer define-internal #f)

(define-internal vasprintf (_fun [out : (_ptr o _string)] _string _pointer -> [ret : _int]
                                 -> (cond
                                      [(< ret 0) (error 'vasprintf "Error ~a" ret)]
                                      [else out])))

#;
(define (vasprintf format args)
  (define-internal vasprintf (_fun [out : (_ptr o _pointer)] _string _pointer -> [ret : _int]
                                   -> (cond
                                        [(< ret 0) (error 'vasprintf "Error ~a" ret)]
                                        [else out])))
  (define pret (vasprintf format args))
  (define ret (cast pret _pointer _string))
  (free pret)
  ret)

#;
(define (callback-proc avcl level fmt args)
  ;(displayln avcl)
  #;(void (vasprintf fmt args)))

 ;; Init ffmpeg (ONCE PER PROCESS)
(void
 (unless (register-process-global video-key (cast 1 _racket _pointer))
   (av-register-all)
   (avfilter-register-all)
   (avformat-network-init)
   #;(av-log-set-callback callback-proc)))
<commit_msg>Apparently windows cannot find vasprintf.<commit_after>#lang racket/base

#|
   Copyright 2016-2017 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

;; Library to initialize the MLT framework.
;; Alternatively your program can just call `mlt-factory-init` on its own.
;;   If you do this though, do make sure to shut things down with mlt-factory-init

(require ffi/unsafe
         ffi/unsafe/define
         ffi/unsafe/global
         "ffmpeg.rkt"
         "threading.rkt")

(define video-key #"VIDEO-FFMPEG-INIT")

(define-ffi-definer define-internal #f)

#;
(define-internal vasprintf (_fun [out : (_ptr o _string)] _string _pointer -> [ret : _int]
                                 -> (cond
                                      [(< ret 0) (error 'vasprintf "Error ~a" ret)]
                                      [else out])))

#;
(define (vasprintf format args)
  (define-internal vasprintf (_fun [out : (_ptr o _pointer)] _string _pointer -> [ret : _int]
                                   -> (cond
                                        [(< ret 0) (error 'vasprintf "Error ~a" ret)]
                                        [else out])))
  (define pret (vasprintf format args))
  (define ret (cast pret _pointer _string))
  (free pret)
  ret)

#;
(define (callback-proc avcl level fmt args)
  ;(displayln avcl)
  #;(void (vasprintf fmt args)))

 ;; Init ffmpeg (ONCE PER PROCESS)
(void
 (unless (register-process-global video-key (cast 1 _racket _pointer))
   (av-register-all)
   (avfilter-register-all)
   (avformat-network-init)
   #;(av-log-set-callback callback-proc)))

{'fraction_non_alphanumeric': 0.10127495790233342, 'fraction_numerical': 0.007216742843396681, 'mean_word_length': 2.323741007194245, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2846376', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1164, 'n_words': 435}