*/
/**
- * @file libavformat/wc3movie.c
+ * @file
* Wing Commander III Movie file demuxer
* by Mike Melanson (melanson@pcisys.net)
* for more information on the WC3 .mve file format, visit:
* palette lookup table that does gamma correction
*
* can be calculated by this formula:
- * for i between 0 and 252 inclusive:
- * wc3_pal_lookup[i] = pow(i / 256.0, 0.8) * 256;
- * values 253, 254 and 255 are all 0xFD
+ * for i between 0 and 251 inclusive:
+ * wc3_pal_lookup[i] = round(pow(i / 256.0, 0.8) * 256);
+ * values 252, 253, 254 and 255 are all 0xFD
* calculating this at runtime should not cause any
* rounding issues, the maximum difference between
* the table values and the calculated doubles is
unsigned int fourcc_tag;
unsigned int size;
AVStream *st;
- char buffer[513];
int ret = 0;
int current_palette = 0;
- int bytes_to_read;
+ char *buffer;
int i;
unsigned char rotate;
case BNAM_TAG:
/* load up the name */
- if ((unsigned)size < 512)
- bytes_to_read = size;
- else
- bytes_to_read = 512;
- if ((ret = get_buffer(pb, buffer, bytes_to_read)) != bytes_to_read)
+ buffer = av_malloc(size+1);
+ if (!buffer)
+ return AVERROR(ENOMEM);
+ if ((ret = get_buffer(pb, buffer, size)) != size)
return AVERROR(EIO);
- buffer[bytes_to_read] = 0;
- av_metadata_set(&s->metadata, "title", buffer);
+ buffer[size] = 0;
+ av_metadata_set2(&s->metadata, "title", buffer,
+ AV_METADATA_DONT_STRDUP_VAL);
break;
case SIZE_TAG:
default:
av_log(s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
- (char)fourcc_tag, (char)(fourcc_tag >> 8), (char)(fourcc_tag >> 16), (char)(fourcc_tag >> 24),
- (char)fourcc_tag, (char)(fourcc_tag >> 8), (char)(fourcc_tag >> 16), (char)(fourcc_tag >> 24));
+ (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24),
+ (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24));
return AVERROR_INVALIDDATA;
break;
}
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_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_XAN_WC3;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = wc3->width;
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_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_PCM_S16LE;
st->codec->codec_tag = 1;
st->codec->channels = WC3_AUDIO_CHANNELS;
default:
av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
- (char)fourcc_tag, (char)(fourcc_tag >> 8), (char)(fourcc_tag >> 16), (char)(fourcc_tag >> 24),
- (char)fourcc_tag, (char)(fourcc_tag >> 8), (char)(fourcc_tag >> 16), (char)(fourcc_tag >> 24));
+ (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24),
+ (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24));
ret = AVERROR_INVALIDDATA;
packet_read = 1;
break;