[Renesas]Modify player output buffer to dynamic malloc

This commit is contained in:
Rbb666 2023-05-05 14:37:37 +08:00 committed by guo
parent df85bdeeee
commit 22a7bf8711
4 changed files with 27 additions and 25 deletions

View File

@ -19,7 +19,6 @@
#define JPEG_WIDTH 400
#define JPEG_HEIGHT 240
#define DCODE_BUFFER_SIZE (35 * 1024)
#define MY_CLASS &lv_media_class
@ -34,6 +33,9 @@ lv_obj_t *ui_ImgButton3;
lv_obj_t *ui_Indicator_Left;
lv_obj_t *ui_Audio_Wave;
static decode_drv_t decode;
static uint8_t *jpeg_outbuffer;
const lv_obj_class_t lv_media_class =
{
.width_def = LV_SIZE_CONTENT,
@ -379,6 +381,21 @@ static void auto_run_video_timer_cb(lv_timer_t *timer)
lv_timer_del(timer);
}
int player_init(void)
{
jpeg_outbuffer = rt_malloc_align(DCODE_BUFFER_SIZE, 8);
RT_ASSERT(jpeg_outbuffer != NULL)
rt_memset(jpeg_outbuffer, 0x00, DCODE_BUFFER_SIZE);
v_player.decode = &decode;
v_player.decode->jpeg_out_buf = jpeg_outbuffer;
v_player.decode->decode_read = lv_avi_player_draw;
player_start(&v_player);
return 0;
}
void lv_video_gui_init(void)
{
win_obj = lv_media_page_create(lv_scr_act());
@ -390,19 +407,6 @@ void lv_video_gui_init(void)
lv_timer_t *t = lv_timer_create(auto_run_video_timer_cb, 2000, NULL);
lv_timer_ready(t);
player_init();
}
static uint8_t jpeg_outbuffer[DCODE_BUFFER_SIZE] BSP_ALIGN_VARIABLE(8);
static decode_drv_t decode;
int player_init(void)
{
v_player.decode = &decode;
v_player.decode->jpeg_out_buf = &jpeg_outbuffer;
v_player.decode->decode_read = lv_avi_player_draw;
player_start(&v_player);
return 0;
}
INIT_APP_EXPORT(player_init);

View File

@ -19,8 +19,6 @@
#define __Map(x, in_min, in_max, out_min, out_max) \
(((x) - (in_min)) * ((out_max) - (out_min)) / ((in_max) - (in_min)) + (out_min))
#define v_pbuffer_size 35 * 1024
struct avi_file_info
{
uint32_t Strsize;
@ -101,7 +99,7 @@ static int video_start_parser(player_t player, int fd, char *filename)
LOG_I("video total time:%02d:%02d:%02d\n", alltime / 3600, (alltime % 3600) / 60, alltime % 60);
lseek(fd, AVI_file.movi_start, SEEK_SET);
avi_file.Strsize = read_video_frame(fd, v_pbuffer, v_pbuffer_size, &avi_file.Strtype);
avi_file.Strsize = read_video_frame(fd, v_pbuffer, DCODE_BUFFER_SIZE, &avi_file.Strtype);
avi_file.BytesRD = avi_file.Strsize + 8;
return fd;
@ -426,7 +424,7 @@ static void player_entry(void *parameter)
}
/* read frame */
avi_file.Strsize = read_video_frame(fd, v_pbuffer, v_pbuffer_size, &avi_file.Strtype);
avi_file.Strsize = read_video_frame(fd, v_pbuffer, DCODE_BUFFER_SIZE, &avi_file.Strtype);
avi_file.BytesRD += avi_file.Strsize + 8;
player->song_time_pass = ((double)avi_file.BytesRD / AVI_file.movi_size) * player->song_time_all;
@ -488,9 +486,9 @@ int player_start(player_t player)
return -RT_ERROR;
}
v_pbuffer = rt_malloc(v_pbuffer_size);
v_pbuffer = rt_malloc(DCODE_BUFFER_SIZE);
RT_ASSERT(v_pbuffer != NULL)
rt_memset(v_pbuffer, 0x00, v_pbuffer_size);
rt_memset(v_pbuffer, 0x00, DCODE_BUFFER_SIZE);
/* read filesystem */
search_files(player, "/", ".avi");

View File

@ -15,9 +15,6 @@
#ifdef BSP_USING_JPEG
#define DCODE_BUFFER_SIZE (35 * 1024)
#define JPEG_TIMEOUT (100)
static rt_sem_t _SemaphoreJPEG = RT_NULL;
volatile static jpeg_status_t g_jpeg_status = JPEG_STATUS_NONE;

View File

@ -4,6 +4,9 @@
#include <rtthread.h>
#include "hal_data.h"
#define DCODE_BUFFER_SIZE (30 * 1024)
#define JPEG_TIMEOUT (100)
typedef struct _decode_drv_t
{
void *jpeg_out_buf;