spec/frames_spec.rb in aviglitch-0.1.3 vs spec/frames_spec.rb in aviglitch-0.1.4
- old
+ new
@@ -458,26 +458,103 @@
f.flag.should == 0
f.id.should == "02dc"
end
end
- it 'should clear keyframes with one method' do
+ it 'should mutate keyframes into deltaframe' do
a = AviGlitch.open @in
- a.frames.clear_keyframes!
+ a.frames.mutate_keyframes_into_deltaframes!
a.output @out
a = AviGlitch.open @out
a.frames.each do |f|
f.is_keyframe?.should be false
end
a = AviGlitch.open @in
- a.frames.clear_keyframes! 0..50
+ a.frames.mutate_keyframes_into_deltaframes! 0..50
a.output @out
a = AviGlitch.open @out
a.frames.each_with_index do |f, i|
if i <= 50
f.is_keyframe?.should be false
end
end
+ end
+
+ it 'should return Enumerator with #each' do
+ a = AviGlitch.open @in
+ enum = a.frames.each
+ enum.each do |f, i|
+ if f.is_keyframe?
+ f.data = f.data.gsub(/\d/, '')
+ end
+ end
+ a.output @out
+ AviGlitch::Base.surely_formatted?(@out, true).should be true
+ expect(File.size(@out)).to be < File.size(@in)
+ end
+
+ it 'should use Enumerator as an external iterator',
+ :skip => Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.0') || RUBY_PLATFORM == 'java' do
+ a = AviGlitch.open @in
+ e = a.frames.each
+ expect {
+ while f = e.next do
+ expect(f).to be_a(AviGlitch::Frame)
+ if f.is_keyframe?
+ f.data = f.data.gsub(/\d/, '')
+ end
+ end
+ }.to raise_error(StopIteration)
+ a.output @out
+ AviGlitch::Base.surely_formatted?(@out, true).should be true
+ expect(File.size(@out)).to be < File.size(@in)
+ end
+
+ it 'should count the size of specific frames' do
+ a = AviGlitch.open @in
+ f = a.frames
+
+ kc1 = f.size_of :keyframes
+ kc2 = f.size_of :keyframe
+ kc3 = f.size_of :iframes
+ kc4 = f.size_of :iframe
+
+ dc1 = f.size_of :deltaframes
+ dc2 = f.size_of :deltaframe
+ dc3 = f.size_of :pframes
+ dc4 = f.size_of :pframe
+
+ vc1 = f.size_of :videoframes
+ vc2 = f.size_of :videoframe
+
+ ac1 = f.size_of :audioframes
+ ac2 = f.size_of :audioframe
+
+ kc = dc = vc = ac = 0
+ a.frames.each do |x|
+ vc += x.is_videoframe? ? 1 : 0
+ kc += x.is_keyframe? ? 1 : 0
+ dc += x.is_deltaframe? ? 1 : 0
+ ac += x.is_audioframe? ? 1 : 0
+ end
+
+ a.close
+
+ expect(kc1).to eq(kc)
+ expect(kc2).to eq(kc)
+ expect(kc3).to eq(kc)
+ expect(kc4).to eq(kc)
+
+ expect(dc1).to eq(dc)
+ expect(dc2).to eq(dc)
+ expect(dc3).to eq(dc)
+ expect(dc4).to eq(dc)
+
+ expect(vc1).to eq(vc)
+ expect(vc2).to eq(vc)
+
+ expect(ac1).to eq(ac)
+ expect(ac2).to eq(ac)
end
end