@@ -113,68 +113,85 @@ test(t => {
113
113
114
114
assert_throws_js (
115
115
TypeError ,
116
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : - 1 , y : 0 , width : 10 , height : 10 } } ) ,
117
- 'negative visibleRect x' ) ;
116
+ ( ) => new VideoFrame (
117
+ image ,
118
+ { timestamp : 10 , visibleRect : { x : - 1 , y : 0 , width : 10 , height : 10 } } ) ,
119
+ 'negative visibleRect x' ) ;
118
120
119
- assert_throws_js (
121
+ assert_throws_js (
120
122
TypeError ,
121
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : - 10 , height : 10 } } ) ,
122
- 'negative visibleRect width' ) ;
123
+ ( ) => new VideoFrame (
124
+ image ,
125
+ { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : - 10 , height : 10 } } ) ,
126
+ 'negative visibleRect width' ) ;
123
127
124
- assert_throws_js (
128
+ assert_throws_js (
125
129
TypeError ,
126
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : 10 , height : 0 } } ) ,
127
- 'zero visibleRect height' ) ;
130
+ ( ) => new VideoFrame (
131
+ image ,
132
+ { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : 10 , height : 0 } } ) ,
133
+ 'zero visibleRect height' ) ;
128
134
129
- assert_throws_js (
130
- TypeError ,
131
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 0 , y : Infinity , width : 10 , height : 10 } } ) ,
132
- 'non finite visibleRect y' ) ;
135
+ assert_throws_js (
136
+ TypeError , ( ) => new VideoFrame ( image , {
137
+ timestamp : 10 ,
138
+ visibleRect : { x : 0 , y : Infinity , width : 10 , height : 10 }
139
+ } ) ,
140
+ 'non finite visibleRect y' ) ;
133
141
134
- assert_throws_js (
135
- TypeError ,
136
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : 10 , height : Infinity } } ) ,
137
- 'non finite visibleRect height' ) ;
142
+ assert_throws_js (
143
+ TypeError , ( ) => new VideoFrame ( image , {
144
+ timestamp : 10 ,
145
+ visibleRect : { x : 0 , y : 0 , width : 10 , height : Infinity }
146
+ } ) ,
147
+ 'non finite visibleRect height' ) ;
138
148
139
- assert_throws_js (
149
+ assert_throws_js (
140
150
TypeError ,
141
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : 33 , height : 17 } } ) ,
142
- 'visibleRect area exceeds coded size' ) ;
151
+ ( ) => new VideoFrame (
152
+ image ,
153
+ { timestamp : 10 , visibleRect : { x : 0 , y : 0 , width : 33 , height : 17 } } ) ,
154
+ 'visibleRect area exceeds coded size' ) ;
143
155
144
- assert_throws_js (
156
+ assert_throws_js (
145
157
TypeError ,
146
- ( ) => new VideoFrame ( image , { timestamp : 10 , visibleRect : { x : 2 , y : 2 , width : 32 , height : 16 } } ) ,
147
- 'visibleRect outside coded size' ) ;
158
+ ( ) => new VideoFrame (
159
+ image ,
160
+ { timestamp : 10 , visibleRect : { x : 2 , y : 2 , width : 32 , height : 16 } } ) ,
161
+ 'visibleRect outside coded size' ) ;
148
162
149
- assert_throws_js (
163
+ assert_throws_js (
150
164
TypeError ,
151
165
( ) => new VideoFrame ( image , { timestamp : 10 , displayHeight : 10 } ) ,
152
- 'displayHeight provided without displayWidth' ) ;
166
+ 'displayHeight provided without displayWidth' ) ;
153
167
154
- assert_throws_js (
155
- TypeError ,
156
- ( ) => new VideoFrame ( image , { timestamp : 10 , displayWidth : 10 } ) ,
157
- 'displayWidth provided without displayHeight' ) ;
168
+ assert_throws_js (
169
+ TypeError , ( ) => new VideoFrame ( image , { timestamp : 10 , displayWidth : 10 } ) ,
170
+ 'displayWidth provided without displayHeight' ) ;
158
171
159
- assert_throws_js (
172
+ assert_throws_js (
160
173
TypeError ,
161
- ( ) => new VideoFrame ( image , { timestamp : 10 , displayWidth : 0 , displayHeight : 10 } ) ,
162
- 'displayWidth is zero' ) ;
174
+ ( ) => new VideoFrame (
175
+ image , { timestamp : 10 , displayWidth : 0 , displayHeight : 10 } ) ,
176
+ 'displayWidth is zero' ) ;
163
177
164
- assert_throws_js (
178
+ assert_throws_js (
165
179
TypeError ,
166
- ( ) => new VideoFrame ( image , { timestamp : 10 , displayWidth : 10 , displayHeight : 0 } ) ,
167
- 'displayHeight is zero' ) ;
180
+ ( ) => new VideoFrame (
181
+ image , { timestamp : 10 , displayWidth : 10 , displayHeight : 0 } ) ,
182
+ 'displayHeight is zero' ) ;
168
183
169
- assert_throws_js (
184
+ assert_throws_js (
170
185
TypeError ,
171
- ( ) => new VideoFrame ( i420Frame , { visibleRect : { x : 1 , y : 0 , width : 2 , height : 2 } } ) ,
186
+ ( ) => new VideoFrame (
187
+ i420Frame , { visibleRect : { x : 1 , y : 0 , width : 2 , height : 2 } } ) ,
172
188
'visibleRect x is not sample aligned' ) ;
173
189
174
- assert_throws_js (
175
- TypeError ,
176
- ( ) => new VideoFrame ( i420Frame , { visibleRect : { x : 0 , y : 0 , width : 1 , height : 2 } } ) ,
177
- 'visibleRect width is not sample aligned' ) ;
190
+ assert_throws_js (
191
+ TypeError ,
192
+ ( ) => new VideoFrame (
193
+ i420Frame , { visibleRect : { x : 0 , y : 1 , width : 2 , height : 2 } } ) ,
194
+ 'visibleRect y is not sample aligned' ) ;
178
195
179
196
} , 'Test invalid CanvasImageSource constructed VideoFrames' ) ;
180
197
@@ -192,7 +209,8 @@ test(t => {
192
209
] ) ;
193
210
let origFrame = new VideoFrame ( data , init ) ;
194
211
195
- let cropLeftHalf = new VideoFrame ( origFrame , { visibleRect : { x : 0 , y : 0 , width : 2 , height : 2 } } ) ;
212
+ let cropLeftHalf = new VideoFrame (
213
+ origFrame , { visibleRect : { x : 0 , y : 0 , width : 2 , height : 2 } } ) ;
196
214
assert_equals ( cropLeftHalf . codedWidth , origFrame . codedWidth ) ;
197
215
assert_equals ( cropLeftHalf . codedHeight , origFrame . codedHeight ) ;
198
216
assert_equals ( cropLeftHalf . visibleRect . x , 0 ) ;
@@ -219,7 +237,8 @@ test(t => {
219
237
] ) ;
220
238
let anamorphicFrame = new VideoFrame ( data , init ) ;
221
239
222
- let cropRightFrame = new VideoFrame ( anamorphicFrame , { visibleRect : { x : 2 , y : 0 , width : 2 , height : 2 } } ) ;
240
+ let cropRightFrame = new VideoFrame (
241
+ anamorphicFrame , { visibleRect : { x : 2 , y : 0 , width : 2 , height : 2 } } ) ;
223
242
assert_equals ( cropRightFrame . codedWidth , anamorphicFrame . codedWidth ) ;
224
243
assert_equals ( cropRightFrame . codedHeight , anamorphicFrame . codedHeight ) ;
225
244
assert_equals ( cropRightFrame . visibleRect . x , 2 ) ;
@@ -246,7 +265,8 @@ test(t => {
246
265
] ) ;
247
266
let scaledFrame = new VideoFrame ( data , init ) ;
248
267
249
- let cropRightFrame = new VideoFrame ( scaledFrame , { visibleRect : { x : 2 , y : 0 , width : 2 , height : 2 } } ) ;
268
+ let cropRightFrame = new VideoFrame (
269
+ scaledFrame , { visibleRect : { x : 2 , y : 0 , width : 2 , height : 2 } } ) ;
250
270
assert_equals ( cropRightFrame . codedWidth , scaledFrame . codedWidth ) ;
251
271
assert_equals ( cropRightFrame . codedHeight , scaledFrame . codedHeight ) ;
252
272
assert_equals ( cropRightFrame . visibleRect . x , 2 ) ;
@@ -260,11 +280,12 @@ test(t => {
260
280
test ( t => {
261
281
let image = makeImageBitmap ( 32 , 16 ) ;
262
282
263
- let scaledFrame = new VideoFrame ( image ,
264
- { visibleRect : { x : 0 , y : 0 , width : 2 , height : 2 } ,
265
- displayWidth : 10 , displayHeight : 20 ,
266
- timestamp : 0
267
- } ) ;
283
+ let scaledFrame = new VideoFrame ( image , {
284
+ visibleRect : { x : 0 , y : 0 , width : 2 , height : 2 } ,
285
+ displayWidth : 10 ,
286
+ displayHeight : 20 ,
287
+ timestamp : 0
288
+ } ) ;
268
289
assert_equals ( scaledFrame . codedWidth , 32 ) ;
269
290
assert_equals ( scaledFrame . codedHeight , 16 ) ;
270
291
assert_equals ( scaledFrame . visibleRect . x , 0 ) ;
@@ -553,6 +574,30 @@ test(t => {
553
574
frame . close ( ) ;
554
575
} , 'Test we can construct a VideoFrame from an offscreen canvas.' ) ;
555
576
577
+ test ( t => {
578
+ let fmt = 'I420' ;
579
+ let vfInit = {
580
+ format : fmt ,
581
+ timestamp : 1234 ,
582
+ codedWidth : 4 ,
583
+ codedHeight : 2 ,
584
+ visibleRect : { x : 0 , y : 0 , width : 1 , height : 1 } ,
585
+ } ;
586
+ let data = new Uint8Array ( [
587
+ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , // y
588
+ 1 , 2 , // u
589
+ 1 , 2 , // v
590
+ 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , // a
591
+ ] ) ;
592
+ let frame = new VideoFrame ( data , vfInit ) ;
593
+ assert_equals ( frame . format , fmt , 'format' ) ;
594
+ assert_equals ( frame . visibleRect . x , 0 , 'visibleRect.x' ) ;
595
+ assert_equals ( frame . visibleRect . y , 0 , 'visibleRect.y' ) ;
596
+ assert_equals ( frame . visibleRect . width , 1 , 'visibleRect.width' ) ;
597
+ assert_equals ( frame . visibleRect . height , 1 , 'visibleRect.height' ) ;
598
+ frame . close ( ) ;
599
+ } , 'Test I420 VideoFrame with odd visible size' ) ;
600
+
556
601
test ( t => {
557
602
let fmt = 'I420A' ;
558
603
let vfInit = { format : fmt , timestamp : 1234 , codedWidth : 4 , codedHeight : 2 } ;
0 commit comments