Browse Source

Fix frame PTS when decoder returns multiple frames in a row

Fixes garbled audio for certain codes (e.g. G.729)

Also adds some additional debug output

Fixes #410

Change-Id: I1dbae2638f1e55bf80bb96549a75b9c4b82d08bf
pull/412/head
Richard Fuchs 8 years ago
parent
commit
23eebfc4d7
2 changed files with 11 additions and 1 deletions
  1. +10
    -0
      recording-daemon/decoder.c
  2. +1
    -1
      recording-daemon/log.h

+ 10
- 0
recording-daemon/decoder.c View File

@ -174,6 +174,12 @@ err:
static int decoder_got_frame(decoder_t *dec, output_t *output, metafile_t *metafile, AVFrame *frame) { static int decoder_got_frame(decoder_t *dec, output_t *output, metafile_t *metafile, AVFrame *frame) {
dbg("got frame pts %llu samples %u contents %02x%02x%02x%02x...", (unsigned long long) frame->pts, frame->nb_samples,
(unsigned int) frame->extended_data[0][0],
(unsigned int) frame->extended_data[0][1],
(unsigned int) frame->extended_data[0][2],
(unsigned int) frame->extended_data[0][3]);
// determine and save sample type // determine and save sample type
if (G_UNLIKELY(dec->in_format.format == -1)) if (G_UNLIKELY(dec->in_format.format == -1))
dec->in_format.format = dec->out_format.format = frame->format; dec->in_format.format = dec->out_format.format = frame->format;
@ -312,11 +318,15 @@ int decoder_input(decoder_t *dec, const str *data, unsigned long ts, output_t *o
#endif #endif
if (got_frame) { if (got_frame) {
dbg("raw frame from decoder pts %llu samples %u", (unsigned long long) frame->pts, frame->nb_samples);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 36, 0) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 36, 0)
frame->pts = frame->pkt_pts; frame->pts = frame->pkt_pts;
#endif #endif
if (G_UNLIKELY(frame->pts == AV_NOPTS_VALUE)) if (G_UNLIKELY(frame->pts == AV_NOPTS_VALUE))
frame->pts = dec->avpkt.pts; frame->pts = dec->avpkt.pts;
dec->avpkt.pts += frame->nb_samples;
if (decoder_got_frame(dec, output, metafile, frame)) if (decoder_got_frame(dec, output, metafile, frame))
return -1; return -1;
frame = NULL; frame = NULL;


+ 1
- 1
recording-daemon/log.h View File

@ -8,7 +8,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#define dbg(fmt, ...) ilog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define dbg(fmt, ...) ilog(LOG_DEBUG, "[%s:%i] " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
void __ilog(int prio, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void __ilog(int prio, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));


Loading…
Cancel
Save