update to libltc-1.1.0
authorRobin Gareus <robin@gareus.org>
Sat, 17 Nov 2012 20:15:41 +0000 (20:15 +0000)
committerRobin Gareus <robin@gareus.org>
Sat, 17 Nov 2012 20:15:41 +0000 (20:15 +0000)
add support for TV standard specific offset and
binary-group-flags

git-svn-id: svn://localhost/ardour2/branches/3.0@13514 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ltc_slave.cc
libs/ardour/session_ltc.cc
libs/ardour/wscript

index 7b182cfa64949a8bf2e5176327fc5d013f4f035e..4a40bb40a2acd4d7e29906b1fc82e2b3e26a5966 100644 (file)
@@ -200,9 +200,9 @@ LTC_Slave::detect_discontinuity(LTCFrameExt *frame, int fps, bool fuzzy) {
        }
 
        if (frame->reverse) {
-               ltc_frame_decrement(&prev_frame.ltc, fps , 0);
+               ltc_frame_decrement(&prev_frame.ltc, fps, LTC_TV_525_60, 0);
        } else {
-               ltc_frame_increment(&prev_frame.ltc, fps , 0);
+               ltc_frame_increment(&prev_frame.ltc, fps, LTC_TV_525_60, 0);
        }
        if (!equal_ltc_frame_time(&prev_frame.ltc, &frame->ltc)) {
                discontinuity_detected = true;
@@ -298,6 +298,7 @@ void
 LTC_Slave::process_ltc(framepos_t const now)
 {
        LTCFrameExt frame;
+       enum LTC_TV_STANDARD tv_standard = LTC_TV_625_50;
        while (ltc_decoder_read(decoder, &frame)) {
                SMPTETimecode stime;
 
@@ -337,15 +338,34 @@ LTC_Slave::process_ltc(framepos_t const now)
                 * is expected to start at the end of the current frame
                 */
                int fps_i = ceil(timecode.rate);
+
+               switch(fps_i) {
+                       case 30:
+                               if (timecode.drop) {
+                                       tv_standard = LTC_TV_525_60;
+                               } else {
+                                       tv_standard = LTC_TV_1125_60;
+                               }
+                               break;
+                       case 25:
+                               tv_standard = LTC_TV_625_50;
+                               break;
+                       default:
+                               tv_standard = LTC_TV_FILM_24; /* == LTC_TV_1125_60 == no offset, 24,30fps BGF */
+                               break;
+               }
+
                if (!frame.reverse) {
-                       ltc_frame_increment(&frame.ltc, fps_i , 0);
+                       ltc_frame_increment(&frame.ltc, fps_i, tv_standard, 0);
                        ltc_frame_to_time(&stime, &frame.ltc, 0);
                        transport_direction = 1;
+                       frame.off_start -= ltc_frame_alignment(session.frame_rate(), tv_standard);
+                       frame.off_end -= ltc_frame_alignment(session.frame_rate(), tv_standard);
                } else {
-                       ltc_frame_decrement(&frame.ltc, fps_i , 0);
+                       ltc_frame_decrement(&frame.ltc, fps_i, tv_standard, 0);
                        int off = frame.off_end - frame.off_start;
-                       frame.off_start += off;
-                       frame.off_end += off;
+                       frame.off_start += off - ltc_frame_alignment(session.frame_rate(), tv_standard);
+                       frame.off_end += off - ltc_frame_alignment(session.frame_rate(), tv_standard);
                        transport_direction = -1;
                }
 
index 733ca6877e64cbdf735919eaa960f933f015ff62..93368d6e612aec79e49b6d9a685108001bea9f34 100644 (file)
@@ -56,7 +56,11 @@ using namespace Timecode;
  * This filter is adaptive so that fast vari-speed signals
  * will not be affected by it.
  */
-#define LTC_RISE_TIME(speed) MIN (100, MAX(25, (4000000 / ((speed==0)?1:speed) / engine().frame_rate())))
+#define LTC_RISE_TIME(speed) MIN (100, MAX(40, (4000000 / ((speed==0)?1:speed) / engine().frame_rate())))
+
+#define TV_STANDARD(tcf) \
+       (timecode_to_frames_per_second(tcf)==25.0 ? LTC_TV_625_50 : \
+        timecode_has_drop_frames(tcf)? LTC_TV_525_60 : LTC_TV_FILM_24)
 
 void
 Session::ltc_tx_initialize()
@@ -67,7 +71,7 @@ Session::ltc_tx_initialize()
        DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX init sr: %1 fps: %2\n", nominal_frame_rate(), timecode_to_frames_per_second(ltc_enc_tcformat)));
        ltc_encoder = ltc_encoder_create(nominal_frame_rate(),
                        timecode_to_frames_per_second(ltc_enc_tcformat),
-                       -2);
+                       TV_STANDARD(ltc_enc_tcformat), 0);
 
        ltc_encoder_set_bufsize(ltc_encoder, nominal_frame_rate(), 23.0);
        ltc_encoder_set_filter(ltc_encoder, LTC_RISE_TIME(1.0));
@@ -208,7 +212,10 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
        TimecodeFormat cur_timecode = config.get_timecode_format();
        if (cur_timecode != ltc_enc_tcformat) {
                DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX1: TC format mismatch - reinit sr: %1 fps: %2\n", nominal_frame_rate(), timecode_to_frames_per_second(cur_timecode)));
-               if (ltc_encoder_reinit(ltc_encoder, nominal_frame_rate(), timecode_to_frames_per_second(cur_timecode), -2)) {
+               if (ltc_encoder_reinit(ltc_encoder, nominal_frame_rate(),
+                                       timecode_to_frames_per_second(cur_timecode), 
+                                       TV_STANDARD(cur_timecode), 0
+                                       )) {
                        PBD::error << _("LTC encoder: invalid framerate - LTC encoding is disabled for the remainder of this session.") << endmsg;
                        ltc_tx_cleanup();
                        return;
@@ -238,6 +245,9 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
         */
        framepos_t cycle_start_frame = (current_speed < 0) ? (start_frame - ltc_out_latency.max) : (start_frame + ltc_out_latency.max);
 
+       /* LTC TV standard offset */
+       cycle_start_frame += ltc_frame_alignment(nominal_frame_rate(), TV_STANDARD(cur_timecode));
+
        /* cycle-start may become negative due to latency compensation */
        if (cycle_start_frame < 0) { cycle_start_frame = 0; }
 
index 22b0ef342b1763e3bac64c9fa8a14cd4207449f7..f47ba0a3b26b3f92393b117cfd6e2d13e36e2671 100644 (file)
@@ -282,7 +282,7 @@ def configure(conf):
     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL',
                       atleast_version='7.0.0')
     autowaf.check_pkg(conf, 'ltc', uselib_store='LTC',
-                      atleast_version='1.0.3', mandatory=False)
+                      atleast_version='1.1.0', mandatory=False)
 
     # we don't try to detect this, since its part of our source tree