Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6105 → Rev 6106

/contrib/media/fplay/Makefile
14,7 → 14,7
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
 
/contrib/media/fplay/audio.c
1,11 → 1,12
 
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include "libswresample/swresample.h"
#include <libswresample/swresample.h>
#include <kos32sys.h>
 
#include <stdio.h>
#include <string.h>
#include "winlib/winlib.h"
#include "sound.h"
#include "fplay.h"
40,19 → 41,12
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,7 → 100,6
int got_frame;
int data_size;
 
 
if( astream.count > 192000*2)
return -1;
 
113,8 → 106,6
if( get_packet(qa, &pkt) == 0 )
return 0;
 
// __asm__("int3");
 
if (!aFrame)
{
if (!(aFrame = avcodec_alloc_frame()))
128,8 → 119,6
{
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
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);
};
/contrib/media/fplay/fplay.c
51,7 → 51,6
int64_t stream_duration;
 
int threads_running = DECODER_THREAD;
mutex_t driver_lock;
 
extern double audio_base;
 
110,11 → 109,8
}
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
 
// 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
if(astream.lock.handle)
mutex_destroy(&astream.lock);
 
mutex_destroy(&driver_lock);
mutex_destroy(&q_video.lock);
mutex_destroy(&q_audio.lock);
 
/contrib/media/fplay/fplay.h
124,10 → 124,6
 
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__ (
/contrib/media/fplay/utils.c
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
{
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;
/contrib/media/fplay/video.c
4,11 → 4,12
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <math.h>
#include <kos32sys.h>
#include <sound.h>
 
#include "winlib/winlib.h"
#include <sound.h>
#include "fplay.h"
#include <math.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
width = ctx->width;
height = ctx->height;
 
 
Frame = avcodec_alloc_frame();
if ( Frame == NULL )
{
83,9 → 83,6
{
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
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
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
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
 
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 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->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;