ffi-libav 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -1
- data/Rakefile +1 -1
- data/lib/ffi/libav.i +4 -3
- data/lib/ffi/libav.rb +976 -1046
- data/lib/libav/frame.rb +4 -4
- data/lib/libav/stream.rb +10 -7
- data/lib/libav/version.rb +1 -1
- data/spec/frame_spec.rb +5 -5
- metadata +2 -2
data/lib/libav/frame.rb
CHANGED
@@ -89,10 +89,10 @@ class Libav::Frame::Video
|
|
89
89
|
:pixel_format => p[:pixel_format] || pixel_format,
|
90
90
|
:stream => stream)
|
91
91
|
ctx = p[:scale_ctx] ||
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
raise NoMemoryError, "
|
92
|
+
sws_getCachedContext(nil, width, height, pixel_format,
|
93
|
+
out.width, out.height, out.pixel_format,
|
94
|
+
SWS_BICUBIC, nil, nil, nil)
|
95
|
+
raise NoMemoryError, "sws_getCachedContext() failed" if ctx.nil?
|
96
96
|
|
97
97
|
# Scale the image
|
98
98
|
rc = sws_scale(ctx, data, linesize, 0, height, out.data, out.linesize)
|
data/lib/libav/stream.rb
CHANGED
@@ -287,7 +287,10 @@ class Libav::Stream::Video
|
|
287
287
|
end
|
288
288
|
|
289
289
|
def fps
|
290
|
-
@av_stream[:r_frame_rate].to_f
|
290
|
+
fps = @av_stream[:r_frame_rate].to_f
|
291
|
+
# Some codecs don't set frame rate, so we'll use 1/timebase
|
292
|
+
fps = 1/@av_stream[:time_base].to_f if fps.nan?
|
293
|
+
fps
|
291
294
|
end
|
292
295
|
|
293
296
|
# Set the +width+ of the frames returned by +decode_frame+
|
@@ -447,12 +450,12 @@ class Libav::Stream::Video
|
|
447
450
|
end
|
448
451
|
|
449
452
|
# Let's throw together a scaling context
|
450
|
-
@swscale_ctx =
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
raise NoMemoryError, "
|
453
|
+
@swscale_ctx = sws_getCachedContext(nil, @av_codec_ctx[:width],
|
454
|
+
@av_codec_ctx[:height],
|
455
|
+
@av_codec_ctx[:pix_fmt], @width,
|
456
|
+
@height, @pixel_format, SWS_BICUBIC,
|
457
|
+
nil, nil, nil) or
|
458
|
+
raise NoMemoryError, "sws_getCachedContext() failed"
|
456
459
|
end
|
457
460
|
|
458
461
|
@decode_ready = true
|
data/lib/libav/version.rb
CHANGED
data/spec/frame_spec.rb
CHANGED
@@ -252,11 +252,11 @@ describe Libav::Frame, "#scale" do
|
|
252
252
|
frame
|
253
253
|
end
|
254
254
|
subject do
|
255
|
-
ctx = FFI::Libav.
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
255
|
+
ctx = FFI::Libav.sws_getCachedContext(nil, src_frame.width,
|
256
|
+
src_frame.height,
|
257
|
+
src_frame.pixel_format, 100, 100,
|
258
|
+
:gray8, FFI::Libav::SWS_BICUBIC,
|
259
|
+
nil, nil, nil)
|
260
260
|
src_frame.scale(:scale_ctx => ctx, :output_frame => dst_frame)
|
261
261
|
end
|
262
262
|
its(:class) { should be(Libav::Frame::Video) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-libav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|