diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index a533a953..09de56c9 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -569,6 +569,11 @@ impl TtToCea608 { let frame_no = pts.mul_div_round(fps_n, fps_d).unwrap().seconds(); + if state.last_frame_no == 0 { + gst_debug!(CAT, obj: element, "Initial skip to frame no {}", frame_no); + state.last_frame_no = pts.mul_div_floor(fps_n, fps_d).unwrap().seconds(); + } + state.max_frame_no = (pts + duration) .mul_div_round(fps_n, fps_d) .unwrap() @@ -809,6 +814,8 @@ impl TtToCea608 { element: &super::TtToCea608, buffer: gst::Buffer, ) -> Result { + gst_log!(CAT, obj: element, "Handling {:?}", buffer); + let pts = buffer.pts().ok_or_else(|| { gst::element_error!( element, @@ -941,6 +948,18 @@ impl TtToCea608 { ); let (timestamp, duration) = e.get(); + + if state.last_frame_no == 0 { + state.last_frame_no = timestamp.mul_div_floor(fps_n, fps_d).unwrap().seconds(); + + gst_debug!( + CAT, + obj: element, + "Initial skip to frame no {}", + state.last_frame_no + ); + } + let frame_no = (timestamp + duration.unwrap()) .mul_div_round(fps_n, fps_d) .unwrap() diff --git a/video/closedcaption/tests/tttocea608.rs b/video/closedcaption/tests/tttocea608.rs index 237a4138..a1715df5 100644 --- a/video/closedcaption/tests/tttocea608.rs +++ b/video/closedcaption/tests/tttocea608.rs @@ -68,16 +68,6 @@ fn test_one_timed_buffer_and_eos() { assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - loop { - let outbuf = h.pull().unwrap(); - if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= ClockTime::SECOND { - break; - } - - let data = outbuf.map_readable().unwrap(); - assert_eq!(&*data, &[0x80, 0x80]); - } - let expected: [(ClockTime, ClockTime, [u8; 2usize]); 7] = [ ( ClockTime::from_nseconds(1_000_000_000), @@ -361,17 +351,6 @@ fn test_one_timed_buffer_and_eos_roll_up2() { let inbuf = new_timed_buffer(&"World", 2 * ClockTime::SECOND, ClockTime::from_nseconds(1)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - /* Padding */ - loop { - let outbuf = h.pull().unwrap(); - if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= ClockTime::SECOND { - break; - } - - let data = outbuf.map_readable().unwrap(); - assert_eq!(&*data, &[0x80, 0x80]); - } - let expected: [(ClockTime, ClockTime, [u8; 2usize]); 5] = [ ( ClockTime::from_nseconds(1_000_000_000), @@ -497,17 +476,6 @@ fn test_word_wrap_roll_up() { let inbuf = new_timed_buffer(&"Hello World", ClockTime::SECOND, ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - /* Padding */ - loop { - let outbuf = h.pull().unwrap(); - if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= ClockTime::SECOND { - break; - } - - let data = outbuf.map_readable().unwrap(); - assert_eq!(&*data, &[0x80, 0x80]); - } - let expected: [(ClockTime, ClockTime, [u8; 2usize]); 11] = [ ( ClockTime::from_nseconds(1_000_000_000),