Commit 6064f697 authored by Vittorio Giovara's avatar Vittorio Giovara

lavc: Enable side data only packets by default

Deprecate the now unused option, but temporarily retain the capability
to disable the now default behaviour.

Mention this change in the AVPacket documentation.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 1e0b8bf0
......@@ -1595,7 +1595,6 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
}
if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0);
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
......
......@@ -1140,7 +1140,9 @@ typedef struct AVPacketSideData {
* then passed to muxers.
*
* For video, it should typically contain one compressed frame. For audio it may
* contain several compressed frames.
* contain several compressed frames. Encoders are allowed to output empty
* packets, with no compressed data, containing only side data
* (e.g. to update some stream parameters at the end of encoding).
*
* AVPacket is one of the few structs in Libav, whose size is a part of public
* ABI. Thus it may be allocated on stack and no new fields can be added to it
......@@ -2867,20 +2869,20 @@ typedef struct AVCodecContext {
*/
uint64_t vbv_delay;
#if FF_API_SIDEDATA_ONLY_PKT
/**
* Encoding only. Allow encoders to output packets that do not contain any
* encoded data, only side data.
* Encoding only and set by default. Allow encoders to output packets
* that do not contain any encoded data, only side data.
*
* Some encoders need to output such packets, e.g. to update some stream
* parameters at the end of encoding.
*
* All callers are strongly recommended to set this option to 1 and update
* their code to deal with such packets, since this behaviour may become
* always enabled in the future (then this option will be deprecated and
* later removed). To avoid ABI issues when this happens, the callers should
* use AVOptions to set this field.
* @deprecated this field disables the default behaviour and
* it is kept only for compatibility.
*/
attribute_deprecated
int side_data_only_packets;
#endif
/**
* Audio only. The number of "priming" samples (padding) inserted by the
......
......@@ -1214,7 +1214,13 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, avctx->extradata);
#if FF_API_SIDEDATA_ONLY_PKT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->side_data_only_packets && !s->flushed) {
FF_ENABLE_DEPRECATION_WARNINGS
#else
if (!s->flushed) {
#endif
uint8_t *side_data = av_packet_new_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
avctx->extradata_size);
if (!side_data)
......
......@@ -473,7 +473,9 @@ static const AVOption avcodec_options[] = {
{"fltp", "32-bit float planar", 0, AV_OPT_TYPE_CONST, {.i64 = AV_SAMPLE_FMT_FLTP }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
{"dblp", "64-bit double planar", 0, AV_OPT_TYPE_CONST, {.i64 = AV_SAMPLE_FMT_DBLP }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"},
{"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, A|V|D },
{"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, A|V|E },
#if FF_API_SIDEDATA_ONLY_PKT
{"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, A|V|E },
#endif
{NULL},
};
......
......@@ -162,5 +162,8 @@
#ifndef FF_API_WITHOUT_PREFIX
#define FF_API_WITHOUT_PREFIX (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_SIDEDATA_ONLY_PKT
#define FF_API_SIDEDATA_ONLY_PKT (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#endif /* AVCODEC_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment