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
107
111
112
113
114/* Quality levels */
115
129
130
131
138
139#define GAVL_QUALITY_FASTEST 1
140
146
147#define GAVL_QUALITY_BEST 5
148
154
155#define GAVL_QUALITY_DEFAULT 2
156
167
168#define GAVL_ACCEL_MMX (1<<0)
169#define GAVL_ACCEL_MMXEXT (1<<1)
170#define GAVL_ACCEL_SSE (1<<2)
171#define GAVL_ACCEL_SSE2 (1<<3)
172#define GAVL_ACCEL_SSE3 (1<<4)
173#define GAVL_ACCEL_3DNOW (1<<5)
174#define GAVL_ACCEL_3DNOWEXT (1<<6)
175#define GAVL_ACCEL_SSSE3 (1<<7)
176#define GAVL_ACCEL_AVX (1<<8)
177#define GAVL_ACCEL_AVX2 (1<<9)
178#define GAVL_ACCEL_NEON (1<<10)
179
183
184GAVL_PUBLIC int gavl_accel_supported(void);
185
189
193
194/* Sample formats: all multibyte numbers are native endian */
195
201
202
208#define GAVL_MAX_CHANNELS 128
209
215
227
232
239
246
263
271
286
287
288/* Audio format -> string conversions */
289
296
297GAVL_PUBLIC
299
306
307GAVL_PUBLIC
309
317
318GAVL_PUBLIC
320
327
328GAVL_PUBLIC
330
331
336
337GAVL_PUBLIC
339
345
346GAVL_PUBLIC
348
355
356GAVL_PUBLIC
358
365
366GAVL_PUBLIC
368
375
376GAVL_PUBLIC
378
379
380
387
388GAVL_PUBLIC
390
397
398GAVL_PUBLIC
400
407
408GAVL_PUBLIC
410
416
417GAVL_PUBLIC
419
420GAVL_PUBLIC
421int gavl_audio_format_buffer_size(const gavl_audio_format_t * format);
422
423
435
436GAVL_PUBLIC
437void gavl_audio_format_dumpi(const gavl_audio_format_t * format, int indent);
438
446
447GAVL_PUBLIC
449
455
456GAVL_PUBLIC
458
464
465GAVL_PUBLIC
467
473
474GAVL_PUBLIC
476
482
483GAVL_PUBLIC
485
486
487
493
494GAVL_PUBLIC
496
503
504GAVL_PUBLIC
506 const gavl_audio_format_t * src);
507
515
516GAVL_PUBLIC
518 const gavl_audio_format_t * format_2);
519
530
531GAVL_PUBLIC
533
539
540GAVL_PUBLIC
542
552
553GAVL_PUBLIC
554int gavl_nearest_samplerate(int in_rate, const int * supported);
555
556
564
565
570
571typedef union
572 {
573 uint8_t * u_8;
574 int8_t * s_8;
575
576 uint16_t * u_16;
577 int16_t * s_16;
578
579 uint32_t * u_32;
580 int32_t * s_32;
581
582 float * f;
583 double * d;
585
590
591typedef union
592 {
595
598
601
604
606
622
633
644
645GAVL_PUBLIC
647
658
659GAVL_PUBLIC
661
670
671GAVL_PUBLIC
673
682
683GAVL_PUBLIC
685 const gavl_audio_format_t * format);
686
696
697GAVL_PUBLIC
699 const gavl_audio_format_t * format,
700 int num_samples);
701
702
703
713
714GAVL_PUBLIC
716 const gavl_audio_format_t * format,
717 int channel);
718
738
739GAVL_PUBLIC
741 gavl_audio_frame_t * dst,
742 const gavl_audio_frame_t * src,
743 int dst_pos,
744 int src_pos,
745 int dst_size,
746 int src_size);
747
759
760GAVL_PUBLIC
762 gavl_audio_frame_t * dst,
763 const gavl_audio_frame_t * src);
764
780
781
782GAVL_PUBLIC
784 gavl_audio_frame_t * src,
785 gavl_audio_frame_t * dst,
786 int start, int len);
787
798
799
800GAVL_PUBLIC
802 const gavl_audio_frame_t * f1,
803 const gavl_audio_frame_t * f2);
804
814
815
816GAVL_PUBLIC
818 const gavl_audio_frame_t * f);
819
820
830
831GAVL_PUBLIC
833 const gavl_audio_format_t * format,
834 uint8_t * data);
843
844GAVL_PUBLIC
846 const gavl_audio_format_t * format,
847 uint8_t * data, int len);
848
849
850GAVL_PUBLIC
851void gavl_audio_frame_to_packet_metadata(const gavl_audio_frame_t * frame,
852 gavl_packet_t * pkt);
853
854GAVL_PUBLIC
855void gavl_packet_to_audio_frame_metadata(const gavl_packet_t * p, gavl_audio_frame_t * frame);
856
857GAVL_PUBLIC
858void gavl_audio_frame_set_from_packet(gavl_audio_frame_t * frame,
859 const gavl_audio_format_t * format,
860 gavl_packet_t * p);
861
862
863
880
881
882GAVL_PUBLIC
884 gavl_audio_frame_t * f, int num_samples);
885
886
905
906GAVL_PUBLIC
908 const gavl_audio_frame_t * frame,
909 const char * name_base);
910
911
916
922
925
926#define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
927
930
931#define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
932
935
936#define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
937
940
941#define GAVL_AUDIO_FRONT_TO_REAR_MASK \
942(GAVL_AUDIO_FRONT_TO_REAR_COPY | \
943GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
944 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
945
946/* Options for mixing stereo to mono */
947
950#define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
953#define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
956#define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
957
960#define GAVL_AUDIO_STEREO_TO_MONO_MASK \
961(GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
962GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
963GAVL_AUDIO_STEREO_TO_MONO_MIX)
964
967
968#define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
969
970
974
975typedef enum
976 {
977 GAVL_AUDIO_DITHER_NONE = 0,
978 GAVL_AUDIO_DITHER_AUTO = 1,
979 GAVL_AUDIO_DITHER_RECT = 2,
980 GAVL_AUDIO_DITHER_TRI = 3,
981 GAVL_AUDIO_DITHER_SHAPED = 4,
983
987
997
1003
1004typedef struct gavl_audio_options_s gavl_audio_options_t;
1005
1011
1012GAVL_PUBLIC
1014
1020
1021GAVL_PUBLIC
1023
1029
1030GAVL_PUBLIC
1032
1038
1039GAVL_PUBLIC
1042
1043
1049
1050GAVL_PUBLIC
1052
1058
1059GAVL_PUBLIC
1062
1068
1069GAVL_PUBLIC
1071 int flags);
1072
1078
1079GAVL_PUBLIC
1081
1086
1087GAVL_PUBLIC
1089
1105
1106GAVL_PUBLIC
1108 const double ** matrix);
1109
1117
1118GAVL_PUBLIC
1119const double **
1121
1130
1131GAVL_PUBLIC
1133
1139
1140GAVL_PUBLIC
1142 const gavl_audio_options_t * src);
1143
1148
1149GAVL_PUBLIC
1151
1152
1153
1154/* Audio converter */
1155
1182
1188
1189typedef struct gavl_audio_converter_s gavl_audio_converter_t;
1190
1195
1196GAVL_PUBLIC
1198
1203
1204GAVL_PUBLIC
1206
1214
1215GAVL_PUBLIC
1217
1218
1232
1233GAVL_PUBLIC
1235 const gavl_audio_format_t * input_format,
1236 const gavl_audio_format_t * output_format);
1237
1251
1252GAVL_PUBLIC
1254 const gavl_audio_format_t * format);
1255
1268
1269
1270GAVL_PUBLIC
1272
1273
1286
1287GAVL_PUBLIC
1289 const gavl_audio_frame_t * input_frame,
1290 gavl_audio_frame_t * output_frame);
1291
1292
1310
1311GAVL_PUBLIC
1313 double ratio ) ;
1314
1315
1330
1331GAVL_PUBLIC
1333 gavl_audio_frame_t * input_frame,
1334 gavl_audio_frame_t * output_frame,
1335 double ratio);
1336
1337
1344
1350
1351typedef struct gavl_volume_control_s gavl_volume_control_t;
1352
1353/* Create / destroy */
1354
1359
1360GAVL_PUBLIC
1362
1367
1368GAVL_PUBLIC
1370
1377
1378GAVL_PUBLIC
1380 const gavl_audio_format_t * format);
1381
1387
1388GAVL_PUBLIC
1390 float volume);
1391
1397
1398GAVL_PUBLIC
1400 gavl_audio_frame_t * frame);
1401
1409
1410GAVL_PUBLIC
1411int gavl_volume_to_int(float volume, float one, int steps);
1412
1420
1421GAVL_PUBLIC
1422float gavl_volume_to_float(int volume, float one, int steps);
1423
1428
1432
1433#define GAVL_MAX_PLANES 4
1434
1440
1444
1445typedef struct
1446 {
1447 int32_t x;
1448 int32_t y;
1449 int32_t w;
1450 int32_t h;
1452
1456
1457typedef struct
1458 {
1459 double x;
1460 double y;
1461 double w;
1462 double h;
1464
1465GAVL_PUBLIC
1466void gavl_rectangle_i_init(gavl_rectangle_i_t * r);
1467
1468GAVL_PUBLIC
1469void gavl_rectangle_f_init(gavl_rectangle_f_t * r);
1470
1471
1477
1478GAVL_PUBLIC
1480 const gavl_video_format_t * format);
1481
1487
1488GAVL_PUBLIC
1490 const gavl_video_format_t * format);
1491
1505
1506GAVL_PUBLIC
1508 gavl_rectangle_i_t * dst_rect,
1509 const gavl_video_format_t * src_format,
1510 const gavl_video_format_t * dst_format);
1511
1522
1523GAVL_PUBLIC
1525 gavl_rectangle_i_t * dst_rect,
1526 const gavl_video_format_t * src_format,
1527 const gavl_video_format_t * dst_format);
1528
1529GAVL_PUBLIC
1530void gavl_rectangle_crop_to_format_scale_f(gavl_rectangle_f_t * src_rect,
1531 gavl_rectangle_f_t * dst_rect,
1532 const gavl_video_format_t * src_format,
1533 const gavl_video_format_t * dst_format);
1534
1535
1536
1537
1543
1544GAVL_PUBLIC
1546
1552
1553GAVL_PUBLIC
1555
1561
1562GAVL_PUBLIC
1564
1570
1571GAVL_PUBLIC
1573
1579
1580GAVL_PUBLIC
1582
1588
1589GAVL_PUBLIC
1591
1597
1598GAVL_PUBLIC
1600
1606
1607GAVL_PUBLIC
1609
1615
1616GAVL_PUBLIC
1618
1624
1625GAVL_PUBLIC
1627
1640
1641GAVL_PUBLIC
1642void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
1643
1652
1653GAVL_PUBLIC
1655 const gavl_video_format_t * format);
1656
1657
1663
1664GAVL_PUBLIC
1666
1672
1673GAVL_PUBLIC
1675
1676
1677
1683
1684GAVL_PUBLIC
1686
1692
1693GAVL_PUBLIC
1695
1703
1704GAVL_PUBLIC
1706
1714
1715GAVL_PUBLIC
1717
1744
1745GAVL_PUBLIC
1747 const gavl_video_format_t * src_format,
1748 const gavl_rectangle_f_t * src_rect,
1749 const gavl_video_format_t * dst_format,
1750 float zoom, float squeeze);
1751
1752GAVL_PUBLIC
1753void gavl_rectangle_fit_aspect_f(gavl_rectangle_f_t * r,
1754 const gavl_video_format_t * src_format,
1755 const gavl_rectangle_f_t * src_rect,
1756 const gavl_video_format_t * dst_format,
1757 float zoom, float squeeze, int do_orient);
1758
1759
1764GAVL_PUBLIC
1766
1771GAVL_PUBLIC
1773
1774
1780
1784#define GAVL_PIXFMT_PLANAR (1<<8)
1785
1789#define GAVL_PIXFMT_RGB (1<<9)
1790
1794#define GAVL_PIXFMT_YUV (1<<10)
1795
1799#define GAVL_PIXFMT_YUVJ (1<<11)
1800
1804#define GAVL_PIXFMT_ALPHA (1<<12)
1805
1809#define GAVL_PIXFMT_GRAY (1<<13)
1810
1814
1816 {
1820
1824
1828
1832
1836
1840
1844
1876
1883
1890
1898
1901
1906
1910
1913
1927
1937
1944
1945 };
1946
1950
1952
1955#define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
1958#define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
1961#define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
1964#define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
1965
1968#define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
1971#define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
1974#define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
1977#define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
1978
1981#define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
1984#define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
1987#define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
1990#define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
1991
1997
2009
2010/*
2011 * Colormodel related functions
2012 */
2013
2019
2020#define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
2021
2022
2028
2029#define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
2030
2036
2037#define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
2038
2044
2045#define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
2046
2052
2053#define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
2054
2060
2061#define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
2062
2063
2069
2070GAVL_PUBLIC
2072
2079
2080GAVL_PUBLIC gavl_color_channel_t
2082
2083
2089
2090GAVL_PUBLIC
2092
2101
2102GAVL_PUBLIC
2103void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
2104
2110
2111GAVL_PUBLIC
2113
2119
2120GAVL_PUBLIC
2122
2128
2129GAVL_PUBLIC
2131
2145
2146GAVL_PUBLIC
2148 gavl_pixelformat_t dst);
2149
2162
2163GAVL_PUBLIC gavl_pixelformat_t
2165 const gavl_pixelformat_t * dst_supported,
2166 int * penalty);
2167
2168
2169
2175
2176GAVL_PUBLIC
2178
2187
2188GAVL_PUBLIC
2190
2191
2197
2198GAVL_PUBLIC
2200
2206
2207GAVL_PUBLIC
2209
2215
2216GAVL_PUBLIC
2218
2219
2220
2225
2226GAVL_PUBLIC
2228
2234
2235GAVL_PUBLIC
2237
2238/* */
2239
2247
2254
2260
2261GAVL_PUBLIC
2263
2269
2270GAVL_PUBLIC
2272
2278
2279GAVL_PUBLIC
2281
2282
2286
2287/* Changing the values alters the gmerlin-avdecoder index format */
2288
2296
2302
2303GAVL_PUBLIC
2305
2311
2312GAVL_PUBLIC
2314
2320
2321GAVL_PUBLIC
2323
2327
2328/* Changing the values alters the gmerlin-avdecoder index format */
2329
2340
2346
2347GAVL_PUBLIC
2349
2355
2356GAVL_PUBLIC
2358
2364
2365GAVL_PUBLIC
2367
2375
2376GAVL_PUBLIC
2378
2379#include <gavl/hw.h> // Needs forward declarations
2380
2381/* Video format structure */
2382
2383#define GAVL_IMAGE_ORIENT_FLIP_H (1<<2)
2384
2385typedef enum
2386 {
2387
2388 GAVL_IMAGE_ORIENT_NORMAL = 0, // EXIF: 1
2389 GAVL_IMAGE_ORIENT_ROT90_CW = 1, // EXIF: 8
2390 GAVL_IMAGE_ORIENT_ROT180_CW = 2, // EXIF: 3
2391 GAVL_IMAGE_ORIENT_ROT270_CW = 3, // EXIF: 6
2392
2393 GAVL_IMAGE_ORIENT_FH = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_NORMAL), // EXIF: 2
2394 GAVL_IMAGE_ORIENT_FH_ROT90_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT90_CW), // EXIF: 7
2395 GAVL_IMAGE_ORIENT_FH_ROT180_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT180_CW), // EXIF: 4
2396 GAVL_IMAGE_ORIENT_FH_ROT270_CW = (GAVL_IMAGE_ORIENT_FLIP_H | GAVL_IMAGE_ORIENT_ROT270_CW), // EXIF: 5
2397
2398 } gavl_image_orientation_t;
2399
2403
2405 {
2406 uint32_t frame_width;
2408
2409 uint32_t image_width;
2411
2412 /* Support for nonsquare pixels */
2413
2414 uint32_t pixel_width;
2416
2418
2421 uint32_t timescale;
2422
2425
2427
2429
2430 gavl_hw_context_t * hwctx;
2431
2432 gavl_image_orientation_t orientation;
2433 };
2434
2441
2442GAVL_PUBLIC
2444 const gavl_video_format_t * src);
2445
2453
2454GAVL_PUBLIC
2456 const gavl_video_format_t * format_2);
2457
2458
2468
2469GAVL_PUBLIC
2470void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
2471 float * off_x, float * off_y);
2472
2473
2474
2486
2487GAVL_PUBLIC
2489 const gavl_video_format_t * src);
2490
2497
2498GAVL_PUBLIC
2500
2501GAVL_PUBLIC
2502void gavl_video_format_get_frame_layout(const gavl_video_format_t * format,
2503 int * offsets,
2504 int * strides,
2505 int * buffersizes,
2506 int multiplane);
2507
2508
2524
2525GAVL_PUBLIC
2527 int pad_h, int pad_v);
2528
2529
2544
2545GAVL_PUBLIC
2547 gavl_video_format_t * channel_format,
2549
2550
2563
2564GAVL_PUBLIC
2566 gavl_video_format_t * field_format,
2567 int field);
2568
2569
2575
2576GAVL_PUBLIC
2578
2590
2591GAVL_PUBLIC
2592void gavl_video_format_dumpi(const gavl_video_format_t * format, int indent);
2593
2594GAVL_PUBLIC
2595void gavl_video_format_normalize_orientation(gavl_video_format_t * in_format,
2596 gavl_video_format_t * out_format);
2597
2598
2599GAVL_PUBLIC const char *
2600gavl_image_orientation_to_string(gavl_image_orientation_t orient);
2601
2602GAVL_PUBLIC int
2603gavl_image_orientation_is_transposed(gavl_image_orientation_t orient);
2604
2605
2623
2627
2629 {
2632
2634 int64_t timestamp;
2635 int64_t duration;
2638
2639 int dummy; // !< Used to be reference count. Was renamed to keep ABI compatibility
2640
2642 int32_t dst_x;
2643 int32_t dst_y;
2644
2645 gavl_hw_context_t * hwctx;
2646 void * storage;
2647
2648 int buf_idx;
2649 };
2650
2651
2662
2663GAVL_PUBLIC
2664gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t * format);
2665
2675
2676GAVL_PUBLIC
2677gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
2678
2679
2680
2689
2690GAVL_PUBLIC
2691void gavl_video_frame_destroy(gavl_video_frame_t*frame);
2692
2703
2704GAVL_PUBLIC
2705void gavl_video_frame_null(gavl_video_frame_t*frame);
2706
2714
2715GAVL_PUBLIC
2716void gavl_video_frame_clear(gavl_video_frame_t * frame,
2717 const gavl_video_format_t * format);
2718
2727
2728GAVL_PUBLIC
2729void gavl_video_frame_fill(gavl_video_frame_t * frame,
2730 const gavl_video_format_t * format,
2731 const float * color);
2732
2744
2745GAVL_PUBLIC
2746void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
2747 const gavl_video_frame_t * src1,
2748 const gavl_video_frame_t * src2,
2749 const gavl_video_format_t * format);
2750
2762
2763GAVL_PUBLIC
2764void gavl_video_frame_psnr(double * psnr,
2765 const gavl_video_frame_t * src1,
2766 const gavl_video_frame_t * src2,
2767 const gavl_video_format_t * format);
2768
2794
2795GAVL_PUBLIC
2796int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
2797 const gavl_video_frame_t * src2,
2798 gavl_video_frame_t * dst,
2799 const gavl_video_format_t * format);
2800
2813
2814GAVL_PUBLIC
2816 gavl_video_frame_t * dst,
2817 const gavl_video_frame_t * src);
2818
2830
2831GAVL_PUBLIC
2833 gavl_video_frame_t * dst,
2834 const gavl_video_frame_t * src, int plane);
2835
2846
2847GAVL_PUBLIC
2849 gavl_video_frame_t * dst,
2850 const gavl_video_frame_t * src);
2851
2862
2863GAVL_PUBLIC
2865 gavl_video_frame_t * dst,
2866 const gavl_video_frame_t * src);
2867
2878
2879GAVL_PUBLIC
2881 gavl_video_frame_t * dst,
2882 const gavl_video_frame_t * src);
2883
2895
2896GAVL_PUBLIC
2897void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
2898 const gavl_video_frame_t * src);
2899
2900
2917
2918GAVL_PUBLIC
2920 const gavl_video_frame_t * src,
2921 gavl_video_frame_t * dst,
2922 const gavl_rectangle_i_t * src_rect);
2923
2938
2939GAVL_PUBLIC
2941 const gavl_video_frame_t * src,
2942 gavl_video_frame_t * dst,
2943 int field);
2944
2945
2946
2958
2959GAVL_PUBLIC
2960void gavl_video_frame_dump(gavl_video_frame_t * frame,
2961 const gavl_video_format_t * format,
2962 const char * namebase);
2963
2973
2974GAVL_PUBLIC
2976 const gavl_video_frame_t * frame);
2977
2987
2988GAVL_PUBLIC
2989void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
2990 const gavl_video_format_t * format);
2991
3002
3003
3004GAVL_PUBLIC
3005void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
3006 const gavl_video_format_t * format,
3007 uint8_t * buffer);
3008
3019
3020GAVL_PUBLIC
3022 const gavl_video_frame_t * frame);
3023
3024
3038
3039GAVL_PUBLIC
3042 const gavl_video_frame_t * src,
3043 gavl_video_frame_t * dst);
3044
3058
3059
3060GAVL_PUBLIC
3063 const gavl_video_frame_t * src,
3064 gavl_video_frame_t * dst);
3065
3066
3077
3078GAVL_PUBLIC
3080 const gavl_video_frame_t * f1,
3081 const gavl_video_frame_t * f2);
3082
3083GAVL_PUBLIC
3084void gavl_video_frame_normalize_orientation(const gavl_video_format_t * in_format,
3085 const gavl_video_format_t * out_format,
3086 const gavl_video_frame_t * in_frame,
3087 gavl_video_frame_t * out_frame);
3088
3089GAVL_PUBLIC
3090void gavl_video_frame_to_packet_metadata(const gavl_video_frame_t * frame,
3091 gavl_packet_t * pkt);
3092
3093GAVL_PUBLIC
3094void gavl_packet_to_video_frame_metadata(const gavl_packet_t * p, gavl_video_frame_t * frame);
3095
3096GAVL_PUBLIC
3097void gavl_video_frame_set_from_packet(gavl_video_frame_t * frame,
3098 const gavl_video_format_t * format,
3099 gavl_packet_t * p);
3100
3101/*****************************
3102 Conversion options
3103******************************/
3104
3108
3112
3119
3120#define GAVL_FORCE_DEINTERLACE (1<<0)
3121
3125
3126#define GAVL_CONVOLVE_CHROMA (1<<1)
3127
3131
3132#define GAVL_CONVOLVE_NORMALIZE (1<<2)
3133
3140
3141#define GAVL_RESAMPLE_CHROMA (1<<3)
3142
3148
3149#define GAVL_FORCE_SW (1<<4)
3150
3157
3163
3169
3177
3183
3189
3193
3206
3215
3223
3229
3230typedef struct gavl_video_options_s gavl_video_options_t;
3231
3232/* Default Options */
3233
3238
3239GAVL_PUBLIC
3241
3250
3251GAVL_PUBLIC
3253
3259
3260GAVL_PUBLIC
3262 const gavl_video_options_t * src);
3263
3268
3269GAVL_PUBLIC
3271
3272
3286
3287GAVL_PUBLIC
3289 const gavl_rectangle_f_t * src_rect,
3290 const gavl_rectangle_i_t * dst_rect);
3291
3298
3299GAVL_PUBLIC
3301 gavl_rectangle_f_t * src_rect,
3302 gavl_rectangle_i_t * dst_rect);
3303
3309
3310GAVL_PUBLIC
3312
3318
3319GAVL_PUBLIC
3321
3322
3328
3329GAVL_PUBLIC
3331 int conversion_flags);
3332
3338
3339GAVL_PUBLIC
3341
3347
3348GAVL_PUBLIC
3350 gavl_alpha_mode_t alpha_mode);
3351
3357
3358GAVL_PUBLIC gavl_alpha_mode_t
3360
3361
3367
3368GAVL_PUBLIC
3370 gavl_scale_mode_t scale_mode);
3371
3377
3378GAVL_PUBLIC gavl_scale_mode_t
3380
3381
3387
3388GAVL_PUBLIC
3390 int order);
3391
3397
3398GAVL_PUBLIC
3400
3401
3407
3408GAVL_PUBLIC
3410 const double * color);
3411
3417
3418GAVL_PUBLIC
3420 double * color);
3421
3427
3428GAVL_PUBLIC
3430 gavl_deinterlace_mode_t deinterlace_mode);
3431
3437
3438GAVL_PUBLIC gavl_deinterlace_mode_t
3440
3446
3447GAVL_PUBLIC
3449 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
3450
3456
3459
3467
3468GAVL_PUBLIC
3471
3472
3480
3481GAVL_PUBLIC gavl_downscale_filter_t
3483
3500
3501GAVL_PUBLIC
3503 float f);
3504
3512
3513GAVL_PUBLIC
3515
3516/* Set an externally created thread pool. If this is not called, a private thread pool will be created if needed.
3517 This function has the advantage that one thread pool can be shared among different elements of a video
3518 pipeline, which will reduce the overhead */
3519
3520GAVL_PUBLIC
3521void gavl_video_options_set_thread_pool(gavl_video_options_t * opt, gavl_thread_pool_t * tp);
3522
3523GAVL_PUBLIC
3524gavl_thread_pool_t * gavl_video_options_get_thread_pool(const gavl_video_options_t * opt);
3525
3526/***************************************************
3527 * Create and destroy video converters
3528 ***************************************************/
3529
3555
3561
3562typedef struct gavl_video_converter_s gavl_video_converter_t;
3563
3568
3569GAVL_PUBLIC
3571
3576
3577GAVL_PUBLIC
3579
3580/**************************************************
3581 * Get options. Change the options with the gavl_video_options_set_*
3582 * functions above
3583 **************************************************/
3584
3592
3593GAVL_PUBLIC gavl_video_options_t *
3595
3596
3609
3610GAVL_PUBLIC
3612 const gavl_video_format_t * input_format,
3613 const gavl_video_format_t * output_format);
3614
3626
3627GAVL_PUBLIC
3629
3630
3631/***************************************************
3632 * Convert a frame
3633 ***************************************************/
3634
3641
3642GAVL_PUBLIC
3644 const gavl_video_frame_t * input_frame,
3645 gavl_video_frame_t * output_frame);
3646
3647
3672
3678
3679typedef struct gavl_video_scaler_s gavl_video_scaler_t;
3680
3685
3686GAVL_PUBLIC
3688
3693
3694GAVL_PUBLIC
3696
3704
3705GAVL_PUBLIC gavl_video_options_t *
3707
3718
3719
3720GAVL_PUBLIC
3722 const gavl_video_format_t * src_format,
3723 const gavl_video_format_t * dst_format);
3724
3744
3745
3746GAVL_PUBLIC
3748 const gavl_video_format_t * format,
3749 int h_radius, const float * h_coeffs,
3750 int v_radius, const float * v_coeffs);
3751
3758
3759GAVL_PUBLIC
3761 const gavl_video_frame_t * input_frame,
3762 gavl_video_frame_t * output_frame);
3763
3771
3777
3778
3779typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
3780
3785
3786GAVL_PUBLIC
3788
3793
3794GAVL_PUBLIC
3796
3804
3805GAVL_PUBLIC gavl_video_options_t *
3807
3817
3818GAVL_PUBLIC
3820 const gavl_video_format_t * src_format);
3821
3822
3829
3830GAVL_PUBLIC
3832 const gavl_video_frame_t * input_frame,
3833 gavl_video_frame_t * output_frame);
3834
3835
3836
3837/**************************************************
3838 * Transparent overlays
3839 **************************************************/
3840
3841/* Overlay struct */
3842
3862
3869
3870typedef gavl_video_frame_t gavl_overlay_t;
3871
3877
3878typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
3879
3884
3885GAVL_PUBLIC
3887
3892
3893GAVL_PUBLIC
3895
3901
3902GAVL_PUBLIC gavl_video_options_t *
3904
3919
3920GAVL_PUBLIC
3922 const gavl_video_format_t * frame_format,
3923 gavl_video_format_t * overlay_format);
3924
3933
3934GAVL_PUBLIC
3936 gavl_overlay_t * ovl);
3937
3943
3944GAVL_PUBLIC
3946 gavl_video_frame_t * dst_frame);
3947
3953
3954GAVL_PUBLIC gavl_video_sink_t *
3956
3972
3977
3978typedef struct gavl_image_transform_s gavl_image_transform_t;
3979
3992
3993typedef void (*gavl_image_transform_func)(void * priv,
3994 double xdst,
3995 double ydst,
3996 double * xsrc,
3997 double * ysrc);
3998
3999
4005
4006GAVL_PUBLIC
4008
4013
4014GAVL_PUBLIC
4016
4033
4034
4035GAVL_PUBLIC
4037 gavl_video_format_t * format,
4038 gavl_image_transform_func func, void * priv);
4039
4046
4047GAVL_PUBLIC
4049 gavl_video_frame_t * in_frame,
4050 gavl_video_frame_t * out_frame);
4051
4061
4062GAVL_PUBLIC gavl_video_options_t *
4064
4068
4081
4086
4087typedef struct
4088 {
4089 int64_t offset;
4090 /* Primary */
4091 int64_t num_entries;
4093
4094 struct
4095 {
4096 int64_t num_frames;
4097 int64_t duration;
4098 } * entries;
4099
4102
4103 struct
4104 {
4105 int64_t pts;
4107 } * timecodes;
4108
4109 /* Secondary */
4110
4112
4119
4129
4130GAVL_PUBLIC gavl_frame_table_t *
4131gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
4132 gavl_timecode_format_t * fmt_ret);
4133
4143
4144GAVL_PUBLIC gavl_frame_table_t *
4145gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
4146 int64_t num_frames,
4147 gavl_timecode_t start_timecode);
4148
4155
4156GAVL_PUBLIC gavl_frame_table_t *
4158
4159
4160
4166
4168
4175
4176GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
4177
4185
4186GAVL_PUBLIC void
4188 int64_t pts, gavl_timecode_t tc);
4189
4199
4200GAVL_PUBLIC int64_t
4202 int64_t frame, int * duration);
4203
4213
4214GAVL_PUBLIC int64_t
4216 int64_t time,
4217 int64_t * start_time);
4218
4228
4229GAVL_PUBLIC gavl_timecode_t
4231 int64_t time,
4232 int64_t * start_time,
4233 const gavl_timecode_format_t * fmt);
4234
4243
4244GAVL_PUBLIC int64_t
4246 gavl_timecode_t tc,
4247 const gavl_timecode_format_t * fmt);
4248
4249
4259
4260GAVL_PUBLIC gavl_timecode_t
4262 int64_t frame,
4263 int64_t * start_time,
4264 const gavl_timecode_format_t * fmt);
4265
4266
4267
4274
4275GAVL_PUBLIC int64_t
4277
4284
4285GAVL_PUBLIC int64_t
4287
4294
4295GAVL_PUBLIC int64_t
4297
4305
4306GAVL_PUBLIC
4308 const char * filename);
4309
4316
4317GAVL_PUBLIC
4319
4325
4326GAVL_PUBLIC void
4328
4332
4350
4355
4356typedef struct gavl_video_frame_pool_s gavl_video_frame_pool_t;
4357
4363
4364GAVL_PUBLIC
4366gavl_video_frame_pool_create(gavl_hw_context_t * hwctx);
4367
4372
4373GAVL_PUBLIC
4375
4376GAVL_PUBLIC
4377void gavl_video_frame_pool_release(gavl_video_frame_t * frame);
4378
4379GAVL_PUBLIC
4380int gavl_video_frame_pool_set_format(gavl_video_frame_pool_t *p, const gavl_video_format_t * fmt);
4381
4382GAVL_PUBLIC
4383const gavl_video_format_t * gavl_video_frame_pool_get_format(const gavl_video_frame_pool_t *p);
4384
4391
4392GAVL_PUBLIC
4394
4401
4402GAVL_PUBLIC
4404
4405/* Debayer routines */
4406
4407#define GAVL_BAYER_GREEN_FIRST (1<<0)
4408#define GAVL_BAYER_BLUE_LINE (1<<1)
4409
4410// GB
4411// RG
4412#define GAVL_BAYER_GBRG (GAVL_BAYER_GREEN_FIRST|GAVL_BAYER_BLUE_LINE)
4413
4414// GR
4415// BG
4416#define GAVL_BAYER_GRBG (GAVL_BAYER_GREEN_FIRST)
4417
4418// BG
4419// GR
4420#define GAVL_BAYER_BGGR (GAVL_BAYER_BLUE_LINE)
4421
4422// RG
4423// GB
4424#define GAVL_BAYER_RGGB 0
4425
4426GAVL_PUBLIC
4427void gavl_video_frame_debayer(gavl_video_options_t * opt,
4428 gavl_video_frame_t * src, gavl_video_frame_t * dst,
4429 int bayer_format, gavl_video_format_t * dst_format);
4430
4431
4435
4436
4437#ifdef __cplusplus
4438}
4439#endif
4440
4441#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:1189
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:248
gavl_sample_format_t
Format of one audio sample.
Definition gavl.h:217
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:234
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:208
@ GAVL_CHID_SIDE_RIGHT
Definition gavl.h:259
@ GAVL_CHID_FRONT_RIGHT
Definition gavl.h:252
@ GAVL_CHID_FRONT_LEFT
Definition gavl.h:251
@ GAVL_CHID_REAR_LEFT
Definition gavl.h:255
@ GAVL_CHID_SIDE_LEFT
Definition gavl.h:258
@ GAVL_CHID_NONE
Definition gavl.h:249
@ GAVL_CHID_FRONT_CENTER_LEFT
Definition gavl.h:253
@ GAVL_CHID_REAR_CENTER
Definition gavl.h:257
@ GAVL_CHID_LFE
Definition gavl.h:260
@ GAVL_CHID_REAR_RIGHT
Definition gavl.h:256
@ GAVL_CHID_AUX
Definition gavl.h:261
@ GAVL_CHID_FRONT_CENTER_RIGHT
Definition gavl.h:254
@ GAVL_CHID_FRONT_CENTER
Definition gavl.h:250
@ GAVL_SAMPLE_FLOAT
Definition gavl.h:224
@ GAVL_SAMPLE_NONE
Definition gavl.h:218
@ GAVL_SAMPLE_U8
Definition gavl.h:219
@ GAVL_SAMPLE_S8
Definition gavl.h:220
@ GAVL_SAMPLE_U16
Definition gavl.h:221
@ GAVL_SAMPLE_S16
Definition gavl.h:222
@ GAVL_SAMPLE_DOUBLE
Definition gavl.h:225
@ GAVL_SAMPLE_S32
Definition gavl.h:223
@ GAVL_INTERLEAVE_2
Definition gavl.h:236
@ GAVL_INTERLEAVE_ALL
Definition gavl.h:237
@ GAVL_INTERLEAVE_NONE
Definition gavl.h:235
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:1004
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:976
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:989
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:995
@ GAVL_RESAMPLE_ZOH
Definition gavl.h:991
@ GAVL_RESAMPLE_LINEAR
Definition gavl.h:992
@ GAVL_RESAMPLE_AUTO
Definition gavl.h:990
@ GAVL_RESAMPLE_SINC_MEDIUM
Definition gavl.h:994
@ GAVL_RESAMPLE_SINC_FAST
Definition gavl.h:993
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:3870
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:3878
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:3562
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:3779
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:1784
#define GAVL_PIXFMT_ALPHA
Definition gavl.h:1804
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:2249
#define GAVL_PIXFMT_GRAY
Definition gavl.h:1809
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:2290
gavl_pixelformat_e
Pixelformat definition.
Definition gavl.h:1816
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:1951
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:2331
#define GAVL_PIXFMT_RGB
Definition gavl.h:1789
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:1794
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:1999
#define GAVL_PIXFMT_YUVJ
Definition gavl.h:1799
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:2252
@ GAVL_CHROMA_PLACEMENT_MPEG2
Definition gavl.h:2251
@ GAVL_CHROMA_PLACEMENT_DEFAULT
Definition gavl.h:2250
@ GAVL_FRAMERATE_UNKNOWN
Definition gavl.h:2291
@ GAVL_FRAMERATE_CONSTANT
Definition gavl.h:2292
@ GAVL_FRAMERATE_STILL
Definition gavl.h:2294
@ GAVL_FRAMERATE_VARIABLE
Definition gavl.h:2293
@ GAVL_YUVJ_420_P
Definition gavl.h:1930
@ GAVL_YUV_422_P
Definition gavl.h:1917
@ GAVL_BGR_24
Definition gavl.h:1866
@ GAVL_YUV_410_P
Definition gavl.h:1926
@ GAVL_RGB_48
Definition gavl.h:1879
@ GAVL_RGB_32
Definition gavl.h:1869
@ GAVL_YUV_420_P
Definition gavl.h:1914
@ GAVL_GRAYA_32
Definition gavl.h:1839
@ GAVL_YUVA_32
Definition gavl.h:1899
@ GAVL_RGB_16
Definition gavl.h:1856
@ GAVL_UYVY
Definition gavl.h:1896
@ GAVL_YUV_422_P_16
Definition gavl.h:1943
@ GAVL_YUV_444_P
Definition gavl.h:1920
@ GAVL_RGB_FLOAT
Definition gavl.h:1886
@ GAVL_YUVJ_422_P
Definition gavl.h:1933
@ GAVL_GRAY_8
Definition gavl.h:1823
@ GAVL_RGB_24
Definition gavl.h:1863
@ GAVL_RGBA_64
Definition gavl.h:1882
@ GAVL_YUY2
Definition gavl.h:1893
@ GAVL_YUVA_FLOAT
Definition gavl.h:1909
@ GAVL_YUVJ_444_P
Definition gavl.h:1936
@ GAVL_GRAYA_FLOAT
Definition gavl.h:1843
@ GAVL_BGR_15
Definition gavl.h:1852
@ GAVL_YUV_444_P_16
Definition gavl.h:1940
@ GAVL_PIXELFORMAT_NONE
Undefined.
Definition gavl.h:1819
@ GAVL_GRAYA_16
Definition gavl.h:1835
@ GAVL_YUV_411_P
Definition gavl.h:1923
@ GAVL_GRAY_FLOAT
Definition gavl.h:1831
@ GAVL_YUV_FLOAT
Definition gavl.h:1905
@ GAVL_RGBA_32
Definition gavl.h:1875
@ GAVL_GRAY_16
Definition gavl.h:1827
@ GAVL_BGR_16
Definition gavl.h:1860
@ GAVL_YUVA_64
Definition gavl.h:1902
@ GAVL_RGB_15
Definition gavl.h:1848
@ GAVL_RGBA_FLOAT
Definition gavl.h:1889
@ GAVL_BGR_32
Definition gavl.h:1872
@ GAVL_INTERLACE_MIXED_BOTTOM
Definition gavl.h:2338
@ GAVL_INTERLACE_MIXED_TOP
Definition gavl.h:2337
@ GAVL_INTERLACE_NONE
Definition gavl.h:2333
@ GAVL_INTERLACE_BOTTOM_FIRST
Definition gavl.h:2335
@ GAVL_INTERLACE_UNKNOWN
Definition gavl.h:2332
@ GAVL_INTERLACE_MIXED
Definition gavl.h:2336
@ GAVL_INTERLACE_TOP_FIRST
Definition gavl.h:2334
@ GAVL_CCH_NONE
None/undefined.
Definition gavl.h:2000
@ GAVL_CCH_Y
Luminance (also grayscale).
Definition gavl.h:2004
@ GAVL_CCH_RED
Red.
Definition gavl.h:2001
@ GAVL_CCH_CR
Chrominance red (aka V).
Definition gavl.h:2006
@ GAVL_CCH_GREEN
Green.
Definition gavl.h:2002
@ GAVL_CCH_ALPHA
Transparency (or, to be more precise opacity).
Definition gavl.h:2007
@ GAVL_CCH_CB
Chrominance blue (aka U).
Definition gavl.h:2005
@ GAVL_CCH_BLUE
Blue.
Definition gavl.h:2003
GAVL_PUBLIC gavl_video_frame_pool_t * gavl_video_frame_pool_create(gavl_hw_context_t *hwctx)
Create a video frame pool.
GAVL_PUBLIC gavl_video_frame_t * gavl_video_frame_pool_get(gavl_video_frame_pool_t *p)
Create a video frame pool.
struct gavl_video_frame_pool_s gavl_video_frame_pool_t
Video frame pool.
Definition gavl.h:4356
GAVL_PUBLIC void gavl_video_frame_pool_destroy(gavl_video_frame_pool_t *p)
Destroy a video frame pool.
GAVL_PUBLIC void gavl_video_frame_pool_reset(gavl_video_frame_pool_t *p)
Reset a video frame pool.
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:3171
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:3185
struct gavl_video_options_s gavl_video_options_t
Definition gavl.h:3230
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:3159
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:3195
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:3217
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:3172
@ GAVL_DEINTERLACE_SCALE
Definition gavl.h:3174
@ GAVL_DEINTERLACE_BLEND
Definition gavl.h:3175
@ GAVL_DEINTERLACE_COPY
Definition gavl.h:3173
@ GAVL_DEINTERLACE_DROP_TOP
Definition gavl.h:3186
@ GAVL_DEINTERLACE_DROP_BOTTOM
Definition gavl.h:3187
@ GAVL_ALPHA_IGNORE
Definition gavl.h:3160
@ GAVL_ALPHA_BLEND_COLOR
Definition gavl.h:3161
@ GAVL_SCALE_NONE
Definition gavl.h:3204
@ GAVL_SCALE_NEAREST
Definition gavl.h:3197
@ GAVL_SCALE_CUBIC_MITCHELL
Definition gavl.h:3201
@ GAVL_SCALE_AUTO
Definition gavl.h:3196
@ GAVL_SCALE_SINC_LANCZOS
Definition gavl.h:3203
@ GAVL_SCALE_CUBIC_CATMULL
Definition gavl.h:3202
@ GAVL_SCALE_CUBIC_BSPLINE
Definition gavl.h:3200
@ GAVL_SCALE_QUADRATIC
Definition gavl.h:3199
@ GAVL_SCALE_BILINEAR
Definition gavl.h:3198
@ GAVL_DOWNSCALE_FILTER_AUTO
Auto selection based on quality.
Definition gavl.h:3218
@ GAVL_DOWNSCALE_FILTER_NONE
Fastest method, might produce heavy aliasing artifacts.
Definition gavl.h:3219
@ GAVL_DOWNSCALE_FILTER_WIDE
Widen the filter curve according to the scaling ratio.
Definition gavl.h:3220
@ GAVL_DOWNSCALE_FILTER_GAUSS
Do a Gaussian preblur.
Definition gavl.h:3221
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:3679
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:3978
void(* gavl_image_transform_func)(void *priv, double xdst, double ydst, double *xsrc, double *ysrc)
Function describing the method.
Definition gavl.h:3993
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.
#define GAVL_MAX_PLANES
Definition gavl.h:1433
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:1351
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:273
uint32_t samples_per_frame
Definition gavl.h:274
uint32_t samplerate
Definition gavl.h:275
float rear_level
Definition gavl.h:281
gavl_interleave_mode_t interleave_mode
Definition gavl.h:278
gavl_sample_format_t sample_format
Definition gavl.h:277
uint32_t num_channels
Definition gavl.h:276
float center_level
Definition gavl.h:280
gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS]
Definition gavl.h:283
Generic container for audio samples.
Definition gavl.h:624
int channel_stride
Definition gavl.h:629
gavl_audio_samples_t samples
Definition gavl.h:625
int valid_samples
Definition gavl.h:627
int64_t timestamp
Definition gavl.h:628
gavl_audio_channels_t channels
Definition gavl.h:626
frame table structure
Definition gavl.h:4088
gavl_timecode_t tc
Timecode associated with this timestamp.
Definition gavl.h:4106
int num_timecodes
Number of timecodes.
Definition gavl.h:4100
int64_t num_frames
Number of frames.
Definition gavl.h:4096
int64_t duration
Duration of each of these frames.
Definition gavl.h:4097
int64_t offset
Timestamp of the first frame.
Definition gavl.h:4089
int64_t entries_alloc
Number of allocated entries (never touch this).
Definition gavl.h:4092
int64_t num_entries
Number of entries.
Definition gavl.h:4091
int64_t pts
Timestamp of this frame.
Definition gavl.h:4105
int timecodes_alloc
Number of allocated timecodes (never touch this).
Definition gavl.h:4101
Packet structure.
Definition compression.h:428
Floating point rectangle.
Definition gavl.h:1458
double x
Definition gavl.h:1459
double y
Definition gavl.h:1460
double w
Definition gavl.h:1461
double h
Definition gavl.h:1462
Integer rectangle.
Definition gavl.h:1446
int32_t x
Definition gavl.h:1447
int32_t h
Definition gavl.h:1450
int32_t y
Definition gavl.h:1448
int32_t w
Definition gavl.h:1449
Timecode format.
Definition timecode.h:61
Video format.
Definition gavl.h:2405
uint32_t frame_height
Definition gavl.h:2407
gavl_chroma_placement_t chroma_placement
Definition gavl.h:2424
gavl_hw_context_t * hwctx
Handle for accessing the frames. If NULL, frames are in regular RAM.
Definition gavl.h:2430
uint32_t image_height
Definition gavl.h:2410
uint32_t pixel_height
Definition gavl.h:2415
uint32_t frame_width
Definition gavl.h:2406
uint32_t image_width
Definition gavl.h:2409
uint32_t timescale
Definition gavl.h:2421
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2426
gavl_framerate_mode_t framerate_mode
Definition gavl.h:2423
gavl_pixelformat_t pixelformat
Definition gavl.h:2417
uint32_t pixel_width
Definition gavl.h:2414
gavl_timecode_format_t timecode_format
Definition gavl.h:2428
uint32_t frame_duration
Definition gavl.h:2419
Definition gavl.h:2629
uint8_t * planes[GAVL_MAX_PLANES]
Definition gavl.h:2630
int64_t duration
Definition gavl.h:2635
int strides[GAVL_MAX_PLANES]
Definition gavl.h:2631
void * client_data
Definition gavl.h:2633
int32_t dst_y
y offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2643
void * storage
Definition gavl.h:2646
int64_t timestamp
Definition gavl.h:2634
int32_t dst_x
x offset in the destination frame. (since 1.5.0) *‍/
Definition gavl.h:2642
gavl_rectangle_i_t src_rect
Valid rectangle in this frame (since 1.5.0) *‍/.
Definition gavl.h:2641
gavl_hw_context_t * hwctx
Handle for accessing the frame.
Definition gavl.h:2645
gavl_interlace_mode_t interlace_mode
Definition gavl.h:2636
gavl_timecode_t timecode
Definition gavl.h:2637
Container for noninterleaved audio samples.
Definition gavl.h:592
int16_t * s_16[GAVL_MAX_CHANNELS]
Definition gavl.h:597
int32_t * s_32[GAVL_MAX_CHANNELS]
Definition gavl.h:600
float * f[GAVL_MAX_CHANNELS]
Definition gavl.h:602
double * d[GAVL_MAX_CHANNELS]
Definition gavl.h:603
int8_t * s_8[GAVL_MAX_CHANNELS]
Definition gavl.h:594
uint8_t * u_8[GAVL_MAX_CHANNELS]
Definition gavl.h:593
uint32_t * u_32[GAVL_MAX_CHANNELS]
Definition gavl.h:599
uint16_t * u_16[GAVL_MAX_CHANNELS]
Definition gavl.h:596
Container for interleaved audio samples.
Definition gavl.h:572
uint32_t * u_32
Definition gavl.h:579
int8_t * s_8
Definition gavl.h:574
uint16_t * u_16
Definition gavl.h:576
int16_t * s_16
Definition gavl.h:577
uint8_t * u_8
Definition gavl.h:573
float * f
Definition gavl.h:582
double * d
Definition gavl.h:583
int32_t * s_32
Definition gavl.h:580