gavl
gavl.h
Go to the documentation of this file.
1/*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2024 Members of the Gmerlin project
5 * http://github.com/bplaum
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * *****************************************************************/
20
21
22
27
28#ifndef GAVL_H_INCLUDED
29#define GAVL_H_INCLUDED
30
31#include <inttypes.h>
32
33#include <gavl/gavldefs.h>
34#include <gavl/gavltime.h>
35#include <gavl/timecode.h>
36#include <gavl/threadpool.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/* Forward declarations */
43
49
50typedef struct gavl_video_source_s gavl_video_source_t;
51
57
58typedef struct gavl_audio_source_s gavl_audio_source_t;
59
65
66typedef struct gavl_packet_source_s gavl_packet_source_t;
67
73
74typedef struct
75gavl_audio_sink_s gavl_audio_sink_t;
76
82
83typedef struct
84gavl_video_sink_s gavl_video_sink_t;
85
91
92typedef struct
93gavl_packet_sink_s gavl_packet_sink_t;
94
95typedef struct
96gavl_packet_s gavl_packet_t;
97
101
103
104typedef struct gavl_video_frame_s gavl_video_frame_t;
105
106/* Global handle for accessing a piece of hardware */
107typedef struct gavl_hw_context_s gavl_hw_context_t;
108
109
113
114
115
116/* Quality levels */
117
131
132
133
140
141#define GAVL_QUALITY_FASTEST 1
142
148
149#define GAVL_QUALITY_BEST 5
150
156
157#define GAVL_QUALITY_DEFAULT 2
158
169
170#define GAVL_ACCEL_MMX (1<<0)
171#define GAVL_ACCEL_MMXEXT (1<<1)
172#define GAVL_ACCEL_SSE (1<<2)
173#define GAVL_ACCEL_SSE2 (1<<3)
174#define GAVL_ACCEL_SSE3 (1<<4)
175#define GAVL_ACCEL_3DNOW (1<<5)
176#define GAVL_ACCEL_3DNOWEXT (1<<6)
177#define GAVL_ACCEL_SSSE3 (1<<7)
178#define GAVL_ACCEL_AVX (1<<8)
179#define GAVL_ACCEL_AVX2 (1<<9)
180#define GAVL_ACCEL_NEON (1<<10)
181
185
186GAVL_PUBLIC int gavl_accel_supported(void);
187
191
195
196/* Sample formats: all multibyte numbers are native endian */
197
203
204
210#define GAVL_MAX_CHANNELS 128
211
217
229
234
241
248
265
273
290
291
292/* Audio format -> string conversions */
293
300
301GAVL_PUBLIC
303
310
311GAVL_PUBLIC
313
321
322GAVL_PUBLIC
324
331
332GAVL_PUBLIC
334
335
340
341GAVL_PUBLIC
343
349
350GAVL_PUBLIC
352
359
360GAVL_PUBLIC
362
369
370GAVL_PUBLIC
372
379
380GAVL_PUBLIC
382
383
384
391
392GAVL_PUBLIC
394
401
402GAVL_PUBLIC
404
411
412GAVL_PUBLIC
414
420
421GAVL_PUBLIC
423
424GAVL_PUBLIC
425int gavl_audio_format_buffer_size(const gavl_audio_format_t * format);
426
427
439
440GAVL_PUBLIC
441void gavl_audio_format_dumpi(const gavl_audio_format_t * format, int indent);
442
450
451GAVL_PUBLIC
453
459
460GAVL_PUBLIC
462
468
469GAVL_PUBLIC
471
477
478GAVL_PUBLIC
480
486
487GAVL_PUBLIC
489
490
491
497
498GAVL_PUBLIC
500
507
508GAVL_PUBLIC
510 const gavl_audio_format_t * src);
511
519
520GAVL_PUBLIC
522 const gavl_audio_format_t * format_2);
523
534
535GAVL_PUBLIC
537
543
544GAVL_PUBLIC
546
556
557GAVL_PUBLIC
558int gavl_nearest_samplerate(int in_rate, const int * supported);
559
560
568
569
574
575typedef union
576 {
577 uint8_t * u_8;
578 int8_t * s_8;
579
580 uint16_t * u_16;
581 int16_t * s_16;
582
583 uint32_t * u_32;
584 int32_t * s_32;
585
586 float * f;
587 double * d;
589
594
595typedef union
596 {
599
602
605
608
610
626
627typedef struct
628 {
632 int64_t timestamp;
634
635 gavl_hw_context_t * hwctx;
636 void * storage;
637 int buf_idx;
639
650
651GAVL_PUBLIC
653
664
665GAVL_PUBLIC
667
676
677GAVL_PUBLIC
679
688
689GAVL_PUBLIC
691 const gavl_audio_format_t * format);
692
702
703GAVL_PUBLIC
705 const gavl_audio_format_t * format,
706 int num_samples);
707
708
709
719
720GAVL_PUBLIC
722 const gavl_audio_format_t * format,
723 int channel);
724
744
745GAVL_PUBLIC
747 gavl_audio_frame_t * dst,
748 const gavl_audio_frame_t * src,
749 int dst_pos,
750 int src_pos,
751 int dst_size,
752 int src_size);
753
765
766GAVL_PUBLIC
768 gavl_audio_frame_t * dst,
769 const gavl_audio_frame_t * src);
770
786
787
788GAVL_PUBLIC
790 gavl_audio_frame_t * src,
791 gavl_audio_frame_t * dst,
792 int start, int len);
793
804
805
806GAVL_PUBLIC
808 const gavl_audio_frame_t * f1,
809 const gavl_audio_frame_t * f2);
810
820
821
822GAVL_PUBLIC
824 const gavl_audio_frame_t * f);
825
826
836
837GAVL_PUBLIC
839 const gavl_audio_format_t * format,
840 uint8_t * data);
849
850GAVL_PUBLIC
852 const gavl_audio_format_t * format,
853 uint8_t * data, int len);
854
855
856GAVL_PUBLIC
857void gavl_audio_frame_to_packet_metadata(const gavl_audio_frame_t * frame,
858 gavl_packet_t * pkt);
859
860GAVL_PUBLIC
861void gavl_packet_to_audio_frame_metadata(const gavl_packet_t * p, gavl_audio_frame_t * frame);
862
863GAVL_PUBLIC
864void gavl_audio_frame_set_from_packet(gavl_audio_frame_t * frame,
865 const gavl_audio_format_t * format,
866 gavl_packet_t * p);
867
868
869
886
887
888GAVL_PUBLIC
890 gavl_audio_frame_t * f, int num_samples);
891
892
911
912GAVL_PUBLIC
914 const gavl_audio_frame_t * frame,
915 const char * name_base);
916
917
922
928
931
932#define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
933
936
937#define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
938
941
942#define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
943
946
947#define GAVL_AUDIO_FRONT_TO_REAR_MASK \
948(GAVL_AUDIO_FRONT_TO_REAR_COPY | \
949GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
950 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
951
952/* Options for mixing stereo to mono */
953
956#define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
959#define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
962#define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
963
966#define GAVL_AUDIO_STEREO_TO_MONO_MASK \
967(GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
968GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
969GAVL_AUDIO_STEREO_TO_MONO_MIX)
970
973
974#define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
975
976
980
981typedef enum
982 {
983 GAVL_AUDIO_DITHER_NONE = 0,
984 GAVL_AUDIO_DITHER_AUTO = 1,
985 GAVL_AUDIO_DITHER_RECT = 2,
986 GAVL_AUDIO_DITHER_TRI = 3,
987 GAVL_AUDIO_DITHER_SHAPED = 4,
989
993
1003
1009
1010typedef struct gavl_audio_options_s gavl_audio_options_t;
1011
1017
1018GAVL_PUBLIC
1020
1026
1027GAVL_PUBLIC
1029
1035
1036GAVL_PUBLIC
1038
1044
1045GAVL_PUBLIC
1048
1049
1055
1056GAVL_PUBLIC
1058
1064
1065GAVL_PUBLIC
1068
1074
1075GAVL_PUBLIC
1077 int flags);
1078
1084
1085GAVL_PUBLIC
1087
1092
1093GAVL_PUBLIC
1095
1111
1112GAVL_PUBLIC
1114 const double ** matrix);
1115
1123
1124GAVL_PUBLIC
1125const double **
1127
1136
1137GAVL_PUBLIC
1139
1145
1146GAVL_PUBLIC
1148 const gavl_audio_options_t * src);
1149
1154
1155GAVL_PUBLIC
1157
1158
1159
1160/* Audio converter */
1161
1188
1194
1195typedef struct gavl_audio_converter_s gavl_audio_converter_t;
1196
1201
1202GAVL_PUBLIC
1204
1209
1210GAVL_PUBLIC
1212
1220
1221GAVL_PUBLIC
1223
1224
1238
1239GAVL_PUBLIC
1241 const gavl_audio_format_t * input_format,
1242 const gavl_audio_format_t * output_format);
1243
1257
1258GAVL_PUBLIC
1260 const gavl_audio_format_t * format);
1261
1274
1275
1276GAVL_PUBLIC
1278
1279
1292
1293GAVL_PUBLIC
1295 const gavl_audio_frame_t * input_frame,
1296 gavl_audio_frame_t * output_frame);
1297
1298
1316
1317GAVL_PUBLIC
1319 double ratio ) ;
1320
1321
1336
1337GAVL_PUBLIC
1339 gavl_audio_frame_t * input_frame,
1340 gavl_audio_frame_t * output_frame,
1341 double ratio);
1342
1343
1350
1356
1357typedef struct gavl_volume_control_s gavl_volume_control_t;
1358
1359/* Create / destroy */
1360
1365
1366GAVL_PUBLIC
1368
1373
1374GAVL_PUBLIC
1376
1383
1384GAVL_PUBLIC
1386 const gavl_audio_format_t * format);
1387
1393
1394GAVL_PUBLIC
1396 float volume);
1397
1403
1404GAVL_PUBLIC
1406 gavl_audio_frame_t * frame);
1407
1415
1416GAVL_PUBLIC
1417int gavl_volume_to_int(float volume, float one, int steps);
1418
1426
1427GAVL_PUBLIC
1428float gavl_volume_to_float(int volume, float one, int steps);
1429
1434
1438
1439#define GAVL_MAX_PLANES 4
1440#define GAVL_MAX_COLOR_CHANNELS 4
1441
1447
1451
1452typedef struct
1453 {
1454 int32_t x;
1455 int32_t y;
1456 int32_t w;
1457 int32_t h;
1459
1463
1464typedef struct
1465 {
1466 double x;
1467 double y;
1468 double w;
1469 double h;
1471
1472GAVL_PUBLIC
1473void gavl_rectangle_i_init(gavl_rectangle_i_t * r);
1474
1475GAVL_PUBLIC
1476void gavl_rectangle_f_init(gavl_rectangle_f_t * r);
1477
1478
1484
1485GAVL_PUBLIC
1487 const gavl_video_format_t * format);
1488
1494
1495GAVL_PUBLIC
1497 const gavl_video_format_t * format);
1498
1512
1513GAVL_PUBLIC
1515 gavl_rectangle_i_t * dst_rect,
1516 const gavl_video_format_t * src_format,
1517 const gavl_video_format_t * dst_format);
1518
1529
1530GAVL_PUBLIC
1532 gavl_rectangle_i_t * dst_rect,
1533 const gavl_video_format_t * src_format,
1534 const gavl_video_format_t * dst_format);
1535
1536GAVL_PUBLIC
1537void gavl_rectangle_crop_to_format_scale_f(gavl_rectangle_f_t * src_rect,
1538 gavl_rectangle_f_t * dst_rect,
1539 const gavl_video_format_t * src_format,
1540 const gavl_video_format_t * dst_format);
1541
1547
1548GAVL_PUBLIC
1550
1556
1557GAVL_PUBLIC
1559
1565
1566GAVL_PUBLIC
1568
1574
1575GAVL_PUBLIC
1577
1583
1584GAVL_PUBLIC
1586
1592
1593GAVL_PUBLIC
1595
1601
1602GAVL_PUBLIC
1604
1610
1611GAVL_PUBLIC
1613
1619
1620GAVL_PUBLIC
1622
1628
1629GAVL_PUBLIC
1631
1644
1645GAVL_PUBLIC
1646void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
1647
1656
1657GAVL_PUBLIC
1659 const gavl_video_format_t * format);
1660
1661
1667
1668GAVL_PUBLIC
1670
1676
1677GAVL_PUBLIC
1679
1680
1681
1687
1688GAVL_PUBLIC
1690
1696
1697GAVL_PUBLIC
1699
1707
1708GAVL_PUBLIC
1710
1718
1719GAVL_PUBLIC
1721
1748
1749GAVL_PUBLIC
1751 const gavl_video_format_t * src_format,
1752 const gavl_rectangle_f_t * src_rect,
1753 const gavl_video_format_t * dst_format,
1754 float zoom, float squeeze);
1755
1756GAVL_PUBLIC
1757void gavl_rectangle_fit_aspect_f(gavl_rectangle_f_t * r,
1758 const gavl_video_format_t * src_format,
1759 const gavl_rectangle_f_t * src_rect,
1760 const gavl_video_format_t * dst_format,
1761 float zoom, float squeeze, int do_orient);
1762
1763
1768GAVL_PUBLIC
1770
1775GAVL_PUBLIC
1777
1778
1784
1788#define GAVL_PIXFMT_PLANAR (1<<8)
1789
1793#define GAVL_PIXFMT_RGB (1<<9)
1794
1798#define GAVL_PIXFMT_YUV (1<<10)
1799
1803#define GAVL_PIXFMT_YUVJ (1<<11)
1804
1808#define GAVL_PIXFMT_ALPHA (1<<12)
1809
1813#define GAVL_PIXFMT_GRAY (1<<13)
1814
1818
1820 {
1824
1828
1832
1836
1840
1844
1848
1880
1887
1894
1902
1905
1910
1914
1917
1931
1941
1948
1949 };
1950
1954
1956
1959#define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
1962#define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
1965#define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
1968#define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
1969
1972#define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
1975#define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
1978#define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
1981#define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
1982
1985#define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
1988#define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
1991#define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
1994#define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
1995
2001
2013
2014/*
2015 * Colormodel related functions
2016 */
2017
2023
2024#define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
2025
2026
2032
2033#define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
2034
2040
2041#define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
2042
2048
2049#define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
2050
2056
2057#define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
2058
2064
2065#define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
2066
2067
2073
2074GAVL_PUBLIC
2076
2083
2084GAVL_PUBLIC gavl_color_channel_t
2086
2087
2093
2094GAVL_PUBLIC
2096
2105
2106GAVL_PUBLIC
2107void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
2108
2114
2115GAVL_PUBLIC
2117
2123
2124GAVL_PUBLIC
2126
2132
2133GAVL_PUBLIC
2135
2149
2150GAVL_PUBLIC
2152 gavl_pixelformat_t dst);
2153
2166
2167GAVL_PUBLIC gavl_pixelformat_t
2169 const gavl_pixelformat_t * dst_supported,
2170 int * penalty);
2171
2172
2173
2179
2180GAVL_PUBLIC
2182
2191
2192GAVL_PUBLIC
2194
2195
2201
2202GAVL_PUBLIC
2204
2210
2211GAVL_PUBLIC
2213
2219
2220GAVL_PUBLIC
2222
2223
2224
2229
2230GAVL_PUBLIC
2232
2238
2239GAVL_PUBLIC
2241
2242/* */
2243
2251
2258
2264
2265GAVL_PUBLIC
2267
2273
2274GAVL_PUBLIC
2276
2282
2283GAVL_PUBLIC
2285
2286
2290
2291/* Changing the values alters the gmerlin-avdecoder index format */
2292
2300
2306
2307GAVL_PUBLIC
2309
2315
2316GAVL_PUBLIC
2318
2324
2325GAVL_PUBLIC
2327
2331
2332/* Changing the values alters the gmerlin-avdecoder index format */
2333
2344
2350
2351GAVL_PUBLIC
2353
2359
2360GAVL_PUBLIC
2362
2368
2369GAVL_PUBLIC
2371
2379
2380GAVL_PUBLIC
2382
2383
2384/* Video format structure */
2385
2386#define GAVL_IMAGE_ORIENT_FLIP_H (1<<2)
2387
2388typedef enum
2389 {
2390
2391 GAVL_IMAGE_ORIENT_NORMAL = 0, // EXIF: 1
2392 GAVL_IMAGE_ORIENT_ROT90_CW = 1, // EXIF: 8
2393 GAVL_IMAGE_ORIENT_ROT180_CW = 2, // EXIF: 3
2394 GAVL_IMAGE_ORIENT_ROT270_CW = 3, // EXIF: 6
2395
2396 GAVL_IMAGE_ORIENT_FH = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_NORMAL), // EXIF: 2
2397 GAVL_IMAGE_ORIENT_FH_ROT90_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT90_CW), // EXIF: 7
2398 GAVL_IMAGE_ORIENT_FH_ROT180_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT180_CW), // EXIF: 4
2399 GAVL_IMAGE_ORIENT_FH_ROT270_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT270_CW), // EXIF: 5
2400
2401 } gavl_image_orientation_t;
2402
2406
2408 {
2409 uint32_t frame_width;
2411
2412 uint32_t image_width;
2414
2415 /* Support for nonsquare pixels */
2416
2417 uint32_t pixel_width;
2419
2421
2424 uint32_t timescale;
2425
2428
2430
2432
2433 gavl_hw_context_t * hwctx;
2434
2435 gavl_image_orientation_t orientation;
2436
2437 int shuffle_indices[GAVL_MAX_COLOR_CHANNELS];
2438
2439 };
2440
2447
2448GAVL_PUBLIC
2450 const gavl_video_format_t * src);
2451
2459
2460GAVL_PUBLIC
2462 const gavl_video_format_t * format_2);
2463
2464
2474
2475GAVL_PUBLIC
2476void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
2477 float * off_x, float * off_y);
2478
2479
2480
2492
2493GAVL_PUBLIC
2495 const gavl_video_format_t * src);
2496
2503
2504GAVL_PUBLIC
2506
2507GAVL_PUBLIC
2508void gavl_video_format_get_frame_layout(const gavl_video_format_t * format,
2509 int * offsets,
2510 int * strides,
2511 int * buffersizes,
2512 int multiplane);
2513
2514
2530
2531GAVL_PUBLIC
2533 int pad_h, int pad_v);
2534
2535
2550
2551GAVL_PUBLIC
2553 gavl_video_format_t * channel_format,
2555
2556
2569
2570GAVL_PUBLIC
2572 gavl_video_format_t * field_format,
2573 int field);
2574
2575
2581
2582GAVL_PUBLIC
2584
2596
2597GAVL_PUBLIC
2598void gavl_video_format_dumpi(const gavl_video_format_t * format, int indent);
2599
2600/* Color channels have a nonstandard order, a separate unshuffle step will be
2601 added unless gavl_video_source_support_shuffle is called */
2602GAVL_PUBLIC
2603int gavl_video_format_has_shuffle(const gavl_video_format_t * format);
2604
2605
2606GAVL_PUBLIC
2607void gavl_video_format_normalize_orientation(gavl_video_format_t * in_format,
2608 gavl_video_format_t * out_format);
2609
2610
2611GAVL_PUBLIC const char *
2612gavl_image_orientation_to_string(gavl_image_orientation_t orient);
2613
2614GAVL_PUBLIC int
2615gavl_image_orientation_is_transposed(gavl_image_orientation_t orient);
2616
2617
2635
2639
2641 {
2644
2646 int64_t timestamp;
2647 int64_t duration;
2650
2651 int dummy; // !< Used to be reference count. Was renamed to keep ABI compatibility
2652
2654 int32_t dst_x;
2655 int32_t dst_y;
2656
2657 gavl_hw_context_t * hwctx;
2658 void * storage;
2659
2660 int buf_idx;
2661 };
2662
2663
2674
2675GAVL_PUBLIC
2676gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t * format);
2677
2687
2688GAVL_PUBLIC
2689gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
2690
2691
2692
2701
2702GAVL_PUBLIC
2703void gavl_video_frame_destroy(gavl_video_frame_t*frame);
2704
2715
2716GAVL_PUBLIC
2717void gavl_video_frame_null(gavl_video_frame_t*frame);
2718
2726
2727GAVL_PUBLIC
2728void gavl_video_frame_clear(gavl_video_frame_t * frame,
2729 const gavl_video_format_t * format);
2730
2739
2740GAVL_PUBLIC
2741void gavl_video_frame_fill(gavl_video_frame_t * frame,
2742 const gavl_video_format_t * format,
2743 const float * color);
2744
2756
2757GAVL_PUBLIC
2758void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
2759 const gavl_video_frame_t * src1,
2760 const gavl_video_frame_t * src2,
2761 const gavl_video_format_t * format);
2762
2774
2775GAVL_PUBLIC
2776void gavl_video_frame_psnr(double * psnr,
2777 const gavl_video_frame_t * src1,
2778 const gavl_video_frame_t * src2,
2779 const gavl_video_format_t * format);
2780
2806
2807GAVL_PUBLIC
2808int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
2809 const gavl_video_frame_t * src2,
2810 gavl_video_frame_t * dst,
2811 const gavl_video_format_t * format);
2812
2825
2826GAVL_PUBLIC
2828 gavl_video_frame_t * dst,
2829 const gavl_video_frame_t * src);
2830
2842
2843GAVL_PUBLIC
2845 gavl_video_frame_t * dst,
2846 const gavl_video_frame_t * src, int plane);
2847
2858
2859GAVL_PUBLIC
2861 gavl_video_frame_t * dst,
2862 const gavl_video_frame_t * src);
2863
2874
2875GAVL_PUBLIC
2877 gavl_video_frame_t * dst,
2878 const gavl_video_frame_t * src);
2879
2890
2891GAVL_PUBLIC
2893 gavl_video_frame_t * dst,
2894 const gavl_video_frame_t * src);
2895
2907
2908GAVL_PUBLIC
2909void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
2910 const gavl_video_frame_t * src);
2911
2912
2929
2930GAVL_PUBLIC
2932 const gavl_video_frame_t * src,
2933 gavl_video_frame_t * dst,
2934 const gavl_rectangle_i_t * src_rect);
2935
2950
2951GAVL_PUBLIC
2953 const gavl_video_frame_t * src,
2954 gavl_video_frame_t * dst,
2955 int field);
2956
2957
2958
2970
2971GAVL_PUBLIC
2972void gavl_video_frame_dump(gavl_video_frame_t * frame,
2973 const gavl_video_format_t * format,
2974 const char * namebase);
2975
2985
2986GAVL_PUBLIC
2988 const gavl_video_frame_t * frame);
2989
2999
3000GAVL_PUBLIC
3001void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
3002 const gavl_video_format_t * format);
3003
3014
3015
3016GAVL_PUBLIC
3017void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
3018 const gavl_video_format_t * format,
3019 uint8_t * buffer);
3020
3031
3032GAVL_PUBLIC
3034 const gavl_video_frame_t * frame);
3035
3036
3050
3051GAVL_PUBLIC
3054 const gavl_video_frame_t * src,
3055 gavl_video_frame_t * dst);
3056
3070
3071
3072GAVL_PUBLIC
3075 const gavl_video_frame_t * src,
3076 gavl_video_frame_t * dst);
3077
3078
3089
3090GAVL_PUBLIC
3092 const gavl_video_frame_t * f1,
3093 const gavl_video_frame_t * f2);
3094
3095GAVL_PUBLIC
3096void gavl_video_frame_normalize_orientation(const gavl_video_format_t * in_format,
3097 const gavl_video_format_t * out_format,
3098 const gavl_video_frame_t * in_frame,
3099 gavl_video_frame_t * out_frame);
3100
3101GAVL_PUBLIC
3102void gavl_video_frame_to_packet_metadata(const gavl_video_frame_t * frame,
3103 gavl_packet_t * pkt);
3104
3105GAVL_PUBLIC
3106void gavl_packet_to_video_frame_metadata(const gavl_packet_t * p, gavl_video_frame_t * frame);
3107
3108GAVL_PUBLIC
3109void gavl_video_frame_set_from_packet(gavl_video_frame_t * frame,
3110 const gavl_video_format_t * format,
3111 gavl_packet_t * p);
3112
3113/*****************************
3114 Conversion options
3115******************************/
3116
3120
3124
3131
3132#define GAVL_FORCE_DEINTERLACE (1<<0)
3133
3137
3138#define GAVL_CONVOLVE_CHROMA (1<<1)
3139
3143
3144#define GAVL_CONVOLVE_NORMALIZE (1<<2)
3145
3152
3153#define GAVL_RESAMPLE_CHROMA (1<<3)
3154
3160
3161#define GAVL_FORCE_SW (1<<4)
3162
3169
3175
3181
3189
3195
3201
3205
3218
3227
3235
3241
3242typedef struct gavl_video_options_s gavl_video_options_t;
3243
3244/* Default Options */
3245
3250
3251GAVL_PUBLIC
3253
3262
3263GAVL_PUBLIC
3265
3271
3272GAVL_PUBLIC
3274 const gavl_video_options_t * src);
3275
3280
3281GAVL_PUBLIC
3283
3284
3298
3299GAVL_PUBLIC
3301 const gavl_rectangle_f_t * src_rect,
3302 const gavl_rectangle_i_t * dst_rect);
3303
3310
3311GAVL_PUBLIC
3313 gavl_rectangle_f_t * src_rect,
3314 gavl_rectangle_i_t * dst_rect);
3315
3321
3322GAVL_PUBLIC
3324
3330
3331GAVL_PUBLIC
3333
3334
3340
3341GAVL_PUBLIC
3343 int conversion_flags);
3344
3350
3351GAVL_PUBLIC
3353
3359
3360GAVL_PUBLIC
3362 gavl_alpha_mode_t alpha_mode);
3363
3369
3370GAVL_PUBLIC gavl_alpha_mode_t
3372
3373
3379
3380GAVL_PUBLIC
3382 gavl_scale_mode_t scale_mode);
3383
3389
3390GAVL_PUBLIC gavl_scale_mode_t
3392
3393
3399
3400GAVL_PUBLIC
3402 int order);
3403
3409
3410GAVL_PUBLIC
3412
3413
3419
3420GAVL_PUBLIC
3422 const double * color);
3423
3429
3430GAVL_PUBLIC
3432 double * color);
3433
3439
3440GAVL_PUBLIC
3442 gavl_deinterlace_mode_t deinterlace_mode);
3443
3449
3450GAVL_PUBLIC gavl_deinterlace_mode_t
3452
3458
3459GAVL_PUBLIC
3461 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
3462
3468
3471
3479
3480GAVL_PUBLIC
3483
3484
3492
3493GAVL_PUBLIC gavl_downscale_filter_t
3495
3512
3513GAVL_PUBLIC
3515 float f);
3516
3524
3525GAVL_PUBLIC
3527
3528/* Set an externally created thread pool. If this is not called, a private thread pool will be created if needed.
3529 This function has the advantage that one thread pool can be shared among different elements of a video
3530 pipeline, which will reduce the overhead */
3531
3532GAVL_PUBLIC
3533void gavl_video_options_set_thread_pool(gavl_video_options_t * opt, gavl_thread_pool_t * tp);
3534
3535GAVL_PUBLIC
3536gavl_thread_pool_t * gavl_video_options_get_thread_pool(const gavl_video_options_t * opt);
3537
3538/***************************************************
3539 * Create and destroy video converters
3540 ***************************************************/
3541
3567
3573
3574typedef struct gavl_video_converter_s gavl_video_converter_t;
3575
3580
3581GAVL_PUBLIC
3583
3588
3589GAVL_PUBLIC
3591
3592/**************************************************
3593 * Get options. Change the options with the gavl_video_options_set_*
3594 * functions above
3595 **************************************************/
3596
3604
3605GAVL_PUBLIC gavl_video_options_t *
3607
3608
3621
3622GAVL_PUBLIC
3624 const gavl_video_format_t * input_format,
3625 const gavl_video_format_t * output_format);
3626
3638
3639GAVL_PUBLIC
3641
3642
3643/***************************************************
3644 * Convert a frame
3645 ***************************************************/
3646
3653
3654GAVL_PUBLIC
3656 const gavl_video_frame_t * input_frame,
3657 gavl_video_frame_t * output_frame);
3658
3659
3684
3690
3691typedef struct gavl_video_scaler_s gavl_video_scaler_t;
3692
3697
3698GAVL_PUBLIC
3700
3705
3706GAVL_PUBLIC
3708
3716
3717GAVL_PUBLIC gavl_video_options_t *
3719
3730
3731
3732GAVL_PUBLIC
3734 const gavl_video_format_t * src_format,
3735 const gavl_video_format_t * dst_format);
3736
3756
3757
3758GAVL_PUBLIC
3760 const gavl_video_format_t * format,
3761 int h_radius, const float * h_coeffs,
3762 int v_radius, const float * v_coeffs);
3763
3770
3771GAVL_PUBLIC
3773 const gavl_video_frame_t * input_frame,
3774 gavl_video_frame_t * output_frame);
3775
3783
3789
3790
3791typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
3792
3797
3798GAVL_PUBLIC
3800
3805
3806GAVL_PUBLIC
3808
3816
3817GAVL_PUBLIC gavl_video_options_t *
3819
3829
3830GAVL_PUBLIC
3832 const gavl_video_format_t * src_format);
3833
3834
3841
3842GAVL_PUBLIC
3844 const gavl_video_frame_t * input_frame,
3845 gavl_video_frame_t * output_frame);
3846
3847
3848
3849/**************************************************
3850 * Transparent overlays
3851 **************************************************/
3852
3853/* Overlay struct */
3854
3874
3881
3882typedef gavl_video_frame_t gavl_overlay_t;
3883
3889
3890typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
3891
3896
3897GAVL_PUBLIC
3899
3904
3905GAVL_PUBLIC
3907
3913
3914GAVL_PUBLIC gavl_video_options_t *
3916
3931
3932GAVL_PUBLIC
3934 const gavl_video_format_t * frame_format,
3935 gavl_video_format_t * overlay_format);
3936
3945
3946GAVL_PUBLIC
3948 gavl_overlay_t * ovl);
3949
3955
3956GAVL_PUBLIC
3958 gavl_video_frame_t * dst_frame);
3959
3965
3966GAVL_PUBLIC gavl_video_sink_t *
3968
3984
3989
3990typedef struct gavl_image_transform_s gavl_image_transform_t;
3991
4004
4005typedef void (*gavl_image_transform_func)(void * priv,
4006 double xdst,
4007 double ydst,
4008 double * xsrc,
4009 double * ysrc);
4010
4011
4017
4018GAVL_PUBLIC
4020
4025
4026GAVL_PUBLIC
4028
4045
4046
4047GAVL_PUBLIC
4049 gavl_video_format_t * format,
4050 gavl_image_transform_func func, void * priv);
4051
4058
4059GAVL_PUBLIC
4061 gavl_video_frame_t * in_frame,
4062 gavl_video_frame_t * out_frame);
4063
4073
4074GAVL_PUBLIC gavl_video_options_t *
4076
4080
4093
4098
4099typedef struct
4100 {
4101 int64_t offset;
4102 /* Primary */
4103 int64_t num_entries;
4105
4106 struct
4107 {
4108 int64_t num_frames;
4109 int64_t duration;
4110 } * entries;
4111
4114
4115 struct
4116 {
4117 int64_t pts;
4119 } * timecodes;
4120
4121 /* Secondary */
4122
4124
4131
4141
4142GAVL_PUBLIC gavl_frame_table_t *
4143gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
4144 gavl_timecode_format_t * fmt_ret);
4145
4155
4156GAVL_PUBLIC gavl_frame_table_t *
4157gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
4158 int64_t num_frames,
4159 gavl_timecode_t start_timecode);
4160
4167
4168GAVL_PUBLIC gavl_frame_table_t *
4170
4171
4172
4178
4180
4187
4188GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
4189
4197
4198GAVL_PUBLIC void
4200 int64_t pts, gavl_timecode_t tc);
4201
4211
4212GAVL_PUBLIC int64_t
4214 int64_t frame, int * duration);
4215
4225
4226GAVL_PUBLIC int64_t
4228 int64_t time,
4229 int64_t * start_time);
4230
4240
4241GAVL_PUBLIC gavl_timecode_t
4243 int64_t time,
4244 int64_t * start_time,
4245 const gavl_timecode_format_t * fmt);
4246
4255
4256GAVL_PUBLIC int64_t
4258 gavl_timecode_t tc,
4259 const gavl_timecode_format_t * fmt);
4260
4261
4271
4272GAVL_PUBLIC gavl_timecode_t
4274 int64_t frame,
4275 int64_t * start_time,
4276 const gavl_timecode_format_t * fmt);
4277
4278
4279
4286
4287GAVL_PUBLIC int64_t
4289
4296
4297GAVL_PUBLIC int64_t
4299
4306
4307GAVL_PUBLIC int64_t
4309
4317
4318GAVL_PUBLIC
4320 const char * filename);
4321
4328
4329GAVL_PUBLIC
4331
4337
4338GAVL_PUBLIC void
4340
4344
4345
4346/* Debayer routines */
4347
4348#define GAVL_BAYER_GREEN_FIRST (1<<0)
4349#define GAVL_BAYER_BLUE_LINE (1<<1)
4350
4351// GB
4352// RG
4353#define GAVL_BAYER_GBRG (GAVL_BAYER_GREEN_FIRST|GAVL_BAYER_BLUE_LINE)
4354
4355// GR
4356// BG
4357#define GAVL_BAYER_GRBG (GAVL_BAYER_GREEN_FIRST)
4358
4359// BG
4360// GR
4361#define GAVL_BAYER_BGGR (GAVL_BAYER_BLUE_LINE)
4362
4363// RG
4364// GB
4365#define GAVL_BAYER_RGGB 0
4366
4367GAVL_PUBLIC
4368void gavl_video_frame_debayer(gavl_video_options_t * opt,
4369 gavl_video_frame_t * src, gavl_video_frame_t * dst,
4370 int bayer_format, gavl_video_format_t * dst_format);
4371
4372
4376
4377
4378#ifdef __cplusplus
4379}
4380#endif
4381
4382#endif /* GAVL_H_INCLUDED */
GAVL_PUBLIC gavl_deinterlace_mode_t gavl_video_options_get_deinterlace_mode(const gavl_video_options_t *opt)
Get the deinterlace mode.
#define GAVL_MAX_COLOR_CHANNELS
Definition gavl.h:1440
GAVL_PUBLIC void gavl_video_options_set_deinterlace_mode(gavl_video_options_t *opt, gavl_deinterlace_mode_t deinterlace_mode)
Set the deinterlace mode.
GAVL_PUBLIC int gavl_accel_supported(void)
Get the supported acceleration flags.
GAVL_PUBLIC gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t *cnv)
gets options of an audio converter
GAVL_PUBLIC void gavl_audio_converter_resample(gavl_audio_converter_t *cnv, gavl_audio_frame_t *input_frame, gavl_audio_frame_t *output_frame, double ratio)
Convert audio.
GAVL_PUBLIC void gavl_audio_converter_destroy(gavl_audio_converter_t *cnv)
Destroys an audio converter and frees all associated memory.
struct gavl_audio_converter_s gavl_audio_converter_t
Opaque audio converter structure.
Definition gavl.h:1195
GAVL_PUBLIC gavl_audio_converter_t * gavl_audio_converter_create(void)
Creates an audio converter.
GAVL_PUBLIC void gavl_audio_convert(gavl_audio_converter_t *cnv, const gavl_audio_frame_t *input_frame, gavl_audio_frame_t *output_frame)
Convert audio.
GAVL_PUBLIC int gavl_audio_converter_init(gavl_audio_converter_t *cnv, const gavl_audio_format_t *input_format, const gavl_audio_format_t *output_format)
Initialize an audio converter.
GAVL_PUBLIC int gavl_audio_converter_init_resample(gavl_audio_converter_t *cnv, const gavl_audio_format_t *format)
Initialize an audio converter just for resampling.
GAVL_PUBLIC int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t *cnv, double ratio)
Set samplerate conversion ratio.
GAVL_PUBLIC int gavl_audio_converter_reinit(gavl_audio_converter_t *cnv)
Reinitialize an audio converter.
gavl_channel_id_t
Audio channel setup.
Definition gavl.h:250
gavl_sample_format_t
Format of one audio sample.
Definition gavl.h:219
GAVL_PUBLIC const char * gavl_interleave_mode_to_short_string(gavl_interleave_mode_t mode)
Convert a gavl_interleave_mode_t to a short string.
GAVL_PUBLIC void gavl_audio_format_copy(gavl_audio_format_t *dst, const gavl_audio_format_t *src)
Copy one audio format to another.
GAVL_PUBLIC int gavl_channel_index(const gavl_audio_format_t *format, gavl_channel_id_t id)
Get the index of a particular channel for a given format.
GAVL_PUBLIC int gavl_side_channels(const gavl_audio_format_t *format)
Get number of side channels for a given format.
GAVL_PUBLIC void gavl_set_channel_setup(gavl_audio_format_t *format)
Set the default channel setup and indices.
GAVL_PUBLIC int gavl_lfe_channels(const gavl_audio_format_t *format)
Get number of LFE channels for a given format.
GAVL_PUBLIC gavl_sample_format_t gavl_get_sample_format(int index)
Get the sample format from index.
GAVL_PUBLIC const char * gavl_channel_id_to_string(gavl_channel_id_t id)
Convert a gavl_channel_id_t to a human readable string.
GAVL_PUBLIC void gavl_audio_format_dumpi(const gavl_audio_format_t *format, int indent)
Dump an audio format to stderr.
GAVL_PUBLIC int gavl_nearest_samplerate(int in_rate, const int *supported)
Get the nearest samplerate out of a list of supported rates.
GAVL_PUBLIC gavl_sample_format_t gavl_short_string_to_sample_format(const char *format)
Convert a short string to a gavl_sample_format_t.
GAVL_PUBLIC const char * gavl_sample_format_to_string(gavl_sample_format_t format)
Convert a gavl_sample_format_t to a human readable string.
gavl_interleave_mode_t
Definition gavl.h:236
GAVL_PUBLIC gavl_sample_format_t gavl_string_to_sample_format(const char *str)
Convert a string to a sample format.
GAVL_PUBLIC int gavl_front_channels(const gavl_audio_format_t *format)
Get number of front channels for a given format.
GAVL_PUBLIC const char * gavl_sample_format_to_short_string(gavl_sample_format_t format)
Convert a gavl_sample_format_t to a human readable string.
GAVL_PUBLIC int gavl_bytes_per_sample(gavl_sample_format_t format)
Get the number of bytes per sample for a given sample format.
GAVL_PUBLIC void gavl_audio_format_dump(const gavl_audio_format_t *format)
Dump an audio format to stderr.
GAVL_PUBLIC int gavl_aux_channels(const gavl_audio_format_t *format)
Get number of aux channels for a given format.
GAVL_PUBLIC int gavl_rear_channels(const gavl_audio_format_t *format)
Get number of rear channels for a given format.
GAVL_PUBLIC gavl_channel_id_t gavl_short_string_to_channel_id(const char *id)
Convert short string to a gavl_channel_id_t.
GAVL_PUBLIC int gavl_num_sample_formats(void)
Get total number of supported sample formats.
GAVL_PUBLIC const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode)
Convert a gavl_interleave_mode_t to a human readable string.
GAVL_PUBLIC const char * gavl_channel_id_to_short_string(gavl_channel_id_t id)
Convert a gavl_channel_id_t to a short string.
GAVL_PUBLIC gavl_interleave_mode_t gavl_short_string_to_interleave_mode(const char *mode)
Convert a short string to a gavl_interleave_mode_t.
GAVL_PUBLIC int gavl_audio_formats_equal(const gavl_audio_format_t *format_1, const gavl_audio_format_t *format_2)
Compare 2 audio formats.
#define GAVL_MAX_CHANNELS
Maximum number of audio channels.
Definition gavl.h:210
@ GAVL_CHID_SIDE_RIGHT
Definition gavl.h:261
@ GAVL_CHID_FRONT_RIGHT
Definition gavl.h:254
@ GAVL_CHID_FRONT_LEFT
Definition gavl.h:253
@ GAVL_CHID_REAR_LEFT
Definition gavl.h:257
@ GAVL_CHID_SIDE_LEFT
Definition gavl.h:260
@ GAVL_CHID_NONE
Definition gavl.h:251
@ GAVL_CHID_FRONT_CENTER_LEFT
Definition gavl.h:255
@ GAVL_CHID_REAR_CENTER
Definition gavl.h:259
@ GAVL_CHID_LFE
Definition gavl.h:262
@ GAVL_CHID_REAR_RIGHT
Definition gavl.h:258
@ GAVL_CHID_AUX
Definition gavl.h:263
@ GAVL_CHID_FRONT_CENTER_RIGHT
Definition gavl.h:256
@ GAVL_CHID_FRONT_CENTER
Definition gavl.h:252
@ GAVL_SAMPLE_FLOAT
Definition gavl.h:226
@ GAVL_SAMPLE_NONE
Definition gavl.h:220
@ GAVL_SAMPLE_U8
Definition gavl.h:221
@ GAVL_SAMPLE_S8
Definition gavl.h:222
@ GAVL_SAMPLE_U16
Definition gavl.h:223
@ GAVL_SAMPLE_S16
Definition gavl.h:224
@ GAVL_SAMPLE_DOUBLE
Definition gavl.h:227
@ GAVL_SAMPLE_S32
Definition gavl.h:225
@ GAVL_INTERLEAVE_2
Definition gavl.h:238
@ GAVL_INTERLEAVE_ALL
Definition gavl.h:239
@ GAVL_INTERLEAVE_NONE
Definition gavl.h:237
GAVL_PUBLIC void gavl_audio_frame_destroy(gavl_audio_frame_t *frame)
Destroy an audio frame.
GAVL_PUBLIC void gavl_audio_frame_from_data(gavl_audio_frame_t *f, const gavl_audio_format_t *format, uint8_t *data, int len)
Set the channel pointers of an audio frame.
GAVL_PUBLIC void gavl_audio_frame_mute(gavl_audio_frame_t *frame, const gavl_audio_format_t *format)
Mute an audio frame.
GAVL_PUBLIC void gavl_audio_frame_null(gavl_audio_frame_t *frame)
Zero all pointers in the audio frame.
GAVL_PUBLIC void gavl_audio_frame_set_channels(gavl_audio_frame_t *f, const gavl_audio_format_t *format, uint8_t *data)
Set the channel pointers of an audio frame.
GAVL_PUBLIC void gavl_audio_frame_mute_samples(gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int num_samples)
Mute a number of samples at the start of an audio frame.
GAVL_PUBLIC int gavl_audio_frame_copy(const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src, int dst_pos, int src_pos, int dst_size, int src_size)
Copy audio data from one frame to another.
GAVL_PUBLIC int gavl_audio_frame_skip(const gavl_audio_format_t *format, gavl_audio_frame_t *f, int num_samples)
Skip samples in am audio frame.
GAVL_PUBLIC gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t *format)
Create audio frame.
GAVL_PUBLIC void gavl_audio_frame_get_subframe(const gavl_audio_format_t *format, gavl_audio_frame_t *src, gavl_audio_frame_t *dst, int start, int len)
Set an audio frame to a subframe of another frame.
GAVL_PUBLIC void gavl_audio_frame_mute_channel(gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int channel)
Mute a single channel of an audio frame.
GAVL_PUBLIC int gavl_audio_frame_plot(const gavl_audio_format_t *format, const gavl_audio_frame_t *frame, const char *name_base)
Plot an audio frame to an ASCII file.
GAVL_PUBLIC int gavl_audio_frames_equal(const gavl_audio_format_t *format, const gavl_audio_frame_t *f1, const gavl_audio_frame_t *f2)
Check if 2 audio frames are bit-identical.
GAVL_PUBLIC void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src)
Copy audio data from one frame to another.
GAVL_PUBLIC int gavl_audio_frame_continuous(const gavl_audio_format_t *format, const gavl_audio_frame_t *f)
Check if an audio frames is continuous in memory.
struct gavl_audio_options_s gavl_audio_options_t
Opaque container for audio conversion options.
Definition gavl.h:1010
GAVL_PUBLIC void gavl_audio_options_set_resample_mode(gavl_audio_options_t *opt, gavl_resample_mode_t mode)
Set the resample mode for the converter.
GAVL_PUBLIC gavl_audio_options_t * gavl_audio_options_create(void)
Create an options container.
GAVL_PUBLIC void gavl_audio_options_copy(gavl_audio_options_t *dst, const gavl_audio_options_t *src)
Copy audio options.
gavl_audio_dither_mode_t
Dither mode.
Definition gavl.h:982
GAVL_PUBLIC void gavl_audio_options_set_conversion_flags(gavl_audio_options_t *opt, int flags)
Set the conversion flags.
GAVL_PUBLIC gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(const gavl_audio_options_t *opt)
Get the dither mode for the converter.
GAVL_PUBLIC void gavl_audio_options_set_defaults(gavl_audio_options_t *opt)
Set all options to their defaults.
GAVL_PUBLIC void gavl_audio_options_set_mix_matrix(gavl_audio_options_t *opt, const double **matrix)
Set a user defined mix matrix.
GAVL_PUBLIC void gavl_audio_options_set_dither_mode(gavl_audio_options_t *opt, gavl_audio_dither_mode_t mode)
Set the dither mode for the converter.
gavl_resample_mode_t
Resample mode.
Definition gavl.h:995
GAVL_PUBLIC const double ** gavl_audio_options_get_mix_matrix(const gavl_audio_options_t *opt)
Get the mix matrix.
GAVL_PUBLIC int gavl_audio_options_get_quality(const gavl_audio_options_t *opt)
Get the quality level for a converter.
GAVL_PUBLIC gavl_resample_mode_t gavl_audio_options_get_resample_mode(const gavl_audio_options_t *opt)
Get the resample mode for the converter.
GAVL_PUBLIC void gavl_audio_options_destroy(gavl_audio_options_t *opt)
Destroy audio options.
GAVL_PUBLIC int gavl_audio_options_get_conversion_flags(const gavl_audio_options_t *opt)
Get the conversion flags.
GAVL_PUBLIC void gavl_audio_options_set_quality(gavl_audio_options_t *opt, int quality)
Set the quality level for the converter.
@ GAVL_RESAMPLE_SINC_BEST
Definition gavl.h:1001
@ GAVL_RESAMPLE_ZOH
Definition gavl.h:997
@ GAVL_RESAMPLE_LINEAR
Definition gavl.h:998
@ GAVL_RESAMPLE_AUTO
Definition gavl.h:996
@ GAVL_RESAMPLE_SINC_MEDIUM
Definition gavl.h:1000
@ GAVL_RESAMPLE_SINC_FAST
Definition gavl.h:999
GAVL_PUBLIC int gavl_frame_table_save(const gavl_frame_table_t *t, const char *filename)
Save a frame table to a file.
GAVL_PUBLIC int64_t gavl_frame_table_end_time(const gavl_frame_table_t *t)
get the end time of the last frame
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_load(const char *filename)
Load a frame table from a file.
GAVL_PUBLIC int64_t gavl_frame_table_frame_to_time(const gavl_frame_table_t *t, int64_t frame, int *duration)
Convert a frame index to a timestamp.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create(void)
Create a frame table.
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_frame_to_timecode(const gavl_frame_table_t *t, int64_t frame, int64_t *start_time, const gavl_timecode_format_t *fmt)
Convert a frame index to a timecode.
GAVL_PUBLIC void gavl_frame_table_dump(const gavl_frame_table_t *t)
Dump a frame table to stderr for debugging.
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_time_to_timecode(const gavl_frame_table_t *t, int64_t time, int64_t *start_time, const gavl_timecode_format_t *fmt)
Convert a timestamp to a timecode.
GAVL_PUBLIC int64_t gavl_frame_table_time_to_frame(const gavl_frame_table_t *t, int64_t time, int64_t *start_time)
Convert a timestamp to a frame index.
GAVL_PUBLIC int64_t gavl_frame_table_duration(const gavl_frame_table_t *t)
get the total duration of all frames
GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t *t)
Destroy a frame table and free all memory.
GAVL_PUBLIC int64_t gavl_frame_table_num_frames(const gavl_frame_table_t *t)
get the total number of frames
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration, int64_t num_frames, gavl_timecode_t start_timecode)
Create a frame table for constant framerate video.
GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t *t, int64_t duration)
Append an entry.
GAVL_PUBLIC void gavl_frame_table_append_timecode(gavl_frame_table_t *t, int64_t pts, gavl_timecode_t tc)
Append a timecodes.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration, gavl_timecode_format_t *fmt_ret)
Create a frame table for an audio stream.
GAVL_PUBLIC int64_t gavl_frame_table_timecode_to_time(const gavl_frame_table_t *t, gavl_timecode_t tc, const gavl_timecode_format_t *fmt)
Convert a timecode to a timestamp.
GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_copy(const gavl_frame_table_t *tab)
Copy a frame table to another.
GAVL_PUBLIC void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the bottom border.
GAVL_PUBLIC int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t *r)
Check if a float rectangle is empty.
GAVL_PUBLIC int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t *r)
Check if an integer rectangle is empty.
GAVL_PUBLIC void gavl_rectangle_f_crop_left(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the left border.
GAVL_PUBLIC void gavl_rectangle_i_align(gavl_rectangle_i_t *r, int h_align, int v_align)
Align a rectangle.
GAVL_PUBLIC void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t *src_rect, gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Crop 2 rectangles to their formats when scaling is available.
GAVL_PUBLIC void gavl_rectangle_i_copy(gavl_rectangle_i_t *dst, const gavl_rectangle_i_t *src)
Copy an integer rectangle.
GAVL_PUBLIC void gavl_rectangle_f_crop_right(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the right border.
GAVL_PUBLIC void gavl_rectangle_i_dump(const gavl_rectangle_i_t *r)
Dump a rectangle to stderr.
GAVL_PUBLIC void gavl_rectangle_i_crop_top(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the top border.
GAVL_PUBLIC void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Crop an integer rectangle so it fits into the image size of a video format.
GAVL_PUBLIC void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t *src_rect, gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Set 2 rectangles as source and destination when no scaling is available.
GAVL_PUBLIC void gavl_rectangle_fit_aspect(gavl_rectangle_i_t *dst_rect, const gavl_video_format_t *src_format, const gavl_rectangle_f_t *src_rect, const gavl_video_format_t *dst_format, float zoom, float squeeze)
Calculate a destination rectangle for scaling.
GAVL_PUBLIC void gavl_rectangle_i_to_f(gavl_rectangle_f_t *dst, const gavl_rectangle_i_t *src)
Convert an integer rectangle to a floating point rectangle.
GAVL_PUBLIC void gavl_rectangle_i_set_all(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Let an integer rectangle span the whole image size of a video format.
GAVL_PUBLIC void gavl_rectangle_f_set_all(gavl_rectangle_f_t *r, const gavl_video_format_t *format)
Let a float rectangle span the whole image size of a video format.
GAVL_PUBLIC void gavl_rectangle_f_copy(gavl_rectangle_f_t *dst, const gavl_rectangle_f_t *src)
Copy a float rectangle.
GAVL_PUBLIC void gavl_rectangle_f_to_i(gavl_rectangle_i_t *dst, const gavl_rectangle_f_t *src)
Convert a floating point rectangle to an integer rectangle.
GAVL_PUBLIC void gavl_rectangle_f_crop_top(gavl_rectangle_f_t *r, double num_pixels)
Crop a float rectangle by some pixels from the top border.
GAVL_PUBLIC void gavl_rectangle_f_dump(const gavl_rectangle_f_t *r)
Dump a floating point rectangle to stderr.
GAVL_PUBLIC void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the bottom border.
GAVL_PUBLIC void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t *r, const gavl_video_format_t *format)
Align a rectangle to a format.
GAVL_PUBLIC void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t *r, const gavl_video_format_t *format)
Crop a floating point rectangle so it fits into the image size of a video format.
GAVL_PUBLIC void gavl_rectangle_i_crop_left(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the left border.
GAVL_PUBLIC void gavl_rectangle_i_crop_right(gavl_rectangle_i_t *r, int num_pixels)
Crop an integer rectangle by some pixels from the right border.
struct gavl_video_sink_s gavl_video_sink_t
Video sink.
Definition gavl.h:83
struct gavl_audio_sink_s gavl_audio_sink_t
Audio sink.
Definition gavl.h:74
struct gavl_packet_sink_s gavl_packet_sink_t
Packet sink.
Definition gavl.h:92
struct gavl_video_source_s gavl_video_source_t
Forward declaration of the video source.
Definition gavl.h:50
struct gavl_audio_source_s gavl_audio_source_t
Forward declaration of the audio source.
Definition gavl.h:58
struct gavl_packet_source_s gavl_packet_source_t
Forward declaration of the packet source.
Definition gavl.h:66
uint64_t gavl_timecode_t
Typedef for timecodes.
Definition timecode.h:44
GAVL_PUBLIC void gavl_overlay_blend(gavl_overlay_blend_context_t *ctx, gavl_video_frame_t *dst_frame)
Blend overlay onto video frame.
GAVL_PUBLIC gavl_overlay_blend_context_t * gavl_overlay_blend_context_create(void)
Create a blend context.
GAVL_PUBLIC void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t *ctx, gavl_overlay_t *ovl)
Set a new overlay.
gavl_video_frame_t gavl_overlay_t
Overlay structure.
Definition gavl.h:3882
GAVL_PUBLIC int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t *ctx, const gavl_video_format_t *frame_format, gavl_video_format_t *overlay_format)
Initialize the blend context.
struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t
Opaque blend context.
Definition gavl.h:3890
GAVL_PUBLIC void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t *ctx)
Destroy a blend context and free all associated memory.
GAVL_PUBLIC gavl_video_sink_t * gavl_overlay_blend_context_get_sink(gavl_overlay_blend_context_t *ctx)
Get the sink for overlays.
GAVL_PUBLIC gavl_video_options_t * gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t *ctx)
Get options from a blend context.
GAVL_PUBLIC int gavl_video_converter_init(gavl_video_converter_t *cnv, const gavl_video_format_t *input_format, const gavl_video_format_t *output_format)
Initialize a video converter.
GAVL_PUBLIC gavl_video_converter_t * gavl_video_converter_create(void)
Creates a video converter.
struct gavl_video_converter_s gavl_video_converter_t
Opaque video converter structure.
Definition gavl.h:3574
GAVL_PUBLIC void gavl_video_convert(gavl_video_converter_t *cnv, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Convert video.
GAVL_PUBLIC int gavl_video_converter_reinit(gavl_video_converter_t *cnv)
Reinitialize a video converter.
GAVL_PUBLIC void gavl_video_converter_destroy(gavl_video_converter_t *cnv)
Destroys a video converter and frees all associated memory.
GAVL_PUBLIC gavl_video_options_t * gavl_video_converter_get_options(gavl_video_converter_t *cnv)
gets options of a video converter
GAVL_PUBLIC int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t *deinterlacer, const gavl_video_format_t *src_format)
Initialize a video deinterlacer.
GAVL_PUBLIC gavl_video_deinterlacer_t * gavl_video_deinterlacer_create(void)
Create a video deinterlacer.
struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t
Opaque deinterlacer structure.
Definition gavl.h:3791
GAVL_PUBLIC void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t *deinterlacer)
Destroy a video deinterlacer.
GAVL_PUBLIC gavl_video_options_t * gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t *deinterlacer)
gets options of a deinterlacer
GAVL_PUBLIC void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t *deinterlacer, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Deinterlace video.
GAVL_PUBLIC void gavl_video_format_set_frame_size(gavl_video_format_t *format, int pad_h, int pad_v)
Set the frame size from the image size.
#define GAVL_PIXFMT_PLANAR
Definition gavl.h:1788
#define GAVL_PIXFMT_ALPHA
Definition gavl.h:1808
struct gavl_video_format_s gavl_video_format_t
Video format.
Definition gavl.h:102
GAVL_PUBLIC int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src, gavl_pixelformat_t dst)
Get the conversion penalty for pixelformat conversions.
GAVL_PUBLIC int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat)
Get bytes per pixel for packed formats.
gavl_chroma_placement_t
Chroma placement.
Definition gavl.h:2253
#define GAVL_PIXFMT_GRAY
Definition gavl.h:1813
GAVL_PUBLIC int gavl_get_color_channel_format(const gavl_video_format_t *frame_format, gavl_video_format_t *channel_format, gavl_color_channel_t ch)
Get the video format for extracting/merging one channel.
gavl_framerate_mode_t
Framerate mode.
Definition gavl.h:2294
gavl_pixelformat_e
Pixelformat definition.
Definition gavl.h:1820
GAVL_PUBLIC gavl_framerate_mode_t gavl_short_string_to_framerate_mode(const char *mode)
Translate a short string into a framerate mode.
GAVL_PUBLIC int gavl_video_formats_equal(const gavl_video_format_t *format_1, const gavl_video_format_t *format_2)
Compare 2 video formats.
GAVL_PUBLIC void gavl_video_format_get_chroma_offset(const gavl_video_format_t *format, int field, int plane, float *off_x, float *off_y)
Get the chroma offsets relative to the luma samples.
GAVL_PUBLIC const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat)
Translate a pixelformat into a human readable string.
GAVL_PUBLIC int gavl_num_pixelformats(void)
Get total number of supported pixelformats.
GAVL_PUBLIC void gavl_video_format_dump(const gavl_video_format_t *format)
Dump a video format to stderr.
GAVL_PUBLIC int gavl_video_format_get_image_size(const gavl_video_format_t *format)
Get the unpadded image size.
GAVL_PUBLIC gavl_pixelformat_t gavl_get_pixelformat(int index)
Get the pixelformat from index.
GAVL_PUBLIC const char * gavl_interlace_mode_to_short_string(gavl_interlace_mode_t mode)
Translate an interlace mode into a short string.
GAVL_PUBLIC gavl_color_channel_t gavl_pixelformat_get_channel(gavl_pixelformat_t pixelformat, int index)
Get the color channel.
GAVL_PUBLIC const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode)
Translate an interlace mode into a human readable string.
enum gavl_pixelformat_e gavl_pixelformat_t
Pixelformat.
Definition gavl.h:1955
GAVL_PUBLIC gavl_pixelformat_t gavl_short_string_to_pixelformat(const char *name)
Translate a short pixelformat name into a pixelformat.
GAVL_PUBLIC const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode)
Translate a chroma placement into a human readable string.
GAVL_PUBLIC const uint32_t * gavl_pixelformat_get_masks(gavl_pixelformat_t pixelformat)
Get the masks for the components.
GAVL_PUBLIC const char * gavl_chroma_placement_to_short_string(gavl_chroma_placement_t mode)
Translate a chroma placement into a short string.
GAVL_PUBLIC gavl_pixelformat_t gavl_string_to_pixelformat(const char *name)
Translate a pixelformat name into a pixelformat.
gavl_interlace_mode_t
Interlace mode.
Definition gavl.h:2335
#define GAVL_PIXFMT_RGB
Definition gavl.h:1793
GAVL_PUBLIC const char * gavl_framerate_mode_to_string(gavl_framerate_mode_t mode)
Translate a framerate mode into a human readable string.
GAVL_PUBLIC int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat)
Get the effective number of bits for one pixel.
#define GAVL_PIXFMT_YUV
Definition gavl.h:1798
GAVL_PUBLIC int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat)
Get the number of planes.
gavl_color_channel_t
Color channel definitions.
Definition gavl.h:2003
#define GAVL_PIXFMT_YUVJ
Definition gavl.h:1803
GAVL_PUBLIC void gavl_video_format_fit_to_source(gavl_video_format_t *dst, const gavl_video_format_t *src)
Set the image size of a destination format from a source format.
GAVL_PUBLIC const char * gavl_pixelformat_to_short_string(gavl_pixelformat_t pixelformat)
Translate a pixelformat into a short string.
GAVL_PUBLIC void gavl_video_format_copy(gavl_video_format_t *dst, const gavl_video_format_t *src)
Copy one video format to another.
GAVL_PUBLIC gavl_pixelformat_t gavl_pixelformat_get_best(gavl_pixelformat_t src, const gavl_pixelformat_t *dst_supported, int *penalty)
Get the best destination format for a given source format.
GAVL_PUBLIC void gavl_video_format_dumpi(const gavl_video_format_t *format, int indent)
Dump a video format to stderr.
GAVL_PUBLIC int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat)
Get bytes per component for planar formats.
GAVL_PUBLIC gavl_interlace_mode_t gavl_short_string_to_interlace_mode(const char *mode)
Translate a short string to an interlace mode.
GAVL_PUBLIC int gavl_pixelformat_num_channels(gavl_pixelformat_t pixelformat)
Get the number of channels.
GAVL_PUBLIC int gavl_interlace_mode_is_mixed(gavl_interlace_mode_t mode)
Check if an interlace mode is mixed.
GAVL_PUBLIC const char * gavl_framerate_mode_to_short_string(gavl_framerate_mode_t mode)
Translate a framerate mode into a short string.
GAVL_PUBLIC void gavl_get_field_format(const gavl_video_format_t *frame_format, gavl_video_format_t *field_format, int field)
Get the video format of one field.
GAVL_PUBLIC gavl_chroma_placement_t gavl_short_string_to_chroma_placement(const char *mode)
Translate a short string into a chroma placement.
GAVL_PUBLIC void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int *sub_h, int *sub_v)
Get the horizontal and vertical subsampling factors.
@ GAVL_CHROMA_PLACEMENT_DVPAL
Definition gavl.h:2256
@ GAVL_CHROMA_PLACEMENT_MPEG2
Definition gavl.h:2255
@ GAVL_CHROMA_PLACEMENT_DEFAULT
Definition gavl.h:2254
@ GAVL_FRAMERATE_UNKNOWN
Definition gavl.h:2295
@ GAVL_FRAMERATE_CONSTANT
Definition gavl.h:2296
@ GAVL_FRAMERATE_STILL
Definition gavl.h:2298
@ GAVL_FRAMERATE_VARIABLE
Definition gavl.h:2297
@ GAVL_YUVJ_420_P
Definition gavl.h:1934
@ GAVL_YUV_422_P
Definition gavl.h:1921
@ GAVL_BGR_24
Definition gavl.h:1870
@ GAVL_YUV_410_P
Definition gavl.h:1930
@ GAVL_RGB_48
Definition gavl.h:1883
@ GAVL_RGB_32
Definition gavl.h:1873
@ GAVL_YUV_420_P
Definition gavl.h:1918
@ GAVL_GRAYA_32
Definition gavl.h:1843
@ GAVL_YUVA_32
Definition gavl.h:1903
@ GAVL_RGB_16
Definition gavl.h:1860
@ GAVL_UYVY
Definition gavl.h:1900
@ GAVL_YUV_422_P_16
Definition gavl.h:1947
@ GAVL_YUV_444_P
Definition gavl.h:1924
@ GAVL_RGB_FLOAT
Definition gavl.h:1890
@ GAVL_YUVJ_422_P
Definition gavl.h:1937
@ GAVL_GRAY_8
Definition gavl.h:1827
@ GAVL_RGB_24
Definition gavl.h:1867
@ GAVL_RGBA_64
Definition gavl.h:1886
@ GAVL_YUY2
Definition gavl.h:1897
@ GAVL_YUVA_FLOAT
Definition gavl.h:1913
@ GAVL_YUVJ_444_P
Definition gavl.h:1940
@ GAVL_GRAYA_FLOAT
Definition gavl.h:1847
@ GAVL_BGR_15
Definition gavl.h:1856
@ GAVL_YUV_444_P_16
Definition gavl.h:1944
@ GAVL_PIXELFORMAT_NONE
Undefined.
Definition gavl.h:1823
@ GAVL_GRAYA_16
Definition gavl.h:1839
@ GAVL_YUV_411_P
Definition gavl.h:1927
@ GAVL_GRAY_FLOAT
Definition gavl.h:1835
@ GAVL_YUV_FLOAT
Definition gavl.h:1909
@ GAVL_RGBA_32
Definition gavl.h:1879
@ GAVL_GRAY_16
Definition gavl.h:1831
@ GAVL_BGR_16
Definition gavl.h:1864
@ GAVL_YUVA_64
Definition gavl.h:1906
@ GAVL_RGB_15
Definition gavl.h:1852
@ GAVL_RGBA_FLOAT
Definition gavl.h:1893
@ GAVL_BGR_32
Definition gavl.h:1876
@ GAVL_INTERLACE_MIXED_BOTTOM
Definition gavl.h:2342
@ GAVL_INTERLACE_MIXED_TOP
Definition gavl.h:2341
@ GAVL_INTERLACE_NONE
Definition gavl.h:2337
@ GAVL_INTERLACE_BOTTOM_FIRST
Definition gavl.h:2339
@ GAVL_INTERLACE_UNKNOWN
Definition gavl.h:2336
@ GAVL_INTERLACE_MIXED
Definition gavl.h:2340
@ GAVL_INTERLACE_TOP_FIRST
Definition gavl.h:2338
@ GAVL_CCH_NONE
None/undefined.
Definition gavl.h:2004
@ GAVL_CCH_Y
Luminance (also grayscale).
Definition gavl.h:2008
@ GAVL_CCH_RED
Red.
Definition gavl.h:2005
@ GAVL_CCH_CR
Chrominance red (aka V).
Definition gavl.h:2010
@ GAVL_CCH_GREEN
Green.
Definition gavl.h:2006
@ GAVL_CCH_ALPHA
Transparency (or, to be more precise opacity).
Definition gavl.h:2011
@ GAVL_CCH_CB
Chrominance blue (aka U).
Definition gavl.h:2009
@ GAVL_CCH_BLUE
Blue.
Definition gavl.h:2007
GAVL_PUBLIC void gavl_video_frame_copy(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another.
GAVL_PUBLIC void gavl_video_frame_copy_plane(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src, int plane)
Copy a single plane from one video frame to another.
GAVL_PUBLIC void gavl_video_frame_destroy(gavl_video_frame_t *frame)
Destroy a video frame.
GAVL_PUBLIC void gavl_video_frame_copy_flip_x(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with horizontal flipping.
GAVL_PUBLIC void gavl_video_frame_set_strides(gavl_video_frame_t *frame, const gavl_video_format_t *format)
Set the strides according to the format.
GAVL_PUBLIC int gavl_video_frame_insert_channel(const gavl_video_format_t *format, gavl_color_channel_t ch, const gavl_video_frame_t *src, gavl_video_frame_t *dst)
Insert one channel from a grayscale image into a video frame.
GAVL_PUBLIC void gavl_video_frame_set_planes(gavl_video_frame_t *frame, const gavl_video_format_t *format, uint8_t *buffer)
Set the frames according to the format.
GAVL_PUBLIC void gavl_video_frame_copy_flip_xy(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with horizontal and vertical flipping.
GAVL_PUBLIC void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat, const gavl_video_frame_t *src, gavl_video_frame_t *dst, const gavl_rectangle_i_t *src_rect)
Get a subframe of another frame.
GAVL_PUBLIC void gavl_video_frame_copy_metadata(gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy metadata of one video frame to another.
GAVL_PUBLIC void gavl_video_frame_fill(gavl_video_frame_t *frame, const gavl_video_format_t *format, const float *color)
Fill the frame with a user specified color.
GAVL_PUBLIC void gavl_video_frame_dump(gavl_video_frame_t *frame, const gavl_video_format_t *format, const char *namebase)
Dump a video frame to files.
GAVL_PUBLIC void gavl_video_frame_copy_flip_y(const gavl_video_format_t *format, gavl_video_frame_t *dst, const gavl_video_frame_t *src)
Copy one video frame to another with vertical flipping.
GAVL_PUBLIC void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat, const gavl_video_frame_t *src, gavl_video_frame_t *dst, int field)
Get a field from a frame.
GAVL_PUBLIC void gavl_video_frame_psnr(double *psnr, const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, const gavl_video_format_t *format)
Calculate the PSNR of 2 source frames.
GAVL_PUBLIC void gavl_video_frame_absdiff(gavl_video_frame_t *dst, const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, const gavl_video_format_t *format)
Fill the frame with the absolute difference of 2 source frames.
GAVL_PUBLIC int gavl_video_frame_ssim(const gavl_video_frame_t *src1, const gavl_video_frame_t *src2, gavl_video_frame_t *dst, const gavl_video_format_t *format)
Calculate the SSIM of 2 source frames.
GAVL_PUBLIC int gavl_video_frame_extract_channel(const gavl_video_format_t *format, gavl_color_channel_t ch, const gavl_video_frame_t *src, gavl_video_frame_t *dst)
Extract one channel of a video frame into a grayscale image.
GAVL_PUBLIC gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t *format)
Create video frame.
GAVL_PUBLIC void gavl_video_frame_null(gavl_video_frame_t *frame)
Zero all pointers in the video frame.
GAVL_PUBLIC void gavl_video_frame_clear(gavl_video_frame_t *frame, const gavl_video_format_t *format)
Fill the frame with black color.
GAVL_PUBLIC int gavl_video_frame_continuous(const gavl_video_format_t *format, const gavl_video_frame_t *frame)
Check if a video frame uses a continuous memory block.
GAVL_PUBLIC int gavl_video_frames_equal(const gavl_video_format_t *format, const gavl_video_frame_t *f1, const gavl_video_frame_t *f2)
Check if 2 video frames are bit-identical.
GAVL_PUBLIC gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t *format)
Create video frame without padding.
GAVL_PUBLIC void gavl_video_frame_dump_metadata(const gavl_video_format_t *format, const gavl_video_frame_t *frame)
Dump a metadata of a video frame.
GAVL_PUBLIC void gavl_video_options_set_quality(gavl_video_options_t *opt, int quality)
Set the quality level for the converter.
GAVL_PUBLIC void gavl_video_options_set_alpha_mode(gavl_video_options_t *opt, gavl_alpha_mode_t alpha_mode)
Set the alpha mode.
GAVL_PUBLIC void gavl_video_options_get_rectangles(const gavl_video_options_t *opt, gavl_rectangle_f_t *src_rect, gavl_rectangle_i_t *dst_rect)
Get source and destination rectangles.
GAVL_PUBLIC void gavl_video_options_get_background_color(const gavl_video_options_t *opt, double *color)
Get the background color for alpha blending.
GAVL_PUBLIC gavl_alpha_mode_t gavl_video_options_get_alpha_mode(const gavl_video_options_t *opt)
Get the alpha mode.
GAVL_PUBLIC void gavl_video_options_set_rectangles(gavl_video_options_t *opt, const gavl_rectangle_f_t *src_rect, const gavl_rectangle_i_t *dst_rect)
Set source and destination rectangles.
GAVL_PUBLIC void gavl_video_options_destroy(gavl_video_options_t *opt)
Destroy video options.
GAVL_PUBLIC int gavl_video_options_get_quality(const gavl_video_options_t *opt)
Get the quality level for the converter.
GAVL_PUBLIC void gavl_video_options_set_scale_mode(gavl_video_options_t *opt, gavl_scale_mode_t scale_mode)
Set the scale mode.
gavl_deinterlace_mode_t
Definition gavl.h:3183
GAVL_PUBLIC gavl_deinterlace_drop_mode_t gavl_video_options_get_deinterlace_drop_mode(const gavl_video_options_t *opt)
Get the deinterlace drop mode.
GAVL_PUBLIC void gavl_video_options_copy(gavl_video_options_t *dst, const gavl_video_options_t *src)
Copy video options.
gavl_deinterlace_drop_mode_t
Specifies which field to drop when deinterlacing.
Definition gavl.h:3197
struct gavl_video_options_s gavl_video_options_t
Definition gavl.h:3242
GAVL_PUBLIC int gavl_video_options_get_scale_order(const gavl_video_options_t *opt)
Get the scale order for GAVL_SCALE_SINC_LANCZOS.
GAVL_PUBLIC float gavl_video_options_get_downscale_blur(const gavl_video_options_t *opt)
Get blur factor for downscaling.
gavl_alpha_mode_t
Definition gavl.h:3171
GAVL_PUBLIC void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t *opt, gavl_deinterlace_drop_mode_t deinterlace_drop_mode)
Set the deinterlace drop mode.
GAVL_PUBLIC gavl_downscale_filter_t gavl_video_options_get_downscale_filter(const gavl_video_options_t *opt)
Get the antialiasing filter for downscaling.
GAVL_PUBLIC gavl_video_options_t * gavl_video_options_create(void)
Create an options container.
GAVL_PUBLIC void gavl_video_options_set_defaults(gavl_video_options_t *opt)
Set all options to their defaults.
GAVL_PUBLIC void gavl_video_options_set_conversion_flags(gavl_video_options_t *opt, int conversion_flags)
Set the conversion flags.
gavl_scale_mode_t
Definition gavl.h:3207
GAVL_PUBLIC void gavl_video_options_set_downscale_blur(gavl_video_options_t *opt, float f)
Set blur factor for downscaling.
GAVL_PUBLIC void gavl_video_options_set_background_color(gavl_video_options_t *opt, const double *color)
Set the background color for alpha blending.
GAVL_PUBLIC void gavl_video_options_set_downscale_filter(gavl_video_options_t *opt, gavl_downscale_filter_t f)
Set antialiasing filter for downscaling.
GAVL_PUBLIC int gavl_video_options_get_conversion_flags(const gavl_video_options_t *opt)
Get the conversion flags.
GAVL_PUBLIC void gavl_video_options_set_scale_order(gavl_video_options_t *opt, int order)
Set the scale order for GAVL_SCALE_SINC_LANCZOS.
gavl_downscale_filter_t
Definition gavl.h:3229
GAVL_PUBLIC gavl_scale_mode_t gavl_video_options_get_scale_mode(const gavl_video_options_t *opt)
Get the scale mode.
@ GAVL_DEINTERLACE_NONE
Definition gavl.h:3184
@ GAVL_DEINTERLACE_SCALE
Definition gavl.h:3186
@ GAVL_DEINTERLACE_BLEND
Definition gavl.h:3187
@ GAVL_DEINTERLACE_COPY
Definition gavl.h:3185
@ GAVL_DEINTERLACE_DROP_TOP
Definition gavl.h:3198
@ GAVL_DEINTERLACE_DROP_BOTTOM
Definition gavl.h:3199
@ GAVL_ALPHA_IGNORE
Definition gavl.h:3172
@ GAVL_ALPHA_BLEND_COLOR
Definition gavl.h:3173
@ GAVL_SCALE_NONE
Definition gavl.h:3216
@ GAVL_SCALE_NEAREST
Definition gavl.h:3209
@ GAVL_SCALE_CUBIC_MITCHELL
Definition gavl.h:3213
@ GAVL_SCALE_AUTO
Definition gavl.h:3208
@ GAVL_SCALE_SINC_LANCZOS
Definition gavl.h:3215
@ GAVL_SCALE_CUBIC_CATMULL
Definition gavl.h:3214
@ GAVL_SCALE_CUBIC_BSPLINE
Definition gavl.h:3212
@ GAVL_SCALE_QUADRATIC
Definition gavl.h:3211
@ GAVL_SCALE_BILINEAR
Definition gavl.h:3210
@ GAVL_DOWNSCALE_FILTER_AUTO
Auto selection based on quality.
Definition gavl.h:3230
@ GAVL_DOWNSCALE_FILTER_NONE
Fastest method, might produce heavy aliasing artifacts.
Definition gavl.h:3231
@ GAVL_DOWNSCALE_FILTER_WIDE
Widen the filter curve according to the scaling ratio.
Definition gavl.h:3232
@ GAVL_DOWNSCALE_FILTER_GAUSS
Do a Gaussian preblur.
Definition gavl.h:3233
GAVL_PUBLIC int gavl_video_scaler_init(gavl_video_scaler_t *scaler, const gavl_video_format_t *src_format, const gavl_video_format_t *dst_format)
Initialize a video scaler.
GAVL_PUBLIC void gavl_video_scaler_destroy(gavl_video_scaler_t *scaler)
Destroy a video scaler.
GAVL_PUBLIC gavl_video_options_t * gavl_video_scaler_get_options(gavl_video_scaler_t *scaler)
gets options of a scaler
GAVL_PUBLIC gavl_video_scaler_t * gavl_video_scaler_create(void)
Create a video scaler.
struct gavl_video_scaler_s gavl_video_scaler_t
Opaque scaler structure.
Definition gavl.h:3691
GAVL_PUBLIC void gavl_video_scaler_scale(gavl_video_scaler_t *scaler, const gavl_video_frame_t *input_frame, gavl_video_frame_t *output_frame)
Scale video.
GAVL_PUBLIC int gavl_video_scaler_init_convolve(gavl_video_scaler_t *scaler, const gavl_video_format_t *format, int h_radius, const float *h_coeffs, int v_radius, const float *v_coeffs)
Initialize a video scaler as a generic convolver.
GAVL_PUBLIC void gavl_image_transform_destroy(gavl_image_transform_t *t)
Destroy a transformation engine.
GAVL_PUBLIC gavl_image_transform_t * gavl_image_transform_create(void)
Create a transformation engine.
GAVL_PUBLIC int gavl_image_transform_init(gavl_image_transform_t *t, gavl_video_format_t *format, gavl_image_transform_func func, void *priv)
Initialize a transformation engine.
GAVL_PUBLIC gavl_video_options_t * gavl_image_transform_get_options(gavl_image_transform_t *t)
Get transformation options.
struct gavl_image_transform_s gavl_image_transform_t
Opaque image transformation engine.
Definition gavl.h:3990
GAVL_PUBLIC void gavl_image_transform_transform(gavl_image_transform_t *t, gavl_video_frame_t *in_frame, gavl_video_frame_t *out_frame)
Transform an image.
void(*) gavl_image_transform_func(void *priv, double xdst, double ydst, double *xsrc, double *ysrc)
Function describing the method.
Definition gavl.h:4005
#define GAVL_MAX_PLANES
Definition gavl.h:1439
GAVL_PUBLIC void gavl_volume_control_set_volume(gavl_volume_control_t *ctrl, float volume)
Set volume for a volume control.
GAVL_PUBLIC void gavl_volume_control_apply(gavl_volume_control_t *ctrl, gavl_audio_frame_t *frame)
Apply a volume control for an audio frame.
GAVL_PUBLIC float gavl_volume_to_float(int volume, float one, int steps)
Convert an integer audio volume to a float (in dB).
GAVL_PUBLIC void gavl_volume_control_destroy(gavl_volume_control_t *ctrl)
Destroys a volume control and frees all associated memory.
GAVL_PUBLIC void gavl_volume_control_set_format(gavl_volume_control_t *ctrl, const gavl_audio_format_t *format)
Set format for a volume control.
struct gavl_volume_control_s gavl_volume_control_t
Opaque structure for a volume control.
Definition gavl.h:1357
GAVL_PUBLIC gavl_volume_control_t * gavl_volume_control_create(void)
Create volume control.
GAVL_PUBLIC int gavl_volume_to_int(float volume, float one, int steps)
Convert an audio volume (in dB) to an integer.
Audio Format.
Definition gavl.h:275
uint32_t samples_per_frame
Definition gavl.h:276
uint32_t samplerate
Definition gavl.h:277
gavl_hw_context_t * hwctx
Definition gavl.h:287
float rear_level
Definition gavl.h:283
gavl_interleave_mode_t interleave_mode
Definition gavl.h:280
gavl_sample_format_t sample_format
Definition gavl.h:279
uint32_t num_channels
Definition gavl.h:278
float center_level
Definition gavl.h:282
gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS]
Definition gavl.h:285
Generic container for audio samples.
Definition gavl.h:628
int channel_stride
Definition gavl.h:633
gavl_audio_samples_t samples
Definition gavl.h:629
int valid_samples
Definition gavl.h:631
gavl_hw_context_t * hwctx
Definition gavl.h:635
int64_t timestamp
Definition gavl.h:632
void * storage
Definition gavl.h:636
gavl_audio_channels_t channels
Definition gavl.h:630
int64_t num_frames
Number of frames.
int64_t duration
Duration of each of these frames.
gavl_timecode_t tc
Timecode associated with this timestamp.
int64_t pts
Timestamp of this frame.
frame table structure
Definition gavl.h:4100
int num_timecodes
Number of timecodes.
Definition gavl.h:4112
int64_t offset
Timestamp of the first frame.
Definition gavl.h:4101
int64_t entries_alloc
Number of allocated entries (never touch this).
Definition gavl.h:4104
int64_t num_entries
Number of entries.
Definition gavl.h:4103
int timecodes_alloc
Number of allocated timecodes (never touch this).
Definition gavl.h:4113
Packet structure.
Definition compression.h:424
Floating point rectangle.
Definition gavl.h:1465
double x
Definition gavl.h:1466
double y
Definition gavl.h:1467
double w
Definition gavl.h:1468
double h
Definition gavl.h:1469
Integer rectangle.
Definition gavl.h:1453
int32_t x
Definition gavl.h:1454
int32_t h
Definition gavl.h:1457
int32_t y
Definition gavl.h:1455
int32_t w
Definition gavl.h:1456
Timecode format.
Definition timecode.h:61
Video format.
Definition gavl.h:2408
uint32_t frame_height
Definition gavl.h:2410
gavl_chroma_placement_t chroma_placement
Definition gavl.h:2427
gavl_hw_context_t * hwctx
Handle for accessing the frames. If NULL, frames are in regular RAM.
Definition gavl.h:2433
uint32_t image_height
Definition gavl.h:2413
uint32_t pixel_height
Definition gavl.h:2418
uint32_t frame_width
Definition gavl.h:2409
uint32_t image_width
Definition gavl.h:2412
uint32_t timescale
Definition gavl.h:2424
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2429
gavl_framerate_mode_t framerate_mode
Definition gavl.h:2426
gavl_pixelformat_t pixelformat
Definition gavl.h:2420
uint32_t pixel_width
Definition gavl.h:2417
gavl_timecode_format_t timecode_format
Definition gavl.h:2431
uint32_t frame_duration
Definition gavl.h:2422
Definition gavl.h:2641
uint8_t * planes[GAVL_MAX_PLANES]
Definition gavl.h:2642
int64_t duration
Definition gavl.h:2647
int strides[GAVL_MAX_PLANES]
Definition gavl.h:2643
void * client_data
Definition gavl.h:2645
int32_t dst_y
y offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2655
void * storage
Definition gavl.h:2658
int64_t timestamp
Definition gavl.h:2646
int32_t dst_x
x offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2654
gavl_rectangle_i_t src_rect
Valid rectangle in this frame (since 1.5.0) *‍/.
Definition gavl.h:2653
gavl_hw_context_t * hwctx
Handle for accessing the frame.
Definition gavl.h:2657
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2648
gavl_timecode_t timecode
Definition gavl.h:2649
Container for noninterleaved audio samples.
Definition gavl.h:596
int16_t * s_16[GAVL_MAX_CHANNELS]
Definition gavl.h:601
int32_t * s_32[GAVL_MAX_CHANNELS]
Definition gavl.h:604
float * f[GAVL_MAX_CHANNELS]
Definition gavl.h:606
double * d[GAVL_MAX_CHANNELS]
Definition gavl.h:607
int8_t * s_8[GAVL_MAX_CHANNELS]
Definition gavl.h:598
uint8_t * u_8[GAVL_MAX_CHANNELS]
Definition gavl.h:597
uint32_t * u_32[GAVL_MAX_CHANNELS]
Definition gavl.h:603
uint16_t * u_16[GAVL_MAX_CHANNELS]
Definition gavl.h:600
Container for interleaved audio samples.
Definition gavl.h:576
uint32_t * u_32
Definition gavl.h:583
int8_t * s_8
Definition gavl.h:578
uint16_t * u_16
Definition gavl.h:580
int16_t * s_16
Definition gavl.h:581
uint8_t * u_8
Definition gavl.h:577
float * f
Definition gavl.h:586
double * d
Definition gavl.h:587
int32_t * s_32
Definition gavl.h:584