39#define MAX_AUDIO_SUBPACKETS 100
79 if (memcmp(p->buf,
"vividas03", 9))
86 20, 52, 111, 10, 27, 71, 142, 53,
87 82, 138, 1, 78, 86, 121, 183, 85,
88105, 152, 39, 140, 172, 11, 64, 144,
89155, 6, 71, 163, 186, 49, 126, 43,
96 for (
int i = 0;
i < 32;
i++) {
98 key |= ((buf[p] >> ((
i*5+3)&7)) & 1u) <<
i;
104static void put_v(uint8_t *p,
unsigned v)
107 *p++ = ((v>>28)&0x7f)|0x80;
109 *p++ = ((v>>21)&0x7f)|0x80;
111 *p++ = ((v>>14)&0x7f)|0x80;
113 *p++ = ((v>>7)&0x7f)|0x80;
118 unsigned char plaintext[8] = {
'S',
'B' };
129 unsigned k = *key_ptr;
145 uint32_t
key, uint32_t *key_ptr,
159 uint32_t tmpkey = *key_ptr -
key;
187 const uint8_t *end = p +
len;
190 if (p >= end || v >= UINT_MAX / 128 - *p)
194 }
while (*p++ & 0x80);
200 uint32_t
key, uint32_t *k2,
int align)
235 uint32_t *
key,
unsigned expected_size)
238 uint8_t ibuf[8], sbuf[8];
248 n =
get_v(sbuf+2, 6);
250 if (sbuf[0] !=
'S' || sbuf[1] !=
'B' || (expected_size>0 && n != expected_size)) {
251 uint32_t tmpkey =
recover_key(ibuf, expected_size);
254 n =
get_v(sbuf+2, 6);
255 if (sbuf[0] !=
'S' || sbuf[1] !=
'B' || expected_size != n)
267 memcpy(buf, sbuf, 8);
283 const uint8_t *buf,
int size)
299 for (
i=0;
i<val_1;
i++) {
320 if (num_video != 1) {
325 for (
i = 0;
i < num_video;
i++) {
368 st->
id = num_video +
i;
397 for (j = 0; j < num_data; j++) {
403 xd_size +=
len + 1 +
len/255;
413 for (j = 0; j < num_data - 1; j++) {
419 for (j = 0; j < num_data; j++) {
421 if (ret < data_len[j]) {
439 const uint8_t *buf,
unsigned size)
448 uint64_t n_sb_blocks_tmp;
455 if (n_sb_blocks_tmp >
size / 2)
470 if (size_tmp > INT_MAX || n_packets_tmp > INT_MAX)
482 if (maxnp < viv->sb_blocks[
i].n_packets)
548 uint8_t keybuffer[187];
549 uint32_t b22_size = 0;
550 uint32_t b22_key = 0;
562 if (num_tracks != 1) {
580 int block_len, block_type;
582 if (here >= header_end)
591 if (block_type == 22) {
599 avio_seek(pb, here + block_len, SEEK_SET);
662 pkt->stream_index = 1;
663 astream =
s->streams[
pkt->stream_index];
694 int last = 0, last_start;
700 if (v_size > INT_MAX || !v_size)
709 pkt->stream_index = 0;
712 int start, pcm_bytes;
716 if (
i > 0 && start == 0)
728 if (last_start < last) {
737 if (v_size > INT_MAX || !v_size)
745 pkt->stream_index = 0;
770 if (stream_index == 0)
773 frame =
av_rescale_q(timestamp,
s->streams[0]->time_base,
s->streams[stream_index]->time_base);
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
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, const 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.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rl32(AVIOContext *s)
int avio_r8(AVIOContext *s)
uint64_t ffio_read_varlen(AVIOContext *bc)
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static const uint8_t *BS_FUNC align(BSCTX *bc)
Skip bits to a byte boundary.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int64_t filesize(AVIOContext *pb)
static int read_header(FFV1Context *f, RangeCoder *c)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int nb_channels
Number of channels in this layout.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
int height
The height of the video frame in pixels.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t nb_frames
number of frames in this stream if known or 0
int id
Format-specific stream ID.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
VIV_SB_entry * sb_entries
int current_audio_subpacket
VIV_AudioSubpacket audio_subpackets[MAX_AUDIO_SUBPACKETS]
#define avpriv_request_sample(...)
static attribute_nonstring const uint8_t plaintext[8]
static double a2(void *priv, double x, double y)
static int viv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int track_index(VividasDemuxContext *viv, AVFormatContext *s, const uint8_t *buf, unsigned size)
static uint8_t * read_sb_block(AVIOContext *src, unsigned *size, uint32_t *key, unsigned expected_size)
static int viv_read_close(AVFormatContext *s)
static void load_sb_block(AVFormatContext *s, VividasDemuxContext *viv, unsigned expected_size)
static int viv_read_header(AVFormatContext *s)
static void decode_block(uint8_t *src, uint8_t *dest, unsigned size, uint32_t key, uint32_t *key_ptr, int align)
static int viv_read_packet(AVFormatContext *s, AVPacket *pkt)
static const uint8_t keybits[32]
static int track_header(VividasDemuxContext *viv, AVFormatContext *s, const uint8_t *buf, int size)
static int viv_probe(const AVProbeData *p)
#define MAX_AUDIO_SUBPACKETS
static uint32_t decode_key(uint8_t *buf)
static unsigned recover_key(unsigned char sample[4], unsigned expected_size)
static uint32_t get_v(uint8_t *p, int len)
static uint8_t * read_vblock(AVIOContext *src, uint32_t *size, uint32_t key, uint32_t *k2, int align)
static void put_v(uint8_t *p, unsigned v)
static void xor_block(void *p1, void *p2, unsigned size, int key, unsigned *key_ptr)