diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 32a795e758..053d342169 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -1028,6 +1029,8 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, break; } case ITU_T_T35_PROVIDER_CODE_DOLBY: { + AVBufferRef *rpu_buf; + AVFrameSideData *rpu; int provider_oriented_code = bytestream2_get_be32(&gb); if (itut_t35->itu_t_t35_country_code != ITU_T_T35_COUNTRY_CODE_US || provider_oriented_code != 0x800) @@ -1039,6 +1041,18 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, break; // ignore } + rpu_buf = av_buffer_alloc(itut_t35->payload_size); + if (rpu_buf) { + memcpy(rpu_buf->data, itut_t35->payload, itut_t35->payload_size); + rpu = av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_DOVI_RPU_BUFFER_T35, rpu_buf); + if (!rpu) { + av_buffer_unref(&rpu_buf); + return AVERROR(ENOMEM); + } + } else { + return AVERROR(ENOMEM); + } + ret = ff_dovi_attach_side_data(&s->dovi, frame); if (ret < 0) return ret; diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index ddcd0708b4..3bf3577ea9 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -562,6 +562,8 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) break; } case ITU_T_T35_PROVIDER_CODE_DOLBY: { + AVBufferRef *rpu_buf; + AVFrameSideData *rpu; int provider_oriented_code = bytestream2_get_be32(&gb); if (itut_t35->country_code != ITU_T_T35_COUNTRY_CODE_US || provider_oriented_code != 0x800) @@ -573,6 +575,18 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) break; // ignore } + rpu_buf = av_buffer_alloc(itut_t35->payload_size); + if (rpu_buf) { + memcpy(rpu_buf->data, itut_t35->payload, itut_t35->payload_size); + rpu = av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_DOVI_RPU_BUFFER_T35, rpu_buf); + if (!rpu) { + av_buffer_unref(&rpu_buf); + goto fail; + } + } else { + goto fail; + } + res = ff_dovi_attach_side_data(&dav1d->dovi, frame); if (res < 0) goto fail; diff --git a/libavutil/frame.c b/libavutil/frame.c index eb04a65c90..5b4c0db543 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -934,6 +934,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_FILM_GRAIN_PARAMS: return "Film grain parameters"; case AV_FRAME_DATA_DETECTION_BBOXES: return "Bounding boxes for object detection and classification"; case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data"; + case AV_FRAME_DATA_DOVI_RPU_BUFFER_T35: return "Dolby Vision RPU ITU T35 Data"; case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata"; case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment"; } diff --git a/libavutil/frame.h b/libavutil/frame.h index 8aa05ec127..67798577b1 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -200,6 +200,12 @@ enum AVFrameSideDataType { */ AV_FRAME_DATA_DOVI_RPU_BUFFER, + /** + * Dolby Vision RPU ITU T35 raw data, suitable for passing to SVT-AV1 + * or other libraries. Array of uint8_t. + */ + AV_FRAME_DATA_DOVI_RPU_BUFFER_T35, + /** * Parsed Dolby Vision metadata, suitable for passing to a software * implementation. The payload is the AVDOVIMetadata struct defined in