gavl

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

gavl.h
Go to the documentation of this file.
1 /*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
27 #ifndef GAVL_H_INCLUDED
28 #define GAVL_H_INCLUDED
29
30 #include <inttypes.h>
31
32 #include <gavl/gavldefs.h>
33 #include <gavl/gavltime.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <gavl/timecode.h>
40
41
64 typedef void (*gavl_video_process_func)(void * data, int start, int end);
65
79 typedef void (*gavl_video_run_func)(gavl_video_process_func func,
80 void * gavl_data,
81 int start, int end,
82 void * client_data, int thread);
83
92 typedef void (*gavl_video_stop_func)(void * client_data, int thread);
93
102 typedef struct gavl_video_format_s gavl_video_format_t;
103
104
105 /* Quality levels */
106
130 #define GAVL_QUALITY_FASTEST 1
131
138 #define GAVL_QUALITY_BEST 5
139
146 #define GAVL_QUALITY_DEFAULT 2
147
159 #define GAVL_ACCEL_MMX (1<<0)
160 #define GAVL_ACCEL_MMXEXT (1<<1)
161 #define GAVL_ACCEL_SSE (1<<2)
162 #define GAVL_ACCEL_SSE2 (1<<3)
163 #define GAVL_ACCEL_SSE3 (1<<4)
164 #define GAVL_ACCEL_3DNOW (1<<5)
165 #define GAVL_ACCEL_3DNOWEXT (1<<6)
166 #define GAVL_ACCEL_SSSE3 (1<<7)
167
168
172 GAVL_PUBLIC int gavl_accel_supported();
173
182 /* Sample formats: all multibyte numbers are native endian */
183
196 #define GAVL_MAX_CHANNELS 128
197
204 typedef enum
205 {
206 GAVL_SAMPLE_NONE = 0,
207 GAVL_SAMPLE_U8 = 1,
208 GAVL_SAMPLE_S8 = 2,
209 GAVL_SAMPLE_U16 = 3,
210 GAVL_SAMPLE_S16 = 4,
211 GAVL_SAMPLE_S32 = 5,
212 GAVL_SAMPLE_FLOAT = 6,
213 GAVL_SAMPLE_DOUBLE = 7
214 } gavl_sample_format_t;
215
221 typedef enum
222 {
223 GAVL_INTERLEAVE_NONE = 0,
224 GAVL_INTERLEAVE_2 = 1,
225 GAVL_INTERLEAVE_ALL = 2
226 } gavl_interleave_mode_t;
227
235 typedef enum
236 {
237 GAVL_CHID_NONE = 0,
238 GAVL_CHID_FRONT_CENTER,
239 GAVL_CHID_FRONT_LEFT,
240 GAVL_CHID_FRONT_RIGHT,
241 GAVL_CHID_FRONT_CENTER_LEFT,
242 GAVL_CHID_FRONT_CENTER_RIGHT,
243 GAVL_CHID_REAR_LEFT,
244 GAVL_CHID_REAR_RIGHT,
245 GAVL_CHID_REAR_CENTER,
246 GAVL_CHID_SIDE_LEFT,
247 GAVL_CHID_SIDE_RIGHT,
248 GAVL_CHID_LFE,
249 GAVL_CHID_AUX,
250 } gavl_channel_id_t;
251
260 typedef struct
261 {
262 int samples_per_frame;
263 int samplerate;
264 int num_channels;
265 gavl_sample_format_t sample_format;
266 gavl_interleave_mode_t interleave_mode;
268 float center_level;
269 float rear_level;
271 gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];
273 } gavl_audio_format_t;
274
275
276 /* Audio format -> string conversions */
277
285 GAVL_PUBLIC
286 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
287
296 GAVL_PUBLIC
297 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
298
304 GAVL_PUBLIC
305 int gavl_num_sample_formats();
306
313 GAVL_PUBLIC
314 gavl_sample_format_t gavl_get_sample_format(int index);
315
322 GAVL_PUBLIC
323 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
324
325
332 GAVL_PUBLIC
333 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
334
341 GAVL_PUBLIC
342 void gavl_audio_format_dump(const gavl_audio_format_t * format);
343
352 GAVL_PUBLIC
353 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
354
361 GAVL_PUBLIC
362 int gavl_front_channels(const gavl_audio_format_t * format);
363
370 GAVL_PUBLIC
371 int gavl_rear_channels(const gavl_audio_format_t * format);
372
379 GAVL_PUBLIC
380 int gavl_side_channels(const gavl_audio_format_t * format);
381
388 GAVL_PUBLIC
389 int gavl_aux_channels(const gavl_audio_format_t * format);
390
391
392
399 GAVL_PUBLIC
400 int gavl_lfe_channels(const gavl_audio_format_t * format);
401
409 GAVL_PUBLIC
410 void gavl_audio_format_copy(gavl_audio_format_t * dst,
411 const gavl_audio_format_t * src);
412
421 GAVL_PUBLIC
422 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
423 const gavl_audio_format_t * format_2);
424
436 GAVL_PUBLIC
437 void gavl_set_channel_setup(gavl_audio_format_t * format);
438
445 GAVL_PUBLIC
446 int gavl_bytes_per_sample(gavl_sample_format_t format);
447
462 typedef union
463 {
464 uint8_t * u_8;
465 int8_t * s_8;
467 uint16_t * u_16;
468 int16_t * s_16;
470 uint32_t * u_32;
471 int32_t * s_32;
473 float * f;
474 double * d;
475 } gavl_audio_samples_t;
476
482 typedef union
483 {
484 uint8_t * u_8[GAVL_MAX_CHANNELS];
485 int8_t * s_8[GAVL_MAX_CHANNELS];
487 uint16_t * u_16[GAVL_MAX_CHANNELS];
488 int16_t * s_16[GAVL_MAX_CHANNELS];
490 uint32_t * u_32[GAVL_MAX_CHANNELS];
491 int32_t * s_32[GAVL_MAX_CHANNELS];
493 float * f[GAVL_MAX_CHANNELS];
494 double * d[GAVL_MAX_CHANNELS];
496 } gavl_audio_channels_t;
497
514 typedef struct
515 {
516 gavl_audio_samples_t samples;
517 gavl_audio_channels_t channels;
518 int valid_samples;
519 int64_t timestamp;
520 int channel_stride;
521 } gavl_audio_frame_t;
522
534 GAVL_PUBLIC
535 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
536
548 GAVL_PUBLIC
549 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
550
560 GAVL_PUBLIC
561 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
562
572 GAVL_PUBLIC
573 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
574 const gavl_audio_format_t * format);
575
586 GAVL_PUBLIC
587 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
588 const gavl_audio_format_t * format,
589 int num_samples);
590
591
592
603 GAVL_PUBLIC
604 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
605 const gavl_audio_format_t * format,
606 int channel);
607
628 GAVL_PUBLIC
629 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
630 gavl_audio_frame_t * dst,
631 const gavl_audio_frame_t * src,
632 int dst_pos,
633 int src_pos,
634 int dst_size,
635 int src_size);
636
649 GAVL_PUBLIC
650 void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t * format,
651 gavl_audio_frame_t * dst,
652 const gavl_audio_frame_t * src);
653
671 GAVL_PUBLIC
672 void gavl_audio_frame_get_subframe(const gavl_audio_format_t * format,
673 gavl_audio_frame_t * src,
674 gavl_audio_frame_t * dst,
675 int start, int len);
676
689 GAVL_PUBLIC
690 int gavl_audio_frames_equal(const gavl_audio_format_t * format,
691 const gavl_audio_frame_t * f1,
692 const gavl_audio_frame_t * f2);
693
713 GAVL_PUBLIC
714 int gavl_audio_frame_plot(const gavl_audio_format_t * format,
715 const gavl_audio_frame_t * frame,
716 const char * name_base);
717
718
733 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
738 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
743 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
748 #define GAVL_AUDIO_FRONT_TO_REAR_MASK \
749 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
750 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
751 GAVL_AUDIO_FRONT_TO_REAR_DIFF)
753 /* Options for mixing stereo to mono */
754
757 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT (1<<3)
760 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
763 #define GAVL_AUDIO_STEREO_TO_MONO_MIX (1<<5)
767 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
768 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
769 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
770 GAVL_AUDIO_STEREO_TO_MONO_MIX)
775 #define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
782 typedef enum
783 {
784 GAVL_AUDIO_DITHER_NONE = 0,
785 GAVL_AUDIO_DITHER_AUTO = 1,
786 GAVL_AUDIO_DITHER_RECT = 2,
787 GAVL_AUDIO_DITHER_TRI = 3,
788 GAVL_AUDIO_DITHER_SHAPED = 4,
789 } gavl_audio_dither_mode_t;
790
795 typedef enum
796 {
797 GAVL_RESAMPLE_AUTO = 0,
798 GAVL_RESAMPLE_ZOH = 1,
799 GAVL_RESAMPLE_LINEAR = 2,
800 GAVL_RESAMPLE_SINC_FAST = 3,
801 GAVL_RESAMPLE_SINC_MEDIUM = 4,
802 GAVL_RESAMPLE_SINC_BEST = 5
803 } gavl_resample_mode_t;
804
811 typedef struct gavl_audio_options_s gavl_audio_options_t;
812
819 GAVL_PUBLIC
820 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
821
828 GAVL_PUBLIC
829 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
830
837 GAVL_PUBLIC
838 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
839
846 GAVL_PUBLIC
847 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
848
849
856 GAVL_PUBLIC
857 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
858
865 GAVL_PUBLIC
866 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
867
874 GAVL_PUBLIC
875 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
876 int flags);
877
884 GAVL_PUBLIC
885 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
886
892 GAVL_PUBLIC
893 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
894
911 GAVL_PUBLIC
912 void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt,
913 const double ** matrix);
914
923 GAVL_PUBLIC
924 const double ** gavl_audio_options_get_mix_matrix(gavl_audio_options_t * opt);
925
935 GAVL_PUBLIC
936 gavl_audio_options_t * gavl_audio_options_create();
937
944 GAVL_PUBLIC
945 void gavl_audio_options_copy(gavl_audio_options_t * dst,
946 const gavl_audio_options_t * src);
947
953 GAVL_PUBLIC
954 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
955
956
957
958 /* Audio converter */
959
993 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
994
1000 GAVL_PUBLIC
1001 gavl_audio_converter_t * gavl_audio_converter_create();
1002
1008 GAVL_PUBLIC
1009 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
1010
1019 GAVL_PUBLIC
1020 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
1021
1022
1037 GAVL_PUBLIC
1038 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
1039 const gavl_audio_format_t * input_format,
1040 const gavl_audio_format_t * output_format);
1041
1056 GAVL_PUBLIC
1057 int gavl_audio_converter_init_resample(gavl_audio_converter_t * cnv,
1058 const gavl_audio_format_t * format);
1059
1074 GAVL_PUBLIC
1075 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
1076
1077
1091 GAVL_PUBLIC
1092 void gavl_audio_convert(gavl_audio_converter_t * cnv,
1093 const gavl_audio_frame_t * input_frame,
1094 gavl_audio_frame_t * output_frame);
1095
1096
1115 GAVL_PUBLIC
1116 int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t * cnv,
1117 double ratio ) ;
1118
1119
1135 GAVL_PUBLIC
1136 void gavl_audio_converter_resample(gavl_audio_converter_t * cnv,
1137 gavl_audio_frame_t * input_frame,
1138 gavl_audio_frame_t * output_frame,
1139 double ratio);
1140
1141
1155 typedef struct gavl_volume_control_s gavl_volume_control_t;
1156
1157 /* Create / destroy */
1158
1164 GAVL_PUBLIC
1165 gavl_volume_control_t * gavl_volume_control_create();
1166
1172 GAVL_PUBLIC
1173 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
1174
1182 GAVL_PUBLIC
1183 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
1184 const gavl_audio_format_t * format);
1185
1192 GAVL_PUBLIC
1193 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
1194 float volume);
1195
1202 GAVL_PUBLIC
1203 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
1204 gavl_audio_frame_t * frame);
1205
1221 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
1222
1223 /* Create / destroy */
1224
1230 GAVL_PUBLIC
1231 gavl_peak_detector_t * gavl_peak_detector_create();
1232
1238 GAVL_PUBLIC
1239 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
1240
1250 GAVL_PUBLIC
1251 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
1252 const gavl_audio_format_t * format);
1253
1260 GAVL_PUBLIC
1261 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
1262 gavl_audio_frame_t * frame);
1263
1276 GAVL_PUBLIC
1277 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
1278 double * min, double * max,
1279 double * abs);
1280
1293 GAVL_PUBLIC
1294 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
1295 double * min, double * max,
1296 double * abs);
1297
1303 GAVL_PUBLIC
1304 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
1305
1315 #define GAVL_MAX_PLANES 4
1327 typedef struct
1328 {
1329 int x;
1330 int y;
1331 int w;
1332 int h;
1333 } gavl_rectangle_i_t;
1334
1339 typedef struct
1340 {
1341 double x;
1342 double y;
1343 double w;
1344 double h;
1345 } gavl_rectangle_f_t;
1346
1353 GAVL_PUBLIC
1354 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
1355 const gavl_video_format_t * format);
1356
1363 GAVL_PUBLIC
1364 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
1365 const gavl_video_format_t * format);
1366
1381 GAVL_PUBLIC
1382 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
1383 gavl_rectangle_i_t * dst_rect,
1384 const gavl_video_format_t * src_format,
1385 const gavl_video_format_t * dst_format);
1386
1398 GAVL_PUBLIC
1399 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
1400 gavl_rectangle_i_t * dst_rect,
1401 const gavl_video_format_t * src_format,
1402 const gavl_video_format_t * dst_format);
1403
1404
1405
1412 GAVL_PUBLIC
1413 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
1414
1421 GAVL_PUBLIC
1422 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
1423
1430 GAVL_PUBLIC
1431 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r, int num_pixels);
1432
1439 GAVL_PUBLIC
1440 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r, int num_pixels);
1441
1448 GAVL_PUBLIC
1449 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r, int num_pixels);
1450
1457 GAVL_PUBLIC
1458 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
1459
1466 GAVL_PUBLIC
1467 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r, double num_pixels);
1468
1475 GAVL_PUBLIC
1476 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r, double num_pixels);
1477
1484 GAVL_PUBLIC
1485 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r, double num_pixels);
1486
1493 GAVL_PUBLIC
1494 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
1495
1509 GAVL_PUBLIC
1510 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
1511
1521 GAVL_PUBLIC
1522 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
1523 const gavl_video_format_t * format);
1524
1525
1532 GAVL_PUBLIC
1533 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
1534
1541 GAVL_PUBLIC
1542 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
1543
1544
1545
1552 GAVL_PUBLIC
1553 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
1554
1561 GAVL_PUBLIC
1562 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
1563
1572 GAVL_PUBLIC
1573 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
1574
1583 GAVL_PUBLIC
1584 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
1585
1613 GAVL_PUBLIC
1614 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
1615 const gavl_video_format_t * src_format,
1616 const gavl_rectangle_f_t * src_rect,
1617 const gavl_video_format_t * dst_format,
1618 float zoom, float squeeze);
1619
1624 GAVL_PUBLIC
1625 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
1626
1631 GAVL_PUBLIC
1632 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
1633
1634
1644 #define GAVL_PIXFMT_PLANAR (1<<8)
1645
1649 #define GAVL_PIXFMT_RGB (1<<9)
1650
1654 #define GAVL_PIXFMT_YUV (1<<10)
1655
1659 #define GAVL_PIXFMT_YUVJ (1<<11)
1660
1664 #define GAVL_PIXFMT_ALPHA (1<<12)
1665
1669 #define GAVL_PIXFMT_GRAY (1<<13)
1670
1675 typedef enum
1676 {
1679 GAVL_PIXELFORMAT_NONE = 0,
1680
1683 GAVL_GRAY_8 = 1 | GAVL_PIXFMT_GRAY,
1684
1687 GAVL_GRAY_16 = 2 | GAVL_PIXFMT_GRAY,
1688
1691 GAVL_GRAY_FLOAT = 3 | GAVL_PIXFMT_GRAY,
1692
1695 GAVL_GRAYA_16 = 1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
1696
1699 GAVL_GRAYA_32 = 2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
1700
1703 GAVL_GRAYA_FLOAT = 3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
1704
1708 GAVL_RGB_15 = 1 | GAVL_PIXFMT_RGB,
1712 GAVL_BGR_15 = 2 | GAVL_PIXFMT_RGB,
1716 GAVL_RGB_16 = 3 | GAVL_PIXFMT_RGB,
1720 GAVL_BGR_16 = 4 | GAVL_PIXFMT_RGB,
1723 GAVL_RGB_24 = 5 | GAVL_PIXFMT_RGB,
1726 GAVL_BGR_24 = 6 | GAVL_PIXFMT_RGB,
1729 GAVL_RGB_32 = 7 | GAVL_PIXFMT_RGB,
1732 GAVL_BGR_32 = 8 | GAVL_PIXFMT_RGB,
1735 GAVL_RGBA_32 = 9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
1736
1739 GAVL_RGB_48 = 10 | GAVL_PIXFMT_RGB,
1742 GAVL_RGBA_64 = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
1743
1746 GAVL_RGB_FLOAT = 12 | GAVL_PIXFMT_RGB,
1749 GAVL_RGBA_FLOAT = 13 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
1750
1753 GAVL_YUY2 = 1 | GAVL_PIXFMT_YUV,
1756 GAVL_UYVY = 2 | GAVL_PIXFMT_YUV,
1759 GAVL_YUVA_32 = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
1762 GAVL_YUVA_64 = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
1765 GAVL_YUV_FLOAT = 5 | GAVL_PIXFMT_YUV,
1766
1769 GAVL_YUVA_FLOAT = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
1770
1774 GAVL_YUV_420_P = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1777 GAVL_YUV_422_P = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1780 GAVL_YUV_444_P = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1783 GAVL_YUV_411_P = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1786 GAVL_YUV_410_P = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1787
1790 GAVL_YUVJ_420_P = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
1793 GAVL_YUVJ_422_P = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
1796 GAVL_YUVJ_444_P = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
1797
1800 GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1803 GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
1804
1805 } gavl_pixelformat_t;
1806
1809 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
1810
1812 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
1813
1815 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
1816
1818 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
1819
1822 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
1823
1825 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
1826
1828 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
1829
1831 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
1832
1835 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
1836
1838 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
1839
1841 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
1842
1844 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
1845
1852 typedef enum
1853 {
1854 GAVL_CCH_RED,
1855 GAVL_CCH_GREEN,
1856 GAVL_CCH_BLUE,
1857 GAVL_CCH_Y,
1858 GAVL_CCH_CB,
1859 GAVL_CCH_CR,
1860 GAVL_CCH_ALPHA,
1861 } gavl_color_channel_t;
1862
1863 /*
1864 * Colormodel related functions
1865 */
1866
1873 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
1874
1875
1882 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
1883
1890 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
1891
1898 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
1899
1906 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
1907
1914 #define gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
1915
1922 GAVL_PUBLIC
1923 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
1924
1934 GAVL_PUBLIC
1935 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
1936
1943 GAVL_PUBLIC
1944 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
1945
1952 GAVL_PUBLIC
1953 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
1954
1961 GAVL_PUBLIC
1962 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
1963
1978 GAVL_PUBLIC
1979 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
1980 gavl_pixelformat_t dst);
1981
1995 GAVL_PUBLIC gavl_pixelformat_t
1996 gavl_pixelformat_get_best(gavl_pixelformat_t src,
1997 const gavl_pixelformat_t * dst_supported,
1998 int * penalty);
1999
2000
2001
2008 GAVL_PUBLIC
2009 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
2010
2017 GAVL_PUBLIC
2018 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
2019
2025 GAVL_PUBLIC
2026 int gavl_num_pixelformats();
2027
2034 GAVL_PUBLIC
2035 gavl_pixelformat_t gavl_get_pixelformat(int index);
2036
2037 /* */
2038
2047 typedef enum
2048 {
2049 GAVL_CHROMA_PLACEMENT_DEFAULT = 0,
2050 GAVL_CHROMA_PLACEMENT_MPEG2,
2051 GAVL_CHROMA_PLACEMENT_DVPAL
2052 } gavl_chroma_placement_t;
2053
2060 GAVL_PUBLIC
2061 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
2062
2067 /* Changing the values alters the gmerlin-avdecoder index format */
2068
2069 typedef enum
2070 {
2071 GAVL_FRAMERATE_UNKNOWN = -1,
2072 GAVL_FRAMERATE_CONSTANT = 0,
2073 GAVL_FRAMERATE_VARIABLE = 1,
2074 GAVL_FRAMERATE_STILL = 2,
2075 } gavl_framerate_mode_t;
2076
2083 GAVL_PUBLIC
2084 const char * gavl_framerate_mode_to_string(gavl_framerate_mode_t mode);
2085
2090 /* Changing the values alters the gmerlin-avdecoder index format */
2091
2092 typedef enum
2093 {
2094 GAVL_INTERLACE_UNKNOWN = -1,
2095 GAVL_INTERLACE_NONE = 0,
2096 GAVL_INTERLACE_TOP_FIRST = 1,
2097 GAVL_INTERLACE_BOTTOM_FIRST = 2,
2098 GAVL_INTERLACE_MIXED = 3,
2099 GAVL_INTERLACE_MIXED_TOP = 4,
2100 GAVL_INTERLACE_MIXED_BOTTOM = 5,
2101 } gavl_interlace_mode_t;
2102
2109 GAVL_PUBLIC
2110 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
2111
2112
2113 /* Video format structure */
2114
2119 struct gavl_video_format_s
2120 {
2121 int frame_width;
2122 int frame_height;
2124 int image_width;
2125 int image_height;
2127 /* Support for nonsquare pixels */
2128
2129 int pixel_width;
2130 int pixel_height;
2132 gavl_pixelformat_t pixelformat;
2134 int frame_duration;
2136 int timescale;
2138 gavl_framerate_mode_t framerate_mode;
2139 gavl_chroma_placement_t chroma_placement;
2141 gavl_interlace_mode_t interlace_mode;
2143 gavl_timecode_format_t timecode_format;
2144 };
2145
2153 GAVL_PUBLIC
2154 void gavl_video_format_copy(gavl_video_format_t * dst,
2155 const gavl_video_format_t * src);
2156
2165 GAVL_PUBLIC
2166 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
2167 const gavl_video_format_t * format_2);
2168
2169
2180 GAVL_PUBLIC
2181 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
2182 float * off_x, float * off_y);
2183
2184
2185
2198 GAVL_PUBLIC
2199 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
2200 const gavl_video_format_t * src);
2201
2209 GAVL_PUBLIC
2210 int gavl_video_format_get_image_size(const gavl_video_format_t * format);
2211
2227 GAVL_PUBLIC
2228 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format,
2229 gavl_video_format_t * channel_format,
2230 gavl_color_channel_t ch);
2231
2232
2239 GAVL_PUBLIC
2240 void gavl_video_format_dump(const gavl_video_format_t * format);
2241
2242
2265 typedef struct
2266 {
2267 uint8_t * planes[GAVL_MAX_PLANES];
2268 int strides[GAVL_MAX_PLANES];
2270 void * user_data;
2271 int64_t timestamp;
2272 int64_t duration;
2273 gavl_interlace_mode_t interlace_mode;
2274 gavl_timecode_t timecode;
2275 } gavl_video_frame_t;
2276
2277
2289 GAVL_PUBLIC
2290 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
2291
2302 GAVL_PUBLIC
2303 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
2304
2305
2306
2316 GAVL_PUBLIC
2317 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
2318
2330 GAVL_PUBLIC
2331 void gavl_video_frame_null(gavl_video_frame_t*frame);
2332
2341 GAVL_PUBLIC
2342 void gavl_video_frame_clear(gavl_video_frame_t * frame,
2343 const gavl_video_format_t * format);
2344
2354 GAVL_PUBLIC
2355 void gavl_video_frame_fill(gavl_video_frame_t * frame,
2356 const gavl_video_format_t * format,
2357 const float * color);
2358
2371 GAVL_PUBLIC
2372 void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
2373 const gavl_video_frame_t * src1,
2374 const gavl_video_frame_t * src2,
2375 const gavl_video_format_t * format);
2376
2389 GAVL_PUBLIC
2390 void gavl_video_frame_psnr(double * psnr,
2391 const gavl_video_frame_t * src1,
2392 const gavl_video_frame_t * src2,
2393 const gavl_video_format_t * format);
2394
2421 GAVL_PUBLIC
2422 int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
2423 const gavl_video_frame_t * src2,
2424 gavl_video_frame_t * dst,
2425 const gavl_video_format_t * format);
2426
2440 GAVL_PUBLIC
2441 void gavl_video_frame_copy(const gavl_video_format_t * format,
2442 gavl_video_frame_t * dst,
2443 const gavl_video_frame_t * src);
2444
2457 GAVL_PUBLIC
2458 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
2459 gavl_video_frame_t * dst,
2460 const gavl_video_frame_t * src, int plane);
2461
2473 GAVL_PUBLIC
2474 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
2475 gavl_video_frame_t * dst,
2476 const gavl_video_frame_t * src);
2477
2489 GAVL_PUBLIC
2490 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
2491 gavl_video_frame_t * dst,
2492 const gavl_video_frame_t * src);
2493
2505 GAVL_PUBLIC
2506 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
2507 gavl_video_frame_t * dst,
2508 const gavl_video_frame_t * src);
2509
2522 GAVL_PUBLIC
2523 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
2524 const gavl_video_frame_t * src);
2525
2526
2544 GAVL_PUBLIC
2545 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
2546 const gavl_video_frame_t * src,
2547 gavl_video_frame_t * dst,
2548 gavl_rectangle_i_t * src_rect);
2549
2565 GAVL_PUBLIC
2566 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
2567 const gavl_video_frame_t * src,
2568 gavl_video_frame_t * dst,
2569 int field);
2570
2571
2572
2585 GAVL_PUBLIC
2586 void gavl_video_frame_dump(gavl_video_frame_t * frame,
2587 const gavl_video_format_t * format,
2588 const char * namebase);
2589
2600 GAVL_PUBLIC
2601 void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
2602 const gavl_video_format_t * format);
2603
2616 GAVL_PUBLIC
2617 void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
2618 const gavl_video_format_t * format,
2619 uint8_t * buffer);
2620
2635 GAVL_PUBLIC
2636 int gavl_video_frame_extract_channel(const gavl_video_format_t * format,
2637 gavl_color_channel_t ch,
2638 const gavl_video_frame_t * src,
2639 gavl_video_frame_t * dst);
2640
2656 GAVL_PUBLIC
2657 int gavl_video_frame_insert_channel(const gavl_video_format_t * format,
2658 gavl_color_channel_t ch,
2659 const gavl_video_frame_t * src,
2660 gavl_video_frame_t * dst);
2661
2662
2674 GAVL_PUBLIC
2675 int gavl_video_frames_equal(const gavl_video_format_t * format,
2676 const gavl_video_frame_t * f1,
2677 const gavl_video_frame_t * f2);
2678
2679
2680 /*****************************
2681 Conversion options
2682 ******************************/
2683
2699 #define GAVL_FORCE_DEINTERLACE (1<<0)
2700
2705 #define GAVL_CONVOLVE_CHROMA (1<<1)
2706
2711 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
2712
2720 #define GAVL_RESAMPLE_CHROMA (1<<3)
2721
2729 typedef enum
2730 {
2731 GAVL_ALPHA_IGNORE = 0,
2732 GAVL_ALPHA_BLEND_COLOR
2733 } gavl_alpha_mode_t;
2734
2741 typedef enum
2742 {
2743 GAVL_DEINTERLACE_NONE = 0,
2744 GAVL_DEINTERLACE_COPY = 1,
2745 GAVL_DEINTERLACE_SCALE = 2,
2746 GAVL_DEINTERLACE_BLEND = 3
2747 } gavl_deinterlace_mode_t;
2748
2755 typedef enum
2756 {
2757 GAVL_DEINTERLACE_DROP_TOP,
2758 GAVL_DEINTERLACE_DROP_BOTTOM,
2759 } gavl_deinterlace_drop_mode_t;
2760
2765 typedef enum
2766 {
2767 GAVL_SCALE_AUTO,
2768 GAVL_SCALE_NEAREST,
2769 GAVL_SCALE_BILINEAR,
2770 GAVL_SCALE_QUADRATIC,
2771 GAVL_SCALE_CUBIC_BSPLINE,
2772 GAVL_SCALE_CUBIC_MITCHELL,
2773 GAVL_SCALE_CUBIC_CATMULL,
2774 GAVL_SCALE_SINC_LANCZOS,
2775 GAVL_SCALE_NONE,
2776 } gavl_scale_mode_t;
2777
2787 typedef enum
2788 {
2789 GAVL_DOWNSCALE_FILTER_AUTO = 0,
2790 GAVL_DOWNSCALE_FILTER_NONE,
2791 GAVL_DOWNSCALE_FILTER_WIDE,
2792 GAVL_DOWNSCALE_FILTER_GAUSS,
2793 } gavl_downscale_filter_t;
2794
2801 typedef struct gavl_video_options_s gavl_video_options_t;
2802
2803 /* Default Options */
2804
2810 GAVL_PUBLIC
2811 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
2812
2822 GAVL_PUBLIC
2823 gavl_video_options_t * gavl_video_options_create();
2824
2831 GAVL_PUBLIC
2832 void gavl_video_options_copy(gavl_video_options_t * dst,
2833 const gavl_video_options_t * src);
2834
2840 GAVL_PUBLIC
2841 void gavl_video_options_destroy(gavl_video_options_t * opt);
2842
2843
2858 GAVL_PUBLIC
2859 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
2860 const gavl_rectangle_f_t * src_rect,
2861 const gavl_rectangle_i_t * dst_rect);
2862
2870 GAVL_PUBLIC
2871 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
2872 gavl_rectangle_f_t * src_rect,
2873 gavl_rectangle_i_t * dst_rect);
2874
2881 GAVL_PUBLIC
2882 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
2883
2890 GAVL_PUBLIC
2891 int gavl_video_options_get_quality(gavl_video_options_t * opt);
2892
2893
2900 GAVL_PUBLIC
2901 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
2902 int conversion_flags);
2903
2910 GAVL_PUBLIC
2911 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
2912
2919 GAVL_PUBLIC
2920 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
2921 gavl_alpha_mode_t alpha_mode);
2922
2929 GAVL_PUBLIC gavl_alpha_mode_t
2930 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
2931
2932
2939 GAVL_PUBLIC
2940 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
2941 gavl_scale_mode_t scale_mode);
2942
2949 GAVL_PUBLIC gavl_scale_mode_t
2950 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
2951
2952
2959 GAVL_PUBLIC
2960 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
2961 int order);
2962
2969 GAVL_PUBLIC
2970 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
2971
2972
2979 GAVL_PUBLIC
2980 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
2981 const float * color);
2982
2989 GAVL_PUBLIC
2990 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
2991 float * color);
2992
2999 GAVL_PUBLIC
3000 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
3001 gavl_deinterlace_mode_t deinterlace_mode);
3002
3009 GAVL_PUBLIC gavl_deinterlace_mode_t
3010 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
3011
3018 GAVL_PUBLIC
3019 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
3020 gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
3021
3028 GAVL_PUBLIC gavl_deinterlace_drop_mode_t
3029 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
3030
3039 GAVL_PUBLIC
3040 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt,
3041 gavl_downscale_filter_t f);
3042
3043
3052 GAVL_PUBLIC gavl_downscale_filter_t
3053 gavl_video_options_get_downscale_filter(gavl_video_options_t * opt);
3054
3072 GAVL_PUBLIC
3073 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt,
3074 float f);
3075
3084 GAVL_PUBLIC
3085 float gavl_video_options_get_downscale_blur(gavl_video_options_t * opt);
3086
3095 GAVL_PUBLIC
3096 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n);
3097
3098
3107 GAVL_PUBLIC
3108 int gavl_video_options_get_num_threads(gavl_video_options_t * opt);
3109
3119 GAVL_PUBLIC
3120 void gavl_video_options_set_run_func(gavl_video_options_t * opt,
3121 gavl_video_run_func func,
3122 void * client_data);
3123
3133 GAVL_PUBLIC
3134 gavl_video_run_func gavl_video_options_get_run_func(gavl_video_options_t * opt,
3135 void ** client_data);
3136
3146 GAVL_PUBLIC
3147 void gavl_video_options_set_stop_func(gavl_video_options_t * opt,
3148 gavl_video_stop_func func,
3149 void * client_data);
3150
3160 GAVL_PUBLIC
3161 gavl_video_stop_func gavl_video_options_get_stop_func(gavl_video_options_t * opt,
3162 void ** client_data);
3163
3164
3165 /***************************************************
3166 * Create and destroy video converters
3167 ***************************************************/
3168
3201 typedef struct gavl_video_converter_s gavl_video_converter_t;
3202
3208 GAVL_PUBLIC
3209 gavl_video_converter_t * gavl_video_converter_create();
3210
3216 GAVL_PUBLIC
3217 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
3218
3219 /**************************************************
3220 * Get options. Change the options with the gavl_video_options_set_*
3221 * functions above
3222 **************************************************/
3223
3232 GAVL_PUBLIC gavl_video_options_t *
3233 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
3234
3235
3249 GAVL_PUBLIC
3250 int gavl_video_converter_init(gavl_video_converter_t* cnv,
3251 const gavl_video_format_t * input_format,
3252 const gavl_video_format_t * output_format);
3253
3266 GAVL_PUBLIC
3267 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
3268
3269
3270 /***************************************************
3271 * Convert a frame
3272 ***************************************************/
3273
3281 GAVL_PUBLIC
3282 void gavl_video_convert(gavl_video_converter_t * cnv,
3283 const gavl_video_frame_t * input_frame,
3284 gavl_video_frame_t * output_frame);
3285
3317 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
3318
3324 GAVL_PUBLIC
3325 gavl_video_scaler_t * gavl_video_scaler_create();
3326
3332 GAVL_PUBLIC
3333 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
3334
3343 GAVL_PUBLIC gavl_video_options_t *
3344 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
3345
3358 GAVL_PUBLIC
3359 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
3360 const gavl_video_format_t * src_format,
3361 const gavl_video_format_t * dst_format);
3362
3384 GAVL_PUBLIC
3385 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
3386 const gavl_video_format_t * format,
3387 int h_radius, const float * h_coeffs,
3388 int v_radius, const float * v_coeffs);
3389
3397 GAVL_PUBLIC
3398 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
3399 const gavl_video_frame_t * input_frame,
3400 gavl_video_frame_t * output_frame);
3401
3417 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
3418
3424 GAVL_PUBLIC
3425 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
3426
3432 GAVL_PUBLIC
3433 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
3434
3443 GAVL_PUBLIC gavl_video_options_t *
3444 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
3445
3456 GAVL_PUBLIC
3457 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
3458 const gavl_video_format_t * src_format);
3459
3460
3468 GAVL_PUBLIC
3469 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
3470 const gavl_video_frame_t * input_frame,
3471 gavl_video_frame_t * output_frame);
3472
3473
3474
3475 /**************************************************
3476 * Transparent overlays
3477 **************************************************/
3478
3479 /* Overlay struct */
3480
3508 typedef struct
3509 {
3510 gavl_video_frame_t * frame;
3511 gavl_rectangle_i_t ovl_rect;
3512 int dst_x;
3513 int dst_y;
3514 } gavl_overlay_t;
3515
3522 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
3523
3529 GAVL_PUBLIC
3530 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
3531
3537 GAVL_PUBLIC
3538 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
3539
3546 GAVL_PUBLIC gavl_video_options_t *
3547 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
3548
3564 GAVL_PUBLIC
3565 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
3566 const gavl_video_format_t * frame_format,
3567 gavl_video_format_t * overlay_format);
3568
3578 GAVL_PUBLIC
3579 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
3580 gavl_overlay_t * ovl);
3581
3588 GAVL_PUBLIC
3589 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
3590 gavl_video_frame_t * dst_frame);
3591
3613 typedef struct gavl_image_transform_s gavl_image_transform_t;
3614
3628 typedef void (*gavl_image_transform_func)(void * priv,
3629 double xdst,
3630 double ydst,
3631 double * xsrc,
3632 double * ysrc);
3633
3634
3641 GAVL_PUBLIC
3642 gavl_image_transform_t * gavl_image_transform_create();
3643
3649 GAVL_PUBLIC
3650 void gavl_image_transform_destroy(gavl_image_transform_t * t);
3651
3670 GAVL_PUBLIC
3671 int gavl_image_transform_init(gavl_image_transform_t * t,
3672 gavl_video_format_t * format,
3673 gavl_image_transform_func func, void * priv);
3674
3682 GAVL_PUBLIC
3683 void gavl_image_transform_transform(gavl_image_transform_t * t,
3684 gavl_video_frame_t * in_frame,
3685 gavl_video_frame_t * out_frame);
3686
3697 GAVL_PUBLIC gavl_video_options_t *
3698 gavl_image_transform_get_options(gavl_image_transform_t * t);
3699
3722 typedef struct
3723 {
3724 int64_t offset;
3725 /* Primary */
3726 int64_t num_entries;
3727 int64_t entries_alloc;
3728
3729 struct
3730 {
3731 int64_t num_frames;
3732 int64_t duration;
3733 } * entries;
3734
3735 int num_timecodes;
3736 int timecodes_alloc;
3737
3738 struct
3739 {
3740 int64_t pts;
3741 gavl_timecode_t tc;
3742 } * timecodes;
3743
3744 /* Secondary */
3745
3746 } gavl_frame_table_t;
3747
3753 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create();
3754
3765 GAVL_PUBLIC gavl_frame_table_t *
3766 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
3767 gavl_timecode_format_t * fmt_ret);
3768
3780 GAVL_PUBLIC gavl_frame_table_t *
3781 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
3782 int64_t num_frames,
3783 gavl_timecode_t start_timecode);
3784
3792 GAVL_PUBLIC gavl_frame_table_t *
3793 gavl_frame_table_copy(const gavl_frame_table_t * tab);
3794
3795
3796
3803 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t);
3804
3812 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
3813
3822 GAVL_PUBLIC void
3823 gavl_frame_table_append_timecode(gavl_frame_table_t * t,
3824 int64_t pts, gavl_timecode_t tc);
3825
3836 GAVL_PUBLIC int64_t
3837 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t,
3838 int64_t frame, int * duration);
3839
3850 GAVL_PUBLIC int64_t
3851 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t,
3852 int64_t time,
3853 int64_t * start_time);
3854
3865 GAVL_PUBLIC gavl_timecode_t
3866 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t,
3867 int64_t time,
3868 int64_t * start_time,
3869 const gavl_timecode_format_t * fmt);
3870
3880 GAVL_PUBLIC int64_t
3881 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t,
3882 gavl_timecode_t tc,
3883 const gavl_timecode_format_t * fmt);
3884
3885
3896 GAVL_PUBLIC gavl_timecode_t
3897 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t,
3898 int64_t frame,
3899 int64_t * start_time,
3900 const gavl_timecode_format_t * fmt);
3901
3902
3903
3911 GAVL_PUBLIC int64_t
3912 gavl_frame_table_num_frames(const gavl_frame_table_t * t);
3913
3921 GAVL_PUBLIC int64_t
3922 gavl_frame_table_duration(const gavl_frame_table_t * t);
3923
3931 GAVL_PUBLIC int64_t
3932 gavl_frame_table_end_time(const gavl_frame_table_t * t);
3933
3942 GAVL_PUBLIC
3943 int gavl_frame_table_save(const gavl_frame_table_t * tab,
3944 const char * filename);
3945
3953 GAVL_PUBLIC
3954 gavl_frame_table_t * gavl_frame_table_load(const char * filename);
3955
3962 GAVL_PUBLIC void
3963 gavl_frame_table_dump(const gavl_frame_table_t * t);
3964
3965
3966
3967
3968
3969
3975 #ifdef __cplusplus
3976 }
3977 #endif
3978
3979 #endif /* GAVL_H_INCLUDED */