From: Philip-Dylan Gleonec <philip-dylan.gleonec@savoirfairelinux.com> To: ffmpeg-devel@ffmpeg.org Cc: Philip-Dylan Gleonec <philip-dylan.gleonec@savoirfairelinux.com> Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec/libopusenc: reload packet loss at encode Date: Mon, 4 Jul 2022 16:13:39 +0200 Message-ID: <20220704141340.493931-2-philip-dylan.gleonec@savoirfairelinux.com> (raw) In-Reply-To: <20220704141340.493931-1-philip-dylan.gleonec@savoirfairelinux.com> An estimation of packet loss is required by libopus to compute its FEC data. Currently, this estimation is constant, and can not be changed after configuration. This means an application using libopus through ffmpeg can not adapt the packet loss estimation when the network quality degrades. This patch makes the encoder reload the packet_loss AVOption before encoding samples, if fec is enabled and the packet loss estimation set is different than the current one. This way an application can modify the packet loss estimation by changing the AVOption. Typical use-case is a RTP stream, where packet loss can be estimated from RTCP packets. Signed-off-by: Philip-Dylan Gleonec <philip-dylan.gleonec@savoirfairelinux.com> --- libavcodec/libopusenc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index c884075ffe..26d2082ffa 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -462,6 +462,23 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, uint8_t *audio; int ret; int discard_padding; + int32_t opus_packet_loss = 0; + + ret = opus_multistream_encoder_ctl(opus->enc, + OPUS_GET_PACKET_LOSS_PERC(&opus_packet_loss)); + if (ret != OPUS_OK) + av_log(avctx, AV_LOG_WARNING, + "Unable to get expected packet loss percentage: %s\n", + opus_strerror(ret)); + + if (opus->opts.fec && (opus_packet_loss != opus->opts.packet_loss)) { + ret = opus_multistream_encoder_ctl(opus->enc, + OPUS_SET_PACKET_LOSS_PERC(opus->opts.packet_loss)); + if (ret != OPUS_OK) + av_log(avctx, AV_LOG_WARNING, + "Unable to set expected packet loss percentage: %s\n", + opus_strerror(ret)); + } if (frame) { ret = ff_af_queue_add(&opus->afq, frame); -- 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 prev parent reply other threads:[~2022-07-04 14:14 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <1179126120.329661.1613560269226.JavaMail.zimbra@savoirfairelinux.com> [not found] ` <780b5984-3673-4b74-8883-63b980a43cc1@gmail.com> [not found] ` <0f24eb6c-375e-fc19-dc03-8b759d601f7a@savoirfairelinux.com> [not found] ` <20210218163835.142726-1-philip-dylan.gleonec@savoirfairelinux.com> [not found] ` <CAN8HRDm8VeaKFpWkpqGWadFtzVOGeNE3K8TJEvKMbu3YYi5cvA@mail.gmail.com> 2022-03-16 14:00 ` [FFmpeg-devel] libopusdec: Enable FEC/PLC Philip-Dylan Gleonec 2022-03-16 14:00 ` [FFmpeg-devel] [PATCH 1/2] avcodec/libopusenc: reload packet loss at encode Philip-Dylan Gleonec 2022-03-16 14:00 ` [FFmpeg-devel] [PATCH 2/2] avcodec/libopusdec: Enable FEC/PLC Philip-Dylan Gleonec 2022-06-16 16:05 ` Philip-Dylan Gleonec 2022-06-17 16:21 ` Michael Niedermayer 2022-07-04 14:13 ` Philip-Dylan Gleonec 2022-07-04 14:13 ` Philip-Dylan Gleonec [this message] 2022-07-04 14:13 ` [FFmpeg-devel] [PATCH v2 " Philip-Dylan Gleonec 2022-07-06 21:50 ` Lynne
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=20220704141340.493931-2-philip-dylan.gleonec@savoirfairelinux.com \ --to=philip-dylan.gleonec@savoirfairelinux.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