From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [RFC PATCH 3/3] aacdec: allow to skip sbr start-up delay
Date: Tue, 12 Sep 2023 08:15:00 +0200 (CEST)
Message-ID: <Ne70q7k--3-9@lynne.ee> (raw)
In-Reply-To: <Ne70gnX--3-9@lynne.ee-Ne70juu----9>
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
Sep 12, 2023, 08:14 by dev@lynne.ee:
> As it happens, there's no standard between startup delay for SBR between
> decoders either. libfdkaac uses 5056 samples, but Apple's encoder (via afconvert)
> uses 3136.
>
> Currently, this only fixes libfdk-aac. Would like to have more samples from more
> encoders so I can fix all known cases.
>
Wrong patch attached.
[-- Attachment #2: 0003-aacdec-allow-to-skip-sbr-start-up-delay.patch --]
[-- Type: text/x-diff, Size: 2042 bytes --]
From c0e5659e5a2d56e883f9e1bb8c6d5bca1059721a Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Tue, 12 Sep 2023 08:06:40 +0200
Subject: [PATCH 3/3] aacdec: allow to skip sbr start-up delay
---
 libavcodec/aac.h             |  1 +
 libavcodec/aacdec_template.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 285d3b7482..3f67f353b7 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -298,6 +298,7 @@ struct AACContext {
     AVCodecContext *avctx;
     AVFrame *frame;
 
+    int sbr_state_changed;
     int is_saved;                 ///< Set if elements have stored overlap from previous frame.
     DynamicRangeControl che_drc;
 
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 0e4a274fea..b6c6d19f61 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1207,6 +1207,8 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
                                                 avctx->extradata_size * 8LL,
                                                 1)) < 0)
             return ret;
+
+        ac->sbr_state_changed = ac->oc[1].m4ac.sbr == 1;
     } else {
         int sr, i;
         uint8_t layout_map[MAX_ELEM_ID*4][3];
@@ -3154,6 +3156,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame,
     int is_dmono, sce_count = 0;
     int payload_alignment;
     uint8_t che_presence[4][MAX_ELEM_ID] = {{0}};
+    int sbr_state_start = ac->oc[1].m4ac.sbr;
 
     ac->frame = frame;
 
@@ -3346,6 +3349,14 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame,
             frame->data[0] = frame->data[1];
     }
 
+    ac->sbr_state_changed |= (ac->oc[1].m4ac.sbr != sbr_state_start) && (ac->oc[1].m4ac.sbr == 1);
+
+    if (ac->sbr_state_changed) {
+        avctx->internal->skip_samples = 5056;
+        avctx->internal->skip_samples_add = 1;
+        ac->sbr_state_changed = 0;
+    }
+
     return 0;
 fail:
     pop_output_configuration(ac);
-- 
2.40.1
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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-09-12  6:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  6:10 [FFmpeg-devel] [RFC PATCH 1/3] aacdec: always skip the first 2048 samples if there's no side data Lynne
     [not found] ` <Ne7-l4q--3-9@lynne.ee-Ne7-pA6----9>
2023-09-12  6:11   ` [FFmpeg-devel] [RFC PATCH 2/3] decode: allow decoders to override skip_samples Lynne
2023-09-12  6:14   ` [FFmpeg-devel] [RFC PATCH 3/3] aacdec: allow to skip sbr start-up delay Lynne
     [not found]   ` <Ne70gnX--3-9@lynne.ee-Ne70juu----9>
2023-09-12  6:15     ` Lynne [this message]
2023-09-12  7:10 ` [FFmpeg-devel] [RFC PATCH 1/3] aacdec: always skip the first 2048 samples if there's no side data Andreas Rheinhardt
2023-09-12 16:25   ` Lynne
2023-09-12 21:24     ` Thierry Foucu
2023-10-03  4:09       ` 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=Ne70q7k--3-9@lynne.ee \
    --to=dev@lynne.ee \
    --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