History

avcodec, avformat: deprecate anything related to side data merging

This patch deprecates anything that has to do with merging/splitting side data. Automatic side data merging (and splitting), as well as all API symbols involved in it, are removed completely. Two FF_API_ defines are dedicated to deprecating API symbols related to this: FF_API_MERGE_SD_API removes av_packet_split/merge_side_data in libavcodec, and FF_API_LAVF_KEEPSIDE_FLAG deprecates AVFMT_FLAG_KEEP_SIDE_DATA in libavformat. Since it was claimed that changing the default from merging side data to not doing it is an ABI change, there are two additional FF_API_ defines, which stop using the side data merging/splitting by default (and remove any code in avformat/avcodec doing this): FF_API_MERGE_SD in libavcodec, and FF_API_LAVF_MERGE_SD in libavformat. It is very much intended that FF_API_MERGE_SD and FF_API_LAVF_MERGE_SD are quickly defined to 0 in the next ABI bump, while the API symbols are retained for a longer time for the sake of compatibility. AVFMT_FLAG_KEEP_SIDE_DATA will (very much intentionally) do nothing for most of the time it will still be defined. Keep in mind that no code exists that actually tries to unset this flag for any reason, nor does such code need to exist. Code setting this flag explicitly will work as before. Thus it's ok for AVFMT_FLAG_KEEP_SIDE_DATA to do nothing once side data merging has been removed from libavformat. In order to avoid that anyone in the future does this incorrectly, here is a small guide how to update the internal code on bumps: - next ABI bump (probably soon): - define FF_API_LAVF_MERGE_SD to 0, and remove all code covered by it - define FF_API_MERGE_SD to 0, and remove all code covered by it - next API bump (typically two years in the future or so): - define FF_API_LAVF_KEEPSIDE_FLAG to 0, and remove all code covered by it - define FF_API_MERGE_SD_API to 0, and remove all code covered by it This forces anyone who actually wants packet side data to temporarily use deprecated API to get it all. If you ask me, this is batshit fucked up crazy, but it's how we roll. Making AVFMT_FLAG_KEEP_SIDE_DATA to be set by default was rejected as an ABI change, so I'm going all the way to get rid of this once and for all.

wm4 committed 9 years ago

Commit d682ae71 parent 5e3a41810 files · +73 −3Browse files

Unified · Split

10 files
  1. doc/APIchanges +5 −0
  2. libavcodec/avcodec.h +4 −0
  3. libavcodec/avpacket.c +4 −0
  4. libavcodec/utils.c +24 −0
  5. libavcodec/version.h +8 −1
  6. libavformat/avformat.h +3 −1
  7. libavformat/mux.c +12 −0
  8. libavformat/options_table.h +2 −0
  9. libavformat/utils.c +4 −0
  10. libavformat/version.h +7 −1
doc/APIchanges+5−0
@@ -15,6 +15,11 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2017-03-21 - xxxxxxx - lavf 57.66.105, lavc 57.83.101 - avformat.h, avcodec.h
19+ Deprecate AVFMT_FLAG_KEEP_SIDE_DATA. It will be ignored after the next major
20+ bump, and libavformat will behave as if it were always set.
21+ Deprecate av_packet_merge_side_data() and av_packet_split_side_data().
22+
1823 2016-03-20 - xxxxxxx - lavu 55.50.100 / 55.21.0 - imgutils.h
1924 Add av_image_copy_uc_from(), a version of av_image_copy() for copying
2025 from GPU mapped memory.
libavcodec/avcodec.h+4−0
@@ -4576,9 +4576,13 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, · 4575 unmodified lines
45764576 uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
45774577 int *size);
45784578
4579+#if FF_API_MERGE_SD_API
4580+attribute_deprecated
45794581 int av_packet_merge_side_data(AVPacket *pkt);
45804582
4583+attribute_deprecated
45814584 int av_packet_split_side_data(AVPacket *pkt);
4585+#endif
45824586
45834587 const char *av_packet_side_data_name(enum AVPacketSideDataType type);
45844588
libavcodec/avpacket.c+4−0
@@ -379,6 +379,8 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) · 378 unmodified lines
379379 return NULL;
380380 }
381381
382+#if FF_API_MERGE_SD_API
383+
382384 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
383385
384386 int av_packet_merge_side_data(AVPacket *pkt){
@@ -460,6 +462,8 @@ int av_packet_split_side_data(AVPacket *pkt){ · 75 unmodified lines
460462 return 0;
461463 }
462464
465+#endif
466+
463467 uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size)
464468 {
465469 AVDictionaryEntry *t = NULL;
libavcodec/utils.c+24−0
@@ -2263,7 +2263,11 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi · 2262 unmodified lines
22632263
22642264 if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size ||
22652265 (avctx->active_thread_type & FF_THREAD_FRAME)) {
2266+#if FF_API_MERGE_SD
2267+FF_DISABLE_DEPRECATION_WARNINGS
22662268 int did_split = av_packet_split_side_data(&tmp);
2269+FF_ENABLE_DEPRECATION_WARNINGS
2270+#endif
22672271 ret = apply_param_change(avctx, &tmp);
22682272 if (ret < 0)
22692273 goto fail;
@@ -2295,11 +2299,13 @@ fail: · 25 unmodified lines
22952299 emms_c(); //needed to avoid an emms_c() call before every return;
22962300
22972301 avctx->internal->pkt = NULL;
2302+#if FF_API_MERGE_SD
22982303 if (did_split) {
22992304 av_packet_free_side_data(&tmp);
23002305 if(ret == tmp.size)
23012306 ret = avpkt->size;
23022307 }
2308+#endif
23032309 if (picture->flags & AV_FRAME_FLAG_DISCARD) {
23042310 *got_picture_ptr = 0;
23052311 }
@@ -2369,7 +2375,11 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, · 63 unmodified lines
23692375 uint8_t discard_reason = 0;
23702376 // copy to ensure we do not change avpkt
23712377 AVPacket tmp = *avpkt;
2378+#if FF_API_MERGE_SD
2379+FF_DISABLE_DEPRECATION_WARNINGS
23722380 int did_split = av_packet_split_side_data(&tmp);
2381+FF_ENABLE_DEPRECATION_WARNINGS
2382+#endif
23732383 ret = apply_param_change(avctx, &tmp);
23742384 if (ret < 0)
23752385 goto fail;
@@ -2481,11 +2491,13 @@ FF_ENABLE_DEPRECATION_WARNINGS · 105 unmodified lines
24812491 }
24822492 fail:
24832493 avctx->internal->pkt = NULL;
2494+#if FF_API_MERGE_SD
24842495 if (did_split) {
24852496 av_packet_free_side_data(&tmp);
24862497 if(ret == tmp.size)
24872498 ret = avpkt->size;
24882499 }
2500+#endif
24892501
24902502 if (ret >= 0 && *got_frame_ptr) {
24912503 if (!avctx->refcounted_frames) {
@@ -2682,6 +2694,8 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, · 190 unmodified lines
26822694 if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
26832695 AVPacket pkt_recoded;
26842696 AVPacket tmp = *avpkt;
2697+#if FF_API_MERGE_SD
2698+FF_DISABLE_DEPRECATION_WARNINGS
26852699 int did_split = av_packet_split_side_data(&tmp);
26862700 //apply_param_change(avctx, &tmp);
26872701
@@ -2694,6 +2708,8 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, · 6 unmodified lines
26942708 memset(tmp.data + tmp.size, 0,
26952709 FFMIN(avpkt->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));
26962710 }
2711+FF_ENABLE_DEPRECATION_WARNINGS
2712+#endif
26972713
26982714 pkt_recoded = tmp;
26992715 ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
@@ -2753,11 +2769,13 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, · 53 unmodified lines
27532769 avctx->internal->pkt = NULL;
27542770 }
27552771
2772+#if FF_API_MERGE_SD
27562773 if (did_split) {
27572774 av_packet_free_side_data(&tmp);
27582775 if(ret == tmp.size)
27592776 ret = avpkt->size;
27602777 }
2778+#endif
27612779
27622780 if (*got_sub_ptr)
27632781 avctx->frame_number++;
@@ -2873,12 +2891,18 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke · 109 unmodified lines
28732891 if (avctx->codec->send_packet) {
28742892 if (avpkt) {
28752893 AVPacket tmp = *avpkt;
2894+#if FF_API_MERGE_SD
2895+FF_DISABLE_DEPRECATION_WARNINGS
28762896 int did_split = av_packet_split_side_data(&tmp);
2897+FF_ENABLE_DEPRECATION_WARNINGS
2898+#endif
28772899 ret = apply_param_change(avctx, &tmp);
28782900 if (ret >= 0)
28792901 ret = avctx->codec->send_packet(avctx, &tmp);
2902+#if FF_API_MERGE_SD
28802903 if (did_split)
28812904 av_packet_free_side_data(&tmp);
2905+#endif
28822906 return ret;
28832907 } else {
28842908 return avctx->codec->send_packet(avctx, NULL);
libavcodec/version.h+8−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 57
3131 #define LIBAVCODEC_VERSION_MINOR 83
32−#define LIBAVCODEC_VERSION_MICRO 100
32+#define LIBAVCODEC_VERSION_MICRO 101
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 LIBAVCODEC_VERSION_MINOR, \
@@ -157,6 +157,9 @@ · 121 unmodified lines
157157 #ifndef FF_API_VAAPI_CONTEXT
158158 #define FF_API_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 58)
159159 #endif
160+#ifndef FF_API_MERGE_SD
161+#define FF_API_MERGE_SD (LIBAVCODEC_VERSION_MAJOR < 58)
162+#endif
160163 #ifndef FF_API_AVCTX_TIMEBASE
161164 #define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59)
162165 #endif
@@ -229,5 +232,9 @@ · 66 unmodified lines
229232 #ifndef FF_API_STRUCT_VAAPI_CONTEXT
230233 #define FF_API_STRUCT_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59)
231234 #endif
235+#ifndef FF_API_MERGE_SD_API
236+#define FF_API_MERGE_SD_API (LIBAVCODEC_VERSION_MAJOR < 59)
237+#endif
238+
232239
233240 #endif /* AVCODEC_VERSION_H */
libavformat/avformat.h+3−1
@@ -1468,7 +1468,9 @@ typedef struct AVFormatContext { · 1467 unmodified lines
14681468 #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
14691469 #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
14701470 #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
1471−#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
1471+#if FF_API_LAVF_KEEPSIDE_FLAG
1472+#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate. Deprecated, will be the default.
1473+#endif
14721474 #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats
14731475 #define AVFMT_FLAG_SHORTEST 0x100000 ///< Stop muxing when the shortest stream stops.
14741476 #define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Wait for packet data before writing a header, and add bitstream filters as requested by the muxer
libavformat/mux.c+12−0
@@ -752,7 +752,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 751 unmodified lines
752752 }
753753 }
754754
755+#if FF_API_LAVF_MERGE_SD
756+FF_DISABLE_DEPRECATION_WARNINGS
755757 did_split = av_packet_split_side_data(pkt);
758+FF_ENABLE_DEPRECATION_WARNINGS
759+#endif
756760
757761 if (!s->internal->header_written) {
758762 ret = s->internal->write_header_ret ? s->internal->write_header_ret : write_header_internal(s);
@@ -777,8 +781,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 18 unmodified lines
777781 }
778782
779783 fail:
784+#if FF_API_LAVF_MERGE_SD
785+FF_DISABLE_DEPRECATION_WARNINGS
780786 if (did_split)
781787 av_packet_merge_side_data(pkt);
788+FF_ENABLE_DEPRECATION_WARNINGS
789+#endif
782790
783791 if (ret < 0) {
784792 pkt->pts = pts_backup;
@@ -875,8 +883,12 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { · 90 unmodified lines
875883 }
876884 }
877885
886+#if FF_API_LAVF_MERGE_SD
887+FF_DISABLE_DEPRECATION_WARNINGS
878888 if (st->internal->nb_bsfcs)
879889 av_packet_split_side_data(pkt);
890+FF_ENABLE_DEPRECATION_WARNINGS
891+#endif
880892
881893 for (i = 0; i < st->internal->nb_bsfcs; i++) {
882894 AVBSFContext *ctx = st->internal->bsfcs[i];
libavformat/options_table.h+2−0
@@ -48,7 +48,9 @@ static const AVOption avformat_options[] = { · 47 unmodified lines
4848 {"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
4949 {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
5050 {"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"},
51+#if FF_API_LAVF_KEEPSIDE_FLAG
5152 {"keepside", "don't merge side data", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
53+#endif
5254 {"fastseek", "fast but inaccurate seeks", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_FAST_SEEK }, INT_MIN, INT_MAX, D, "fflags"},
5355 {"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
5456 {"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
libavformat/utils.c+4−0
@@ -1675,8 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1674 unmodified lines
16751675 st->inject_global_side_data = 0;
16761676 }
16771677
1678+#if FF_API_LAVF_MERGE_SD
1679+FF_DISABLE_DEPRECATION_WARNINGS
16781680 if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))
16791681 av_packet_merge_side_data(pkt);
1682+FF_ENABLE_DEPRECATION_WARNINGS
1683+#endif
16801684 }
16811685
16821686 av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata);
libavformat/version.h+7−1
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 // Also please add any ticket numbers that you believe might be affected here
3434 #define LIBAVFORMAT_VERSION_MAJOR 57
3535 #define LIBAVFORMAT_VERSION_MINOR 66
36−#define LIBAVFORMAT_VERSION_MICRO 104
36+#define LIBAVFORMAT_VERSION_MICRO 105
3737
3838 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3939 LIBAVFORMAT_VERSION_MINOR, \
@@ -88,6 +88,12 @@ · 48 unmodified lines
8888 #ifndef FF_API_HLS_WRAP
8989 #define FF_API_HLS_WRAP (LIBAVFORMAT_VERSION_MAJOR < 58)
9090 #endif
91+#ifndef FF_API_LAVF_MERGE_SD
92+#define FF_API_LAVF_MERGE_SD (LIBAVFORMAT_VERSION_MAJOR < 58)
93+#endif
94+#ifndef FF_API_LAVF_KEEPSIDE_FLAG
95+#define FF_API_LAVF_KEEPSIDE_FLAG (LIBAVFORMAT_VERSION_MAJOR < 58)
96+#endif
9197
9298
9399 #ifndef FF_API_R_FRAME_RATE

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t