diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-09-20 11:43:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-20 11:43:32 +0200 |
commit | 018e0db5eff21d2b7e546bc63f4807dea782d00d (patch) | |
tree | e31a5976d3ff3f89d8403e6b8c475f97bcebd702 /libavformat | |
parent | c6b425896541c6cc0b58c1aceb8821333f4049bc (diff) | |
parent | 09f3c937ed6fd7c5bd64450d45f73b0f4975f4c9 (diff) | |
download | ffmpeg-018e0db5eff21d2b7e546bc63f4807dea782d00d.tar.gz |
Merge commit '09f3c937ed6fd7c5bd64450d45f73b0f4975f4c9'
* commit '09f3c937ed6fd7c5bd64450d45f73b0f4975f4c9':
asfenc: remember send time and offset of the index entries
Conflicts:
libavformat/asfenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/asf.h | 2 | ||||
-rw-r--r-- | libavformat/asfenc.c | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/libavformat/asf.h b/libavformat/asf.h index 414baef11e..904d3486e8 100644 --- a/libavformat/asf.h +++ b/libavformat/asf.h @@ -88,6 +88,8 @@ typedef struct ASFMainHeader { typedef struct ASFIndex { uint32_t packet_number; uint16_t packet_count; + uint64_t send_time; + uint64_t offset; } ASFIndex; extern const ff_asf_guid ff_asf_header; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 2727230453..6653808b97 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -208,6 +208,7 @@ typedef struct { uint16_t maximum_packet; uint32_t next_packet_number; uint16_t next_packet_count; + uint64_t next_packet_offset; int next_start_sec; int end_sec; } ASFContext; @@ -763,7 +764,8 @@ static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst, } static int update_index(AVFormatContext *s, int start_sec, - uint32_t packet_number, uint16_t packet_count) + uint32_t packet_number, uint16_t packet_count, + uint64_t packet_offset) { ASFContext *asf = s->priv_data; @@ -773,6 +775,7 @@ static int update_index(AVFormatContext *s, int start_sec, if (!asf->next_start_sec) { asf->next_packet_number = packet_number; asf->next_packet_count = packet_count; + asf->next_packet_offset = packet_offset; } if (start_sec > asf->nb_index_memory_alloc) { @@ -788,11 +791,15 @@ static int update_index(AVFormatContext *s, int start_sec, for (i = asf->next_start_sec; i < start_sec; i++) { asf->index_ptr[i].packet_number = asf->next_packet_number; asf->index_ptr[i].packet_count = asf->next_packet_count; + asf->index_ptr[i].send_time = asf->next_start_sec * INT64_C(10000000); + asf->index_ptr[i].offset = asf->next_packet_offset; + } } asf->maximum_packet = FFMAX(asf->maximum_packet, packet_count); asf->next_packet_number = packet_number; asf->next_packet_count = packet_count; + asf->next_packet_offset = packet_offset; asf->next_start_sec = start_sec; return 0; @@ -801,6 +808,7 @@ static int update_index(AVFormatContext *s, int start_sec, static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) { ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; ASFStream *stream; AVCodecContext *codec; uint32_t packet_number; @@ -808,6 +816,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) int start_sec; int flags = pkt->flags; int ret; + uint64_t offset = avio_tell(pb); codec = s->streams[pkt->stream_index]->codec; stream = &asf->streams[pkt->stream_index]; @@ -830,7 +839,8 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) /* check index */ if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) { uint16_t packet_count = asf->nb_packets - packet_number; - if ((ret = update_index(s, start_sec, packet_number, packet_count)) < 0) + ret = update_index(s, start_sec, packet_number, packet_count, offset); + if (ret < 0) return ret; } asf->end_sec = start_sec; @@ -871,7 +881,7 @@ static int asf_write_trailer(AVFormatContext *s) /* write index */ data_size = avio_tell(s->pb); if (!asf->is_streamed && asf->next_start_sec) { - if ((ret = update_index(s, asf->end_sec + 1, 0, 0)) < 0) + if ((ret = update_index(s, asf->end_sec + 1, 0, 0, 0)) < 0) return ret; asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->next_start_sec); } |