* [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
@ 2022-03-14 11:56 Paul B Mahol
2022-03-14 11:56 ` [FFmpeg-devel] [PATCH 2/2] avformat/nullenc: use null encoders instead Paul B Mahol
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Paul B Mahol @ 2022-03-14 11:56 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavcodec/Makefile | 2 ++
libavcodec/allcodecs.c | 2 ++
libavcodec/codec_desc.c | 14 ++++++++++
libavcodec/codec_id.h | 2 ++
libavcodec/nullenc.c | 61 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 81 insertions(+)
create mode 100644 libavcodec/nullenc.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cd929da8e6..8554b5ee7d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -542,6 +542,8 @@ OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
+OBJS-$(CONFIG_NULL_AUDIO_ENCODER) += nullenc.o
+OBJS-$(CONFIG_NULL_VIDEO_ENCODER) += nullenc.o
OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o opus_rc.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 628d27fd75..a30920bfe2 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -487,6 +487,8 @@ extern const AVCodec ff_mpc8_decoder;
extern const AVCodec ff_msnsiren_decoder;
extern const AVCodec ff_nellymoser_encoder;
extern const AVCodec ff_nellymoser_decoder;
+extern const AVCodec ff_null_audio_encoder;
+extern const AVCodec ff_null_video_encoder;
extern const AVCodec ff_on2avc_decoder;
extern const AVCodec ff_opus_encoder;
extern const AVCodec ff_opus_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 81f3b3c640..7d6bfd352c 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3516,6 +3516,20 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"),
.props = AV_CODEC_PROP_LOSSLESS,
},
+ {
+ .id = AV_CODEC_ID_AUDIO_NULL,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "null_audio",
+ .long_name = NULL_IF_CONFIG_SMALL("Audio NULL"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_VIDEO_NULL,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "null_video",
+ .long_name = NULL_IF_CONFIG_SMALL("Video NULL"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
};
static int descriptor_compare(const void *key, const void *member)
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 3ffb9bd22e..4822dc7685 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -571,6 +571,8 @@ 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
+ AV_CODEC_ID_AUDIO_NULL = 0x21002, ///< Null audio codec
+ AV_CODEC_ID_VIDEO_NULL = 0x21003, ///< Null video codec
};
/**
diff --git a/libavcodec/nullenc.c b/libavcodec/nullenc.c
new file mode 100644
index 0000000000..8d3553ed33
--- /dev/null
+++ b/libavcodec/nullenc.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2022 The FFmpeg Project
+ *
+ * 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 "libavutil/internal.h"
+#include "libavutil/frame.h"
+#include "libavutil/buffer.h"
+
+#include "avcodec.h"
+#include "internal.h"
+#include "encode.h"
+
+static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
+{
+ int ret;
+
+ pkt->pts = frame->pts;
+ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
+ pkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
+ return ret;
+ *got_packet = 1;
+ return 0;
+}
+
+const AVCodec ff_null_video_encoder = {
+ .name = "null_video",
+ .long_name = NULL_IF_CONFIG_SMALL("Video NULL encoder"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_VIDEO_NULL,
+ .encode2 = null_encoder,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+};
+
+const AVCodec ff_null_audio_encoder = {
+ .name = "null_audio",
+ .long_name = NULL_IF_CONFIG_SMALL("Audio NULL encoder"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_AUDIO_NULL,
+ .encode2 = null_encoder,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+ .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
+};
--
2.33.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avformat/nullenc: use null encoders instead
2022-03-14 11:56 [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders Paul B Mahol
@ 2022-03-14 11:56 ` Paul B Mahol
2022-03-14 12:12 ` [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders James Almer
2022-03-15 8:47 ` Anton Khirnov
2 siblings, 0 replies; 8+ messages in thread
From: Paul B Mahol @ 2022-03-14 11:56 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavformat/nullenc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/nullenc.c b/libavformat/nullenc.c
index d4769d5920..a83ed72039 100644
--- a/libavformat/nullenc.c
+++ b/libavformat/nullenc.c
@@ -30,8 +30,8 @@ static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
const AVOutputFormat ff_null_muxer = {
.name = "null",
.long_name = NULL_IF_CONFIG_SMALL("raw null video"),
- .audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
- .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME,
+ .audio_codec = AV_CODEC_ID_AUDIO_NULL,
+ .video_codec = AV_CODEC_ID_VIDEO_NULL,
.write_packet = null_write_packet,
.flags = AVFMT_VARIABLE_FPS | AVFMT_NOFILE | AVFMT_NOTIMESTAMPS,
.interleave_packet = ff_interleave_packet_passthrough,
--
2.33.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-14 11:56 [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders Paul B Mahol
2022-03-14 11:56 ` [FFmpeg-devel] [PATCH 2/2] avformat/nullenc: use null encoders instead Paul B Mahol
@ 2022-03-14 12:12 ` James Almer
2022-03-14 12:17 ` Paul B Mahol
2022-03-15 8:47 ` Anton Khirnov
2 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2022-03-14 12:12 UTC (permalink / raw)
To: ffmpeg-devel
On 3/14/2022 8:56 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> libavcodec/Makefile | 2 ++
> libavcodec/allcodecs.c | 2 ++
> libavcodec/codec_desc.c | 14 ++++++++++
> libavcodec/codec_id.h | 2 ++
> libavcodec/nullenc.c | 61 +++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 81 insertions(+)
> create mode 100644 libavcodec/nullenc.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index cd929da8e6..8554b5ee7d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -542,6 +542,8 @@ OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
> OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
> OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
> OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
> +OBJS-$(CONFIG_NULL_AUDIO_ENCODER) += nullenc.o
> +OBJS-$(CONFIG_NULL_VIDEO_ENCODER) += nullenc.o
> OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
> OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
> OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o opus_rc.o \
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 628d27fd75..a30920bfe2 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -487,6 +487,8 @@ extern const AVCodec ff_mpc8_decoder;
> extern const AVCodec ff_msnsiren_decoder;
> extern const AVCodec ff_nellymoser_encoder;
> extern const AVCodec ff_nellymoser_decoder;
> +extern const AVCodec ff_null_audio_encoder;
> +extern const AVCodec ff_null_video_encoder;
> extern const AVCodec ff_on2avc_decoder;
> extern const AVCodec ff_opus_encoder;
> extern const AVCodec ff_opus_decoder;
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 81f3b3c640..7d6bfd352c 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -3516,6 +3516,20 @@ static const AVCodecDescriptor codec_descriptors[] = {
> .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"),
> .props = AV_CODEC_PROP_LOSSLESS,
> },
> + {
> + .id = AV_CODEC_ID_AUDIO_NULL,
> + .type = AVMEDIA_TYPE_AUDIO,
> + .name = "null_audio",
> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL"),
> + .props = AV_CODEC_PROP_LOSSY,
> + },
> + {
> + .id = AV_CODEC_ID_VIDEO_NULL,
> + .type = AVMEDIA_TYPE_VIDEO,
> + .name = "null_video",
> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL"),
> + .props = AV_CODEC_PROP_LOSSY,
Also AV_CODEC_PROP_INTRA_ONLY on both.
> + },
> };
>
> static int descriptor_compare(const void *key, const void *member)
> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> index 3ffb9bd22e..4822dc7685 100644
> --- a/libavcodec/codec_id.h
> +++ b/libavcodec/codec_id.h
> @@ -571,6 +571,8 @@ 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
> + AV_CODEC_ID_AUDIO_NULL = 0x21002, ///< Null audio codec
> + AV_CODEC_ID_VIDEO_NULL = 0x21003, ///< Null video codec
> };
>
> /**
> diff --git a/libavcodec/nullenc.c b/libavcodec/nullenc.c
> new file mode 100644
> index 0000000000..8d3553ed33
> --- /dev/null
> +++ b/libavcodec/nullenc.c
> @@ -0,0 +1,61 @@
> +/*
> + * Copyright (c) 2022 The FFmpeg Project
> + *
> + * 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 "libavutil/internal.h"
> +#include "libavutil/frame.h"
> +#include "libavutil/buffer.h"
> +
> +#include "avcodec.h"
> +#include "internal.h"
> +#include "encode.h"
> +
> +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
> + const AVFrame *frame, int *got_packet)
> +{
> + int ret;
> +
> + pkt->pts = frame->pts;
> + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
> + pkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
> + pkt->flags |= AV_PKT_FLAG_KEY;
> + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
To avoid bogus statistics, could you instead allocate a blank packet of
size av_samples_get_buffer_size()?
Also, use ff_get_encode_buffer() and set the DR1 codec cap.
> + return ret;
> + *got_packet = 1;
> + return 0;
> +}
> +
> +const AVCodec ff_null_video_encoder = {
> + .name = "null_video",
> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL encoder"),
> + .type = AVMEDIA_TYPE_VIDEO,
> + .id = AV_CODEC_ID_VIDEO_NULL,
> + .encode2 = null_encoder,
> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> +};
> +
> +const AVCodec ff_null_audio_encoder = {
> + .name = "null_audio",
> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL encoder"),
> + .type = AVMEDIA_TYPE_AUDIO,
> + .id = AV_CODEC_ID_AUDIO_NULL,
> + .encode2 = null_encoder,
> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
What's the benefit from this? If the idea is to get rid of
wrappedavframe, then you also need to fix vapoursync, decklink, kmsgrab,
opengl, xv, and yuv4mpeg.
I'd rather not add more fake codec ids for this purpose unless it's a
thorough solution.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-14 12:17 ` Paul B Mahol
@ 2022-03-14 12:17 ` James Almer
2022-03-14 12:31 ` Paul B Mahol
0 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2022-03-14 12:17 UTC (permalink / raw)
To: ffmpeg-devel
On 3/14/2022 9:17 AM, Paul B Mahol wrote:
> On Mon, Mar 14, 2022 at 1:12 PM James Almer <jamrial@gmail.com> wrote:
>
>>
>>
>> On 3/14/2022 8:56 AM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>> ---
>>> libavcodec/Makefile | 2 ++
>>> libavcodec/allcodecs.c | 2 ++
>>> libavcodec/codec_desc.c | 14 ++++++++++
>>> libavcodec/codec_id.h | 2 ++
>>> libavcodec/nullenc.c | 61 +++++++++++++++++++++++++++++++++++++++++
>>> 5 files changed, 81 insertions(+)
>>> create mode 100644 libavcodec/nullenc.c
>>>
>>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>>> index cd929da8e6..8554b5ee7d 100644
>>> --- a/libavcodec/Makefile
>>> +++ b/libavcodec/Makefile
>>> @@ -542,6 +542,8 @@ OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
>>> OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
>>> OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
>>> OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
>>> +OBJS-$(CONFIG_NULL_AUDIO_ENCODER) += nullenc.o
>>> +OBJS-$(CONFIG_NULL_VIDEO_ENCODER) += nullenc.o
>>> OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
>>> OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
>>> OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o
>> opus_rc.o \
>>> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
>>> index 628d27fd75..a30920bfe2 100644
>>> --- a/libavcodec/allcodecs.c
>>> +++ b/libavcodec/allcodecs.c
>>> @@ -487,6 +487,8 @@ extern const AVCodec ff_mpc8_decoder;
>>> extern const AVCodec ff_msnsiren_decoder;
>>> extern const AVCodec ff_nellymoser_encoder;
>>> extern const AVCodec ff_nellymoser_decoder;
>>> +extern const AVCodec ff_null_audio_encoder;
>>> +extern const AVCodec ff_null_video_encoder;
>>> extern const AVCodec ff_on2avc_decoder;
>>> extern const AVCodec ff_opus_encoder;
>>> extern const AVCodec ff_opus_decoder;
>>> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
>>> index 81f3b3c640..7d6bfd352c 100644
>>> --- a/libavcodec/codec_desc.c
>>> +++ b/libavcodec/codec_desc.c
>>> @@ -3516,6 +3516,20 @@ static const AVCodecDescriptor
>> codec_descriptors[] = {
>>> .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket
>> passthrough"),
>>> .props = AV_CODEC_PROP_LOSSLESS,
>>> },
>>> + {
>>> + .id = AV_CODEC_ID_AUDIO_NULL,
>>> + .type = AVMEDIA_TYPE_AUDIO,
>>> + .name = "null_audio",
>>> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL"),
>>> + .props = AV_CODEC_PROP_LOSSY,
>>> + },
>>> + {
>>> + .id = AV_CODEC_ID_VIDEO_NULL,
>>> + .type = AVMEDIA_TYPE_VIDEO,
>>> + .name = "null_video",
>>> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL"),
>>> + .props = AV_CODEC_PROP_LOSSY,
>>
>> Also AV_CODEC_PROP_INTRA_ONLY on both.
>>
>>> + },
>>> };
>>>
>>> static int descriptor_compare(const void *key, const void *member)
>>> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
>>> index 3ffb9bd22e..4822dc7685 100644
>>> --- a/libavcodec/codec_id.h
>>> +++ b/libavcodec/codec_id.h
>>> @@ -571,6 +571,8 @@ 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
>>> + AV_CODEC_ID_AUDIO_NULL = 0x21002, ///< Null audio codec
>>> + AV_CODEC_ID_VIDEO_NULL = 0x21003, ///< Null video codec
>>> };
>>>
>>> /**
>>> diff --git a/libavcodec/nullenc.c b/libavcodec/nullenc.c
>>> new file mode 100644
>>> index 0000000000..8d3553ed33
>>> --- /dev/null
>>> +++ b/libavcodec/nullenc.c
>>> @@ -0,0 +1,61 @@
>>> +/*
>>> + * Copyright (c) 2022 The FFmpeg Project
>>> + *
>>> + * 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 "libavutil/internal.h"
>>> +#include "libavutil/frame.h"
>>> +#include "libavutil/buffer.h"
>>> +
>>> +#include "avcodec.h"
>>> +#include "internal.h"
>>> +#include "encode.h"
>>> +
>>> +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
>>> + const AVFrame *frame, int *got_packet)
>>> +{
>>> + int ret;
>>> +
>>> + pkt->pts = frame->pts;
>>> + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
>>> + pkt->duration = ff_samples_to_time_base(avctx,
>> frame->nb_samples);
>>> + pkt->flags |= AV_PKT_FLAG_KEY;
>>> + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
>>
>> To avoid bogus statistics, could you instead allocate a blank packet of
>> size av_samples_get_buffer_size()?
>> Also, use ff_get_encode_buffer() and set the DR1 codec cap.
>>
>>> + return ret;
>>> + *got_packet = 1;
>>> + return 0;
>>> +}
>>> +
>>> +const AVCodec ff_null_video_encoder = {
>>> + .name = "null_video",
>>> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL encoder"),
>>> + .type = AVMEDIA_TYPE_VIDEO,
>>> + .id = AV_CODEC_ID_VIDEO_NULL,
>>> + .encode2 = null_encoder,
>>> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
>>> +};
>>> +
>>> +const AVCodec ff_null_audio_encoder = {
>>> + .name = "null_audio",
>>> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL encoder"),
>>> + .type = AVMEDIA_TYPE_AUDIO,
>>> + .id = AV_CODEC_ID_AUDIO_NULL,
>>> + .encode2 = null_encoder,
>>> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
>>> + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
>>
>> What's the benefit from this? If the idea is to get rid of
>> wrappedavframe, then you also need to fix vapoursync, decklink, kmsgrab,
>> opengl, xv, and yuv4mpeg.
>>
>> I'd rather not add more fake codec ids for this purpose unless it's a
>> thorough solution.
>>
>
> See null muxer patch. null muxer does not need pcm codecs or wrapped video
> codec.
I saw it, hence my comment above. wrappedavframe is still used by
several components, so this is adding two new pseudo codec ids but not
resolving the problem wrappedavframes represents.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-14 12:12 ` [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders James Almer
@ 2022-03-14 12:17 ` Paul B Mahol
2022-03-14 12:17 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Paul B Mahol @ 2022-03-14 12:17 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Mar 14, 2022 at 1:12 PM James Almer <jamrial@gmail.com> wrote:
>
>
> On 3/14/2022 8:56 AM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> > libavcodec/Makefile | 2 ++
> > libavcodec/allcodecs.c | 2 ++
> > libavcodec/codec_desc.c | 14 ++++++++++
> > libavcodec/codec_id.h | 2 ++
> > libavcodec/nullenc.c | 61 +++++++++++++++++++++++++++++++++++++++++
> > 5 files changed, 81 insertions(+)
> > create mode 100644 libavcodec/nullenc.c
> >
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index cd929da8e6..8554b5ee7d 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -542,6 +542,8 @@ OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
> > OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
> > OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
> > OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
> > +OBJS-$(CONFIG_NULL_AUDIO_ENCODER) += nullenc.o
> > +OBJS-$(CONFIG_NULL_VIDEO_ENCODER) += nullenc.o
> > OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
> > OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
> > OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o
> opus_rc.o \
> > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> > index 628d27fd75..a30920bfe2 100644
> > --- a/libavcodec/allcodecs.c
> > +++ b/libavcodec/allcodecs.c
> > @@ -487,6 +487,8 @@ extern const AVCodec ff_mpc8_decoder;
> > extern const AVCodec ff_msnsiren_decoder;
> > extern const AVCodec ff_nellymoser_encoder;
> > extern const AVCodec ff_nellymoser_decoder;
> > +extern const AVCodec ff_null_audio_encoder;
> > +extern const AVCodec ff_null_video_encoder;
> > extern const AVCodec ff_on2avc_decoder;
> > extern const AVCodec ff_opus_encoder;
> > extern const AVCodec ff_opus_decoder;
> > diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> > index 81f3b3c640..7d6bfd352c 100644
> > --- a/libavcodec/codec_desc.c
> > +++ b/libavcodec/codec_desc.c
> > @@ -3516,6 +3516,20 @@ static const AVCodecDescriptor
> codec_descriptors[] = {
> > .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket
> passthrough"),
> > .props = AV_CODEC_PROP_LOSSLESS,
> > },
> > + {
> > + .id = AV_CODEC_ID_AUDIO_NULL,
> > + .type = AVMEDIA_TYPE_AUDIO,
> > + .name = "null_audio",
> > + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL"),
> > + .props = AV_CODEC_PROP_LOSSY,
> > + },
> > + {
> > + .id = AV_CODEC_ID_VIDEO_NULL,
> > + .type = AVMEDIA_TYPE_VIDEO,
> > + .name = "null_video",
> > + .long_name = NULL_IF_CONFIG_SMALL("Video NULL"),
> > + .props = AV_CODEC_PROP_LOSSY,
>
> Also AV_CODEC_PROP_INTRA_ONLY on both.
>
> > + },
> > };
> >
> > static int descriptor_compare(const void *key, const void *member)
> > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> > index 3ffb9bd22e..4822dc7685 100644
> > --- a/libavcodec/codec_id.h
> > +++ b/libavcodec/codec_id.h
> > @@ -571,6 +571,8 @@ 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
> > + AV_CODEC_ID_AUDIO_NULL = 0x21002, ///< Null audio codec
> > + AV_CODEC_ID_VIDEO_NULL = 0x21003, ///< Null video codec
> > };
> >
> > /**
> > diff --git a/libavcodec/nullenc.c b/libavcodec/nullenc.c
> > new file mode 100644
> > index 0000000000..8d3553ed33
> > --- /dev/null
> > +++ b/libavcodec/nullenc.c
> > @@ -0,0 +1,61 @@
> > +/*
> > + * Copyright (c) 2022 The FFmpeg Project
> > + *
> > + * 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 "libavutil/internal.h"
> > +#include "libavutil/frame.h"
> > +#include "libavutil/buffer.h"
> > +
> > +#include "avcodec.h"
> > +#include "internal.h"
> > +#include "encode.h"
> > +
> > +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
> > + const AVFrame *frame, int *got_packet)
> > +{
> > + int ret;
> > +
> > + pkt->pts = frame->pts;
> > + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
> > + pkt->duration = ff_samples_to_time_base(avctx,
> frame->nb_samples);
> > + pkt->flags |= AV_PKT_FLAG_KEY;
> > + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
>
> To avoid bogus statistics, could you instead allocate a blank packet of
> size av_samples_get_buffer_size()?
> Also, use ff_get_encode_buffer() and set the DR1 codec cap.
>
> > + return ret;
> > + *got_packet = 1;
> > + return 0;
> > +}
> > +
> > +const AVCodec ff_null_video_encoder = {
> > + .name = "null_video",
> > + .long_name = NULL_IF_CONFIG_SMALL("Video NULL encoder"),
> > + .type = AVMEDIA_TYPE_VIDEO,
> > + .id = AV_CODEC_ID_VIDEO_NULL,
> > + .encode2 = null_encoder,
> > + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> > +};
> > +
> > +const AVCodec ff_null_audio_encoder = {
> > + .name = "null_audio",
> > + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL encoder"),
> > + .type = AVMEDIA_TYPE_AUDIO,
> > + .id = AV_CODEC_ID_AUDIO_NULL,
> > + .encode2 = null_encoder,
> > + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> > + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
>
> What's the benefit from this? If the idea is to get rid of
> wrappedavframe, then you also need to fix vapoursync, decklink, kmsgrab,
> opengl, xv, and yuv4mpeg.
>
> I'd rather not add more fake codec ids for this purpose unless it's a
> thorough solution.
>
See null muxer patch. null muxer does not need pcm codecs or wrapped video
codec.
> _______________________________________________
> 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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-14 12:17 ` James Almer
@ 2022-03-14 12:31 ` Paul B Mahol
0 siblings, 0 replies; 8+ messages in thread
From: Paul B Mahol @ 2022-03-14 12:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Mar 14, 2022 at 1:17 PM James Almer <jamrial@gmail.com> wrote:
>
>
> On 3/14/2022 9:17 AM, Paul B Mahol wrote:
> > On Mon, Mar 14, 2022 at 1:12 PM James Almer <jamrial@gmail.com> wrote:
> >
> >>
> >>
> >> On 3/14/2022 8:56 AM, Paul B Mahol wrote:
> >>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> >>> ---
> >>> libavcodec/Makefile | 2 ++
> >>> libavcodec/allcodecs.c | 2 ++
> >>> libavcodec/codec_desc.c | 14 ++++++++++
> >>> libavcodec/codec_id.h | 2 ++
> >>> libavcodec/nullenc.c | 61
> +++++++++++++++++++++++++++++++++++++++++
> >>> 5 files changed, 81 insertions(+)
> >>> create mode 100644 libavcodec/nullenc.c
> >>>
> >>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> >>> index cd929da8e6..8554b5ee7d 100644
> >>> --- a/libavcodec/Makefile
> >>> +++ b/libavcodec/Makefile
> >>> @@ -542,6 +542,8 @@ OBJS-$(CONFIG_MXPEG_DECODER) +=
> mxpegdec.o
> >>> OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o
> nellymoser.o
> >>> OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o
> nellymoser.o
> >>> OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
> >>> +OBJS-$(CONFIG_NULL_AUDIO_ENCODER) += nullenc.o
> >>> +OBJS-$(CONFIG_NULL_VIDEO_ENCODER) += nullenc.o
> >>> OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
> >>> OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
> >>> OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o
> opus_celt.o
> >> opus_rc.o \
> >>> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> >>> index 628d27fd75..a30920bfe2 100644
> >>> --- a/libavcodec/allcodecs.c
> >>> +++ b/libavcodec/allcodecs.c
> >>> @@ -487,6 +487,8 @@ extern const AVCodec ff_mpc8_decoder;
> >>> extern const AVCodec ff_msnsiren_decoder;
> >>> extern const AVCodec ff_nellymoser_encoder;
> >>> extern const AVCodec ff_nellymoser_decoder;
> >>> +extern const AVCodec ff_null_audio_encoder;
> >>> +extern const AVCodec ff_null_video_encoder;
> >>> extern const AVCodec ff_on2avc_decoder;
> >>> extern const AVCodec ff_opus_encoder;
> >>> extern const AVCodec ff_opus_decoder;
> >>> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> >>> index 81f3b3c640..7d6bfd352c 100644
> >>> --- a/libavcodec/codec_desc.c
> >>> +++ b/libavcodec/codec_desc.c
> >>> @@ -3516,6 +3516,20 @@ static const AVCodecDescriptor
> >> codec_descriptors[] = {
> >>> .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket
> >> passthrough"),
> >>> .props = AV_CODEC_PROP_LOSSLESS,
> >>> },
> >>> + {
> >>> + .id = AV_CODEC_ID_AUDIO_NULL,
> >>> + .type = AVMEDIA_TYPE_AUDIO,
> >>> + .name = "null_audio",
> >>> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL"),
> >>> + .props = AV_CODEC_PROP_LOSSY,
> >>> + },
> >>> + {
> >>> + .id = AV_CODEC_ID_VIDEO_NULL,
> >>> + .type = AVMEDIA_TYPE_VIDEO,
> >>> + .name = "null_video",
> >>> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL"),
> >>> + .props = AV_CODEC_PROP_LOSSY,
> >>
> >> Also AV_CODEC_PROP_INTRA_ONLY on both.
> >>
> >>> + },
> >>> };
> >>>
> >>> static int descriptor_compare(const void *key, const void *member)
> >>> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> >>> index 3ffb9bd22e..4822dc7685 100644
> >>> --- a/libavcodec/codec_id.h
> >>> +++ b/libavcodec/codec_id.h
> >>> @@ -571,6 +571,8 @@ 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
> >>> + AV_CODEC_ID_AUDIO_NULL = 0x21002, ///< Null audio codec
> >>> + AV_CODEC_ID_VIDEO_NULL = 0x21003, ///< Null video codec
> >>> };
> >>>
> >>> /**
> >>> diff --git a/libavcodec/nullenc.c b/libavcodec/nullenc.c
> >>> new file mode 100644
> >>> index 0000000000..8d3553ed33
> >>> --- /dev/null
> >>> +++ b/libavcodec/nullenc.c
> >>> @@ -0,0 +1,61 @@
> >>> +/*
> >>> + * Copyright (c) 2022 The FFmpeg Project
> >>> + *
> >>> + * 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 "libavutil/internal.h"
> >>> +#include "libavutil/frame.h"
> >>> +#include "libavutil/buffer.h"
> >>> +
> >>> +#include "avcodec.h"
> >>> +#include "internal.h"
> >>> +#include "encode.h"
> >>> +
> >>> +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
> >>> + const AVFrame *frame, int *got_packet)
> >>> +{
> >>> + int ret;
> >>> +
> >>> + pkt->pts = frame->pts;
> >>> + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
> >>> + pkt->duration = ff_samples_to_time_base(avctx,
> >> frame->nb_samples);
> >>> + pkt->flags |= AV_PKT_FLAG_KEY;
> >>> + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
> >>
> >> To avoid bogus statistics, could you instead allocate a blank packet of
> >> size av_samples_get_buffer_size()?
> >> Also, use ff_get_encode_buffer() and set the DR1 codec cap.
> >>
> >>> + return ret;
> >>> + *got_packet = 1;
> >>> + return 0;
> >>> +}
> >>> +
> >>> +const AVCodec ff_null_video_encoder = {
> >>> + .name = "null_video",
> >>> + .long_name = NULL_IF_CONFIG_SMALL("Video NULL encoder"),
> >>> + .type = AVMEDIA_TYPE_VIDEO,
> >>> + .id = AV_CODEC_ID_VIDEO_NULL,
> >>> + .encode2 = null_encoder,
> >>> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> >>> +};
> >>> +
> >>> +const AVCodec ff_null_audio_encoder = {
> >>> + .name = "null_audio",
> >>> + .long_name = NULL_IF_CONFIG_SMALL("Audio NULL encoder"),
> >>> + .type = AVMEDIA_TYPE_AUDIO,
> >>> + .id = AV_CODEC_ID_AUDIO_NULL,
> >>> + .encode2 = null_encoder,
> >>> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> >>> + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
> >>
> >> What's the benefit from this? If the idea is to get rid of
> >> wrappedavframe, then you also need to fix vapoursync, decklink, kmsgrab,
> >> opengl, xv, and yuv4mpeg.
> >>
> >> I'd rather not add more fake codec ids for this purpose unless it's a
> >> thorough solution.
> >>
> >
> > See null muxer patch. null muxer does not need pcm codecs or wrapped
> video
> > codec.
>
> I saw it, hence my comment above. wrappedavframe is still used by
> several components, so this is adding two new pseudo codec ids but not
> resolving the problem wrappedavframes represents.
>
Not interested in fixing wrapped mess. I added encoder for null muxer.
So that audio decoding/filtering can be benchmarked properly.
_______________________________________________
> 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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-14 11:56 [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders Paul B Mahol
2022-03-14 11:56 ` [FFmpeg-devel] [PATCH 2/2] avformat/nullenc: use null encoders instead Paul B Mahol
2022-03-14 12:12 ` [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders James Almer
@ 2022-03-15 8:47 ` Anton Khirnov
2022-03-15 8:53 ` Paul B Mahol
2 siblings, 1 reply; 8+ messages in thread
From: Anton Khirnov @ 2022-03-15 8:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Paul B Mahol (2022-03-14 12:56:01)
> +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
> + const AVFrame *frame, int *got_packet)
> +{
> + int ret;
> +
> + pkt->pts = frame->pts;
> + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
> + pkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
> + pkt->flags |= AV_PKT_FLAG_KEY;
> + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
> + return ret;
> + *got_packet = 1;
Why return packets at all? Wouldn't it be simpler to just never return
any data?
--
Anton Khirnov
_______________________________________________
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders
2022-03-15 8:47 ` Anton Khirnov
@ 2022-03-15 8:53 ` Paul B Mahol
0 siblings, 0 replies; 8+ messages in thread
From: Paul B Mahol @ 2022-03-15 8:53 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, Mar 15, 2022 at 9:47 AM Anton Khirnov <anton@khirnov.net> wrote:
> Quoting Paul B Mahol (2022-03-14 12:56:01)
> > +static int null_encoder(AVCodecContext *avctx, AVPacket *pkt,
> > + const AVFrame *frame, int *got_packet)
> > +{
> > + int ret;
> > +
> > + pkt->pts = frame->pts;
> > + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO)
> > + pkt->duration = ff_samples_to_time_base(avctx,
> frame->nb_samples);
> > + pkt->flags |= AV_PKT_FLAG_KEY;
> > + if ((ret = ff_alloc_packet(avctx, pkt, 1)) < 0)
> > + return ret;
> > + *got_packet = 1;
>
> Why return packets at all? Wouldn't it be simpler to just never return
> any data?
>
But than there is no progress report at all.
>
> --
> Anton Khirnov
> _______________________________________________
> 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".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-03-15 8:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 11:56 [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders Paul B Mahol
2022-03-14 11:56 ` [FFmpeg-devel] [PATCH 2/2] avformat/nullenc: use null encoders instead Paul B Mahol
2022-03-14 12:12 ` [FFmpeg-devel] [PATCH 1/2] avcodec: add null encoders James Almer
2022-03-14 12:17 ` Paul B Mahol
2022-03-14 12:17 ` James Almer
2022-03-14 12:31 ` Paul B Mahol
2022-03-15 8:47 ` Anton Khirnov
2022-03-15 8:53 ` Paul B Mahol
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