37 #define MAX_AUDIO_SUBPACKETS 100 77 if (memcmp(p->
buf,
"vividas03", 9))
84 20, 52, 111, 10, 27, 71, 142, 53,
85 82, 138, 1, 78, 86, 121, 183, 85,
86 105, 152, 39, 140, 172, 11, 64, 144,
87 155, 6, 71, 163, 186, 49, 126, 43,
94 for (
int i = 0;
i < 32;
i++) {
96 key |= ((buf[p] >> ((
i*5+3)&7)) & 1
u) <<
i;
105 *p++ = ((v>>28)&0x7f)|0x80;
107 *p++ = ((v>>21)&0x7f)|0x80;
109 *p++ = ((v>>14)&0x7f)|0x80;
111 *p++ = ((v>>7)&0x7f)|0x80;
116 unsigned char plaintext[8] = {
'S',
'B' };
118 put_v(plaintext+2, expected_size);
127 unsigned k = *key_ptr;
143 uint32_t
key, uint32_t *key_ptr,
154 a2 = (4 - align) & 3;
157 uint32_t tmpkey = *key_ptr -
key;
162 memcpy(tmp + align, src, a2);
164 memcpy(dest, tmp + align, a2);
176 memcpy(tmp, src + size, s);
178 memcpy(dest + size, tmp, s);
188 if (p >= end || v >= UINT_MAX / 128 - *p)
192 }
while (*p++ & 0x80);
198 uint32_t
key, uint32_t *k2,
int align)
233 uint32_t *
key,
unsigned expected_size)
246 n =
get_v(sbuf+2, 6);
248 if (sbuf[0] !=
'S' || sbuf[1] !=
'B' || (expected_size>0 && n != expected_size)) {
249 uint32_t tmpkey =
recover_key(ibuf, expected_size);
252 n =
get_v(sbuf+2, 6);
253 if (sbuf[0] !=
'S' || sbuf[1] !=
'B' || expected_size != n)
265 memcpy(buf, sbuf, 8);
295 for (i=0;i<val_1;i++) {
316 if (num_video != 1) {
321 for (i = 0; i < num_video; i++) {
364 st->
id = num_video +
i;
393 for (j = 0; j < num_data; j++) {
395 if (len < 0 || len > INT_MAX/2 - xd_size) {
399 xd_size += len + 1 + len/255;
409 for (j = 0; j < num_data - 1; j++) {
415 for (j = 0; j < num_data; j++) {
416 int ret =
avio_read(pb, &p[offset], data_len[j]);
417 if (ret < data_len[j]) {
423 offset += data_len[j];
426 if (offset < st->codecpar->extradata_size)
442 uint64_t n_sb_blocks_tmp;
449 if (n_sb_blocks_tmp > size / 2)
464 if (size_tmp > INT_MAX || n_packets_tmp > INT_MAX)
480 if (filesize > 0 && poff > filesize)
543 uint32_t b22_size = 0;
544 uint32_t b22_key = 0;
556 if (num_tracks != 1) {
572 int block_len, block_type;
574 if (here >= header_end)
583 if (block_type == 22) {
589 avio_seek(pb, here + block_len, SEEK_SET);
686 int last = 0, last_start;
692 if (v_size > INT_MAX || !v_size)
704 int start, pcm_bytes;
708 if (
i > 0 && start == 0)
720 if (last_start < last)
727 if (v_size > INT_MAX || !v_size)
760 if (stream_index == 0)
uint64_t ffio_read_varlen(AVIOContext *bc)
static uint8_t * read_vblock(AVIOContext *src, uint32_t *size, uint32_t key, uint32_t *k2, int align)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static uint32_t get_v(uint8_t *p, int len)
static void decode_block(uint8_t *src, uint8_t *dest, unsigned size, uint32_t key, uint32_t *key_ptr, int align)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
#define avpriv_request_sample(...)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static unsigned recover_key(unsigned char sample[4], unsigned expected_size)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_cold int end(AVCodecContext *avctx)
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define u(width, name, range_min, range_max)
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static const uint8_t plaintext[8]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * read_sb_block(AVIOContext *src, unsigned *size, uint32_t *key, unsigned expected_size)
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVMediaType codec_type
General type of the encoded data.
static int viv_read_header(AVFormatContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
static const uint8_t offset[127][2]
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
VIV_SB_entry * sb_entries
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int viv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
AVInputFormat ff_vividas_demuxer
static void xor_block(void *p1, void *p2, unsigned size, int key, unsigned *key_ptr)
#define MAX_AUDIO_SUBPACKETS
int current_audio_subpacket
static int read_header(FFV1Context *f)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVIOContext * pb
I/O context.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static uint32_t decode_key(uint8_t *buf)
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
static int viv_read_packet(AVFormatContext *s, AVPacket *pkt)
This structure contains the data a format has to probe a file.
#define flags(name, subs,...)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int sample_rate
Audio only.
unsigned int avio_rl16(AVIOContext *s)
static void load_sb_block(AVFormatContext *s, VividasDemuxContext *viv, unsigned expected_size)
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int64_t nb_frames
number of frames in this stream if known or 0
static int viv_read_close(AVFormatContext *s)
static int viv_probe(const AVProbeData *p)
void * priv_data
Format private data.
static int track_header(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static const uint8_t keybits[32]
VIV_AudioSubpacket audio_subpackets[MAX_AUDIO_SUBPACKETS]
static int track_index(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *buf, unsigned size)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static void put_v(uint8_t *p, unsigned v)