24 #include "libavutil/avstring.h"
25 #include "libavutil/channel_layout.h"
27 #include "libavutil/intreadwrite.h"
28 #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);
135 if ((startpos + header_size) >=
avio_tell(pb) + 2) {
141 if ((startpos + header_size) >
avio_tell(pb))
150 int flavor, sub_packet_h, coded_framesize, sub_packet_size;
151 int codecdata_length;
218 if(sub_packet_size <= 0){
236 if (codecdata_length >= 1) {
297 if (v ==
MKTAG(0xfd,
'a',
'r',
'.')) {
301 }
else if (v ==
MKBETAG(
'L',
'S',
'D',
':')) {
336 0x10000, fps, (1 << 30) - 1);
356 unsigned int size, n_pkts, str_id, next_off, n, pos, pts;
376 "Invalid stream index %d for index at pos %"PRId64
"\n",
381 "Nr. of packets in packet index for stream index %d "
382 "exceeds filesize (%"PRId64
" at %"PRId64
" = %"PRId64
")\n",
388 for (n = 0; n < n_pkts; n++) {
398 if (next_off &&
avio_tell(pb) < next_off &&
401 "Non-linear index detected, not supported\n");
430 unsigned int data_off = 0, indx_off = 0;
435 if (tag ==
MKTAG(
'.',
'r',
'a', 0xfd)) {
438 }
else if (tag !=
MKTAG(
'.',
'R',
'M',
'F')) {
451 av_dlog(s,
"tag=%c%c%c%c (%08x) size=%d\n",
458 if (tag_size < 10 && tag !=
MKTAG(
'D',
'A',
'T',
'A'))
461 case MKTAG(
'P',
'R',
'O',
'P'):
475 case MKTAG(
'C',
'O',
'N',
'T'):
478 case MKTAG(
'M',
'D',
'P',
'R'):
500 case MKTAG(
'D',
'A',
'T',
'A'):
517 avio_seek(pb, indx_off, SEEK_SET) >= 0) {
537 return (n << 16) | n1;
542 #define RAW_PACKET_SIZE 1000
548 uint32_t
state=0xFFFFFFFF;
559 state= (state<<8) +
avio_r8(pb);
561 if(state ==
MKBETAG(
'I',
'N',
'D',
'X')){
562 int n_pkts, expected_len;
566 expected_len = 20 + n_pkts * 14;
570 else if (len != expected_len)
572 "Index size %d (%d pkts) is wrong, should be %d.\n",
573 len, n_pkts, expected_len);
578 }
else if (state ==
MKBETAG(
'D',
'A',
'T',
'A')) {
580 "DATA tag in middle of chunk, file may be broken.\n");
583 if(state > (
unsigned)0xFFFF || state <= 12)
617 int hdr, seq, pic_num, len2, pos;
653 if((seq & 0x7F) == 1 || vst->
curpic_num != pic_num){
654 vst->
slices = ((hdr & 0x3F) << 1) + 1;
665 len =
FFMIN(len, pos);
684 #if FF_API_DESTRUCT_PACKET
710 for (j=0;j<pkt->
size;j+=2) {
711 FFSWAP(
int, ptr[0], ptr[1]);
720 int *seq,
int flags, int64_t timestamp)
746 for (x = 0; x < h/2; x++)
750 for (x = 0; x < w/sps; x++)
790 int seq= 128*(pkt->
data[2]&0x7F) + (pkt->
data[3]>>1);
793 seq |= (timestamp&~0x3FFF);
794 if(seq - timestamp > 0x2000) seq -= 0x4000;
795 if(seq - timestamp < -0x2000) seq += 0x4000;
800 pkt->
pts = timestamp;
839 int i,
len, res, seq = 1;
840 int64_t timestamp, pos;
858 flags = (seq++ == 1) ? 2 : 0;
861 len=
sync(s, ×tamp, &flags, &i, &pos);
866 if(len<0 || s->pb->eof_reached)
870 &seq, flags, timestamp);
871 if((flags&2) && (seq&0x7F) == 1)
900 if ((p->
buf[0] ==
'.' && p->
buf[1] ==
'R' &&
901 p->
buf[2] ==
'M' && p->
buf[3] ==
'F' &&
902 p->
buf[4] == 0 && p->
buf[5] == 0) ||
903 (p->
buf[0] ==
'.' && p->
buf[1] ==
'r' &&
904 p->
buf[2] ==
'a' && p->
buf[3] == 0xfd))
911 int64_t *ppos, int64_t pos_limit)
928 len=
sync(s, &dts, &flags, &stream_index2, &pos);
932 st = s->
streams[stream_index2];
940 if((flags&2) && (seq&0x7F) == 1){
941 av_dlog(s,
"%d %d-%d %"PRId64
" %d\n",
942 flags, stream_index2, stream_index, dts, seq);
944 if(stream_index2 == stream_index)
static int get_num(AVIOContext *pb, int *len)
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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
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.
Opaque data information usually continuous.
#define MKBETAG(a, b, c, d)
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 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...
#define DEINT_ID_GENR
interleaving for Cooker/ATRAC
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.
static int64_t start_time
#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.
int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, int codec_data_size)
Read the MDPR chunk, which contains stream-specific codec initialization parameters.
#define DEINT_ID_VBRF
VBR case for AAC.
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 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
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
int width
picture width / height.
AVInputFormat ff_rm_demuxer
AVStream ** streams
A list of all streams in the file.
#define FF_ARRAY_ELEMS(a)
#define DEINT_ID_INT4
interleaving for 28.8
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
#define DEINT_ID_SIPR
interleaving for Sipro
int sample_rate
samples per second
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)
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
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.
AVDictionary * metadata
Metadata that applies to the whole file.
This structure contains the data a format has to probe a file.
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]
AVInputFormat ff_rdt_demuxer
#define MKTAG(a, b, c, d)
void ff_rm_free_rmstream(RMStream *rms)
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.
#define FFSWAP(type, a, b)
int64_t start_time
Decoding: pts of the first frame of the stream, 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)
int eof_reached
true if eof reached
#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)
int64_t audiotimestamp
Audio descrambling matrix parameters.
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.
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 ...