Commit e0de84ad authored by Anton Khirnov's avatar Anton Khirnov

lavc/encode: map AVCodecContext.decoded_side_data to coded_side_data

This way it can be automagically propagated through the encoder to
muxing.
parent a3f46709
......@@ -782,6 +782,29 @@ int ff_encode_preinit(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) {
const enum AVPacketSideDataType type_packet = ff_sd_global_map[i].packet;
const enum AVFrameSideDataType type_frame = ff_sd_global_map[i].frame;
const AVFrameSideData *sd_frame;
AVPacketSideData *sd_packet;
sd_frame = av_frame_side_data_get(avctx->decoded_side_data,
avctx->nb_decoded_side_data,
type_frame);
if (!sd_frame ||
av_packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data,
type_packet))
continue;
sd_packet = av_packet_side_data_new(&avctx->coded_side_data, &avctx->nb_coded_side_data,
type_packet, sd_frame->size, 0);
if (!sd_packet)
return AVERROR(ENOMEM);
memcpy(sd_packet->data, sd_frame->data, sd_frame->size);
}
if (CONFIG_FRAME_THREAD_ENCODER) {
ret = ff_frame_thread_encoder_init(avctx);
if (ret < 0)
......
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