From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 09/22] avcodec/dovi_rpu: add ff_dovi_get_metadata()
Date: Sun, 28 Jul 2024 12:25:14 +0200
Message-ID: <20240728102527.17991-9-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20240728102527.17991-1-ffmpeg@haasn.xyz>
From: Niklas Haas <git@haasn.dev>
Provides direct access to the AVDOVIMetadata without having to attach it
to a frame.
---
libavcodec/dovi_rpu.h | 9 +++++++++
libavcodec/dovi_rpudec.c | 40 +++++++++++++++++++++++++++-------------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h
index e2e7635cfb..4eb4bc0873 100644
--- a/libavcodec/dovi_rpu.h
+++ b/libavcodec/dovi_rpu.h
@@ -108,8 +108,17 @@ void ff_dovi_ctx_flush(DOVIContext *s);
int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
int err_recognition);
+/**
+ * Get the decoded AVDOVIMetadata. Ownership passes to the caller.
+ *
+ * Returns the size of *out_metadata, a negative error code, or 0 if no
+ * metadata is available to return.
+ */
+int ff_dovi_get_metadata(DOVIContext *s, AVDOVIMetadata **out_metadata);
+
/**
* Attach the decoded AVDOVIMetadata as side data to an AVFrame.
+ * Returns 0 or a negative error code.
*/
int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame);
diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c
index bf6e5075d1..0ddc923539 100644
--- a/libavcodec/dovi_rpudec.c
+++ b/libavcodec/dovi_rpudec.c
@@ -30,10 +30,8 @@
#include "get_bits.h"
#include "refstruct.h"
-int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
+int ff_dovi_get_metadata(DOVIContext *s, AVDOVIMetadata **out_metadata)
{
- AVFrameSideData *sd;
- AVBufferRef *buf;
AVDOVIMetadata *dovi;
size_t dovi_size, ext_sz;
@@ -44,7 +42,32 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
if (!dovi)
return AVERROR(ENOMEM);
- buf = av_buffer_create((uint8_t *) dovi, dovi_size, NULL, NULL, 0);
+ /* Copy only the parts of these structs known to us at compiler-time. */
+#define COPY(t, a, b, last) memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
+ COPY(AVDOVIRpuDataHeader, av_dovi_get_header(dovi), &s->header, ext_mapping_idc_5_7);
+ COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, nlq_pivots);
+ COPY(AVDOVIColorMetadata, av_dovi_get_color(dovi), s->color, source_diagonal);
+ ext_sz = FFMIN(sizeof(AVDOVIDmData), dovi->ext_block_size);
+ for (int i = 0; i < s->num_ext_blocks; i++)
+ memcpy(av_dovi_get_ext(dovi, i), &s->ext_blocks[i], ext_sz);
+ dovi->num_ext_blocks = s->num_ext_blocks;
+
+ *out_metadata = dovi;
+ return dovi_size;
+}
+
+int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
+{
+ AVFrameSideData *sd;
+ AVDOVIMetadata *dovi;
+ AVBufferRef *buf;
+ int size;
+
+ size = ff_dovi_get_metadata(s, &dovi);
+ if (size <= 0)
+ return size;
+
+ buf = av_buffer_create((uint8_t *) dovi, size, NULL, NULL, 0);
if (!buf) {
av_free(dovi);
return AVERROR(ENOMEM);
@@ -56,15 +79,6 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
return AVERROR(ENOMEM);
}
- /* Copy only the parts of these structs known to us at compiler-time. */
-#define COPY(t, a, b, last) memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
- COPY(AVDOVIRpuDataHeader, av_dovi_get_header(dovi), &s->header, ext_mapping_idc_5_7);
- COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, nlq_pivots);
- COPY(AVDOVIColorMetadata, av_dovi_get_color(dovi), s->color, source_diagonal);
- ext_sz = FFMIN(sizeof(AVDOVIDmData), dovi->ext_block_size);
- for (int i = 0; i < s->num_ext_blocks; i++)
- memcpy(av_dovi_get_ext(dovi, i), &s->ext_blocks[i], ext_sz);
- dovi->num_ext_blocks = s->num_ext_blocks;
return 0;
}
--
2.45.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-07-28 10:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-28 10:25 [FFmpeg-devel] [PATCH 01/22] avutil/dovi_meta: document static vs dynamic ext blocks Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 02/22] avcodec/dovi_rpudec: implement validation for compression Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 03/22] avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 04/22] avcodec/dovi_rpuenc: eliminate unnecessary loop Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 05/22] avcodec/dovi_rpuenc: respect dv_md_compression Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 06/22] avcodec/dovi_rpuenc: add `flags` to ff_dovi_rpu_generate() Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 07/22] avcodec/dovi_rpuenc: make encapsulation optional Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 08/22] avcodec/dovi_rpuenc: add a flag to enable compression Niklas Haas
2024-07-28 10:25 ` Niklas Haas [this message]
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 10/22] avcodec/dovi_rpuenc: add ff_dovi_configure_ext() Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 11/22] avcodec/dovi_rpuenc: add configuration for compression Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 12/22] avcodec/bsf/dovi_rpu: add new bitstream filter Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 13/22] avcodec/dovi_rpu: move ext blocks into dedicated struct Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 14/22] avcodec/dovi_rpu: separate static ext blocks Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 15/22] avcodec/dovi_rpudec: don't unnecessarily allocate DOVIExt Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 16/22] avcodec/dovi_rpudec: implement limited DM decompression Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 17/22] avcodec/dovi_rpudec: sanitize DM data before decoding Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 18/22] avcodec/dovi_rpuenc: implement DM metadata compression Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 19/22] avcodec/dovi_rpuenc: slightly improve profile autodetection Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 20/22] avcodec/dovi_rpudec: error out on strange RPU formats Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 21/22] avcodec/libsvtav1: raise strictness of missing DV error Niklas Haas
2024-08-03 18:08 ` Andreas Rheinhardt
2024-08-04 16:31 ` Niklas Haas
2024-07-28 10:25 ` [FFmpeg-devel] [PATCH 22/22] avcodec/libx265: " Niklas Haas
2024-07-31 12:14 ` [FFmpeg-devel] [PATCH 01/22] avutil/dovi_meta: document static vs dynamic ext blocks Niklas Haas
[not found] ` <D964CDCD-7D3D-4373-9F37-0404669324FE@cosmin.at>
2024-08-03 3:53 ` Cosmin Stejerean via ffmpeg-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240728102527.17991-9-ffmpeg@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=git@haasn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git