Browse code

avcodec, avutil, avformat: remove AVOption requirement for some fields

Allow all struct fields to be accessed directly, as long as they're
public.

Before this change, many fields were "public", but could be accessed via
AVOption only. This meant they were effectively not public, but were
present for documentation purposes, which was incredibly confusing at
best.

wm4 authored on 2017/02/13 19:40:22
Showing 7 changed files
... ...
@@ -15,6 +15,11 @@ libavutil:     2015-08-28
15 15
 
16 16
 API changes, most recent first:
17 17
 
18
+2017-03-02 - xxxxxxx - lavu 55.47.101, lavc 57.81.102, lavf 57.66.103
19
+  Remove requirement to use AVOption or accessors to access certain fields
20
+  in AVFrame, AVCodecContext, and AVFormatContext that were previously
21
+  documented as "no direct access" allowed.
22
+
18 23
 2017-02-13 - xxxxxxx - lavc 57.80.100 - avcodec.h
19 24
   Add AVCodecContext.hw_device_ctx.
20 25
 
... ...
@@ -1680,7 +1680,7 @@ enum AVFieldOrder {
1680 1680
  * New fields can be added to the end with minor version bumps.
1681 1681
  * Removal, reordering and changes to existing fields require a major
1682 1682
  * version bump.
1683
- * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1683
+ * You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1684 1684
  * applications.
1685 1685
  * The name string for AVOptions options matches the associated command line
1686 1686
  * parameter name and can be found in libavcodec/options_table.h
... ...
@@ -2951,8 +2951,8 @@ typedef struct AVCodecContext {
2951 2951
 #define FF_DEBUG_MMCO        0x00000800
2952 2952
 #define FF_DEBUG_BUGS        0x00001000
2953 2953
 #if FF_API_DEBUG_MV
2954
-#define FF_DEBUG_VIS_QP      0x00002000 ///< only access through AVOptions from outside libavcodec
2955
-#define FF_DEBUG_VIS_MB_TYPE 0x00004000 ///< only access through AVOptions from outside libavcodec
2954
+#define FF_DEBUG_VIS_QP      0x00002000
2955
+#define FF_DEBUG_VIS_MB_TYPE 0x00004000
2956 2956
 #endif
2957 2957
 #define FF_DEBUG_BUFFERS     0x00008000
2958 2958
 #define FF_DEBUG_THREADS     0x00010000
... ...
@@ -2962,7 +2962,6 @@ typedef struct AVCodecContext {
2962 2962
 #if FF_API_DEBUG_MV
2963 2963
     /**
2964 2964
      * debug
2965
-     * Code outside libavcodec should access this field using AVOptions
2966 2965
      * - encoding: Set by user.
2967 2966
      * - decoding: Set by user.
2968 2967
      */
... ...
@@ -3097,8 +3096,6 @@ typedef struct AVCodecContext {
3097 3097
      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
3098 3098
      * - encoding: unused
3099 3099
      * - decoding: Set by user.
3100
-     * Code outside libavcodec should access this field using:
3101
-     * av_codec_{get,set}_lowres(avctx)
3102 3100
      */
3103 3101
      int lowres;
3104 3102
 #endif
... ...
@@ -3399,8 +3396,6 @@ typedef struct AVCodecContext {
3399 3399
 
3400 3400
     /**
3401 3401
      * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
3402
-     * Code outside libavcodec should access this field using:
3403
-     * av_codec_{get,set}_pkt_timebase(avctx)
3404 3402
      * - encoding unused.
3405 3403
      * - decoding set by user.
3406 3404
      */
... ...
@@ -3408,8 +3403,6 @@ typedef struct AVCodecContext {
3408 3408
 
3409 3409
     /**
3410 3410
      * AVCodecDescriptor
3411
-     * Code outside libavcodec should access this field using:
3412
-     * av_codec_{get,set}_codec_descriptor(avctx)
3413 3411
      * - encoding: unused.
3414 3412
      * - decoding: set by libavcodec.
3415 3413
      */
... ...
@@ -3420,8 +3413,6 @@ typedef struct AVCodecContext {
3420 3420
      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
3421 3421
      * - encoding: unused
3422 3422
      * - decoding: Set by user.
3423
-     * Code outside libavcodec should access this field using:
3424
-     * av_codec_{get,set}_lowres(avctx)
3425 3423
      */
3426 3424
      int lowres;
3427 3425
 #endif
... ...
@@ -3462,7 +3453,6 @@ typedef struct AVCodecContext {
3462 3462
      * However for formats that do not use pre-multiplied alpha
3463 3463
      * there might be serious artefacts (though e.g. libswscale currently
3464 3464
      * assumes pre-multiplied alpha anyway).
3465
-     * Code outside libavcodec should access this field using AVOptions
3466 3465
      *
3467 3466
      * - decoding: set by user
3468 3467
      * - encoding: unused
... ...
@@ -3479,7 +3469,6 @@ typedef struct AVCodecContext {
3479 3479
 #if !FF_API_DEBUG_MV
3480 3480
     /**
3481 3481
      * debug motion vectors
3482
-     * Code outside libavcodec should access this field using AVOptions
3483 3482
      * - encoding: Set by user.
3484 3483
      * - decoding: Set by user.
3485 3484
      */
... ...
@@ -3491,7 +3480,6 @@ typedef struct AVCodecContext {
3491 3491
 
3492 3492
     /**
3493 3493
      * custom intra quantization matrix
3494
-     * Code outside libavcodec should access this field using av_codec_g/set_chroma_intra_matrix()
3495 3494
      * - encoding: Set by user, can be NULL.
3496 3495
      * - decoding: unused.
3497 3496
      */
... ...
@@ -3500,8 +3488,6 @@ typedef struct AVCodecContext {
3500 3500
     /**
3501 3501
      * dump format separator.
3502 3502
      * can be ", " or "\n      " or anything else
3503
-     * Code outside libavcodec should access this field using AVOptions
3504
-     * (NO direct access).
3505 3503
      * - encoding: Set by user.
3506 3504
      * - decoding: Set by user.
3507 3505
      */
... ...
@@ -3511,13 +3497,12 @@ typedef struct AVCodecContext {
3511 3511
      * ',' separated list of allowed decoders.
3512 3512
      * If NULL then all are allowed
3513 3513
      * - encoding: unused
3514
-     * - decoding: set by user through AVOPtions (NO direct access)
3514
+     * - decoding: set by user
3515 3515
      */
3516 3516
     char *codec_whitelist;
3517 3517
 
3518 3518
     /*
3519 3519
      * Properties of the stream that gets decoded
3520
-     * To be accessed through av_codec_get_properties() (NO direct access)
3521 3520
      * - encoding: unused
3522 3521
      * - decoding: set by libavcodec
3523 3522
      */
... ...
@@ -3668,7 +3653,7 @@ typedef struct AVCodec {
3668 3668
     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3669 3669
     const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3670 3670
     const uint64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3671
-    uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder, no direct access, use av_codec_get_max_lowres()
3671
+    uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
3672 3672
     const AVClass *priv_class;              ///< AVClass for the private context
3673 3673
     const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3674 3674
 
... ...
@@ -29,7 +29,7 @@
29 29
 
30 30
 #define LIBAVCODEC_VERSION_MAJOR  57
31 31
 #define LIBAVCODEC_VERSION_MINOR  81
32
-#define LIBAVCODEC_VERSION_MICRO 101
32
+#define LIBAVCODEC_VERSION_MICRO 102
33 33
 
34 34
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 35
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -1649,7 +1649,7 @@ typedef struct AVFormatContext {
1649 1649
     /**
1650 1650
      * Audio preload in microseconds.
1651 1651
      * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1652
-     * - encoding: Set by user via AVOptions (NO direct access)
1652
+     * - encoding: Set by user
1653 1653
      * - decoding: unused
1654 1654
      */
1655 1655
     int audio_preload;
... ...
@@ -1657,7 +1657,7 @@ typedef struct AVFormatContext {
1657 1657
     /**
1658 1658
      * Max chunk time in microseconds.
1659 1659
      * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1660
-     * - encoding: Set by user via AVOptions (NO direct access)
1660
+     * - encoding: Set by user
1661 1661
      * - decoding: unused
1662 1662
      */
1663 1663
     int max_chunk_duration;
... ...
@@ -1665,7 +1665,7 @@ typedef struct AVFormatContext {
1665 1665
     /**
1666 1666
      * Max chunk size in bytes
1667 1667
      * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1668
-     * - encoding: Set by user via AVOptions (NO direct access)
1668
+     * - encoding: Set by user
1669 1669
      * - decoding: unused
1670 1670
      */
1671 1671
     int max_chunk_size;
... ...
@@ -1674,14 +1674,14 @@ typedef struct AVFormatContext {
1674 1674
      * forces the use of wallclock timestamps as pts/dts of packets
1675 1675
      * This has undefined results in the presence of B frames.
1676 1676
      * - encoding: unused
1677
-     * - decoding: Set by user via AVOptions (NO direct access)
1677
+     * - decoding: Set by user
1678 1678
      */
1679 1679
     int use_wallclock_as_timestamps;
1680 1680
 
1681 1681
     /**
1682 1682
      * avio flags, used to force AVIO_FLAG_DIRECT.
1683 1683
      * - encoding: unused
1684
-     * - decoding: Set by user via AVOptions (NO direct access)
1684
+     * - decoding: Set by user
1685 1685
      */
1686 1686
     int avio_flags;
1687 1687
 
... ...
@@ -1689,34 +1689,34 @@ typedef struct AVFormatContext {
1689 1689
      * The duration field can be estimated through various ways, and this field can be used
1690 1690
      * to know how the duration was estimated.
1691 1691
      * - encoding: unused
1692
-     * - decoding: Read by user via AVOptions (NO direct access)
1692
+     * - decoding: Read by user
1693 1693
      */
1694 1694
     enum AVDurationEstimationMethod duration_estimation_method;
1695 1695
 
1696 1696
     /**
1697 1697
      * Skip initial bytes when opening stream
1698 1698
      * - encoding: unused
1699
-     * - decoding: Set by user via AVOptions (NO direct access)
1699
+     * - decoding: Set by user
1700 1700
      */
1701 1701
     int64_t skip_initial_bytes;
1702 1702
 
1703 1703
     /**
1704 1704
      * Correct single timestamp overflows
1705 1705
      * - encoding: unused
1706
-     * - decoding: Set by user via AVOptions (NO direct access)
1706
+     * - decoding: Set by user
1707 1707
      */
1708 1708
     unsigned int correct_ts_overflow;
1709 1709
 
1710 1710
     /**
1711 1711
      * Force seeking to any (also non key) frames.
1712 1712
      * - encoding: unused
1713
-     * - decoding: Set by user via AVOptions (NO direct access)
1713
+     * - decoding: Set by user
1714 1714
      */
1715 1715
     int seek2any;
1716 1716
 
1717 1717
     /**
1718 1718
      * Flush the I/O context after each packet.
1719
-     * - encoding: Set by user via AVOptions (NO direct access)
1719
+     * - encoding: Set by user
1720 1720
      * - decoding: unused
1721 1721
      */
1722 1722
     int flush_packets;
... ...
@@ -1726,14 +1726,14 @@ typedef struct AVFormatContext {
1726 1726
      * The maximal score is AVPROBE_SCORE_MAX, its set when the demuxer probes
1727 1727
      * the format.
1728 1728
      * - encoding: unused
1729
-     * - decoding: set by avformat, read by user via av_format_get_probe_score() (NO direct access)
1729
+     * - decoding: set by avformat, read by user
1730 1730
      */
1731 1731
     int probe_score;
1732 1732
 
1733 1733
     /**
1734 1734
      * number of bytes to read maximally to identify format.
1735 1735
      * - encoding: unused
1736
-     * - decoding: set by user through AVOPtions (NO direct access)
1736
+     * - decoding: set by user
1737 1737
      */
1738 1738
     int format_probesize;
1739 1739
 
... ...
@@ -1741,7 +1741,7 @@ typedef struct AVFormatContext {
1741 1741
      * ',' separated list of allowed decoders.
1742 1742
      * If NULL then all are allowed
1743 1743
      * - encoding: unused
1744
-     * - decoding: set by user through AVOptions (NO direct access)
1744
+     * - decoding: set by user
1745 1745
      */
1746 1746
     char *codec_whitelist;
1747 1747
 
... ...
@@ -1749,7 +1749,7 @@ typedef struct AVFormatContext {
1749 1749
      * ',' separated list of allowed demuxers.
1750 1750
      * If NULL then all are allowed
1751 1751
      * - encoding: unused
1752
-     * - decoding: set by user through AVOptions (NO direct access)
1752
+     * - decoding: set by user
1753 1753
      */
1754 1754
     char *format_whitelist;
1755 1755
 
... ...
@@ -1771,7 +1771,7 @@ typedef struct AVFormatContext {
1771 1771
      * Forced video codec.
1772 1772
      * This allows forcing a specific decoder, even when there are multiple with
1773 1773
      * the same codec_id.
1774
-     * Demuxing: Set by user via av_format_set_video_codec (NO direct access).
1774
+     * Demuxing: Set by user
1775 1775
      */
1776 1776
     AVCodec *video_codec;
1777 1777
 
... ...
@@ -1779,7 +1779,7 @@ typedef struct AVFormatContext {
1779 1779
      * Forced audio codec.
1780 1780
      * This allows forcing a specific decoder, even when there are multiple with
1781 1781
      * the same codec_id.
1782
-     * Demuxing: Set by user via av_format_set_audio_codec (NO direct access).
1782
+     * Demuxing: Set by user
1783 1783
      */
1784 1784
     AVCodec *audio_codec;
1785 1785
 
... ...
@@ -1787,7 +1787,7 @@ typedef struct AVFormatContext {
1787 1787
      * Forced subtitle codec.
1788 1788
      * This allows forcing a specific decoder, even when there are multiple with
1789 1789
      * the same codec_id.
1790
-     * Demuxing: Set by user via av_format_set_subtitle_codec (NO direct access).
1790
+     * Demuxing: Set by user
1791 1791
      */
1792 1792
     AVCodec *subtitle_codec;
1793 1793
 
... ...
@@ -1795,7 +1795,7 @@ typedef struct AVFormatContext {
1795 1795
      * Forced data codec.
1796 1796
      * This allows forcing a specific decoder, even when there are multiple with
1797 1797
      * the same codec_id.
1798
-     * Demuxing: Set by user via av_format_set_data_codec (NO direct access).
1798
+     * Demuxing: Set by user
1799 1799
      */
1800 1800
     AVCodec *data_codec;
1801 1801
 
... ...
@@ -1819,15 +1819,13 @@ typedef struct AVFormatContext {
1819 1819
 
1820 1820
     /**
1821 1821
      * Output timestamp offset, in microseconds.
1822
-     * Muxing: set by user via AVOptions (NO direct access)
1822
+     * Muxing: set by user
1823 1823
      */
1824 1824
     int64_t output_ts_offset;
1825 1825
 
1826 1826
     /**
1827 1827
      * dump format separator.
1828 1828
      * can be ", " or "\n      " or anything else
1829
-     * Code outside libavformat should access this field using AVOptions
1830
-     * (NO direct access).
1831 1829
      * - muxing: Set by user.
1832 1830
      * - demuxing: Set by user.
1833 1831
      */
... ...
@@ -1864,7 +1862,7 @@ typedef struct AVFormatContext {
1864 1864
     /**
1865 1865
      * ',' separated list of allowed protocols.
1866 1866
      * - encoding: unused
1867
-     * - decoding: set by user through AVOptions (NO direct access)
1867
+     * - decoding: set by user
1868 1868
      */
1869 1869
     char *protocol_whitelist;
1870 1870
 
... ...
@@ -1899,18 +1897,22 @@ typedef struct AVFormatContext {
1899 1899
     /**
1900 1900
      * ',' separated list of disallowed protocols.
1901 1901
      * - encoding: unused
1902
-     * - decoding: set by user through AVOptions (NO direct access)
1902
+     * - decoding: set by user
1903 1903
      */
1904 1904
     char *protocol_blacklist;
1905 1905
 
1906 1906
     /**
1907 1907
      * The maximum number of streams.
1908 1908
      * - encoding: unused
1909
-     * - decoding: set by user through AVOptions (NO direct access)
1909
+     * - decoding: set by user
1910 1910
      */
1911 1911
     int max_streams;
1912 1912
 } AVFormatContext;
1913 1913
 
1914
+/**
1915
+ * Accessors for some AVFormatContext fields. These used to be provided for ABI
1916
+ * compatibility, and do not need to be used anymore.
1917
+ */
1914 1918
 int av_format_get_probe_score(const AVFormatContext *s);
1915 1919
 AVCodec * av_format_get_video_codec(const AVFormatContext *s);
1916 1920
 void      av_format_set_video_codec(AVFormatContext *s, AVCodec *c);
... ...
@@ -33,7 +33,7 @@
33 33
 // Also please add any ticket numbers that you believe might be affected here
34 34
 #define LIBAVFORMAT_VERSION_MAJOR  57
35 35
 #define LIBAVFORMAT_VERSION_MINOR  66
36
-#define LIBAVFORMAT_VERSION_MICRO 102
36
+#define LIBAVFORMAT_VERSION_MICRO 103
37 37
 
38 38
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
39 39
                                                LIBAVFORMAT_VERSION_MINOR, \
... ...
@@ -179,9 +179,6 @@ typedef struct AVFrameSideData {
179 179
  *
180 180
  * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
181 181
  * to the end with a minor bump.
182
- * Similarly fields that are marked as to be only accessed by
183
- * av_opt_ptr() can be reordered. This allows 2 forks to add fields
184
- * without breaking compatibility with each other.
185 182
  *
186 183
  * Fields can be accessed through AVOptions, the name string used, matches the
187 184
  * C structure field name for fields accessible through AVOptions. The AVClass
... ...
@@ -420,8 +417,6 @@ typedef struct AVFrame {
420 420
 
421 421
     /**
422 422
      * MPEG vs JPEG YUV range.
423
-     * It must be accessed using av_frame_get_color_range() and
424
-     * av_frame_set_color_range().
425 423
      * - encoding: Set by user
426 424
      * - decoding: Set by libavcodec
427 425
      */
... ...
@@ -433,8 +428,6 @@ typedef struct AVFrame {
433 433
 
434 434
     /**
435 435
      * YUV colorspace type.
436
-     * It must be accessed using av_frame_get_colorspace() and
437
-     * av_frame_set_colorspace().
438 436
      * - encoding: Set by user
439 437
      * - decoding: Set by libavcodec
440 438
      */
... ...
@@ -444,8 +437,6 @@ typedef struct AVFrame {
444 444
 
445 445
     /**
446 446
      * frame timestamp estimated using various heuristics, in stream time base
447
-     * Code outside libavutil should access this field using:
448
-     * av_frame_get_best_effort_timestamp(frame)
449 447
      * - encoding: unused
450 448
      * - decoding: set by libavcodec, read by user.
451 449
      */
... ...
@@ -453,8 +444,6 @@ typedef struct AVFrame {
453 453
 
454 454
     /**
455 455
      * reordered pos from the last AVPacket that has been input into the decoder
456
-     * Code outside libavutil should access this field using:
457
-     * av_frame_get_pkt_pos(frame)
458 456
      * - encoding: unused
459 457
      * - decoding: Read by user.
460 458
      */
... ...
@@ -463,8 +452,6 @@ typedef struct AVFrame {
463 463
     /**
464 464
      * duration of the corresponding packet, expressed in
465 465
      * AVStream->time_base units, 0 if unknown.
466
-     * Code outside libavutil should access this field using:
467
-     * av_frame_get_pkt_duration(frame)
468 466
      * - encoding: unused
469 467
      * - decoding: Read by user.
470 468
      */
... ...
@@ -472,8 +459,6 @@ typedef struct AVFrame {
472 472
 
473 473
     /**
474 474
      * metadata.
475
-     * Code outside libavutil should access this field using:
476
-     * av_frame_get_metadata(frame)
477 475
      * - encoding: Set by user.
478 476
      * - decoding: Set by libavcodec.
479 477
      */
... ...
@@ -483,8 +468,6 @@ typedef struct AVFrame {
483 483
      * decode error flags of the frame, set to a combination of
484 484
      * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
485 485
      * were errors during the decoding.
486
-     * Code outside libavutil should access this field using:
487
-     * av_frame_get_decode_error_flags(frame)
488 486
      * - encoding: unused
489 487
      * - decoding: set by libavcodec, read by user.
490 488
      */
... ...
@@ -494,8 +477,6 @@ typedef struct AVFrame {
494 494
 
495 495
     /**
496 496
      * number of audio channels, only used for audio.
497
-     * Code outside libavutil should access this field using:
498
-     * av_frame_get_channels(frame)
499 497
      * - encoding: unused
500 498
      * - decoding: Read by user.
501 499
      */
... ...
@@ -503,8 +484,7 @@ typedef struct AVFrame {
503 503
 
504 504
     /**
505 505
      * size of the corresponding packet containing the compressed
506
-     * frame. It must be accessed using av_frame_get_pkt_size() and
507
-     * av_frame_set_pkt_size().
506
+     * frame.
508 507
      * It is set to a negative value if unknown.
509 508
      * - encoding: unused
510 509
      * - decoding: set by libavcodec, read by user.
... ...
@@ -514,13 +494,11 @@ typedef struct AVFrame {
514 514
 #if FF_API_FRAME_QP
515 515
     /**
516 516
      * QP table
517
-     * Not to be accessed directly from outside libavutil
518 517
      */
519 518
     attribute_deprecated
520 519
     int8_t *qscale_table;
521 520
     /**
522 521
      * QP store stride
523
-     * Not to be accessed directly from outside libavutil
524 522
      */
525 523
     attribute_deprecated
526 524
     int qstride;
... ...
@@ -528,9 +506,6 @@ typedef struct AVFrame {
528 528
     attribute_deprecated
529 529
     int qscale_type;
530 530
 
531
-    /**
532
-     * Not to be accessed directly from outside libavutil
533
-     */
534 531
     AVBufferRef *qp_table_buf;
535 532
 #endif
536 533
     /**
... ...
@@ -552,9 +527,8 @@ typedef struct AVFrame {
552 552
 } AVFrame;
553 553
 
554 554
 /**
555
- * Accessors for some AVFrame fields.
556
- * The position of these field in the structure is not part of the ABI,
557
- * they should not be accessed directly outside libavutil.
555
+ * Accessors for some AVFrame fields. These used to be provided for ABI
556
+ * compatibility, and do not need to be used anymore.
558 557
  */
559 558
 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
560 559
 void    av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
... ...
@@ -80,7 +80,7 @@
80 80
 
81 81
 #define LIBAVUTIL_VERSION_MAJOR  55
82 82
 #define LIBAVUTIL_VERSION_MINOR  47
83
-#define LIBAVUTIL_VERSION_MICRO 100
83
+#define LIBAVUTIL_VERSION_MICRO 101
84 84
 
85 85
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
86 86
                                                LIBAVUTIL_VERSION_MINOR, \