/*
* "Real" compatible mux and demux.
- * Copyright (c) 2000, 2001 Gerard Lantau.
+ * Copyright (c) 2000, 2001 Fabrice Bellard.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
stream->total_frames = stream->nb_packets;
break;
default:
- abort();
+ av_abort();
}
}
h263_hack_version = get_be32(pb);
switch(h263_hack_version) {
case 0x10000000:
- st->codec.sub_id = 0;
- st->codec.codec_id = CODEC_ID_RV10;
- break;
case 0x10003000:
case 0x10003001:
- st->codec.sub_id = 3;
+ st->codec.sub_id = h263_hack_version;
st->codec.codec_id = CODEC_ID_RV10;
break;
default:
return -EIO;
}
+static int get_num(ByteIOContext *pb, int *len)
+{
+ int n, n1;
+
+ n = get_be16(pb);
+ (*len)-=2;
+ if (n >= 0x4000) {
+ return n - 0x4000;
+ } else {
+ n1 = get_be16(pb);
+ (*len)-=2;
+ return (n << 16) | n1;
+ }
+}
+
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
RMContext *rm = s->priv_data;
}
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
- get_byte(pb);
- get_byte(pb);
- get_be16(pb);
- get_be16(pb);
- get_byte(pb);
- len -= 7;
+ int full_frame, h, pic_num;
+
+ h= get_byte(pb);
+ if ((h & 0xc0) == 0xc0) {
+ int len2, pos;
+ full_frame = 1;
+ len2= get_num(pb, &len);
+ pos = get_num(pb, &len);
+ //printf("pos:%d\n",len);
+ len -= 2;
+ } else {
+ int seq, frame_size, pos;
+ full_frame = 0;
+ seq = get_byte(pb);
+ frame_size = get_num(pb, &len);
+ pos = get_num(pb, &len);
+ //printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos);
+ len -= 3;
+ }
+ /* picture number */
+ pic_num= get_byte(pb);
+
+ //XXX/FIXME/HACK, demuxer should be fixed to send complete frames ...
+ if(st->codec.slice_offset==NULL) st->codec.slice_offset= (int*)malloc(sizeof(int));
+ st->codec.slice_count= full_frame;
+ st->codec.slice_offset[0]= 0;
}
-
av_new_packet(pkt, len);
pkt->stream_index = i;
get_buffer(pb, pkt->data, len);
+
/* for AC3, needs to swap bytes */
if (st->codec.codec_id == CODEC_ID_AC3) {
ptr = pkt->data;
return 0;
}
-AVInputFormat rm_iformat = {
+static AVInputFormat rm_iformat = {
"rm",
"rm format",
sizeof(RMContext),
rm_read_close,
};
-AVOutputFormat rm_oformat = {
+static AVOutputFormat rm_oformat = {
"rm",
"rm format",
"audio/x-pn-realaudio",