Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0ed5415520
Fetching contributors…

Cannot retrieve contributors at this time

257 lines (212 sloc) 11.059 kb
require 'ffmpeg/test_case'
class TestFFMPEGFrame < FFMPEG::TestCase
def setup
super
@frame = FFMPEG::Frame.new 40, 30, FFMPEG::PixelFormat::YUV420P
@frame.defaults
@data_size = @frame.data_size
end
def test_class_from
format_context = FFMPEG::FormatContext.new @thumbs_up
codec_context = format_context.video_stream.codec_context
frame = FFMPEG::Frame.from codec_context
assert_equal 176, frame.width
assert_equal 144, frame.height
assert_equal FFMPEG::PixelFormat::YUV420P, frame.pixel_format
end
def test_clear
@frame.fill
@frame.data = ["\x55" * @data_size, nil, nil, nil]
@frame.clear
assert_equal "\0" * @data_size, @frame.data[0]
end
def test_data
@frame.fill
data = @frame.data
assert_equal 4, data.length
assert_equal @data_size, data[0].length
refute_nil data[1]
refute_nil data[2]
assert_equal nil, data[3]
data[0].replace "\xff"
refute_equal "\xff", @frame.data[0]
end
def test_data_equals
@frame.fill
@frame.data = ["\x55" * @data_size, nil, nil, nil]
assert_equal "\x55" * @data_size, @frame.data[0]
end
def test_data_equals2
@frame.fill
data = util_fill_frame @frame
@frame.data = data
data = @frame.data
expected = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x01\x02\x03\x04\x05\x06\x07\x08",
"\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18",
"\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28",
"\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11",
"\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21",
"\x22\x23\x24\x25\x26\x27\x28\x29\x03\x04\x05\x06\x07\x08\x09\x0a",
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a",
"\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a",
"\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13",
"\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23",
"\x24\x25\x26\x27\x28\x29\x2a\x2b\x05\x06\x07\x08\x09\x0a\x0b\x0c",
"\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c",
"\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c",
"\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15",
"\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25",
"\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x07\x08\x09\x0a\x0b\x0c\x0d\x0e",
"\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e",
"\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e",
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17",
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27",
"\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10",
"\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
"\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30",
"\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
"\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29",
"\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x0b\x0c\x0d\x0e\x0f\x10\x11\x12",
"\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22",
"\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32",
"\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b",
"\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b",
"\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x0d\x0e\x0f\x10\x11\x12\x13\x14",
"\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24",
"\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34",
"\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d",
"\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d",
"\x2e\x2f\x30\x31\x32\x33\x34\x35\x0f\x10\x11\x12\x13\x14\x15\x16",
"\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26",
"\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x11\x12\x13\x14\x15\x16\x17\x18",
"\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28",
"\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38",
"\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21",
"\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31",
"\x32\x33\x34\x35\x36\x37\x38\x39\x13\x14\x15\x16\x17\x18\x19\x1a",
"\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a",
"\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a",
"\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23",
"\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33",
"\x34\x35\x36\x37\x38\x39\x3a\x3b\x15\x16\x17\x18\x19\x1a\x1b\x1c",
"\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c",
"\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c",
"\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25",
"\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35",
"\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x17\x18\x19\x1a\x1b\x1c\x1d\x1e",
"\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e",
"\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e",
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27",
"\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37",
"\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
"\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30",
"\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40",
"\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29",
"\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39",
"\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x1b\x1c\x1d\x1e\x1f\x20\x21\x22",
"\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32",
"\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42",
"\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b",
"\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b",
"\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x1d\x1e\x1f\x20\x21\x22\x23\x24",
"\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34",
"\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44",
"\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80",
"\x80\x80\x80\x80\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81",
"\x81\x81\x81\x81\x81\x81\x81\x81\x82\x82\x82\x82\x82\x82\x82\x82",
"\x82\x82\x82\x82\x82\x82\x82\x82\x82\x82\x82\x82\x83\x83\x83\x83",
"\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83\x83",
"\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84\x84",
"\x84\x84\x84\x84\x85\x85\x85\x85\x85\x85\x85\x85\x85\x85\x85\x85",
"\x85\x85\x85\x85\x85\x85\x85\x85\x86\x86\x86\x86\x86\x86\x86\x86",
"\x86\x86\x86\x86\x86\x86\x86\x86\x86\x86\x86\x86\x87\x87\x87\x87",
"\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87\x87",
"\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88\x88",
"\x88\x88\x88\x88\x89\x89\x89\x89\x89\x89\x89\x89\x89\x89\x89\x89",
"\x89\x89\x89\x89\x89\x89\x89\x89\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a",
"\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8b\x8b\x8b\x8b",
"\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b\x8b",
"\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c\x8c",
"\x8c\x8c\x8c\x8c\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d",
"\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8d\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e",
"\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x8e\x40\x41\x42\x43",
"\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b",
"\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47",
"\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43",
"\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b",
"\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47",
"\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43",
"\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b",
"\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47",
"\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x40\x41\x42\x43",
"\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b",
"\x4c\x4d\x4e\x4f\x50\x51\x52\x53",
].join ''
# for rebuilding above if it's wrong
#data = data.first
#until data.empty? do
# bytes = data.slice! 0, 16
# p bytes.unpack('C*').map { |byte|
# "x#{"%02x" % byte}"
# }.join('')
#end
#flunk
assert_equal expected, data[0]
end
def test_data_size
assert_equal 1800, @data_size
end
def test_defaults
@frame.defaults
# this test sucks, the underlying C call does these things now
assert_equal FFMPEG::NOPTS_VALUE, @frame.pts
assert_equal true, @frame.key_frame
end
def test_fill
assert_equal [nil, nil, nil, nil], @frame.data
@frame.fill
data = @frame.data
assert_equal @data_size, data.first.length
end
def test_key_frame
assert_equal true, @frame.key_frame
end
def test_key_frame_eh
assert @frame.key_frame?
end
def test_linesize
@frame.fill
assert_equal [40, 20, 20, 0], @frame.linesize
end
def test_picture_type
@frame.picture_type = FFMPEG::PixelFormat::RGBA
assert_equal FFMPEG::PixelFormat::RGBA, @frame.picture_type
end
def test_pts
@frame.pts = 2
assert_equal 2, @frame.pts
end
def test_quality
@frame.quality = 2
assert_equal 2, @frame.quality
end
def test_type
assert_equal nil, @frame.type
@frame.picture_type = FFMPEG::Frame::I_TYPE
assert_equal :I_TYPE, @frame.type
end
end
Jump to Line
Something went wrong with that request. Please try again.