Skip to content

Commit

Permalink
remove audio_convert
Browse files Browse the repository at this point in the history
Signed-off-by: Jack <[email protected]>
  • Loading branch information
Jackarain committed Nov 29, 2012
1 parent 20021d9 commit 0a99c81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
38 changes: 6 additions & 32 deletions libav/avplay.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

#define USE_SWR

#include <stdlib.h>
#include <math.h>
#include "avplay.h"
Expand All @@ -13,8 +10,9 @@ enum bool_type
};
#endif


/* 队列类型. */
#define QUEUE_PACKET 0
#define QUEUE_PACKET 0
#define QUEUE_AVFRAME 1

#define IO_BUFFER_SIZE 32768
Expand All @@ -23,10 +21,10 @@ enum bool_type
#define MIN_AV_FRAMES 5
#define AUDIO_BUFFER_MAX_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE * 2)
#define AVDECODE_BUFFER_SIZE 2
#define DEVIATION 6
#define DEVIATION 6

#define AV_SYNC_THRESHOLD 0.01f
#define AV_NOSYNC_THRESHOLD 10.0f
#define AV_NOSYNC_THRESHOLD 10.0f
#define AUDIO_DIFF_AVG_NB 20

#define SEEKING_FLAG -1
Expand Down Expand Up @@ -922,10 +920,8 @@ void av_stop(avplay *play)
avcodec_close(play->m_video_ctx);
if (play->m_format_ctx)
avformat_close_input(&play->m_format_ctx);
#ifndef USE_SWR
if (play->m_audio_convert_ctx)
av_audio_convert_free(play->m_audio_convert_ctx);
#endif
if (play->m_swr_ctx)
swr_free(play->m_swr_ctx);
if (play->m_resample_ctx)
audio_resample_close(play->m_resample_ctx);
pthread_mutex_destroy(&play->m_buf_size_mtx);
Expand Down Expand Up @@ -1057,7 +1053,6 @@ void audio_copy(avplay *play, AVFrame *dst, AVFrame* src)
/* 重采样到AV_SAMPLE_FMT_S16格式. */
if (play->m_audio_ctx->sample_fmt != AV_SAMPLE_FMT_S16)
{
#ifdef USE_SWR
if (!play->m_swr_ctx)
{
uint64_t in_channel_layout = av_get_default_channel_layout(play->m_audio_ctx->channels);
Expand All @@ -1078,27 +1073,6 @@ void audio_copy(avplay *play, AVFrame *dst, AVFrame* src)
src->linesize[0] = dst->linesize[0] = ret * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * out_channels;
memcpy(src->data[0], dst->data[0], src->linesize[0]);
}
#else
if (!play->m_audio_convert_ctx)
play->m_audio_convert_ctx = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, play->m_audio_ctx->sample_fmt, 1, NULL, 0);

if (play->m_audio_convert_ctx)
{
const void *ibuf[6] = { src->data[0] };
void *obuf[6] = { dst->data[0] };
int istride[6] = { av_get_bytes_per_sample(play->m_audio_ctx->sample_fmt) };
int ostride[6] = { 2 };
int len = src->linesize[0] / istride[0];
if (av_audio_convert(play->m_audio_convert_ctx, obuf, ostride, ibuf, istride, len) < 0)
{
assert(0);
}
dst->linesize[0] = src->linesize[0] = len * 2;
memcpy(src->data[0], dst->data[0], src->linesize[0]);
/* FIXME: existing code assume that data_size equals framesize*channels*2
remove this legacy cruft */
}
#endif
}

/* 重采样到双声道. */
Expand Down
6 changes: 0 additions & 6 deletions libav/avplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
#ifndef USE_SWR
#include <libavcodec/audioconvert.h>
#endif
#include <assert.h>
#include "defs.h"

Expand Down Expand Up @@ -115,9 +112,6 @@ typedef struct avplay

/* 重采样音频指针. */
struct SwsContext *m_swsctx;
#ifndef USE_SWR
AVAudioConvert *m_audio_convert_ctx;
#endif
struct SwrContext *m_swr_ctx;
ReSampleContext *m_resample_ctx;

Expand Down

0 comments on commit 0a99c81

Please sign in to comment.