@@ -48,8 +48,7 @@ static int fill_map(const AVPixFmtDescriptor *desc, uint8_t *map)
48
48
} else {
49
49
int had0 = 0 ;
50
50
unsigned depthb = 0 ;
51
- unsigned i ;
52
- for (i = 0 ; i < desc -> nb_components ; i ++ ) {
51
+ for (unsigned i = 0 ; i < desc -> nb_components ; i ++ ) {
53
52
/* all components must have same depth in bytes */
54
53
unsigned db = (desc -> comp [i ].depth + 7 ) / 8 ;
55
54
unsigned pos = desc -> comp [i ].offset / db ;
@@ -100,7 +99,7 @@ int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSp
100
99
const AVPixFmtDescriptor * desc = av_pix_fmt_desc_get (format );
101
100
const AVLumaCoefficients * luma = NULL ;
102
101
const AVComponentDescriptor * c ;
103
- unsigned i , nb_planes = 0 ;
102
+ unsigned nb_planes = 0 ;
104
103
int pixelstep [MAX_PLANES ] = { 0 };
105
104
int depthb = 0 ;
106
105
@@ -121,7 +120,7 @@ int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSp
121
120
? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG ;
122
121
if (range != AVCOL_RANGE_JPEG && range != AVCOL_RANGE_MPEG )
123
122
return AVERROR (EINVAL );
124
- for (i = 0 ; i < desc -> nb_components ; i ++ ) {
123
+ for (unsigned i = 0 ; i < desc -> nb_components ; i ++ ) {
125
124
int db ;
126
125
c = & desc -> comp [i ];
127
126
/* for now, only 8-16 bits formats */
@@ -172,7 +171,6 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
172
171
173
172
void ff_draw_color (FFDrawContext * draw , FFDrawColor * color , const uint8_t rgba [4 ])
174
173
{
175
- unsigned i ;
176
174
double yuvad [4 ];
177
175
double rgbad [4 ];
178
176
const AVPixFmtDescriptor * desc = draw -> desc ;
@@ -206,7 +204,7 @@ void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
206
204
if (desc -> nb_components <= 2 )
207
205
yuvad [1 ] = yuvad [3 ];
208
206
209
- for (i = 0 ; i < desc -> nb_components ; i ++ ) {
207
+ for (unsigned i = 0 ; i < desc -> nb_components ; i ++ ) {
210
208
unsigned val = yuvad [i ] * ((1 << (draw -> desc -> comp [i ].depth + draw -> desc -> comp [i ].shift )) - 1 ) + 0.5 ;
211
209
if (desc -> comp [i ].depth > 8 )
212
210
color -> comp [desc -> comp [i ].plane ].u16 [desc -> comp [i ].offset / 2 ] = val ;
@@ -229,15 +227,15 @@ void ff_copy_rectangle2(FFDrawContext *draw,
229
227
int dst_x , int dst_y , int src_x , int src_y ,
230
228
int w , int h )
231
229
{
232
- int plane , y , wp , hp ;
230
+ int wp , hp ;
233
231
uint8_t * p , * q ;
234
232
235
- for (plane = 0 ; plane < draw -> nb_planes ; plane ++ ) {
233
+ for (int plane = 0 ; plane < draw -> nb_planes ; plane ++ ) {
236
234
p = pointer_at (draw , src , src_linesize , plane , src_x , src_y );
237
235
q = pointer_at (draw , dst , dst_linesize , plane , dst_x , dst_y );
238
236
wp = AV_CEIL_RSHIFT (w , draw -> hsub [plane ]) * draw -> pixelstep [plane ];
239
237
hp = AV_CEIL_RSHIFT (h , draw -> vsub [plane ]);
240
- for (y = 0 ; y < hp ; y ++ ) {
238
+ for (int y = 0 ; y < hp ; y ++ ) {
241
239
memcpy (q , p , wp );
242
240
p += src_linesize [plane ];
243
241
q += dst_linesize [plane ];
@@ -249,11 +247,11 @@ void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color,
249
247
uint8_t * dst [], int dst_linesize [],
250
248
int dst_x , int dst_y , int w , int h )
251
249
{
252
- int plane , x , y , wp , hp ;
250
+ int wp , hp ;
253
251
uint8_t * p0 , * p ;
254
252
FFDrawColor color_tmp = * color ;
255
253
256
- for (plane = 0 ; plane < draw -> nb_planes ; plane ++ ) {
254
+ for (int plane = 0 ; plane < draw -> nb_planes ; plane ++ ) {
257
255
p0 = pointer_at (draw , dst , dst_linesize , plane , dst_x , dst_y );
258
256
wp = AV_CEIL_RSHIFT (w , draw -> hsub [plane ]);
259
257
hp = AV_CEIL_RSHIFT (h , draw -> vsub [plane ]);
@@ -262,19 +260,19 @@ void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color,
262
260
p = p0 ;
263
261
264
262
if (HAVE_BIGENDIAN && draw -> desc -> comp [0 ].depth > 8 ) {
265
- for (x = 0 ; 2 * x < draw -> pixelstep [plane ]; x ++ )
263
+ for (int x = 0 ; 2 * x < draw -> pixelstep [plane ]; x ++ )
266
264
color_tmp .comp [plane ].u16 [x ] = av_bswap16 (color_tmp .comp [plane ].u16 [x ]);
267
265
}
268
266
269
267
/* copy first line from color */
270
- for (x = 0 ; x < wp ; x ++ ) {
268
+ for (int x = 0 ; x < wp ; x ++ ) {
271
269
memcpy (p , color_tmp .comp [plane ].u8 , draw -> pixelstep [plane ]);
272
270
p += draw -> pixelstep [plane ];
273
271
}
274
272
wp *= draw -> pixelstep [plane ];
275
273
/* copy next lines from first line */
276
274
p = p0 + dst_linesize [plane ];
277
- for (y = 1 ; y < hp ; y ++ ) {
275
+ for (int y = 1 ; y < hp ; y ++ ) {
278
276
memcpy (p , p0 , wp );
279
277
p += dst_linesize [plane ];
280
278
}
@@ -325,14 +323,13 @@ static void blend_line(uint8_t *dst, unsigned src, unsigned alpha,
325
323
{
326
324
unsigned asrc = alpha * src ;
327
325
unsigned tau = 0x1010101 - alpha ;
328
- int x ;
329
326
330
327
if (left ) {
331
328
unsigned suba = (left * alpha ) >> hsub ;
332
329
* dst = (* dst * (0x1010101 - suba ) + src * suba ) >> 24 ;
333
330
dst += dx ;
334
331
}
335
- for (x = 0 ; x < w ; x ++ ) {
332
+ for (int x = 0 ; x < w ; x ++ ) {
336
333
* dst = (* dst * tau + asrc ) >> 24 ;
337
334
dst += dx ;
338
335
}
@@ -347,15 +344,14 @@ static void blend_line16(uint8_t *dst, unsigned src, unsigned alpha,
347
344
{
348
345
unsigned asrc = alpha * src ;
349
346
unsigned tau = 0x10001 - alpha ;
350
- int x ;
351
347
352
348
if (left ) {
353
349
unsigned suba = (left * alpha ) >> hsub ;
354
350
uint16_t value = AV_RL16 (dst );
355
351
AV_WL16 (dst , (value * (0x10001 - suba ) + src * suba ) >> 16 );
356
352
dst += dx ;
357
353
}
358
- for (x = 0 ; x < w ; x ++ ) {
354
+ for (int x = 0 ; x < w ; x ++ ) {
359
355
uint16_t value = AV_RL16 (dst );
360
356
AV_WL16 (dst , (value * tau + asrc ) >> 16 );
361
357
dst += dx ;
@@ -372,8 +368,8 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
372
368
int dst_w , int dst_h ,
373
369
int x0 , int y0 , int w , int h )
374
370
{
375
- unsigned alpha , nb_planes , nb_comp , plane , comp ;
376
- int w_sub , h_sub , x_sub , y_sub , left , right , top , bottom , y ;
371
+ unsigned alpha , nb_planes , nb_comp ;
372
+ int w_sub , h_sub , x_sub , y_sub , left , right , top , bottom ;
377
373
uint8_t * p0 , * p ;
378
374
379
375
nb_comp = draw -> desc -> nb_components -
@@ -393,15 +389,15 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
393
389
}
394
390
nb_planes = draw -> nb_planes - !!(draw -> desc -> flags & AV_PIX_FMT_FLAG_ALPHA && !(draw -> flags & FF_DRAW_PROCESS_ALPHA ));
395
391
nb_planes += !nb_planes ;
396
- for (plane = 0 ; plane < nb_planes ; plane ++ ) {
392
+ for (unsigned plane = 0 ; plane < nb_planes ; plane ++ ) {
397
393
p0 = pointer_at (draw , dst , dst_linesize , plane , x0 , y0 );
398
394
w_sub = w ;
399
395
h_sub = h ;
400
396
x_sub = x0 ;
401
397
y_sub = y0 ;
402
398
subsampling_bounds (draw -> hsub [plane ], & x_sub , & w_sub , & left , & right );
403
399
subsampling_bounds (draw -> vsub [plane ], & y_sub , & h_sub , & top , & bottom );
404
- for (comp = 0 ; comp < nb_comp ; comp ++ ) {
400
+ for (unsigned comp = 0 ; comp < nb_comp ; comp ++ ) {
405
401
const int depth = draw -> desc -> comp [comp ].depth ;
406
402
const int offset = draw -> desc -> comp [comp ].offset ;
407
403
const int index = offset / ((depth + 7 ) / 8 );
@@ -422,14 +418,14 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
422
418
p += dst_linesize [plane ];
423
419
}
424
420
if (depth <= 8 ) {
425
- for (y = 0 ; y < h_sub ; y ++ ) {
421
+ for (int y = 0 ; y < h_sub ; y ++ ) {
426
422
blend_line (p , color -> comp [plane ].u8 [index ], alpha ,
427
423
draw -> pixelstep [plane ], w_sub ,
428
424
draw -> hsub [plane ], left , right );
429
425
p += dst_linesize [plane ];
430
426
}
431
427
} else {
432
- for (y = 0 ; y < h_sub ; y ++ ) {
428
+ for (int y = 0 ; y < h_sub ; y ++ ) {
433
429
blend_line16 (p , color -> comp [plane ].u16 [index ], alpha ,
434
430
draw -> pixelstep [plane ], w_sub ,
435
431
draw -> hsub [plane ], left , right );
@@ -455,16 +451,16 @@ static void blend_pixel16(uint8_t *dst, unsigned src, unsigned alpha,
455
451
const uint8_t * mask , int mask_linesize , int l2depth ,
456
452
unsigned w , unsigned h , unsigned shift , unsigned xm0 )
457
453
{
458
- unsigned xm , x , y , t = 0 ;
454
+ unsigned t = 0 ;
459
455
unsigned xmshf = 3 - l2depth ;
460
456
unsigned xmmod = 7 >> l2depth ;
461
457
unsigned mbits = (1 << (1 << l2depth )) - 1 ;
462
458
unsigned mmult = 255 / mbits ;
463
459
uint16_t value = AV_RL16 (dst );
464
460
465
- for (y = 0 ; y < h ; y ++ ) {
466
- xm = xm0 ;
467
- for (x = 0 ; x < w ; x ++ ) {
461
+ for (unsigned y = 0 ; y < h ; y ++ ) {
462
+ unsigned xm = xm0 ;
463
+ for (unsigned x = 0 ; x < w ; x ++ ) {
468
464
t += ((mask [xm >> xmshf ] >> ((~xm & xmmod ) << l2depth )) & mbits )
469
465
* mmult ;
470
466
xm ++ ;
@@ -479,15 +475,15 @@ static void blend_pixel(uint8_t *dst, unsigned src, unsigned alpha,
479
475
const uint8_t * mask , int mask_linesize , int l2depth ,
480
476
unsigned w , unsigned h , unsigned shift , unsigned xm0 )
481
477
{
482
- unsigned xm , x , y , t = 0 ;
478
+ unsigned t = 0 ;
483
479
unsigned xmshf = 3 - l2depth ;
484
480
unsigned xmmod = 7 >> l2depth ;
485
481
unsigned mbits = (1 << (1 << l2depth )) - 1 ;
486
482
unsigned mmult = 255 / mbits ;
487
483
488
- for (y = 0 ; y < h ; y ++ ) {
489
- xm = xm0 ;
490
- for (x = 0 ; x < w ; x ++ ) {
484
+ for (unsigned y = 0 ; y < h ; y ++ ) {
485
+ unsigned xm = xm0 ;
486
+ for (unsigned x = 0 ; x < w ; x ++ ) {
491
487
t += ((mask [xm >> xmshf ] >> ((~xm & xmmod ) << l2depth )) & mbits )
492
488
* mmult ;
493
489
xm ++ ;
@@ -504,15 +500,14 @@ static void blend_line_hv16(uint8_t *dst, int dst_delta,
504
500
unsigned hsub , unsigned vsub ,
505
501
int xm , int left , int right , int hband )
506
502
{
507
- int x ;
508
503
509
504
if (left ) {
510
505
blend_pixel16 (dst , src , alpha , mask , mask_linesize , l2depth ,
511
506
left , hband , hsub + vsub , xm );
512
507
dst += dst_delta ;
513
508
xm += left ;
514
509
}
515
- for (x = 0 ; x < w ; x ++ ) {
510
+ for (int x = 0 ; x < w ; x ++ ) {
516
511
blend_pixel16 (dst , src , alpha , mask , mask_linesize , l2depth ,
517
512
1 << hsub , hband , hsub + vsub , xm );
518
513
dst += dst_delta ;
@@ -529,15 +524,14 @@ static void blend_line_hv(uint8_t *dst, int dst_delta,
529
524
unsigned hsub , unsigned vsub ,
530
525
int xm , int left , int right , int hband )
531
526
{
532
- int x ;
533
527
534
528
if (left ) {
535
529
blend_pixel (dst , src , alpha , mask , mask_linesize , l2depth ,
536
530
left , hband , hsub + vsub , xm );
537
531
dst += dst_delta ;
538
532
xm += left ;
539
533
}
540
- for (x = 0 ; x < w ; x ++ ) {
534
+ for (int x = 0 ; x < w ; x ++ ) {
541
535
blend_pixel (dst , src , alpha , mask , mask_linesize , l2depth ,
542
536
1 << hsub , hband , hsub + vsub , xm );
543
537
dst += dst_delta ;
@@ -553,9 +547,9 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
553
547
const uint8_t * mask , int mask_linesize , int mask_w , int mask_h ,
554
548
int l2depth , unsigned endianness , int x0 , int y0 )
555
549
{
556
- unsigned alpha , nb_planes , nb_comp , plane , comp ;
557
- int xm0 , ym0 , w_sub , h_sub , x_sub , y_sub , left , right , top , bottom , y ;
558
- uint8_t * p0 , * p ;
550
+ unsigned alpha , nb_planes , nb_comp ;
551
+ int xm0 , ym0 , w_sub , h_sub , x_sub , y_sub , left , right , top , bottom ;
552
+ uint8_t * p ;
559
553
const uint8_t * m ;
560
554
561
555
nb_comp = draw -> desc -> nb_components -
@@ -575,15 +569,15 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
575
569
}
576
570
nb_planes = draw -> nb_planes - !!(draw -> desc -> flags & AV_PIX_FMT_FLAG_ALPHA && !(draw -> flags & FF_DRAW_PROCESS_ALPHA ));
577
571
nb_planes += !nb_planes ;
578
- for (plane = 0 ; plane < nb_planes ; plane ++ ) {
579
- p0 = pointer_at (draw , dst , dst_linesize , plane , x0 , y0 );
572
+ for (unsigned plane = 0 ; plane < nb_planes ; plane ++ ) {
573
+ uint8_t * p0 = pointer_at (draw , dst , dst_linesize , plane , x0 , y0 );
580
574
w_sub = mask_w ;
581
575
h_sub = mask_h ;
582
576
x_sub = x0 ;
583
577
y_sub = y0 ;
584
578
subsampling_bounds (draw -> hsub [plane ], & x_sub , & w_sub , & left , & right );
585
579
subsampling_bounds (draw -> vsub [plane ], & y_sub , & h_sub , & top , & bottom );
586
- for (comp = 0 ; comp < nb_comp ; comp ++ ) {
580
+ for (unsigned comp = 0 ; comp < nb_comp ; comp ++ ) {
587
581
const int depth = draw -> desc -> comp [comp ].depth ;
588
582
const int offset = draw -> desc -> comp [comp ].offset ;
589
583
const int index = offset / ((depth + 7 ) / 8 );
@@ -610,7 +604,7 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
610
604
m += top * mask_linesize ;
611
605
}
612
606
if (depth <= 8 ) {
613
- for (y = 0 ; y < h_sub ; y ++ ) {
607
+ for (int y = 0 ; y < h_sub ; y ++ ) {
614
608
blend_line_hv (p , draw -> pixelstep [plane ],
615
609
color -> comp [plane ].u8 [index ], alpha ,
616
610
m , mask_linesize , l2depth , w_sub ,
@@ -620,7 +614,7 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
620
614
m += mask_linesize << draw -> vsub [plane ];
621
615
}
622
616
} else {
623
- for (y = 0 ; y < h_sub ; y ++ ) {
617
+ for (int y = 0 ; y < h_sub ; y ++ ) {
624
618
blend_line_hv16 (p , draw -> pixelstep [plane ],
625
619
color -> comp [plane ].u16 [index ], alpha ,
626
620
m , mask_linesize , l2depth , w_sub ,
@@ -663,12 +657,11 @@ int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir,
663
657
664
658
AVFilterFormats * ff_draw_supported_pixel_formats (unsigned flags )
665
659
{
666
- enum AVPixelFormat i ;
667
660
FFDrawContext draw ;
668
661
AVFilterFormats * fmts = NULL ;
669
662
int ret ;
670
663
671
- for (i = 0 ; av_pix_fmt_desc_get (i ); i ++ )
664
+ for (enum AVPixelFormat i = 0 ; av_pix_fmt_desc_get (i ); i ++ )
672
665
if (ff_draw_init (& draw , i , flags ) >= 0 &&
673
666
(ret = ff_add_format (& fmts , i )) < 0 )
674
667
return NULL ;
0 commit comments