From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lavc: add null codecs
Date: Fri, 27 Jan 2023 19:48:25 +0100
Message-ID: <CAPYw7P6oqr1QwN94qkaeJMaxwifKebiE0xq=7B_aYzzU5xt1og@mail.gmail.com> (raw)
In-Reply-To: <20230127184415.11478-1-anton@khirnov.net>
On 1/27/23, Anton Khirnov <anton@khirnov.net> wrote:
> They discard all input without ever returning any output. Useful for
> development.
> ---
> libavcodec/Makefile | 4 ++
> libavcodec/allcodecs.c | 6 +++
> libavcodec/codec_desc.c | 12 ++++++
> libavcodec/codec_id.h | 10 +++++
> libavcodec/null.c | 96 +++++++++++++++++++++++++++++++++++++++++
> libavcodec/version.h | 2 +-
> 6 files changed, 129 insertions(+), 1 deletion(-)
> create mode 100644 libavcodec/null.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 2d9710923d..098ab18353 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -219,6 +219,8 @@ OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o
> celp_filters.o \
> acelp_pitch_delay.o
> OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpegenc_common.o
> OBJS-$(CONFIG_ANM_DECODER) += anm.o
> +OBJS-$(CONFIG_ANULL_DECODER) += null.o
> +OBJS-$(CONFIG_ANULL_ENCODER) += null.o
> OBJS-$(CONFIG_ANSI_DECODER) += ansi.o cga_data.o
> OBJS-$(CONFIG_APAC_DECODER) += apac.o
> OBJS-$(CONFIG_APE_DECODER) += apedec.o
> @@ -746,6 +748,8 @@ OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
> OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdaudio.o
> OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdvideo.o
> OBJS-$(CONFIG_VMNC_DECODER) += vmnc.o
> +OBJS-$(CONFIG_VNULL_DECODER) += null.o
> +OBJS-$(CONFIG_VNULL_ENCODER) += null.o
> OBJS-$(CONFIG_VORBIS_DECODER) += vorbisdec.o vorbisdsp.o vorbis.o
> \
> vorbis_data.o
> OBJS-$(CONFIG_VORBIS_ENCODER) += vorbisenc.o vorbis.o \
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index f728c6c82e..7452002f24 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -882,6 +882,12 @@ extern const FFCodec ff_vp9_qsv_decoder;
> extern const FFCodec ff_vp9_vaapi_encoder;
> extern const FFCodec ff_vp9_qsv_encoder;
>
> +// null codecs
> +extern const FFCodec ff_vnull_decoder;
> +extern const FFCodec ff_vnull_encoder;
> +extern const FFCodec ff_anull_decoder;
> +extern const FFCodec ff_anull_encoder;
> +
> // The iterate API is not usable with ossfuzz due to the excessive size of
> binaries created
> #if CONFIG_OSSFUZZ
> const FFCodec * codec_list[] = {
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 2272232ed6..b3bec2f659 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1923,6 +1923,12 @@ static const AVCodecDescriptor codec_descriptors[] =
> {
> .long_name = NULL_IF_CONFIG_SMALL("ViewQuest VQC"),
> .props = AV_CODEC_PROP_LOSSY,
> },
> + {
> + .id = AV_CODEC_ID_VNULL,
> + .type = AVMEDIA_TYPE_VIDEO,
> + .name = "vnull",
> + .long_name = NULL_IF_CONFIG_SMALL("Null video codec"),
> + },
>
> /* various PCM "codecs" */
> {
> @@ -3339,6 +3345,12 @@ static const AVCodecDescriptor codec_descriptors[] =
> {
> .long_name = NULL_IF_CONFIG_SMALL("FTR Voice"),
> .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
> },
> + {
> + .id = AV_CODEC_ID_ANULL,
> + .type = AVMEDIA_TYPE_AUDIO,
> + .name = "anull",
> + .long_name = NULL_IF_CONFIG_SMALL("Null audio codec"),
> + },
>
> /* subtitle codecs */
> {
> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> index 5ec3fd4b30..c197e956b7 100644
> --- a/libavcodec/codec_id.h
> +++ b/libavcodec/codec_id.h
> @@ -320,6 +320,11 @@ enum AVCodecID {
> AV_CODEC_ID_WBMP,
> AV_CODEC_ID_MEDIA100,
> AV_CODEC_ID_VQC,
> + /**
> + * Dummy null video codec, useful mainly for development and
> debugging.
> + * Null encoder/decoder discard all input and never return any output.
> + */
> + AV_CODEC_ID_VNULL,
Cant you move those two to special ones like wrapped avframe?
With that one changed LGTM.
>
> /* various PCM "codecs" */
> AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the
> start of audio codecs
> @@ -534,6 +539,11 @@ enum AVCodecID {
> AV_CODEC_ID_MISC4,
> AV_CODEC_ID_APAC,
> AV_CODEC_ID_FTR,
> + /**
> + * Dummy null audio codec, useful mainly for development and
> debugging.
> + * Null encoder/decoder discard all input and never return any output.
> + */
> + AV_CODEC_ID_ANULL,
>
> /* subtitle codecs */
> AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing
> at the start of subtitle codecs.
> diff --git a/libavcodec/null.c b/libavcodec/null.c
> new file mode 100644
> index 0000000000..df75a077ae
> --- /dev/null
> +++ b/libavcodec/null.c
> @@ -0,0 +1,96 @@
> +/*
> + * Null codecs
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +#include "config_components.h"
> +
> +#include "codec_internal.h"
> +#include "decode.h"
> +#include "encode.h"
> +
> +#if CONFIG_VNULL_DECODER || CONFIG_ANULL_DECODER
> +static int null_decode(AVCodecContext *avctx, AVFrame *frame,
> + int *got_frame, AVPacket *avpkt)
> +{
> + *got_frame = 0;
> + return avpkt->size;
> +}
> +
> +#if CONFIG_VNULL_DECODER
> +const FFCodec ff_vnull_decoder = {
> + .p.name = "vnull",
> + CODEC_LONG_NAME("null video"),
> + .p.type = AVMEDIA_TYPE_VIDEO,
> + .p.id = AV_CODEC_ID_VNULL,
> + .p.capabilities = AV_CODEC_CAP_DR1,
> + FF_CODEC_DECODE_CB(null_decode),
> +};
> +#endif
> +
> +#if CONFIG_ANULL_DECODER
> +const FFCodec ff_anull_decoder = {
> + .p.name = "anull",
> + CODEC_LONG_NAME("null audio"),
> + .p.type = AVMEDIA_TYPE_AUDIO,
> + .p.id = AV_CODEC_ID_ANULL,
> + .p.capabilities = AV_CODEC_CAP_DR1,
> + FF_CODEC_DECODE_CB(null_decode),
> +};
> +#endif
> +
> +#endif
> +
> +#if CONFIG_VNULL_ENCODER || CONFIG_ANULL_ENCODER
> +static int null_encode(AVCodecContext *avctx, AVPacket *pkt,
> + const AVFrame *frame, int *got_packet)
> +{
> + *got_packet = 0;
> + return 0;
> +}
> +
> +#if CONFIG_VNULL_ENCODER
> +const FFCodec ff_vnull_encoder = {
> + .p.name = "vnull",
> + CODEC_LONG_NAME("null video"),
> + .p.type = AVMEDIA_TYPE_VIDEO,
> + .p.id = AV_CODEC_ID_VNULL,
> + FF_CODEC_ENCODE_CB(null_encode),
> +};
> +#endif
> +
> +#if CONFIG_ANULL_ENCODER
> +const FFCodec ff_anull_encoder = {
> + .p.name = "anull",
> + CODEC_LONG_NAME("null audio"),
> + .p.type = AVMEDIA_TYPE_AUDIO,
> + .p.id = AV_CODEC_ID_ANULL,
> + .p.capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
> + .p.sample_fmts = (const enum AVSampleFormat[]){
> + AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8P,
> + AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
> + AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P,
> + AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64P,
> + AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
> + AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
> + },
> + FF_CODEC_ENCODE_CB(null_encode),
> +};
> +#endif
> +
> +#endif
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index dfd3d5d7e5..7ac8d2b2fe 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,7 +29,7 @@
>
> #include "version_major.h"
>
> -#define LIBAVCODEC_VERSION_MINOR 57
> +#define LIBAVCODEC_VERSION_MINOR 58
> #define LIBAVCODEC_VERSION_MICRO 100
>
> #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> --
> 2.35.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".
>
_______________________________________________
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:[~2023-01-27 18:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 18:44 Anton Khirnov
2023-01-27 18:48 ` Paul B Mahol [this message]
2023-01-29 23:12 ` Paul B Mahol
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='CAPYw7P6oqr1QwN94qkaeJMaxwifKebiE0xq=7B_aYzzU5xt1og@mail.gmail.com' \
--to=onemda@gmail.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