aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-04-02 01:51:44 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-02 01:54:27 +0200
commit4defa68fe25eae4d7c27341e3b35811c047dcd3f (patch)
tree9d4d37343ec4c99801c1b76b813b0a5b2b04576b /libavformat
parenta2f5e14a867768019b49b830e29801f1bfb2abb7 (diff)
parentaa05f2126e18d23432bde77e6f44e41691472fef (diff)
downloadffmpeg-4defa68fe25eae4d7c27341e3b35811c047dcd3f.tar.gz
Merge remote branch 'qatar/master'
* qatar/master: ac3enc: ARM optimised ac3_compute_matissa_size ac3: armv6 optimised bit_alloc_calc_bap fate: simplify fft test rules avio: document avio_alloc_context. lavf: make compute_chapters_end less picky. sierravmd: fix Indeo3 videos FFT: simplify fft8() fate: add fixed-point fft/mdct tests Fixed-point support in fft-test ape: check that number of seektable entries is equal to number of frames Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/ape.c5
-rw-r--r--libavformat/avio.h16
-rw-r--r--libavformat/sierravmd.c4
-rw-r--r--libavformat/utils.c27
4 files changed, 37 insertions, 15 deletions
diff --git a/libavformat/ape.c b/libavformat/ape.c
index eb10f4538c..28b80b25aa 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -250,6 +250,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
av_log(s, AV_LOG_ERROR, "Too many frames: %d\n", ape->totalframes);
return -1;
}
+ if (ape->seektablelength && (ape->seektablelength / sizeof(*ape->seektable)) < ape->totalframes) {
+ av_log(s, AV_LOG_ERROR, "Number of seek entries is less than number of frames: %d vs. %d\n",
+ ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
+ return AVERROR_INVALIDDATA;
+ }
ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
if(!ape->frames)
return AVERROR(ENOMEM);
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 8cbd7aafec..710246854b 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -454,6 +454,22 @@ attribute_deprecated void init_checksum(AVIOContext *s,
attribute_deprecated unsigned long get_checksum(AVIOContext *s);
#endif
+/**
+ * Allocate and initialize an AVIOContext for buffered I/O. It must be later
+ * freed with av_free().
+ *
+ * @param buffer Memory block for input/output operations via AVIOContext.
+ * @param buffer_size The buffer size is very important for performance.
+ * For protocols with fixed blocksize it should be set to this blocksize.
+ * For others a typical size is a cache page, e.g. 4kb.
+ * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
+ * @param opaque An opaque pointer to user-specific data.
+ * @param read_packet A function for refilling the buffer, may be NULL.
+ * @param write_packet A function for writing the buffer contents, may be NULL.
+ * @param seek A function for seeking to specified byte position, may be NULL.
+ *
+ * @return Allocated AVIOContext or NULL on failure.
+ */
AVIOContext *avio_alloc_context(
unsigned char *buffer,
int buffer_size,
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index 0fa1142c0b..64836e214b 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -99,7 +99,7 @@ static int vmd_read_header(AVFormatContext *s,
if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
return AVERROR(EIO);
- if(vmd->vmd_header[16] == 'i' && vmd->vmd_header[17] == 'v' && vmd->vmd_header[18] == '3')
+ if(vmd->vmd_header[24] == 'i' && vmd->vmd_header[25] == 'v' && vmd->vmd_header[26] == '3')
vmd->is_indeo3 = 1;
else
vmd->is_indeo3 = 0;
@@ -249,7 +249,7 @@ static int vmd_read_packet(AVFormatContext *s,
return AVERROR(ENOMEM);
pkt->pos= avio_tell(pb);
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
- if(vmd->is_indeo3)
+ if(vmd->is_indeo3 && frame->frame_record[0] == 0x02)
ret = avio_read(pb, pkt->data, frame->frame_size);
else
ret = avio_read(pb, pkt->data + BYTES_PER_FRAME_RECORD,
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9399bcbce5..61226f73da 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2168,22 +2168,23 @@ enum CodecID av_codec_get_id(const AVCodecTag * const *tags, unsigned int tag)
static void compute_chapters_end(AVFormatContext *s)
{
- unsigned int i;
+ unsigned int i, j;
+ int64_t max_time = s->duration + (s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time;
- for (i=0; i+1<s->nb_chapters; i++)
+ for (i = 0; i < s->nb_chapters; i++)
if (s->chapters[i]->end == AV_NOPTS_VALUE) {
- assert(s->chapters[i]->start <= s->chapters[i+1]->start);
- assert(!av_cmp_q(s->chapters[i]->time_base, s->chapters[i+1]->time_base));
- s->chapters[i]->end = s->chapters[i+1]->start;
+ AVChapter *ch = s->chapters[i];
+ int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q, ch->time_base)
+ : INT64_MAX;
+
+ for (j = 0; j < s->nb_chapters; j++) {
+ AVChapter *ch1 = s->chapters[j];
+ int64_t next_start = av_rescale_q(ch1->start, ch1->time_base, ch->time_base);
+ if (j != i && next_start > ch->start && next_start < end)
+ end = next_start;
+ }
+ ch->end = (end == INT64_MAX) ? ch->start : end;
}
-
- if (s->nb_chapters && s->chapters[i]->end == AV_NOPTS_VALUE) {
- assert(s->start_time != AV_NOPTS_VALUE);
- assert(s->duration > 0);
- s->chapters[i]->end = av_rescale_q(s->start_time + s->duration,
- AV_TIME_BASE_Q,
- s->chapters[i]->time_base);
- }
}
static int get_std_framerate(int i){