Skip to content

Commit

Permalink
merge from microcai pull request
Browse files Browse the repository at this point in the history
Signed-off-by: Jack <[email protected]>
  • Loading branch information
Jackarain committed Nov 28, 2012
1 parent 24abc4f commit 18351d4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
52 changes: 23 additions & 29 deletions libav/avplay.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
//#include <libavcodec/audioconvert.h>

#include "avplay.h"
#include <stdlib.h>
#include <math.h>
Expand Down Expand Up @@ -908,8 +902,8 @@ void av_stop(avplay *play)
avcodec_close(play->m_video_ctx);
if (play->m_format_ctx)
avformat_close_input(&play->m_format_ctx);
// if (play->m_audio_convert_ctx)
// av_audio_convert_free(play->m_audio_convert_ctx);
if (play->m_audio_convert_ctx)
av_audio_convert_free(play->m_audio_convert_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 @@ -1032,27 +1026,27 @@ void audio_copy(avplay *play, AVFrame *dst, AVFrame* src)
/* 重采样到AV_SAMPLE_FMT_S16格式. */
if (play->m_audio_ctx->sample_fmt != AV_SAMPLE_FMT_S16)
{
// 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 */
// }
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 */
}
}

/* 重采样到双声道. */
Expand Down
9 changes: 7 additions & 2 deletions libav/avplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
# define EXPORT_API
#endif

#include <libavformat/avio.h>
#include <pthread.h>
#include <libavformat/avio.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libavcodec/audioconvert.h>
#include <assert.h>
#include "defs.h"

Expand Down Expand Up @@ -100,7 +105,7 @@ typedef struct avplay

/* 重采样音频指针. */
struct SwsContext *m_swsctx;
// AVAudioConvert *m_audio_convert_ctx;
AVAudioConvert *m_audio_convert_ctx;
ReSampleContext *m_resample_ctx;

/* 音频和视频的AVStream、AVCodecContext指针和index. */
Expand Down
4 changes: 2 additions & 2 deletions source/torrent_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "libtorrent/fingerprint.hpp"

#ifdef WIN32
#pragma comment(lib, "../openssl/libs/libeay32.lib");
#pragma comment(lib, "../openssl/libs/ssleay32.lib");
// #pragma comment(lib, "../openssl/libs/libeay32.lib");
// #pragma comment(lib, "../openssl/libs/ssleay32.lib");
#endif // WIN32


Expand Down
8 changes: 4 additions & 4 deletions win32/avcore/player_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ LRESULT player_impl::win_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
if (m_avplay && (m_avplay->m_play_status == playing
|| m_avplay->m_play_status == completed)
&& (fact >= 0.0f && fact <= 1.0f))
::seek(m_avplay, fact);
::av_seek(m_avplay, fact);
}
break;
// case WM_PAINT:
Expand Down Expand Up @@ -975,7 +975,7 @@ BOOL player_impl::stop()
{
if (m_avplay)
{
::stop(m_avplay);
::av_stop(m_avplay);
m_cur_index = -1;
::logger("stop play.\n");
return TRUE;
Expand Down Expand Up @@ -1023,7 +1023,7 @@ void player_impl::seek_to(double fact)
{
if (m_avplay)
{
::seek(m_avplay, fact);
::av_seek(m_avplay, fact);
::logger("seek to %.2f.\n", fact);
}
}
Expand All @@ -1032,7 +1032,7 @@ void player_impl::volume(double l, double r)
{
if (m_avplay)
{
::volume(m_avplay, l, r);
::av_volume(m_avplay, l, r);
::logger("set volume to left: %.2f, right: %.2f.\n", l, r);
}
}
Expand Down

0 comments on commit 18351d4

Please sign in to comment.