FFmpeg
Loading...
Searching...
No Matches
asfenc.c File Reference
#include "config_components.h"
#include "libavutil/avassert.h"
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavcodec/codec_desc.h"
#include "avformat.h"
#include "avlanguage.h"
#include "avio_internal.h"
#include "internal.h"
#include "mux.h"
#include "riff.h"
#include "asf.h"

Go to the source code of this file.

Data Structures

struct  ASFStream
 
struct  ASFContext
 

Macros

#define ASF_INDEXED_INTERVAL   10000000
 
#define ASF_INDEX_BLOCK   (1<<9)
 
#define ASF_PAYLOADS_PER_PACKET   63
 
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE   0x2
 
#define ASF_PACKET_ERROR_CORRECTION_FLAGS
 
#define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE   0
 
#define ASF_PPI_PROPERTY_FLAGS
 
#define ASF_PPI_LENGTH_TYPE_FLAGS   0
 
#define ASF_PAYLOAD_FLAGS   ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
 
#define ASF_PPI_SEQUENCE_FIELD_SIZE   1
 
#define ASF_PPI_SEQUENCE_FIELD_SIZE   2
 
#define ASF_PPI_SEQUENCE_FIELD_SIZE   4
 
#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   1
 
#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   2
 
#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   4
 
#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   1
 
#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   2
 
#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   4
 
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   1
 
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   2
 
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   4
 
#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   1
 
#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   2
 
#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   4
 
#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   1
 
#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   2
 
#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   4
 
#define ASF_PAYLOAD_LENGTH_FIELD_SIZE   1
 
#define ASF_PAYLOAD_LENGTH_FIELD_SIZE   2
 
#define PACKET_HEADER_MIN_SIZE
 
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH   0x08
 
#define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
 
#define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
 
#define SINGLE_PAYLOAD_HEADERS
 
#define MULTI_PAYLOAD_HEADERS
 
#define DATA_HEADER_SIZE   50
 
#define PACKET_SIZE_MAX   65536
 
#define PACKET_SIZE_MIN   100
 
#define PREROLL_TIME   3100
 

Functions

static void put_str16 (AVIOContext *s, AVIOContext *dyn_buf, const char *tag)
 
static int64_t put_header (AVIOContext *pb, const ff_asf_guid *g)
 
static void end_header (AVIOContext *pb, int64_t pos)
 
static void put_chunk (AVFormatContext *s, int type, int payload_length, int flags)
 
static int32_t get_send_time (ASFContext *asf, int64_t pres_time, uint64_t *offset)
 
static void asf_write_markers (AVFormatContext *s, AVIOContext *dyn_buf)
 
static int asf_write_header1 (AVFormatContext *s, int64_t file_size, int64_t data_chunk_size)
 
static int asf_write_header (AVFormatContext *s)
 
static int asf_write_stream_header (AVFormatContext *s)
 
static int put_payload_parsing_info (AVFormatContext *s, unsigned sendtime, unsigned duration, int nb_payloads, int padsize)
 
static void flush_packet (AVFormatContext *s)
 
static void put_payload_header (AVFormatContext *s, ASFStream *stream, int64_t presentation_time, int m_obj_size, int m_obj_offset, int payload_len, int flags)
 
static void put_frame (AVFormatContext *s, ASFStream *stream, AVStream *avst, int64_t timestamp, const uint8_t *buf, int m_obj_size, int flags)
 
static int update_index (AVFormatContext *s, int start_sec, uint32_t packet_number, uint16_t packet_count, uint64_t packet_offset)
 
static int asf_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int asf_write_index (AVFormatContext *s, const ASFIndex *index, uint16_t max, uint32_t count)
 
static int asf_write_trailer (AVFormatContext *s)
 
static void asf_deinit (AVFormatContext *s)
 

Variables

static const AVCodecTag codec_asf_bmp_tags []
 
static const AVCodecTag *const asf_codec_tags []
 
static const AVOption asf_options []
 
static const AVClass asf_muxer_class
 

Macro Definition Documentation

◆ ASF_INDEXED_INTERVAL

#define ASF_INDEXED_INTERVAL   10000000

Definition at line 38 of file asfenc.c.

