22 #include "libavutil/avassert.h"
23 #include "libavutil/avstring.h"
24 #include "libavutil/channel_layout.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/dict.h"
34 #define DEINT_ID_GENR MKTAG('g', 'e', 'n', 'r')
35 #define DEINT_ID_INT0 MKTAG('I', 'n', 't', '0')
36 #define DEINT_ID_INT4 MKTAG('I', 'n', 't', '4')
37 #define DEINT_ID_SIPR MKTAG('s', 'i', 'p', 'r')
38 #define DEINT_ID_VBRF MKTAG('v', 'b', 'r', 'f')
39 #define DEINT_ID_VBRS MKTAG('v', 'b', 'r', 's')
77 if (buf_size > 0) *q =
'\0';
104 get_strl(pb, buf,
sizeof(buf), len);
131 unsigned bytes_per_minute;
138 if ((startpos + header_size) >=
avio_tell(pb) + 2) {
144 if ((startpos + header_size) >
avio_tell(pb))
146 if (bytes_per_minute)
155 int flavor, sub_packet_h, coded_framesize, sub_packet_size;
156 int codecdata_length;
157 unsigned bytes_per_minute;
169 if (bytes_per_minute)
211 codecdata_length = 0;
232 if(sub_packet_size <= 0){
251 if (codecdata_length >= 1) {
314 if (v ==
MKTAG(0xfd,
'a',
'r',
'.')) {
318 }
else if (v ==
MKBETAG(
'L',
'S',
'D',
':')) {
327 }
else if(mime && !strcmp(mime,
"logical-fileinfo")){
328 int stream_count, rule_count, property_count, i;
339 for(i=0; i<property_count; i++){
380 0x10000, fps, (1 << 30) - 1);
381 #if FF_API_R_FRAME_RATE
403 unsigned int size, n_pkts, str_id, next_off,
n, pos, pts;
423 "Invalid stream index %d for index at pos %"PRId64
"\n",
428 "Nr. of packets in packet index for stream index %d "
429 "exceeds filesize (%"PRId64
" at %"PRId64
" = %"PRId64
")\n",
435 for (n = 0; n < n_pkts; n++) {
445 if (next_off &&
avio_tell(pb) < next_off &&
448 "Non-linear index detected, not supported\n");
477 unsigned int data_off = 0, indx_off = 0;
478 char buf[128], mime[128];
482 if (tag ==
MKTAG(
'.',
'r',
'a', 0xfd)) {
485 }
else if (tag !=
MKTAG(
'.',
'R',
'M',
'F')) {
498 av_dlog(s,
"tag=%c%c%c%c (%08x) size=%d\n",
505 if (tag_size < 10 && tag !=
MKTAG(
'D',
'A',
'T',
'A'))
508 case MKTAG(
'P',
'R',
'O',
'P'):
523 case MKTAG(
'C',
'O',
'N',
'T'):
526 case MKTAG(
'M',
'D',
'P',
'R'):
550 case MKTAG(
'D',
'A',
'T',
'A'):
567 avio_seek(pb, indx_off, SEEK_SET) >= 0) {
587 return (n << 16) | n1;
592 #define RAW_PACKET_SIZE 1000
598 uint32_t
state=0xFFFFFFFF;
609 state= (state<<8) +
avio_r8(pb);
611 if(state ==
MKBETAG(
'I',
'N',
'D',
'X')){
612 int n_pkts, expected_len;
616 expected_len = 20 + n_pkts * 14;
620 else if (len != expected_len)
622 "Index size %d (%d pkts) is wrong, should be %d.\n",
623 len, n_pkts, expected_len);
628 }
else if (state ==
MKBETAG(
'D',
'A',
'T',
'A')) {
630 "DATA tag in middle of chunk, file may be broken.\n");
633 if(state > (
unsigned)0xFFFF || state <= 12)
668 int seq = 0, pic_num = 0, len2 = 0, pos = 0;
706 return ret < 0 ? ret :
AVERROR(EIO);
713 if((seq & 0x7F) == 1 || vst->
curpic_num != pic_num){
718 vst->
slices = ((hdr & 0x3F) << 1) + 1;
730 len =
FFMIN(len, pos);
755 #if FF_API_DESTRUCT_PACKET
781 for (j=0;j<pkt->
size;j+=2) {
782 FFSWAP(
int, ptr[0], ptr[1]);
791 int *seq,
int flags, int64_t timestamp)
800 return ret < 0 ? ret : -1;
819 for (x = 0; x < h/2; x++)
823 for (x = 0; x < w/sps; x++)
863 int seq= 128*(pkt->
data[2]&0x7F) + (pkt->
data[3]>>1);
866 seq |= (timestamp&~0x3FFF);
867 if(seq - timestamp > 0x2000) seq -= 0x4000;
868 if(seq - timestamp < -0x2000) seq += 0x4000;
873 pkt->
pts = timestamp;
914 int64_t timestamp, pos;
934 flags = (seq++ == 1) ? 2 : 0;
937 len=
sync(s, ×tamp, &flags, &i, &pos);
946 &seq, flags, timestamp);
949 if((flags&2) && (seq&0x7F) == 1)
978 if ((p->
buf[0] ==
'.' && p->
buf[1] ==
'R' &&
979 p->
buf[2] ==
'M' && p->
buf[3] ==
'F' &&
980 p->
buf[4] == 0 && p->
buf[5] == 0) ||
981 (p->
buf[0] ==
'.' && p->
buf[1] ==
'r' &&
982 p->
buf[2] ==
'a' && p->
buf[3] == 0xfd))
989 int64_t *ppos, int64_t pos_limit)
1008 len=
sync(s, &dts, &flags, &stream_index2, &pos);
1012 st = s->
streams[stream_index2];
1020 if((flags&2) && (seq&0x7F) == 1){
1021 av_dlog(s,
"%d %d-%d %"PRId64
" %d\n",
1022 flags, stream_index2, stream_index, dts, seq);
1024 if(stream_index2 == stream_index)
1035 int64_t pts,
int flags)
static int get_num(AVIOContext *pb, int *len)
const char const char void * val
discard all frames except keyframes
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]
RMStream * ff_rm_alloc_rmstream(void)
#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)
AVCodecContext * codec
Codec context associated with this stream.
int index
stream index in AVFormatContext
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
static int rm_read_header(AVFormatContext *s)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
#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.
int ffio_limit(AVIOContext *s, int size)
static int64_t start_time
attribute_deprecated void(* destruct)(struct AVPacket *)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
int ff_rm_parse_packet(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, int len, AVPacket *pkt, int *seq, int flags, int64_t ts)
Parse one rm-stream packet from the input bytestream.
int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, int codec_data_size, const uint8_t *mime)
Read the MDPR chunk, which contains stream-specific codec initialization parameters.
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...
#define DEINT_ID_GENR
interleaving for Cooker/ATRAC
#define FFSWAP(type, a, b)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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)
#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.
static int rm_read_close(AVFormatContext *s)
void * priv_data
Format private data.
#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.
#define DEINT_ID_VBRF
VBR case for AAC.
int64_t pktpos
first slice position in file
AVRational avg_frame_rate
Average framerate.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
unsigned int nb_streams
A list of all streams in the file.
#define FF_ARRAY_ELEMS(a)
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
Opaque data information usually continuous.
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
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)
int coded_framesize
Descrambling parameters from container.
static int read_header(FFV1Context *f)
static void rm_ac3_swap_bytes(AVStream *st, AVPacket *pkt)
const AVCodecTag ff_rm_codec_tags[]
enum AVMediaType codec_type
int ff_rm_retrieve_cache(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, AVPacket *pkt)
Retrieve one cached packet from the rm-context.
#define DEINT_ID_SIPR
interleaving for Sipro
int sample_rate
samples per second
main external API structure.
#define AV_EF_EXPLODE
abort decoding on minor error detection
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int rm_probe(AVProbeData *p)
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define MKTAG(a, b, c, d)
This structure contains the data a format has to probe a file.
#define MKBETAG(a, b, c, d)
int audio_pkt_cnt
Output packet counter.
static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos)
const char *const ff_rm_metadata[4]
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...
void ff_rm_free_rmstream(RMStream *rms)
static int rm_read_header_old(AVFormatContext *s)
#define AVERROR_INVALIDDATA
#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)
static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
AVInputFormat ff_rdt_demuxer
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
int64_t audiotimestamp
Audio descrambling matrix parameters.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int videobufsize
current assembled frame size
#define AV_CH_LAYOUT_MONO
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.
This structure stores compressed data.
static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide)
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.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...