case CODEC_TYPE_AUDIO:
st->codec.sample_rate = ap->sample_rate;
st->codec.channels = ap->channels;
+ av_set_pts_info(st, 64, 1, st->codec.sample_rate);
break;
case CODEC_TYPE_VIDEO:
st->codec.frame_rate = ap->frame_rate;
size= RAW_PACKET_SIZE;
if (av_new_packet(pkt, size) < 0)
- return -EIO;
+ return AVERROR_IO;
pkt->stream_index = 0;
ret = get_buffer(&s->pb, pkt->data, size);
if (ret <= 0) {
av_free_packet(pkt);
- return -EIO;
+ return AVERROR_IO;
}
/* note: we need to modify the packet size here to handle the last
packet */
size = RAW_PACKET_SIZE;
if (av_new_packet(pkt, size) < 0)
- return -EIO;
+ return AVERROR_IO;
pkt->stream_index = 0;
ret = get_partial_buffer(&s->pb, pkt->data, size);
if (ret <= 0) {
av_free_packet(pkt);
- return -EIO;
+ return AVERROR_IO;
}
pkt->size = ret;
return ret;
}
int pcm_read_seek(AVFormatContext *s,
- int stream_index, int64_t timestamp)
+ int stream_index, int64_t timestamp, int flags)
{
AVStream *st;
int block_align, byte_rate;
return -1;
/* compute the position by aligning it to block_align */
- pos = av_rescale(timestamp * byte_rate, st->time_base.num, st->time_base.den);
- pos = (pos / block_align) * block_align;
+ pos = av_rescale_rnd(timestamp * byte_rate,
+ st->time_base.num,
+ st->time_base.den * (int64_t)block_align,
+ (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
+ pos *= block_align;
/* recompute exact position */
st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
return 0;
}
+static int shorten_read_header(AVFormatContext *s,
+ AVFormatParameters *ap)
+{
+ AVStream *st;
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR_NOMEM;
+ st->codec.codec_type = CODEC_TYPE_AUDIO;
+ st->codec.codec_id = CODEC_ID_SHORTEN;
+ st->need_parsing = 1;
+ /* the parameters will be extracted from the compressed bitstream */
+ return 0;
+}
+
+/* dts read */
+static int dts_read_header(AVFormatContext *s,
+ AVFormatParameters *ap)
+{
+ AVStream *st;
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR_NOMEM;
+
+ st->codec.codec_type = CODEC_TYPE_AUDIO;
+ st->codec.codec_id = CODEC_ID_DTS;
+ st->need_parsing = 1;
+ /* the parameters will be extracted from the compressed bitstream */
+ return 0;
+}
+
/* mpeg1/h263 input */
static int video_read_header(AVFormatContext *s,
AVFormatParameters *ap)
return 0;
}
+static int h261_probe(AVProbeData *p)
+{
+ int code;
+ const uint8_t *d;
+
+ if (p->buf_size < 6)
+ return 0;
+ d = p->buf;
+ code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
+ if (code == 0x10) {
+ return 50;
+ }
+ return 0;
+}
+
+AVInputFormat shorten_iformat = {
+ "shn",
+ "raw shn",
+ 0,
+ NULL,
+ shorten_read_header,
+ raw_read_partial_packet,
+ raw_read_close,
+ .extensions = "shn",
+};
+
AVInputFormat ac3_iformat = {
"ac3",
"raw ac3",
};
#endif //CONFIG_ENCODERS
+AVInputFormat dts_iformat = {
+ "dts",
+ "raw dts",
+ 0,
+ NULL,
+ dts_read_header,
+ raw_read_partial_packet,
+ raw_read_close,
+ .extensions = "dts",
+};
+
+AVInputFormat h261_iformat = {
+ "h261",
+ "raw h261",
+ 0,
+ h261_probe,
+ video_read_header,
+ raw_read_partial_packet,
+ raw_read_close,
+ .extensions = "h261",
+ .value = CODEC_ID_H261,
+};
+
+#ifdef CONFIG_ENCODERS
+AVOutputFormat h261_oformat = {
+ "h261",
+ "raw h261",
+ "video/x-h261",
+ "h261",
+ 0,
+ 0,
+ CODEC_ID_H261,
+ raw_write_header,
+ raw_write_packet,
+ raw_write_trailer,
+};
+#endif //CONFIG_ENCODERS
+
AVInputFormat h263_iformat = {
"h263",
"raw h263",
};
#endif //CONFIG_ENCODERS
+#ifdef CONFIG_ENCODERS
+AVOutputFormat mpeg2video_oformat = {
+ "mpeg2video",
+ "MPEG2 video",
+ NULL,
+ "m2v",
+ 0,
+ 0,
+ CODEC_ID_MPEG2VIDEO,
+ raw_write_header,
+ raw_write_packet,
+ raw_write_trailer,
+};
+#endif //CONFIG_ENCODERS
+
AVInputFormat mjpeg_iformat = {
"mjpeg",
"MJPEG video",
packet_size = avpicture_get_size(st->codec.pix_fmt, width, height);
if (packet_size < 0)
- av_abort();
+ return -1;
if (av_new_packet(pkt, packet_size) < 0)
- return -EIO;
+ return AVERROR_IO;
pkt->stream_index = 0;
#if 0
#endif
if (ret != pkt->size) {
av_free_packet(pkt);
- return -EIO;
+ return AVERROR_IO;
} else {
return 0;
}
int raw_init(void)
{
+
+ av_register_input_format(&shorten_iformat);
+
av_register_input_format(&ac3_iformat);
av_register_output_format(&ac3_oformat);
+ av_register_input_format(&dts_iformat);
+
+ av_register_input_format(&h261_iformat);
+ av_register_output_format(&h261_oformat);
+
av_register_input_format(&h263_iformat);
av_register_output_format(&h263_oformat);
av_register_input_format(&mpegvideo_iformat);
av_register_output_format(&mpeg1video_oformat);
+ av_register_output_format(&mpeg2video_oformat);
+
av_register_input_format(&mjpeg_iformat);
av_register_output_format(&mjpeg_oformat);