mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-27 15:56:18 -04:00
Clean up the video output code - remove the final traces of libvo (used by mpeg2dec) and remove unused code-paths from the main decoding loop.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10638 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f5e78674ff
commit
567cb6e615
3 changed files with 23 additions and 168 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* mpegplayer.c - based on mpeg2dec.c
|
* mpegplayer.c - based on mpeg2dec.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
|
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
|
||||||
|
|
@ -45,11 +45,8 @@ struct plugin_api* rb;
|
||||||
#define BUFFER_SIZE (MEM-6)*1024*1024
|
#define BUFFER_SIZE (MEM-6)*1024*1024
|
||||||
|
|
||||||
static mpeg2dec_t * mpeg2dec;
|
static mpeg2dec_t * mpeg2dec;
|
||||||
static vo_open_t * output_open = NULL;
|
|
||||||
static vo_instance_t * output;
|
|
||||||
static int total_offset = 0;
|
static int total_offset = 0;
|
||||||
|
|
||||||
extern vo_open_t vo_rockbox_open;
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||||
#define MPEG_STOP BUTTON_OFF
|
#define MPEG_STOP BUTTON_OFF
|
||||||
|
|
@ -106,7 +103,6 @@ static bool decode_mpeg2 (uint8_t * current, uint8_t * end)
|
||||||
{
|
{
|
||||||
const mpeg2_info_t * info;
|
const mpeg2_info_t * info;
|
||||||
mpeg2_state_t state;
|
mpeg2_state_t state;
|
||||||
vo_setup_result_t setup_result;
|
|
||||||
|
|
||||||
mpeg2_buffer (mpeg2dec, current, end);
|
mpeg2_buffer (mpeg2dec, current, end);
|
||||||
total_offset += end - current;
|
total_offset += end - current;
|
||||||
|
|
@ -121,70 +117,20 @@ static bool decode_mpeg2 (uint8_t * current, uint8_t * end)
|
||||||
case STATE_BUFFER:
|
case STATE_BUFFER:
|
||||||
return false;
|
return false;
|
||||||
case STATE_SEQUENCE:
|
case STATE_SEQUENCE:
|
||||||
/* might set nb fbuf, convert format, stride */
|
vo_setup(info->sequence->width,
|
||||||
/* might set fbufs */
|
info->sequence->height,
|
||||||
if (output->setup (output, info->sequence->width,
|
info->sequence->chroma_width,
|
||||||
info->sequence->height,
|
info->sequence->chroma_height);
|
||||||
info->sequence->chroma_width,
|
mpeg2_skip (mpeg2dec, false);
|
||||||
info->sequence->chroma_height, &setup_result)) {
|
|
||||||
//fprintf (stderr, "display setup failed\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (setup_result.convert &&
|
|
||||||
mpeg2_convert (mpeg2dec, setup_result.convert, NULL)) {
|
|
||||||
//fprintf (stderr, "color conversion setup failed\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (output->set_fbuf) {
|
|
||||||
uint8_t * buf[3];
|
|
||||||
void * id;
|
|
||||||
|
|
||||||
mpeg2_custom_fbuf (mpeg2dec, 1);
|
|
||||||
output->set_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
output->set_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
} else if (output->setup_fbuf) {
|
|
||||||
uint8_t * buf[3];
|
|
||||||
void * id;
|
|
||||||
|
|
||||||
output->setup_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
output->setup_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
output->setup_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
}
|
|
||||||
mpeg2_skip (mpeg2dec, (output->draw == NULL));
|
|
||||||
break;
|
break;
|
||||||
case STATE_PICTURE:
|
case STATE_PICTURE:
|
||||||
/* might skip */
|
|
||||||
/* might set fbuf */
|
|
||||||
if (output->set_fbuf) {
|
|
||||||
uint8_t * buf[3];
|
|
||||||
void * id;
|
|
||||||
|
|
||||||
output->set_fbuf (output, buf, &id);
|
|
||||||
mpeg2_set_buf (mpeg2dec, buf, id);
|
|
||||||
}
|
|
||||||
if (output->start_fbuf)
|
|
||||||
output->start_fbuf (output, info->current_fbuf->buf,
|
|
||||||
info->current_fbuf->id);
|
|
||||||
break;
|
break;
|
||||||
case STATE_SLICE:
|
case STATE_SLICE:
|
||||||
case STATE_END:
|
case STATE_END:
|
||||||
case STATE_INVALID_END:
|
case STATE_INVALID_END:
|
||||||
/* draw current picture */
|
/* draw current picture */
|
||||||
/* might free frame buffer */
|
if (info->display_fbuf)
|
||||||
if (info->display_fbuf) {
|
vo_draw_frame(info->display_fbuf->buf);
|
||||||
if (output->draw)
|
|
||||||
output->draw (output, info->display_fbuf->buf,
|
|
||||||
info->display_fbuf->id);
|
|
||||||
//print_fps (0);
|
|
||||||
}
|
|
||||||
if (output->discard && info->discard_fbuf)
|
|
||||||
output->discard (output, info->discard_fbuf->buf,
|
|
||||||
info->discard_fbuf->id);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -256,20 +202,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
output_open = vo_rockbox_open;
|
|
||||||
|
|
||||||
if (output_open == NULL) {
|
|
||||||
//fprintf (stderr, "output_open is NULL\n");
|
|
||||||
return PLUGIN_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
output = output_open ();
|
|
||||||
|
|
||||||
if (output == NULL) {
|
|
||||||
//fprintf (stderr, "Can not open output\n");
|
|
||||||
return PLUGIN_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mpeg2dec = mpeg2_init ();
|
mpeg2dec = mpeg2_init ();
|
||||||
|
|
||||||
if (mpeg2dec == NULL)
|
if (mpeg2dec == NULL)
|
||||||
|
|
|
||||||
|
|
@ -21,38 +21,6 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct mpeg2_sequence_s;
|
void vo_draw_frame (uint8_t * const * buf);
|
||||||
struct mpeg2_convert_init_s;
|
void vo_setup (unsigned int width, unsigned int height,
|
||||||
typedef struct {
|
unsigned int chroma_width, unsigned int chroma_height);
|
||||||
int (* convert) (int stage, void * id,
|
|
||||||
const struct mpeg2_sequence_s * sequence,
|
|
||||||
int stride, uint32_t accel, void * arg,
|
|
||||||
struct mpeg2_convert_init_s * result);
|
|
||||||
} vo_setup_result_t;
|
|
||||||
|
|
||||||
typedef struct vo_instance_s vo_instance_t;
|
|
||||||
struct vo_instance_s {
|
|
||||||
int (* setup) (vo_instance_t * instance, unsigned int width,
|
|
||||||
unsigned int height, unsigned int chroma_width,
|
|
||||||
unsigned int chroma_height, vo_setup_result_t * result);
|
|
||||||
void (* setup_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id);
|
|
||||||
void (* set_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id);
|
|
||||||
void (* start_fbuf) (vo_instance_t * instance,
|
|
||||||
uint8_t * const * buf, void * id);
|
|
||||||
void (* draw) (vo_instance_t * instance, uint8_t * const * buf, void * id);
|
|
||||||
void (* discard) (vo_instance_t * instance,
|
|
||||||
uint8_t * const * buf, void * id);
|
|
||||||
void (* close) (vo_instance_t * instance);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef vo_instance_t * vo_open_t (void);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char * name;
|
|
||||||
vo_open_t * open;
|
|
||||||
} vo_driver_t;
|
|
||||||
|
|
||||||
void vo_accel (uint32_t accel);
|
|
||||||
|
|
||||||
/* return NULL terminated array of all drivers */
|
|
||||||
vo_driver_t const * vo_drivers (void);
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@ static int output_y;
|
||||||
static int output_width;
|
static int output_width;
|
||||||
static int output_height;
|
static int output_height;
|
||||||
|
|
||||||
#if (LCD_DEPTH == 16) && \
|
#ifdef SIMULATOR
|
||||||
((LCD_PIXELFORMAT == RGB565) || (LCD_PIXELFORMAT == RGB565SWAPPED))
|
|
||||||
|
|
||||||
#define RYFAC (31*257)
|
#define RYFAC (31*257)
|
||||||
#define GYFAC (63*257)
|
#define GYFAC (63*257)
|
||||||
|
|
@ -59,9 +58,9 @@ static int output_height;
|
||||||
#define ROUNDOFFS (127*257)
|
#define ROUNDOFFS (127*257)
|
||||||
|
|
||||||
/* Draw a partial YUV colour bitmap - taken from the Rockbox JPEG viewer */
|
/* Draw a partial YUV colour bitmap - taken from the Rockbox JPEG viewer */
|
||||||
void yuv_bitmap_part(unsigned char * const src[3],
|
static void yuv_bitmap_part(unsigned char * const src[3],
|
||||||
int src_x, int src_y, int stride,
|
int src_x, int src_y, int stride,
|
||||||
int x, int y, int width, int height)
|
int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
fb_data *dst, *dst_end;
|
fb_data *dst, *dst_end;
|
||||||
|
|
||||||
|
|
@ -190,25 +189,20 @@ void yuv_bitmap_part(unsigned char * const src[3],
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void rockbox_draw_frame (vo_instance_t * instance,
|
void vo_draw_frame (uint8_t * const * buf)
|
||||||
uint8_t * const * buf, void * id)
|
|
||||||
{
|
{
|
||||||
char str[80];
|
char str[80];
|
||||||
static int frame=0;
|
static int frame=0;
|
||||||
int ticks,fps;
|
int ticks,fps;
|
||||||
|
|
||||||
(void)id;
|
#ifdef SIMULATOR
|
||||||
(void)instance;
|
|
||||||
|
|
||||||
#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
|
|
||||||
rb->lcd_yuv_blit(buf,
|
|
||||||
0,0,image_width,
|
|
||||||
output_x,output_y,output_width,output_height);
|
|
||||||
#elif (LCD_DEPTH == 16) && \
|
|
||||||
((LCD_PIXELFORMAT == RGB565) || (LCD_PIXELFORMAT == RGB565SWAPPED))
|
|
||||||
yuv_bitmap_part(buf,0,0,image_width,
|
yuv_bitmap_part(buf,0,0,image_width,
|
||||||
output_x,output_y,output_width,output_height);
|
output_x,output_y,output_width,output_height);
|
||||||
rb->lcd_update_rect(output_x,output_y,output_width,output_height);
|
rb->lcd_update_rect(output_x,output_y,output_width,output_height);
|
||||||
|
#else
|
||||||
|
rb->lcd_yuv_blit(buf,
|
||||||
|
0,0,image_width,
|
||||||
|
output_x,output_y,output_width,output_height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (starttick==0) {
|
if (starttick==0) {
|
||||||
|
|
@ -230,41 +224,9 @@ static void rockbox_draw_frame (vo_instance_t * instance,
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vo_instance_t static_instance;
|
void vo_setup(unsigned int width, unsigned int height,
|
||||||
|
unsigned int chroma_width, unsigned int chroma_height)
|
||||||
static vo_instance_t * internal_open (int setup (vo_instance_t *, unsigned int,
|
|
||||||
unsigned int, unsigned int,
|
|
||||||
unsigned int,
|
|
||||||
vo_setup_result_t *),
|
|
||||||
void draw (vo_instance_t *,
|
|
||||||
uint8_t * const *, void *))
|
|
||||||
{
|
{
|
||||||
vo_instance_t * instance;
|
|
||||||
|
|
||||||
instance = (vo_instance_t *) &static_instance;
|
|
||||||
if (instance == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
instance->setup = setup;
|
|
||||||
instance->setup_fbuf = NULL;
|
|
||||||
instance->set_fbuf = NULL;
|
|
||||||
instance->start_fbuf = NULL;
|
|
||||||
instance->draw = draw;
|
|
||||||
instance->discard = NULL;
|
|
||||||
//instance->close = (void (*) (vo_instance_t *)) free;
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rockbox_setup (vo_instance_t * instance, unsigned int width,
|
|
||||||
unsigned int height, unsigned int chroma_width,
|
|
||||||
unsigned int chroma_height,
|
|
||||||
vo_setup_result_t * result)
|
|
||||||
{
|
|
||||||
(void)instance;
|
|
||||||
|
|
||||||
result->convert = NULL;
|
|
||||||
|
|
||||||
image_width=width;
|
image_width=width;
|
||||||
image_height=height;
|
image_height=height;
|
||||||
image_chroma_x=image_width/chroma_width;
|
image_chroma_x=image_width/chroma_width;
|
||||||
|
|
@ -285,11 +247,4 @@ static int rockbox_setup (vo_instance_t * instance, unsigned int width,
|
||||||
output_height = image_height;
|
output_height = image_height;
|
||||||
output_y = (LCD_HEIGHT-image_height)/2;
|
output_y = (LCD_HEIGHT-image_height)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
vo_instance_t * vo_rockbox_open (void)
|
|
||||||
{
|
|
||||||
return internal_open (rockbox_setup, rockbox_draw_frame);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue