Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-06 15:44:15 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-10 08:27:09 +0300
commit107bdd97a9f0acec2e5ea9c63af6ea999444a78a (patch)
treec14682cf0e7ce8e56e9698021066a077bae5a276 /libavformat/nutenc.c
parentf4a2d722aa8f666e863476b95e1e2cbe92d8146b (diff)
avformat/mux: Move ff_choose_timebase to nutenc, its only user
(This function does not seem to abide by its documentation.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/nutenc.c')
-rw-r--r--libavformat/nutenc.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index d8c35783ae..0cea1fabb3 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -36,6 +36,26 @@
#include "riff.h"
#include "version.h"
+/**
+ * Chooses a timebase for muxing the specified stream.
+ *
+ * The chosen timebase allows sample accurate timestamps based
+ * on the framerate or sample rate for audio streams. It also is
+ * at least as precise as 1/min_precision would be.
+ */
+static AVRational choose_timebase(AVFormatContext *s, AVStream *st, int min_precision)
+{
+ AVRational q = st->time_base;
+
+ for (int j = 2; j < 14; j += 1 + (j > 2))
+ while (q.den / q.num < min_precision && q.num % j == 0)
+ q.num /= j;
+ while (q.den / q.num < min_precision && q.den < (1<<24))
+ q.den <<= 1;
+
+ return q;
+}
+
static int find_expected_header(AVCodecParameters *p, int size, int key_frame,
uint8_t out[64])
{
@@ -728,7 +748,7 @@ static int nut_write_header(AVFormatContext *s)
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) {
time_base = (AVRational) {1, st->codecpar->sample_rate};
} else {
- time_base = ff_choose_timebase(s, st, 48000);
+ time_base = choose_timebase(s, st, 48000);
}
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);