36 #define DEINT_ID_GENR MKTAG('g', 'e', 'n', 'r')
37 #define DEINT_ID_INT0 MKTAG('I', 'n', 't', '0')
38 #define DEINT_ID_INT4 MKTAG('I', 'n', 't', '4')
39 #define DEINT_ID_SIPR MKTAG('s', 'i', 'p', 'r')
40 #define DEINT_ID_VBRF MKTAG('v', 'b', 'r', 'f')
41 #define DEINT_ID_VBRS MKTAG('v', 'b', 'r', 's')
81 if (buf_size > 0) *q =
'\0';
107 get_strl(pb, buf,
sizeof(buf), len);
136 unsigned bytes_per_minute;
143 if ((startpos + header_size) >=
avio_tell(pb) + 2) {
149 if ((startpos + header_size) >
avio_tell(pb))
151 if (bytes_per_minute)
160 int flavor, sub_packet_h, coded_framesize, sub_packet_size;
161 int codecdata_length;
162 unsigned bytes_per_minute;
174 if (bytes_per_minute)
217 codecdata_length = 0;
238 if(sub_packet_size <= 0){
257 if (codecdata_length >= 1) {
314 unsigned int codec_data_size,
const uint8_t *mime)
321 if (codec_data_size > INT_MAX)
323 if (codec_data_size == 0)
330 if (v ==
MKTAG(0xfd,
'a',
'r',
'.')) {
334 }
else if (v ==
MKBETAG(
'L',
'S',
'D',
':')) {
343 }
else if(mime && !strcmp(mime,
"logical-fileinfo")){
344 int stream_count, rule_count, property_count, i;
355 for(i=0; i<property_count; i++){
396 0x10000, fps, (1 << 30) - 1);
397 #if FF_API_R_FRAME_RATE
409 if (codec_data_size >= size) {
423 unsigned int size, n_pkts, str_id, next_off,
n, pos,
pts;
443 "Invalid stream index %d for index at pos %"PRId64
"\n",
448 "Nr. of packets in packet index for stream index %d "
449 "exceeds filesize (%"PRId64
" at %"PRId64
" = %"PRId64
")\n",
455 for (n = 0; n < n_pkts; n++) {
465 if (next_off &&
avio_tell(pb) < next_off &&
468 "Non-linear index detected, not supported\n");
499 unsigned int data_off = 0, indx_off = 0;
500 char buf[128], mime[128];
507 if (tag ==
MKTAG(
'.',
'r',
'a', 0xfd)) {
510 }
else if (tag !=
MKTAG(
'.',
'R',
'M',
'F')) {
530 if (tag_size < 10 && tag !=
MKTAG(
'D',
'A',
'T',
'A'))
533 case MKTAG(
'P',
'R',
'O',
'P'):
548 case MKTAG(
'C',
'O',
'N',
'T'):
551 case MKTAG(
'M',
'D',
'P',
'R'):
581 if (v ==
MKBETAG(
'M',
'L',
'T',
'I')) {
586 for (i = 0; i<number_of_streams; i++)
589 if (number_of_mdpr != 1) {
592 for (i = 0; i < number_of_mdpr; i++) {
600 st2->
id = st->
id + (i<<16);
616 avio_seek(pb, codec_pos + size, SEEK_SET);
625 case MKTAG(
'D',
'A',
'T',
'A'):
642 avio_seek(pb, indx_off, SEEK_SET) >= 0) {
666 return (n << 16) | n1;
671 #define RAW_PACKET_SIZE 1000
677 uint32_t
state=0xFFFFFFFF;
690 state= (state<<8) +
avio_r8(pb);
692 if(state ==
MKBETAG(
'I',
'N',
'D',
'X')){
693 int n_pkts, expected_len;
697 expected_len = 20 + n_pkts * 14;
701 else if (len != expected_len)
703 "Index size %d (%d pkts) is wrong, should be %d.\n",
704 len, n_pkts, expected_len);
709 }
else if (state ==
MKBETAG(
'D',
'A',
'T',
'A')) {
711 "DATA tag in middle of chunk, file may be broken.\n");
714 if(state > (
unsigned)0xFFFF || state <= 12)
721 mlti_id = (
avio_r8(pb)>>1)-1<<16;
722 mlti_id =
FFMAX(mlti_id, 0);
727 if (mlti_id + num == st->
id)
750 int seq = 0, pic_num = 0, len2 = 0, pos = 0;
788 return ret < 0 ? ret :
AVERROR(EIO);
795 if((seq & 0x7F) == 1 || vst->
curpic_num != pic_num){
800 vst->
slices = ((hdr & 0x3F) << 1) + 1;
812 len =
FFMIN(len, pos);
837 #if FF_API_DESTRUCT_PACKET
863 for (j=0;j<pkt->
size;j+=2) {
864 FFSWAP(
int, ptr[0], ptr[1]);
873 if (ret >= 0) memset(dst + ret, 0, n - ret);
874 else memset(dst , 0, n);
883 int *seq,
int flags, int64_t timestamp)
892 return ret < 0 ? ret : -1;
911 for (x = 0; x < h/2; x++)
915 for (x = 0; x < w/sps; x++)
958 int seq= 128*(pkt->
data[2]&0x7F) + (pkt->
data[3]>>1);
961 seq |= (timestamp&~0x3FFF);
962 if(seq - timestamp > 0x2000) seq -= 0x4000;
963 if(seq - timestamp < -0x2000) seq += 0x4000;
968 pkt->
pts = timestamp;
1011 int i,
len, res, seq = 1;
1012 int64_t timestamp, pos;
1032 flags = (seq++ == 1) ? 2 : 0;
1035 len =
rm_sync(s, ×tamp, &flags, &i, &pos);
1044 &seq, flags, timestamp);
1047 if((flags&2) && (seq&0x7F) == 1)
1076 if ((p->
buf[0] ==
'.' && p->
buf[1] ==
'R' &&
1077 p->
buf[2] ==
'M' && p->
buf[3] ==
'F' &&
1078 p->
buf[4] == 0 && p->
buf[5] == 0) ||
1079 (p->
buf[0] ==
'.' && p->
buf[1] ==
'r' &&
1080 p->
buf[2] ==
'a' && p->
buf[3] == 0xfd))
1087 int64_t *ppos, int64_t pos_limit)
1106 len =
rm_sync(s, &dts, &flags, &stream_index2, &pos);
1110 st = s->
streams[stream_index2];
1118 if((flags&2) && (seq&0x7F) == 1){
1120 flags, stream_index2, stream_index, dts, seq);
1122 if(stream_index2 == stream_index)
static int get_num(AVIOContext *pb, int *len)
const char const char void * val
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_free_packet(AVPacket *pkt)
Free a packet.
#define DEINT_ID_INT0
no interleaving needed
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
static int64_t rm_read_dts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
const unsigned char ff_sipr_subpk_size[4]
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int rm_read_header(AVFormatContext *s)
unsigned int avio_rb16(AVIOContext *s)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
#define DEINT_ID_VBRS
VBR case for AAC.
int videobufpos
position for the next slice in the video buffer
int audio_stream_num
Stream number for audio packets.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ffio_limit(AVIOContext *s, int size)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int64_t start_time
Opaque data information usually continuous.
attribute_deprecated void(* destruct)(struct AVPacket *)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
int flags
Flags modifying the (de)muxer behaviour.
int curpic_num
picture number of current frame
static av_cold int read_close(AVFormatContext *ctx)
static int rm_read_index(AVFormatContext *s)
this function assumes that the demuxer has already seeked to the start of the INDX chunk...
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define DEINT_ID_GENR
interleaving for Cooker/ATRAC
static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, RMDemuxContext *rm, RMStream *vst, AVPacket *pkt, int len, int *pseq, int64_t *timestamp)
static void get_str8(AVIOContext *pb, char *buf, int buf_size)
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.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static int rm_read_close(AVFormatContext *s)
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
simple assert() macros that are a bit more flexible than ISO C assert().
#define DEINT_ID_VBRF
VBR case for AAC.
static int rm_sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos)
int64_t pktpos
first slice position in file
AVRational avg_frame_rate
Average framerate.
RMStream * ff_rm_alloc_rmstream(void)
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
common internal API header
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVPacket pkt
place to store merged video frame / reordered audio data
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
audio channel layout utility functions
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
static int readfull(AVFormatContext *s, AVIOContext *pb, uint8_t *dst, int n)
int width
picture width / height.
AVInputFormat ff_rm_demuxer
#define DEINT_ID_INT4
interleaving for 28.8
static int rm_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
#define FF_ARRAY_ELEMS(a)
int coded_framesize
Descrambling parameters from container.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void rm_ac3_swap_bytes(AVStream *st, AVPacket *pkt)
const AVCodecTag ff_rm_codec_tags[]
enum AVMediaType codec_type
#define DEINT_ID_SIPR
interleaving for Sipro
int sample_rate
samples per second
AVIOContext * pb
I/O context.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int rm_probe(AVProbeData *p)
int ff_rm_parse_packet(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int len, AVPacket *pkt, int *seq, int flags, int64_t timestamp)
Parse one rm-stream packet from the input bytestream.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, unsigned int codec_data_size, const uint8_t *mime)
Read the MDPR chunk, which contains stream-specific codec initialization parameters.
This structure contains the data a format has to probe a file.
int audio_pkt_cnt
Output packet counter.
static int64_t pts
Global timestamp for the audio frames.
const char *const ff_rm_metadata[4]
AVInputFormat ff_rdt_demuxer
void ff_rm_free_rmstream(RMStream *rms)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int64_t duration
Decoding: duration of the stream, in stream time base.
void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize)
Perform 4-bit block reordering for SIPR data.
#define FF_DISABLE_DEPRECATION_WARNINGS
int32_t deint_id
Length of each subpacket.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
int ff_rm_retrieve_cache(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, AVPacket *pkt)
Retrieve one cached packet from the rm-context.
static int rm_read_header_old(AVFormatContext *s)
#define MKBETAG(a, b, c, d)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_ENABLE_DEPRECATION_WARNINGS
int channels
number of audio channels
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int read_all)
void * priv_data
Format private data.
static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int64_t audiotimestamp
Audio descrambling matrix parameters.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define FFSWAP(type, a, b)
int videobufsize
current assembled frame size
#define AV_CH_LAYOUT_MONO
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
int sub_packet_lengths[16]
Audio frame size from container.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.