[FFmpeg-devel] [PATCH 1/4] fftools/ffmpeg_enc: strip DOVI config record for AV1
Niklas Haas
ffmpeg at haasn.xyz
Tue Mar 19 21:16:39 EET 2024
From: Niklas Haas <git at haasn.dev>
AV1 streams don't use configuration records, so delete them when
encoding to AV1. Ideally this would be, as the comment suggests, handled
at the frame-level (and stripped by the av1 encoder), but given the
status quo of copying the packet-level data here directly, we should
definitely make an effort to strip it.
---
fftools/ffmpeg_enc.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index c9a12af1393..0c21acfafc6 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -354,17 +354,20 @@ int enc_open(void *opaque, const AVFrame *frame)
*/
if (ist) {
for (int i = 0; i < ist->st->codecpar->nb_coded_side_data; i++) {
- AVPacketSideData *sd_src = &ist->st->codecpar->coded_side_data[i];
- if (sd_src->type != AV_PKT_DATA_CPB_PROPERTIES) {
- AVPacketSideData *sd_dst = av_packet_side_data_new(&ost->par_in->coded_side_data,
- &ost->par_in->nb_coded_side_data,
- sd_src->type, sd_src->size, 0);
- if (!sd_dst)
- return AVERROR(ENOMEM);
- memcpy(sd_dst->data, sd_src->data, sd_src->size);
- if (ist->autorotate && sd_src->type == AV_PKT_DATA_DISPLAYMATRIX)
- av_display_rotation_set((int32_t *)sd_dst->data, 0);
- }
+ AVPacketSideData *sd_src, *sd_dst;
+ sd_src = &ist->st->codecpar->coded_side_data[i];
+ if (sd_src->type == AV_PKT_DATA_CPB_PROPERTIES)
+ continue;
+ if (sd_src->type == AV_PKT_DATA_DOVI_CONF && enc->id == AV_CODEC_ID_AV1)
+ continue; /* AV1 doesn't use DOVI configuration records */
+ sd_dst = av_packet_side_data_new(&ost->par_in->coded_side_data,
+ &ost->par_in->nb_coded_side_data,
+ sd_src->type, sd_src->size, 0);
+ if (!sd_dst)
+ return AVERROR(ENOMEM);
+ memcpy(sd_dst->data, sd_src->data, sd_src->size);
+ if (ist->autorotate && sd_src->type == AV_PKT_DATA_DISPLAYMATRIX)
+ av_display_rotation_set((int32_t *)sd_dst->data, 0);
}
}
--
2.44.0
More information about the ffmpeg-devel
mailing list