Referenced by asf_write_index(), and asf_write_packet().

◆ ASF_INDEX_BLOCK

#define ASF_INDEX_BLOCK   (1<<9)

Definition at line 39 of file asfenc.c.

Referenced by asf_write_header(), and update_index().

◆ ASF_PAYLOADS_PER_PACKET

#define ASF_PAYLOADS_PER_PACKET   63

Definition at line 40 of file asfenc.c.

Referenced by put_frame().

◆ ASF_PACKET_ERROR_CORRECTION_DATA_SIZE

#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE   0x2

Definition at line 42 of file asfenc.c.

◆ ASF_PACKET_ERROR_CORRECTION_FLAGS

#define ASF_PACKET_ERROR_CORRECTION_FLAGS
Value:
#define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT
Definition asf.h:128
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
Definition asfdec_o.c:45

Definition at line 43 of file asfenc.c.

Referenced by put_payload_parsing_info().

◆ ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE

#define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE   0

Definition at line 50 of file asfenc.c.

◆ ASF_PPI_PROPERTY_FLAGS

#define ASF_PPI_PROPERTY_FLAGS
Value:
#define ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE
Definition asf.h:165
#define ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE
Definition asf.h:175
#define ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE
Definition asf.h:180
#define ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD
Definition asf.h:172

Definition at line 53 of file asfenc.c.

Referenced by put_payload_parsing_info().

◆ ASF_PPI_LENGTH_TYPE_FLAGS

#define ASF_PPI_LENGTH_TYPE_FLAGS   0

Definition at line 59 of file asfenc.c.

Referenced by put_payload_parsing_info().

◆ ASF_PAYLOAD_FLAGS

#define ASF_PAYLOAD_FLAGS   ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD

Definition at line 61 of file asfenc.c.

Referenced by put_payload_parsing_info().

◆ ASF_PPI_SEQUENCE_FIELD_SIZE [1/3]

#define ASF_PPI_SEQUENCE_FIELD_SIZE   1

Definition at line 64 of file asfenc.c.

◆ ASF_PPI_SEQUENCE_FIELD_SIZE [2/3]

#define ASF_PPI_SEQUENCE_FIELD_SIZE   2

Definition at line 64 of file asfenc.c.

◆ ASF_PPI_SEQUENCE_FIELD_SIZE [3/3]

#define ASF_PPI_SEQUENCE_FIELD_SIZE   4

Definition at line 64 of file asfenc.c.

◆ ASF_PPI_PACKET_LENGTH_FIELD_SIZE [1/3]

#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   1

Definition at line 77 of file asfenc.c.

◆ ASF_PPI_PACKET_LENGTH_FIELD_SIZE [2/3]

#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   2

Definition at line 77 of file asfenc.c.

◆ ASF_PPI_PACKET_LENGTH_FIELD_SIZE [3/3]

#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE   4

Definition at line 77 of file asfenc.c.

◆ ASF_PPI_PADDING_LENGTH_FIELD_SIZE [1/3]

#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   1

Definition at line 90 of file asfenc.c.

◆ ASF_PPI_PADDING_LENGTH_FIELD_SIZE [2/3]

#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   2

Definition at line 90 of file asfenc.c.

◆ ASF_PPI_PADDING_LENGTH_FIELD_SIZE [3/3]

#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE   4

Definition at line 90 of file asfenc.c.

◆ ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE [1/3]

#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   1

Definition at line 103 of file asfenc.c.

◆ ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE [2/3]

#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   2

Definition at line 103 of file asfenc.c.

◆ ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE [3/3]

#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE   4

Definition at line 103 of file asfenc.c.

◆ ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE [1/3]

#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   1

Definition at line 116 of file asfenc.c.

◆ ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE [2/3]

#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   2

Definition at line 116 of file asfenc.c.

◆ ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE [3/3]

#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE   4

Definition at line 116 of file asfenc.c.

◆ ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE [1/3]

#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   1

Definition at line 129 of file asfenc.c.

◆ ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE [2/3]

#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   2

Definition at line 129 of file asfenc.c.

◆ ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE [3/3]

#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE   4

Definition at line 129 of file asfenc.c.

◆ ASF_PAYLOAD_LENGTH_FIELD_SIZE [1/2]

