]> git.sesse.net Git - nageru/commitdiff
Correct audio pts for framing. Still something fishy around, though.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Apr 2016 22:56:54 +0000 (00:56 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Apr 2016 22:56:57 +0000 (00:56 +0200)
h264encode.cpp

index c1649e177e3c804a9e1c4883804c1d85c1c43270..8c615b4b918ca71b1b020ead900f7a479c8ccd95 100644 (file)
@@ -1698,14 +1698,17 @@ void H264EncoderImpl::encode_audio(
                return;
        }
 
+       int64_t sample_offset = audio_queue->size();
+
        audio_queue->insert(audio_queue->end(), audio.begin(), audio.end());
        size_t sample_num;
        for (sample_num = 0;
             sample_num + ctx->frame_size * 2 <= audio_queue->size();
             sample_num += ctx->frame_size * 2) {
+               int64_t adjusted_audio_pts = audio_pts + (int64_t(sample_num) - sample_offset) * TIMEBASE / (OUTPUT_FREQUENCY * 2);
                encode_audio_one_frame(&(*audio_queue)[sample_num],
                                       ctx->frame_size,
-                                      audio_pts,  // FIXME: Must be increased or decreased as needed.
+                                      adjusted_audio_pts,
                                       ctx,
                                       resampler,
                                       destinations);