~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to linux/x86/include/libavutil/opt.h

  • Committer: GitHub
  • Author(s): Henrik Rydgård
  • Date: 2016-10-25 19:54:41 UTC
  • mfrom: (55.1.1)
  • Revision ID: git-v1:0813d5ebb6a08902d7394eb09f13cc082061a722
Merge pull request #42 from orbea/x86

Update FFMPEG libs for Linux x86, compiled with GCC 5.3.0 (Slackware …

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "log.h"
34
34
#include "pixfmt.h"
35
35
#include "samplefmt.h"
 
36
#include "version.h"
36
37
 
37
38
/**
38
39
 * @defgroup avoptions AVOptions
212
213
 * In some cases it may be more convenient to put all options into an
213
214
 * AVDictionary and call av_opt_set_dict() on it. A specific case of this
214
215
 * are the format/codec open functions in lavf/lavc which take a dictionary
215
 
 * filled with option as a parameter. This allows to set some options
 
216
 * filled with option as a parameter. This makes it possible to set some options
216
217
 * that cannot be set otherwise, since e.g. the input file format is not known
217
218
 * before the file is actually opened.
218
219
 */
226
227
    AV_OPT_TYPE_STRING,
227
228
    AV_OPT_TYPE_RATIONAL,
228
229
    AV_OPT_TYPE_BINARY,  ///< offset must point to a pointer immediately followed by an int for the length
 
230
    AV_OPT_TYPE_DICT,
229
231
    AV_OPT_TYPE_CONST = 128,
230
232
    AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
231
233
    AV_OPT_TYPE_PIXEL_FMT  = MKBETAG('P','F','M','T'),
234
236
    AV_OPT_TYPE_DURATION   = MKBETAG('D','U','R',' '),
235
237
    AV_OPT_TYPE_COLOR      = MKBETAG('C','O','L','R'),
236
238
    AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'),
237
 
#if FF_API_OLD_AVOPTIONS
238
 
    FF_OPT_TYPE_FLAGS = 0,
239
 
    FF_OPT_TYPE_INT,
240
 
    FF_OPT_TYPE_INT64,
241
 
    FF_OPT_TYPE_DOUBLE,
242
 
    FF_OPT_TYPE_FLOAT,
243
 
    FF_OPT_TYPE_STRING,
244
 
    FF_OPT_TYPE_RATIONAL,
245
 
    FF_OPT_TYPE_BINARY,  ///< offset must point to a pointer immediately followed by an int for the length
246
 
    FF_OPT_TYPE_CONST=128,
247
 
#endif
 
239
    AV_OPT_TYPE_BOOL           = MKBETAG('B','O','O','L'),
248
240
};
249
241
 
250
242
/**
282
274
    int flags;
283
275
#define AV_OPT_FLAG_ENCODING_PARAM  1   ///< a generic parameter which can be set by the user for muxing or encoding
284
276
#define AV_OPT_FLAG_DECODING_PARAM  2   ///< a generic parameter which can be set by the user for demuxing or decoding
 
277
#if FF_API_OPT_TYPE_METADATA
285
278
#define AV_OPT_FLAG_METADATA        4   ///< some data extracted or inserted into the file like title, comment, ...
 
279
#endif
286
280
#define AV_OPT_FLAG_AUDIO_PARAM     8
287
281
#define AV_OPT_FLAG_VIDEO_PARAM     16
288
282
#define AV_OPT_FLAG_SUBTITLE_PARAM  32
 
283
/**
 
284
 * The option is inteded for exporting values to the caller.
 
285
 */
 
286
#define AV_OPT_FLAG_EXPORT          64
 
287
/**
 
288
 * The option may not be set through the AVOptions API, only read.
 
289
 * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
 
290
 */
 
291
#define AV_OPT_FLAG_READONLY        128
289
292
#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
290
293
//FIXME think about enc-audio, ... style flags
291
294
 
302
305
 */