#define ASF_PAYLOAD_LENGTH_FIELD_SIZE   1

Definition at line 142 of file asfenc.c.

◆ ASF_PAYLOAD_LENGTH_FIELD_SIZE [2/2]

#define ASF_PAYLOAD_LENGTH_FIELD_SIZE   2

Definition at line 142 of file asfenc.c.

◆ PACKET_HEADER_MIN_SIZE

#define PACKET_HEADER_MIN_SIZE
Value:
1 + /* Length Type Flags */ \
1 + /* Property Flags */ \
4 + /* Send Time Field */ \
2) /* Duration Field */
#define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE
Definition asfenc.c:50
#define ASF_PPI_PADDING_LENGTH_FIELD_SIZE
Definition asfenc.c:90
#define ASF_PPI_PACKET_LENGTH_FIELD_SIZE
Definition asfenc.c:77
#define ASF_PPI_SEQUENCE_FIELD_SIZE
Definition asfenc.c:64

Definition at line 151 of file asfenc.c.

Referenced by put_frame(), and put_payload_parsing_info().

◆ ASF_PAYLOAD_REPLICATED_DATA_LENGTH

#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH   0x08

Definition at line 163 of file asfenc.c.

Referenced by put_payload_header().

◆ PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD

#define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
Value:
(1 + /* Stream Number */ \
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH
Definition asfenc.c:163
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
Definition asfenc.c:103
#define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
Definition asfenc.c:116
#define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
Definition asfenc.c:129

Definition at line 165 of file asfenc.c.

Referenced by put_frame().

◆ PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS

#define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS

◆ SINGLE_PAYLOAD_HEADERS

#define SINGLE_PAYLOAD_HEADERS
Value:
#define PACKET_HEADER_MIN_SIZE
Definition asfenc.c:151
#define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
Definition asfenc.c:165

Definition at line 180 of file asfenc.c.

Referenced by put_frame().

◆ MULTI_PAYLOAD_HEADERS

#define MULTI_PAYLOAD_HEADERS
Value:
1 + /* Payload Flags */ \
#define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
Definition asfenc.c:172

Definition at line 184 of file asfenc.c.

Referenced by put_frame().

◆ DATA_HEADER_SIZE

#define DATA_HEADER_SIZE   50

Definition at line 189 of file asfenc.c.

Referenced by asf_write_header(), asf_write_header1(), and get_send_time().

◆ PACKET_SIZE_MAX

#define PACKET_SIZE_MAX   65536

Definition at line 191 of file asfenc.c.

◆ PACKET_SIZE_MIN

#define PACKET_SIZE_MIN   100

Definition at line 192 of file asfenc.c.

◆ PREROLL_TIME

#define PREROLL_TIME   3100

Definition at line 245 of file asfenc.c.

Referenced by asf_write_header1(), asf_write_markers(), asf_write_packet(), and put_frame().

Function Documentation

◆ put_str16()

static void put_str16 ( AVIOContext * s,
AVIOContext * dyn_buf,
const char * tag )
static

Definition at line 247 of file asfenc.c.

Referenced by asf_write_header1().

◆ put_header()

static int64_t put_header ( AVIOContext * pb,
const ff_asf_guid * g )
static

Definition at line 259 of file asfenc.c.

Referenced by asf_write_header1(), and asf_write_markers().

◆ end_header()

static void end_header ( AVIOContext * pb,
int64_t pos )
static

Definition at line 270 of file asfenc.c.

Referenced by asf_write_header1(), and asf_write_markers().

◆ put_chunk()

static void put_chunk ( AVFormatContext * s,
int type,
int payload_length,
int flags )
static

Definition at line 281 of file asfenc.c.

Referenced by asf_write_header1(), asf_write_trailer(), and flush_packet().

◆ get_send_time()

static int32_t get_send_time ( ASFContext * asf,
int64_t pres_time,
uint64_t * offset )
static

Definition at line 297 of file asfenc.c.

Referenced by asf_write_markers().

◆ asf_write_markers()

static void asf_write_markers ( AVFormatContext * s,
AVIOContext * dyn_buf )
static

Definition at line 311 of file asfenc.c.

Referenced by asf_write_header1().

◆ asf_write_header1()

static int asf_write_header1 ( AVFormatContext * s,
int64_t file_size,
int64_t data_chunk_size )
static

Definition at line 350 of file asfenc.c.

Referenced by asf_write_header(), and asf_write_trailer().

◆ asf_write_header()

static int asf_write_header ( AVFormatContext * s)
static

Definition at line 738 of file asfenc.c.

Referenced by asf_write_stream_header().

◆ asf_write_stream_header()

static int asf_write_stream_header ( AVFormatContext * s)
static

Definition at line 775 of file asfenc.c.

◆ put_payload_parsing_info()

static int put_payload_parsing_info ( AVFormatContext * s,
unsigned sendtime,
unsigned duration,
int nb_payloads,
int padsize )
static

Definition at line 784 of file asfenc.c.

Referenced by flush_packet().

◆ flush_packet()

static void flush_packet ( AVFormatContext * s)
static

Definition at line 831 of file asfenc.c.

Referenced by asf_write_trailer(), and put_frame().

◆ put_payload_header()

static void put_payload_header ( AVFormatContext * s,
ASFStream * stream,
int64_t presentation_time,
int m_obj_size,
int m_obj_offset,
int payload_len,
int flags )
static

Definition at line 862 of file asfenc.c.

Referenced by put_frame().

◆ put_frame()

static void put_frame ( AVFormatContext * s,
ASFStream * stream,
AVStream * avst,
int64_t timestamp,
const uint8_t * buf,
int m_obj_size,
int flags )
static

Definition at line 893 of file asfenc.c.

Referenced by asf_write_packet().

◆ update_index()

static int update_index ( AVFormatContext * s,
int start_sec,
uint32_t packet_number,
uint16_t packet_count,
uint64_t packet_offset )
static

Definition at line 964 of file asfenc.c.

Referenced by asf_write_packet(), and asf_write_trailer().

◆ asf_write_packet()

static int asf_write_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 1004 of file asfenc.c.

◆ asf_write_index()

static int asf_write_index ( AVFormatContext * s,
const ASFIndex * index,
uint16_t max,
uint32_t count )
static

Definition at line 1052 of file asfenc.c.

Referenced by asf_write_trailer().

◆ asf_write_trailer()

static int asf_write_trailer ( AVFormatContext * s)
static

Definition at line 1071 of file asfenc.c.

◆ asf_deinit()

static void asf_deinit ( AVFormatContext * s)
static

Definition at line 1101 of file asfenc.c.

Variable Documentation

◆ codec_asf_bmp_tags

const AVCodecTag codec_asf_bmp_tags[]
static
Initial value:
= {
{ AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
{ AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
{ AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
}
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_MPEG4
Definition codec_id.h:62
@ AV_CODEC_ID_MSMPEG4V3
Definition codec_id.h:66
#define MKTAG(a, b, c, d)
Definition macros.h:55

Definition at line 234 of file asfenc.c.

◆ asf_codec_tags

const AVCodecTag* const asf_codec_tags[]
static
Initial value:
= {
}
static const AVCodecTag codec_asf_bmp_tags[]
Definition asfenc.c:234
#define NULL
Definition coverity.c:32
const AVCodecTag ff_codec_bmp_tags[]
Definition riff.c:36
const AVCodecTag ff_codec_wav_tags[]
Definition riff.c:525

Definition at line 241 of file asfenc.c.

◆ asf_options

const AVOption asf_options[]
static
Initial value:
= {
{ "packet_size", "Packet size", 0x42 , AV_OPT_TYPE_INT, {.i64 = 3200}, PACKET_SIZE_MIN, PACKET_SIZE_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
}
#define PACKET_SIZE_MAX
Definition asfenc.c:191
#define PACKET_SIZE_MIN
Definition asfenc.c:192
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition opt.h:351
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 1108 of file asfenc.c.

◆ asf_muxer_class

const AVClass asf_muxer_class
static
Initial value:
= {
.class_name = "ASF (stream) muxer",
.item_name = av_default_item_name,
.option = asf_options,
}
static const AVOption asf_options[]
Definition asfenc.c:1108
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 1113 of file asfenc.c.