Mercurial > libavformat.hg
comparison mov.c @ 5332:ff45ef768724 libavformat
compute codec bitrate in mov demuxer, patch by haim alon, haim dot alter at gmail dot com
author | bcoudurier |
---|---|
date | Sat, 24 Oct 2009 20:40:00 +0000 |
parents | c6eeec0f9b40 |
children | d2db7a53bc0d |
comparison
equal
deleted
inserted
replaced
5331:4449e753bc78 | 5332:ff45ef768724 |
---|---|
1427 unsigned int stts_index = 0; | 1427 unsigned int stts_index = 0; |
1428 unsigned int stsc_index = 0; | 1428 unsigned int stsc_index = 0; |
1429 unsigned int stss_index = 0; | 1429 unsigned int stss_index = 0; |
1430 unsigned int stps_index = 0; | 1430 unsigned int stps_index = 0; |
1431 unsigned int i, j; | 1431 unsigned int i, j; |
1432 uint64_t stream_size = 0; | |
1432 | 1433 |
1433 /* adjust first dts according to edit list */ | 1434 /* adjust first dts according to edit list */ |
1434 if (sc->time_offset) { | 1435 if (sc->time_offset) { |
1435 int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset; | 1436 int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset; |
1436 current_dts = -rescaled; | 1437 current_dts = -rescaled; |
1486 "size %d, distance %d, keyframe %d\n", st->index, current_sample, | 1487 "size %d, distance %d, keyframe %d\n", st->index, current_sample, |
1487 current_offset, current_dts, sample_size, distance, keyframe); | 1488 current_offset, current_dts, sample_size, distance, keyframe); |
1488 } | 1489 } |
1489 | 1490 |
1490 current_offset += sample_size; | 1491 current_offset += sample_size; |
1492 stream_size += sample_size; | |
1491 current_dts += sc->stts_data[stts_index].duration; | 1493 current_dts += sc->stts_data[stts_index].duration; |
1492 distance++; | 1494 distance++; |
1493 stts_sample++; | 1495 stts_sample++; |
1494 current_sample++; | 1496 current_sample++; |
1495 if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) { | 1497 if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) { |
1496 stts_sample = 0; | 1498 stts_sample = 0; |
1497 stts_index++; | 1499 stts_index++; |
1498 } | 1500 } |
1499 } | 1501 } |
1500 } | 1502 } |
1503 st->codec->bit_rate = stream_size*8*sc->time_scale/st->duration; | |
1501 } else { | 1504 } else { |
1502 for (i = 0; i < sc->chunk_count; i++) { | 1505 for (i = 0; i < sc->chunk_count; i++) { |
1503 unsigned chunk_samples; | 1506 unsigned chunk_samples; |
1504 | 1507 |
1505 current_offset = sc->chunk_offsets[i]; | 1508 current_offset = sc->chunk_offsets[i]; |