303
306
typedef struct AVOptionRange {
304
307
    const char *str;
305
 
    double value_min, value_max;             ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
306
 
    double component_min, component_max;     ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
307
 
    int is_range;                            ///< if set to 1 the struct encodes a range, if set to 0 a single value
 
308
    /**
 
309
     * Value range.
 
310
     * For string ranges this represents the min/max length.
 
311
     * For dimensions this represents the min/max pixel count or width/height in multi-component case.
 
312
     */
 
313
    double value_min, value_max;
 
314
    /**
 
315
     * Value's component range.
 
316
     * For string this represents the unicode range for chars, 0-127 limits to ASCII.
 
317
     */
 
318
    double component_min, component_max;
 
319
    /**
 
320
     * Range flag.
 
321
     * If set to 1 the struct encodes a range, if set to 0 a single value.
 
322
     */
 
323
    int is_range;
308
324
} AVOptionRange;
309
325
 
310
326
/**
311
 
 * List of AVOptionRange structs
 
327
 * List of AVOptionRange structs.
312
328
 */
313
329
typedef struct AVOptionRanges {
 
330
    /**
 
331
     * Array of option ranges.
 
332
     *
 
333
     * Most of option types use just one component.
 
334
     * Following describes multi-component option types:
 
335
     *
 
336
     * AV_OPT_TYPE_IMAGE_SIZE:
 
337
     * component index 0: range of pixel count (width * height).
 
338
     * component index 1: range of width.
 
339
     * component index 2: range of height.
 
340
     *
 
341
     * @note To obtain multi-component version of this structure, user must
 
342
     *       provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or
 
343
     *       av_opt_query_ranges_default function.
 
344
     *
 
345
     * Multi-component range can be read as in following example:
 
346
     *
 
347
     * @code
 
348
     * int range_index, component_index;
 
349
     * AVOptionRanges *ranges;
 
350
     * AVOptionRange *range[3]; //may require more than 3 in the future.
 
351
     * av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE);
 
352
     * for (range_index = 0; range_index < ranges->nb_ranges; range_index++) {
 
353
     *     for (component_index = 0; component_index < ranges->nb_components; component_index++)
 
354
     *         range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index];
 
355
     *     //do something with range here.
 
356
     * }
 
357
     * av_opt_freep_ranges(&ranges);
 
358
     * @endcode
 
359
     */
314
360
    AVOptionRange **range;
 
361
    /**
 
362
     * Number of ranges per component.
 
363
     */
315
364
    int nb_ranges;
 
365
    /**
 
366
     * Number of componentes.
 
367
     */
 
368
    int nb_components;
316
369
} AVOptionRanges;
317
370
 
318
 
 
319
 
#if FF_API_FIND_OPT
320
 
/**
321
 
 * Look for an option in obj. Look only for the options which
322
 
 * have the flags set as specified in mask and flags (that is,
323
 
 * for which it is the case that (opt->flags & mask) == flags).
324
 
 *
325
 
 * @param[in] obj a pointer to a struct whose first element is a
326
 
 * pointer to an AVClass
327
 
 * @param[in] name the name of the option to look for
328
 
 * @param[in] unit the unit of the option to look for, or any if NULL
329
 
 * @return a pointer to the option found, or NULL if no option
330
 
 * has been found
331
 
 *
332
 
 * @deprecated use av_opt_find.
333
 
 */
334
 
attribute_deprecated
335
 
const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
336
 
#endif
337
 
 
338
 
#if FF_API_OLD_AVOPTIONS
339
 
/**
340
 
 * Set the field of obj with the given name to value.
341
 
 *
342
 
 * @param[in] obj A struct whose first element is a pointer to an
343
 
 * AVClass.
344
 
 * @param[in] name the name of the field to set
345
 
 * @param[in] val The value to set. If the field is not of a string
346
 
 * type, then the given string is parsed.
347
 
 * SI postfixes and some named scalars are supported.
348
 
 * If the field is of a numeric type, it has to be a numeric or named
349
 
 * scalar. Behavior with more than one scalar and +- infix operators
350
 
 * is undefined.
351
 
 * If the field is of a flags type, it has to be a sequence of numeric
352
 
 * scalars or named flags separated by '+' or '-'. Prefixing a flag
353
 
 * with '+' causes it to be set without affecting the other flags;
354
 
 * similarly, '-' unsets a flag.
355
 
 * @param[out] o_out if non-NULL put here a pointer to the AVOption
356
 
 * found
357
 
 * @param alloc this parameter is currently ignored
358
 
 * @return 0 if the value has been set, or an AVERROR code in case of
359
 
 * error:
360
 
 * AVERROR_OPTION_NOT_FOUND if no matching option exists
361
 
 * AVERROR(ERANGE) if the value is out of range
362
 
 * AVERROR(EINVAL) if the value is not valid
363
 
 * @deprecated use av_opt_set()
364
 
 */
