[FFmpeg-devel] [PATCH] lavf/swf: support 8-bit audio.
Clément Bœsch
ubitux at gmail.com
Wed Feb 20 20:57:50 CET 2013
---
libavformat/swfdec.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 8fb4aeb..69e5f04 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -184,7 +184,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
len -= 8;
} else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
/* streaming found */
- int sample_rate_code;
+ int sample_rate_code, is_16bits;
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
@@ -210,12 +210,15 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
ast->need_parsing = AVSTREAM_PARSE_FULL;
sample_rate_code= (v>>2) & 3;
+ is_16bits = v>>1 & 1;
+ if (!is_16bits)
+ ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
ast->codec->sample_rate = 44100 >> (3 - sample_rate_code);
avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
len -= 4;
} else if (tag == TAG_DEFINESOUND) {
/* audio stream */
- int sample_rate_code;
+ int sample_rate_code, is_16bits;
int ch_id = avio_rl16(pb);
for (i=0; i<s->nb_streams; i++) {
@@ -224,7 +227,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto skip;
}
- // FIXME: 8-bit uncompressed PCM audio will be interpreted as 16-bit
// FIXME: The entire audio stream is stored in a single chunk/tag. Normally,
// these are smaller audio streams in DEFINESOUND tags, but it's technically
// possible they could be huge. Break it up into multiple packets if it's big.
@@ -238,6 +240,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
ast->need_parsing = AVSTREAM_PARSE_FULL;
sample_rate_code= (v>>2) & 3;
+ is_16bits = v>>1 & 1;
+ if (!is_16bits)
+ ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
ast->codec->sample_rate = 44100 >> (3 - sample_rate_code);
avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
ast->duration = avio_rl32(pb); // number of samples
--
1.8.1.4
More information about the ffmpeg-devel
mailing list