Fplay: update

git-svn-id: svn://kolibrios.org@6106 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-01-27 14:43:42 +00:00
parent 19354e2950
commit f9f301e7a1
6 changed files with 11 additions and 145 deletions

View File

@ -14,7 +14,7 @@ ARFLAG = crs
SDK_DIR:= $(abspath ../../sdk)
LIB_DIR:= $(SDK_DIR)/lib
INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/ffmpeg
INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/ffmpeg-2.5
INCLUDES+=-I$(SDK_DIR)/sources/freetype/include
#-I$(SDK_DIR)/sources/vaapi/libva-1.4.1

View File

@ -1,11 +1,12 @@
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include "libswresample/swresample.h"
#include <stdio.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <kos32sys.h>
#include "winlib/winlib.h"
#include "sound.h"
#include "fplay.h"
@ -40,19 +41,12 @@ int init_audio(int format)
int version =-1;
char *errstr;
mutex_lock(&driver_lock);
if((err = InitSound(&version)) !=0 )
{
mutex_unlock(&driver_lock);
errstr = "Sound service not installed\n\r";
goto exit_whith_error;
};
mutex_unlock(&driver_lock);
// printf("sound version 0x%x\n", version);
if( (SOUND_VERSION>(version&0xFFFF)) ||
(SOUND_VERSION<(version >> 16)))
{
@ -106,15 +100,12 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa)
int got_frame;
int data_size;
if( astream.count > 192000*2)
return -1;
if( get_packet(qa, &pkt) == 0 )
return 0;
// __asm__("int3");
if (!aFrame)
{
if (!(aFrame = avcodec_alloc_frame()))
@ -128,8 +119,6 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa)
{
data_size = 192000;
// len = avcodec_decode_audio3(ctx,(int16_t*)decoder_buffer,
// &data_size, &pkt_tmp);
got_frame = 0;
len = avcodec_decode_audio4(ctx, aFrame, &got_frame, &pkt_tmp);
@ -200,19 +189,7 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa)
samples = astream.buffer+astream.count;
memcpy(samples, decoder_buffer, data_size);
/*
memcpy(samples, aFrame->extended_data[0], plane_size);
if (planar && ctx->channels > 1)
{
uint8_t *out = ((uint8_t *)samples) + plane_size;
for (ch = 1; ch < ctx->channels; ch++)
{
memcpy(out, aFrame->extended_data[ch], plane_size);
out += plane_size;
}
}
*/
astream.count += data_size;
mutex_unlock(&astream.lock);
};

View File

@ -51,7 +51,6 @@ int64_t rewind_pos;
int64_t stream_duration;
int threads_running = DECODER_THREAD;
mutex_t driver_lock;
extern double audio_base;
@ -110,11 +109,8 @@ int main( int argc, char *argv[])
}
else movie_file = file_name;
// __asm__ __volatile__("int3");
stream_duration = pFormatCtx->duration;
printf("duration %f\n", (double)stream_duration);
// Find the first video stream
videoStream=-1;
audioStream=-1;
@ -172,7 +168,6 @@ int main( int argc, char *argv[])
// printf("ctx->pix_fmt %d\n", pCodecCtx->pix_fmt);
mutex_init(&driver_lock);
mutex_init(&q_video.lock);
mutex_init(&q_audio.lock);
@ -245,7 +240,6 @@ int main( int argc, char *argv[])
if(astream.lock.handle)
mutex_destroy(&astream.lock);
mutex_destroy(&driver_lock);
mutex_destroy(&q_video.lock);
mutex_destroy(&q_audio.lock);

View File