365
 
attribute_deprecated
366
 
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
367
 
 
368
 
attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
369
 
attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
370
 
attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
371
 
 
372
 
double av_get_double(void *obj, const char *name, const AVOption **o_out);
373
 
AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
374
 
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
375
 
attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
376
 
attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
377
 
#endif
378
 
 
379
371
/**
380
372
 * Show the obj options.
381
373
 *
394
386
 */
395
387
void av_opt_set_defaults(void *s);
396
388
 
397
 
#if FF_API_OLD_AVOPTIONS
398
 
attribute_deprecated
 
389
/**
 
390
 * Set the values of all AVOption fields to their default values. Only these
 
391
 * AVOption fields for which (opt->flags & mask) == flags will have their
 
392
 * default applied to s.
 
393
 *
 
394
 * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
 
395
 * @param mask combination of AV_OPT_FLAG_*
 
396
 * @param flags combination of AV_OPT_FLAG_*
 
397
 */
399
398
void av_opt_set_defaults2(void *s, int mask, int flags);
400
 
#endif
401
399
 
402
400
/**
403
401
 * Parse the key/value pairs list in opts. For each key/value pair
413
411
 * @return the number of successfully set key/value pairs, or a negative
414
412
 * value corresponding to an AVERROR code in case of error:
415
413
 * AVERROR(EINVAL) if opts cannot be parsed,
416
 
 * the error code issued by av_set_string3() if a key/value pair
 
414
 * the error code issued by av_opt_set() if a key/value pair
417
415
 * cannot be set
418
416
 */
419
417
int av_set_options_string(void *ctx, const char *opts,
450
448
                           const char *const *shorthand,
451
449
                           const char *key_val_sep, const char *pairs_sep);
452
450
/**
453
 
 * Free all string and binary options in obj.
 
451
 * Free all allocated objects in obj.
454
452
 */
455
453
void av_opt_free(void *obj);
456
454
 
480
478
 */
481
479
int av_opt_set_dict(void *obj, struct AVDictionary **options);
482
480
 
 
481
 
 
482
/**
 
483
 * Set all the options from a given dictionary on an object.
 
484
 *
 
485
 * @param obj a struct whose first element is a pointer to AVClass
 
486
 * @param options options to process. This dictionary will be freed and replaced
 
487
 *                by a new one containing all options not found in obj.
 
488
 *                Of course this new dictionary needs to be freed by caller
 
489
 *                with av_dict_free().
 
490
 * @param search_flags A combination of AV_OPT_SEARCH_*.
 
491
 *
 
492
 * @return 0 on success, a negative AVERROR if some option was found in obj,
 
493
 *         but could not be set.
 
494
 *
 
495
 * @see av_dict_copy()
 
496
 */
 
497
int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
 
498
 
483
499
/**
484
500
 * Extract a key-value pair from the beginning of a string.
485
501
 *
537
553
 * @}
538
554
 */
539
555
 
540
 
#define AV_OPT_SEARCH_CHILDREN   0x0001 /**< Search in possible children of the
541
 
                                             given object first. */
 
556
#define AV_OPT_SEARCH_CHILDREN   (1 << 0) /**< Search in possible children of the
 
557
                                               given object first. */
542
558
/**
543
559
 *  The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
544
560
 *  instead of a required pointer to a struct containing AVClass. This is
545
561
 *  useful for searching for options without needing to allocate the corresponding
546
562
 *  object.
547
563
 */
548
 
#define AV_OPT_SEARCH_FAKE_OBJ   0x0002
 
564
#define AV_OPT_SEARCH_FAKE_OBJ   (1 << 1)
 
565
 
 
566
/**
 
567
 *  In av_opt_get, return NULL if the option has a pointer type and is set to NULL,
 
568
 *  rather than returning an empty string.
 
569
 */
 
570
#define AV_OPT_ALLOW_NULL (1 << 2)
 
571
 
 
572
/**
 
573
 *  Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
 
574
 *  one component for certain option types.
 
575
 *  @see AVOptionRanges for details.
 
576
 */
 
577
#define AV_OPT_MULTI_COMPONENT_RANGE (1 << 12)
549
578
 
550
579
/**
551
580
 * Look for an option in an object. Consider only options which
565
594
 *         was found.
566
595
 *
567
596
 * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
568
 
 * directly with av_set_string3(). Use special calls which take an options
 
597
 * directly with av_opt_set(). Use special calls which take an options
569
598
 * AVDictionary (e.g. avformat_open_input()) to set options found with this
570
599
 * flag.
571
600
 */
605
634
 *             or NULL
606
635
 * @return next AVOption or NULL
607
636
 */
608
 
const AVOption *av_opt_next(void *obj, const AVOption *prev);
 
637
const AVOption *av_opt_next(const void *obj, const AVOption *prev);
609
638
 
610
639
/**
611
640
 * Iterate over AVOptions-enabled children of obj.
649
678
 * AVERROR(ERANGE) if the value is out of range
650
679
 * AVERROR(EINVAL) if the value is not valid
651
680
 */
652
 
int av_opt_set       (void *obj, const char *name, const char *val, int search_flags);
653
 
int av_opt_set_int   (void *obj, const char *name, int64_t     val, int search_flags);
654
 
int av_opt_set_double(void *obj, const char *name, double      val, int search_flags);
655
 
int av_opt_set_q     (void *obj, const char *name, AVRational  val, int search_flags);
656
 
int av_opt_set_bin   (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
 
681
int av_opt_set         (void *obj, const char *name, const char *val, int search_flags);
 
682
int av_opt_set_int     (void *obj, const char *name, int64_t     val, int search_flags);
 
683
int av_opt_set_double  (void *obj, const char *name, double      val, int search_flags);
 
684
int av_opt_set_q       (void *obj, const char *name, AVRational  val, int search_flags);
 
685
int av_opt_set_bin     (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
657
686
int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
658
687
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
659
688
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
660
689
int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
661
690
int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags);
 
691
/**
 
692
 * @note Any old dictionary present is discarded and replaced with a copy of the new one. The
 
693
 * caller still owns val is and responsible for freeing it.
 
694
 */
 
695
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags);
662
696
 
663
697
/**
664
698
 * Set a binary option to an integer list.
675
709
     AVERROR(EINVAL) : \
676
710
     av_opt_set_bin(obj, name, (const uint8_t *)(val), \
677
711
                    av_int_list_length(val, term) * sizeof(*(val)), flags))
 
712
 
678
713
/**
679
714
 * @}
680
715
 */
693
728
 */
694
729
/**
695
730
 * @note the returned string will be av_malloc()ed and must be av_free()ed by the caller
 
731
 *
 
732
 * @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option has
 
733
 * AV_OPT_TYPE_STRING or AV_OPT_TYPE_BINARY and is set to NULL, *out_val will be set
 
734
 * to NULL instead of an allocated empty string.
696
735
 */
697
 
int av_opt_get       (void *obj, const char *name, int search_flags, uint8_t   **out_val);
698
 
int av_opt_get_int   (void *obj, const char *name, int search_flags, int64_t    *out_val);
699
 
int av_opt_get_double(void *obj, const char *name, int search_flags, double     *out_val);
700
 
int av_opt_get_q     (void *obj, const char *name, int search_flags, AVRational *out_val);
 
736
int av_opt_get         (void *obj, const char *name, int search_flags, uint8_t   **out_val);
 
737
int av_opt_get_int     (void *obj, const char *name, int search_flags, int64_t    *out_val);
 
738
int av_opt_get_double  (void *obj, const char *name, int search_flags, double     *out_val);
 
