Commit 6b10228a authored by Aurelien Jacobs's avatar Aurelien Jacobs

matroskadec: add support for SIPR audio tracks

Originally committed as revision 22492 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 1ab0406d
...@@ -100,7 +100,7 @@ OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o ...@@ -100,7 +100,7 @@ OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
OBJS-$(CONFIG_M4V_DEMUXER) += raw.o OBJS-$(CONFIG_M4V_DEMUXER) += raw.o
OBJS-$(CONFIG_M4V_MUXER) += raw.o OBJS-$(CONFIG_M4V_MUXER) += raw.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
riff.o isom.o riff.o isom.o rm.o
OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \ OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \
riff.o isom.o avc.o flacenc.o riff.o isom.o avc.o flacenc.o
OBJS-$(CONFIG_MJPEG_DEMUXER) += raw.o OBJS-$(CONFIG_MJPEG_DEMUXER) += raw.o
......
...@@ -45,7 +45,7 @@ const CodecTags ff_mkv_codec_tags[]={ ...@@ -45,7 +45,7 @@ const CodecTags ff_mkv_codec_tags[]={
{"A_REAL/28_8" , CODEC_ID_RA_288}, {"A_REAL/28_8" , CODEC_ID_RA_288},
{"A_REAL/ATRC" , CODEC_ID_ATRAC3}, {"A_REAL/ATRC" , CODEC_ID_ATRAC3},
{"A_REAL/COOK" , CODEC_ID_COOK}, {"A_REAL/COOK" , CODEC_ID_COOK},
// {"A_REAL/SIPR" , CODEC_ID_SIPRO}, {"A_REAL/SIPR" , CODEC_ID_SIPR},
{"A_TRUEHD" , CODEC_ID_TRUEHD}, {"A_TRUEHD" , CODEC_ID_TRUEHD},
{"A_TTA1" , CODEC_ID_TTA}, {"A_TTA1" , CODEC_ID_TTA},
{"A_VORBIS" , CODEC_ID_VORBIS}, {"A_VORBIS" , CODEC_ID_VORBIS},
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
/* For ff_codec_get_id(). */ /* For ff_codec_get_id(). */
#include "riff.h" #include "riff.h"
#include "isom.h" #include "isom.h"
#include "rm.h"
#include "matroska.h" #include "matroska.h"
#include "libavcodec/mpeg4audio.h" #include "libavcodec/mpeg4audio.h"
#include "libavutil/intfloat_readwrite.h" #include "libavutil/intfloat_readwrite.h"
...@@ -1312,10 +1313,12 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -1312,10 +1313,12 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
track->audio.out_samplerate = 8000; track->audio.out_samplerate = 8000;
track->audio.channels = 1; track->audio.channels = 1;
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) { codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
int flavor;
init_put_byte(&b, track->codec_priv.data,track->codec_priv.size, init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL); 0, NULL, NULL, NULL, NULL);
url_fskip(&b, 24); url_fskip(&b, 22);
flavor = get_be16(&b);
track->audio.coded_framesize = get_be32(&b); track->audio.coded_framesize = get_be32(&b);
url_fskip(&b, 12); url_fskip(&b, 12);
track->audio.sub_packet_h = get_be16(&b); track->audio.sub_packet_h = get_be16(&b);
...@@ -1326,6 +1329,11 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -1326,6 +1329,11 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->block_align = track->audio.coded_framesize; st->codec->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0; track->codec_priv.size = 0;
} else { } else {
if (codec_id == CODEC_ID_SIPR && flavor < 4) {
const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
st->codec->bit_rate = sipr_bit_rate[flavor];
}
st->codec->block_align = track->audio.sub_packet_size; st->codec->block_align = track->audio.sub_packet_size;
extradata_offset = 78; extradata_offset = 78;
} }
...@@ -1638,6 +1646,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, ...@@ -1638,6 +1646,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
for (n = 0; n < laces; n++) { for (n = 0; n < laces; n++) {
if ((st->codec->codec_id == CODEC_ID_RA_288 || if ((st->codec->codec_id == CODEC_ID_RA_288 ||
st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_COOK ||
st->codec->codec_id == CODEC_ID_SIPR ||
st->codec->codec_id == CODEC_ID_ATRAC3) && st->codec->codec_id == CODEC_ID_ATRAC3) &&
st->codec->block_align && track->audio.sub_packet_size) { st->codec->block_align && track->audio.sub_packet_size) {
int a = st->codec->block_align; int a = st->codec->block_align;
...@@ -1653,11 +1662,15 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, ...@@ -1653,11 +1662,15 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
for (x=0; x<h/2; x++) for (x=0; x<h/2; x++)
memcpy(track->audio.buf+x*2*w+y*cfs, memcpy(track->audio.buf+x*2*w+y*cfs,
data+x*cfs, cfs); data+x*cfs, cfs);
else if (st->codec->codec_id == CODEC_ID_SIPR)
memcpy(track->audio.buf + y*w, data, w);
else else
for (x=0; x<w/sps; x++) for (x=0; x<w/sps; x++)
memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps);
if (++track->audio.sub_packet_cnt >= h) { if (++track->audio.sub_packet_cnt >= h) {
if (st->codec->codec_id == CODEC_ID_SIPR)
ff_rm_reorder_sipr_data(track->audio.buf, h, w);
track->audio.sub_packet_cnt = 0; track->audio.sub_packet_cnt = 0;
track->audio.pkt_cnt = h*w / a; track->audio.pkt_cnt = h*w / a;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment