Go to the documentation of this file.
41 #define CHUNK_PREAMBLE_SIZE 4
42 #define OPCODE_PREAMBLE_SIZE 4
44 #define CHUNK_INIT_AUDIO 0x0000
45 #define CHUNK_AUDIO_ONLY 0x0001
46 #define CHUNK_INIT_VIDEO 0x0002
47 #define CHUNK_VIDEO 0x0003
48 #define CHUNK_SHUTDOWN 0x0004
49 #define CHUNK_END 0x0005
51 #define CHUNK_HAVE_PACKET 0xFFFB
52 #define CHUNK_DONE 0xFFFC
53 #define CHUNK_NOMEM 0xFFFD
54 #define CHUNK_EOF 0xFFFE
55 #define CHUNK_BAD 0xFFFF
57 #define OPCODE_END_OF_STREAM 0x00
58 #define OPCODE_END_OF_CHUNK 0x01
59 #define OPCODE_CREATE_TIMER 0x02
60 #define OPCODE_INIT_AUDIO_BUFFERS 0x03
61 #define OPCODE_START_STOP_AUDIO 0x04
62 #define OPCODE_INIT_VIDEO_BUFFERS 0x05
63 #define OPCODE_VIDEO_DATA_06 0x06
64 #define OPCODE_SEND_BUFFER 0x07
65 #define OPCODE_AUDIO_FRAME 0x08
66 #define OPCODE_SILENCE_FRAME 0x09
67 #define OPCODE_INIT_VIDEO_MODE 0x0A
68 #define OPCODE_CREATE_GRADIENT 0x0B
69 #define OPCODE_SET_PALETTE 0x0C
70 #define OPCODE_SET_PALETTE_COMPRESSED 0x0D
71 #define OPCODE_SET_SKIP_MAP 0x0E
72 #define OPCODE_SET_DECODING_MAP 0x0F
73 #define OPCODE_VIDEO_DATA_10 0x10
74 #define OPCODE_VIDEO_DATA_11 0x11
75 #define OPCODE_UNKNOWN_12 0x12
76 #define OPCODE_UNKNOWN_13 0x13
77 #define OPCODE_UNKNOWN_14 0x14
78 #define OPCODE_UNKNOWN_15 0x15
80 #define PALETTE_COUNT 256
126 if (
s->audio_chunk_offset &&
s->audio_channels &&
s->audio_bits) {
129 "audio codec is known\n");
135 s->audio_chunk_offset += 6;
136 s->audio_chunk_size -= 6;
139 avio_seek(pb,
s->audio_chunk_offset, SEEK_SET);
140 s->audio_chunk_offset = 0;
146 pkt->
pts =
s->audio_frame_count;
150 s->audio_frame_count +=
151 (
s->audio_chunk_size /
s->audio_channels / (
s->audio_bits / 8));
153 s->audio_frame_count +=
154 (
s->audio_chunk_size - 6 -
s->audio_channels) /
s->audio_channels;
157 pkt->
pts,
s->audio_frame_count);
161 }
else if (
s->frame_format) {
165 if (
av_new_packet(
pkt, 8 +
s->decode_map_chunk_size +
s->video_chunk_size +
s->skip_map_chunk_size))
168 if (
s->has_palette) {
193 pkt->
pos =
s->video_chunk_offset;
194 avio_seek(pb,
s->video_chunk_offset, SEEK_SET);
195 s->video_chunk_offset = 0;
198 s->video_chunk_size) {
202 if (
s->decode_map_chunk_size) {
203 pkt->
pos =
s->decode_map_chunk_offset;
204 avio_seek(pb,
s->decode_map_chunk_offset, SEEK_SET);
205 s->decode_map_chunk_offset = 0;
208 s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
213 if (
s->skip_map_chunk_size) {
214 pkt->
pos =
s->skip_map_chunk_offset;
215 avio_seek(pb,
s->skip_map_chunk_offset, SEEK_SET);
216 s->skip_map_chunk_offset = 0;
219 s->skip_map_chunk_size) !=
s->skip_map_chunk_size) {
224 s->video_chunk_size = 0;
225 s->decode_map_chunk_size = 0;
226 s->skip_map_chunk_size = 0;
233 s->video_pts +=
s->frame_pts_inc;
239 avio_seek(pb,
s->next_chunk_offset, SEEK_SET);
279 unsigned char opcode_type;
280 unsigned char opcode_version;
282 unsigned char scratch[1024];
284 int first_color, last_color;
286 unsigned char r,
g,
b;
300 chunk_size =
AV_RL16(&chunk_preamble[0]);
301 chunk_type =
AV_RL16(&chunk_preamble[2]);
305 switch (chunk_type) {
338 while ((chunk_size > 0) && (chunk_type !=
CHUNK_BAD)) {
351 opcode_size =
AV_RL16(&opcode_preamble[0]);
352 opcode_type = opcode_preamble[2];
353 opcode_version = opcode_preamble[3];
356 chunk_size -= opcode_size;
357 if (chunk_size < 0) {
364 opcode_type, opcode_version, opcode_size);
365 switch (opcode_type) {
379 if ((opcode_version > 0) || (opcode_size != 6)) {
384 if (
avio_read(pb, scratch, opcode_size) !=
389 s->frame_pts_inc = ((uint64_t)
AV_RL32(&scratch[0])) *
AV_RL16(&scratch[4]);
394 if (opcode_version > 1 || opcode_size > 10 || opcode_size < 6) {
399 if (
avio_read(pb, scratch, opcode_size) !=
404 s->audio_sample_rate =
AV_RL16(&scratch[4]);
405 audio_flags =
AV_RL16(&scratch[2]);
407 s->audio_channels = (audio_flags & 1) + 1;
409 s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
411 if ((opcode_version == 1) && (audio_flags & 0x4))
413 else if (
s->audio_bits == 16)
418 s->audio_bits,
s->audio_sample_rate,
419 (
s->audio_channels == 2) ?
"stereo" :
"mono",
421 "Interplay audio" :
"PCM");
431 if ((opcode_version > 2) || (opcode_size > 8) || opcode_size < 4
432 || opcode_version == 2 && opcode_size < 8
438 if (
avio_read(pb, scratch, opcode_size) !=
445 if (
width !=
s->video_width) {
449 if (
height !=
s->video_height) {
453 if (opcode_version < 2 || !
AV_RL16(&scratch[6])) {
459 s->video_width,
s->video_height);
481 s->audio_chunk_size = opcode_size;
504 if (opcode_size > 0x304 || opcode_size < 4) {
509 if (
avio_read(pb, scratch, opcode_size) != opcode_size) {
515 first_color =
AV_RL16(&scratch[0]);
516 last_color = first_color +
AV_RL16(&scratch[2]) - 1;
518 if ( (first_color > 0xFF) || (last_color > 0xFF)
519 || (last_color - first_color + 1)*3 + 4 > opcode_size) {
520 av_log(
s->avf,
AV_LOG_TRACE,
"demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
521 first_color, last_color);
526 for (
i = first_color;
i <= last_color;
i++) {
529 r = scratch[j++] * 4;
530 g = scratch[j++] * 4;
531 b = scratch[j++] * 4;
532 s->palette[
i] = (0xFF
U << 24) | (
r << 16) | (
g << 8) | (
b);
533 s->palette[
i] |=
s->palette[
i] >> 6 & 0x30303;
548 s->skip_map_chunk_size = opcode_size;
557 s->decode_map_chunk_size = opcode_size;
564 s->frame_format = opcode_type;
570 s->video_chunk_size = opcode_size;
582 if (
s->avf->nb_streams == 1 &&
s->audio_type)
591 static const char signature[] =
"Interplay MVE File\x1A\0\x1A";
595 const uint8_t *
b = p->
buf;
613 uint8_t signature_buffer[
sizeof(
signature)];
617 avio_read(pb, signature_buffer,
sizeof(signature_buffer));
619 memmove(signature_buffer, signature_buffer + 1,
sizeof(signature_buffer) - 1);
620 signature_buffer[
sizeof(signature_buffer) - 1] =
avio_r8(pb);
628 for (
i = 0;
i < 256;
i++)
641 chunk_type =
AV_RL16(&chunk_preamble[2]);
#define OPCODE_CREATE_GRADIENT
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
#define AVERROR_EOF
End of file.
#define OPCODE_UNKNOWN_12
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int64_t next_chunk_offset
int buf_size
Size of buf except extra allocated bytes.
#define OPCODE_SET_PALETTE_COMPRESSED
enum AVCodecID audio_type
#define OPCODE_INIT_AUDIO_BUFFERS
static int ipmovie_read_header(AVFormatContext *s)
#define OPCODE_UNKNOWN_14
static int ipmovie_probe(const AVProbeData *p)
int64_t audio_chunk_offset
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const char signature[]
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define OPCODE_VIDEO_DATA_06
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define OPCODE_START_STOP_AUDIO
#define OPCODE_PREAMBLE_SIZE
#define OPCODE_END_OF_STREAM
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
unsigned int video_height
#define OPCODE_END_OF_CHUNK
int64_t decode_map_chunk_offset
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
int decode_map_chunk_size
@ AV_CODEC_ID_INTERPLAY_VIDEO
@ AV_CODEC_ID_INTERPLAY_DPCM
unsigned int audio_frame_count
int64_t skip_map_chunk_offset
This structure contains the data a format has to probe a file.
#define OPCODE_SET_SKIP_MAP
AVChannelLayout ch_layout
Audio only.
#define OPCODE_UNKNOWN_13
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
static int init_audio(AVFormatContext *s)
#define OPCODE_INIT_VIDEO_BUFFERS
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height)
Add side data to a packet for changing parameters to the given values.
#define OPCODE_SET_DECODING_MAP
int avio_r8(AVIOContext *s)
const AVInputFormat ff_ipmovie_demuxer
#define OPCODE_INIT_VIDEO_MODE
unsigned int audio_channels
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
#define OPCODE_VIDEO_DATA_10
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define OPCODE_SILENCE_FRAME
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
#define OPCODE_VIDEO_DATA_11
int block_align
Audio only.
#define OPCODE_CREATE_TIMER
#define OPCODE_AUDIO_FRAME
#define OPCODE_UNKNOWN_15
static int ipmovie_read_packet(AVFormatContext *s, AVPacket *pkt)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
#define CHUNK_PREAMBLE_SIZE
int index
stream index in AVFormatContext
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
unsigned int audio_sample_rate
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define CHUNK_HAVE_PACKET
#define OPCODE_SET_PALETTE
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int64_t video_chunk_offset
static int read_probe(const AVProbeData *p)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define OPCODE_SEND_BUFFER
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.