Go to the documentation of this file.
113 #define MODE_MATROSKAv2 0x01
114 #define MODE_WEBM 0x02
118 #define MAX_TRACKS 126
168 #define MAX_EBML_HEADER_SIZE 35
172 #define MAX_SEEKENTRY_SIZE 21
176 #define MAX_CUETRACKPOS_SIZE 35
179 #define MAX_CUEPOINT_CONTENT_SIZE(num_tracks) 10 + MAX_CUETRACKPOS_SIZE * num_tracks
182 #define OPUS_SEEK_PREROLL 80000000
186 return (
av_log2(
id + 1) - 1) / 7 + 1;
236 bytes = needed_bytes;
241 num |= 1ULL << bytes * 7;
242 for (
i = bytes - 1;
i >= 0;
i--)
255 for (
i = bytes - 1;
i >= 0;
i--)
264 while (
tmp>>=8) bytes++;
268 for (
i = bytes - 1;
i >= 0;
i--)
317 uint64_t expectedsize)
373 uint32_t
id, int64_t *pos)
449 if (numelements > 0) {
530 currentpos = seekhead->
filepos;
550 int64_t cluster_pos, int64_t relative_pos, int64_t
duration)
587 uint64_t
pts = entry->
pts;
591 for (j = 0; j < num_tracks; j++)
592 tracks[j].has_cue = 0;
595 av_assert0(tracknum>=0 && tracknum<num_tracks);
607 for (j = 0; j < num_tracks; j++)
608 tracks[j].has_cue = 0;
611 av_assert0(tracknum>=0 && tracknum<num_tracks);
633 const uint8_t *header_start[3];
635 int first_header_size;
639 first_header_size = 30;
641 first_header_size = 42;
644 first_header_size, header_start, header_len) < 0) {
650 for (j = 0; j < 2; j++) {
653 for (j = 0; j < 3; j++)
654 avio_write(pb, header_start[j], header_len[j]);
691 if (
len >= ((1<<24) - 4)) {
724 extradata_size * 8, 1);
732 "Error parsing AAC extradata, unable to determine samplerate.\n");
779 "Invalid extradata found, ALAC expects a 36-byte "
805 int native_id,
int qt_id)
809 int ret, codecpriv_size;
828 for(
i = 0;
i < 0x5a - 8;
i++)
873 int side_data_size = 0;
874 int ret, colorinfo_size;
909 if (side_data_size) {
951 if (colorinfo_size) {
953 avio_write(pb, colorinfo_ptr, colorinfo_size);
965 int side_data_size = 0;
966 int ret, projection_size;
1015 (
double) spherical->
yaw / (1 << 16));
1016 if (spherical->
pitch)
1018 (
double) spherical->
pitch / (1 << 16));
1019 if (spherical->
roll)
1021 (
double) spherical->
roll / (1 << 16));
1025 if (projection_size) {
1029 avio_write(pb, projection_ptr, projection_size);
1040 switch (field_order) {
1054 switch (field_order) {
1089 int stereo_mode = atoi(
tag->value);
1098 stereo_mode != 10 && stereo_mode != 12) {
1111 switch (stereo->
type) {
1163 "The specified stereo mode is not valid.\n");
1184 int output_sample_rate = 0;
1185 int display_width_div = 1;
1186 int display_height_div = 1;
1208 &output_sample_rate);
1225 }
else if (
tag &&
tag->value) {
1252 codec_id =
"D_WEBVTT/DESCRIPTIONS";
1265 "Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.\n");
1285 av_log(
s,
AV_LOG_ERROR,
"Raw RGB is not supported Natively in Matroska, you can use AVI or NUT or\n"
1286 "If you would like to store it anyway using VFW mode, enable allow_raw_vfw (-allow_raw_vfw 1)\n");
1296 if (codecdelay < 0) {
1329 else if (!native_id) {
1333 s->internal->avoid_negative_ts_use_pts = 0;
1347 &display_height_div);
1361 if (d_width > INT_MAX) {
1365 if (d_width != par->
width || display_width_div != 1 || display_height_div != 1) {
1366 if (mkv->
mode ==
MODE_WEBM || display_width_div != 1 || display_height_div != 1) {
1380 }
else if (display_width_div != 1 || display_height_div != 1) {
1411 if (output_sample_rate)
1430 av_log(
s,
AV_LOG_ERROR,
"Only audio, video, and subtitles are supported for Matroska.\n");
1450 int i,
ret, default_stream_exists = 0;
1460 for (
i = 0;
i <
s->nb_streams;
i++) {
1464 for (
i = 0;
i <
s->nb_streams;
i++) {
1501 for (
i = 0;
i <
s->nb_chapters;
i++) {
1504 int64_t chapterstart =
av_rescale_q(
c->start,
c->time_base, scale);
1507 if (chapterstart < 0 || chapterstart > chapterend || chapterend < 0) {
1509 "Invalid chapter start (%"PRId64
") or end (%"PRId64
").\n",
1510 chapterstart, chapterend);
1548 if ((p = strrchr(p,
'-')) &&
1556 else if (*p >=
'a' && *p <=
'z')
1659 for (
i = 0;
i <
s->nb_streams;
i++) {
1673 for (
i = 0;
i <
s->nb_streams;
i++) {
1683 i + 1, &tag_target);
1701 for (
i = 0;
i <
s->nb_chapters;
i++) {
1759 for (
i = 0;
i <
s->nb_streams;
i++) {
1764 const char *mimetype =
NULL;
1785 mimetype = t->
value;
1801 "it cannot be deduced from the codec id.\n",
i);
1842 av_log(
s,
AV_LOG_DEBUG,
"get_metadata_duration found duration in context metadata: %" PRId64
"\n",
us);
1846 for (
i = 0;
i <
s->nb_streams;
i++) {
1865 int64_t creation_time;
1867 if (!strcmp(
s->oformat->name,
"webm")) {
1878 for (
i = 0;
i <
s->nb_streams;
i++) {
1931 uint32_t segment_uid[4];
1936 for (
i = 0;
i < 4;
i++)
1942 const char *ident =
"Lavf";
1949 int64_t date_utc = (creation_time - 978307200000000LL) * 1000;
1951 AV_WB64(date_utc_buf, date_utc);
1961 if (
s->duration > 0) {
1964 av_log(
s,
AV_LOG_DEBUG,
"Write early duration from recording time = %" PRIu64
"\n", scaledDuration);
1965 }
else if (metadata_duration > 0) {
1968 av_log(
s,
AV_LOG_DEBUG,
"Write early duration from metadata = %" PRIu64
"\n", scaledDuration);
1992 for (
i = 0;
i <
s->nb_chapters;
i++)
2018 if (
s->metadata_header_padding > 0) {
2019 if (
s->metadata_header_padding == 1)
2020 s->metadata_header_padding++;
2059 int size = pkt_size + 4;
2086 if (srclen <
header.blocksize) {
2106 srclen -=
header.blocksize;
2127 uint64_t additional_id = 0;
2128 int64_t discard_padding = 0;
2130 ebml_master block_group, block_additions, block_more;
2137 "Writing block of size %d with pts %" PRId64
", dts %" PRId64
", "
2138 "duration %" PRId64
" at relative offset %" PRId64
" in cluster "
2139 "at offset %" PRId64
". TrackNumber %d, keyframe %d\n",
2173 if (side_data && side_data_size >= 10) {
2183 if (side_data_size < 8) {
2186 additional_id =
AV_RB64(side_data);
2188 side_data_size -= 8;
2192 if ((side_data_size && additional_id == 1) || discard_padding) {
2200 avio_w8(pb, 0x80 | track_number);
2213 if (discard_padding) {
2217 if (side_data_size && additional_id == 1) {
2227 if ((side_data_size && additional_id == 1) || discard_padding) {
2238 int id_size, settings_size,
size;
2239 const char *
id, *settings;
2241 const int flags = 0;
2251 settings = settings ? settings :
"";
2253 size = id_size + 1 + settings_size + 1 +
pkt->
size;
2258 "Writing block of size %d with pts %" PRId64
", dts %" PRId64
", "
2259 "duration %" PRId64
" at relative offset %" PRId64
" in cluster "
2260 "at offset %" PRId64
". TrackNumber %d, keyframe %d\n",
2286 "Starting new cluster at offset %" PRIu64
" bytes, "
2287 "pts %" PRIu64
", dts %" PRIu64
"\n",
2298 int side_data_size = 0,
ret;
2306 int filler, output_sample_rate = 0;
2309 &output_sample_rate);
2312 if (!output_sample_rate)
2318 memcpy(par->
extradata, side_data, side_data_size);
2331 av_log(
s,
AV_LOG_ERROR,
"Error parsing AAC extradata, unable to determine samplerate.\n");
2352 memcpy(codecpriv_par->
extradata, side_data, side_data_size);
2373 if (!codecpriv_size) {
2386 memcpy(par->
extradata, side_data, side_data_size);
2408 int64_t relative_packet_pos;
2419 if ((int16_t)cluster_time != cluster_time) {
2452 #if FF_API_CONVERGENCE_DURATION
2489 int64_t cluster_time;
2491 int start_new_cluster;
2511 start_new_cluster = keyframe;
2516 start_new_cluster = 1;
2521 cluster_size > 4 * 1024))) {
2522 start_new_cluster = 1;
2524 start_new_cluster = 0;
2527 if (mkv->
cluster_pos != -1 && start_new_cluster) {
2540 mkv->
is_dash ? start_new_cluster : 0);
2544 "Could not write cached audio packet ret:%d\n",
ret);
2569 "Flushing cluster at offset %" PRIu64
" bytes\n",
2582 int64_t currentpos, cuespos;
2591 "Could not write cached audio packet ret:%d\n",
ret);
2617 "Insufficient space reserved for cues: %d "
2618 "(needed: %" PRId64
").\n",
2623 if (cues_end < cuespos + mkv->reserve_cues_space)
2625 (cues_end - cuespos));
2660 for (
i = 0;
i <
s->nb_streams; ++
i) {
2665 char duration_string[20] =
"";
2672 snprintf(duration_string, 20,
"%02d:%02d:%012.9f",
2673 (
int) duration_sec / 3600, ((
int) duration_sec / 60) % 60,
2674 fmod(duration_sec, 60));
2730 "At most %d streams are supported for muxing in Matroska\n",
2735 for (
i = 0;
i <
s->nb_streams;
i++) {
2743 "The Matroska muxer does not yet support muxing %s\n",
2749 if (
s->avoid_negative_ts < 0) {
2750 s->avoid_negative_ts = 1;
2751 s->internal->avoid_negative_ts_use_pts = 1;
2754 for (
i = 0;
i <
s->nb_streams;
i++) {
2807 #define OFFSET(x) offsetof(MatroskaMuxContext, x)
2808 #define FLAGS AV_OPT_FLAG_ENCODING_PARAM
2810 {
"reserve_index_space",
"Reserve a given amount of space (in bytes) at the beginning of the file for the index (cues).",
OFFSET(reserve_cues_space),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
FLAGS },
2811 {
"cluster_size_limit",
"Store at most the provided amount of bytes in a cluster. ",
OFFSET(cluster_size_limit),
AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX,
FLAGS },
2812 {
"cluster_time_limit",
"Store at most the provided number of milliseconds in a cluster.",
OFFSET(cluster_time_limit),
AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX,
FLAGS },
2813 {
"dash",
"Create a WebM file conforming to WebM DASH specification",
OFFSET(is_dash),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
FLAGS },
2814 {
"dash_track_number",
"Track number for the DASH stream",
OFFSET(dash_track_number),
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127,
FLAGS },
2817 {
"write_crc32",
"write a CRC32 element inside every Level 1 element",
OFFSET(write_crc),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
FLAGS },
2821 #if CONFIG_MATROSKA_MUXER
2822 static const AVClass matroska_class = {
2832 .mime_type =
"video/x-matroska",
2833 .extensions =
"mkv",
2835 .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
2837 .video_codec = CONFIG_LIBX264_ENCODER ?
2852 .priv_class = &matroska_class,
2856 #if CONFIG_WEBM_MUXER
2857 static const AVClass webm_class = {
2867 .mime_type =
"video/webm",
2868 .extensions =
"webm",
2881 .priv_class = &webm_class,
2885 #if CONFIG_MATROSKA_AUDIO_MUXER
2886 static const AVClass mka_class = {
2895 .mime_type =
"audio/x-matroska",
2896 .extensions =
"mka",
2898 .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
2911 .priv_class = &mka_class,
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
#define MAX_TRACKS
Maximum number of tracks allowed in a Matroska file (with track numbers in range 1 to 126 (inclusive)
int64_t * stream_durations
#define MATROSKA_ID_TAGTARGETS_ATTACHUID
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define MATROSKA_ID_VIDEODISPLAYUNIT
#define FF_ENABLE_DEPRECATION_WARNINGS
#define MATROSKA_ID_CODECPRIVATE
#define MATROSKA_ID_TRACKNUMBER
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define MATROSKA_ID_CHAPSTRING
static int mkv_init(struct AVFormatContext *s)
#define MATROSKA_ID_TAGTARGETS
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define MATROSKA_ID_CLUSTERTIMECODE
static int ebml_num_size(uint64_t num)
Calculate how many bytes are needed to represent a given number in EBML.
@ AVIO_DATA_MARKER_BOUNDARY_POINT
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
static EbmlSyntax ebml_header[]
static av_cold int init(AVCodecContext *avctx)
#define MATROSKA_ID_TITLE
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void put_ebml_size_unknown(AVIOContext *pb, int bytes)
Write an EBML size meaning "unknown size".
enum AVMediaType codec_type
General type of the encoded data.
enum AVSphericalProjection projection
Projection type.
uint32_t bound_bottom
Distance from the bottom edge.
#define MATROSKA_ID_VIDEOCOLORMASTERINGMETA
#define MATROSKA_ID_CHAPTERFLAGENABLED
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
This struct describes the properties of an encoded stream.
#define EBML_ID_EBMLMAXSIZELENGTH
enum AVColorSpace color_space
#define MATROSKA_ID_VIDEOPIXELWIDTH
@ MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR
#define MATROSKA_ID_AUDIOSAMPLINGFREQ
#define OPUS_SEEK_PREROLL
Seek preroll value for opus.
#define MATROSKA_ID_DISCARDPADDING
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
@ MATROSKA_VIDEO_FIELDORDER_BB
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
#define MATROSKA_ID_DURATION
#define MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
#define MATROSKA_ID_VIDEOCOLORPRIMARIES
#define MATROSKA_ID_SEGMENT
unsigned MaxCLL
Max content light level (cd/m^2).
static av_cold int end(AVCodecContext *avctx)
static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, uint32_t elementid, unsigned int uid)
#define MATROSKA_ID_CHAPTERS
@ AVCOL_TRC_NB
Not part of ABI.
#define MATROSKA_ID_VIDEOCOLOR_BY
#define MATROSKA_ID_BLOCKDURATION
#define MATROSKA_ID_VIDEOCOLORRANGE
#define MATROSKA_ID_BLOCK
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
#define MATROSKA_ID_TRACKDEFAULTDURATION
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install targets
static void put_xiph_size(AVIOContext *pb, int size)
@ AVCOL_SPC_NB
Not part of ABI.
AVRational avg_frame_rate
Average framerate.
@ MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED
static int mkv_write_attachments(AVFormatContext *s)
static int mkv_blockgroup_size(int pkt_size)
#define MATROSKA_ID_DATEUTC
static int ebml_id_size(uint32_t id)
static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, MatroskaMuxContext *mkv, uint32_t id)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
@ MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR
void * av_mallocz_array(size_t nmemb, size_t size)
#define AV_LOG_VERBOSE
Detailed information.
const AVCodecTag ff_codec_wav_tags[]
static void put_ebml_binary(AVIOContext *pb, uint32_t elementid, const void *buf, int size)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided AVIOContext.
@ AV_SPHERICAL_EQUIRECTANGULAR_TILE
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection.
#define MATROSKA_ID_CUETIME
static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
#define MATROSKA_ID_CUERELATIVEPOSITION
#define MAX_PCE_SIZE
Maximum size of a PCE including the 3-bit ID_PCE.
int ff_flac_is_native_layout(uint64_t channel_layout)
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
@ AV_SPHERICAL_EQUIRECTANGULAR
Video represents a sphere mapped on a flat surface using equirectangular projection.
enum AVMediaType codec_type
#define MATROSKA_ID_CHAPLANG
#define MATROSKA_ID_CUEDURATION
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
@ MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
@ MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
#define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX
void avio_wl16(AVIOContext *s, unsigned int val)
enum AVColorPrimaries color_primaries
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
#define MATROSKA_ID_VIDEOCOLOR_WHITEY
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
static ebml_master start_ebml_master(AVIOContext *pb, uint32_t elementid, uint64_t expectedsize)
#define MATROSKA_ID_AUDIOOUTSAMPLINGFREQ
#define MATROSKA_ID_VIDEOPROJECTIONPRIVATE
@ MATROSKA_VIDEO_STEREOMODE_TYPE_MONO
int bits_per_raw_sample
This is the number of valid bits in each output sample.
attribute_deprecated int64_t convergence_duration
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
#define MATROSKA_ID_CHAPTERDISPLAY
static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, uint32_t elementid, uint64_t filepos)
#define MATROSKA_ID_TRACKUID
static int webm_query_codec(enum AVCodecID codec_id, int std_compliance)
#define EBML_ID_DOCTYPEVERSION
@ AVCOL_RANGE_NB
Not part of ABI.
static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
const char *const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB]
mkv_seekhead_entry * entries
static int query_codec(enum AVCodecID id, int std_compliance)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define MATROSKA_ID_VIDEOALPHAMODE
#define us(width, name, range_min, range_max, subs,...)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define MATROSKA_ID_VIDEOCOLOR_WHITEX
@ MATROSKA_TRACK_TYPE_METADATA
@ MATROSKA_VIDEO_FIELDORDER_TT
@ AV_CODEC_ID_DVB_SUBTITLE
MatroskaVideoStereoModeType
enum AVColorTransferCharacteristic color_trc
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int mkv_write_tracks(AVFormatContext *s)
#define MATROSKA_ID_BLOCKADDITIONAL
@ AV_STEREO3D_FRAMESEQUENCE
Views are alternated temporally.
@ AV_PKT_DATA_WEBVTT_SETTINGS
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void end_ebml_master_crc32_preliminary(AVIOContext *pb, AVIOContext **dyn_cp, MatroskaMuxContext *mkv, uint32_t id, int64_t *pos)
Complete ebml master without destroying the buffer, allowing for later updates.
#define MATROSKA_ID_VIDEOFIELDORDER
static const AVOption options[]
uint32_t chapter_id_offset
static void put_ebml_id(AVIOContext *pb, uint32_t id)
#define EBML_ID_EBMLMAXIDLENGTH
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int64_t relative_pos
relative offset from the position of the cluster containing the block
@ AV_STEREO3D_LINES
Views are packed per line, as if interlaced.
static void end_ebml_master(AVIOContext *pb, ebml_master master)
#define MATROSKA_ID_FILEUID
@ MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
@ AVCOL_PRI_NB
Not part of ABI.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
#define MATROSKA_ID_VIDEODISPLAYWIDTH
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static int mkv_write_flush_packet(AVFormatContext *s, AVPacket *pkt)
@ MATROSKA_VIDEO_FIELDORDER_BT
int64_t cluster_pos
file offset of the current cluster
static int put_wv_codecpriv(AVIOContext *pb, AVCodecParameters *par)
#define MATROSKA_ID_TAGNAME
uint32_t bound_top
Distance from the top edge.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define MATROSKA_ID_TIMECODESCALE
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define MATROSKA_ID_CUETRACKPOSITION
static const AVCodecTag additional_audio_tags[]
#define MATROSKA_ID_SEEKENTRY
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define MATROSKA_ID_TRACKTYPE
static const AVCodecTag additional_video_tags[]
@ MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR
#define MATROSKA_ID_SEGMENTUID
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t cluster_time_limit
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
#define MATROSKA_ID_AUDIOCHANNELS
static int mkv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
#define MATROSKA_ID_VIDEOSTEREOMODE
static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_cue)
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
const CodecTags ff_webm_codec_tags[]
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int flags
Additional information about the frame packing.
#define MATROSKA_ID_VIDEOCOLORSPACE
#define MATROSKA_ID_TRACKNAME
static int get_aac_sample_rates(AVFormatContext *s, uint8_t *extradata, int extradata_size, int *sample_rate, int *output_sample_rate)
#define EBML_ID_DOCTYPEREADVERSION
AVCodecParameters * codecpar
Codec parameters associated with this stream.
@ MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM
#define LIBAVUTIL_VERSION_INT
static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int native_id, int qt_id)
#define MATROSKA_ID_BLOCKGROUP
#define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN
Describe the class of an AVClass context structure.
static void mkv_start_new_cluster(AVFormatContext *s, AVPacket *pkt)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define MATROSKA_ID_ATTACHMENTS
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define MATROSKA_ID_CHAPTERATOM
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
@ MATROSKA_TRACK_TYPE_AUDIO
@ MATROSKA_VIDEO_DISPLAYUNIT_DAR
static int write_trailer(AVFormatContext *s1)
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, int i, AVIOContext *pb, int default_stream_exists)
Rational number (pair of numerator and denominator).
#define MATROSKA_ID_WRITINGAPP
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to a data buffer.
enum AVPacketSideDataType type
#define MATROSKA_ID_VIDEOCOLOR_GY
@ AV_CODEC_ID_DVD_SUBTITLE
const char * av_default_item_name(void *ptr)
Return the context name.
#define MATROSKA_ID_SIMPLETAG
#define MATROSKA_ID_VIDEOPROJECTION
#define MATROSKA_ID_SEEKID
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes)
Write a number in EBML variable length format.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int ff_flac_write_header(AVIOContext *pb, uint8_t *extradata, int extradata_size, int last_block)
void avio_w8(AVIOContext *s, int b)
#define MATROSKA_ID_CHAPTERTIMESTART
int64_t sample_rate_offset
@ MATROSKA_TRACK_TYPE_VIDEO
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
static int64_t get_metadata_duration(AVFormatContext *s)
#define MATROSKA_ID_FILEMIMETYPE
#define MATROSKA_ID_VIDEODISPLAYHEIGHT
const CodecMime ff_mkv_image_mime_tags[]
#define MATROSKA_ID_TRACKAUDIO
@ AVCOL_RANGE_UNSPECIFIED
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
static void put_ebml_float(AVIOContext *pb, uint32_t elementid, double val)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define MATROSKA_ID_VIDEOCOLORMAXCLL
#define MATROSKA_ID_TRACKENTRY
int extradata_size
Size of the extradata content in bytes.
int ff_wv_parse_header(WvHeader *wv, const uint8_t *data)
Parse a WavPack block header.
static int mkv_write_header(AVFormatContext *s)
int64_t duration
duration of the block according to time base
const AVCodecTag ff_codec_movvideo_tags[]
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, unsigned int uid, ebml_master *tag)
#define MATROSKA_ID_AUDIOBITDEPTH
Context structure for the Lagged Fibonacci PRNG.
@ MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT
#define MATROSKA_ID_TRACKFLAGDEFAULT
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
@ AV_SPHERICAL_CUBEMAP
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
@ AV_STEREO3D_CHECKERBOARD
Views are packed in a checkerboard-like structure per pixel.
static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, AVIOContext *dyn_cp)
#define MATROSKA_ID_TRACKFLAGLACING
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define MATROSKA_ID_VIDEOCOLOR_GX
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
uint32_t bound_right
Distance from the right edge.
static void mkv_write_field_order(AVIOContext *pb, int mode, enum AVFieldOrder field_order)
static int mkv_check_tag(AVDictionary *m, uint32_t elementid)
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
#define MATROSKA_ID_FILEDATA
static int mkv_strip_wavpack(const uint8_t *src, uint8_t **pdst, int *size)
int sizebytes
how many bytes were reserved for the size
static int mkv_add_cuepoint(mkv_cues *cues, int stream, int tracknum, int64_t ts, int64_t cluster_pos, int64_t relative_pos, int64_t duration)
#define MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH
#define MATROSKA_ID_BLOCKMORE
const CodecMime ff_mkv_mime_tags[]
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define MATROSKA_ID_VIDEOCOLORMAXFALL
#define FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX
Tell ff_put_wav_header() to use WAVEFORMATEX even for PCM codecs.
@ AVCHROMA_LOC_UNSPECIFIED
static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
const char const char void * val
@ AVIO_DATA_MARKER_SYNC_POINT
A point in the output bytestream where a decoder can start decoding (i.e.
static int start_ebml_master_crc32(AVIOContext **dyn_cp, MatroskaMuxContext *mkv)
#define MATROSKA_ID_POINTENTRY
static const uint8_t header[24]
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
uint32_t padding
Number of pixels to pad from the edge of each cube face.
static const AVCodecTag additional_subtitle_tags[]
void avio_wl32(AVIOContext *s, unsigned int val)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
int flags
A combination of AV_PKT_FLAG values.
static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStream *st)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int mkv_write_trailer(AVFormatContext *s)
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
#define MATROSKA_ID_VIDEOPIXELHEIGHT
#define FF_COMPLIANCE_NORMAL
static int mkv_write_tags(AVFormatContext *s)
#define MATROSKA_ID_MUXINGAPP
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
#define MATROSKA_ID_EDITIONFLAGDEFAULT
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
#define MATROSKA_ID_FILEDESC
#define MAX_SEEKENTRY_SIZE
2 bytes * 3 for EBML IDs, 3 1-byte EBML lengths, 8 bytes for 64 bit offset, 4 bytes for target EBML I...
#define MATROSKA_ID_VIDEOPROJECTIONTYPE
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the provided AVIOContext.
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
#define MATROSKA_ID_FILENAME
static void put_ebml_void(AVIOContext *pb, uint64_t size)
Write a void element of a given size.
int32_t roll
Rotation around the forward vector [-180, 180].
#define MATROSKA_ID_CODECID
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
static void mkv_free(MatroskaMuxContext *mkv)
Free the members allocated in the mux context.
mkv_attachments * attachments
#define AV_TIME_BASE
Internal time base represented as integer.
#define MATROSKA_ID_CUECLUSTERPOSITION
int64_t cluster_pos
file offset of the cluster containing the block
#define MATROSKA_ID_CUETRACK
#define MATROSKA_ID_SEEKPOSITION
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
#define MATROSKA_ID_CLUSTER
#define MATROSKA_ID_TRACKLANGUAGE
int64_t pos
absolute offset in the containing AVIOContext where the master's elements start
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)
#define MATROSKA_ID_VIDEOFLAGINTERLACED
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const AVMetadataConv ff_mkv_metadata_conv[]
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par)
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
enum AVColorRange color_range
Video only.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int mkv_check_tag_name(const char *name, uint32_t elementid)
#define MATROSKA_ID_EDITIONFLAGHIDDEN
#define MATROSKA_ID_CHAPTERUID
enum AVFieldOrder field_order
Video only.
@ MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
#define MAX_EBML_HEADER_SIZE
2 bytes * 7 for EBML IDs, 7 1-byte EBML lengths, 6 1-byte uint, 8 byte for "matroska" doctype string
#define MATROSKA_ID_VIDEOPROJECTIONPOSEYAW
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint32_t blockid, AVPacket *pkt, int keyframe)
int disposition
AV_DISPOSITION_* bit field.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
@ AV_STEREO3D_COLUMNS
Views are packed per column.
int32_t pitch
Rotation around the right vector [-90, 90].
int nb_side_data
The number of elements in the AVStream.side_data array.
enum AVStereo3DType type
How views are packed within the video.
#define MATROSKA_ID_VIDEOCOLOR_BX
#define MATROSKA_ID_TAGSTRING
static void put_ebml_string(AVIOContext *pb, uint32_t elementid, const char *str)
#define MATROSKA_ID_VIDEOCOLORMATRIXCOEFF
#define MATROSKA_ID_SIMPLEBLOCK
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
enum AVChromaLocation chroma_location
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
#define MATROSKA_ID_EDITIONENTRY
static int64_t mkv_write_seekhead(AVIOContext *pb, MatroskaMuxContext *mkv)
Write the seek head to the file and free it.
void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int ignore_extradata)
static int mkv_query_codec(enum AVCodecID codec_id, int std_compliance)
const AVCodecTag ff_codec_bmp_tags[]
#define EBML_ID_EBMLVERSION
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define MATROSKA_ID_TAGLANG
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
#define MATROSKA_ID_VIDEOCOLOR
#define MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS
static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
#define MATROSKA_ID_VIDEOCOLOR_RX
int(* filler)(InterplayACMContext *s, unsigned ind, unsigned col)
@ MATROSKA_TRACK_TYPE_SUBTITLE
int64_t * stream_duration_offsets
static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, AVStream *st)
#define MAX_CUEPOINT_CONTENT_SIZE(num_tracks)
per-cuepoint - 1 1-byte EBML ID, 1 1-byte EBML size, 8-byte uint max
@ MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR
int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, int first_header_size, const uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use.
int reserved_size
-1 if appending to file
void avio_wb64(AVIOContext *s, uint64_t val)
#define MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ
#define FF_DISABLE_DEPRECATION_WARNINGS
static mkv_seekhead * mkv_start_seekhead(AVIOContext *pb, int64_t segment_offset, int numelements)
Initialize a mkv_seekhead element to be ready to index level 1 Matroska elements.
char * av_strdup(const char *s)
Duplicate a string.
#define MATROSKA_ID_BLOCKREFERENCE
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int ff_av1_filter_obus_buf(const uint8_t *buf, uint8_t **out, int *size)
Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and write the resulting bitstream ...
#define MATROSKA_ID_VIDEOCOLOR_RY
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
@ MATROSKA_VIDEO_FIELDORDER_TB
uint32_t bound_left
Distance from the left edge.
int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
#define MATROSKA_ID_TRACKVIDEO
const CodecTags ff_mkv_codec_tags[]
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
#define MATROSKA_ID_TRACKFLAGFORCED
@ MATROSKA_VIDEO_STEREOMODE_TYPE_NB
#define EBML_ID_EBMLREADVERSION
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
This structure stores compressed data.
static int mkv_write_chapters(AVFormatContext *s)
static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, AVStream *st, int mode, int *h_width, int *h_height)
#define MATROSKA_ID_CHAPTERFLAGHIDDEN
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define MATROSKA_ID_ATTACHEDFILE
#define MATROSKA_ID_CODECDELAY
uint64_t channel_layout
Audio only.
static mkv_cues * mkv_start_cues(int64_t segment_offset)
int64_t segment_offset
the file offset to the beginning of the segment
#define MAX_CUETRACKPOS_SIZE
per-cuepoint-track - 5 1-byte EBML IDs, 5 1-byte EBML sizes, 3 8-byte uint max and one 1-byte uint fo...
void ffio_fill(AVIOContext *s, int b, int count)
void avio_wb16(AVIOContext *s, unsigned int val)
#define flags(name, subs,...)
#define MATROSKA_ID_TAGTARGETS_TRACKUID
#define MATROSKA_ID_CHAPTERTIMEEND
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MATROSKA_ID_TRACKS
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
int64_t last_track_timestamp[MAX_TRACKS]
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
static void write_header(FFV1Context *f)
static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
#define MATROSKA_ID_SEEKPREROLL
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val)
#define MATROSKA_ID_SEEKHEAD
int initial_padding
Audio only.
#define MATROSKA_ID_VIDEOPROJECTIONPOSEROLL
#define MATROSKA_ID_BLOCKADDID
This structure describes how to handle spherical videos, outlining information about projection,...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
int32_t yaw
Rotation around the up vector [-180, 180].
#define MATROSKA_ID_TAGTARGETS_CHAPTERUID
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
@ MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define MATROSKA_ID_BLOCKADDITIONS