summaryrefslogtreecommitdiff
path: root/libavformat/rsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/rsd.c')
-rw-r--r--libavformat/rsd.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/libavformat/rsd.c b/libavformat/rsd.c
index dd1f3723d0..e02d767a01 100644
--- a/libavformat/rsd.c
+++ b/libavformat/rsd.c
@@ -56,7 +56,7 @@ static int rsd_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
int i, ret, version, start = 0x800;
- AVCodecContext *codec;
+ AVCodecParameters *par;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
@@ -65,16 +65,16 @@ static int rsd_read_header(AVFormatContext *s)
avio_skip(pb, 3); // "RSD"
version = avio_r8(pb) - '0';
- codec = st->codec;
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->codec_tag = avio_rl32(pb);
- codec->codec_id = ff_codec_get_id(rsd_tags, codec->codec_tag);
- if (!codec->codec_id) {
+ par = st->codecpar;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_tag = avio_rl32(pb);
+ par->codec_id = ff_codec_get_id(rsd_tags, par->codec_tag);
+ if (!par->codec_id) {
char tag_buf[32];
- av_get_codec_tag_string(tag_buf, sizeof(tag_buf), codec->codec_tag);
+ av_get_codec_tag_string(tag_buf, sizeof(tag_buf), par->codec_tag);
for (i=0; i < FF_ARRAY_ELEMS(rsd_unsupported_tags); i++) {
- if (codec->codec_tag == rsd_unsupported_tags[i]) {
+ if (par->codec_tag == rsd_unsupported_tags[i]) {
avpriv_request_sample(s, "Codec tag: %s", tag_buf);
return AVERROR_PATCHWELCOME;
}
@@ -83,43 +83,43 @@ static int rsd_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- codec->channels = avio_rl32(pb);
- if (!codec->channels)
+ par->channels = avio_rl32(pb);
+ if (!par->channels)
return AVERROR_INVALIDDATA;
avio_skip(pb, 4); // Bit depth
- codec->sample_rate = avio_rl32(pb);
- if (!codec->sample_rate)
+ par->sample_rate = avio_rl32(pb);
+ if (!par->sample_rate)
return AVERROR_INVALIDDATA;
avio_skip(pb, 4); // Unknown
- switch (codec->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_XMA2:
- codec->block_align = 2048;
- ff_alloc_extradata(codec, 34);
- if (!codec->extradata)
+ par->block_align = 2048;
+ ff_alloc_extradata(par, 34);
+ if (!par->extradata)
return AVERROR(ENOMEM);
- memset(codec->extradata, 0, 34);
+ memset(par->extradata, 0, 34);
break;
case AV_CODEC_ID_ADPCM_PSX:
- codec->block_align = 16 * codec->channels;
+ par->block_align = 16 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
- codec->block_align = 20 * codec->channels;
+ par->block_align = 20 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
if (version == 2)
start = avio_rl32(pb);
- codec->bits_per_coded_sample = 4;
- codec->block_align = 36 * codec->channels;
+ par->bits_per_coded_sample = 4;
+ par->block_align = 36 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_THP_LE:
/* RSD3GADP is mono, so only alloc enough memory
@@ -127,24 +127,24 @@ static int rsd_read_header(AVFormatContext *s)
start = avio_rl32(pb);
- if ((ret = ff_get_extradata(codec, s->pb, 32)) < 0)
+ if ((ret = ff_get_extradata(par, s->pb, 32)) < 0)
return ret;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_THP:
- codec->block_align = 8 * codec->channels;
+ par->block_align = 8 * par->channels;
avio_skip(s->pb, 0x1A4 - avio_tell(s->pb));
- if ((ret = ff_alloc_extradata(st->codec, 32 * st->codec->channels)) < 0)
+ if ((ret = ff_alloc_extradata(st->codecpar, 32 * par->channels)) < 0)
return ret;
- for (i = 0; i < st->codec->channels; i++) {
- avio_read(s->pb, st->codec->extradata + 32 * i, 32);
+ for (i = 0; i < par->channels; i++) {
+ avio_read(s->pb, st->codecpar->extradata + 32 * i, 32);
avio_skip(s->pb, 8);
}
if (pb->seekable)
- st->duration = (avio_size(pb) - start) / (8 * st->codec->channels) * 14;
+ st->duration = (avio_size(pb) - start) / (8 * par->channels) * 14;
break;
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
@@ -152,24 +152,24 @@ static int rsd_read_header(AVFormatContext *s)
start = avio_rl32(pb);
if (pb->seekable)
- st->duration = (avio_size(pb) - start) / 2 / codec->channels;
+ st->duration = (avio_size(pb) - start) / 2 / par->channels;
break;
}
avio_skip(pb, start - avio_tell(pb));
- if (codec->codec_id == AV_CODEC_ID_XMA2) {
+ if (par->codec_id == AV_CODEC_ID_XMA2) {
avio_skip(pb, avio_rb32(pb) + avio_rb32(pb));
st->duration = avio_rb32(pb);
}
- avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;
}
static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int ret, size = 1024;
int64_t pos;
@@ -177,20 +177,20 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
pos = avio_tell(s->pb);
- if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||
- codec->codec_id == AV_CODEC_ID_ADPCM_PSX ||
- codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
- codec->codec_id == AV_CODEC_ID_XMA2) {
- ret = av_get_packet(s->pb, pkt, codec->block_align);
- } else if (codec->codec_tag == MKTAG('W','A','D','P') &&
- codec->channels > 1) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||
+ par->codec_id == AV_CODEC_ID_ADPCM_PSX ||
+ par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
+ par->codec_id == AV_CODEC_ID_XMA2) {
+ ret = av_get_packet(s->pb, pkt, par->block_align);
+ } else if (par->codec_tag == MKTAG('W','A','D','P') &&
+ par->channels > 1) {
int i, ch;
- ret = av_new_packet(pkt, codec->block_align);
+ ret = av_new_packet(pkt, par->block_align);
if (ret < 0)
return ret;
for (i = 0; i < 4; i++) {
- for (ch = 0; ch < codec->channels; ch++) {
+ for (ch = 0; ch < par->channels; ch++) {
pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
}
@@ -200,7 +200,7 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size);
}
- if (codec->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
+ if (par->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
pkt->duration = (pkt->data[0] >> 2) * 512;
pkt->pos = pos;