+/*
+ * NUT (de)muxing via libnut
+ * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavformat/libnut.c
+ * NUT demuxing and muxing via libnut.
+ * @author Oded Shimon <ods15@ods15.dyndns.org>
+ */
+
#include "avformat.h"
#include "riff.h"
#include <libnut.h>
#define ID_LENGTH (strlen(ID_STRING) + 1)
typedef struct {
- nut_context_t * nut;
- nut_stream_header_t * s;
+ nut_context_tt * nut;
+ nut_stream_header_tt * s;
} NUTContext;
static const AVCodecTag nut_tags[] = {
{ 0, 0 },
};
-#ifdef CONFIG_MUXERS
+#if CONFIG_LIBNUT_MUXER
static int av_write(void * h, size_t len, const uint8_t * buf) {
ByteIOContext * bc = h;
put_buffer(bc, buf, len);
static int nut_write_header(AVFormatContext * avf) {
NUTContext * priv = avf->priv_data;
- ByteIOContext * bc = &avf->pb;
- nut_muxer_opts_t mopts = {
+ ByteIOContext * bc = avf->pb;
+ nut_muxer_opts_tt mopts = {
.output = {
.priv = bc,
.write = av_write,
.max_distance = 32768,
.fti = NULL,
};
- nut_stream_header_t * s;
+ nut_stream_header_tt * s;
int i;
priv->s = s = av_mallocz((avf->nb_streams + 1) * sizeof*s);
s[i].type = codec->codec_type == CODEC_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS;
if (codec->codec_tag) fourcc = codec->codec_tag;
- else fourcc = codec_get_tag(nut_tags, codec->codec_id);
+ else fourcc = ff_codec_get_tag(nut_tags, codec->codec_id);
if (!fourcc) {
- if (codec->codec_type == CODEC_TYPE_VIDEO) fourcc = codec_get_bmp_tag(codec->codec_id);
- if (codec->codec_type == CODEC_TYPE_AUDIO) fourcc = codec_get_wav_tag(codec->codec_id);
+ if (codec->codec_type == CODEC_TYPE_VIDEO) fourcc = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id);
+ if (codec->codec_type == CODEC_TYPE_AUDIO) fourcc = ff_codec_get_tag(ff_codec_wav_tags, codec->codec_id);
}
s[i].fourcc_len = 4;
static int nut_write_packet(AVFormatContext * avf, AVPacket * pkt) {
NUTContext * priv = avf->priv_data;
- nut_packet_t p;
+ nut_packet_tt p;
p.len = pkt->size;
p.stream = pkt->stream_index;
}
static int nut_write_trailer(AVFormatContext * avf) {
- ByteIOContext * bc = &avf->pb;
+ ByteIOContext * bc = avf->pb;
NUTContext * priv = avf->priv_data;
int i;
}
AVOutputFormat libnut_muxer = {
- "nut",
+ "libnut",
"nut format",
"video/x-nut",
"nut",
nut_write_trailer,
.flags = AVFMT_GLOBALHEADER,
};
-#endif //CONFIG_MUXERS
+#endif /* CONFIG_LIBNUT_MUXER */
static int nut_probe(AVProbeData *p) {
- if (p->buf_size >= ID_LENGTH && !memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX;
+ if (!memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX;
return 0;
}
static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
NUTContext * priv = avf->priv_data;
- ByteIOContext * bc = &avf->pb;
- nut_demuxer_opts_t dopts = {
+ ByteIOContext * bc = avf->pb;
+ nut_demuxer_opts_tt dopts = {
.input = {
.priv = bc,
.seek = av_seek,
.read_index = 1,
.cache_syncpoints = 1,
};
- nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts);
- nut_stream_header_t * s;
+ nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts);
+ nut_stream_header_tt * s;
int ret, i;
if ((ret = nut_read_headers(nut, &s, NULL))) {
st->start_time = 0;
st->duration = s[i].max_pts;
- st->codec->codec_id = codec_get_id(nut_tags, st->codec->codec_tag);
+ st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag);
switch(s[i].type) {
case NUT_AUDIO_CLASS:
st->codec->codec_type = CODEC_TYPE_AUDIO;
- if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag);
+ if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag);
st->codec->channels = s[i].channel_count;
st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;
break;
case NUT_VIDEO_CLASS:
st->codec->codec_type = CODEC_TYPE_VIDEO;
- if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag);
+ if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
st->codec->width = s[i].width;
st->codec->height = s[i].height;
- st->codec->sample_aspect_ratio.num = s[i].sample_width;
- st->codec->sample_aspect_ratio.den = s[i].sample_height;
+ st->sample_aspect_ratio.num = s[i].sample_width;
+ st->sample_aspect_ratio.den = s[i].sample_height;
break;
}
if (st->codec->codec_id == CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");
static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) {
NUTContext * priv = avf->priv_data;
- nut_packet_t pd;
+ nut_packet_tt pd;
int ret;
ret = nut_read_next_packet(priv->nut, &pd);
if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY;
pkt->pts = pd.pts;
pkt->stream_index = pd.stream;
- pkt->pos = url_ftell(&avf->pb);
+ pkt->pos = url_ftell(avf->pb);
ret = nut_read_frame(priv->nut, &pd.len, pkt->data);
}
AVInputFormat libnut_demuxer = {
- "nut",
- "nut format",
+ "libnut",
+ NULL_IF_CONFIG_SMALL("NUT format"),
sizeof(NUTContext),
nut_probe,
nut_read_header,