FFmpeg
Macros | Functions | Variables
nutenc.c File Reference
#include <stdint.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/tree.h"
#include "libavutil/dict.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
#include "libavutil/opt.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/mpegaudiodata.h"
#include "mux.h"
#include "nut.h"
#include "internal.h"
#include "avio_internal.h"
#include "riff.h"
#include "version.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(NUTContext, x)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static AVRational choose_timebase (AVFormatContext *s, AVStream *st, int min_precision)
 Chooses a timebase for muxing the specified stream. More...
 
static int find_expected_header (AVCodecParameters *p, int size, int key_frame, uint8_t out[64])
 
static int find_header_idx (AVFormatContext *s, AVCodecParameters *p, int size, int frame_type)
 
static void build_elision_headers (AVFormatContext *s)
 
static void build_frame_code (AVFormatContext *s)
 
static int get_v_length (uint64_t val)
 Get the length in bytes which is needed to store val as v. More...
 
static void put_v (AVIOContext *bc, uint64_t val)
 Put val using a variable number of bytes. More...
 
static void put_tt (NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val)
 
static void put_str (AVIOContext *bc, const char *string)
 Store a string as vb. More...
 
static void put_s (AVIOContext *bc, int64_t val)
 
static void put_packet (NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, uint64_t startcode)
 
static void write_mainheader (NUTContext *nut, AVIOContext *bc)
 
static int write_streamheader (AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i)
 
static int add_info (AVIOContext *bc, const char *type, const char *value)
 
static int write_globalinfo (NUTContext *nut, AVIOContext *bc)
 
static int write_streaminfo (NUTContext *nut, AVIOContext *bc, int stream_id)
 
static int write_chapter (NUTContext *nut, AVIOContext *bc, int id)
 
static int write_index (NUTContext *nut, AVIOContext *bc)
 
static int write_headers (AVFormatContext *avctx, AVIOContext *bc)
 
static int nut_write_header (AVFormatContext *s)
 
static int get_needed_flags (NUTContext *nut, StreamContext *nus, FrameCode *fc, AVPacket *pkt)
 
static int find_best_header_idx (NUTContext *nut, AVPacket *pkt)
 
static int write_sm_data (AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta)
 
static int nut_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int nut_write_trailer (AVFormatContext *s)
 
static void nut_write_deinit (AVFormatContext *s)
 

Variables

static const AVOption options []
 
class {
      class_name = "nutenc"
 
      item_name = av_default_item_name
 
      option = options
 
      version = LIBAVUTIL_VERSION_INT
 
}; 
 
const FFOutputFormat ff_nut_muxer
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(NUTContext, x)

Definition at line 1224 of file nutenc.c.

◆ E

Definition at line 1225 of file nutenc.c.

Function Documentation

◆ choose_timebase()

static AVRational choose_timebase ( AVFormatContext s,
AVStream st,
int  min_precision 
)
static

Chooses a timebase for muxing the specified stream.

The chosen timebase allows sample accurate timestamps based on the framerate or sample rate for audio streams. It also is at least as precise as 1/min_precision would be.

Definition at line 48 of file nutenc.c.

Referenced by nut_write_header().

◆ find_expected_header()

static int find_expected_header ( AVCodecParameters p,
int  size,
int  key_frame,
uint8_t  out[64] 
)
static

Definition at line 61 of file nutenc.c.

Referenced by find_header_idx().

◆ find_header_idx()

static int find_header_idx ( AVFormatContext s,
AVCodecParameters p,
int  size,
int  frame_type 
)
static

Definition at line 128 of file nutenc.c.

Referenced by build_frame_code().

◆ build_elision_headers()

static void build_elision_headers ( AVFormatContext s)
static

Definition at line 145 of file nutenc.c.

Referenced by nut_write_header().

◆ build_frame_code()

static void build_frame_code ( AVFormatContext s)
static

Definition at line 167 of file nutenc.c.

Referenced by nut_write_header().

◆ get_v_length()

static int get_v_length ( uint64_t  val)
static

Get the length in bytes which is needed to store val as v.

Definition at line 306 of file nutenc.c.

Referenced by nut_write_packet(), and put_v().

◆ put_v()

static void put_v ( AVIOContext bc,
uint64_t  val 
)
static

◆ put_tt()

static void put_tt ( NUTContext nut,
AVRational time_base,
AVIOContext bc,
uint64_t  val 
)
static

Definition at line 329 of file nutenc.c.

Referenced by nut_write_packet(), write_chapter(), and write_index().

◆ put_str()

static void put_str ( AVIOContext bc,
const char *  string 
)
static

Store a string as vb.

Definition at line 338 of file nutenc.c.

Referenced by add_info(), and write_sm_data().

◆ put_s()

static void put_s ( AVIOContext bc,
int64_t  val 
)
static

Definition at line 346 of file nutenc.c.

Referenced by add_info(), write_chapter(), write_mainheader(), and write_sm_data().

◆ put_packet()

static void put_packet ( NUTContext nut,
AVIOContext bc,
AVIOContext dyn_bc,
uint64_t  startcode 
)
static

Definition at line 351 of file nutenc.c.

Referenced by nut_write_packet(), nut_write_trailer(), and write_headers().

◆ write_mainheader()

static void write_mainheader ( NUTContext nut,
AVIOContext bc 
)
static

Definition at line 372 of file nutenc.c.

Referenced by write_headers().

◆ write_streamheader()

static int write_streamheader ( AVFormatContext avctx,
AVIOContext bc,
AVStream st,
int  i 
)
static

