28 #include "libavutil/intreadwrite.h"
29 #include "libavutil/avassert.h"
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)
137 if (
id == av_guid[i].
id)
138 return &(av_guid[i].
guid);
185 avio_seek(pb, -(chunk_len - 16), SEEK_CUR);
187 avio_seek(pb, chunk_len - (16 + 4), SEEK_CUR);
203 for (i = 0; i < wctx->
nb_index; i++) {
231 int64_t hdr_pos_start;
270 hdr_size =
avio_tell(pb) - hdr_pos_start;
273 avio_seek(pb, -(hdr_size + 4), SEEK_CUR);
529 avio_wl64(pb, len |(1ULL<<62) | (1ULL<<60));
548 for (i = 0; i < nb_sectors; i++) {
549 avio_wl32(pb, start_sector + (i << shift));
609 return 16 + 4 + 4 + strlen(key)*2 + 2;
626 return strlen(
"image/jpeg")*2 + 2 + 1 + (e ? strlen(e->
value)*2 : 0) + 2 + 4 + pkt->
size;
690 int sector_bits, nb_sectors, pad;
694 w->
length = (end_pos - start_pos);
718 nb_sectors = (int)(w->
length >> sector_bits);
721 pad = (1 << sector_bits) - (w->
length % (1 << sector_bits));
747 int64_t start_pos, file_end_pos;
const uint8_t ff_table_0_entries_time_le16[40]
const ff_asf_guid ff_metadata_guid
static void write_table_entries_time(AVFormatContext *s)
const ff_asf_guid ff_SBE2_STREAM_DESC_EVENT
static int shift(int a, int b)
#define WTV_BIGSECTOR_BITS
void av_free_packet(AVPacket *pkt)
Free a packet.
static int attachment_value_size(const AVPacket *pkt, const AVDictionaryEntry *e)
static void write_fat(AVIOContext *pb, int start_sector, int nb_sectors, int shift)
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVCodecContext * codec
Codec context associated with this stream.
int index
stream index in AVFormatContext
int av_copy_packet(AVPacket *dst, AVPacket *src)
Copy packet, including contents.
static int64_t write_fat_sector(AVFormatContext *s, int64_t start_pos, int nb_sectors, int sector_bits, int depth)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
const ff_asf_guid ff_mediatype_video
static void write_chunk_header2(AVFormatContext *s, const ff_asf_guid *guid, int stream_id)
int64_t last_timestamp_pos
last timestamp chunk position
static int write_table0_header_time(AVIOContext *pb)
const ff_asf_guid ff_format_waveformatex
static int write_root_table(AVFormatContext *s, int64_t sector_pos)
static void write_table_redirector_legacy_attrib(AVFormatContext *s)
const ff_asf_guid ff_data_guid
static void add_serial_pair(WtvSyncEntry **list, int *count, int64_t serial, int64_t value)
static const uint8_t table_0_redirector_legacy_attrib[]
const ff_asf_guid ff_mediatype_audio
const ff_asf_guid ff_mediasubtype_cpfilters_processed
static const ff_asf_guid sub_wtv_guid
static int write_stream_codec(AVFormatContext *s, AVStream *st)
static void finish_chunk_noindex(AVFormatContext *s)
static int metadata_header_size(const char *key)
const ff_asf_guid ff_sync_guid
WTVHeaderWriteFunc * write_header
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
WtvChunkEntry index[MAX_NB_INDEX]
const uint8_t ff_table_0_entries_legacy_attrib_le16[58]
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static void write_sync(AVFormatContext *s)
static const uint8_t legacy_attrib[]
int WTVHeaderWriteFunc(AVIOContext *pb)
void * priv_data
Format private data.
static void write_chunk_header(AVFormatContext *s, const ff_asf_guid *guid, int length, int stream_id)
Write chunk header.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int64_t timeline_start_pos
static void write_index(AVFormatContext *s)
const AVCodecTag ff_codec_wav_tags[]
const uint8_t ff_timeline_table_0_entries_Events_le16[62]
int flags
A combination of AV_PKT_FLAG values.
#define write_pad(pb, size)
const ff_asf_guid ff_format_cpfilters_processed
static const uint8_t table_0_header_time[]
unsigned int nb_streams
A list of all streams in the file.
static const WTVRootEntryTable wtv_root_entry_table[]
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
const AVCodecTag ff_codec_bmp_tags[]
static int write_table0_header_legacy_attrib(AVIOContext *pb)
const uint8_t ff_timeline_le16[16]
const ff_asf_guid ff_timestamp_guid
static void write_table_entries_attrib(AVFormatContext *s)
const ff_asf_guid ff_format_mpeg2_video
static const uint8_t timeline_table_0_header_events[]
preferred ID for MPEG-1/2 video decoding
static int finish_file(AVFormatContext *s, enum WtvFileIndex index, int64_t start_pos)
Pad the remainder of a file Write out fat table.
const AVCodecGuid ff_codec_wav_guids[]
static void write_timestamp(AVFormatContext *s, AVPacket *pkt)
enum AVMediaType codec_type
static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
main external API structure.
static int write_trailer(AVFormatContext *s)
AVIOContext * pb
I/O context.
const ff_asf_guid ff_index_guid
static const ff_asf_guid * get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid)
static void finish_chunk(AVFormatContext *s)
const AVCodecGuid ff_video_guids[]
const AVMetadataConv ff_asf_metadata_conv[]
static int write_table0_header_events(AVIOContext *pb)
void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
AVOutputFormat ff_wtv_muxer
static int write_header(AVFormatContext *s)
static void write_tag(AVIOContext *pb, const char *key, const char *value)
const ff_asf_guid ff_dir_entry_guid
static int write_stream_data(AVFormatContext *s, AVStream *st)
#define WTV_BIGSECTOR_SIZE
int64_t serial
chunk serial number
int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
static const uint8_t table_0_header_legacy_attrib[]
static int write_packet(AVFormatContext *s, AVPacket *pkt)
const ff_asf_guid ff_wtv_guid
static void write_table_entries_events(AVFormatContext *s)
int64_t last_chunk_pos
last chunk position
int64_t first_index_pos
first index_chunk position
#define AV_DICT_IGNORE_SUFFIX
static void write_tag_int32(AVIOContext *pb, const char *key, int value)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const ff_asf_guid ff_stream1_guid
void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
static void write_metadata_header(AVIOContext *pb, int type, const char *key, int value_size)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.