41 int64_t pos, avail_size;
66 if (size <= avail_size)
93 int fill_size, size1, frame_offset;
96 int64_t last_pos = -1;
142 seekback =
FFMAX(seekback, 0);
181 ff_dlog(s,
"seek to %"PRIx64
" -> %"PRIx64
"\n", pos1, pos);
193 ff_dlog(s,
"dts=%0.6f\n", dts / 1000000.0);
203 int64_t pos_min, pos_max;
211 pts_start =
get_dts(s, pos_min);
215 if (pts - 100000 > pts_start)
220 pts_start =
get_dts(s, pos_min);
224 if (pts - 100000 <= pts_start) {
231 if (newpos == pos_min)
236 if (newpts - 100000 <= pts) {
272 #define VALIDATE_PARAMETER(parameter, name, check) { \
274 av_log(s, AV_LOG_ERROR, "Invalid " name " %d\n", codecpar->parameter); \
275 ret = AVERROR_INVALIDDATA; \
289 int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
308 ffm->
file_size = (UINT64_C(1) << 63) - 1;
323 case MKBETAG(
'M',
'A',
'I',
'N'):
331 case MKBETAG(
'C',
'O',
'M',
'M'):
332 f_cprv = f_stvi = f_stau = 0;
367 #if FF_API_LAVF_AVCTX
369 st->codec->flags =
flags;
390 case MKBETAG(
'S',
'T',
'V',
'I'):
416 avio_get_str(pb, INT_MAX, rc_eq_buf,
sizeof(rc_eq_buf));
449 case MKBETAG(
'S',
'T',
'A',
'U'):
461 case MKBETAG(
'C',
'P',
'R',
'V'):
478 case MKBETAG(
'S',
'2',
'V',
'I'):
496 case MKBETAG(
'S',
'2',
'A',
'U'):
549 if (tag ==
MKTAG(
'F',
'F',
'M',
'2'))
551 if (tag !=
MKTAG(
'F',
'F',
'M',
'1')) {
567 ffm->
file_size = (UINT64_C(1) << 63) - 1;
612 #if FF_API_LAVF_AVCTX
614 st->codec->flags =
flags;
642 avio_get_str(pb, INT_MAX, rc_eq_buf,
sizeof(rc_eq_buf));
734 ff_dlog(s,
"pos=%08"PRIx64
" spos=%"PRIx64
", write_index=%"PRIx64
" size=%"PRIx64
"\n",
788 int64_t pos_min, pos_max, pos;
789 int64_t pts_min, pts_max,
pts;
792 ff_dlog(s,
"wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
807 while (pos_min <= pos_max) {
810 if (pts_min > wanted_pts || pts_max <= wanted_pts) {
811 pos = pts_min > wanted_pts ? pos_min : pos_max;
815 pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
816 (double)(pts_max - pts_min);
820 else if (pos >= pos_max)
824 if (pts == wanted_pts) {
826 }
else if (pts > wanted_pts) {
850 p->
buf[0] ==
'F' && p->
buf[1] ==
'F' && p->
buf[2] ==
'M' &&
851 (p->
buf[3] ==
'1' || p->
buf[3] ==
'2'))
877 .priv_class = &ffm_class,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static const AVOption options[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
char * recommended_encoder_configuration
String containing paris of key and values describing recommended encoder configuration.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
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).
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static int ffm_append_recommended_configuration(AVStream *st, char **conf)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
unsigned int avio_rb16(AVIOContext *s)
static int ffm_resync(AVFormatContext *s, uint32_t state)
static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
static int ffm_read_data(AVFormatContext *s, uint8_t *buf, int size, int header)
This struct describes the properties of an encoded stream.
int frame_size
Audio only.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int64_t get_dts(AVFormatContext *s, int64_t pos)
#define FRAME_HEADER_SIZE
unsigned int avio_rb32(AVIOContext *s)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
static int ffm_is_avail_data(AVFormatContext *s, int size)
#define AVERROR_EOF
End of file.
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const uint8_t header[24]
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
static int ffm2_read_header(AVFormatContext *s)
#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 void adjust_write_index(AVFormatContext *s)
unsigned int avio_rl32(AVIOContext *s)
int ffio_set_buf_size(AVIOContext *s, int buf_size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define VALIDATE_PARAMETER(parameter, name, check)
static const AVClass ffm_class
enum AVMediaType codec_type
General type of the encoded data.
simple assert() macros that are a bit more flexible than ISO C assert().
static int ffm_probe(AVProbeData *p)
int flags
A combination of AV_PKT_FLAG values.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
common internal API header
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
uint8_t header[FRAME_HEADER_SIZE+4]
Usually treated as AVMEDIA_TYPE_DATA.
int buffer_size
Maximum buffer size.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
AVIOContext * pb
I/O context.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static int write_index(NUTContext *nut, AVIOContext *bc)
Describe the class of an AVClass context structure.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
static int ffm_read_header(AVFormatContext *s)
This structure contains the data a format has to probe a file.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
This struct describes the properties of a single codec described by an AVCodecID. ...
static int64_t pts
Global timestamp for the audio frames.
const AVClass * priv_class
AVClass for the private context.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
AVInputFormat ff_ffm_demuxer
static int64_t ffm_seek1(AVFormatContext *s, int64_t pos1)
int sample_rate
Audio only.
unsigned int avio_rl16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
#define FF_DISABLE_DEPRECATION_WARNINGS
uint8_t packet[FFM_PACKET_SIZE]
common internal api header.
int64_t pos
position in the file of the current buffer
static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
#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...
int eof_reached
true if eof reached
#define FF_ENABLE_DEPRECATION_WARNINGS
void * priv_data
Format private data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVCodecParameters * codecpar
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
#define MKTAG(a, b, c, d)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...