Definition at line 452 of file nutenc.c.

Referenced by write_headers().

◆ add_info()

static int add_info ( AVIOContext bc,
const char *  type,
const char *  value 
)
static

Definition at line 509 of file nutenc.c.

Referenced by write_chapter(), write_globalinfo(), and write_streaminfo().

◆ write_globalinfo()

static int write_globalinfo ( NUTContext nut,
AVIOContext bc 
)
static

Definition at line 517 of file nutenc.c.

Referenced by write_headers().

◆ write_streaminfo()

static int write_streaminfo ( NUTContext nut,
AVIOContext bc,
int  stream_id 
)
static

Definition at line 545 of file nutenc.c.

Referenced by write_headers().

◆ write_chapter()

static int write_chapter ( NUTContext nut,
AVIOContext bc,
int  id 
)
static

Definition at line 587 of file nutenc.c.

Referenced by write_headers().

◆ write_index()

static int write_index ( NUTContext nut,
AVIOContext bc 
)
static

Definition at line 615 of file nutenc.c.

Referenced by nut_write_trailer().

◆ write_headers()

static int write_headers ( AVFormatContext avctx,
AVIOContext bc 
)
static

Definition at line 667 of file nutenc.c.

Referenced by nut_write_header(), nut_write_packet(), and nut_write_trailer().

◆ nut_write_header()

static int nut_write_header ( AVFormatContext s)
static

Definition at line 719 of file nutenc.c.

◆ get_needed_flags()

static int get_needed_flags ( NUTContext nut,
StreamContext nus,
FrameCode fc,
AVPacket pkt 
)
static

Definition at line 805 of file nutenc.c.

Referenced by nut_write_packet().

◆ find_best_header_idx()

static int find_best_header_idx ( NUTContext nut,
AVPacket pkt 
)
static

Definition at line 834 of file nutenc.c.

Referenced by nut_write_packet().

◆ write_sm_data()

static int write_sm_data ( AVFormatContext s,
AVIOContext bc,
AVPacket pkt,
int  is_meta 
)
static

Definition at line 853 of file nutenc.c.

Referenced by nut_write_packet().

◆ nut_write_packet()

static int nut_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 963 of file nutenc.c.

◆ nut_write_trailer()

static int nut_write_trailer ( AVFormatContext s)
static

Definition at line 1186 of file nutenc.c.

◆ nut_write_deinit()

static void nut_write_deinit ( AVFormatContext s)
static

Definition at line 1209 of file nutenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "syncpoints", "NUT syncpoint behaviour", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, E, .unit = "syncpoints" },
{ "default", "", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, E, .unit = "syncpoints" },
{ "none", "Disable syncpoints, low overhead and unseekable", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_PIPE}, INT_MIN, INT_MAX, E, .unit = "syncpoints" },
{ "timestamped", "Extend syncpoints with a wallclock timestamp", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_BROADCAST}, INT_MIN, INT_MAX, E, .unit = "syncpoints" },
{ "write_index", "Write index", OFFSET(write_index), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E, },
{ NULL },
}

Definition at line 1226 of file nutenc.c.

◆ class_name

class_name = "nutenc"
private

Definition at line 1236 of file nutenc.c.

◆ item_name

item_name = av_default_item_name
private

Definition at line 1237 of file nutenc.c.

◆ option

option = options
private

Definition at line 1238 of file nutenc.c.

◆ version

version = LIBAVUTIL_VERSION_INT
private

Definition at line 1239 of file nutenc.c.

◆ @416

const { ... }

◆ ff_nut_muxer

const FFOutputFormat ff_nut_muxer
Initial value:
= {
.p.name = "nut",
.p.long_name = NULL_IF_CONFIG_SMALL("NUT"),
.p.mime_type = "video/x-nut",
.p.extensions = "nut",
.priv_data_size = sizeof(NUTContext),
.p.audio_codec = CONFIG_LIBVORBIS ? AV_CODEC_ID_VORBIS :
CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_MP2,
.p.video_codec = AV_CODEC_ID_MPEG4,
.write_header = nut_write_header,
.write_packet = nut_write_packet,
.write_trailer = nut_write_trailer,
.deinit = nut_write_deinit,
.p.codec_tag = ff_nut_codec_tags,
.p.priv_class = &class,
}

Definition at line 1242 of file nutenc.c.

NUT_PIPE
#define NUT_PIPE
Definition: nut.h:114
nut_write_trailer
static int nut_write_trailer(AVFormatContext *s)
Definition: nutenc.c:1186
AVFMT_VARIABLE_FPS
#define AVFMT_VARIABLE_FPS
Format allows variable fps.
Definition: avformat.h:482
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
nut_write_packet
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: nutenc.c:963
nut_write_header
static int nut_write_header(AVFormatContext *s)
Definition: nutenc.c:719
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:447
NUTContext
Definition: nut.h:91
E
#define E
Definition: nutenc.c:1225
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition: codec_id.h:446
write_index
static int write_index(NUTContext *nut, AVIOContext *bc)
Definition: nutenc.c:615
NULL
#define NULL
Definition: coverity.c:32
NUT_BROADCAST
#define NUT_BROADCAST
Definition: nut.h:113
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVFMT_GLOBALHEADER
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:478
ff_nut_codec_tags
const AVCodecTag *const ff_nut_codec_tags[]
Definition: nut.c:253
OFFSET
#define OFFSET(x)
Definition: nutenc.c:1224
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
nut_write_deinit
static void nut_write_deinit(AVFormatContext *s)
Definition: nutenc.c:1209
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:451
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299