gavl

- Main Page
- Modules
- Data Structures
- Files
- Directories

- File List
- Globals

# gavl.h

Go to the documentation of this file.

    00001 /*****************************************************************
    00002  * gavl - a general purpose audio/video processing library
    00003  *
    00004  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
    00005  * gmerlin-general@lists.sourceforge.net
    00006  * http://gmerlin.sourceforge.net
    00007  *
    00008  * This program is free software: you can redistribute it and/or modify
    00009  * it under the terms of the GNU General Public License as published by
    00010  * the Free Software Foundation, either version 2 of the License, or
    00011  * (at your option) any later version.
    00012  *
    00013  * This program is distributed in the hope that it will be useful,
    00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016  * GNU General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU General Public License
    00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    00020  * *****************************************************************/
    00021
    00027 #ifndef GAVL_H_INCLUDED
    00028 #define GAVL_H_INCLUDED
    00029
    00030 #include <inttypes.h>
    00031
    00032 #include <gavl/gavldefs.h>
    00033 #include <gavl/gavltime.h>
    00034
    00035 #ifdef __cplusplus
    00036 extern "C" {
    00037 #endif
    00038
    00039 #include <gavl/timecode.h>
    00040
    00041
    00064 typedef void (*gavl_video_process_func)(void * data, int start, int end);
    00065
    00079 typedef void (*gavl_video_run_func)(gavl_video_process_func func,
    00080                                     void * gavl_data,
    00081                                     int start, int end,
    00082                                     void * client_data, int thread);
    00083
    00092 typedef void (*gavl_video_stop_func)(void * client_data, int thread);
    00093
    00102 typedef struct gavl_video_format_s gavl_video_format_t;
    00103
    00104
    00105 /* Quality levels */
    00106
    00130 #define GAVL_QUALITY_FASTEST 1
    00131
    00138 #define GAVL_QUALITY_BEST    5
    00139
    00146 #define GAVL_QUALITY_DEFAULT 2
    00147
    00159 #define GAVL_ACCEL_MMX      (1<<0) //!< MMX
    00160 #define GAVL_ACCEL_MMXEXT   (1<<1) //!< Extended MMX (a.k.a MMX2)
    00161 #define GAVL_ACCEL_SSE      (1<<2) //!< Intel SSE
    00162 #define GAVL_ACCEL_SSE2     (1<<3) //!< Intel SSE2
    00163 #define GAVL_ACCEL_SSE3     (1<<4) //!< Intel SSE3
    00164 #define GAVL_ACCEL_3DNOW    (1<<5) //!< AMD 3Dnow
    00165 #define GAVL_ACCEL_3DNOWEXT (1<<6) //!< AMD 3Dnow ext
    00166 #define GAVL_ACCEL_SSSE3    (1<<7) //!< Intel SSSE3
    00167
    00172 GAVL_PUBLIC int gavl_accel_supported();
    00173
    00182 /* Sample formats: all multibyte numbers are native endian */
    00183
    00196 #define GAVL_MAX_CHANNELS 128
    00197
    00204 typedef enum
    00205   {
    00206     GAVL_SAMPLE_NONE   = 0,
    00207     GAVL_SAMPLE_U8     = 1,
    00208     GAVL_SAMPLE_S8     = 2,
    00209     GAVL_SAMPLE_U16    = 3,
    00210     GAVL_SAMPLE_S16    = 4,
    00211     GAVL_SAMPLE_S32    = 5,
    00212     GAVL_SAMPLE_FLOAT  = 6,
    00213     GAVL_SAMPLE_DOUBLE = 7
    00214   } gavl_sample_format_t;
    00215
    00221 typedef enum
    00222   {
    00223     GAVL_INTERLEAVE_NONE = 0,
    00224     GAVL_INTERLEAVE_2    = 1,
    00225     GAVL_INTERLEAVE_ALL  = 2
    00226   } gavl_interleave_mode_t;
    00227
    00235 typedef enum
    00236   {
    00237     GAVL_CHID_NONE         = 0,
    00238     GAVL_CHID_FRONT_CENTER,
    00239     GAVL_CHID_FRONT_LEFT,
    00240     GAVL_CHID_FRONT_RIGHT,
    00241     GAVL_CHID_FRONT_CENTER_LEFT,
    00242     GAVL_CHID_FRONT_CENTER_RIGHT,
    00243     GAVL_CHID_REAR_LEFT,
    00244     GAVL_CHID_REAR_RIGHT,
    00245     GAVL_CHID_REAR_CENTER,
    00246     GAVL_CHID_SIDE_LEFT,
    00247     GAVL_CHID_SIDE_RIGHT,
    00248     GAVL_CHID_LFE,
    00249     GAVL_CHID_AUX,
    00250   } gavl_channel_id_t;
    00251
    00260 typedef struct
    00261   {
    00262   int samples_per_frame;
    00263   int samplerate;
    00264   int num_channels;
    00265   gavl_sample_format_t   sample_format;
    00266   gavl_interleave_mode_t interleave_mode;
    00268   float center_level;
    00269   float rear_level;
    00271   gavl_channel_id_t channel_locations[GAVL_MAX_CHANNELS];
    00273   } gavl_audio_format_t;
    00274
    00275
    00276 /* Audio format -> string conversions */
    00277
    00285 GAVL_PUBLIC
    00286 const char * gavl_sample_format_to_string(gavl_sample_format_t format);
    00287
    00296 GAVL_PUBLIC
    00297 gavl_sample_format_t gavl_string_to_sample_format(const char * str);
    00298
    00304 GAVL_PUBLIC
    00305 int gavl_num_sample_formats();
    00306
    00313 GAVL_PUBLIC
    00314 gavl_sample_format_t gavl_get_sample_format(int index);
    00315
    00322 GAVL_PUBLIC
    00323 const char * gavl_channel_id_to_string(gavl_channel_id_t id);
    00324
    00325
    00332 GAVL_PUBLIC
    00333 const char * gavl_interleave_mode_to_string(gavl_interleave_mode_t mode);
    00334
    00341 GAVL_PUBLIC
    00342 void gavl_audio_format_dump(const gavl_audio_format_t * format);
    00343
    00352 GAVL_PUBLIC
    00353 int gavl_channel_index(const gavl_audio_format_t * format, gavl_channel_id_t id);
    00354
    00361 GAVL_PUBLIC
    00362 int gavl_front_channels(const gavl_audio_format_t * format);
    00363
    00370 GAVL_PUBLIC
    00371 int gavl_rear_channels(const gavl_audio_format_t * format);
    00372
    00379 GAVL_PUBLIC
    00380 int gavl_side_channels(const gavl_audio_format_t * format);
    00381
    00388 GAVL_PUBLIC
    00389 int gavl_aux_channels(const gavl_audio_format_t * format);
    00390
    00391
    00392
    00399 GAVL_PUBLIC
    00400 int gavl_lfe_channels(const gavl_audio_format_t * format);
    00401
    00409 GAVL_PUBLIC
    00410 void gavl_audio_format_copy(gavl_audio_format_t * dst,
    00411                             const gavl_audio_format_t * src);
    00412
    00421 GAVL_PUBLIC
    00422 int gavl_audio_formats_equal(const gavl_audio_format_t * format_1,
    00423                               const gavl_audio_format_t * format_2);
    00424
    00436 GAVL_PUBLIC
    00437 void gavl_set_channel_setup(gavl_audio_format_t * format);
    00438
    00445 GAVL_PUBLIC
    00446 int gavl_bytes_per_sample(gavl_sample_format_t format);
    00447
    00462 typedef union
    00463   {
    00464   uint8_t * u_8;
    00465   int8_t *  s_8;
    00467   uint16_t * u_16;
    00468   int16_t  * s_16;
    00470   uint32_t * u_32;
    00471   int32_t  * s_32;
    00473   float * f;
    00474   double * d;
    00475   } gavl_audio_samples_t;
    00476
    00482 typedef union
    00483   {
    00484   uint8_t * u_8[GAVL_MAX_CHANNELS];
    00485   int8_t *  s_8[GAVL_MAX_CHANNELS];
    00487   uint16_t * u_16[GAVL_MAX_CHANNELS];
    00488   int16_t  * s_16[GAVL_MAX_CHANNELS];
    00490   uint32_t * u_32[GAVL_MAX_CHANNELS];
    00491   int32_t  * s_32[GAVL_MAX_CHANNELS];
    00493   float * f[GAVL_MAX_CHANNELS];
    00494   double * d[GAVL_MAX_CHANNELS];
    00496   } gavl_audio_channels_t;
    00497
    00514 typedef struct
    00515   {
    00516   gavl_audio_samples_t  samples;
    00517   gavl_audio_channels_t channels;
    00518   int valid_samples;
    00519   int64_t timestamp;
    00520   int channel_stride;
    00521   } gavl_audio_frame_t;
    00522
    00534 GAVL_PUBLIC
    00535 gavl_audio_frame_t * gavl_audio_frame_create(const gavl_audio_format_t* format);
    00536
    00548 GAVL_PUBLIC
    00549 void gavl_audio_frame_null(gavl_audio_frame_t * frame);
    00550
    00560 GAVL_PUBLIC
    00561 void gavl_audio_frame_destroy(gavl_audio_frame_t * frame);
    00562
    00572 GAVL_PUBLIC
    00573 void gavl_audio_frame_mute(gavl_audio_frame_t * frame,
    00574                            const gavl_audio_format_t * format);
    00575
    00586 GAVL_PUBLIC
    00587 void gavl_audio_frame_mute_samples(gavl_audio_frame_t * frame,
    00588                                    const gavl_audio_format_t * format,
    00589                                    int num_samples);
    00590
    00591
    00592
    00603 GAVL_PUBLIC
    00604 void gavl_audio_frame_mute_channel(gavl_audio_frame_t * frame,
    00605                                    const gavl_audio_format_t * format,
    00606                                    int channel);
    00607
    00628 GAVL_PUBLIC
    00629 int gavl_audio_frame_copy(const gavl_audio_format_t * format,
    00630                           gavl_audio_frame_t * dst,
    00631                           const gavl_audio_frame_t * src,
    00632                           int dst_pos,
    00633                           int src_pos,
    00634                           int dst_size,
    00635                           int src_size);
    00636
    00649 GAVL_PUBLIC
    00650 void gavl_audio_frame_copy_ptrs(const gavl_audio_format_t * format,
    00651                                 gavl_audio_frame_t * dst,
    00652                                 const gavl_audio_frame_t * src);
    00653
    00671 GAVL_PUBLIC
    00672 void gavl_audio_frame_get_subframe(const gavl_audio_format_t * format,
    00673                                    gavl_audio_frame_t * src,
    00674                                    gavl_audio_frame_t * dst,
    00675                                    int start, int len);
    00676
    00689 GAVL_PUBLIC
    00690 int gavl_audio_frames_equal(const gavl_audio_format_t * format,
    00691                             const gavl_audio_frame_t * f1,
    00692                             const gavl_audio_frame_t * f2);
    00693
    00713 GAVL_PUBLIC
    00714 int gavl_audio_frame_plot(const gavl_audio_format_t * format,
    00715                           const gavl_audio_frame_t * frame,
    00716                           const char * name_base);
    00717
    00718
    00733 #define GAVL_AUDIO_FRONT_TO_REAR_COPY (1<<0)
    00738 #define GAVL_AUDIO_FRONT_TO_REAR_MUTE (1<<1)
    00743 #define GAVL_AUDIO_FRONT_TO_REAR_DIFF (1<<2)
    00748 #define GAVL_AUDIO_FRONT_TO_REAR_MASK           \
    00749 (GAVL_AUDIO_FRONT_TO_REAR_COPY | \
    00750 GAVL_AUDIO_FRONT_TO_REAR_MUTE | \
    00751  GAVL_AUDIO_FRONT_TO_REAR_DIFF)
    00753 /* Options for mixing stereo to mono */
    00754
    00757 #define GAVL_AUDIO_STEREO_TO_MONO_LEFT  (1<<3)
    00760 #define GAVL_AUDIO_STEREO_TO_MONO_RIGHT (1<<4)
    00763 #define GAVL_AUDIO_STEREO_TO_MONO_MIX   (1<<5)
    00767 #define GAVL_AUDIO_STEREO_TO_MONO_MASK \
    00768 (GAVL_AUDIO_STEREO_TO_MONO_LEFT | \
    00769 GAVL_AUDIO_STEREO_TO_MONO_RIGHT | \
    00770 GAVL_AUDIO_STEREO_TO_MONO_MIX)
    00775 #define GAVL_AUDIO_NORMALIZE_MIX_MATRIX (1<<6)
    00782 typedef enum
    00783   {
    00784     GAVL_AUDIO_DITHER_NONE   = 0,
    00785     GAVL_AUDIO_DITHER_AUTO   = 1,
    00786     GAVL_AUDIO_DITHER_RECT   = 2,
    00787     GAVL_AUDIO_DITHER_TRI    = 3,
    00788     GAVL_AUDIO_DITHER_SHAPED = 4,
    00789   } gavl_audio_dither_mode_t;
    00790
    00795 typedef enum
    00796   {
    00797     GAVL_RESAMPLE_AUTO        = 0,
    00798     GAVL_RESAMPLE_ZOH         = 1,
    00799     GAVL_RESAMPLE_LINEAR      = 2,
    00800     GAVL_RESAMPLE_SINC_FAST   = 3,
    00801     GAVL_RESAMPLE_SINC_MEDIUM = 4,
    00802     GAVL_RESAMPLE_SINC_BEST   = 5
    00803   } gavl_resample_mode_t;
    00804
    00811 typedef struct gavl_audio_options_s gavl_audio_options_t;
    00812
    00819 GAVL_PUBLIC
    00820 void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality);
    00821
    00828 GAVL_PUBLIC
    00829 int gavl_audio_options_get_quality(gavl_audio_options_t * opt);
    00830
    00837 GAVL_PUBLIC
    00838 void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t mode);
    00839
    00846 GAVL_PUBLIC
    00847 gavl_audio_dither_mode_t gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt);
    00848
    00849
    00856 GAVL_PUBLIC
    00857 void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t mode);
    00858
    00865 GAVL_PUBLIC
    00866 gavl_resample_mode_t gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt);
    00867
    00874 GAVL_PUBLIC
    00875 void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
    00876                                              int flags);
    00877
    00884 GAVL_PUBLIC
    00885 int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt);
    00886
    00892 GAVL_PUBLIC
    00893 void gavl_audio_options_set_defaults(gavl_audio_options_t * opt);
    00894
    00911 GAVL_PUBLIC
    00912 void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt,
    00913                                        const double ** matrix);
    00914
    00923 GAVL_PUBLIC
    00924 const double ** gavl_audio_options_get_mix_matrix(gavl_audio_options_t * opt);
    00925
    00935 GAVL_PUBLIC
    00936 gavl_audio_options_t * gavl_audio_options_create();
    00937
    00944 GAVL_PUBLIC
    00945 void gavl_audio_options_copy(gavl_audio_options_t * dst,
    00946                              const gavl_audio_options_t * src);
    00947
    00953 GAVL_PUBLIC
    00954 void gavl_audio_options_destroy(gavl_audio_options_t * opt);
    00955
    00956
    00957
    00958 /* Audio converter */
    00959
    00993 typedef struct gavl_audio_converter_s gavl_audio_converter_t;
    00994
    01000 GAVL_PUBLIC
    01001 gavl_audio_converter_t * gavl_audio_converter_create();
    01002
    01008 GAVL_PUBLIC
    01009 void gavl_audio_converter_destroy(gavl_audio_converter_t* cnv);
    01010
    01019 GAVL_PUBLIC
    01020 gavl_audio_options_t * gavl_audio_converter_get_options(gavl_audio_converter_t*cnv);
    01021
    01022
    01037 GAVL_PUBLIC
    01038 int gavl_audio_converter_init(gavl_audio_converter_t* cnv,
    01039                               const gavl_audio_format_t * input_format,
    01040                               const gavl_audio_format_t * output_format);
    01041
    01056 GAVL_PUBLIC
    01057 int gavl_audio_converter_init_resample(gavl_audio_converter_t * cnv,
    01058                                    const gavl_audio_format_t * format);
    01059
    01074 GAVL_PUBLIC
    01075 int gavl_audio_converter_reinit(gavl_audio_converter_t* cnv);
    01076
    01077
    01091 GAVL_PUBLIC
    01092 void gavl_audio_convert(gavl_audio_converter_t * cnv,
    01093                         const gavl_audio_frame_t * input_frame,
    01094                         gavl_audio_frame_t * output_frame);
    01095
    01096
    01115 GAVL_PUBLIC
    01116 int gavl_audio_converter_set_resample_ratio(gavl_audio_converter_t * cnv,
    01117                 double ratio ) ;
    01118
    01119
    01135 GAVL_PUBLIC
    01136 void gavl_audio_converter_resample(gavl_audio_converter_t * cnv,
    01137                               gavl_audio_frame_t * input_frame,
    01138                               gavl_audio_frame_t * output_frame,
    01139                               double ratio);
    01140
    01141
    01155 typedef struct gavl_volume_control_s gavl_volume_control_t;
    01156
    01157 /* Create / destroy */
    01158
    01164 GAVL_PUBLIC
    01165 gavl_volume_control_t * gavl_volume_control_create();
    01166
    01172 GAVL_PUBLIC
    01173 void gavl_volume_control_destroy(gavl_volume_control_t *ctrl);
    01174
    01182 GAVL_PUBLIC
    01183 void gavl_volume_control_set_format(gavl_volume_control_t *ctrl,
    01184                                     const gavl_audio_format_t * format);
    01185
    01192 GAVL_PUBLIC
    01193 void gavl_volume_control_set_volume(gavl_volume_control_t * ctrl,
    01194                                     float volume);
    01195
    01202 GAVL_PUBLIC
    01203 void gavl_volume_control_apply(gavl_volume_control_t *ctrl,
    01204                                gavl_audio_frame_t * frame);
    01205
    01221 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
    01222
    01223 /* Create / destroy */
    01224
    01230 GAVL_PUBLIC
    01231 gavl_peak_detector_t * gavl_peak_detector_create();
    01232
    01238 GAVL_PUBLIC
    01239 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
    01240
    01250 GAVL_PUBLIC
    01251 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
    01252                                    const gavl_audio_format_t * format);
    01253
    01260 GAVL_PUBLIC
    01261 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
    01262                               gavl_audio_frame_t * frame);
    01263
    01276 GAVL_PUBLIC
    01277 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
    01278                                  double * min, double * max,
    01279                                  double * abs);
    01280
    01293 GAVL_PUBLIC
    01294 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
    01295                                   double * min, double * max,
    01296                                   double * abs);
    01297
    01303 GAVL_PUBLIC
    01304 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
    01305
    01315 #define GAVL_MAX_PLANES 4
    01327 typedef struct
    01328   {
    01329   int x;
    01330   int y;
    01331   int w;
    01332   int h;
    01333   } gavl_rectangle_i_t;
    01334
    01339 typedef struct
    01340   {
    01341   double x;
    01342   double y;
    01343   double w;
    01344   double h;
    01345   } gavl_rectangle_f_t;
    01346
    01353 GAVL_PUBLIC
    01354 void gavl_rectangle_i_crop_to_format(gavl_rectangle_i_t * r,
    01355                                    const gavl_video_format_t * format);
    01356
    01363 GAVL_PUBLIC
    01364 void gavl_rectangle_f_crop_to_format(gavl_rectangle_f_t * r,
    01365                                      const gavl_video_format_t * format);
    01366
    01381 GAVL_PUBLIC
    01382 void gavl_rectangle_crop_to_format_noscale(gavl_rectangle_i_t * src_rect,
    01383                                            gavl_rectangle_i_t * dst_rect,
    01384                                            const gavl_video_format_t * src_format,
    01385                                            const gavl_video_format_t * dst_format);
    01386
    01398 GAVL_PUBLIC
    01399 void gavl_rectangle_crop_to_format_scale(gavl_rectangle_f_t * src_rect,
    01400                                          gavl_rectangle_i_t * dst_rect,
    01401                                          const gavl_video_format_t * src_format,
    01402                                          const gavl_video_format_t * dst_format);
    01403
    01404
    01405
    01412 GAVL_PUBLIC
    01413 void gavl_rectangle_i_set_all(gavl_rectangle_i_t * r, const gavl_video_format_t * format);
    01414
    01421 GAVL_PUBLIC
    01422 void gavl_rectangle_f_set_all(gavl_rectangle_f_t * r, const gavl_video_format_t * format);
    01423
    01430 GAVL_PUBLIC
    01431 void gavl_rectangle_i_crop_left(gavl_rectangle_i_t * r,   int num_pixels);
    01432
    01439 GAVL_PUBLIC
    01440 void gavl_rectangle_i_crop_right(gavl_rectangle_i_t * r,  int num_pixels);
    01441
    01448 GAVL_PUBLIC
    01449 void gavl_rectangle_i_crop_top(gavl_rectangle_i_t * r,    int num_pixels);
    01450
    01457 GAVL_PUBLIC
    01458 void gavl_rectangle_i_crop_bottom(gavl_rectangle_i_t * r, int num_pixels);
    01459
    01466 GAVL_PUBLIC
    01467 void gavl_rectangle_f_crop_left(gavl_rectangle_f_t * r,   double num_pixels);
    01468
    01475 GAVL_PUBLIC
    01476 void gavl_rectangle_f_crop_right(gavl_rectangle_f_t * r,  double num_pixels);
    01477
    01484 GAVL_PUBLIC
    01485 void gavl_rectangle_f_crop_top(gavl_rectangle_f_t * r,    double num_pixels);
    01486
    01493 GAVL_PUBLIC
    01494 void gavl_rectangle_f_crop_bottom(gavl_rectangle_f_t * r, double num_pixels);
    01495
    01509 GAVL_PUBLIC
    01510 void gavl_rectangle_i_align(gavl_rectangle_i_t * r, int h_align, int v_align);
    01511
    01521 GAVL_PUBLIC
    01522 void gavl_rectangle_i_align_to_format(gavl_rectangle_i_t * r,
    01523                                       const gavl_video_format_t * format);
    01524
    01525
    01532 GAVL_PUBLIC
    01533 void gavl_rectangle_i_copy(gavl_rectangle_i_t * dst, const gavl_rectangle_i_t * src);
    01534
    01541 GAVL_PUBLIC
    01542 void gavl_rectangle_f_copy(gavl_rectangle_f_t * dst, const gavl_rectangle_f_t * src);
    01543
    01544
    01545
    01552 GAVL_PUBLIC
    01553 void gavl_rectangle_i_to_f(gavl_rectangle_f_t * dst, const gavl_rectangle_i_t * src);
    01554
    01561 GAVL_PUBLIC
    01562 void gavl_rectangle_f_to_i(gavl_rectangle_i_t * dst, const gavl_rectangle_f_t * src);
    01563
    01572 GAVL_PUBLIC
    01573 int gavl_rectangle_i_is_empty(const gavl_rectangle_i_t * r);
    01574
    01583 GAVL_PUBLIC
    01584 int gavl_rectangle_f_is_empty(const gavl_rectangle_f_t * r);
    01585
    01613 GAVL_PUBLIC
    01614 void gavl_rectangle_fit_aspect(gavl_rectangle_i_t * dst_rect,
    01615                                const gavl_video_format_t * src_format,
    01616                                const gavl_rectangle_f_t * src_rect,
    01617                                const gavl_video_format_t * dst_format,
    01618                                float zoom, float squeeze);
    01619
    01624 GAVL_PUBLIC
    01625 void gavl_rectangle_i_dump(const gavl_rectangle_i_t * r);
    01626
    01631 GAVL_PUBLIC
    01632 void gavl_rectangle_f_dump(const gavl_rectangle_f_t * r);
    01633
    01634
    01644 #define GAVL_PIXFMT_PLANAR (1<<8)
    01645
    01649 #define GAVL_PIXFMT_RGB    (1<<9)
    01650
    01654 #define GAVL_PIXFMT_YUV    (1<<10)
    01655
    01659 #define GAVL_PIXFMT_YUVJ   (1<<11)
    01660
    01664 #define GAVL_PIXFMT_ALPHA  (1<<12)
    01665
    01669 #define GAVL_PIXFMT_GRAY   (1<<13)
    01670
    01675 typedef enum
    01676   {
    01679     GAVL_PIXELFORMAT_NONE =  0,
    01680
    01683     GAVL_GRAY_8          =  1 | GAVL_PIXFMT_GRAY,
    01684
    01687     GAVL_GRAY_16          =  2 | GAVL_PIXFMT_GRAY,
    01688
    01691     GAVL_GRAY_FLOAT       =  3 | GAVL_PIXFMT_GRAY,
    01692
    01695     GAVL_GRAYA_16          =  1 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
    01696
    01699     GAVL_GRAYA_32          =  2 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
    01700
    01703     GAVL_GRAYA_FLOAT       =  3 | GAVL_PIXFMT_GRAY | GAVL_PIXFMT_ALPHA,
    01704
    01708     GAVL_RGB_15          =  1 | GAVL_PIXFMT_RGB,
    01712     GAVL_BGR_15          =  2 | GAVL_PIXFMT_RGB,
    01716     GAVL_RGB_16          =  3 | GAVL_PIXFMT_RGB,
    01720     GAVL_BGR_16          =  4 | GAVL_PIXFMT_RGB,
    01723     GAVL_RGB_24          =  5 | GAVL_PIXFMT_RGB,
    01726     GAVL_BGR_24          =  6 | GAVL_PIXFMT_RGB,
    01729     GAVL_RGB_32          =  7 | GAVL_PIXFMT_RGB,
    01732     GAVL_BGR_32          =  8 | GAVL_PIXFMT_RGB,
    01735     GAVL_RGBA_32         =  9 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
    01736
    01739     GAVL_RGB_48       = 10 | GAVL_PIXFMT_RGB,
    01742     GAVL_RGBA_64      = 11 | GAVL_PIXFMT_RGB | GAVL_PIXFMT_ALPHA,
    01743
    01746     GAVL_RGB_FLOAT    = 12 | GAVL_PIXFMT_RGB,
    01749     GAVL_RGBA_FLOAT   = 13 | GAVL_PIXFMT_RGB  | GAVL_PIXFMT_ALPHA,
    01750
    01753     GAVL_YUY2            = 1 | GAVL_PIXFMT_YUV,
    01756     GAVL_UYVY            = 2 | GAVL_PIXFMT_YUV,
    01759     GAVL_YUVA_32         = 3 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
    01762     GAVL_YUVA_64         = 4 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
    01765     GAVL_YUV_FLOAT       = 5 | GAVL_PIXFMT_YUV,
    01766
    01769     GAVL_YUVA_FLOAT       = 6 | GAVL_PIXFMT_YUV | GAVL_PIXFMT_ALPHA,
    01770
    01774     GAVL_YUV_420_P       = 1 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01777     GAVL_YUV_422_P       = 2 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01780     GAVL_YUV_444_P       = 3 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01783     GAVL_YUV_411_P       = 4 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01786     GAVL_YUV_410_P       = 5 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01787
    01790     GAVL_YUVJ_420_P      = 6 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
    01793     GAVL_YUVJ_422_P      = 7 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
    01796     GAVL_YUVJ_444_P      = 8 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV | GAVL_PIXFMT_YUVJ,
    01797
    01800     GAVL_YUV_444_P_16 = 9 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01803     GAVL_YUV_422_P_16 = 10 | GAVL_PIXFMT_PLANAR | GAVL_PIXFMT_YUV,
    01804
    01805   } gavl_pixelformat_t;
    01806
    01809 #define GAVL_PIXELFORMAT_1D_8 GAVL_GRAY_8
    01810
    01812 #define GAVL_PIXELFORMAT_2D_8 GAVL_GRAYA_16
    01813
    01815 #define GAVL_PIXELFORMAT_3D_8 GAVL_RGB_24
    01816
    01818 #define GAVL_PIXELFORMAT_4D_8 GAVL_RGBA_32
    01819
    01822 #define GAVL_PIXELFORMAT_1D_16 GAVL_GRAY_16
    01823
    01825 #define GAVL_PIXELFORMAT_2D_16 GAVL_GRAYA_32
    01826
    01828 #define GAVL_PIXELFORMAT_3D_16 GAVL_RGB_48
    01829
    01831 #define GAVL_PIXELFORMAT_4D_16 GAVL_RGBA_64
    01832
    01835 #define GAVL_PIXELFORMAT_1D_FLOAT GAVL_GRAY_FLOAT
    01836
    01838 #define GAVL_PIXELFORMAT_2D_FLOAT GAVL_GRAYA_FLOAT
    01839
    01841 #define GAVL_PIXELFORMAT_3D_FLOAT GAVL_RGB_FLOAT
    01842
    01844 #define GAVL_PIXELFORMAT_4D_FLOAT GAVL_RGBA_FLOAT
    01845
    01852 typedef enum
    01853   {
    01854     GAVL_CCH_RED,
    01855     GAVL_CCH_GREEN,
    01856     GAVL_CCH_BLUE,
    01857     GAVL_CCH_Y,
    01858     GAVL_CCH_CB,
    01859     GAVL_CCH_CR,
    01860     GAVL_CCH_ALPHA,
    01861   } gavl_color_channel_t;
    01862
    01863 /*
    01864  *  Colormodel related functions
    01865  */
    01866
    01873 #define gavl_pixelformat_is_gray(fmt) ((fmt) & GAVL_PIXFMT_GRAY)
    01874
    01875
    01882 #define gavl_pixelformat_is_rgb(fmt) ((fmt) & GAVL_PIXFMT_RGB)
    01883
    01890 #define gavl_pixelformat_is_yuv(fmt) ((fmt) & GAVL_PIXFMT_YUV)
    01891
    01898 #define gavl_pixelformat_is_jpeg_scaled(fmt) ((fmt) & GAVL_PIXFMT_YUVJ)
    01899
    01906 #define gavl_pixelformat_has_alpha(fmt) ((fmt) & GAVL_PIXFMT_ALPHA)
    01907
    01914 #define  gavl_pixelformat_is_planar(fmt) ((fmt) & GAVL_PIXFMT_PLANAR)
    01915
    01922 GAVL_PUBLIC
    01923 int gavl_pixelformat_num_planes(gavl_pixelformat_t pixelformat);
    01924
    01934 GAVL_PUBLIC
    01935 void gavl_pixelformat_chroma_sub(gavl_pixelformat_t pixelformat, int * sub_h, int * sub_v);
    01936
    01943 GAVL_PUBLIC
    01944 int gavl_pixelformat_bytes_per_component(gavl_pixelformat_t pixelformat);
    01945
    01952 GAVL_PUBLIC
    01953 int gavl_pixelformat_bytes_per_pixel(gavl_pixelformat_t pixelformat);
    01954
    01961 GAVL_PUBLIC
    01962 int gavl_pixelformat_bits_per_pixel(gavl_pixelformat_t pixelformat);
    01963
    01978 GAVL_PUBLIC
    01979 int gavl_pixelformat_conversion_penalty(gavl_pixelformat_t src,
    01980                                         gavl_pixelformat_t dst);
    01981
    01995 GAVL_PUBLIC gavl_pixelformat_t
    01996 gavl_pixelformat_get_best(gavl_pixelformat_t src,
    01997                           const gavl_pixelformat_t * dst_supported,
    01998                           int * penalty);
    01999
    02000
    02001
    02008 GAVL_PUBLIC
    02009 const char * gavl_pixelformat_to_string(gavl_pixelformat_t pixelformat);
    02010
    02017 GAVL_PUBLIC
    02018 gavl_pixelformat_t gavl_string_to_pixelformat(const char * name);
    02019
    02025 GAVL_PUBLIC
    02026 int gavl_num_pixelformats();
    02027
    02034 GAVL_PUBLIC
    02035 gavl_pixelformat_t gavl_get_pixelformat(int index);
    02036
    02037 /*  */
    02038
    02047 typedef enum
    02048   {
    02049     GAVL_CHROMA_PLACEMENT_DEFAULT = 0,
    02050     GAVL_CHROMA_PLACEMENT_MPEG2,
    02051     GAVL_CHROMA_PLACEMENT_DVPAL
    02052   } gavl_chroma_placement_t;
    02053
    02060 GAVL_PUBLIC
    02061 const char * gavl_chroma_placement_to_string(gavl_chroma_placement_t mode);
    02062
    02067 /* Changing the values alters the gmerlin-avdecoder index format */
    02068
    02069 typedef enum
    02070   {
    02071     GAVL_FRAMERATE_UNKNOWN     = -1,
    02072     GAVL_FRAMERATE_CONSTANT    = 0,
    02073     GAVL_FRAMERATE_VARIABLE    = 1,
    02074     GAVL_FRAMERATE_STILL       = 2,
    02075   } gavl_framerate_mode_t;
    02076
    02083 GAVL_PUBLIC
    02084 const char * gavl_framerate_mode_to_string(gavl_framerate_mode_t mode);
    02085
    02090 /* Changing the values alters the gmerlin-avdecoder index format */
    02091
    02092 typedef enum
    02093   {
    02094     GAVL_INTERLACE_UNKNOWN       = -1,
    02095     GAVL_INTERLACE_NONE          = 0,
    02096     GAVL_INTERLACE_TOP_FIRST     = 1,
    02097     GAVL_INTERLACE_BOTTOM_FIRST  = 2,
    02098     GAVL_INTERLACE_MIXED         = 3,
    02099     GAVL_INTERLACE_MIXED_TOP     = 4,
    02100     GAVL_INTERLACE_MIXED_BOTTOM  = 5,
    02101   } gavl_interlace_mode_t;
    02102
    02109 GAVL_PUBLIC
    02110 const char * gavl_interlace_mode_to_string(gavl_interlace_mode_t mode);
    02111
    02112
    02113 /* Video format structure */
    02114
    02119 struct gavl_video_format_s
    02120   {
    02121   int frame_width;
    02122   int frame_height;
    02124   int image_width;
    02125   int image_height;
    02127   /* Support for nonsquare pixels */
    02128
    02129   int pixel_width;
    02130   int pixel_height;
    02132   gavl_pixelformat_t pixelformat;
    02134   int frame_duration;
    02136   int timescale;
    02138   gavl_framerate_mode_t   framerate_mode;
    02139   gavl_chroma_placement_t chroma_placement;
    02141   gavl_interlace_mode_t   interlace_mode;
    02143   gavl_timecode_format_t  timecode_format;
    02144   };
    02145
    02153 GAVL_PUBLIC
    02154 void gavl_video_format_copy(gavl_video_format_t * dst,
    02155                             const gavl_video_format_t * src);
    02156
    02165 GAVL_PUBLIC
    02166 int gavl_video_formats_equal(const gavl_video_format_t * format_1,
    02167                              const gavl_video_format_t * format_2);
    02168
    02169
    02180 GAVL_PUBLIC
    02181 void gavl_video_format_get_chroma_offset(const gavl_video_format_t * format, int field, int plane,
    02182                                          float * off_x, float * off_y);
    02183
    02184
    02185
    02198 GAVL_PUBLIC
    02199 void gavl_video_format_fit_to_source(gavl_video_format_t * dst,
    02200                                      const gavl_video_format_t * src);
    02201
    02209 GAVL_PUBLIC
    02210 int gavl_video_format_get_image_size(const gavl_video_format_t * format);
    02211
    02227 GAVL_PUBLIC
    02228 int gavl_get_color_channel_format(const gavl_video_format_t * frame_format,
    02229                                   gavl_video_format_t * channel_format,
    02230                                   gavl_color_channel_t ch);
    02231
    02232
    02239 GAVL_PUBLIC
    02240 void gavl_video_format_dump(const gavl_video_format_t * format);
    02241
    02242
    02265 typedef struct
    02266   {
    02267   uint8_t * planes[GAVL_MAX_PLANES];
    02268   int strides[GAVL_MAX_PLANES];
    02270   void * user_data;
    02271   int64_t timestamp;
    02272   int64_t duration;
    02273   gavl_interlace_mode_t   interlace_mode;
    02274   gavl_timecode_t timecode;
    02275   } gavl_video_frame_t;
    02276
    02277
    02289 GAVL_PUBLIC
    02290 gavl_video_frame_t * gavl_video_frame_create(const gavl_video_format_t*format);
    02291
    02302 GAVL_PUBLIC
    02303 gavl_video_frame_t * gavl_video_frame_create_nopad(const gavl_video_format_t*format);
    02304
    02305
    02306
    02316 GAVL_PUBLIC
    02317 void gavl_video_frame_destroy(gavl_video_frame_t*frame);
    02318
    02330 GAVL_PUBLIC
    02331 void gavl_video_frame_null(gavl_video_frame_t*frame);
    02332
    02341 GAVL_PUBLIC
    02342 void gavl_video_frame_clear(gavl_video_frame_t * frame,
    02343                             const gavl_video_format_t * format);
    02344
    02354 GAVL_PUBLIC
    02355 void gavl_video_frame_fill(gavl_video_frame_t * frame,
    02356                            const gavl_video_format_t * format,
    02357                            const float * color);
    02358
    02371 GAVL_PUBLIC
    02372 void gavl_video_frame_absdiff(gavl_video_frame_t * dst,
    02373                               const gavl_video_frame_t * src1,
    02374                               const gavl_video_frame_t * src2,
    02375                               const gavl_video_format_t * format);
    02376
    02389 GAVL_PUBLIC
    02390 void gavl_video_frame_psnr(double * psnr,
    02391                            const gavl_video_frame_t * src1,
    02392                            const gavl_video_frame_t * src2,
    02393                            const gavl_video_format_t * format);
    02394
    02421 GAVL_PUBLIC
    02422 int gavl_video_frame_ssim(const gavl_video_frame_t * src1,
    02423                           const gavl_video_frame_t * src2,
    02424                           gavl_video_frame_t * dst,
    02425                           const gavl_video_format_t * format);
    02426
    02440 GAVL_PUBLIC
    02441 void gavl_video_frame_copy(const gavl_video_format_t * format,
    02442                            gavl_video_frame_t * dst,
    02443                            const gavl_video_frame_t * src);
    02444
    02457 GAVL_PUBLIC
    02458 void gavl_video_frame_copy_plane(const gavl_video_format_t * format,
    02459                                  gavl_video_frame_t * dst,
    02460                                  const gavl_video_frame_t * src, int plane);
    02461
    02473 GAVL_PUBLIC
    02474 void gavl_video_frame_copy_flip_x(const gavl_video_format_t * format,
    02475                                   gavl_video_frame_t * dst,
    02476                                   const gavl_video_frame_t * src);
    02477
    02489 GAVL_PUBLIC
    02490 void gavl_video_frame_copy_flip_y(const gavl_video_format_t * format,
    02491                                   gavl_video_frame_t * dst,
    02492                                   const gavl_video_frame_t * src);
    02493
    02505 GAVL_PUBLIC
    02506 void gavl_video_frame_copy_flip_xy(const gavl_video_format_t * format,
    02507                                    gavl_video_frame_t * dst,
    02508                                   const gavl_video_frame_t * src);
    02509
    02522 GAVL_PUBLIC
    02523 void gavl_video_frame_copy_metadata(gavl_video_frame_t * dst,
    02524                                     const gavl_video_frame_t * src);
    02525
    02526
    02544 GAVL_PUBLIC
    02545 void gavl_video_frame_get_subframe(gavl_pixelformat_t pixelformat,
    02546                                    const gavl_video_frame_t * src,
    02547                                    gavl_video_frame_t * dst,
    02548                                    gavl_rectangle_i_t * src_rect);
    02549
    02565 GAVL_PUBLIC
    02566 void gavl_video_frame_get_field(gavl_pixelformat_t pixelformat,
    02567                                 const gavl_video_frame_t * src,
    02568                                 gavl_video_frame_t * dst,
    02569                                 int field);
    02570
    02571
    02572
    02585 GAVL_PUBLIC
    02586 void gavl_video_frame_dump(gavl_video_frame_t * frame,
    02587                            const gavl_video_format_t * format,
    02588                            const char * namebase);
    02589
    02600 GAVL_PUBLIC
    02601 void gavl_video_frame_set_strides(gavl_video_frame_t * frame,
    02602                                   const gavl_video_format_t * format);
    02603
    02616 GAVL_PUBLIC
    02617 void gavl_video_frame_set_planes(gavl_video_frame_t * frame,
    02618                                  const gavl_video_format_t * format,
    02619                                  uint8_t * buffer);
    02620
    02635 GAVL_PUBLIC
    02636 int gavl_video_frame_extract_channel(const gavl_video_format_t * format,
    02637                                      gavl_color_channel_t ch,
    02638                                      const gavl_video_frame_t * src,
    02639                                      gavl_video_frame_t * dst);
    02640
    02656 GAVL_PUBLIC
    02657 int gavl_video_frame_insert_channel(const gavl_video_format_t * format,
    02658                                     gavl_color_channel_t ch,
    02659                                     const gavl_video_frame_t * src,
    02660                                     gavl_video_frame_t * dst);
    02661
    02662
    02674 GAVL_PUBLIC
    02675 int gavl_video_frames_equal(const gavl_video_format_t * format,
    02676                              const gavl_video_frame_t * f1,
    02677                              const gavl_video_frame_t * f2);
    02678
    02679
    02680 /*****************************
    02681  Conversion options
    02682 ******************************/
    02683
    02699 #define GAVL_FORCE_DEINTERLACE (1<<0)
    02700
    02705 #define GAVL_CONVOLVE_CHROMA   (1<<1)
    02706
    02711 #define GAVL_CONVOLVE_NORMALIZE (1<<2)
    02712
    02720 #define GAVL_RESAMPLE_CHROMA    (1<<3)
    02721
    02729 typedef enum
    02730   {
    02731     GAVL_ALPHA_IGNORE      = 0,
    02732     GAVL_ALPHA_BLEND_COLOR
    02733   } gavl_alpha_mode_t;
    02734
    02741 typedef enum
    02742   {
    02743     GAVL_DEINTERLACE_NONE      = 0,
    02744     GAVL_DEINTERLACE_COPY      = 1,
    02745     GAVL_DEINTERLACE_SCALE     = 2,
    02746     GAVL_DEINTERLACE_BLEND     = 3
    02747   } gavl_deinterlace_mode_t;
    02748
    02755 typedef enum
    02756   {
    02757     GAVL_DEINTERLACE_DROP_TOP,
    02758     GAVL_DEINTERLACE_DROP_BOTTOM,
    02759   } gavl_deinterlace_drop_mode_t;
    02760
    02765 typedef enum
    02766   {
    02767     GAVL_SCALE_AUTO,
    02768     GAVL_SCALE_NEAREST,
    02769     GAVL_SCALE_BILINEAR,
    02770     GAVL_SCALE_QUADRATIC,
    02771     GAVL_SCALE_CUBIC_BSPLINE,
    02772     GAVL_SCALE_CUBIC_MITCHELL,
    02773     GAVL_SCALE_CUBIC_CATMULL,
    02774     GAVL_SCALE_SINC_LANCZOS,
    02775     GAVL_SCALE_NONE,
    02776   } gavl_scale_mode_t;
    02777
    02787 typedef enum
    02788   {
    02789     GAVL_DOWNSCALE_FILTER_AUTO = 0,
    02790     GAVL_DOWNSCALE_FILTER_NONE,
    02791     GAVL_DOWNSCALE_FILTER_WIDE,
    02792     GAVL_DOWNSCALE_FILTER_GAUSS,
    02793   } gavl_downscale_filter_t;
    02794
    02801 typedef struct gavl_video_options_s gavl_video_options_t;
    02802
    02803 /* Default Options */
    02804
    02810 GAVL_PUBLIC
    02811 void gavl_video_options_set_defaults(gavl_video_options_t * opt);
    02812
    02822 GAVL_PUBLIC
    02823 gavl_video_options_t * gavl_video_options_create();
    02824
    02831 GAVL_PUBLIC
    02832 void gavl_video_options_copy(gavl_video_options_t * dst,
    02833                              const gavl_video_options_t * src);
    02834
    02840 GAVL_PUBLIC
    02841 void gavl_video_options_destroy(gavl_video_options_t * opt);
    02842
    02843
    02858 GAVL_PUBLIC
    02859 void gavl_video_options_set_rectangles(gavl_video_options_t * opt,
    02860                                        const gavl_rectangle_f_t * src_rect,
    02861                                        const gavl_rectangle_i_t * dst_rect);
    02862
    02870 GAVL_PUBLIC
    02871 void gavl_video_options_get_rectangles(gavl_video_options_t * opt,
    02872                                        gavl_rectangle_f_t * src_rect,
    02873                                        gavl_rectangle_i_t * dst_rect);
    02874
    02881 GAVL_PUBLIC
    02882 void gavl_video_options_set_quality(gavl_video_options_t * opt, int quality);
    02883
    02890 GAVL_PUBLIC
    02891 int gavl_video_options_get_quality(gavl_video_options_t * opt);
    02892
    02893
    02900 GAVL_PUBLIC
    02901 void gavl_video_options_set_conversion_flags(gavl_video_options_t * opt,
    02902                                              int conversion_flags);
    02903
    02910 GAVL_PUBLIC
    02911 int gavl_video_options_get_conversion_flags(gavl_video_options_t * opt);
    02912
    02919 GAVL_PUBLIC
    02920 void gavl_video_options_set_alpha_mode(gavl_video_options_t * opt,
    02921                                        gavl_alpha_mode_t alpha_mode);
    02922
    02929 GAVL_PUBLIC gavl_alpha_mode_t
    02930 gavl_video_options_get_alpha_mode(gavl_video_options_t * opt);
    02931
    02932
    02939 GAVL_PUBLIC
    02940 void gavl_video_options_set_scale_mode(gavl_video_options_t * opt,
    02941                                        gavl_scale_mode_t scale_mode);
    02942
    02949 GAVL_PUBLIC gavl_scale_mode_t
    02950 gavl_video_options_get_scale_mode(gavl_video_options_t * opt);
    02951
    02952
    02959 GAVL_PUBLIC
    02960 void gavl_video_options_set_scale_order(gavl_video_options_t * opt,
    02961                                         int order);
    02962
    02969 GAVL_PUBLIC
    02970 int gavl_video_options_get_scale_order(gavl_video_options_t * opt);
    02971
    02972
    02979 GAVL_PUBLIC
    02980 void gavl_video_options_set_background_color(gavl_video_options_t * opt,
    02981                                              const float * color);
    02982
    02989 GAVL_PUBLIC
    02990 void gavl_video_options_get_background_color(gavl_video_options_t * opt,
    02991                                              float * color);
    02992
    02999 GAVL_PUBLIC
    03000 void gavl_video_options_set_deinterlace_mode(gavl_video_options_t * opt,
    03001                                              gavl_deinterlace_mode_t deinterlace_mode);
    03002
    03009 GAVL_PUBLIC gavl_deinterlace_mode_t
    03010 gavl_video_options_get_deinterlace_mode(gavl_video_options_t * opt);
    03011
    03018 GAVL_PUBLIC
    03019 void gavl_video_options_set_deinterlace_drop_mode(gavl_video_options_t * opt,
    03020                                                   gavl_deinterlace_drop_mode_t deinterlace_drop_mode);
    03021
    03028 GAVL_PUBLIC gavl_deinterlace_drop_mode_t
    03029 gavl_video_options_get_deinterlace_drop_mode(gavl_video_options_t * opt);
    03030
    03039 GAVL_PUBLIC
    03040 void gavl_video_options_set_downscale_filter(gavl_video_options_t * opt,
    03041                                              gavl_downscale_filter_t f);
    03042
    03043
    03052 GAVL_PUBLIC gavl_downscale_filter_t
    03053 gavl_video_options_get_downscale_filter(gavl_video_options_t * opt);
    03054
    03072 GAVL_PUBLIC
    03073 void gavl_video_options_set_downscale_blur(gavl_video_options_t * opt,
    03074                                            float f);
    03075
    03084 GAVL_PUBLIC
    03085 float gavl_video_options_get_downscale_blur(gavl_video_options_t * opt);
    03086
    03095 GAVL_PUBLIC
    03096 void gavl_video_options_set_num_threads(gavl_video_options_t * opt, int n);
    03097
    03098
    03107 GAVL_PUBLIC
    03108 int gavl_video_options_get_num_threads(gavl_video_options_t * opt);
    03109
    03119 GAVL_PUBLIC
    03120 void gavl_video_options_set_run_func(gavl_video_options_t * opt,
    03121                                      gavl_video_run_func func,
    03122                                      void * client_data);
    03123
    03133 GAVL_PUBLIC
    03134 gavl_video_run_func gavl_video_options_get_run_func(gavl_video_options_t * opt,
    03135                                                     void ** client_data);
    03136
    03146 GAVL_PUBLIC
    03147 void gavl_video_options_set_stop_func(gavl_video_options_t * opt,
    03148                                       gavl_video_stop_func func,
    03149                                       void * client_data);
    03150
    03160 GAVL_PUBLIC
    03161 gavl_video_stop_func gavl_video_options_get_stop_func(gavl_video_options_t * opt,
    03162                                                       void ** client_data);
    03163
    03164
    03165 /***************************************************
    03166  * Create and destroy video converters
    03167  ***************************************************/
    03168
    03201 typedef struct gavl_video_converter_s gavl_video_converter_t;
    03202
    03208 GAVL_PUBLIC
    03209 gavl_video_converter_t * gavl_video_converter_create();
    03210
    03216 GAVL_PUBLIC
    03217 void gavl_video_converter_destroy(gavl_video_converter_t*cnv);
    03218
    03219 /**************************************************
    03220  * Get options. Change the options with the gavl_video_options_set_*
    03221  * functions above
    03222  **************************************************/
    03223
    03232 GAVL_PUBLIC gavl_video_options_t *
    03233 gavl_video_converter_get_options(gavl_video_converter_t*cnv);
    03234
    03235
    03249 GAVL_PUBLIC
    03250 int gavl_video_converter_init(gavl_video_converter_t* cnv,
    03251                               const gavl_video_format_t * input_format,
    03252                               const gavl_video_format_t * output_format);
    03253
    03266 GAVL_PUBLIC
    03267 int gavl_video_converter_reinit(gavl_video_converter_t* cnv);
    03268
    03269
    03270 /***************************************************
    03271  * Convert a frame
    03272  ***************************************************/
    03273
    03281 GAVL_PUBLIC
    03282 void gavl_video_convert(gavl_video_converter_t * cnv,
    03283                         const gavl_video_frame_t * input_frame,
    03284                         gavl_video_frame_t * output_frame);
    03285
    03317 typedef struct gavl_video_scaler_s gavl_video_scaler_t;
    03318
    03324 GAVL_PUBLIC
    03325 gavl_video_scaler_t * gavl_video_scaler_create();
    03326
    03332 GAVL_PUBLIC
    03333 void gavl_video_scaler_destroy(gavl_video_scaler_t * scaler);
    03334
    03343 GAVL_PUBLIC gavl_video_options_t *
    03344 gavl_video_scaler_get_options(gavl_video_scaler_t * scaler);
    03345
    03358 GAVL_PUBLIC
    03359 int gavl_video_scaler_init(gavl_video_scaler_t * scaler,
    03360                            const gavl_video_format_t * src_format,
    03361                            const gavl_video_format_t * dst_format);
    03362
    03384 GAVL_PUBLIC
    03385 int gavl_video_scaler_init_convolve(gavl_video_scaler_t * scaler,
    03386                                     const gavl_video_format_t * format,
    03387                                     int h_radius, const float * h_coeffs,
    03388                                     int v_radius, const float * v_coeffs);
    03389
    03397 GAVL_PUBLIC
    03398 void gavl_video_scaler_scale(gavl_video_scaler_t * scaler,
    03399                              const gavl_video_frame_t * input_frame,
    03400                              gavl_video_frame_t * output_frame);
    03401
    03417 typedef struct gavl_video_deinterlacer_s gavl_video_deinterlacer_t;
    03418
    03424 GAVL_PUBLIC
    03425 gavl_video_deinterlacer_t * gavl_video_deinterlacer_create();
    03426
    03432 GAVL_PUBLIC
    03433 void gavl_video_deinterlacer_destroy(gavl_video_deinterlacer_t * deinterlacer);
    03434
    03443 GAVL_PUBLIC gavl_video_options_t *
    03444 gavl_video_deinterlacer_get_options(gavl_video_deinterlacer_t * deinterlacer);
    03445
    03456 GAVL_PUBLIC
    03457 int gavl_video_deinterlacer_init(gavl_video_deinterlacer_t * deinterlacer,
    03458                                  const gavl_video_format_t * src_format);
    03459
    03460
    03468 GAVL_PUBLIC
    03469 void gavl_video_deinterlacer_deinterlace(gavl_video_deinterlacer_t * deinterlacer,
    03470                                          const gavl_video_frame_t * input_frame,
    03471                                          gavl_video_frame_t * output_frame);
    03472
    03473
    03474
    03475 /**************************************************
    03476  * Transparent overlays
    03477  **************************************************/
    03478
    03479 /* Overlay struct */
    03480
    03508 typedef struct
    03509   {
    03510   gavl_video_frame_t * frame;
    03511   gavl_rectangle_i_t ovl_rect;
    03512   int dst_x;
    03513   int dst_y;
    03514   } gavl_overlay_t;
    03515
    03522 typedef struct gavl_overlay_blend_context_s gavl_overlay_blend_context_t;
    03523
    03529 GAVL_PUBLIC
    03530 gavl_overlay_blend_context_t * gavl_overlay_blend_context_create();
    03531
    03537 GAVL_PUBLIC
    03538 void gavl_overlay_blend_context_destroy(gavl_overlay_blend_context_t * ctx);
    03539
    03546 GAVL_PUBLIC gavl_video_options_t *
    03547 gavl_overlay_blend_context_get_options(gavl_overlay_blend_context_t * ctx);
    03548
    03564 GAVL_PUBLIC
    03565 int gavl_overlay_blend_context_init(gavl_overlay_blend_context_t * ctx,
    03566                                     const gavl_video_format_t * frame_format,
    03567                                     gavl_video_format_t * overlay_format);
    03568
    03578 GAVL_PUBLIC
    03579 void gavl_overlay_blend_context_set_overlay(gavl_overlay_blend_context_t * ctx,
    03580                                             gavl_overlay_t * ovl);
    03581
    03588 GAVL_PUBLIC
    03589 void gavl_overlay_blend(gavl_overlay_blend_context_t * ctx,
    03590                         gavl_video_frame_t * dst_frame);
    03591
    03613 typedef struct gavl_image_transform_s gavl_image_transform_t;
    03614
    03628 typedef void (*gavl_image_transform_func)(void * priv,
    03629                                           double xdst,
    03630                                           double ydst,
    03631                                           double * xsrc,
    03632                                           double * ysrc);
    03633
    03634
    03641 GAVL_PUBLIC
    03642 gavl_image_transform_t * gavl_image_transform_create();
    03643
    03649 GAVL_PUBLIC
    03650 void gavl_image_transform_destroy(gavl_image_transform_t * t);
    03651
    03670 GAVL_PUBLIC
    03671 int gavl_image_transform_init(gavl_image_transform_t * t,
    03672                               gavl_video_format_t * format,
    03673                               gavl_image_transform_func func, void * priv);
    03674
    03682 GAVL_PUBLIC
    03683 void gavl_image_transform_transform(gavl_image_transform_t * t,
    03684                                     gavl_video_frame_t * in_frame,
    03685                                     gavl_video_frame_t * out_frame);
    03686
    03697 GAVL_PUBLIC gavl_video_options_t *
    03698 gavl_image_transform_get_options(gavl_image_transform_t * t);
    03699
    03722 typedef struct
    03723   {
    03724   int64_t offset;
    03725   /* Primary */
    03726   int64_t num_entries;
    03727   int64_t entries_alloc;
    03728
    03729   struct
    03730     {
    03731     int64_t num_frames;
    03732     int64_t duration;
    03733     } * entries;
    03734
    03735   int num_timecodes;
    03736   int timecodes_alloc;
    03737
    03738   struct
    03739     {
    03740     int64_t pts;
    03741     gavl_timecode_t tc;
    03742     } * timecodes;
    03743
    03744   /* Secondary */
    03745
    03746   } gavl_frame_table_t;
    03747
    03753 GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_create();
    03754
    03765 GAVL_PUBLIC gavl_frame_table_t *
    03766 gavl_frame_table_create_audio(int samplerate, int64_t offset, int64_t duration,
    03767                               gavl_timecode_format_t * fmt_ret);
    03768
    03780 GAVL_PUBLIC gavl_frame_table_t *
    03781 gavl_frame_table_create_cfr(int64_t offset, int64_t frame_duration,
    03782                             int64_t num_frames,
    03783                             gavl_timecode_t start_timecode);
    03784
    03792 GAVL_PUBLIC gavl_frame_table_t *
    03793 gavl_frame_table_copy(const gavl_frame_table_t * tab);
    03794
    03795
    03796
    03803 GAVL_PUBLIC void gavl_frame_table_destroy(gavl_frame_table_t * t);
    03804
    03812 GAVL_PUBLIC void gavl_frame_table_append_entry(gavl_frame_table_t * t, int64_t duration);
    03813
    03822 GAVL_PUBLIC void
    03823 gavl_frame_table_append_timecode(gavl_frame_table_t * t,
    03824                                  int64_t pts, gavl_timecode_t tc);
    03825
    03836 GAVL_PUBLIC int64_t
    03837 gavl_frame_table_frame_to_time(const gavl_frame_table_t * t,
    03838                                int64_t frame, int * duration);
    03839
    03850 GAVL_PUBLIC int64_t
    03851 gavl_frame_table_time_to_frame(const gavl_frame_table_t * t,
    03852                                int64_t time,
    03853                                int64_t * start_time);
    03854
    03865 GAVL_PUBLIC gavl_timecode_t
    03866 gavl_frame_table_time_to_timecode(const gavl_frame_table_t * t,
    03867                                   int64_t time,
    03868                                   int64_t * start_time,
    03869                                   const gavl_timecode_format_t * fmt);
    03870
    03880 GAVL_PUBLIC int64_t
    03881 gavl_frame_table_timecode_to_time(const gavl_frame_table_t * t,
    03882                                   gavl_timecode_t tc,
    03883                                   const gavl_timecode_format_t * fmt);
    03884
    03885
    03896 GAVL_PUBLIC gavl_timecode_t
    03897 gavl_frame_table_frame_to_timecode(const gavl_frame_table_t * t,
    03898                                    int64_t frame,
    03899                                    int64_t * start_time,
    03900                                    const gavl_timecode_format_t * fmt);
    03901
    03902
    03903
    03911 GAVL_PUBLIC int64_t
    03912 gavl_frame_table_num_frames(const gavl_frame_table_t * t);
    03913
    03921 GAVL_PUBLIC int64_t
    03922 gavl_frame_table_duration(const gavl_frame_table_t * t);
    03923
    03931 GAVL_PUBLIC int64_t
    03932 gavl_frame_table_end_time(const gavl_frame_table_t * t);
    03933
    03942 GAVL_PUBLIC
    03943 int gavl_frame_table_save(const gavl_frame_table_t * tab,
    03944                           const char * filename);
    03945
    03953 GAVL_PUBLIC
    03954 gavl_frame_table_t * gavl_frame_table_load(const char * filename);
    03955
    03962 GAVL_PUBLIC void
    03963 gavl_frame_table_dump(const gavl_frame_table_t * t);
    03964
    03965
    03966
    03967
    03968
    03969
    03975 #ifdef __cplusplus
    03976 }
    03977 #endif
    03978
    03979 #endif /* GAVL_H_INCLUDED */