#include "avformat.h"
#define HUFFMAN_TABLE_SIZE (64 * 1024)
-#define FRAME_PTS_INC (90000 / 14)
+#define IDCIN_FPS 14
typedef struct IdcinDemuxContext {
int video_stream_index;
static int idcin_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
IdcinDemuxContext *idcin = s->priv_data;
AVStream *st;
unsigned int width, height;
st = av_new_stream(s, 0);
if (!st)
- return AVERROR_NOMEM;
- av_set_pts_info(st, 33, 1, 90000);
+ return AVERROR(ENOMEM);
+ av_set_pts_info(st, 33, 1, IDCIN_FPS);
idcin->video_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_IDCIN;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
HUFFMAN_TABLE_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
/* save a reference in order to transport the palette */
st->codec->palctrl = &idcin->palctrl;
idcin->audio_present = 1;
st = av_new_stream(s, 0);
if (!st)
- return AVERROR_NOMEM;
- av_set_pts_info(st, 33, 1, 90000);
+ return AVERROR(ENOMEM);
+ av_set_pts_info(st, 33, 1, IDCIN_FPS);
idcin->audio_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_tag = 1;
unsigned int command;
unsigned int chunk_size;
IdcinDemuxContext *idcin = s->priv_data;
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
int i;
int palette_scale;
unsigned char r, g, b;
unsigned char palette_buffer[768];
- if (url_feof(&s->pb))
- return AVERROR_IO;
+ if (url_feof(s->pb))
+ return AVERROR(EIO);
if (idcin->next_chunk_is_video) {
command = get_le32(pb);
if (command == 2) {
- return AVERROR_IO;
+ return AVERROR(EIO);
} else if (command == 1) {
/* trigger a palette change */
idcin->palctrl.palette_changed = 1;
if (get_buffer(pb, palette_buffer, 768) != 768)
- return AVERROR_IO;
+ return AVERROR(EIO);
/* scale the palette as necessary */
palette_scale = 2;
for (i = 0; i < 768; i++)
chunk_size -= 4;
ret= av_get_packet(pb, pkt, chunk_size);
if (ret != chunk_size)
- return AVERROR_IO;
+ return AVERROR(EIO);
pkt->stream_index = idcin->video_stream_index;
pkt->pts = idcin->pts;
} else {
chunk_size = idcin->audio_chunk_size1;
ret= av_get_packet(pb, pkt, chunk_size);
if (ret != chunk_size)
- return AVERROR_IO;
+ return AVERROR(EIO);
pkt->stream_index = idcin->audio_stream_index;
pkt->pts = idcin->pts;
idcin->current_audio_chunk ^= 1;
- idcin->pts += FRAME_PTS_INC;
+ idcin->pts++;
}
if (idcin->audio_present)