aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-01-13 14:40:24 +0200
committerMartin Storsjö <martin@martin.st>2012-01-25 12:15:41 +0200
commitbc7d05177fc93c62de4e03dddccba55c42124e5a (patch)
tree2daf5aeaaef3c14f33596718fb1e4bb1beddfd95
parent3b5d4428acf6eab60410358a5dbf931a17300ecf (diff)
downloadffmpeg-bc7d05177fc93c62de4e03dddccba55c42124e5a.tar.gz
movdec: Calculate an average bit rate for fragmented streams, too
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/isom.h1
-rw-r--r--libavformat/mov.c15
2 files changed, 15 insertions, 1 deletions
diff --git a/libavformat/isom.h b/libavformat/isom.h
index e6d04dc526..16d777651a 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -125,6 +125,7 @@ typedef struct MOVStreamContext {
int dts_shift; ///< dts shift when ctts is negative
uint32_t palette[256];
int has_palette;
+ int64_t data_size;
} MOVStreamContext;
typedef struct MOVContext {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index c6022d5d3a..9fb4a21c8c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1580,8 +1580,10 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
init_get_bits(&gb, buf, 8*num_bytes);
- for (i=0; i<entries; i++)
+ for (i = 0; i < entries; i++) {
sc->sample_sizes[i] = get_bits_long(&gb, field_size);
+ sc->data_size += sc->sample_sizes[i];
+ }
av_free(buf);
return 0;
@@ -2258,6 +2260,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
distance++;
dts += sample_duration;
offset += sample_size;
+ sc->data_size += sample_size;
}
frag->moof_offset = offset;
st->duration = dts + sc->time_offset;
@@ -2576,6 +2579,16 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (pb->seekable && mov->chapter_track > 0)
mov_read_chapters(s);
+ if (mov->trex_data) {
+ int i;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ MOVStreamContext *sc = st->priv_data;
+ if (st->duration)
+ st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
+ }
+ }
+
return 0;
}