This and the following commits fix #10857
Unified · Split
| @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | API changes, most recent first: | 3 | API changes, most recent first: |
| 4 | 4 | ||
| 5 | 2024-03-08 - xxxxxxxxxx - lavc 61.1.100 - avcodec.h | ||
| 6 | Add AVCodecContext.[nb_]side_data_prefer_packet. | ||
| 7 | |||
| 5 | 2024-03-08 - xxxxxxxxxx - lavu 59.1.100 - opt.h | 8 | 2024-03-08 - xxxxxxxxxx - lavu 59.1.100 - opt.h |
| 6 | Add AV_OPT_TYPE_FLAG_ARRAY and AVOptionArrayDef. | 9 | Add AV_OPT_TYPE_FLAG_ARRAY and AVOptionArrayDef. |
| 7 | 10 | ||
| @@ -2028,6 +2028,40 @@ typedef struct AVCodecContext { · 2027 unmodified lines | |||
| 2028 | * an error. | 2028 | * an error. |
| 2029 | */ | 2029 | */ |
| 2030 | int64_t frame_num; | 2030 | int64_t frame_num; |
| 2031 | |||
| 2032 | /** | ||
| 2033 | * Decoding only. May be set by the caller before avcodec_open2() to an | ||
| 2034 | * av_malloc()'ed array (or via AVOptions). Owned and freed by the decoder | ||
| 2035 | * afterwards. | ||
| 2036 | * | ||
| 2037 | * Side data attached to decoded frames may come from several sources: | ||
| 2038 | * 1. coded_side_data, which the decoder will for certain types translate | ||
| 2039 | * from packet-type to frame-type and attach to frames; | ||
| 2040 | * 2. side data attached to an AVPacket sent for decoding (same | ||
| 2041 | * considerations as above); | ||
| 2042 | * 3. extracted from the coded bytestream. | ||
| 2043 | * The first two cases are supplied by the caller and typically come from a | ||
| 2044 | * container. | ||
| 2045 | * | ||
| 2046 | * This array configures decoder behaviour in cases when side data of the | ||
| 2047 | * same type is present both in the coded bytestream and in the | ||
| 2048 | * user-supplied side data (items 1. and 2. above). In all cases, at most | ||
| 2049 | * one instance of each side data type will be attached to output frames. By | ||
| 2050 | * default it will be the bytestream side data. Adding an | ||
| 2051 | * AVPacketSideDataType value to this array will flip the preference for | ||
| 2052 | * this type, thus making the decoder prefer user-supplied side data over | ||
| 2053 | * bytestream. In case side data of the same type is present both in | ||
| 2054 | * coded_data and attacked to a packet, the packet instance always has | ||
| 2055 | * priority. | ||
| 2056 | * | ||
| 2057 | * The array may also contain a single -1, in which case the preference is | ||
| 2058 | * switched for all side data types. | ||
| 2059 | */ | ||
| 2060 | int *side_data_prefer_packet; | ||
| 2061 | /** | ||
| 2062 | * Number of entries in side_data_prefer_packet. | ||
| 2063 | */ | ||
| 2064 | unsigned nb_side_data_prefer_packet; | ||
| 2031 | } AVCodecContext; | 2065 | } AVCodecContext; |
| 2032 | 2066 | ||
| 2033 | /** | 2067 | /** |
| @@ -65,6 +65,12 @@ typedef struct DecodeContext { · 64 unmodified lines | |||
| 65 | int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far | 65 | int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far |
| 66 | int64_t pts_correction_last_pts; /// PTS of the last frame | 66 | int64_t pts_correction_last_pts; /// PTS of the last frame |
| 67 | int64_t pts_correction_last_dts; /// DTS of the last frame | 67 | int64_t pts_correction_last_dts; /// DTS of the last frame |
| 68 | |||
| 69 | /** | ||
| 70 | * Bitmask indicating for which side data types we prefer user-supplied | ||
| 71 | * (global or attached to packets) side data over bytestream. | ||
| 72 | */ | ||
| 73 | uint64_t side_data_pref_mask; | ||
| 68 | } DecodeContext; | 74 | } DecodeContext; |
| 69 | 75 | ||
| 70 | static DecodeContext *decode_ctx(AVCodecInternal *avci) | 76 | static DecodeContext *decode_ctx(AVCodecInternal *avci) |
| @@ -1739,6 +1745,35 @@ int ff_decode_preinit(AVCodecContext *avctx) · 1668 unmodified lines | |||
| 1739 | avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; | 1745 | avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; |
| 1740 | } | 1746 | } |
| 1741 | 1747 | ||
| 1748 | if (avctx->nb_side_data_prefer_packet == 1 && | ||
| 1749 | avctx->side_data_prefer_packet[0] == -1) | ||
| 1750 | dc->side_data_pref_mask = ~0ULL; | ||
| 1751 | else { | ||
| 1752 | for (unsigned i = 0; i < avctx->nb_side_data_prefer_packet; i++) { | ||
| 1753 | int val = avctx->side_data_prefer_packet[i]; | ||
| 1754 | |||
| 1755 | if (val < 0 || val >= AV_PKT_DATA_NB) { | ||
| 1756 | av_log(avctx, AV_LOG_ERROR, "Invalid side data type: %d\n", val); | ||
| 1757 | return AVERROR(EINVAL); | ||
| 1758 | } | ||
| 1759 | |||
| 1760 | for (unsigned j = 0; j < FF_ARRAY_ELEMS(sd_global_map); j++) { | ||
| 1761 | if (sd_global_map[j].packet == val) { | ||
| 1762 | val = sd_global_map[j].frame; | ||
| 1763 | |||
| 1764 | // this code will need to be changed when we have more than | ||
| 1765 | // 64 frame side data types | ||
| 1766 | if (val >= 64) { | ||
| 1767 | av_log(avctx, AV_LOG_ERROR, "Side data type too big\n"); | ||
| 1768 | return AVERROR_BUG; | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | dc->side_data_pref_mask |= 1ULL << val; | ||
| 1772 | } | ||
| 1773 | } | ||
| 1774 | } | ||
| 1775 | } | ||
| 1776 | |||
| 1742 | avci->in_pkt = av_packet_alloc(); | 1777 | avci->in_pkt = av_packet_alloc(); |
| 1743 | avci->last_pkt_props = av_packet_alloc(); | 1778 | avci->last_pkt_props = av_packet_alloc(); |
| 1744 | if (!avci->in_pkt || !avci->last_pkt_props) | 1779 | if (!avci->in_pkt || !avci->last_pkt_props) |
| @@ -42,6 +42,8 @@ · 41 unmodified lines | |||
| 42 | #define D AV_OPT_FLAG_DECODING_PARAM | 42 | #define D AV_OPT_FLAG_DECODING_PARAM |
| 43 | #define CC AV_OPT_FLAG_CHILD_CONSTS | 43 | #define CC AV_OPT_FLAG_CHILD_CONSTS |
| 44 | 44 | ||
| 45 | #define AR AV_OPT_TYPE_FLAG_ARRAY | ||
| 46 | |||
| 45 | #define AV_CODEC_DEFAULT_BITRATE 200*1000 | 47 | #define AV_CODEC_DEFAULT_BITRATE 200*1000 |
| 46 | 48 | ||
| 47 | static const AVOption avcodec_options[] = { | 49 | static const AVOption avcodec_options[] = { |
| @@ -395,6 +397,16 @@ static const AVOption avcodec_options[] = { · 347 unmodified lines | |||
| 395 | {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, | 397 | {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, |
| 396 | {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, | 398 | {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, |
| 397 | {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, | 399 | {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, |
| 400 | {"side_data_prefer_packet", "Comma-separated list of side data types for which user-supplied (container) data is preferred over coded bytestream", | ||
| 401 | OFFSET(side_data_prefer_packet), AV_OPT_TYPE_INT | AR, .min = -1, .max = INT_MAX, .flags = V|A|S|D, .unit = "side_data_pkt" }, | ||
| 402 | {"replaygain", .default_val.i64 = AV_PKT_DATA_REPLAYGAIN, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 403 | {"displaymatrix", .default_val.i64 = AV_PKT_DATA_DISPLAYMATRIX, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 404 | {"spherical", .default_val.i64 = AV_PKT_DATA_SPHERICAL, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 405 | {"stereo3d", .default_val.i64 = AV_PKT_DATA_STEREO3D, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 406 | {"audio_service_type", .default_val.i64 = AV_PKT_DATA_AUDIO_SERVICE_TYPE, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 407 | {"mastering_display_metadata", .default_val.i64 = AV_PKT_DATA_MASTERING_DISPLAY_METADATA, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 408 | {"content_light_level", .default_val.i64 = AV_PKT_DATA_CONTENT_LIGHT_LEVEL, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 409 | {"icc_profile", .default_val.i64 = AV_PKT_DATA_ICC_PROFILE, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, | ||
| 398 | {NULL}, | 410 | {NULL}, |
| 399 | }; | 411 | }; |
| 400 | 412 | ||
| @@ -29,7 +29,7 @@ · 28 unmodified lines | |||
| 29 | 29 | ||
| 30 | #include "version_major.h" | 30 | #include "version_major.h" |
| 31 | 31 | ||
| 32 | #define LIBAVCODEC_VERSION_MINOR 0 | 32 | #define LIBAVCODEC_VERSION_MINOR 1 |
| 33 | #define LIBAVCODEC_VERSION_MICRO 100 | 33 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 34 | 34 | ||
| 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |