lavc: add null codecs

They discard all input without ever returning any output. Useful for
development.
release/6.0
Anton Khirnov 2 years ago
parent 229f3259f8
commit e3a99041b8
  1. 4
      libavcodec/Makefile
  2. 6
      libavcodec/allcodecs.c
  3. 12
      libavcodec/codec_desc.c
  4. 10
      libavcodec/codec_id.h
  5. 97
      libavcodec/null.c

@ -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
@ -747,6 +749,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 \

@ -884,6 +884,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[] = {

@ -3625,6 +3625,18 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"),
.props = AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_VNULL,
.type = AVMEDIA_TYPE_VIDEO,
.name = "vnull",
.long_name = NULL_IF_CONFIG_SMALL("Null video codec"),
},
{
.id = AV_CODEC_ID_ANULL,
.type = AVMEDIA_TYPE_AUDIO,
.name = "anull",
.long_name = NULL_IF_CONFIG_SMALL("Null audio codec"),
},
};
static int descriptor_compare(const void *key, const void *member)

@ -590,6 +590,16 @@ enum AVCodecID {
* stream (only used by libavformat) */
AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
/**
* 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,
/**
* 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,
};
/**

@ -0,0 +1,97 @@
/*
* 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,
AV_SAMPLE_FMT_NONE,
},
FF_CODEC_ENCODE_CB(null_encode),
};
#endif
#endif
Loading…
Cancel
Save