39 #define CHUNK_PREAMBLE_SIZE 4
40 #define OPCODE_PREAMBLE_SIZE 4
42 #define CHUNK_INIT_AUDIO 0x0000
43 #define CHUNK_AUDIO_ONLY 0x0001
44 #define CHUNK_INIT_VIDEO 0x0002
45 #define CHUNK_VIDEO 0x0003
46 #define CHUNK_SHUTDOWN 0x0004
47 #define CHUNK_END 0x0005
49 #define CHUNK_DONE 0xFFFC
50 #define CHUNK_NOMEM 0xFFFD
51 #define CHUNK_EOF 0xFFFE
52 #define CHUNK_BAD 0xFFFF
54 #define OPCODE_END_OF_STREAM 0x00
55 #define OPCODE_END_OF_CHUNK 0x01
56 #define OPCODE_CREATE_TIMER 0x02
57 #define OPCODE_INIT_AUDIO_BUFFERS 0x03
58 #define OPCODE_START_STOP_AUDIO 0x04
59 #define OPCODE_INIT_VIDEO_BUFFERS 0x05
60 #define OPCODE_UNKNOWN_06 0x06
61 #define OPCODE_SEND_BUFFER 0x07
62 #define OPCODE_AUDIO_FRAME 0x08
63 #define OPCODE_SILENCE_FRAME 0x09
64 #define OPCODE_INIT_VIDEO_MODE 0x0A
65 #define OPCODE_CREATE_GRADIENT 0x0B
66 #define OPCODE_SET_PALETTE 0x0C
67 #define OPCODE_SET_PALETTE_COMPRESSED 0x0D
68 #define OPCODE_UNKNOWN_0E 0x0E
69 #define OPCODE_SET_DECODING_MAP 0x0F
70 #define OPCODE_UNKNOWN_10 0x10
71 #define OPCODE_VIDEO_DATA 0x11
72 #define OPCODE_UNKNOWN_12 0x12
73 #define OPCODE_UNKNOWN_13 0x13
74 #define OPCODE_UNKNOWN_14 0x14
75 #define OPCODE_UNKNOWN_15 0x15
77 #define PALETTE_COUNT 256
122 "audio codec is known\n");
149 av_dlog(
NULL,
"sending audio frame with pts %"PRId64
" (%d audio frames)\n",
198 av_dlog(
NULL,
"sending video frame with pts %"PRId64
"\n", pkt->
pts);
223 unsigned char opcode_type;
224 unsigned char opcode_version;
226 unsigned char scratch[1024];
228 int first_color, last_color;
230 unsigned char r,
g,
b;
244 chunk_size =
AV_RL16(&chunk_preamble[0]);
245 chunk_type =
AV_RL16(&chunk_preamble[2]);
247 av_dlog(
NULL,
"chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
249 switch (chunk_type) {
282 while ((chunk_size > 0) && (chunk_type !=
CHUNK_BAD)) {
295 opcode_size =
AV_RL16(&opcode_preamble[0]);
296 opcode_type = opcode_preamble[2];
297 opcode_version = opcode_preamble[3];
300 chunk_size -= opcode_size;
301 if (chunk_size < 0) {
302 av_dlog(
NULL,
"chunk_size countdown just went negative\n");
307 av_dlog(
NULL,
" opcode type %02X, version %d, 0x%04X bytes: ",
308 opcode_type, opcode_version, opcode_size);
309 switch (opcode_type) {
323 if ((opcode_version > 0) || (opcode_size > 6)) {
328 if (
avio_read(pb, scratch, opcode_size) !=
334 av_dlog(
NULL,
" %.2f frames/second (timer div = %d, subdiv = %d)\n",
341 if ((opcode_version > 1) || (opcode_size > 10)) {
346 if (
avio_read(pb, scratch, opcode_size) !=
352 audio_flags =
AV_RL16(&scratch[2]);
356 s->
audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
358 if ((opcode_version == 1) && (audio_flags & 0x4))
364 av_dlog(
NULL,
"audio: %d bits, %d Hz, %s, %s format\n",
368 "Interplay audio" :
"PCM");
378 if ((opcode_version > 2) || (opcode_size > 8)) {
383 if (
avio_read(pb, scratch, opcode_size) !=
388 width =
AV_RL16(&scratch[0]) * 8;
389 height =
AV_RL16(&scratch[2]) * 8;
398 if (opcode_version < 2 || !
AV_RL16(&scratch[6])) {
414 av_dlog(
NULL,
"unknown (but documented) opcode %02X\n", opcode_type);
451 if (opcode_size > 0x304) {
452 av_dlog(
NULL,
"demux_ipmovie: set_palette opcode too large\n");
456 if (
avio_read(pb, scratch, opcode_size) != opcode_size) {
462 first_color =
AV_RL16(&scratch[0]);
463 last_color = first_color +
AV_RL16(&scratch[2]) - 1;
465 if ((first_color > 0xFF) || (last_color > 0xFF)) {
466 av_dlog(
NULL,
"demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
467 first_color, last_color);
472 for (i = first_color; i <= last_color; i++) {
475 r = scratch[j++] * 4;
476 g = scratch[j++] * 4;
477 b = scratch[j++] * 4;
478 s->
palette[i] = (r << 16) | (g << 8) | (
b);
524 static const char signature[] =
"Interplay MVE File\x1A\0\x1A";
547 uint8_t signature_buffer[
sizeof(
signature)];
549 avio_read(pb, signature_buffer,
sizeof(signature_buffer));
551 memmove(signature_buffer, signature_buffer + 1,
sizeof(signature_buffer) - 1);
552 signature_buffer[
sizeof(signature_buffer) - 1] =
avio_r8(pb);
573 chunk_type =
AV_RL16(&chunk_preamble[2]);
#define OPCODE_SET_PALETTE_COMPRESSED
int64_t decode_map_chunk_offset
#define OPCODE_UNKNOWN_06
#define OPCODE_SEND_BUFFER
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define OPCODE_VIDEO_DATA
int64_t pos
byte position in stream, -1 if unknown
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define OPCODE_UNKNOWN_14
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
#define OPCODE_CREATE_GRADIENT
static int ipmovie_probe(AVProbeData *p)
static const char signature[]
#define OPCODE_UNKNOWN_12
int64_t audio_chunk_offset
unsigned int audio_channels
static int read_header(FFV1Context *f)
int decode_map_chunk_size
void av_free_packet(AVPacket *pkt)
Free a packet.
int64_t next_chunk_offset
#define AVERROR_EOF
End of file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
unsigned int video_height
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define OPCODE_INIT_AUDIO_BUFFERS
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
#define OPCODE_UNKNOWN_13
#define OPCODE_SET_DECODING_MAP
#define OPCODE_END_OF_CHUNK
int avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int bit_rate
the average bitrate
#define OPCODE_UNKNOWN_10
int width
picture width / height.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
#define OPCODE_PREAMBLE_SIZE
#define OPCODE_START_STOP_AUDIO
#define OPCODE_UNKNOWN_0E
static int read_probe(AVProbeData *p)
#define OPCODE_END_OF_STREAM
static int ipmovie_read_header(AVFormatContext *s, AVFormatParameters *ap)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
#define OPCODE_INIT_VIDEO_MODE
enum AVMediaType codec_type
int sample_rate
samples per second
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
#define OPCODE_INIT_VIDEO_BUFFERS
struct IPMVEContext IPMVEContext
int64_t video_chunk_offset
This structure contains the data a format has to probe a file.
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
#define OPCODE_AUDIO_FRAME
#define OPCODE_CREATE_TIMER
#define OPCODE_SILENCE_FRAME
#define CHUNK_PREAMBLE_SIZE
AVInputFormat ff_ipmovie_demuxer
CodecID
Identify the syntax and semantics of the bitstream.
int eof_reached
true if eof reached
#define OPCODE_SET_PALETTE
int channels
number of audio channels
unsigned int audio_frame_count
void * priv_data
Format private data.
#define OPCODE_UNKNOWN_15
static int ipmovie_read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned int audio_sample_rate
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...