183
183
return (gavl_video_scale_scanline_func)0;
186
static void get_offset_internal(gavl_pixelformat_t pixelformat,
188
int * advance, int * offset)
192
case GAVL_PIXELFORMAT_NONE:
267
case GAVL_YUVJ_420_P:
268
case GAVL_YUVJ_422_P:
269
case GAVL_YUVJ_444_P:
273
case GAVL_YUV_444_P_16:
274
case GAVL_YUV_422_P_16:
287
case GAVL_GRAY_FLOAT:
288
*advance = sizeof(float);
291
case GAVL_GRAYA_FLOAT:
292
*advance = 2 * sizeof(float);
297
*advance = 3 * sizeof(float);
300
case GAVL_RGBA_FLOAT:
301
case GAVL_YUVA_FLOAT:
302
*advance = 4 * sizeof(float);
308
186
static void get_minmax(gavl_pixelformat_t pixelformat,
309
187
int * min, int * max, float * min_f, float * max_f)
705
583
if(ctx->num_directions == 1)
707
get_offset_internal(src_format->pixelformat,
585
gavl_pixelformat_get_offset(src_format->pixelformat,
708
586
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
709
get_offset_internal(dst_format->pixelformat,
587
gavl_pixelformat_get_offset(dst_format->pixelformat,
710
588
plane, &ctx->offset1.dst_advance, &ctx->offset1.dst_offset);
712
590
/* We set this once here */
717
595
else if(ctx->num_directions == 2)
719
get_offset_internal(src_format->pixelformat,
597
gavl_pixelformat_get_offset(src_format->pixelformat,
720
598
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
721
get_offset_internal(dst_format->pixelformat,
599
gavl_pixelformat_get_offset(dst_format->pixelformat,
722
600
plane, &ctx->offset2.dst_advance, &ctx->offset2.dst_offset);
724
602
ctx->offset1.dst_offset = 0;
743
621
ctx->func1 = copy_scanline_noadvance;
745
623
/* Set source and destination offsets */
746
get_offset_internal(src_format->pixelformat,
624
gavl_pixelformat_get_offset(src_format->pixelformat,
747
625
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
748
get_offset_internal(dst_format->pixelformat,
626
gavl_pixelformat_get_offset(dst_format->pixelformat,
749
627
plane, &ctx->offset1.dst_advance, &ctx->offset1.dst_offset);
751
629
/* We set this once here */
780
658
if((tmp_opt.scale_mode == tmp_opt_y.scale_mode) &&
781
659
(tmp_opt.scale_order == tmp_opt_y.scale_order))
783
memset(&funcs, 0, sizeof(funcs));
784
661
gavl_init_scale_funcs(&funcs, &tmp_opt, ctx->offset1.src_advance,
785
ctx->offset2.dst_advance);
662
ctx->offset2.dst_advance, &(ctx->table_h), &(ctx->table_v));
786
663
ctx->func1 = get_func(&(funcs.funcs_xy), src_format->pixelformat, &bits_h);
787
664
// fprintf(stderr, "X AND Y %d\n");
790
667
if(ctx->func1) /* Scaling routines for x-y are there, good */
792
669
ctx->num_directions = 1;
794
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
672
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
795
673
/* Must be bits_h since we have only one function (and thus one accuracy) */
796
gavl_video_scale_table_init_int(&(ctx->table_v), bits_h);
674
gavl_video_scale_table_init_int(&(ctx->table_v), bits_h);
797
676
ctx->offset = &(ctx->offset1);
798
677
ctx->dst_size = ctx->dst_rect.w;
829
708
gavl_video_scale_table_shift_indices(&(ctx->table_v), -src_rect_i.y);
830
709
ctx->first_scanline = src_rect_i.y;
832
memset(&funcs, 0, sizeof(funcs));
833
gavl_init_scale_funcs(&funcs, &tmp_opt,
711
gavl_init_scale_funcs(&funcs, &tmp_opt,
834
712
ctx->offset1.src_advance,
835
ctx->offset1.dst_advance);
713
ctx->offset1.dst_advance,
714
&(ctx->table_h), NULL);
836
715
ctx->func1 = get_func(&funcs.funcs_x, src_format->pixelformat, &bits_h);
717
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
838
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
840
memset(&funcs, 0, sizeof(funcs));
841
719
gavl_init_scale_funcs(&funcs, &tmp_opt_y,
842
720
ctx->offset2.src_advance,
843
ctx->offset2.dst_advance);
721
ctx->offset2.dst_advance,
722
NULL, &(ctx->table_v));
844
723
ctx->func2 = get_func(&funcs.funcs_y,
845
724
src_format->pixelformat, &bits_v);
847
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
727
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
859
739
gavl_video_scale_table_shift_indices(&(ctx->table_h), -src_rect_i.x);
861
memset(&funcs, 0, sizeof(funcs));
862
741
gavl_init_scale_funcs(&funcs, &tmp_opt_y,
863
742
ctx->offset1.src_advance,
864
ctx->offset1.dst_advance);
743
ctx->offset1.dst_advance,
744
NULL, &(ctx->table_v));
865
745
ctx->func1 = get_func(&funcs.funcs_y, src_format->pixelformat, &bits_v);
867
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
748
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
869
memset(&funcs, 0, sizeof(funcs));
870
750
gavl_init_scale_funcs(&funcs, &tmp_opt,
871
751
ctx->offset2.src_advance,
872
ctx->offset2.dst_advance);
752
ctx->offset2.dst_advance,
753
&(ctx->table_h), NULL);
873
754
ctx->func2 = get_func(&(funcs.funcs_x),
874
755
src_format->pixelformat, &bits_h);
876
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
757
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
879
760
/* Allocate temporary buffer */
888
769
ctx->src_rect.w, ctx->dst_rect.w, src_width);
889
770
// fprintf(stderr, "Initializing x table done\n");
891
memset(&funcs, 0, sizeof(funcs));
892
772
gavl_init_scale_funcs(&funcs, &tmp_opt,
893
773
ctx->offset1.src_advance,
894
ctx->offset1.dst_advance);
774
ctx->offset1.dst_advance,
775
&(ctx->table_h), NULL);
895
776
ctx->func1 = get_func(&(funcs.funcs_x), src_format->pixelformat, &bits_h);
898
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
779
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
905
786
gavl_video_scale_table_init(&(ctx->table_v), &tmp_opt, offset_y,
906
787
ctx->src_rect.h, ctx->dst_rect.h, src_height);
907
788
// fprintf(stderr, "Initializing y table done\n");
908
memset(&funcs, 0, sizeof(funcs));
909
789
gavl_init_scale_funcs(&funcs, &tmp_opt,
910
790
ctx->offset1.src_advance,
911
ctx->offset1.dst_advance);
791
ctx->offset1.dst_advance,
792
NULL, &(ctx->table_v));
912
793
ctx->func1 = get_func(&(funcs.funcs_y), src_format->pixelformat, &bits_v);
914
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
796
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);
917
799
if(!ctx->func1 || ((ctx->num_directions == 2) && !ctx->func2))
928
810
fprintf(stderr, "Vertical table:\n");
929
811
gavl_video_scale_table_dump(&(ctx->table_v));
933
get_minmax(src_format->pixelformat, ctx->min_values_h, ctx->max_values_h, ctx->min_values_f, ctx->max_values_f);
934
get_minmax(src_format->pixelformat, ctx->min_values_v, ctx->max_values_v, ctx->min_values_f, ctx->max_values_f);
814
get_minmax(src_format->pixelformat, ctx->min_values_h,
815
ctx->max_values_h, ctx->min_values_f, ctx->max_values_f);
817
get_minmax(src_format->pixelformat, ctx->min_values_v,
818
ctx->max_values_v, ctx->min_values_f, ctx->max_values_f);
937
821
fprintf(stderr, "Min: %d %d %d, max: %d %d %d\n",
938
822
ctx->min_values_h[0],
1202
1086
if(ctx->num_directions == 1)
1204
get_offset_internal(format->pixelformat,
1088
gavl_pixelformat_get_offset(format->pixelformat,
1205
1089
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
1206
get_offset_internal(format->pixelformat,
1090
gavl_pixelformat_get_offset(format->pixelformat,
1207
1091
plane, &ctx->offset1.dst_advance, &ctx->offset1.dst_offset);
1209
1093
/* We set this once here */
1214
1098
else if(ctx->num_directions == 2)
1216
get_offset_internal(format->pixelformat,
1100
gavl_pixelformat_get_offset(format->pixelformat,
1217
1101
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
1219
get_offset_internal(format->pixelformat,
1103
gavl_pixelformat_get_offset(format->pixelformat,
1220
1104
plane, &ctx->offset2.dst_advance, &ctx->offset2.dst_offset);
1222
1106
ctx->offset1.dst_offset = 0;
1243
1127
ctx->func1 = copy_scanline_noadvance;
1245
1129
/* Set source and destination offsets */
1246
get_offset_internal(format->pixelformat,
1130
gavl_pixelformat_get_offset(format->pixelformat,
1247
1131
plane, &ctx->offset1.src_advance, &ctx->offset1.src_offset);
1248
get_offset_internal(format->pixelformat,
1132
gavl_pixelformat_get_offset(format->pixelformat,
1249
1133
plane, &ctx->offset1.dst_advance, &ctx->offset1.dst_offset);
1251
1135
/* We set this once here */
1283
1167
if((tmp_opt.scale_mode == tmp_opt_y.scale_mode) &&
1284
1168
(tmp_opt.scale_order == tmp_opt_y.scale_order))
1286
memset(&funcs, 0, sizeof(funcs));
1287
gavl_init_scale_funcs(&funcs, &tmp_opt,
1288
ctx->offset1.src_advance,
1289
ctx->offset2.dst_advance);
1170
gavl_init_scale_funcs(&funcs, &tmp_opt,
1171
ctx->offset1.src_advance,
1172
ctx->offset2.dst_advance,
1173
&(ctx->table_h), &(ctx->table_v));
1290
1174
ctx->func1 = get_func(&(funcs.funcs_xy), format->pixelformat, &bits_h);
1291
1175
// fprintf(stderr, "X AND Y\n");
1317
1201
gavl_video_scale_table_shift_indices(&(ctx->table_v),
1318
1202
-src_rect_i.y);
1319
memset(&funcs, 0, sizeof(funcs));
1320
gavl_init_scale_funcs(&funcs, &tmp_opt,
1321
ctx->offset1.src_advance,
1322
ctx->offset1.dst_advance);
1203
gavl_init_scale_funcs(&funcs, &tmp_opt,
1204
ctx->offset1.src_advance,
1205
ctx->offset1.dst_advance,
1206
&(ctx->table_h), NULL);
1323
1207
ctx->func1 = get_func(&funcs.funcs_x, format->pixelformat, &bits_h);
1325
1209
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
1327
memset(&funcs, 0, sizeof(funcs));
1328
gavl_init_scale_funcs(&funcs, &tmp_opt_y,
1211
gavl_init_scale_funcs(&funcs, &tmp_opt_y,
1329
1212
ctx->offset2.src_advance,
1330
ctx->offset2.dst_advance);
1213
ctx->offset2.dst_advance,
1214
NULL, &(ctx->table_v));
1331
1215
ctx->func2 = get_func(&funcs.funcs_y, format->pixelformat, &bits_v);
1348
1232
h_radius, h_coeffs,
1350
1234
// fprintf(stderr, "Initializing x table done\n");
1351
memset(&funcs, 0, sizeof(funcs));
1352
1235
gavl_init_scale_funcs(&funcs, &tmp_opt,
1353
1236
ctx->offset1.src_advance,
1354
ctx->offset1.dst_advance);
1237
ctx->offset1.dst_advance,
1238
&(ctx->table_h), NULL);
1355
1239
ctx->func1 = get_func(&(funcs.funcs_x), format->pixelformat, &bits_h);
1357
1241
gavl_video_scale_table_init_int(&(ctx->table_h), bits_h);
1369
1253
// fprintf(stderr, "Initializing y table done\n");
1370
memset(&funcs, 0, sizeof(funcs));
1371
1254
gavl_init_scale_funcs(&funcs, &tmp_opt,
1372
1255
ctx->offset1.src_advance,
1373
ctx->offset1.dst_advance);
1256
ctx->offset1.dst_advance,
1257
NULL, &(ctx->table_v));
1374
1258
ctx->func1 = get_func(&(funcs.funcs_y), format->pixelformat, &bits_v);
1376
1260
gavl_video_scale_table_init_int(&(ctx->table_v), bits_v);