From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/cbs: Remove CBS_CONTENT_TYPE_POD
Date: Sat, 22 Oct 2022 00:17:44 +0200
Message-ID: <AS8P250MB07447D7529CC514D70EA7DB58F2D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744D4EAF95F3F984BA3E5488F2B9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
Andreas Rheinhardt:
> It is equivalent to CBS_CONTENT_TYPE_INTERNAL_REFS
> with nb_offsets equal to zero.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/cbs.c | 18 ++++--------------
> libavcodec/cbs_internal.h | 21 ++++++++++++---------
> 2 files changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 8d6e3c3442..504197e06d 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -839,12 +839,10 @@ void ff_cbs_delete_unit(CodedBitstreamFragment *frag,
> static void cbs_default_free_unit_content(void *opaque, uint8_t *data)
> {
> const CodedBitstreamUnitTypeDescriptor *desc = opaque;
> - if (desc->content_type == CBS_CONTENT_TYPE_INTERNAL_REFS) {
> - int i;
> - for (i = 0; i < desc->type.ref.nb_offsets; i++) {
> - void **ptr = (void**)(data + desc->type.ref.offsets[i]);
> - av_buffer_unref((AVBufferRef**)(ptr + 1));
> - }
> +
> + for (int i = 0; i < desc->type.ref.nb_offsets; i++) {
> + void **ptr = (void**)(data + desc->type.ref.offsets[i]);
> + av_buffer_unref((AVBufferRef**)(ptr + 1));
> }
> av_free(data);
> }
> @@ -981,14 +979,6 @@ static int cbs_clone_unit_content(CodedBitstreamContext *ctx,
> return AVERROR(ENOSYS);
>
> switch (desc->content_type) {
> - case CBS_CONTENT_TYPE_POD:
> - ref = av_buffer_alloc(desc->content_size);
> - if (!ref)
> - return AVERROR(ENOMEM);
> - memcpy(ref->data, unit->content, desc->content_size);
> - err = 0;
> - break;
> -
> case CBS_CONTENT_TYPE_INTERNAL_REFS:
> err = cbs_clone_internal_refs_unit_content(&ref, unit, desc);
> break;
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index 5ccba3c901..045df91744 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -31,9 +31,7 @@
>
>
> enum CBSContentType {
> - // Unit content is a simple structure.
> - CBS_CONTENT_TYPE_POD,
> - // Unit content contains some references to other structures, but all
> + // Unit content may contain some references to other structures, but all
> // managed via buffer reference counting. The descriptor defines the
> // structure offsets of every buffer reference.
> CBS_CONTENT_TYPE_INTERNAL_REFS,
> @@ -78,9 +76,12 @@ typedef const struct CodedBitstreamUnitTypeDescriptor {
> size_t content_size;
>
> union {
> + // This union's state is determined by content_type:
> + // ref for CBS_CONTENT_TYPE_INTERNAL_REFS,
> + // complex for CBS_CONTENT_TYPE_COMPLEX.
> struct {
> - // Number of entries in the ref_offsets array. Only nonzero
> - // if the content_type is CBS_CONTENT_TYPE_INTERNAL_REFS.
> + // Number of entries in the ref_offsets array.
> + // May be zero, then the structure is POD-like.
> int nb_offsets;
> // The structure must contain two adjacent elements:
> // type *field;
> @@ -191,18 +192,20 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
> #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
>
> #define TYPE_LIST(...) { __VA_ARGS__ }
> -#define CBS_UNIT_TYPE_POD(type, structure) { \
> +#define CBS_UNIT_TYPE_POD(type_, structure) { \
> .nb_unit_types = 1, \
> - .unit_type.list = { type }, \
> - .content_type = CBS_CONTENT_TYPE_POD, \
> + .unit_type.list = { type_ }, \
> + .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
> .content_size = sizeof(structure), \
> + .type.ref = { .nb_offsets = 0 }, \
> }
> #define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
> .nb_unit_types = CBS_UNIT_TYPE_RANGE, \
> .unit_type.range.start = range_start, \
> .unit_type.range.end = range_end, \
> - .content_type = CBS_CONTENT_TYPE_POD, \
> + .content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
> .content_size = sizeof(structure), \
> + .type.ref = { .nb_offsets = 0 }, \
> }
>
> #define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
Will apply this patchset tonight unless there are objections.
- Andreas
_______________________________________________
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".
prev parent reply other threads:[~2022-10-21 22:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 15:03 Andreas Rheinhardt
2022-10-19 15:05 ` [FFmpeg-devel] [PATCH 2/2] avocdec/cbs_internal: Rename CBS_MAX_UNIT_TYPES->CBS_MAX_LIST_UNIT_TYPES Andreas Rheinhardt
2022-10-21 22:17 ` Andreas Rheinhardt [this message]
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=AS8P250MB07447D7529CC514D70EA7DB58F2D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/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