get_strl(pb, buf, buf_size, get_byte(pb));
}
-static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
- int read_all)
+static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
+ AVStream *st, int read_all)
{
RMContext *rm = s->priv_data;
- ByteIOContext *pb = s->pb;
char buf[256];
uint32_t version;
int i;
}
rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);
- } else if ((!strcmp(buf, "cook")) || (!strcmp(buf, "atrc"))) {
+ } else if ((!strcmp(buf, "cook")) || (!strcmp(buf, "atrc")) || (!strcmp(buf, "sipr"))) {
int codecdata_length, i;
get_be16(pb); get_byte(pb);
if (((version >> 16) & 0xff) == 5)
return -1;
}
+ if(sub_packet_size <= 0){
+ av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
+ return -1;
+ }
+
if (!strcmp(buf, "cook")) st->codec->codec_id = CODEC_ID_COOK;
+ else if (!strcmp(buf, "sipr")) st->codec->codec_id = CODEC_ID_SIPR;
else st->codec->codec_id = CODEC_ID_ATRAC3;
st->codec->extradata_size= codecdata_length;
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
}
int
-ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st)
+ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
+ AVStream *st, int codec_data_size)
{
- ByteIOContext *pb = s->pb;
unsigned int v;
- int codec_data_size, size;
+ int size;
int64_t codec_pos;
- codec_data_size = get_be32(pb);
+ av_set_pts_info(st, 64, 1, 1000);
codec_pos = url_ftell(pb);
v = get_be32(pb);
if (v == MKTAG(0xfd, 'a', 'r', '.')) {
/* ra type header */
- if (rm_read_audio_stream_info(s, st, 0))
+ if (rm_read_audio_stream_info(s, pb, st, 0))
return -1;
} else {
int fps, fps2;
if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
&& st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
&& st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
- && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
+ && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')
+ && st->codec->codec_tag != MKTAG('R', 'V', 'T', 'R'))
goto fail1;
st->codec->width = get_be16(pb);
st->codec->height = get_be16(pb);
return -1;
}
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codec->extradata)
+ return AVERROR(ENOMEM);
get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
st = av_new_stream(s, 0);
if (!st)
return -1;
- return rm_read_audio_stream_info(s, st, 1);
+ return rm_read_audio_stream_info(s, s->pb, st, 1);
}
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st;
ByteIOContext *pb = s->pb;
unsigned int tag;
- int tag_size, i;
+ int tag_size;
unsigned int start_time, duration;
char buf[128];
int flags = 0;
for(;;) {
if (url_feof(pb))
- goto fail;
+ return -1;
tag = get_le32(pb);
tag_size = get_be32(pb);
get_be16(pb);
tag_size);
#endif
if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A'))
- goto fail;
+ return -1;
switch(tag) {
case MKTAG('P', 'R', 'O', 'P'):
/* file header */
case MKTAG('M', 'D', 'P', 'R'):
st = av_new_stream(s, 0);
if (!st)
- goto fail;
+ return AVERROR(ENOMEM);
st->id = get_be16(pb);
get_be32(pb); /* max bit rate */
st->codec->bit_rate = get_be32(pb); /* bit rate */
get_str8(pb, buf, sizeof(buf)); /* desc */
get_str8(pb, buf, sizeof(buf)); /* mimetype */
st->codec->codec_type = CODEC_TYPE_DATA;
- av_set_pts_info(st, 64, 1, 1000);
- if (ff_rm_read_mdpr_codecdata(s, st) < 0)
+ if (ff_rm_read_mdpr_codecdata(s, s->pb, st, get_be32(pb)) < 0)
return -1;
break;
case MKTAG('D', 'A', 'T', 'A'):
get_be32(pb); /* next data header */
rm->curpic_num = -1;
return 0;
-
- fail:
- for(i=0;i<s->nb_streams;i++) {
- av_free(s->streams[i]);
- }
- return AVERROR(EIO);
}
static int get_num(ByteIOContext *pb, int *len)
return -1;
}
-static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len)
+static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
+ RMContext *rm, AVPacket *pkt, int len)
{
- ByteIOContext *pb = s->pb;
int hdr, seq, pic_num, len2, pos;
int type;
}
int
-ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt,
+ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
+ AVStream *st, int len, AVPacket *pkt,
int *seq, int *flags, int64_t *timestamp)
{
- ByteIOContext *pb = s->pb;
RMContext *rm = s->priv_data;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
rm->current_stream= st->id;
- if(rm_assemble_video_frame(s, rm, pkt, len) == 1)
+ if(rm_assemble_video_frame(s, pb, rm, pkt, len) == 1)
return -1; //got partial frame
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
(st->codec->codec_id == CODEC_ID_COOK) ||
- (st->codec->codec_id == CODEC_ID_ATRAC3)) {
+ (st->codec->codec_id == CODEC_ID_ATRAC3) ||
+ (st->codec->codec_id == CODEC_ID_SIPR)) {
int x;
int sps = rm->sub_packet_size;
int cfs = rm->coded_framesize;
}
void
-ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt)
+ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
+ AVStream *st, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
RMContext *rm = s->priv_data;
assert (rm->audio_pkt_cnt > 0);
if (rm->audio_pkt_cnt) {
// If there are queued audio packet return them first
st = s->streams[rm->audio_stream_num];
- ff_rm_retrieve_cache(s, st, pkt);
+ ff_rm_retrieve_cache(s, s->pb, st, pkt);
} else if (rm->old_format) {
st = s->streams[0];
if (st->codec->codec_id == CODEC_ID_RA_288) {
return AVERROR(EIO);
st = s->streams[i];
- if (ff_rm_parse_packet (s, st, len, pkt, &seq, &flags, ×tamp) < 0)
+ if (ff_rm_parse_packet (s, s->pb, st, len, pkt, &seq, &flags, ×tamp) < 0)
goto resync;
if((flags&2) && (seq&0x7F) == 1)
AVInputFormat rm_demuxer = {
"rm",
- "rm format",
+ NULL_IF_CONFIG_SMALL("RM format"),
sizeof(RMContext),
rm_probe,
rm_read_header,
NULL,
rm_read_dts,
};
+
+AVInputFormat rdt_demuxer = {
+ "rdt",
+ NULL_IF_CONFIG_SMALL("RDT demuxer"),
+ sizeof(RMContext),
+ NULL, NULL, NULL, rm_read_close, NULL, NULL
+};