diff options
author | James Almer <jamrial@gmail.com> | 2023-07-16 17:57:26 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2023-10-06 10:03:57 -0300 |
commit | 5432d2aacad5fa7420fe2d9369ed061d521e92d6 (patch) | |
tree | 9c1bf0307108a16ed652261d590042e5944e288d /libavformat/mpegenc.c | |
parent | 21d7cc6fa9a26e94965fa71b25655d07568450fe (diff) |
avformat/avformat: use the side data from AVStream.codecpar
Deprecate AVStream.side_data and its helpers in favor of the AVStream's
codecpar.coded_side_data.
This will considerably simplify the propagation of global side data to decoders
and from encoders. Instead of having to do it inside packets, it will be
available during init().
Global and frame specific side data will therefore be distinct.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mpegenc.c')
-rw-r--r-- | libavformat/mpegenc.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index c06e308296..12d9fb33ec 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -342,8 +342,6 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) lpcm_id = LPCM_ID; for (i = 0; i < ctx->nb_streams; i++) { - AVCPBProperties *props; - st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) @@ -430,13 +428,19 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) stream->max_buffer_size = 4 * 1024; s->audio_bound++; break; - case AVMEDIA_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: { + const AVPacketSideData *sd; + AVCPBProperties *props = NULL; if (st->codecpar->codec_id == AV_CODEC_ID_H264) stream->id = h264_id++; else stream->id = mpv_id++; - props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + sd = av_packet_side_data_get(st->codecpar->coded_side_data, + st->codecpar->nb_coded_side_data, + AV_PKT_DATA_CPB_PROPERTIES); + if (sd) + props = (AVCPBProperties*)sd->data; if (props && props->buffer_size) stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8; else { @@ -453,6 +457,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) } s->video_bound++; break; + } case AVMEDIA_TYPE_SUBTITLE: stream->id = mps_id++; stream->max_buffer_size = 16 * 1024; @@ -470,12 +475,17 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) audio_bitrate = 0; video_bitrate = 0; for (i = 0; i < ctx->nb_streams; i++) { - AVCPBProperties *props; + const AVPacketSideData *sd; + AVCPBProperties *props = NULL; int codec_rate; st = ctx->streams[i]; stream = (StreamInfo *)st->priv_data; - props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + sd = av_packet_side_data_get(st->codecpar->coded_side_data, + st->codecpar->nb_coded_side_data, + AV_PKT_DATA_CPB_PROPERTIES); + if (sd) + props = (AVCPBProperties*)sd->data; if (props) codec_rate = props->max_bitrate; else |