libeplayer: simplify writer/pcm

This commit is contained in:
martii
2014-04-05 19:32:58 +02:00
parent aa98de5993
commit 27d4c15952
5 changed files with 15 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ CXXFLAGS = -Wall
AM_CPPFLAGS = -I$(srcdir)/include AM_CPPFLAGS = -I$(srcdir)/include
AM_CPPFLAGS += -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE AM_CPPFLAGS += -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
AM_CPPFLAGS += -ggdb
libeplayer3_la_SOURCES = \ libeplayer3_la_SOURCES = \
container/container.cpp container/container_ffmpeg.cpp \ container/container.cpp container/container_ffmpeg.cpp \

View File

@@ -340,7 +340,7 @@ static void *FFMPEGThread(void *arg)
ffmpeg_printf(200, "packet_size %d - index %d\n", packet.size, pid); ffmpeg_printf(200, "packet_size %d - index %d\n", packet.size, pid);
if (videoTrack && (videoTrack->Id == pid)) { if (videoTrack && (videoTrack->Id == pid)) {
currentVideoPts = /* CHECK videoTrack->pts = */pts = calcPts(avContext, videoTrack->stream, packet.pts); currentVideoPts = pts = calcPts(avContext, videoTrack->stream, packet.pts);
ffmpeg_printf(200, "VideoTrack index = %d %lld\n", pid, currentVideoPts); ffmpeg_printf(200, "VideoTrack index = %d %lld\n", pid, currentVideoPts);
@@ -356,7 +356,7 @@ static void *FFMPEGThread(void *arg)
} else if (audioTrack && (audioTrack->Id == pid)) { } else if (audioTrack && (audioTrack->Id == pid)) {
context->currentAudioPtsP = &currentAudioPts; //FIXME, temporary workaround only context->currentAudioPtsP = &currentAudioPts; //FIXME, temporary workaround only
if (!context->playback->BackWard) { if (!context->playback->BackWard) {
currentAudioPts = /* CHECK audioTrack->pts = */pts = calcPts(avContext, audioTrack->stream, packet.pts); currentAudioPts = pts = calcPts(avContext, audioTrack->stream, packet.pts);
ffmpeg_printf(200, "AudioTrack index = %d\n", pid); ffmpeg_printf(200, "AudioTrack index = %d\n", pid);
avOut.pts = pts; avOut.pts = pts;

Binary file not shown.

View File

@@ -42,7 +42,6 @@ typedef struct Track_s {
/* length of track */ /* length of track */
int64_t duration; int64_t duration;
//CHECK int64_t pts;
/* context from ffmpeg */ /* context from ffmpeg */
AVFormatContext *avfc; AVFormatContext *avfc;

View File

@@ -274,21 +274,12 @@ AVFrame *decoded_frame = NULL;
int out_sample_rate = 44100; int out_sample_rate = 44100;
int out_channels = 2; int out_channels = 2;
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO; uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
int restart_audio_resampling = 0; int restart_audio_resampling = 1;
static int reset() static int reset()
{ {
initialHeader = 1; initialHeader = 1;
restart_audio_resampling = 1;
if (swr) {
swr_free(&swr);
swr = NULL; //FIXME: Needed?
}
if (decoded_frame) {
av_frame_free(&decoded_frame);
decoded_frame = NULL; //FIXME: Needed?
}
return 0; return 0;
} }
@@ -306,10 +297,16 @@ static int writeData(WriterAVCallData_t *call)
if (restart_audio_resampling) { if (restart_audio_resampling) {
restart_audio_resampling = 0; restart_audio_resampling = 0;
reset(); initialHeader = 1;
call->context->output->Command(call->context, OUTPUT_CLEAR, NULL); if (swr) {
call->context->output->Command(call->context, OUTPUT_PLAY, NULL); swr_free(&swr);
swr = NULL; //FIXME: Needed?
}
if (decoded_frame) {
av_frame_free(&decoded_frame);
decoded_frame = NULL; //FIXME: Needed?
}
AVCodec *codec = avcodec_find_decoder(c->codec_id); AVCodec *codec = avcodec_find_decoder(c->codec_id);
@@ -395,7 +392,7 @@ static int writeData(WriterAVCallData_t *call)
int64_t next_out_pts = av_rescale(swr_next_pts(swr, next_in_pts), int64_t next_out_pts = av_rescale(swr_next_pts(swr, next_in_pts),
call->stream->time_base.den, call->stream->time_base.den,
call->stream->time_base.num * (int64_t) out_sample_rate * c->sample_rate); call->stream->time_base.num * (int64_t) out_sample_rate * c->sample_rate);
*(call->context->currentAudioPtsP) = /* audioTrack->pts = */ pts = calcPts(call->avfc, call->stream, next_out_pts); *(call->context->currentAudioPtsP) = pts = calcPts(call->avfc, call->stream, next_out_pts);
out_samples = swr_convert(swr, &output, out_samples, (const uint8_t **) &decoded_frame->data[0], in_samples); out_samples = swr_convert(swr, &output, out_samples, (const uint8_t **) &decoded_frame->data[0], in_samples);
uSampleRate = out_sample_rate; uSampleRate = out_sample_rate;