Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac
@ 2023-09-06  0:10 Paul B Mahol
  2023-09-06  6:11 ` Tomas Härdin
  0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2023-09-06  0:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 10 bytes --]

Attached.

[-- Attachment #2: 0001-avformat-flacdec-set-time-base-for-headerless-flac.patch --]
[-- Type: text/x-patch, Size: 1690 bytes --]

From dea5517ee383b4133a11137b99b27ba389e04a47 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 6 Sep 2023 02:04:10 +0200
Subject: [PATCH] avformat/flacdec: set time base for headerless flac

Fixes #6396.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/flacdec.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index b58ec03963..5104f23110 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -46,11 +46,16 @@ static void reset_index_position(int64_t metadata_head_size, AVStream *st)
         sti->index_entries[i].pos += metadata_head_size;
 }
 
+static const uint16_t sr_table[16] = {
+    0, 1764, 3528, 3840, 160, 320, 441, 480, 640, 882, 960, 1920, 0, 0, 0, 0
+};
+
 static int flac_read_header(AVFormatContext *s)
 {
     int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
     uint8_t header[4];
     uint8_t *buffer=NULL;
+    uint32_t marker;
     FLACDecContext *flac = s->priv_data;
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
@@ -61,7 +66,11 @@ static int flac_read_header(AVFormatContext *s)
     /* the parameters will be extracted from the compressed bitstream */
 
     /* if fLaC marker is not found, assume there is no header */
-    if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
+    marker = avio_rl32(s->pb);
+    if (marker != MKTAG('f','L','a','C')) {
+        const int sample_rate = 50 * sr_table[(marker >> 16) & 0xF];
+        if (sample_rate)
+            avpriv_set_pts_info(st, 64, 1, sample_rate);
         avio_seek(s->pb, -4, SEEK_CUR);
         return 0;
     }
-- 
2.39.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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac
  2023-09-06  0:10 [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac Paul B Mahol
@ 2023-09-06  6:11 ` Tomas Härdin
  2023-09-06  7:11   ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Tomas Härdin @ 2023-09-06  6:11 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

ons 2023-09-06 klockan 02:10 +0200 skrev Paul B Mahol:
> +static const uint16_t sr_table[16] = {
> +    0, 1764, 3528, 3840, 160, 320, 441, 480, 640, 882, 960, 1920, 0,
> 0, 0, 0
> +};

Why not premultiply these by 50?

/Tomas
_______________________________________________
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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac
  2023-09-06  6:11 ` Tomas Härdin
@ 2023-09-06  7:11   ` Paul B Mahol
  2023-09-07  9:17     ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2023-09-06  7:11 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, Sep 6, 2023 at 8:12 AM Tomas Härdin <git@haerdin.se> wrote:

> ons 2023-09-06 klockan 02:10 +0200 skrev Paul B Mahol:
> > +static const uint16_t sr_table[16] = {
> > +    0, 1764, 3528, 3840, 160, 320, 441, 480, 640, 882, 960, 1920, 0,
> > 0, 0, 0
> > +};
>
> Why not premultiply these by 50?
>

Because that would use 2x more space.


> /Tomas
> _______________________________________________
> 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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac
  2023-09-06  7:11   ` Paul B Mahol
@ 2023-09-07  9:17     ` Paul B Mahol
  0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2023-09-07  9:17 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

will apply
_______________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2023-09-07  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06  0:10 [FFmpeg-devel] [PATCH] avformat/flacdec: set time base for headerless flac Paul B Mahol
2023-09-06  6:11 ` Tomas Härdin
2023-09-06  7:11   ` Paul B Mahol
2023-09-07  9:17     ` 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