[FFmpeg-devel] Fixes for audio/L16

2018-11-22 Thread Igor Derzhavin
Hello!
A little bunch of fixes for audio/L16 mime type handling:
0001 - RFC 2045 says MIME type should be case insensitive;
0002 - RFC 2586 says audio/L16 should be in network byte order (aka big
endian);
0003 - though "endiannes" parameter not in RFC it is widely used;
From e40e9567995042d75f8070daaa2efde46409f877 Mon Sep 17 00:00:00 2001
From: Igor Derzhavin 
Date: Thu, 22 Nov 2018 10:38:20 +0300
Subject: [PATCH 1/3] avformat/pcmdec: mime-type should be case insensitive
 (audio/L16)

---
 libavformat/pcmdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index bd2a0384f8..0d146a46a0 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -52,7 +52,7 @@ static int pcm_read_header(AVFormatContext *s)
 if (mime_type && s->iformat->mime_type) {
 int rate = 0, channels = 0;
 size_t len = strlen(s->iformat->mime_type);
-if (!strncmp(s->iformat->mime_type, mime_type, len)) {
+if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) {
 uint8_t *options = mime_type + len;
 len = strlen(mime_type);
 while (options < mime_type + len) {
-- 
2.17.1

From 4aa886c8941086d5290c10439a4a822538ec61e8 Mon Sep 17 00:00:00 2001
From: Igor Derzhavin 
Date: Thu, 22 Nov 2018 10:54:42 +0300
Subject: [PATCH 3/3] avformat/pcmdec: endianness for audio/L16 mime type

---
 libavformat/pcmdec.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 8530dbc1e3..9895af03a4 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -50,9 +50,9 @@ static int pcm_read_header(AVFormatContext *s)
 
 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
 if (mime_type && s->iformat->mime_type) {
-int rate = 0, channels = 0;
+int rate = 0, channels = 0, little_endian = 0;
 size_t len = strlen(s->iformat->mime_type);
-if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) {
+if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) { /* audio/L16 */
 uint8_t *options = mime_type + len;
 len = strlen(mime_type);
 while (options < mime_type + len) {
@@ -63,6 +63,12 @@ static int pcm_read_header(AVFormatContext *s)
 sscanf(options, " rate=%d", &rate);
 if (!channels)
 sscanf(options, " channels=%d", &channels);
+if (!little_endian) {
+ char val[14]; /* sizeof("little-endian") == 14 */
+ if (sscanf(options, " endianness=%13s", val) == 1) {
+ little_endian = strcmp(val, "little-endian") == 0;
+ }
+}
 }
 if (rate <= 0) {
 av_log(s, AV_LOG_ERROR,
@@ -74,6 +80,8 @@ static int pcm_read_header(AVFormatContext *s)
 st->codecpar->sample_rate = rate;
 if (channels > 0)
 st->codecpar->channels = channels;
+if (little_endian)
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 }
 }
 av_freep(&mime_type);
-- 
2.17.1

From 817fd71b9c87d019996d711d47517994c55636b1 Mon Sep 17 00:00:00 2001
From: Igor Derzhavin 
Date: Thu, 22 Nov 2018 10:39:57 +0300
Subject: [PATCH 2/3] avformat/pcmdec: audio/L16 should be in network byte
 order by default (rfc 2586)

---
 libavformat/pcmdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 0d146a46a0..8530dbc1e3 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -142,10 +142,10 @@ PCMDEF(s24le, "PCM signed 24-bit little-endian",
NULL, AV_CODEC_ID_PCM_S24LE)
 
 PCMDEF(s16be, "PCM signed 16-bit big-endian",
-   AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE)
+   AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE, .mime_type = "audio/L16")
 
 PCMDEF(s16le, "PCM signed 16-bit little-endian",
-   AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE, .mime_type = "audio/L16",)
+   AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
 
 PCMDEF(s8, "PCM signed 8-bit",
"sb", AV_CODEC_ID_PCM_S8)
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Fixes for audio/L16

2018-11-22 Thread Igor Derzhavin
No, I don't now applications that can play pcm streams through HTTP. VLC
misdetect such streams as mp3, and there is a two years old bug
https://trac.videolan.org/vlc/ticket/17229.

On Thu, Nov 22, 2018 at 4:00 PM Carl Eugen Hoyos  wrote:

> 2018-11-22 10:16 GMT+01:00, Igor Derzhavin :
>
> > A little bunch of fixes for audio/L16 mime type handling:
> > 0001 - RFC 2045 says MIME type should be case insensitive;
> > 0002 - RFC 2586 says audio/L16 should be in network byte order (aka big
> > endian);
> > 0003 - though "endiannes" parameter not in RFC it is widely used;
>
> Great, did you test this with any other application?
>
> Thank you, Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Fixes for audio/L16

2018-11-24 Thread Igor Derzhavin
Hello!
Do you accept these patches? Or what can I do more?
We use ffmpeg (libavformat/libavcodec) within our company and came across
that http url with content type
"audio/l16;rate=24000;channels=1;endianness=big-endian" incorrectly opens
as s16le with sample rate 16000.
This patches fixes that.

On Thu, Nov 22, 2018 at 4:45 PM Igor Derzhavin 
wrote:

> No, I don't now applications that can play pcm streams through HTTP. VLC
> misdetect such streams as mp3, and there is a two years old bug
> https://trac.videolan.org/vlc/ticket/17229.
>
> On Thu, Nov 22, 2018 at 4:00 PM Carl Eugen Hoyos 
> wrote:
>
>> 2018-11-22 10:16 GMT+01:00, Igor Derzhavin :
>>
>> > A little bunch of fixes for audio/L16 mime type handling:
>> > 0001 - RFC 2045 says MIME type should be case insensitive;
>> > 0002 - RFC 2586 says audio/L16 should be in network byte order (aka big
>> > endian);
>> > 0003 - though "endiannes" parameter not in RFC it is widely used;
>>
>> Great, did you test this with any other application?
>>
>> Thank you, Carl Eugen
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavformat/flvdec.c: don't build index_entries for input stream if AVIOContext is not seekable

2015-06-10 Thread Igor Derzhavin
Hello.
I suggest a small patch for FLV demuxer that prevent building index_entries
list if AVIOContext is not seekable. Whithout this check indext_entries
list behave as memory leak on continous stream (for example rtmp live
stream)
From 5ee9ec176f8019e117fcfdd17bcddea8911c7945 Mon Sep 17 00:00:00 2001
From: Igor Derzhavin 
Date: Wed, 10 Jun 2015 14:56:02 +0300
Subject: [PATCH] libavformat/flvdec.c: don't build index_entries for input
 stream if AVIOContext is not seekable

Signed-off-by: Igor Derzhavin 
---
 libavformat/flvdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 940d4dd..aea26c7 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -896,8 +896,9 @@ skip:
 }
 av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard);
 
-if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY ||
-stream_type == FLV_STREAM_TYPE_AUDIO)
+if (s->pb->seekable &&
+((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY ||
+  stream_type == FLV_STREAM_TYPE_AUDIO))
 av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME);
 
 if (  (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || (stream_type == FLV_STREAM_TYPE_AUDIO)))
-- 
1.9.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel