36 #define WTV_BIGSECTOR_SIZE (1 << WTV_BIGSECTOR_BITS)
37 #define INDEX_BASE 0x2
38 #define MAX_NB_INDEX 10
51 {
'l'_'e'_'g'_'a'_'c'_'y'_'_'_'a'_'t'_'t'_'r'_'i'_'b', 0};
55 {0x8C,0xC3,0xD2,0xC2,0x7E,0x9A,0xDA,0x11,0x8B,0xF7,0x00,0x07,0xE9,0x5E,0xAD,0x8D};
114 int new_count = *count + 1;
131 #define write_pad(pb, size) ffio_fill(pb, 0, size)
175 avio_seek(pb, -(chunk_len - 16), SEEK_CUR);
177 avio_seek(pb, chunk_len - (16 + 4), SEEK_CUR);
219 unsigned int num, den;
295 hdr_size =
avio_tell(pb) - hdr_pos_start;
298 avio_seek(pb, -(hdr_size + 4), SEEK_CUR);
412 for (
i = 0;
i <
s->nb_streams;
i++) {
425 for (
i = 0;
i <
s->nb_streams;
i++) {
548 int filename_padding =
WTV_PAD8(
h->header_size) -
h->header_size;
555 avio_wl16(pb, 40 +
h->header_size + filename_padding + 8);
558 avio_wl32(pb, (
h->header_size + filename_padding) >> 1);
570 avio_seek(pb, 8 +
h->header_size + filename_padding +
len, SEEK_CUR);
588 for (
i = 0;
i < nb_sectors;
i++) {
608 write_fat(
s->pb, start_sector1, nb_sectors1, 0);
649 return 16 + 4 + 4 + strlen(
key)*2 + 2;
666 return strlen(
"image/jpeg")*2 + 2 + 1 + (e ? strlen(e->
value)*2 : 0) + 2 + 4 +
pkt->
size;
731 int sector_bits, nb_sectors, pad;
735 w->length = (end_pos - start_pos);
754 av_log(
s,
AV_LOG_ERROR,
"unsupported file allocation table depth (%"PRIi64
" bytes)\n",
w->length);
759 nb_sectors = (
int)(
w->length >> sector_bits);
762 pad = (1 << sector_bits) - (
w->length % (1 << sector_bits));
775 w->length |= 1ULL<<60;
777 w->length |= 1ULL<<63;
788 int64_t start_pos, file_end_pos;
const AVMetadataConv ff_asf_metadata_conv[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_wl64(AVIOContext *s, uint64_t val)
void avio_wl32(AVIOContext *s, unsigned int val)
void avio_wl16(AVIOContext *s, unsigned int val)
void avio_w8(AVIOContext *s, int b)
int avio_put_str16le(AVIOContext *s, const char *str)
Convert an UTF-8 string to UTF-16LE and write it.
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)
void ffio_fill(AVIOContext *s, int b, int count)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
#define AV_NOPTS_VALUE
Undefined timestamp value.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
Check presence of H264 startcode.
const AVCodecGuid ff_codec_wav_guids[]
const AVCodecTag ff_codec_bmp_tags[]
const AVCodecTag ff_codec_wav_tags[]
const ff_asf_guid * ff_get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid)
void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int ignore_extradata, int rgb_frame_is_flipped)
#define FF_MEDIASUBTYPE_BASE_GUID
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
const AVCodecTag *const ff_riff_codec_tags_list[]
static int shift(int a, int b)
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
AVRational avg_frame_rate
Average framerate.
WTVHeaderWriteFunc * write_header
int64_t first_index_pos
first index_chunk position
int64_t last_chunk_pos
last chunk position
int64_t last_timestamp_pos
last timestamp chunk position
int64_t timeline_start_pos
WtvChunkEntry index[MAX_NB_INDEX]
int64_t serial
chunk serial number
const ff_asf_guid ff_mediatype_audio
const uint8_t ff_timeline_table_0_entries_Events_le16[62]
const ff_asf_guid ff_format_mpeg2_video
const ff_asf_guid ff_metadata_guid
const ff_asf_guid ff_format_none
const ff_asf_guid ff_mediasubtype_cpfilters_processed
const uint8_t ff_table_0_entries_time_le16[40]
const ff_asf_guid ff_SBE2_STREAM_DESC_EVENT
const ff_asf_guid ff_mediatype_video
const AVCodecGuid ff_video_guids[]
const ff_asf_guid ff_data_guid
const ff_asf_guid ff_format_waveformatex
const uint8_t ff_timeline_le16[16]
const ff_asf_guid ff_format_videoinfo2
const ff_asf_guid ff_timestamp_guid
const ff_asf_guid ff_index_guid
#define WTV_BIGSECTOR_BITS
const uint8_t ff_table_0_entries_legacy_attrib_le16[58]
const ff_asf_guid ff_dir_entry_guid
const ff_asf_guid ff_sync_guid
const ff_asf_guid ff_wtv_guid
const ff_asf_guid ff_format_cpfilters_processed
const ff_asf_guid ff_stream1_guid
int WTVHeaderWriteFunc(AVIOContext *pb)
static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
static void write_chunk_header(AVFormatContext *s, const ff_asf_guid *guid, int length, int stream_id)
Write chunk header.
static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
static int metadata_header_size(const char *key)
static void write_table_entries_events(AVFormatContext *s)
static const uint8_t timeline_table_0_header_events[]
static void write_table_entries_attrib(AVFormatContext *s)
static const ff_asf_guid sub_wtv_guid
static const uint8_t table_0_header_time[]
static int write_stream_data(AVFormatContext *s, AVStream *st)
static void write_table_redirector_legacy_attrib(AVFormatContext *s)
static void write_metadata_header(AVIOContext *pb, int type, const char *key, int value_size)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
static int write_table0_header_legacy_attrib(AVIOContext *pb)
static int finish_file(AVFormatContext *s, enum WtvFileIndex index, int64_t start_pos)
Pad the remainder of a file Write out fat table.
static void write_table_entries_time(AVFormatContext *s)
static void write_tag_int32(AVIOContext *pb, const char *key, int value)
static void write_timestamp(AVFormatContext *s, AVPacket *pkt)
static int64_t write_fat_sector(AVFormatContext *s, int64_t start_pos, int nb_sectors, int sector_bits, int depth)
static void finish_chunk_noindex(AVFormatContext *s)
static int attachment_value_size(const AVPacket *pkt, const AVDictionaryEntry *e)
#define write_pad(pb, size)
static const uint8_t table_0_redirector_legacy_attrib[]
@ WTV_TABLE_0_ENTRIES_LEGACY_ATTRIB
@ WTV_TABLE_0_REDIRECTOR_LEGACY_ATTRIB
@ WTV_TIMELINE_TABLE_0_ENTRIES_EVENTS
@ WTV_TABLE_0_HEADER_LEGACY_ATTRIB
@ WTV_TABLE_0_ENTRIES_TIME
@ WTV_TABLE_0_HEADER_TIME
@ WTV_TIMELINE_TABLE_0_HEADER_EVENTS
static int write_table0_header_time(AVIOContext *pb)
static int write_root_table(AVFormatContext *s, int64_t sector_pos)
static void add_serial_pair(WtvSyncEntry **list, int *count, int64_t serial, int64_t value)
static void write_index(AVFormatContext *s)
static void write_chunk_header2(AVFormatContext *s, const ff_asf_guid *guid, int stream_id)
static int write_header(AVFormatContext *s)
static const uint8_t table_0_header_legacy_attrib[]
static const WTVRootEntryTable wtv_root_entry_table[]
#define WTV_BIGSECTOR_SIZE
static int write_stream_codec(AVFormatContext *s, AVStream *st)
static void write_sync(AVFormatContext *s)
static int write_trailer(AVFormatContext *s)
static int write_table0_header_events(AVIOContext *pb)
static const uint8_t legacy_attrib[]
static void finish_chunk(AVFormatContext *s)
static void write_tag(AVIOContext *pb, const char *key, const char *value)
static void write_fat(AVIOContext *pb, int start_sector, int nb_sectors, int shift)
AVOutputFormat ff_wtv_muxer