Fix video aspect ratio calculation
This commit is contained in:
		
					parent
					
						
							
								aec1c67178
							
						
					
				
			
			
				commit
				
					
						c51ccf4f2c
					
				
			
		
					 2 changed files with 44 additions and 10 deletions
				
			
		|  | @ -77,16 +77,19 @@ class StreamTest extends TestCase | |||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     public function testGetDimensionsFromVideoWithDisplayRatio() | ||||
|     /** | ||||
|      * @dataProvider providePropertiesForDimensionsExtraction | ||||
|      */ | ||||
|     public function testGetDimensionsFromVideoWithDisplayRatio($data) | ||||
|     { | ||||
|         $stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => '4:3', 'display_aspect_ratio' => '16:9')); | ||||
|         $this->assertEquals(new Dimension(1280, 720), $stream->getDimensions()); | ||||
|     } | ||||
| 
 | ||||
|     public function testGetDimensionsFromVideoWith11SampleRatio() | ||||
|     { | ||||
|         $stream = new Stream(array('codec_type' => 'video', 'width' => 1920, 'height' => 1080, 'sample_aspect_ratio' => '1:1', 'display_aspect_ratio' => '16:9')); | ||||
|         $this->assertEquals(new Dimension(1920, 1080), $stream->getDimensions()); | ||||
|         $stream = new Stream(array( | ||||
|             'codec_type' => 'video', | ||||
|             'width' => $data['width'], | ||||
|             'height' =>  $data['height'], | ||||
|             'sample_aspect_ratio' =>  $data['sar'], | ||||
|             'display_aspect_ratio' =>  $data['dar'] | ||||
|         )); | ||||
|         $this->assertEquals(new Dimension($data['result_width'], $data['result_height']), $stream->getDimensions()); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -102,4 +105,30 @@ class StreamTest extends TestCase | |||
|     { | ||||
|         return array(array('0:1'), array('2:1:3')); | ||||
|     } | ||||
| 
 | ||||
|     public function providePropertiesForDimensionsExtraction() | ||||
|     { | ||||
|         return array( | ||||
|             array( | ||||
|                 array('width' => '960', 'height' => '720', | ||||
|                 'sar' => '4:3', 'dar' => '16:9', | ||||
|                 'result_width' => '1280', 'result_height' => '720'), | ||||
|             ), | ||||
|             array( | ||||
|                 array('width' => '1920', 'height' => '1080', | ||||
|                 'sar' => '1:1', 'dar' => '16:9', | ||||
|                 'result_width' => '1920', 'result_height' => '1080'), | ||||
|             ), | ||||
|             array( | ||||
|                 array('width' => '640', 'height' => '480', | ||||
|                 'sar' => '75:74', 'dar' => '50:37', | ||||
|                 'result_width' => '649', 'result_height' => '480'), | ||||
|             ), | ||||
|             array( | ||||
|                 array('width' => '720', 'height' => '576', | ||||
|                   'sar' => '52:28', 'dar' => '16:9', | ||||
|                   'result_width' => '1337', 'result_height' => '752'), | ||||
|             ), | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue