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
49 static int av_write(
void * h,
size_t len,
const uint8_t * buf) {
59 nut_muxer_opts_tt mopts = {
67 .max_distance = 32768,
70 nut_stream_header_tt * s;
79 int num, denom, ssize;
93 for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF;
98 s[i].time_base.num = denom;
99 s[i].time_base.den = num;
107 s[i].width = codec->
width;
108 s[i].height = codec->
height;
109 s[i].sample_width = 0;
110 s[i].sample_height = 0;
111 s[i].colorspace_type = 0;
114 s[i].samplerate_denom = 1;
115 s[i].channel_count = codec->
channels;
120 priv->
nut = nut_muxer_init(&mopts, s,
NULL);
135 nut_write_frame_reorder(priv->
nut, &p, pkt->
data);
145 nut_muxer_uninit_reorder(priv->
nut);
148 for(i = 0; priv->
s[i].type != -1; i++ )
av_freep(&priv->
s[i].fourcc);
156 .long_name =
"nut format",
157 .mime_type =
"video/x-nut",
180 static off_t
av_seek(
void * h,
long long pos,
int whence) {
182 if (whence == SEEK_END) {
192 nut_demuxer_opts_tt dopts = {
202 .cache_syncpoints = 1,
204 nut_context_tt * nut = priv->
nut = nut_demuxer_init(&dopts);
205 nut_stream_header_tt * s;
208 if ((ret = nut_read_headers(nut, &s,
NULL))) {
210 nut_demuxer_uninit(nut);
216 for (i = 0; s[i].type != -1 && i < 2; i++) {
220 for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->
codec->
codec_tag |= s[i].fourcc[j]<<(j*8);
237 case NUT_AUDIO_CLASS:
244 case NUT_VIDEO_CLASS:
265 ret = nut_read_next_packet(priv->
nut, &pd);
268 if (ret != NUT_ERR_EOF)
278 ret = nut_read_frame(priv->
nut, &pd.len, pkt->
data);
285 int active_streams[] = { stream_index, -1 };
286 double time_pos = target_ts * priv->
s[stream_index].time_base.num / (double)priv->
s[stream_index].time_base.den;
296 nut_demuxer_uninit(priv->
nut);
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t avio_size(AVIOContext *s)
Get the filesize.
int64_t pos
byte position in stream, -1 if unknown
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
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)
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static off_t av_seek(void *h, long long pos, int whence)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int nut_read_header(AVFormatContext *avf, AVFormatParameters *ap)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int read_header(FFV1Context *f)
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
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)
enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int nut_read_seek(AVFormatContext *avf, int stream_index, int64_t target_ts, int flags)
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
const AVCodecTag ff_codec_wav_tags[]
int flags
A combination of AV_PKT_FLAG values.
static const AVCodecTag nut_tags[]
AVCodecContext * codec
codec context
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
int void avio_flush(AVIOContext *s)
const AVCodecTag ff_codec_bmp_tags[]
int width
picture width / height.
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int read_probe(AVProbeData *p)
enum AVMediaType codec_type
int sample_rate
samples per second
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
static size_t av_read(void *h, size_t len, uint8_t *buf)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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)
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum CodecID id)
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
AVInputFormat ff_libnut_demuxer
int channels
number of audio channels
void * priv_data
Format private data.
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)
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...
preferred ID for decoding MPEG audio layer 1, 2 or 3