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#define GAVL_PIXFMT_EXTENDED (1<<14)
1819
1820
1824
1826 {
1830
1834
1838
1842
1846
1850
1854
1886
1893
1900
1908
1911
1916
1920
1923
1937
1947
1954
1955 /* Extended (as specified by fourcc) */
1956
1957 GAVL_PIXELFORMAT_EXTENDED = GAVL_PIXFMT_EXTENDED,
1958
1959 };
1960
1964
1966
1969#define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
1972#define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
1975#define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
1978#define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
1979
1982#define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
1985#define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
1988#define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
1991#define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
1992
1995#define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
1998#define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
2001#define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
2004#define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
2005
2011
2023
2024/*
2025 * Colormodel related functions
2026 */
2027
2033
2034#define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
2035
2036
2042
2043#define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
2044
2050
2051#define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
2052
2058
2059#define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
2060
2066
2067#define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
2068
2074
2075#define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
2076
2077
2083
2084GAVL_PUBLIC
2086
2093
2094GAVL_PUBLIC gavl_color_channel_t
2096
2097
2103
2104GAVL_PUBLIC
2106
2115
2116GAVL_PUBLIC
2117void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
2118
2124
2125GAVL_PUBLIC
2127
2133
2134GAVL_PUBLIC
2136
2142
2143GAVL_PUBLIC
2145
2159
2160GAVL_PUBLIC
2162 gavl_pixelformat_t dst);
2163
2176
2177GAVL_PUBLIC gavl_pixelformat_t
2179 const gavl_pixelformat_t * dst_supported,
2180 int * penalty);
2181
2182
2183
2189
2190GAVL_PUBLIC
2192
2201
2202GAVL_PUBLIC
2204
2205
2211
2212GAVL_PUBLIC
2214
2220
2221GAVL_PUBLIC
2223
2229
2230GAVL_PUBLIC
2232
2233
2234
2239
2240GAVL_PUBLIC
2242
2248
2249GAVL_PUBLIC
2251
2252/* */
2253
2261
2268
2274
2275GAVL_PUBLIC
2277
2283
2284GAVL_PUBLIC
2286
2292
2293GAVL_PUBLIC
2295
2296
2300
2301/* Changing the values alters the gmerlin-avdecoder index format */
2302
2310
2316
2317GAVL_PUBLIC
2319
2325
2326GAVL_PUBLIC
2328
2334
2335GAVL_PUBLIC
2337
2341
2342/* Changing the values alters the gmerlin-avdecoder index format */
2343
2354
2360
2361GAVL_PUBLIC
2363
2369
2370GAVL_PUBLIC
2372
2378
2379GAVL_PUBLIC
2381
2389
2390GAVL_PUBLIC
2392
2393
2394/* Video format structure */
2395
2396#define GAVL_IMAGE_ORIENT_FLIP_H (1<<2)
2397
2398typedef enum
2399 {
2400
2401 GAVL_IMAGE_ORIENT_NORMAL = 0, // EXIF: 1
2402 GAVL_IMAGE_ORIENT_ROT90_CW = 1, // EXIF: 8
2403 GAVL_IMAGE_ORIENT_ROT180_CW = 2, // EXIF: 3
2404 GAVL_IMAGE_ORIENT_ROT270_CW = 3, // EXIF: 6
2405
2406 GAVL_IMAGE_ORIENT_FH = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_NORMAL), // EXIF: 2
2407 GAVL_IMAGE_ORIENT_FH_ROT90_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT90_CW), // EXIF: 7
2408 GAVL_IMAGE_ORIENT_FH_ROT180_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT180_CW), // EXIF: 4
2409 GAVL_IMAGE_ORIENT_FH_ROT270_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT270_CW), // EXIF: 5
2410
2411 } gavl_image_orientation_t;
2412
2416
2418 {
2419 uint32_t frame_width;
2421
2422 uint32_t image_width;
2424
2425 /* Support for nonsquare pixels */
2426
2427 uint32_t pixel_width;
2429
2431
2434 uint32_t timescale;
2435
2438
2440
2442
2443 gavl_hw_context_t * hwctx;
2444
2445 gavl_image_orientation_t orientation;
2446
2447 uint32_t fourcc; // Format Specifier (for GAVL_PIXELFORMAT_EXTENDED)
2448
2449 };
2450
2457
2458GAVL_PUBLIC
2460 const gavl_video_format_t * src);
2461
2469
2470GAVL_PUBLIC
2472 const gavl_video_format_t * format_2);
2473
2474
2484
2485GAVL_PUBLIC
2486void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
2487 float * off_x, float * off_y);
2488
2489
2490
2502
2503GAVL_PUBLIC
2505 const gavl_video_format_t * src);
2506
2513
2514GAVL_PUBLIC
2516
2517GAVL_PUBLIC
2518void gavl_video_format_get_frame_layout(const gavl_video_format_t * format,
2519 int * offsets,
2520 int * strides,
2521 int * buffersizes,
2522 int multiplane);
2523
2524
2540
2541GAVL_PUBLIC
2543 int pad_h, int pad_v);
2544
2545
2560
2561GAVL_PUBLIC
2563 gavl_video_format_t * channel_format,
2565
2566
2579
2580GAVL_PUBLIC
2582 gavl_video_format_t * field_format,
2583 int field);
2584
2585
2591
2592GAVL_PUBLIC
2594
2606
2607GAVL_PUBLIC
2608void gavl_video_format_dumpi(const gavl_video_format_t * format, int indent);
2609
2610/* Color channels have a nonstandard order, a separate unshuffle step will be
2611 added unless gavl_video_source_support_shuffle is called */
2612GAVL_PUBLIC
2613int gavl_video_format_has_shuffle(const gavl_video_format_t * format);
2614
2615
2616GAVL_PUBLIC
2617void gavl_video_format_normalize_orientation(gavl_video_format_t * in_format,
2618 gavl_video_format_t * out_format);
2619
2620
2621GAVL_PUBLIC const char *
2622gavl_image_orientation_to_string(gavl_image_orientation_t orient);
2623
2624GAVL_PUBLIC int
2625gavl_image_orientation_is_transposed(gavl_image_orientation_t orient);
2626
2627
2645
2649
2651 {
2654
2656 int64_t timestamp;
2657 int64_t duration;
2660
2661 int dummy; // !< Used to be reference count. Was renamed to keep ABI compatibility
2662
2664 int32_t dst_x;
2665 int32_t dst_y;
2666
2667 gavl_hw_context_t * hwctx;
2668 void * storage;
2669
2670 int buf_idx;
2671 };
2672
2673
2684
2685GAVL_PUBLIC
2686gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t * format);
2687
2697
2698GAVL_PUBLIC
2699gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
2700
2701
2702
2711
2712GAVL_PUBLIC
2713void gavl_video_frame_destroy(gavl_video_frame_t*frame);
2714
2725
2726GAVL_PUBLIC
2727void gavl_video_frame_null(gavl_video_frame_t*frame);
2728
2736
2737GAVL_PUBLIC
2738void gavl_video_frame_clear(gavl_video_frame_t * frame,
2739 const gavl_video_format_t * format);
2740
2749
2750GAVL_PUBLIC
2751void gavl_video_frame_fill(gavl_video_frame_t * frame,
2752 const gavl_video_format_t * format,
2753 const float * color);
2754
2766
2767GAVL_PUBLIC
2768void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
2769 const gavl_video_frame_t * src1,
2770 const gavl_video_frame_t * src2,
2771 const gavl_video_format_t * format);
2772
2784
2785GAVL_PUBLIC
2786void gavl_video_frame_psnr(double * psnr,
2787 const gavl_video_frame_t * src1,
2788 const gavl_video_frame_t * src2,
2789 const gavl_video_format_t * format);
2790
2816
2817GAVL_PUBLIC
2818int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
2819 const gavl_video_frame_t * src2,
2820 gavl_video_frame_t * dst,
2821 const gavl_video_format_t * format);
2822
2835
2836GAVL_PUBLIC
2838 gavl_video_frame_t * dst,
2839 const gavl_video_frame_t * src);
2840
2852
2853GAVL_PUBLIC
2855 gavl_video_frame_t * dst,
2856 const gavl_video_frame_t * src, int plane);
2857
2868
2869GAVL_PUBLIC
2871 gavl_video_frame_t * dst,
2872 const gavl_video_frame_t * src);
2873
2884
2885GAVL_PUBLIC
2887 gavl_video_frame_t * dst,
2888 const gavl_video_frame_t * src);
2889
2900
2901GAVL_PUBLIC
2903 gavl_video_frame_t * dst,
2904 const gavl_video_frame_t * src);
2905
2917
2918GAVL_PUBLIC
2919void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
2920 const gavl_video_frame_t * src);
2921
2922
2939
2940GAVL_PUBLIC
2942 const gavl_video_frame_t * src,
2943 gavl_video_frame_t * dst,
2944 const gavl_rectangle_i_t * src_rect);
2945
2960
2961GAVL_PUBLIC
2963 const gavl_video_frame_t * src,
2964 gavl_video_frame_t * dst,
2965 int field);
2966
2967
2968
2980
2981GAVL_PUBLIC
2982void gavl_video_frame_dump(gavl_video_frame_t * frame,
2983 const gavl_video_format_t * format,
2984 const char * namebase);
2985
2995
2996GAVL_PUBLIC
2998 const gavl_video_frame_t * frame);
2999
3009
3010GAVL_PUBLIC
3011void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
3012 const gavl_video_format_t * format);
3013
3024
3025
3026GAVL_PUBLIC
3027void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
3028 const gavl_video_format_t * format,
3029 uint8_t * buffer);
3030
3041
3042GAVL_PUBLIC
3044 const gavl_video_frame_t * frame);
3045
3046
3060
3061GAVL_PUBLIC
3064 const gavl_video_frame_t * src,
3065 gavl_video_frame_t * dst);
3066
3080
3081
3082GAVL_PUBLIC
3085 const gavl_video_frame_t * src,
3086 gavl_video_frame_t * dst);
3087
3088
3099
3100GAVL_PUBLIC
3102 const gavl_video_frame_t * f1,
3103 const gavl_video_frame_t * f2);
3104
3105GAVL_PUBLIC
3106void gavl_video_frame_normalize_orientation(const gavl_video_format_t * in_format,
3107 const gavl_video_format_t * out_format,
3108 const gavl_video_frame_t * in_frame,
3109 gavl_video_frame_t * out_frame);
3110
3111GAVL_PUBLIC
3112void gavl_video_frame_to_packet_metadata(const gavl_video_frame_t * frame,
3113 gavl_packet_t * pkt);
3114
3115GAVL_PUBLIC
3116void gavl_packet_to_video_frame_metadata(const gavl_packet_t * p, gavl_video_frame_t * frame);
3117
3118GAVL_PUBLIC
3119void gavl_video_frame_set_from_packet(gavl_video_frame_t * frame,
3120 const gavl_video_format_t * format,
3121 gavl_packet_t * p);
3122
3123/*****************************
3124 Conversion options
3125******************************/
3126
3130
3134
3141
3142#define GAVL_FORCE_DEINTERLACE (1<<0)
3143
3147
3148#define GAVL_CONVOLVE_CHROMA (1<<1)
3149
3153
3154#define GAVL_CONVOLVE_NORMALIZE (1<<2)
3155
3162
3163#define GAVL_RESAMPLE_CHROMA (1<<3)
3164
3170
3171#define GAVL_FORCE_SW (1<<4)
3172
3179
3185
3191
3199
3205
3211
3215
3228
3237
3245
3251
3252typedef struct gavl_video_options_s gavl_video_options_t;
3253
3254/* Default Options */
3255
3260
3261GAVL_PUBLIC
3263
3272
3273GAVL_PUBLIC
3275
3281
3282GAVL_PUBLIC
3284 const gavl_video_options_t * src);
3285
3290
3291GAVL_PUBLIC
3293
3294
3308
3309GAVL_PUBLIC
3311 const gavl_rectangle_f_t * src_rect,
3312 const gavl_rectangle_i_t * dst_rect);
3313
3320
3321GAVL_PUBLIC
3323 gavl_rectangle_f_t * src_rect,
3324 gavl_rectangle_i_t * dst_rect);
3325
3331
3332GAVL_PUBLIC
3334
3340
3341GAVL_PUBLIC
3343
3344
3350
3351GAVL_PUBLIC
3353 int conversion_flags);
3354
3360
3361GAVL_PUBLIC
3363
3369
3370GAVL_PUBLIC
3372 gavl_alpha_mode_t alpha_mode);
3373
3379
3380GAVL_PUBLIC gavl_alpha_mode_t
3382
3383
3389
3390GAVL_PUBLIC
3392 gavl_scale_mode_t scale_mode);
3393
3399
3400GAVL_PUBLIC gavl_scale_mode_t
3402
3403
3409
3410GAVL_PUBLIC
3412 int order);
3413
3419
3420GAVL_PUBLIC
3422
3423
3429
3430GAVL_PUBLIC
3432 const double * color);
3433
3439
3440GAVL_PUBLIC
3442 double * color);
3443
3449
3450GAVL_PUBLIC
3452 gavl_deinterlace_mode_t deinterlace_mode);
3453
3459
3460GAVL_PUBLIC gavl_deinterlace_mode_t
3462
3468
3469GAVL_PUBLIC
3471 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
3472
3478
3481
3489
3490GAVL_PUBLIC
3493
3494
3502
3503GAVL_PUBLIC gavl_downscale_filter_t
3505
3522
3523GAVL_PUBLIC
3525 float f);
3526
3534
3535GAVL_PUBLIC
3537
3538/* Set an externally created thread pool. If this is not called, a private thread pool will be created if needed.
3539 This function has the advantage that one thread pool can be shared among different elements of a video
3540 pipeline, which will reduce the overhead */
3541
3542GAVL_PUBLIC
3543void gavl_video_options_set_thread_pool(gavl_video_options_t * opt, gavl_thread_pool_t * tp);
3544
3545GAVL_PUBLIC
3546gavl_thread_pool_t * gavl_video_options_get_thread_pool(const gavl_video_options_t * opt);
3547
3548/***************************************************
3549 * Create and destroy video converters
3550 ***************************************************/
3551
3577
3583
3584typedef struct gavl_video_converter_s gavl_video_converter_t;
3585
3590
3591GAVL_PUBLIC
3593
3598
3599GAVL_PUBLIC
3601
3602/**************************************************
3603 * Get options. Change the options with the gavl_video_options_set_*
3604 * functions above
3605 **************************************************/
3606
3614
3615GAVL_PUBLIC gavl_video_options_t *
3617
3618
3631
3632GAVL_PUBLIC
3634 const gavl_video_format_t * input_format,
3635 const gavl_video_format_t * output_format);
3636
3648
3649GAVL_PUBLIC
3651
3652
3653/***************************************************
3654 * Convert a frame
3655 ***************************************************/
3656
3663
3664GAVL_PUBLIC
3666 const gavl_video_frame_t * input_frame,
3667 gavl_video_frame_t * output_frame);
3668
3669
3694
3700
3701typedef struct gavl_video_scaler_s gavl_video_scaler_t;
3702
3707
3708GAVL_PUBLIC
3710
3715
3716GAVL_PUBLIC
3718
3726
3727GAVL_PUBLIC gavl_video_options_t *
3729
3740
3741
3742GAVL_PUBLIC
3744 const gavl_video_format_t * src_format,
3745 const gavl_video_format_t * dst_format);
3746
3766
3767
3768GAVL_PUBLIC
3770 const gavl_video_format_t * format,
3771 int h_radius, const float * h_coeffs,
3772 int v_radius, const float * v_coeffs);
3773
3780
3781GAVL_PUBLIC
3783 const gavl_video_frame_t * input_frame,
3784 gavl_video_frame_t * output_frame);
3785
3793
3799
3800
3801typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
3802
3807
3808GAVL_PUBLIC
3810
3815
3816GAVL_PUBLIC
3818
3826
3827GAVL_PUBLIC gavl_video_options_t *
3829
3839
3840GAVL_PUBLIC
3842 const gavl_video_format_t * src_format);
3843
3844
3851
3852GAVL_PUBLIC
3854 const gavl_video_frame_t * input_frame,
3855 gavl_video_frame_t * output_frame);
3856
3857
3858
3859/**************************************************
3860 * Transparent overlays
3861 **************************************************/
3862
3863/* Overlay struct */
3864
3884
3891
3892typedef gavl_video_frame_t gavl_overlay_t;
3893
3899
3900typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
3901
3906
3907GAVL_PUBLIC
3909
3914
3915GAVL_PUBLIC
3917
3923
3924GAVL_PUBLIC gavl_video_options_t *
3926
3941
3942GAVL_PUBLIC
3944 const gavl_video_format_t * frame_format,
3945 gavl_video_format_t * overlay_format);
3946
3955
3956GAVL_PUBLIC
3958 gavl_overlay_t * ovl);
3959
3965
3966GAVL_PUBLIC
3968 gavl_video_frame_t * dst_frame);
3969
3975
3976GAVL_PUBLIC gavl_video_sink_t *
3978
3994
3999
4000typedef struct gavl_image_transform_s gavl_image_transform_t;
4001
4014
4015typedef void (*gavl_image_transform_func)(void * priv,
4016 double xdst,
4017 double ydst,
4018 double * xsrc,
4019 double * ysrc);
4020
4021
4027
4028GAVL_PUBLIC
4030
4035
4036GAVL_PUBLIC
4038
4055
4056
4057GAVL_PUBLIC
4059 gavl_video_format_t * format,
4060 gavl_image_transform_func func, void * priv);
4061
4068
4069GAVL_PUBLIC
4071 gavl_video_frame_t * in_frame,
4072 gavl_video_frame_t * out_frame);
4073
4083
4084GAVL_PUBLIC gavl_video_options_t *
4086
4090
4103
4108
4109typedef struct
4110 {
4111 int64_t offset;
4112 /* Primary */
4113 int64_t num_entries;
4115
4116 struct
4117 {
4118 int64_t num_frames;
4119 int64_t duration;
4120 } * entries;
4121
4124
4125 struct
4126 {
4127 int64_t pts;
4129 } * timecodes;
4130
4131 /* Secondary */
4132
4134
4141
4151
4152GAVL_PUBLIC gavl_frame_table_t *
4153gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
4154 gavl_timecode_format_t * fmt_ret);
4155
4165
4166GAVL_PUBLIC gavl_frame_table_t *
4167gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
4168 int64_t num_frames,
4169 gavl_timecode_t start_timecode);
4170
4177
4178GAVL_PUBLIC gavl_frame_table_t *
4180
4181
4182
4188
4190
4197
4198GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
4199
4207
4208GAVL_PUBLIC void
4210 int64_t pts, gavl_timecode_t tc);
4211
4221
4222GAVL_PUBLIC int64_t
4224 int64_t frame, int * duration);
4225
4235
4236GAVL_PUBLIC int64_t
4238 int64_t time,
4239 int64_t * start_time);
4240
4250
4251GAVL_PUBLIC gavl_timecode_t
4253 int64_t time,
4254 int64_t * start_time,
4255 const gavl_timecode_format_t * fmt);
4256
4265
4266GAVL_PUBLIC int64_t
4268 gavl_timecode_t tc,
4269 const gavl_timecode_format_t * fmt);
4270
4271
4281
4282GAVL_PUBLIC gavl_timecode_t
4284 int64_t frame,
4285 int64_t * start_time,
4286 const gavl_timecode_format_t * fmt);
4287
4288
4289
4296
4297GAVL_PUBLIC int64_t
4299
4306
4307GAVL_PUBLIC int64_t
4309
4316
4317GAVL_PUBLIC int64_t
4319
4327
4328GAVL_PUBLIC
4330 const char * filename);
4331
4338
4339GAVL_PUBLIC
4341
4347
4348GAVL_PUBLIC void
4350
4354
4355
4356/* Debayer routines */
4357
4358#define GAVL_BAYER_GREEN_FIRST (1<<0)
4359#define GAVL_BAYER_BLUE_LINE (1<<1)
4360
4361// GB
4362// RG
4363#define GAVL_BAYER_GBRG (GAVL_BAYER_GREEN_FIRST|GAVL_BAYER_BLUE_LINE)
4364
4365// GR
4366// BG
4367#define GAVL_BAYER_GRBG (GAVL_BAYER_GREEN_FIRST)
4368
4369// BG
4370// GR
4371#define GAVL_BAYER_BGGR (GAVL_BAYER_BLUE_LINE)
4372
4373// RG
4374// GB
4375#define GAVL_BAYER_RGGB 0
4376
4377GAVL_PUBLIC
4378void gavl_video_frame_debayer(gavl_video_options_t * opt,
4379 gavl_video_frame_t * src, gavl_video_frame_t * dst,
4380 int bayer_format, gavl_video_format_t * dst_format);
4381
4382
4386
4387
4388#ifdef __cplusplus
4389}
4390#endif
4391
4392#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.
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:3892
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:3900
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:3584
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:3801
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:2263
#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:2304
gavl_pixelformat_e
Pixelformat definition.
Definition gavl.h:1826
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:1965
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:2345
#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:2013
#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.
#define GAVL_PIXFMT_EXTENDED
Definition gavl.h:1818
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:2266
@ GAVL_CHROMA_PLACEMENT_MPEG2
Definition gavl.h:2265
@ GAVL_CHROMA_PLACEMENT_DEFAULT
Definition gavl.h:2264
@ GAVL_FRAMERATE_UNKNOWN
Definition gavl.h:2305
@ GAVL_FRAMERATE_CONSTANT
Definition gavl.h:2306
@ GAVL_FRAMERATE_STILL
Definition gavl.h:2308
@ GAVL_FRAMERATE_VARIABLE
Definition gavl.h:2307
@ GAVL_YUVJ_420_P
Definition gavl.h:1940
@ GAVL_YUV_422_P
Definition gavl.h:1927
@ GAVL_BGR_24
Definition gavl.h:1876
@ GAVL_YUV_410_P
Definition gavl.h:1936
@ GAVL_RGB_48
Definition gavl.h:1889
@ GAVL_RGB_32
Definition gavl.h:1879
@ GAVL_YUV_420_P
Definition gavl.h:1924
@ GAVL_GRAYA_32
Definition gavl.h:1849
@ GAVL_YUVA_32
Definition gavl.h:1909
@ GAVL_RGB_16
Definition gavl.h:1866
@ GAVL_UYVY
Definition gavl.h:1906
@ GAVL_YUV_422_P_16
Definition gavl.h:1953
@ GAVL_YUV_444_P
Definition gavl.h:1930
@ GAVL_RGB_FLOAT
Definition gavl.h:1896
@ GAVL_YUVJ_422_P
Definition gavl.h:1943
@ GAVL_GRAY_8
Definition gavl.h:1833
@ GAVL_RGB_24
Definition gavl.h:1873
@ GAVL_RGBA_64
Definition gavl.h:1892
@ GAVL_YUY2
Definition gavl.h:1903
@ GAVL_YUVA_FLOAT
Definition gavl.h:1919
@ GAVL_YUVJ_444_P
Definition gavl.h:1946
@ GAVL_GRAYA_FLOAT
Definition gavl.h:1853
@ GAVL_BGR_15
Definition gavl.h:1862
@ GAVL_YUV_444_P_16
Definition gavl.h:1950
@ GAVL_PIXELFORMAT_NONE
Undefined.
Definition gavl.h:1829
@ GAVL_GRAYA_16
Definition gavl.h:1845
@ GAVL_YUV_411_P
Definition gavl.h:1933
@ GAVL_GRAY_FLOAT
Definition gavl.h:1841
@ GAVL_YUV_FLOAT
Definition gavl.h:1915
@ GAVL_RGBA_32
Definition gavl.h:1885
@ GAVL_GRAY_16
Definition gavl.h:1837
@ GAVL_BGR_16
Definition gavl.h:1870
@ GAVL_YUVA_64
Definition gavl.h:1912
@ GAVL_RGB_15
Definition gavl.h:1858
@ GAVL_RGBA_FLOAT
Definition gavl.h:1899
@ GAVL_BGR_32
Definition gavl.h:1882
@ GAVL_INTERLACE_MIXED_BOTTOM
Definition gavl.h:2352
@ GAVL_INTERLACE_MIXED_TOP
Definition gavl.h:2351
@ GAVL_INTERLACE_NONE
Definition gavl.h:2347
@ GAVL_INTERLACE_BOTTOM_FIRST
Definition gavl.h:2349
@ GAVL_INTERLACE_UNKNOWN
Definition gavl.h:2346
@ GAVL_INTERLACE_MIXED
Definition gavl.h:2350
@ GAVL_INTERLACE_TOP_FIRST
Definition gavl.h:2348
@ GAVL_CCH_NONE
None/undefined.
Definition gavl.h:2014
@ GAVL_CCH_Y
Luminance (also grayscale).
Definition gavl.h:2018
@ GAVL_CCH_RED
Red.
Definition gavl.h:2015
@ GAVL_CCH_CR
Chrominance red (aka V).
Definition gavl.h:2020
@ GAVL_CCH_GREEN
Green.
Definition gavl.h:2016
@ GAVL_CCH_ALPHA
Transparency (or, to be more precise opacity).
Definition gavl.h:2021
@ GAVL_CCH_CB
Chrominance blue (aka U).
Definition gavl.h:2019
@ GAVL_CCH_BLUE
Blue.
Definition gavl.h:2017
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:3193
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:3207
struct gavl_video_options_s gavl_video_options_t
Definition gavl.h:3252
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:3181
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:3217
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:3239
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:3194
@ GAVL_DEINTERLACE_SCALE
Definition gavl.h:3196
@ GAVL_DEINTERLACE_BLEND
Definition gavl.h:3197
@ GAVL_DEINTERLACE_COPY
Definition gavl.h:3195
@ GAVL_DEINTERLACE_DROP_TOP
Definition gavl.h:3208
@ GAVL_DEINTERLACE_DROP_BOTTOM
Definition gavl.h:3209
@ GAVL_ALPHA_IGNORE
Definition gavl.h:3182
@ GAVL_ALPHA_BLEND_COLOR
Definition gavl.h:3183
@ GAVL_SCALE_NONE
Definition gavl.h:3226
@ GAVL_SCALE_NEAREST
Definition gavl.h:3219
@ GAVL_SCALE_CUBIC_MITCHELL
Definition gavl.h:3223
@ GAVL_SCALE_AUTO
Definition gavl.h:3218
@ GAVL_SCALE_SINC_LANCZOS
Definition gavl.h:3225
@ GAVL_SCALE_CUBIC_CATMULL
Definition gavl.h:3224
@ GAVL_SCALE_CUBIC_BSPLINE
Definition gavl.h:3222
@ GAVL_SCALE_QUADRATIC
Definition gavl.h:3221
@ GAVL_SCALE_BILINEAR
Definition gavl.h:3220
@ GAVL_DOWNSCALE_FILTER_AUTO
Auto selection based on quality.
Definition gavl.h:3240
@ GAVL_DOWNSCALE_FILTER_NONE
Fastest method, might produce heavy aliasing artifacts.
Definition gavl.h:3241
@ GAVL_DOWNSCALE_FILTER_WIDE
Widen the filter curve according to the scaling ratio.
Definition gavl.h:3242
@ GAVL_DOWNSCALE_FILTER_GAUSS
Do a Gaussian preblur.
Definition gavl.h:3243
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:3701
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:4000
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:4015
#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:4110
int num_timecodes
Number of timecodes.
Definition gavl.h:4122
int64_t offset
Timestamp of the first frame.
Definition gavl.h:4111
int64_t entries_alloc
Number of allocated entries (never touch this).
Definition gavl.h:4114
int64_t num_entries
Number of entries.
Definition gavl.h:4113
int timecodes_alloc
Number of allocated timecodes (never touch this).
Definition gavl.h:4123
Packet structure.
Definition compression.h:425
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:2418
uint32_t frame_height
Definition gavl.h:2420
gavl_chroma_placement_t chroma_placement
Definition gavl.h:2437
gavl_hw_context_t * hwctx
Handle for accessing the frames. If NULL, frames are in regular RAM.
Definition gavl.h:2443
uint32_t image_height
Definition gavl.h:2423
uint32_t pixel_height
Definition gavl.h:2428
uint32_t frame_width
Definition gavl.h:2419
uint32_t image_width
Definition gavl.h:2422
uint32_t timescale
Definition gavl.h:2434
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2439
gavl_framerate_mode_t framerate_mode
Definition gavl.h:2436
gavl_pixelformat_t pixelformat
Definition gavl.h:2430
uint32_t pixel_width
Definition gavl.h:2427
gavl_timecode_format_t timecode_format
Definition gavl.h:2441
uint32_t frame_duration
Definition gavl.h:2432
Definition gavl.h:2651
uint8_t * planes[GAVL_MAX_PLANES]
Definition gavl.h:2652
int64_t duration
Definition gavl.h:2657
int strides[GAVL_MAX_PLANES]
Definition gavl.h:2653
void * client_data
Definition gavl.h:2655
int32_t dst_y
y offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2665
void * storage
Definition gavl.h:2668
int64_t timestamp
Definition gavl.h:2656
int32_t dst_x
x offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2664
gavl_rectangle_i_t src_rect
Valid rectangle in this frame (since 1.5.0) *‍/.
Definition gavl.h:2663
gavl_hw_context_t * hwctx
Handle for accessing the frame.
Definition gavl.h:2667
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2658
gavl_timecode_t timecode
Definition gavl.h:2659
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