libeplayer3/container_ffmpeg: don't set pts if audio-only

This commit is contained in:
martii
2014-03-22 14:18:37 +01:00
parent 243bbc3f5b
commit 7767f23a0f

View File

@@ -485,12 +485,9 @@ static void FFMPEGThread(Context_t * context)
} else } else
avcodec_get_frame_defaults(decoded_frame); avcodec_get_frame_defaults(decoded_frame);
int len = avcodec_decode_audio4(c, decoded_frame, int len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &packet);
&got_frame,
&packet);
if (len < 0) { if (len < 0) {
restart_audio_resampling = 1; restart_audio_resampling = 1;
// fprintf(stderr, "avcodec_decode_audio4: %d\n", len);
break; break;
} }
@@ -502,10 +499,7 @@ static void FFMPEGThread(Context_t * context)
int e; int e;
if (!swr) { if (!swr) {
int rates[] = { 48000, 96000, 192000, 44100, 88200, int rates[] = { 48000, 96000, 192000, 44100, 88200, 176400, 0 };
176400,
0
};
int *rate = rates; int *rate = rates;
int in_rate = c->sample_rate; int in_rate = c->sample_rate;
while (*rate && ((*rate / in_rate) * in_rate != *rate) while (*rate && ((*rate / in_rate) * in_rate != *rate)
@@ -546,15 +540,13 @@ static void FFMPEGThread(Context_t * context)
uint8_t *output = NULL; uint8_t *output = NULL;
int in_samples = decoded_frame->nb_samples; int in_samples = decoded_frame->nb_samples;
int out_samples = av_rescale_rnd(swr_get_delay(swr, int out_samples = av_rescale_rnd(swr_get_delay(swr, c->sample_rate) + in_samples, out_sample_rate, c->sample_rate, AV_ROUND_UP);
c->sample_rate) + in_samples,
out_sample_rate,
c->sample_rate, AV_ROUND_UP);
e = av_samples_alloc(&output, NULL, out_channels, out_samples, AV_SAMPLE_FMT_S16, 1); e = av_samples_alloc(&output, NULL, out_channels, out_samples, AV_SAMPLE_FMT_S16, 1);
if (e < 0) { if (e < 0) {
fprintf(stderr, "av_samples_alloc: %d\n", -e); fprintf(stderr, "av_samples_alloc: %d\n", -e);
continue; continue;
} }
// FIXME. PTS calculation is probably broken.
int64_t next_in_pts = av_rescale(av_frame_get_best_effort_timestamp(decoded_frame), int64_t next_in_pts = av_rescale(av_frame_get_best_effort_timestamp(decoded_frame),
((AVStream *) audioTrack->stream)->time_base.num * (int64_t) out_sample_rate * c->sample_rate, ((AVStream *) audioTrack->stream)->time_base.num * (int64_t) out_sample_rate * c->sample_rate,
((AVStream *) audioTrack->stream)->time_base.den); ((AVStream *) audioTrack->stream)->time_base.den);
@@ -575,7 +567,7 @@ static void FFMPEGThread(Context_t * context)
avOut.data = output; avOut.data = output;
avOut.len = out_samples * sizeof(short) * out_channels; avOut.len = out_samples * sizeof(short) * out_channels;
avOut.pts = pts; avOut.pts = videoTrack ? pts : 0;
avOut.extradata = (unsigned char *) &extradata; avOut.extradata = (unsigned char *) &extradata;
avOut.extralen = sizeof(extradata); avOut.extralen = sizeof(extradata);
avOut.frameRate = 0; avOut.frameRate = 0;