From: "\"zhilizhao(赵志立)\"" <quinkblack@foxmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [Internet][PATCH 1/6] avcodec/cbs: add API to discard units by AVDiscard
Date: Mon, 29 May 2023 20:32:52 +0800
Message-ID: <tencent_A26E7D0AAE3E3869C1E9B5686AA202396B0A@qq.com> (raw)
In-Reply-To: <20dcc5d8-b920-426b-8f10-f534bebf6cf7@EX-SZ059.tencent.com>
Ping. Any comments on the idea?
> On May 18, 2023, at 05:23, Zhao Zhili <quinkblack@foxmail.com> wrote:
>
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> ---
> libavcodec/cbs.c | 21 +++++++++++++++++++++
> libavcodec/cbs.h | 17 +++++++++++++++++
> libavcodec/cbs_internal.h | 6 ++++++
> 3 files changed, 44 insertions(+)
>
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 504197e06d..cf5211249b 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -1026,3 +1026,24 @@ int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
> av_buffer_unref(&ref);
> return 0;
> }
> +
> +void ff_cbs_discard_units(CodedBitstreamContext *ctx,
> + CodedBitstreamFragment *frag,
> + enum AVDiscard skip,
> + int flags)
> +{
> + if (!ctx->codec->discarded_unit)
> + return;
> +
> + for (int i = frag->nb_units - 1; i >= 0; i--) {
> + if (ctx->codec->discarded_unit(ctx, &frag->units[i], skip)) {
> + // discard all units
> + if (!(flags & DISCARD_FLAG_KEEP_NON_VCL)) {
> + ff_cbs_fragment_free(frag);
> + return;
> + }
> +
> + ff_cbs_delete_unit(frag, i);
> + }
> + }
> +}
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index ee21623dac..b4131db5fe 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -26,6 +26,7 @@
>
> #include "codec_id.h"
> #include "codec_par.h"
> +#include "defs.h"
> #include "packet.h"
>
>
> @@ -432,5 +433,21 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
> int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
> CodedBitstreamUnit *unit);
>
> +enum CbsDiscardFlags {
> + DISCARD_FLAG_NONE = 0,
> +
> + /**
> + * keep non-vcl units even if the picture has been dropped.
> + */
> + DISCARD_FLAG_KEEP_NON_VCL = 0x01,
> +};
> +
> +/**
> + * Discard units accroding to 'skip'.
> + */
> +void ff_cbs_discard_units(CodedBitstreamContext *ctx,
> + CodedBitstreamFragment *frag,
> + enum AVDiscard skip,
> + int flags);
>
> #endif /* AVCODEC_CBS_H */
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index e585c77934..077954eee5 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -133,6 +133,12 @@ typedef struct CodedBitstreamType {
> CodedBitstreamUnit *unit,
> PutBitContext *pbc);
>
> + // Return 1 when the unit should be dropped according to 'skip',
> + // 0 otherwise.
> + int (*discarded_unit)(CodedBitstreamContext *ctx,
> + const CodedBitstreamUnit *unit,
> + enum AVDiscard skip);
> +
> // Read the data from all of frag->units and assemble it into
> // a bitstream for the whole fragment.
> int (*assemble_fragment)(CodedBitstreamContext *ctx,
> --
> 2.25.1
>
>
>
>
_______________________________________________
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 parent reply other threads:[~2023-05-29 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20dcc5d8-b920-426b-8f10-f534bebf6cf7@EX-SZ059.tencent.com>
2023-05-29 12:32 ` "zhilizhao(赵志立)" [this message]
2023-06-12 11:58 ` "zhilizhao(赵志立)"
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=tencent_A26E7D0AAE3E3869C1E9B5686AA202396B0A@qq.com \
--to=quinkblack@foxmail.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