739
int av_opt_get_q       (void *obj, const char *name, int search_flags, AVRational *out_val);
701
740
int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
702
741
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
703
742
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
704
743
int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
705
744
int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout);
706
745
/**
 
746
 * @param[out] out_val The returned dictionary is a copy of the actual value and must
 
747
 * be freed with av_dict_free() by the caller
 
748
 */
 
749
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
 
750
/**
707
751
 * @}
708
752
 */
709
753
/**
728
772
 *
729
773
 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
730
774
 *              AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
 
775
 *              AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
731
776
 *
732
777
 * The result must be freed with av_opt_freep_ranges.
733
778
 *
734
 
 * @return >= 0 on success, a negative errro code otherwise
 
779
 * @return number of compontents returned on success, a negative errro code otherwise
735
780
 */
736
781
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
737
782
 
738
783
/**
 
784
 * Copy options from src object into dest object.
 
785
 *
 
786
 * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
 
787
 * Original memory allocated for such options is freed unless both src and dest options points to the same memory.
 
788
 *
 
789
 * @param dest Object to copy from
 
790
 * @param src  Object to copy into
 
791
 * @return 0 on success, negative on error
 
792
 */
 
793
int av_opt_copy(void *dest, const void *src);
 
794
 
 
795
/**
739
796
 * Get a default list of allowed ranges for the given option.
740
797
 *
741
798
 * This list is constructed without using the AVClass.query_ranges() callback
743
800
 *
744
801
 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
745
802
 *              AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
 
803
 *              AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
746
804
 *
747
805
 * The result must be freed with av_opt_free_ranges.
748
806
 *
749
 
 * @return >= 0 on success, a negative errro code otherwise
 
807
 * @return number of compontents returned on success, a negative errro code otherwise
750
808
 */
751
809
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
752
810
 
753
811
/**
 
812
 * Check if given option is set to its default value.
 
813
 *
 
814
 * Options o must belong to the obj. This function must not be called to check child's options state.
 
815
 * @see av_opt_is_set_to_default_by_name().
 
816
 *
 
817
 * @param obj  AVClass object to check option on
 
818
 * @param o    option to be checked
 
819
 * @return     >0 when option is set to its default,
 
820
 *              0 when option is not set its default,
 
821
 *             <0 on error
 
822
 */
 
823
int av_opt_is_set_to_default(void *obj, const AVOption *o);
 
824
 
 
825
/**
 
826
 * Check if given option is set to its default value.
 
827
 *
 
828
 * @param obj          AVClass object to check option on
 
829
 * @param name         option name
 
830
 * @param search_flags combination of AV_OPT_SEARCH_*
 
831
 * @return             >0 when option is set to its default,
 
832
 *                     0 when option is not set its default,
 
833
 *                     <0 on error
 
834
 */
 
835
int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags);
 
836
 
 
837
 
 
838
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS              0x00000001  ///< Serialize options that are not set to default values only.
 
839
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT            0x00000002  ///< Serialize options that exactly match opt_flags only.
 
840
 
 
841
/**
 
842
 * Serialize object's options.
 
843
 *
 
844
 * Create a string containing object's serialized options.
 
845
 * Such string may be passed back to av_opt_set_from_string() in order to restore option values.
 
846
 * A key/value or pairs separator occurring in the serialized value or
 
847
 * name string are escaped through the av_escape() function.
 
848
 *
 
849
 * @param[in]  obj           AVClass object to serialize
 
850
 * @param[in]  opt_flags     serialize options with all the specified flags set (AV_OPT_FLAG)
 
851
 * @param[in]  flags         combination of AV_OPT_SERIALIZE_* flags
 
852
 * @param[out] buffer        Pointer to buffer that will be allocated with string containg serialized options.
 
853
 *                           Buffer must be freed by the caller when is no longer needed.
 
854
 * @param[in]  key_val_sep   character used to separate key from value
 
855
 * @param[in]  pairs_sep     character used to separate two pairs from each other
 
856
 * @return                   >= 0 on success, negative on error
 
857
 * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
 
858
 */
 
859
int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
 
860
                     const char key_val_sep, const char pairs_sep);
 
861
/**
754
862
 * @}
755
863
 */
756
864