@ -124,10 +124,6 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa);
double get_master_clock(void);
int create_thread(int (*proc)(void *param), void *param, int stack_size);
static inline void GetNotify(void *event)
{
__asm__ __volatile__ (

View File

@ -10,86 +10,6 @@
extern uint32_t hw2d ;
#if 0
#define FUTEX_INIT 0
#define FUTEX_DESTROY 1
#define FUTEX_WAIT 2
#define FUTEX_WAKE 3
int __fastcall mutex_init(mutex_t *mutex)
{
unsigned int handle;
mutex->lock = 0;
asm volatile(
"int $0x40\t"
:"=a"(handle)
:"a"(77),"b"(FUTEX_INIT),"c"(mutex));
mutex->handle = handle;
return handle;
};
int __fastcall mutex_destroy(mutex_t *mutex)
{
int retval;
asm volatile(
"int $0x40\t"
:"=a"(retval)
:"a"(77),"b"(FUTEX_DESTROY),"c"(mutex->handle));
return retval;
};
#define exchange_acquire(ptr, new) \
__atomic_exchange_4((ptr), (new), __ATOMIC_ACQUIRE)
#define exchange_release(ptr, new) \
__atomic_exchange_4((ptr), (new), __ATOMIC_RELEASE)
void __fastcall mutex_lock(mutex_t *mutex)
{
int tmp;
if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
return;
while (exchange_acquire (&mutex->lock, 2) != 0)
{
asm volatile(
"int $0x40\t"
:"=a"(tmp)
:"a"(77),"b"(FUTEX_WAIT),
"c"(mutex->handle),"d"(2),"S"(0));
}
}
int __fastcall mutex_trylock (mutex_t *mutex)
{
int zero = 0;
return __atomic_compare_exchange_4(&mutex->lock, &zero, 1,0,__ATOMIC_ACQUIRE,__ATOMIC_RELAXED);
}
void __fastcall mutex_unlock(mutex_t *mutex)
{
int prev;
prev = exchange_release (&mutex->lock, 0);
if (prev != 1)
{
asm volatile(
"int $0x40\t"
:"=a"(prev)
:"a"(77),"b"(FUTEX_WAKE),
"c"(mutex->handle),"d"(1));
};
};
#endif
int64_t _lseeki64(int fd, int64_t offset, int origin )
{
int off = offset;
@ -100,10 +20,6 @@ int put_packet(queue_t *q, AVPacket *pkt)
{
AVPacketList *q_pkt;
/* duplicate the packet */
// if (av_dup_packet(pkt) < 0)
// return -1;
q_pkt = av_malloc(sizeof(AVPacketList));
if (!q_pkt)
return -1;

View File

@ -4,11 +4,12 @@
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <kos32sys.h>
#include "winlib/winlib.h"
#include <sound.h>
#include "fplay.h"
#include <math.h>
#include <kos32sys.h>
#include <sound.h>
#include "winlib/winlib.h"
#include "fplay.h"
int fplay_blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,int w, int h);
void draw_va_picture(render_t *render, AVPicture *picture);
@ -71,7 +72,6 @@ int init_video(AVCodecContext *ctx)
width = ctx->width;
height = ctx->height;
Frame = avcodec_alloc_frame();
if ( Frame == NULL )
{
@ -83,9 +83,6 @@ int init_video(AVCodecContext *ctx)
{
int ret;
// printf("alloc picture %d %d %x\n",
// ctx->width, ctx->height, ctx->pix_fmt );
ret = avpicture_alloc(&frames[i].picture, ctx->pix_fmt,
ctx->width, ctx->height);
if ( ret != 0 )
@ -152,12 +149,6 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
else
pts= 0;
// pts = *(int64_t*)av_opt_ptr(avcodec_get_frame_class(),
// Frame, "best_effort_timestamp");
// if (pts == AV_NOPTS_VALUE)
// pts = 0;
pts *= av_q2d(video_time_base);
dst_pic = &frames[dfx].picture;
@ -167,7 +158,6 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height);
frames[dfx].pts = pts*1000.0;
// printf("pts %f\n", frames[dfx].pts);
frames[dfx].ready = 1;
@ -205,8 +195,6 @@ static void player_stop()
decoder_state = PLAY_2_STOP;
sound_state = PLAY_2_STOP;
render_draw_client(main_render);
// printf("stop player\n");
};
int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
@ -353,7 +341,6 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
rewind_pos = (prg->max - prg->min)*prg->pos/prg->ctrl.w;
// printf("progress action pos: %d time: %f\n", prg->pos, (double)rewind_pos);
player_state = REWIND;
decoder_state = REWIND;
sound_state = PLAY_2_STOP;
@ -379,10 +366,8 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
int level;
peak = sld->min + sld->pos * (sld->max - sld->min)/(96);
// level = (log2(peak+16384)*10000.0)/15 - 10000;
level = peak;
// printf("level %d\n", level);
set_audio_volume(level, level);
send_message(&sld->ctrl, MSG_PAINT, 0, 0);
win->panel.lvl->vol = level;
@ -621,9 +606,7 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags)
render->ctx_height = ctx->height;
render->ctx_format = ctx->pix_fmt;
mutex_lock(&driver_lock);
render->caps = pxInit(1);
mutex_unlock(&driver_lock);
right = win->w;
bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;