* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/crc.h"
+#include "libavcodec/ac3_parser.h"
+#include "libavcodec/bitstream.h"
+#include "libavcodec/bytestream.h"
#include "avformat.h"
-#include "ac3_parser.h"
#include "raw.h"
-#include "crc.h"
-#include "bitstream.h"
#ifdef CONFIG_MUXERS
/* simple formats */
return 0;
}
+static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+ return 0;
+}
+
static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
put_buffer(s->pb, pkt->data, pkt->size);
return ret;
}
+static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ int packet_size, ret, width, height;
+ AVStream *st = s->streams[0];
+
+ width = st->codec->width;
+ height = st->codec->height;
+
+ packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
+ if (packet_size < 0)
+ return -1;
+
+ ret= av_get_packet(s->pb, pkt, packet_size);
+ pkt->pts=
+ pkt->dts= pkt->pos / packet_size;
+
+ pkt->stream_index = 0;
+ if (ret != packet_size) {
+ return AVERROR(EIO);
+ } else {
+ return 0;
+ }
+}
+
// http://www.artificis.hu/files/texts/ingenient.txt
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
{
return ret;
}
-static int raw_read_close(AVFormatContext *s)
-{
- return 0;
-}
-
int pcm_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp, int flags)
{
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
} else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
st->codec->codec_id == CODEC_ID_MPEG4 ||
+ st->codec->codec_id == CODEC_ID_DIRAC ||
st->codec->codec_id == CODEC_ID_H264) {
av_set_pts_info(st, 64, 1, 25);
}
return 0;
}
+#define DCA_MARKER_14B_BE 0x1FFFE800
+#define DCA_MARKER_14B_LE 0xFF1F00E8
+#define DCA_MARKER_RAW_BE 0x7FFE8001
+#define DCA_MARKER_RAW_LE 0xFE7F0180
+static int dts_probe(AVProbeData *p)
+{
+ const uint8_t *buf, *bufp;
+ uint32_t state = -1;
+
+ buf = p->buf;
+
+ for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
+ bufp = buf;
+ state = (state << 16) | bytestream_get_be16(&bufp);
+
+ /* Regular bitstream */
+ if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
+ return AVPROBE_SCORE_MAX/2+1;
+
+ /* 14 bits big endian bitstream */
+ if (state == DCA_MARKER_14B_BE)
+ if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
+ return AVPROBE_SCORE_MAX/2+1;
+
+ /* 14 bits little endian bitstream */
+ if (state == DCA_MARKER_14B_LE)
+ if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
+ return AVPROBE_SCORE_MAX/2+1;
+ }
+
+ return 0;
+}
+
+static int dirac_probe(AVProbeData *p)
+{
+ if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
+ return AVPROBE_SCORE_MAX;
+ else
+ return 0;
+}
+
static int ac3_probe(AVProbeData *p)
{
int max_frames, first_frames = 0, frames;
else return AVPROBE_SCORE_MAX / 2;
}
-AVInputFormat shorten_demuxer = {
- "shn",
- "raw shorten",
- 0,
- NULL,
- audio_read_header,
- raw_read_partial_packet,
- raw_read_close,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "shn",
- .value = CODEC_ID_SHORTEN,
-};
-AVInputFormat flac_demuxer = {
- "flac",
- "raw flac",
+/* Note: Do not forget to add new entries to the Makefile as well. */
+
+AVInputFormat aac_demuxer = {
+ "aac",
+ NULL_IF_CONFIG_SMALL("ADTS AAC"),
0,
- flac_probe,
+ NULL,
audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "flac",
- .value = CODEC_ID_FLAC,
-};
-
-#ifdef CONFIG_MUXERS
-AVOutputFormat flac_muxer = {
- "flac",
- "raw flac",
- "audio/x-flac",
- "flac",
- 0,
- CODEC_ID_FLAC,
- 0,
- flac_write_header,
- raw_write_packet,
- .flags= AVFMT_NOTIMESTAMPS,
+ .extensions = "aac",
+ .value = CODEC_ID_AAC,
};
-#endif //CONFIG_MUXERS
#ifdef CONFIG_AC3_DEMUXER
AVInputFormat ac3_demuxer = {
"ac3",
- "raw ac3",
+ NULL_IF_CONFIG_SMALL("raw AC-3"),
0,
ac3_probe,
audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "ac3",
.value = CODEC_ID_AC3,
#ifdef CONFIG_MUXERS
AVOutputFormat ac3_muxer = {
"ac3",
- "raw ac3",
+ NULL_IF_CONFIG_SMALL("raw AC-3"),
"audio/x-ac3",
"ac3",
0,
CODEC_ID_AC3,
- 0,
+ CODEC_ID_NONE,
NULL,
raw_write_packet,
.flags= AVFMT_NOTIMESTAMPS,
};
+#endif //CONFIG_MUXERS
-AVOutputFormat dts_muxer = {
- "dts",
- "raw dts",
- "audio/x-dca",
- "dts",
+AVInputFormat dirac_demuxer = {
+ "dirac",
+ NULL_IF_CONFIG_SMALL("raw Dirac"),
0,
- CODEC_ID_DTS,
+ dirac_probe,
+ video_read_header,
+ raw_read_partial_packet,
+ .flags= AVFMT_GENERIC_INDEX,
+ .value = CODEC_ID_DIRAC,
+};
+
+#ifdef CONFIG_MUXERS
+AVOutputFormat dirac_muxer = {
+ "dirac",
+ NULL_IF_CONFIG_SMALL("raw Dirac"),
+ NULL,
+ "drc",
0,
+ CODEC_ID_NONE,
+ CODEC_ID_DIRAC,
NULL,
raw_write_packet,
.flags= AVFMT_NOTIMESTAMPS,
};
-
-#endif //CONFIG_MUXERS
+#endif
AVInputFormat dts_demuxer = {
"dts",
- "raw dts",
+ NULL_IF_CONFIG_SMALL("raw DTS"),
0,
- NULL,
+ dts_probe,
audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "dts",
.value = CODEC_ID_DTS,
};
-AVInputFormat aac_demuxer = {
- "aac",
- "ADTS AAC",
+#ifdef CONFIG_MUXERS
+AVOutputFormat dts_muxer = {
+ "dts",
+ NULL_IF_CONFIG_SMALL("raw DTS"),
+ "audio/x-dca",
+ "dts",
0,
+ CODEC_ID_DTS,
+ CODEC_ID_NONE,
NULL,
+ raw_write_packet,
+ .flags= AVFMT_NOTIMESTAMPS,
+};
+#endif
+
+AVInputFormat flac_demuxer = {
+ "flac",
+ NULL_IF_CONFIG_SMALL("raw FLAC"),
+ 0,
+ flac_probe,
audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "aac",
- .value = CODEC_ID_AAC,
+ .extensions = "flac",
+ .value = CODEC_ID_FLAC,
+};
+
+#ifdef CONFIG_MUXERS
+AVOutputFormat flac_muxer = {
+ "flac",
+ NULL_IF_CONFIG_SMALL("raw FLAC"),
+ "audio/x-flac",
+ "flac",
+ 0,
+ CODEC_ID_FLAC,
+ CODEC_ID_NONE,
+ flac_write_header,
+ raw_write_packet,
+ .flags= AVFMT_NOTIMESTAMPS,
};
+#endif //CONFIG_MUXERS
AVInputFormat gsm_demuxer = {
"gsm",
- "GSM",
+ NULL_IF_CONFIG_SMALL("GSM"),
0,
NULL,
audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "gsm",
.value = CODEC_ID_GSM,
};
-#ifdef CONFIG_ROQ_MUXER
-AVOutputFormat roq_muxer =
-{
- "RoQ",
- "Id RoQ format",
- NULL,
- "roq",
- 0,
- CODEC_ID_ROQ_DPCM,
- CODEC_ID_ROQ,
- roq_write_header,
- raw_write_packet,
-};
-#endif //CONFIG_ROQ_MUXER
-
AVInputFormat h261_demuxer = {
"h261",
- "raw h261",
+ NULL_IF_CONFIG_SMALL("raw H.261"),
0,
h261_probe,
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "h261",
.value = CODEC_ID_H261,
#ifdef CONFIG_MUXERS
AVOutputFormat h261_muxer = {
"h261",
- "raw h261",
+ NULL_IF_CONFIG_SMALL("raw H.261"),
"video/x-h261",
"h261",
0,
- 0,
+ CODEC_ID_NONE,
CODEC_ID_H261,
NULL,
raw_write_packet,
AVInputFormat h263_demuxer = {
"h263",
- "raw h263",
+ NULL_IF_CONFIG_SMALL("raw H.263"),
0,
h263_probe,
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
// .extensions = "h263", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_H263,
#ifdef CONFIG_MUXERS
AVOutputFormat h263_muxer = {
"h263",
- "raw h263",
+ NULL_IF_CONFIG_SMALL("raw H.263"),
"video/x-h263",
"h263",
0,
- 0,
+ CODEC_ID_NONE,
CODEC_ID_H263,
NULL,
raw_write_packet,
};
#endif //CONFIG_MUXERS
+AVInputFormat h264_demuxer = {
+ "h264",
+ NULL_IF_CONFIG_SMALL("raw H.264 video format"),
+ 0,
+ NULL /*mpegvideo_probe*/,
+ video_read_header,
+ raw_read_partial_packet,
+ .flags= AVFMT_GENERIC_INDEX,
+ .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
+ .value = CODEC_ID_H264,
+};
+
+#ifdef CONFIG_MUXERS
+AVOutputFormat h264_muxer = {
+ "h264",
+ NULL_IF_CONFIG_SMALL("raw H.264 video format"),
+ NULL,
+ "h264",
+ 0,
+ CODEC_ID_NONE,
+ CODEC_ID_H264,
+ NULL,
+ raw_write_packet,
+ .flags= AVFMT_NOTIMESTAMPS,
+};
+#endif //CONFIG_MUXERS
+
+AVInputFormat ingenient_demuxer = {
+ "ingenient",
+ NULL_IF_CONFIG_SMALL("Ingenient MJPEG"),
+ 0,
+ NULL,
+ video_read_header,
+ ingenient_read_packet,
+ .flags= AVFMT_GENERIC_INDEX,
+ .extensions = "cgi", // FIXME
+ .value = CODEC_ID_MJPEG,
+};
+
AVInputFormat m4v_demuxer = {
"m4v",
- "raw MPEG4 video format",
+ NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
0,
mpeg4video_probe, /** probing for mpeg4 data */
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "m4v", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_MPEG4,
#ifdef CONFIG_MUXERS
AVOutputFormat m4v_muxer = {
"m4v",
- "raw MPEG4 video format",
+ NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
NULL,
"m4v",
0,
};
#endif //CONFIG_MUXERS
-AVInputFormat h264_demuxer = {
- "h264",
- "raw H264 video format",
+AVInputFormat mjpeg_demuxer = {
+ "mjpeg",
+ NULL_IF_CONFIG_SMALL("MJPEG video"),
0,
- NULL /*mpegvideo_probe*/,
+ NULL,
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
- .value = CODEC_ID_H264,
+ .extensions = "mjpg,mjpeg",
+ .value = CODEC_ID_MJPEG,
};
#ifdef CONFIG_MUXERS
-AVOutputFormat h264_muxer = {
- "h264",
- "raw H264 video format",
- NULL,
- "h264",
+AVOutputFormat mjpeg_muxer = {
+ "mjpeg",
+ NULL_IF_CONFIG_SMALL("MJPEG video"),
+ "video/x-mjpeg",
+ "mjpg,mjpeg",
0,
CODEC_ID_NONE,
- CODEC_ID_H264,
+ CODEC_ID_MJPEG,
NULL,
raw_write_packet,
.flags= AVFMT_NOTIMESTAMPS,
};
#endif //CONFIG_MUXERS
-AVInputFormat mpegvideo_demuxer = {
- "mpegvideo",
- "MPEG video",
+AVInputFormat mlp_demuxer = {
+ "mlp",
+ NULL_IF_CONFIG_SMALL("raw MLP"),
0,
- mpegvideo_probe,
- video_read_header,
+ NULL,
+ audio_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
- .value = CODEC_ID_MPEG1VIDEO,
+ .extensions = "mlp",
+ .value = CODEC_ID_MLP,
};
#ifdef CONFIG_MUXERS
AVOutputFormat mpeg1video_muxer = {
"mpeg1video",
- "MPEG video",
+ NULL_IF_CONFIG_SMALL("MPEG video"),
"video/x-mpeg",
"mpg,mpeg,m1v",
0,
- 0,
+ CODEC_ID_NONE,
CODEC_ID_MPEG1VIDEO,
NULL,
raw_write_packet,
#ifdef CONFIG_MUXERS
AVOutputFormat mpeg2video_muxer = {
"mpeg2video",
- "MPEG2 video",
+ NULL_IF_CONFIG_SMALL("MPEG-2 video"),
NULL,
"m2v",
0,
- 0,
+ CODEC_ID_NONE,
CODEC_ID_MPEG2VIDEO,
NULL,
raw_write_packet,
};
#endif //CONFIG_MUXERS
-AVInputFormat mjpeg_demuxer = {
- "mjpeg",
- "MJPEG video",
+AVInputFormat mpegvideo_demuxer = {
+ "mpegvideo",
+ NULL_IF_CONFIG_SMALL("MPEG video"),
0,
- NULL,
+ mpegvideo_probe,
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "mjpg,mjpeg",
- .value = CODEC_ID_MJPEG,
+ .value = CODEC_ID_MPEG1VIDEO,
};
-AVInputFormat ingenient_demuxer = {
- "ingenient",
- "Ingenient MJPEG",
+#ifdef CONFIG_MUXERS
+AVOutputFormat null_muxer = {
+ "null",
+ NULL_IF_CONFIG_SMALL("null video format"),
+ NULL,
+ NULL,
0,
+#ifdef WORDS_BIGENDIAN
+ CODEC_ID_PCM_S16BE,
+#else
+ CODEC_ID_PCM_S16LE,
+#endif
+ CODEC_ID_RAWVIDEO,
NULL,
- video_read_header,
- ingenient_read_packet,
- raw_read_close,
+ null_write_packet,
+ .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
+};
+#endif //CONFIG_MUXERS
+
+AVInputFormat rawvideo_demuxer = {
+ "rawvideo",
+ NULL_IF_CONFIG_SMALL("raw video format"),
+ 0,
+ NULL,
+ raw_read_header,
+ rawvideo_read_packet,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "cgi", // FIXME
- .value = CODEC_ID_MJPEG,
+ .extensions = "yuv,cif,qcif,rgb",
+ .value = CODEC_ID_RAWVIDEO,
};
#ifdef CONFIG_MUXERS
-AVOutputFormat mjpeg_muxer = {
- "mjpeg",
- "MJPEG video",
- "video/x-mjpeg",
- "mjpg,mjpeg",
- 0,
+AVOutputFormat rawvideo_muxer = {
+ "rawvideo",
+ NULL_IF_CONFIG_SMALL("raw video format"),
+ NULL,
+ "yuv,rgb",
0,
- CODEC_ID_MJPEG,
+ CODEC_ID_NONE,
+ CODEC_ID_RAWVIDEO,
NULL,
raw_write_packet,
.flags= AVFMT_NOTIMESTAMPS,
};
#endif //CONFIG_MUXERS
+#ifdef CONFIG_ROQ_MUXER
+AVOutputFormat roq_muxer =
+{
+ "RoQ",
+ NULL_IF_CONFIG_SMALL("id RoQ format"),
+ NULL,
+ "roq",
+ 0,
+ CODEC_ID_ROQ_DPCM,
+ CODEC_ID_ROQ,
+ roq_write_header,
+ raw_write_packet,
+};
+#endif //CONFIG_ROQ_MUXER
+
+AVInputFormat shorten_demuxer = {
+ "shn",
+ NULL_IF_CONFIG_SMALL("raw Shorten"),
+ 0,
+ NULL,
+ audio_read_header,
+ raw_read_partial_packet,
+ .flags= AVFMT_GENERIC_INDEX,
+ .extensions = "shn",
+ .value = CODEC_ID_SHORTEN,
+};
+
AVInputFormat vc1_demuxer = {
"vc1",
- "raw vc1",
+ NULL_IF_CONFIG_SMALL("raw VC-1"),
0,
NULL /* vc1_probe */,
video_read_header,
raw_read_partial_packet,
- raw_read_close,
.extensions = "vc1",
.value = CODEC_ID_VC1,
};
#define PCMINPUTDEF(name, long_name, ext, codec) \
AVInputFormat pcm_ ## name ## _demuxer = {\
#name,\
- long_name,\
+ NULL_IF_CONFIG_SMALL(long_name),\
0,\
NULL,\
raw_read_header,\
raw_read_packet,\
- raw_read_close,\
+ NULL,\
pcm_read_seek,\
.flags= AVFMT_GENERIC_INDEX,\
.extensions = ext,\
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
AVOutputFormat pcm_ ## name ## _muxer = {\
#name,\
- long_name,\
+ NULL_IF_CONFIG_SMALL(long_name),\
NULL,\
ext,\
0,\
codec,\
- 0,\
+ CODEC_ID_NONE,\
NULL,\
raw_write_packet,\
.flags= AVFMT_NOTIMESTAMPS,\
#endif
-PCMDEF(s16le, "pcm signed 16 bit little endian format",
- LE_DEF("sw"), CODEC_ID_PCM_S16LE)
-
-PCMDEF(s16be, "pcm signed 16 bit big endian format",
+PCMDEF(s16be, "PCM signed 16 bit big-endian format",
BE_DEF("sw"), CODEC_ID_PCM_S16BE)
-PCMDEF(u16le, "pcm unsigned 16 bit little endian format",
- LE_DEF("uw"), CODEC_ID_PCM_U16LE)
+PCMDEF(s16le, "PCM signed 16 bit little-endian format",
+ LE_DEF("sw"), CODEC_ID_PCM_S16LE)
-PCMDEF(u16be, "pcm unsigned 16 bit big endian format",
+PCMDEF(s8, "PCM signed 8 bit format",
+ "sb", CODEC_ID_PCM_S8)
+
+PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
BE_DEF("uw"), CODEC_ID_PCM_U16BE)
-PCMDEF(s8, "pcm signed 8 bit format",
- "sb", CODEC_ID_PCM_S8)
+PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
+ LE_DEF("uw"), CODEC_ID_PCM_U16LE)
-PCMDEF(u8, "pcm unsigned 8 bit format",
+PCMDEF(u8, "PCM unsigned 8 bit format",
"ub", CODEC_ID_PCM_U8)
-PCMDEF(mulaw, "pcm mu law format",
- "ul", CODEC_ID_PCM_MULAW)
-
-PCMDEF(alaw, "pcm A law format",
+PCMDEF(alaw, "PCM A-law format",
"al", CODEC_ID_PCM_ALAW)
-static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
- int packet_size, ret, width, height;
- AVStream *st = s->streams[0];
-
- width = st->codec->width;
- height = st->codec->height;
-
- packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
- if (packet_size < 0)
- return -1;
-
- ret= av_get_packet(s->pb, pkt, packet_size);
- pkt->pts=
- pkt->dts= pkt->pos / packet_size;
-
- pkt->stream_index = 0;
- if (ret != packet_size) {
- return AVERROR(EIO);
- } else {
- return 0;
- }
-}
-
-AVInputFormat rawvideo_demuxer = {
- "rawvideo",
- "raw video format",
- 0,
- NULL,
- raw_read_header,
- rawvideo_read_packet,
- raw_read_close,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "yuv,cif,qcif,rgb",
- .value = CODEC_ID_RAWVIDEO,
-};
-
-#ifdef CONFIG_MUXERS
-AVOutputFormat rawvideo_muxer = {
- "rawvideo",
- "raw video format",
- NULL,
- "yuv,rgb",
- 0,
- CODEC_ID_NONE,
- CODEC_ID_RAWVIDEO,
- NULL,
- raw_write_packet,
- .flags= AVFMT_NOTIMESTAMPS,
-};
-#endif //CONFIG_MUXERS
-
-#ifdef CONFIG_MUXERS
-static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
-{
- return 0;
-}
-
-AVOutputFormat null_muxer = {
- "null",
- "null video format",
- NULL,
- NULL,
- 0,
-#ifdef WORDS_BIGENDIAN
- CODEC_ID_PCM_S16BE,
-#else
- CODEC_ID_PCM_S16LE,
-#endif
- CODEC_ID_RAWVIDEO,
- NULL,
- null_write_packet,
- .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
-};
-#endif //CONFIG_MUXERS
+PCMDEF(mulaw, "PCM mu-law format",
+ "ul", CODEC_ID_PCM_MULAW)