2001-07-22 16:18:56 +02:00
|
|
|
/*
|
2006-10-23 10:57:54 +02:00
|
|
|
* FFM (ffserver live feed) muxer and demuxer
|
2002-05-26 00:31:48 +02:00
|
|
|
* Copyright (c) 2001 Fabrice Bellard.
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2002-05-26 00:31:48 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 17:30:46 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2001-07-22 16:18:56 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2002-05-26 00:31:48 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2002-05-26 00:31:48 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-10-07 17:30:46 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 23:43:26 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-07-22 16:18:56 +02:00
|
|
|
*/
|
|
|
|
#include "avformat.h"
|
2001-08-13 23:37:10 +02:00
|
|
|
#include <unistd.h>
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* The FFM file is made of blocks of fixed size */
|
|
|
|
#define FFM_HEADER_SIZE 14
|
|
|
|
#define PACKET_ID 0x666d
|
|
|
|
|
|
|
|
/* each packet contains frames (which can span several packets */
|
2002-05-09 03:18:08 +02:00
|
|
|
#define FRAME_HEADER_SIZE 8
|
2001-07-22 16:18:56 +02:00
|
|
|
#define FLAG_KEY_FRAME 0x01
|
|
|
|
|
|
|
|
typedef struct FFMStream {
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts;
|
2001-07-22 16:18:56 +02:00
|
|
|
} FFMStream;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
READ_HEADER,
|
|
|
|
READ_DATA,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct FFMContext {
|
|
|
|
/* only reading mode */
|
|
|
|
offset_t write_index, file_size;
|
2002-04-08 22:58:56 +02:00
|
|
|
int read_state;
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t header[FRAME_HEADER_SIZE];
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* read and write */
|
|
|
|
int first_packet; /* true if first packet, needed to set the discontinuity tag */
|
2006-01-19 01:54:10 +01:00
|
|
|
int first_frame_in_packet; /* true if first frame in packet, needed to know if PTS information is valid */
|
2001-07-22 16:18:56 +02:00
|
|
|
int packet_size;
|
|
|
|
int frame_offset;
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts;
|
|
|
|
uint8_t *packet_ptr, *packet_end;
|
|
|
|
uint8_t packet[FFM_PACKET_SIZE];
|
2001-07-22 16:18:56 +02:00
|
|
|
} FFMContext;
|
|
|
|
|
2003-11-19 03:34:40 +01:00
|
|
|
static int64_t get_pts(AVFormatContext *s, offset_t pos);
|
|
|
|
|
2002-05-20 18:31:13 +02:00
|
|
|
/* disable pts hack for testing */
|
|
|
|
int ffm_nopts = 0;
|
|
|
|
|
2005-09-23 02:25:41 +02:00
|
|
|
#ifdef CONFIG_MUXERS
|
2001-07-22 16:18:56 +02:00
|
|
|
static void flush_packet(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
int fill_size, h;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
|
|
|
|
fill_size = ffm->packet_end - ffm->packet_ptr;
|
|
|
|
memset(ffm->packet_ptr, 0, fill_size);
|
2002-04-08 22:58:56 +02:00
|
|
|
|
2005-12-17 19:14:38 +01:00
|
|
|
if (url_ftell(pb) % ffm->packet_size)
|
2003-11-19 03:34:40 +01:00
|
|
|
av_abort();
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
/* put header */
|
2002-04-08 22:58:56 +02:00
|
|
|
put_be16(pb, PACKET_ID);
|
2001-07-22 16:18:56 +02:00
|
|
|
put_be16(pb, fill_size);
|
|
|
|
put_be64(pb, ffm->pts);
|
|
|
|
h = ffm->frame_offset;
|
|
|
|
if (ffm->first_packet)
|
|
|
|
h |= 0x8000;
|
|
|
|
put_be16(pb, h);
|
|
|
|
put_buffer(pb, ffm->packet, ffm->packet_end - ffm->packet);
|
2005-05-07 02:58:28 +02:00
|
|
|
put_flush_packet(pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* prepare next packet */
|
|
|
|
ffm->frame_offset = 0; /* no key frame */
|
|
|
|
ffm->pts = 0; /* no pts */
|
|
|
|
ffm->packet_ptr = ffm->packet;
|
|
|
|
ffm->first_packet = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 'first' is true if first data of a frame */
|
2002-04-08 22:58:56 +02:00
|
|
|
static void ffm_write_data(AVFormatContext *s,
|
2003-09-11 00:37:33 +02:00
|
|
|
const uint8_t *buf, int size,
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts, int first)
|
2001-07-22 16:18:56 +02:00
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (first && ffm->frame_offset == 0)
|
|
|
|
ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE;
|
|
|
|
if (first && ffm->pts == 0)
|
|
|
|
ffm->pts = pts;
|
|
|
|
|
|
|
|
/* write as many packets as needed */
|
|
|
|
while (size > 0) {
|
|
|
|
len = ffm->packet_end - ffm->packet_ptr;
|
|
|
|
if (len > size)
|
|
|
|
len = size;
|
|
|
|
memcpy(ffm->packet_ptr, buf, len);
|
2002-04-08 22:58:56 +02:00
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm->packet_ptr += len;
|
|
|
|
buf += len;
|
|
|
|
size -= len;
|
|
|
|
if (ffm->packet_ptr >= ffm->packet_end) {
|
|
|
|
/* special case : no pts in packet : we leave the current one */
|
|
|
|
if (ffm->pts == 0)
|
|
|
|
ffm->pts = pts;
|
|
|
|
|
|
|
|
flush_packet(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ffm_write_header(AVFormatContext *s)
|
|
|
|
{
|
2002-05-20 18:31:13 +02:00
|
|
|
FFMContext *ffm = s->priv_data;
|
2001-07-22 16:18:56 +02:00
|
|
|
AVStream *st;
|
|
|
|
FFMStream *fst;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
AVCodecContext *codec;
|
|
|
|
int bit_rate, i;
|
|
|
|
|
|
|
|
ffm->packet_size = FFM_PACKET_SIZE;
|
2002-04-08 22:58:56 +02:00
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
/* header */
|
2005-10-13 01:25:15 +02:00
|
|
|
put_le32(pb, MKTAG('F', 'F', 'M', '1'));
|
2001-07-22 16:18:56 +02:00
|
|
|
put_be32(pb, ffm->packet_size);
|
|
|
|
/* XXX: store write position in other file ? */
|
|
|
|
put_be64(pb, ffm->packet_size); /* current write position */
|
|
|
|
|
|
|
|
put_be32(pb, s->nb_streams);
|
|
|
|
bit_rate = 0;
|
|
|
|
for(i=0;i<s->nb_streams;i++) {
|
|
|
|
st = s->streams[i];
|
2005-07-18 00:24:36 +02:00
|
|
|
bit_rate += st->codec->bit_rate;
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
put_be32(pb, bit_rate);
|
|
|
|
|
|
|
|
/* list of streams */
|
|
|
|
for(i=0;i<s->nb_streams;i++) {
|
|
|
|
st = s->streams[i];
|
2002-06-05 04:21:10 +02:00
|
|
|
fst = av_mallocz(sizeof(FFMStream));
|
2001-07-22 16:18:56 +02:00
|
|
|
if (!fst)
|
|
|
|
goto fail;
|
2004-07-25 13:59:34 +02:00
|
|
|
av_set_pts_info(st, 64, 1, 1000000);
|
2001-07-22 16:18:56 +02:00
|
|
|
st->priv_data = fst;
|
|
|
|
|
2005-07-18 00:24:36 +02:00
|
|
|
codec = st->codec;
|
2001-07-22 16:18:56 +02:00
|
|
|
/* generic info */
|
|
|
|
put_be32(pb, codec->codec_id);
|
|
|
|
put_byte(pb, codec->codec_type);
|
|
|
|
put_be32(pb, codec->bit_rate);
|
2005-12-22 02:10:11 +01:00
|
|
|
put_be32(pb, st->quality);
|
2002-05-09 14:37:44 +02:00
|
|
|
put_be32(pb, codec->flags);
|
2005-05-06 05:19:45 +02:00
|
|
|
put_be32(pb, codec->flags2);
|
|
|
|
put_be32(pb, codec->debug);
|
2001-07-22 16:18:56 +02:00
|
|
|
/* specific info */
|
|
|
|
switch(codec->codec_type) {
|
|
|
|
case CODEC_TYPE_VIDEO:
|
2005-04-30 23:43:59 +02:00
|
|
|
put_be32(pb, codec->time_base.num);
|
|
|
|
put_be32(pb, codec->time_base.den);
|
2001-07-22 16:18:56 +02:00
|
|
|
put_be16(pb, codec->width);
|
|
|
|
put_be16(pb, codec->height);
|
2002-05-09 03:18:08 +02:00
|
|
|
put_be16(pb, codec->gop_size);
|
2005-05-06 05:19:45 +02:00
|
|
|
put_be32(pb, codec->pix_fmt);
|
2002-05-09 03:18:08 +02:00
|
|
|
put_byte(pb, codec->qmin);
|
|
|
|
put_byte(pb, codec->qmax);
|
|
|
|
put_byte(pb, codec->max_qdiff);
|
|
|
|
put_be16(pb, (int) (codec->qcompress * 10000.0));
|
|
|
|
put_be16(pb, (int) (codec->qblur * 10000.0));
|
2002-05-16 03:57:55 +02:00
|
|
|
put_be32(pb, codec->bit_rate_tolerance);
|
2002-10-22 11:23:14 +02:00
|
|
|
put_strz(pb, codec->rc_eq);
|
2002-09-12 04:26:58 +02:00
|
|
|
put_be32(pb, codec->rc_max_rate);
|
|
|
|
put_be32(pb, codec->rc_min_rate);
|
|
|
|
put_be32(pb, codec->rc_buffer_size);
|
2005-07-19 16:50:22 +02:00
|
|
|
put_be64(pb, av_dbl2int(codec->i_quant_factor));
|
|
|
|
put_be64(pb, av_dbl2int(codec->b_quant_factor));
|
|
|
|
put_be64(pb, av_dbl2int(codec->i_quant_offset));
|
|
|
|
put_be64(pb, av_dbl2int(codec->b_quant_offset));
|
2002-09-12 04:26:58 +02:00
|
|
|
put_be32(pb, codec->dct_algo);
|
2005-05-06 05:19:45 +02:00
|
|
|
put_be32(pb, codec->strict_std_compliance);
|
|
|
|
put_be32(pb, codec->max_b_frames);
|
|
|
|
put_be32(pb, codec->luma_elim_threshold);
|
|
|
|
put_be32(pb, codec->chroma_elim_threshold);
|
|
|
|
put_be32(pb, codec->mpeg_quant);
|
|
|
|
put_be32(pb, codec->intra_dc_precision);
|
|
|
|
put_be32(pb, codec->me_method);
|
|
|
|
put_be32(pb, codec->mb_decision);
|
|
|
|
put_be32(pb, codec->nsse_weight);
|
|
|
|
put_be32(pb, codec->frame_skip_cmp);
|
2005-07-19 16:50:22 +02:00
|
|
|
put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
|
2001-07-22 16:18:56 +02:00
|
|
|
break;
|
|
|
|
case CODEC_TYPE_AUDIO:
|
|
|
|
put_be32(pb, codec->sample_rate);
|
|
|
|
put_le16(pb, codec->channels);
|
2002-05-09 03:18:08 +02:00
|
|
|
put_le16(pb, codec->frame_size);
|
2001-07-22 16:18:56 +02:00
|
|
|
break;
|
2002-05-09 03:18:08 +02:00
|
|
|
default:
|
2004-10-01 15:16:16 +02:00
|
|
|
return -1;
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
/* hack to have real time */
|
2002-05-20 18:31:13 +02:00
|
|
|
if (ffm_nopts)
|
|
|
|
fst->pts = 0;
|
|
|
|
else
|
2002-07-25 18:05:25 +02:00
|
|
|
fst->pts = av_gettime();
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flush until end of block reached */
|
|
|
|
while ((url_ftell(pb) % ffm->packet_size) != 0)
|
|
|
|
put_byte(pb, 0);
|
|
|
|
|
|
|
|
put_flush_packet(pb);
|
|
|
|
|
|
|
|
/* init packet mux */
|
|
|
|
ffm->packet_ptr = ffm->packet;
|
|
|
|
ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE;
|
2004-10-01 15:16:16 +02:00
|
|
|
assert(ffm->packet_end >= ffm->packet);
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm->frame_offset = 0;
|
|
|
|
ffm->pts = 0;
|
|
|
|
ffm->first_packet = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
for(i=0;i<s->nb_streams;i++) {
|
|
|
|
st = s->streams[i];
|
2002-05-24 03:19:27 +02:00
|
|
|
av_freep(&st->priv_data);
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-05-29 04:06:32 +02:00
|
|
|
static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
|
2001-07-22 16:18:56 +02:00
|
|
|
{
|
2004-05-29 04:06:32 +02:00
|
|
|
AVStream *st = s->streams[pkt->stream_index];
|
2001-07-22 16:18:56 +02:00
|
|
|
FFMStream *fst = st->priv_data;
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts;
|
|
|
|
uint8_t header[FRAME_HEADER_SIZE];
|
2002-05-09 03:18:08 +02:00
|
|
|
int duration;
|
2004-05-29 04:06:32 +02:00
|
|
|
int size= pkt->size;
|
2002-05-09 03:18:08 +02:00
|
|
|
|
2004-05-29 04:06:32 +02:00
|
|
|
//XXX/FIXME use duration from pkt
|
2005-07-18 00:24:36 +02:00
|
|
|
if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
|
|
|
|
duration = ((float)st->codec->frame_size / st->codec->sample_rate * 1000000.0);
|
2002-05-09 03:18:08 +02:00
|
|
|
} else {
|
2005-07-18 00:24:36 +02:00
|
|
|
duration = (1000000.0 * st->codec->time_base.num / (float)st->codec->time_base.den);
|
2002-05-09 03:18:08 +02:00
|
|
|
}
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
pts = fst->pts;
|
|
|
|
/* packet size & key_frame */
|
2004-05-29 04:06:32 +02:00
|
|
|
header[0] = pkt->stream_index;
|
2001-07-22 16:18:56 +02:00
|
|
|
header[1] = 0;
|
2004-05-29 04:06:32 +02:00
|
|
|
if (pkt->flags & PKT_FLAG_KEY)
|
2001-07-22 16:18:56 +02:00
|
|
|
header[1] |= FLAG_KEY_FRAME;
|
|
|
|
header[2] = (size >> 16) & 0xff;
|
|
|
|
header[3] = (size >> 8) & 0xff;
|
|
|
|
header[4] = size & 0xff;
|
2002-05-09 03:18:08 +02:00
|
|
|
header[5] = (duration >> 16) & 0xff;
|
|
|
|
header[6] = (duration >> 8) & 0xff;
|
|
|
|
header[7] = duration & 0xff;
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
|
2004-05-29 04:06:32 +02:00
|
|
|
ffm_write_data(s, pkt->data, size, pts, 0);
|
2001-07-22 16:18:56 +02:00
|
|
|
|
2002-05-09 03:18:08 +02:00
|
|
|
fst->pts += duration;
|
2001-07-22 16:18:56 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ffm_write_trailer(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
|
|
|
|
/* flush packets */
|
|
|
|
if (ffm->packet_ptr > ffm->packet)
|
|
|
|
flush_packet(s);
|
|
|
|
|
|
|
|
put_flush_packet(pb);
|
|
|
|
|
2002-05-26 00:31:48 +02:00
|
|
|
if (!url_is_streamed(pb)) {
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t size;
|
2002-05-26 00:31:48 +02:00
|
|
|
/* update the write offset */
|
|
|
|
size = url_ftell(pb);
|
|
|
|
url_fseek(pb, 8, SEEK_SET);
|
|
|
|
put_be64(pb, size);
|
|
|
|
put_flush_packet(pb);
|
|
|
|
}
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2005-09-23 02:25:41 +02:00
|
|
|
#endif //CONFIG_MUXERS
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* ffm demux */
|
|
|
|
|
|
|
|
static int ffm_is_avail_data(AVFormatContext *s, int size)
|
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
offset_t pos, avail_size;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = ffm->packet_end - ffm->packet_ptr;
|
2002-05-26 00:31:48 +02:00
|
|
|
if (!ffm_nopts) {
|
|
|
|
/* XXX: I don't understand this test, so I disabled it for testing */
|
|
|
|
if (size <= len)
|
|
|
|
return 1;
|
|
|
|
}
|
2001-07-22 16:18:56 +02:00
|
|
|
pos = url_ftell(&s->pb);
|
|
|
|
if (pos == ffm->write_index) {
|
|
|
|
/* exactly at the end of stream */
|
|
|
|
return 0;
|
|
|
|
} else if (pos < ffm->write_index) {
|
|
|
|
avail_size = ffm->write_index - pos;
|
|
|
|
} else {
|
|
|
|
avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
|
|
|
|
}
|
|
|
|
avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
|
|
|
|
if (size <= avail_size)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first is true if we read the frame header */
|
2002-04-08 22:58:56 +02:00
|
|
|
static int ffm_read_data(AVFormatContext *s,
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t *buf, int size, int first)
|
2001-07-22 16:18:56 +02:00
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
int len, fill_size, size1, frame_offset;
|
|
|
|
|
|
|
|
size1 = size;
|
|
|
|
while (size > 0) {
|
|
|
|
redo:
|
|
|
|
len = ffm->packet_end - ffm->packet_ptr;
|
|
|
|
if (len > size)
|
|
|
|
len = size;
|
|
|
|
if (len == 0) {
|
|
|
|
if (url_ftell(pb) == ffm->file_size)
|
|
|
|
url_fseek(pb, ffm->packet_size, SEEK_SET);
|
2002-05-18 23:30:16 +02:00
|
|
|
retry_read:
|
2001-07-22 16:18:56 +02:00
|
|
|
get_be16(pb); /* PACKET_ID */
|
|
|
|
fill_size = get_be16(pb);
|
|
|
|
ffm->pts = get_be64(pb);
|
2006-01-19 01:54:10 +01:00
|
|
|
ffm->first_frame_in_packet = 1;
|
2001-07-22 16:18:56 +02:00
|
|
|
frame_offset = get_be16(pb);
|
|
|
|
get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
|
|
|
|
ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
|
2003-11-19 03:34:40 +01:00
|
|
|
if (ffm->packet_end < ffm->packet)
|
2004-10-01 15:16:16 +02:00
|
|
|
return -1;
|
2001-07-22 16:18:56 +02:00
|
|
|
/* if first packet or resynchronization packet, we must
|
|
|
|
handle it specifically */
|
|
|
|
if (ffm->first_packet || (frame_offset & 0x8000)) {
|
2002-05-18 23:30:16 +02:00
|
|
|
if (!frame_offset) {
|
|
|
|
/* This packet has no frame headers in it */
|
|
|
|
if (url_ftell(pb) >= ffm->packet_size * 3) {
|
|
|
|
url_fseek(pb, -ffm->packet_size * 2, SEEK_CUR);
|
|
|
|
goto retry_read;
|
|
|
|
}
|
|
|
|
/* This is bad, we cannot find a valid frame header */
|
|
|
|
return 0;
|
|
|
|
}
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm->first_packet = 0;
|
2002-05-18 23:30:16 +02:00
|
|
|
if ((frame_offset & 0x7ffff) < FFM_HEADER_SIZE)
|
2004-10-01 15:16:16 +02:00
|
|
|
return -1;
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm->packet_ptr = ffm->packet + (frame_offset & 0x7fff) - FFM_HEADER_SIZE;
|
|
|
|
if (!first)
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
ffm->packet_ptr = ffm->packet;
|
|
|
|
}
|
|
|
|
goto redo;
|
|
|
|
}
|
|
|
|
memcpy(buf, ffm->packet_ptr, len);
|
|
|
|
buf += len;
|
|
|
|
ffm->packet_ptr += len;
|
|
|
|
size -= len;
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
return size1 - size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-19 03:34:40 +01:00
|
|
|
static void adjust_write_index(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
int64_t pts;
|
|
|
|
//offset_t orig_write_index = ffm->write_index;
|
|
|
|
offset_t pos_min, pos_max;
|
|
|
|
int64_t pts_start;
|
|
|
|
offset_t ptr = url_ftell(pb);
|
|
|
|
|
|
|
|
|
|
|
|
pos_min = 0;
|
|
|
|
pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE;
|
|
|
|
|
|
|
|
pts_start = get_pts(s, pos_min);
|
|
|
|
|
|
|
|
pts = get_pts(s, pos_max);
|
|
|
|
|
2005-12-17 19:14:38 +01:00
|
|
|
if (pts - 100000 > pts_start)
|
2004-03-18 21:52:40 +01:00
|
|
|
goto end;
|
2003-11-19 03:34:40 +01:00
|
|
|
|
|
|
|
ffm->write_index = FFM_PACKET_SIZE;
|
|
|
|
|
|
|
|
pts_start = get_pts(s, pos_min);
|
|
|
|
|
|
|
|
pts = get_pts(s, pos_max);
|
|
|
|
|
|
|
|
if (pts - 100000 <= pts_start) {
|
|
|
|
while (1) {
|
|
|
|
offset_t newpos;
|
|
|
|
int64_t newpts;
|
|
|
|
|
|
|
|
newpos = ((pos_max + pos_min) / (2 * FFM_PACKET_SIZE)) * FFM_PACKET_SIZE;
|
|
|
|
|
|
|
|
if (newpos == pos_min)
|
|
|
|
break;
|
|
|
|
|
|
|
|
newpts = get_pts(s, newpos);
|
|
|
|
|
|
|
|
if (newpts - 100000 <= pts) {
|
|
|
|
pos_max = newpos;
|
|
|
|
pts = newpts;
|
|
|
|
} else {
|
|
|
|
pos_min = newpos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ffm->write_index += pos_max;
|
|
|
|
}
|
|
|
|
|
2006-11-01 23:39:58 +01:00
|
|
|
//printf("Adjusted write index from %"PRId64" to %"PRId64": pts=%0.6f\n", orig_write_index, ffm->write_index, pts / 1000000.);
|
2003-11-19 03:34:40 +01:00
|
|
|
//printf("pts range %0.6f - %0.6f\n", get_pts(s, 0) / 1000000. , get_pts(s, ffm->file_size - 2 * FFM_PACKET_SIZE) / 1000000. );
|
|
|
|
|
2004-03-18 21:52:40 +01:00
|
|
|
end:
|
2003-11-19 03:34:40 +01:00
|
|
|
url_fseek(pb, ptr, SEEK_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|
|
|
{
|
2002-05-20 18:31:13 +02:00
|
|
|
FFMContext *ffm = s->priv_data;
|
2001-07-22 16:18:56 +02:00
|
|
|
AVStream *st;
|
|
|
|
FFMStream *fst;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
AVCodecContext *codec;
|
2003-08-08 19:52:30 +02:00
|
|
|
int i, nb_streams;
|
2003-02-11 17:35:48 +01:00
|
|
|
uint32_t tag;
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* header */
|
|
|
|
tag = get_le32(pb);
|
|
|
|
if (tag != MKTAG('F', 'F', 'M', '1'))
|
|
|
|
goto fail;
|
|
|
|
ffm->packet_size = get_be32(pb);
|
|
|
|
if (ffm->packet_size != FFM_PACKET_SIZE)
|
|
|
|
goto fail;
|
|
|
|
ffm->write_index = get_be64(pb);
|
|
|
|
/* get also filesize */
|
|
|
|
if (!url_is_streamed(pb)) {
|
2005-05-19 02:06:27 +02:00
|
|
|
ffm->file_size = url_fsize(pb);
|
2003-11-19 03:34:40 +01:00
|
|
|
adjust_write_index(s);
|
2001-07-22 16:18:56 +02:00
|
|
|
} else {
|
2006-12-07 00:46:11 +01:00
|
|
|
ffm->file_size = (UINT64_C(1) << 63) - 1;
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
|
2003-08-08 19:52:30 +02:00
|
|
|
nb_streams = get_be32(pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
get_be32(pb); /* total bitrate */
|
|
|
|
/* read each stream */
|
2003-08-08 19:52:30 +02:00
|
|
|
for(i=0;i<nb_streams;i++) {
|
2002-09-12 04:26:58 +02:00
|
|
|
char rc_eq_buf[128];
|
|
|
|
|
2003-08-08 19:52:30 +02:00
|
|
|
st = av_new_stream(s, 0);
|
2001-07-22 16:18:56 +02:00
|
|
|
if (!st)
|
|
|
|
goto fail;
|
2002-06-05 04:21:10 +02:00
|
|
|
fst = av_mallocz(sizeof(FFMStream));
|
2001-07-22 16:18:56 +02:00
|
|
|
if (!fst)
|
|
|
|
goto fail;
|
2005-10-13 01:25:15 +02:00
|
|
|
s->streams[i] = st;
|
2005-12-17 19:14:38 +01:00
|
|
|
|
2004-05-29 04:06:32 +02:00
|
|
|
av_set_pts_info(st, 64, 1, 1000000);
|
2005-12-17 19:14:38 +01:00
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
st->priv_data = fst;
|
|
|
|
|
2005-07-18 00:24:36 +02:00
|
|
|
codec = st->codec;
|
2001-07-22 16:18:56 +02:00
|
|
|
/* generic info */
|
2005-10-13 01:25:15 +02:00
|
|
|
codec->codec_id = get_be32(pb);
|
|
|
|
codec->codec_type = get_byte(pb); /* codec_type */
|
2001-07-22 16:18:56 +02:00
|
|
|
codec->bit_rate = get_be32(pb);
|
2005-10-13 01:25:15 +02:00
|
|
|
st->quality = get_be32(pb);
|
2002-05-09 14:37:44 +02:00
|
|
|
codec->flags = get_be32(pb);
|
2005-05-06 05:19:45 +02:00
|
|
|
codec->flags2 = get_be32(pb);
|
|
|
|
codec->debug = get_be32(pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
/* specific info */
|
|
|
|
switch(codec->codec_type) {
|
|
|
|
case CODEC_TYPE_VIDEO:
|
2005-04-30 23:43:59 +02:00
|
|
|
codec->time_base.num = get_be32(pb);
|
|
|
|
codec->time_base.den = get_be32(pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
codec->width = get_be16(pb);
|
|
|
|
codec->height = get_be16(pb);
|
2002-05-09 03:18:08 +02:00
|
|
|
codec->gop_size = get_be16(pb);
|
2005-05-06 05:19:45 +02:00
|
|
|
codec->pix_fmt = get_be32(pb);
|
2002-05-09 03:18:08 +02:00
|
|
|
codec->qmin = get_byte(pb);
|
|
|
|
codec->qmax = get_byte(pb);
|
|
|
|
codec->max_qdiff = get_byte(pb);
|
|
|
|
codec->qcompress = get_be16(pb) / 10000.0;
|
|
|
|
codec->qblur = get_be16(pb) / 10000.0;
|
2002-05-16 03:57:55 +02:00
|
|
|
codec->bit_rate_tolerance = get_be32(pb);
|
2003-01-24 00:34:29 +01:00
|
|
|
codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
|
2002-09-12 04:26:58 +02:00
|
|
|
codec->rc_max_rate = get_be32(pb);
|
|
|
|
codec->rc_min_rate = get_be32(pb);
|
|
|
|
codec->rc_buffer_size = get_be32(pb);
|
2005-07-19 16:50:22 +02:00
|
|
|
codec->i_quant_factor = av_int2dbl(get_be64(pb));
|
|
|
|
codec->b_quant_factor = av_int2dbl(get_be64(pb));
|
|
|
|
codec->i_quant_offset = av_int2dbl(get_be64(pb));
|
|
|
|
codec->b_quant_offset = av_int2dbl(get_be64(pb));
|
2002-09-12 04:26:58 +02:00
|
|
|
codec->dct_algo = get_be32(pb);
|
2005-05-06 05:19:45 +02:00
|
|
|
codec->strict_std_compliance = get_be32(pb);
|
|
|
|
codec->max_b_frames = get_be32(pb);
|
|
|
|
codec->luma_elim_threshold = get_be32(pb);
|
|
|
|
codec->chroma_elim_threshold = get_be32(pb);
|
|
|
|
codec->mpeg_quant = get_be32(pb);
|
|
|
|
codec->intra_dc_precision = get_be32(pb);
|
|
|
|
codec->me_method = get_be32(pb);
|
|
|
|
codec->mb_decision = get_be32(pb);
|
|
|
|
codec->nsse_weight = get_be32(pb);
|
|
|
|
codec->frame_skip_cmp = get_be32(pb);
|
2005-07-19 16:50:22 +02:00
|
|
|
codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb));
|
2001-07-22 16:18:56 +02:00
|
|
|
break;
|
|
|
|
case CODEC_TYPE_AUDIO:
|
|
|
|
codec->sample_rate = get_be32(pb);
|
|
|
|
codec->channels = get_le16(pb);
|
2002-05-09 03:18:08 +02:00
|
|
|
codec->frame_size = get_le16(pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
break;
|
2002-05-09 03:18:08 +02:00
|
|
|
default:
|
2002-09-12 04:26:58 +02:00
|
|
|
goto fail;
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get until end of block reached */
|
|
|
|
while ((url_ftell(pb) % ffm->packet_size) != 0)
|
|
|
|
get_byte(pb);
|
|
|
|
|
|
|
|
/* init packet demux */
|
|
|
|
ffm->packet_ptr = ffm->packet;
|
|
|
|
ffm->packet_end = ffm->packet;
|
|
|
|
ffm->frame_offset = 0;
|
|
|
|
ffm->pts = 0;
|
|
|
|
ffm->read_state = READ_HEADER;
|
|
|
|
ffm->first_packet = 1;
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
for(i=0;i<s->nb_streams;i++) {
|
|
|
|
st = s->streams[i];
|
|
|
|
if (st) {
|
2002-05-24 03:19:27 +02:00
|
|
|
av_freep(&st->priv_data);
|
2002-05-19 01:11:09 +02:00
|
|
|
av_free(st);
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return < 0 if eof */
|
|
|
|
static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
FFMContext *ffm = s->priv_data;
|
2002-05-09 03:18:08 +02:00
|
|
|
int duration;
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
switch(ffm->read_state) {
|
|
|
|
case READ_HEADER:
|
2002-05-26 00:31:48 +02:00
|
|
|
if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
|
2001-07-22 16:18:56 +02:00
|
|
|
return -EAGAIN;
|
2002-05-26 00:31:48 +02:00
|
|
|
}
|
2001-07-22 16:18:56 +02:00
|
|
|
#if 0
|
2006-11-01 23:39:58 +01:00
|
|
|
printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
|
2001-07-22 16:18:56 +02:00
|
|
|
url_ftell(&s->pb), s->pb.pos, ffm->write_index, ffm->file_size);
|
|
|
|
#endif
|
2005-12-17 19:14:38 +01:00
|
|
|
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
|
2002-05-26 00:31:48 +02:00
|
|
|
FRAME_HEADER_SIZE)
|
2001-07-22 16:18:56 +02:00
|
|
|
return -EAGAIN;
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0;i<FRAME_HEADER_SIZE;i++)
|
|
|
|
printf("%02x ", ffm->header[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
ffm->read_state = READ_DATA;
|
|
|
|
/* fall thru */
|
|
|
|
case READ_DATA:
|
|
|
|
size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4];
|
|
|
|
if (!ffm_is_avail_data(s, size)) {
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
2002-05-09 03:18:08 +02:00
|
|
|
duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7];
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
av_new_packet(pkt, size);
|
|
|
|
pkt->stream_index = ffm->header[0];
|
2005-12-17 19:14:38 +01:00
|
|
|
pkt->pos = url_ftell(&s->pb);
|
2001-07-22 16:18:56 +02:00
|
|
|
if (ffm->header[1] & FLAG_KEY_FRAME)
|
|
|
|
pkt->flags |= PKT_FLAG_KEY;
|
2002-04-08 22:58:56 +02:00
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
ffm->read_state = READ_HEADER;
|
|
|
|
if (ffm_read_data(s, pkt->data, size, 0) != size) {
|
|
|
|
/* bad case: desynchronized packet. we cancel all the packet loading */
|
|
|
|
av_free_packet(pkt);
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
2006-01-19 01:54:10 +01:00
|
|
|
if (ffm->first_frame_in_packet)
|
|
|
|
{
|
|
|
|
pkt->pts = ffm->pts;
|
|
|
|
ffm->first_frame_in_packet = 0;
|
|
|
|
}
|
2002-05-09 03:18:08 +02:00
|
|
|
pkt->duration = duration;
|
2001-07-22 16:18:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//#define DEBUG_SEEK
|
|
|
|
|
|
|
|
/* pos is between 0 and file_size - FFM_PACKET_SIZE. It is translated
|
|
|
|
by the write position inside this function */
|
|
|
|
static void ffm_seek1(AVFormatContext *s, offset_t pos1)
|
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
ByteIOContext *pb = &s->pb;
|
|
|
|
offset_t pos;
|
|
|
|
|
|
|
|
pos = pos1 + ffm->write_index;
|
|
|
|
if (pos >= ffm->file_size)
|
|
|
|
pos -= (ffm->file_size - FFM_PACKET_SIZE);
|
|
|
|
#ifdef DEBUG_SEEK
|
2006-11-01 23:39:58 +01:00
|
|
|
printf("seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
|
2001-07-22 16:18:56 +02:00
|
|
|
#endif
|
|
|
|
url_fseek(pb, pos, SEEK_SET);
|
|
|
|
}
|
|
|
|
|
2003-02-11 17:35:48 +01:00
|
|
|
static int64_t get_pts(AVFormatContext *s, offset_t pos)
|
2001-07-22 16:18:56 +02:00
|
|
|
{
|
|
|
|
ByteIOContext *pb = &s->pb;
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts;
|
2001-07-22 16:18:56 +02:00
|
|
|
|
2002-04-08 22:58:56 +02:00
|
|
|
ffm_seek1(s, pos);
|
2001-07-22 16:18:56 +02:00
|
|
|
url_fskip(pb, 4);
|
|
|
|
pts = get_be64(pb);
|
|
|
|
#ifdef DEBUG_SEEK
|
|
|
|
printf("pts=%0.6f\n", pts / 1000000.0);
|
|
|
|
#endif
|
|
|
|
return pts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* seek to a given time in the file. The file read pointer is
|
|
|
|
positionned at or before pts. XXX: the following code is quite
|
|
|
|
approximative */
|
2004-10-12 01:53:53 +02:00
|
|
|
static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
|
2001-07-22 16:18:56 +02:00
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
offset_t pos_min, pos_max, pos;
|
2003-02-11 17:35:48 +01:00
|
|
|
int64_t pts_min, pts_max, pts;
|
2001-07-22 16:18:56 +02:00
|
|
|
double pos1;
|
|
|
|
|
|
|
|
#ifdef DEBUG_SEEK
|
|
|
|
printf("wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
|
|
|
|
#endif
|
|
|
|
/* find the position using linear interpolation (better than
|
|
|
|
dichotomy in typical cases) */
|
|
|
|
pos_min = 0;
|
|
|
|
pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE;
|
|
|
|
while (pos_min <= pos_max) {
|
|
|
|
pts_min = get_pts(s, pos_min);
|
|
|
|
pts_max = get_pts(s, pos_max);
|
|
|
|
/* linear interpolation */
|
2002-04-08 22:58:56 +02:00
|
|
|
pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
|
2001-07-22 16:18:56 +02:00
|
|
|
(double)(pts_max - pts_min);
|
2003-02-11 17:35:48 +01:00
|
|
|
pos = (((int64_t)pos1) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
|
2001-07-22 16:18:56 +02:00
|
|
|
if (pos <= pos_min)
|
|
|
|
pos = pos_min;
|
|
|
|
else if (pos >= pos_max)
|
|
|
|
pos = pos_max;
|
|
|
|
pts = get_pts(s, pos);
|
|
|
|
/* check if we are lucky */
|
|
|
|
if (pts == wanted_pts) {
|
|
|
|
goto found;
|
|
|
|
} else if (pts > wanted_pts) {
|
|
|
|
pos_max = pos - FFM_PACKET_SIZE;
|
|
|
|
} else {
|
|
|
|
pos_min = pos + FFM_PACKET_SIZE;
|
|
|
|
}
|
|
|
|
}
|
2004-10-12 01:53:53 +02:00
|
|
|
pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
|
2001-07-22 16:18:56 +02:00
|
|
|
if (pos > 0)
|
|
|
|
pos -= FFM_PACKET_SIZE;
|
|
|
|
found:
|
|
|
|
ffm_seek1(s, pos);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-21 19:36:32 +01:00
|
|
|
#ifdef CONFIG_FFSERVER
|
2001-07-22 16:18:56 +02:00
|
|
|
offset_t ffm_read_write_index(int fd)
|
|
|
|
{
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t buf[8];
|
2001-07-22 16:18:56 +02:00
|
|
|
offset_t pos;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
lseek(fd, 8, SEEK_SET);
|
|
|
|
read(fd, buf, 8);
|
|
|
|
pos = 0;
|
2002-04-08 22:58:56 +02:00
|
|
|
for(i=0;i<8;i++)
|
2003-08-08 19:52:30 +02:00
|
|
|
pos |= (int64_t)buf[i] << (56 - i * 8);
|
2001-07-22 16:18:56 +02:00
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ffm_write_write_index(int fd, offset_t pos)
|
|
|
|
{
|
2003-02-11 17:35:48 +01:00
|
|
|
uint8_t buf[8];
|
2001-07-22 16:18:56 +02:00
|
|
|
int i;
|
|
|
|
|
2002-04-08 22:58:56 +02:00
|
|
|
for(i=0;i<8;i++)
|
2001-07-22 16:18:56 +02:00
|
|
|
buf[i] = (pos >> (56 - i * 8)) & 0xff;
|
|
|
|
lseek(fd, 8, SEEK_SET);
|
|
|
|
write(fd, buf, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size)
|
|
|
|
{
|
|
|
|
FFMContext *ffm = s->priv_data;
|
|
|
|
ffm->write_index = pos;
|
|
|
|
ffm->file_size = file_size;
|
|
|
|
}
|
2006-01-21 19:36:32 +01:00
|
|
|
#endif // CONFIG_FFSERVER
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
static int ffm_read_close(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
AVStream *st;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<s->nb_streams;i++) {
|
|
|
|
st = s->streams[i];
|
2002-05-24 03:19:27 +02:00
|
|
|
av_freep(&st->priv_data);
|
2001-07-22 16:18:56 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-05-24 04:06:51 +02:00
|
|
|
static int ffm_probe(AVProbeData *p)
|
|
|
|
{
|
2002-05-26 00:31:48 +02:00
|
|
|
if (p->buf_size >= 4 &&
|
2005-12-17 19:14:38 +01:00
|
|
|
p->buf[0] == 'F' && p->buf[1] == 'F' && p->buf[2] == 'M' &&
|
2002-05-26 00:31:48 +02:00
|
|
|
p->buf[3] == '1')
|
2002-05-24 04:06:51 +02:00
|
|
|
return AVPROBE_SCORE_MAX + 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-10 23:14:37 +02:00
|
|
|
#ifdef CONFIG_FFM_DEMUXER
|
|
|
|
AVInputFormat ffm_demuxer = {
|
2002-05-20 18:31:13 +02:00
|
|
|
"ffm",
|
|
|
|
"ffm format",
|
2002-05-26 00:31:48 +02:00
|
|
|
sizeof(FFMContext),
|
2002-05-24 04:06:51 +02:00
|
|
|
ffm_probe,
|
2002-05-20 18:31:13 +02:00
|
|
|
ffm_read_header,
|
|
|
|
ffm_read_packet,
|
|
|
|
ffm_read_close,
|
|
|
|
ffm_seek,
|
|
|
|
};
|
2006-07-10 23:14:37 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_FFM_MUXER
|
|
|
|
AVOutputFormat ffm_muxer = {
|
2001-07-22 16:18:56 +02:00
|
|
|
"ffm",
|
|
|
|
"ffm format",
|
|
|
|
"",
|
|
|
|
"ffm",
|
2002-05-26 00:31:48 +02:00
|
|
|
sizeof(FFMContext),
|
2001-07-22 16:18:56 +02:00
|
|
|
/* not really used */
|
|
|
|
CODEC_ID_MP2,
|
|
|
|
CODEC_ID_MPEG1VIDEO,
|
|
|
|
ffm_write_header,
|
|
|
|
ffm_write_packet,
|
|
|
|
ffm_write_trailer,
|
|
|
|
};
|
2006-07-10 23:14:37 +02:00
|
|
|
#endif //CONFIG_FFM_MUXER
|