#define FORM_TAG MKTAG('F', 'O', 'R', 'M')
#define MOVE_TAG MKTAG('M', 'O', 'V', 'E')
-#define _PC__TAG MKTAG('_', 'P', 'C', '_')
+#define PC__TAG MKTAG('_', 'P', 'C', '_')
#define SOND_TAG MKTAG('S', 'O', 'N', 'D')
#define BNAM_TAG MKTAG('B', 'N', 'A', 'M')
#define SIZE_TAG MKTAG('S', 'I', 'Z', 'E')
#define WC3_AUDIO_BITS 16
/* nice, constant framerate */
-#define WC3_FRAME_PTS_INC (90000 / 15)
+#define WC3_FRAME_FPS 15
#define PALETTE_SIZE (256 * 3)
#define PALETTE_COUNT 256
static int wc3_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- Wc3DemuxContext *wc3 = (Wc3DemuxContext *)s->priv_data;
- ByteIOContext *pb = &s->pb;
+ Wc3DemuxContext *wc3 = s->priv_data;
+ ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
AVStream *st;
* the first BRCH tag */
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
fourcc_tag = AV_RL32(&preamble[0]);
size = (AV_RB32(&preamble[4]) + 1) & (~1);
url_fseek(pb, size, SEEK_CUR);
break;
- case _PC__TAG:
+ case PC__TAG:
/* need the number of palettes */
url_fseek(pb, 8, SEEK_CUR);
if ((ret = get_buffer(pb, preamble, 4)) != 4)
- return AVERROR_IO;
+ return AVERROR(EIO);
wc3->palette_count = AV_RL32(&preamble[0]);
if((unsigned)wc3->palette_count >= UINT_MAX / PALETTE_SIZE){
wc3->palette_count= 0;
else
bytes_to_read = 512;
if ((ret = get_buffer(pb, s->title, bytes_to_read)) != bytes_to_read)
- return AVERROR_IO;
+ return AVERROR(EIO);
break;
case SIZE_TAG:
/* video resolution override */
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
wc3->width = AV_RL32(&preamble[0]);
wc3->height = AV_RL32(&preamble[4]);
break;
if ((ret = get_buffer(pb,
&wc3->palettes[current_palette * PALETTE_SIZE],
PALETTE_SIZE)) != PALETTE_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
/* transform the current palette in place */
for (i = current_palette * PALETTE_SIZE;
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
fourcc_tag = AV_RL32(&preamble[0]);
/* chunk sizes are 16-bit aligned */
size = (AV_RB32(&preamble[4]) + 1) & (~1);
/* initialize the decoder streams */
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, WC3_FRAME_FPS);
wc3->video_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_XAN_WC3;
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, WC3_FRAME_FPS);
wc3->audio_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- Wc3DemuxContext *wc3 = (Wc3DemuxContext *)s->priv_data;
- ByteIOContext *pb = &s->pb;
+ Wc3DemuxContext *wc3 = s->priv_data;
+ ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
/* get the next chunk preamble */
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
- ret = AVERROR_IO;
+ ret = AVERROR(EIO);
fourcc_tag = AV_RL32(&preamble[0]);
/* chunk sizes are 16-bit aligned */
case SHOT_TAG:
/* load up new palette */
if ((ret = get_buffer(pb, preamble, 4)) != 4)
- return AVERROR_IO;
+ return AVERROR(EIO);
palette_number = AV_RL32(&preamble[0]);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
pkt->stream_index = wc3->video_stream_index;
pkt->pts = wc3->pts;
if (ret != size)
- ret = AVERROR_IO;
+ ret = AVERROR(EIO);
packet_read = 1;
break;
url_fseek(pb, size, SEEK_CUR);
#else
if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
- ret = AVERROR_IO;
+ ret = AVERROR(EIO);
else {
int i = 0;
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
pkt->stream_index = wc3->audio_stream_index;
pkt->pts = wc3->pts;
if (ret != size)
- ret = AVERROR_IO;
+ ret = AVERROR(EIO);
/* time to advance pts */
- wc3->pts += WC3_FRAME_PTS_INC;
+ wc3->pts++;
packet_read = 1;
break;
static int wc3_read_close(AVFormatContext *s)
{
- Wc3DemuxContext *wc3 = (Wc3DemuxContext *)s->priv_data;
+ Wc3DemuxContext *wc3 = s->priv_data;
av_free(wc3->palettes);
AVInputFormat wc3_demuxer = {
"wc3movie",
- "Wing Commander III movie format",
+ NULL_IF_CONFIG_SMALL("Wing Commander III movie format"),
sizeof(Wc3DemuxContext),
wc3_probe,
wc3_read_header,