33 #define ID_STRING "nut/multimedia container"
34 #define ID_LENGTH (strlen(ID_STRING) + 1)
38 nut_stream_header_tt *
s;
48 #if CONFIG_LIBNUT_MUXER
59 nut_muxer_opts_tt mopts = {
67 .max_distance = 32768,
70 nut_stream_header_tt *
s;
81 int num, denom, ssize;
95 for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF;
100 s[i].time_base.num = denom;
101 s[i].time_base.den = num;
109 s[i].width = par->
width;
110 s[i].height = par->
height;
111 s[i].sample_width = 0;
112 s[i].sample_height = 0;
113 s[i].colorspace_type = 0;
116 s[i].samplerate_denom = 1;
122 priv->
nut = nut_muxer_init(&mopts, s,
NULL);
137 nut_write_frame_reorder(priv->
nut, &p, pkt->
data);
147 nut_muxer_uninit_reorder(priv->
nut);
150 for(i = 0; priv->
s[i].type != -1; i++ )
av_freep(&priv->
s[i].fourcc);
158 .long_name =
"nut format",
159 .mime_type =
"video/x-nut",
182 static off_t
av_seek(
void *
h, int64_t pos,
int whence) {
184 if (whence == SEEK_END) {
194 nut_demuxer_opts_tt dopts = {
204 .cache_syncpoints = 1,
206 nut_context_tt * nut = priv->
nut = nut_demuxer_init(&dopts);
207 nut_stream_header_tt *
s;
213 if ((ret = nut_read_headers(nut, &s,
NULL))) {
215 nut_demuxer_uninit(nut);
222 for (i = 0; s[i].type != -1 && i < 2; i++) {
229 for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->
codecpar->
codec_tag |= s[i].fourcc[j]<<(j*8);
236 nut_demuxer_uninit(nut);
250 case NUT_AUDIO_CLASS:
257 case NUT_VIDEO_CLASS:
278 ret = nut_read_next_packet(priv->
nut, &pd);
281 if (ret != NUT_ERR_EOF)
291 ret = nut_read_frame(priv->
nut, &pd.len, pkt->
data);
298 int active_streams[] = { stream_index, -1 };
299 double time_pos = target_ts * priv->
s[stream_index].time_base.num / (double)priv->
s[stream_index].time_base.den;
309 nut_demuxer_uninit(priv->
nut);
int64_t avio_size(AVIOContext *s)
Get the filesize.
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).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t(* seek)(void *opaque, int64_t offset, int whence)
This struct describes the properties of an encoded stream.
static int nut_read_header(AVFormatContext *avf)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int nut_read_seek(AVFormatContext *avf, int stream_index, int64_t target_ts, int flags)
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.
void ff_parse_specific_params(AVStream *st, int *au_rate, int *au_ssize, int *au_scale)
static int nut_write_header(AVFormatContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int video_delay
Video only.
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
const AVCodecTag ff_codec_wav_tags[]
int flags
A combination of AV_PKT_FLAG values.
static const AVCodecTag nut_tags[]
int extradata_size
Size of the extradata content in bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
const AVCodecTag ff_codec_bmp_tags[]
static int write_trailer(AVFormatContext *s1)
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVIOContext * pb
I/O context.
static off_t av_seek(void *h, int64_t pos, int whence)
static size_t av_read(void *h, size_t len, uint8_t *buf)
static int nut_write_trailer(AVFormatContext *s)
This structure contains the data a format has to probe a file.
static int nut_probe(AVProbeData *p)
static int nut_read_close(AVFormatContext *s)
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
AVInputFormat ff_libnut_demuxer
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static void * av_mallocz_array(size_t nmemb, size_t size)
AVCodecParameters * codecpar
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
static int nut_read_packet(AVFormatContext *avf, AVPacket *pkt)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...