Commit f102b577 authored by Rafaël Carré's avatar Rafaël Carré

Same for lxdialog and xvmc

parent d6008a8b
This diff is collapsed.
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
#define ACS_DARROW 'v' #define ACS_DARROW 'v'
#endif #endif
/* /*
* Attribute names * Attribute names
*/ */
#define screen_attr attributes[0] #define screen_attr attributes[0]
...@@ -146,23 +146,23 @@ void color_setup (void); ...@@ -146,23 +146,23 @@ void color_setup (void);
void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
void print_button (WINDOW * win, const char *label, int y, int x, int selected); void print_button (WINDOW * win, const char *label, int y, int x, int selected);
void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
chtype border); chtype border);
void draw_shadow (WINDOW * win, int y, int x, int height, int width); void draw_shadow (WINDOW * win, int y, int x, int height, int width);
int first_alpha (const char *string, const char *exempt); int first_alpha (const char *string, const char *exempt);
int dialog_yesno (const char *title, const char *prompt, int height, int width); int dialog_yesno (const char *title, const char *prompt, int height, int width);
int dialog_msgbox (const char *title, const char *prompt, int height, int dialog_msgbox (const char *title, const char *prompt, int height,
int width, int pause); int width, int pause);
int dialog_textbox (const char *title, const char *file, int height, int width); int dialog_textbox (const char *title, const char *file, int height, int width);
int dialog_menu (const char *title, const char *prompt, int height, int width, int dialog_menu (const char *title, const char *prompt, int height, int width,
int menu_height, const char *choice, int item_no, int menu_height, const char *choice, int item_no,
const char * const * items); const char * const * items);
int dialog_checklist (const char *title, const char *prompt, int height, int dialog_checklist (const char *title, const char *prompt, int height,
int width, int list_height, int item_no, int width, int list_height, int item_no,
const char * const * items, int flag); const char * const * items, int flag);
extern unsigned char dialog_input_result[]; extern unsigned char dialog_input_result[];
int dialog_inputbox (const char *title, const char *prompt, int height, int dialog_inputbox (const char *title, const char *prompt, int height,
int width, const char *init); int width, const char *init);
/* /*
* This is the base for fictitious keys, which activate * This is the base for fictitious keys, which activate
......
...@@ -44,7 +44,7 @@ print_buttons(WINDOW *dialog, int height, int width, int selected) ...@@ -44,7 +44,7 @@ print_buttons(WINDOW *dialog, int height, int width, int selected)
*/ */
int int
dialog_inputbox (const char *title, const char *prompt, int height, int width, dialog_inputbox (const char *title, const char *prompt, int height, int width,
const char *init) const char *init)
{ {
int i, x, y, box_y, box_x, box_width; int i, x, y, box_y, box_x, box_width;
int input_x = 0, scroll = 0, key = 0, button = -1; int input_x = 0, scroll = 0, key = 0, button = -1;
...@@ -65,23 +65,23 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, ...@@ -65,23 +65,23 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE); mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
...@@ -93,7 +93,7 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, ...@@ -93,7 +93,7 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
box_y = y + 2; box_y = y + 2;
box_x = (width - box_width) / 2; box_x = (width - box_width) / 2;
draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2,
border_attr, dialog_attr); border_attr, dialog_attr);
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
...@@ -102,139 +102,139 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width, ...@@ -102,139 +102,139 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
if (!init) if (!init)
instr[0] = '\0'; instr[0] = '\0';
else else
strcpy (instr, init); strcpy (instr, init);
input_x = strlen (instr); input_x = strlen (instr);
if (input_x >= box_width) { if (input_x >= box_width) {
scroll = input_x - box_width + 1; scroll = input_x - box_width + 1;
input_x = box_width - 1; input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++) for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]); waddch (dialog, instr[scroll + i]);
} else } else
waddstr (dialog, instr); waddstr (dialog, instr);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
while (key != ESC) { while (key != ESC) {
key = wgetch (dialog); key = wgetch (dialog);
if (button == -1) { /* Input box selected */ if (button == -1) { /* Input box selected */
switch (key) { switch (key) {
case TAB: case TAB:
case KEY_UP: case KEY_UP:
case KEY_DOWN: case KEY_DOWN:
break; break;
case KEY_LEFT: case KEY_LEFT:
continue; continue;
case KEY_RIGHT: case KEY_RIGHT:
continue; continue;
case KEY_BACKSPACE: case KEY_BACKSPACE:
case 127: case 127:
if (input_x || scroll) { if (input_x || scroll) {
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
if (!input_x) { if (!input_x) {
scroll = scroll < box_width - 1 ? scroll = scroll < box_width - 1 ?
0 : scroll - (box_width - 1); 0 : scroll - (box_width - 1);
wmove (dialog, box_y, box_x); wmove (dialog, box_y, box_x);
for (i = 0; i < box_width; i++) for (i = 0; i < box_width; i++)
waddch (dialog, instr[scroll + input_x + i] ? waddch (dialog, instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' '); instr[scroll + input_x + i] : ' ');
input_x = strlen (instr) - scroll; input_x = strlen (instr) - scroll;
} else } else
input_x--; input_x--;
instr[scroll + input_x] = '\0'; instr[scroll + input_x] = '\0';
mvwaddch (dialog, box_y, input_x + box_x, ' '); mvwaddch (dialog, box_y, input_x + box_x, ' ');
wmove (dialog, box_y, input_x + box_x); wmove (dialog, box_y, input_x + box_x);
wrefresh (dialog); wrefresh (dialog);
} }
continue; continue;
default: default:
if (key < 0x100 && isprint (key)) { if (key < 0x100 && isprint (key)) {
if (scroll + input_x < MAX_LEN) { if (scroll + input_x < MAX_LEN) {
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
instr[scroll + input_x] = key; instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0'; instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) { if (input_x == box_width - 1) {
scroll++; scroll++;
wmove (dialog, box_y, box_x); wmove (dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++) for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]); waddch (dialog, instr[scroll + i]);
} else { } else {
wmove (dialog, box_y, input_x++ + box_x); wmove (dialog, box_y, input_x++ + box_x);
waddch (dialog, key); waddch (dialog, key);
} }
wrefresh (dialog); wrefresh (dialog);
} else } else
flash (); /* Alarm user about overflow */ flash (); /* Alarm user about overflow */
continue; continue;
} }
} }
} }
switch (key) { switch (key) {
case 'O': case 'O':
case 'o': case 'o':
delwin (dialog); delwin (dialog);
return 0; return 0;
case 'H': case 'H':
case 'h': case 'h':
delwin (dialog); delwin (dialog);
return 1; return 1;
case KEY_UP: case KEY_UP:
case KEY_LEFT: case KEY_LEFT:
switch (button) { switch (button) {
case -1: case -1:
button = 1; /* Indicates "Cancel" button is selected */ button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1); print_buttons(dialog, height, width, 1);
break; break;
case 0: case 0:
button = -1; /* Indicates input box is selected */ button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
break; break;
case 1: case 1:
button = 0; /* Indicates "OK" button is selected */ button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
break; break;
} }
break; break;
case TAB: case TAB:
case KEY_DOWN: case KEY_DOWN:
case KEY_RIGHT: case KEY_RIGHT:
switch (button) { switch (button) {
case -1: case -1:
button = 0; /* Indicates "OK" button is selected */ button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
break; break;
case 0: case 0:
button = 1; /* Indicates "Cancel" button is selected */ button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1); print_buttons(dialog, height, width, 1);
break; break;
case 1: case 1:
button = -1; /* Indicates input box is selected */ button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
break; break;
} }
break; break;
case ' ': case ' ':
case '\n': case '\n':
delwin (dialog); delwin (dialog);
return (button == -1 ? 0 : button); return (button == -1 ? 0 : button);
case 'X': case 'X':
case 'x': case 'x':
key = ESC; key = ESC;
case ESC: case ESC:
break; break;
} }
} }
delwin (dialog); delwin (dialog);
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }
...@@ -67,19 +67,19 @@ main (int argc, const char * const * argv) ...@@ -67,19 +67,19 @@ main (int argc, const char * const * argv)
trace(TRACE_CALLS|TRACE_UPDATE); trace(TRACE_CALLS|TRACE_UPDATE);
#endif #endif
if (argc < 2) { if (argc < 2) {
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} }
while (offset < argc - 1 && !end_common_opts) { /* Common options */ while (offset < argc - 1 && !end_common_opts) { /* Common options */
if (!strcmp (argv[offset + 1], "--title")) { if (!strcmp (argv[offset + 1], "--title")) {
if (argc - offset < 3 || title != NULL) { if (argc - offset < 3 || title != NULL) {
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} else { } else {
title = argv[offset + 2]; title = argv[offset + 2];
offset += 2; offset += 2;
} }
} else if (!strcmp (argv[offset + 1], "--backtitle")) { } else if (!strcmp (argv[offset + 1], "--backtitle")) {
if (backtitle != NULL) { if (backtitle != NULL) {
Usage (argv[0]); Usage (argv[0]);
...@@ -88,48 +88,48 @@ main (int argc, const char * const * argv) ...@@ -88,48 +88,48 @@ main (int argc, const char * const * argv)
backtitle = argv[offset + 2]; backtitle = argv[offset + 2];
offset += 2; offset += 2;
} }
} else if (!strcmp (argv[offset + 1], "--clear")) { } else if (!strcmp (argv[offset + 1], "--clear")) {
if (clear_screen) { /* Hey, "--clear" can't appear twice! */ if (clear_screen) { /* Hey, "--clear" can't appear twice! */
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} else if (argc == 2) { /* we only want to clear the screen */ } else if (argc == 2) { /* we only want to clear the screen */
init_dialog (); init_dialog ();
refresh (); /* init_dialog() will clear the screen for us */ refresh (); /* init_dialog() will clear the screen for us */
end_dialog (); end_dialog ();
return 0; return 0;
} else { } else {
clear_screen = 1; clear_screen = 1;
offset++; offset++;
} }
} else /* no more common options */ } else /* no more common options */
end_common_opts = 1; end_common_opts = 1;
} }
if (argc - 1 == offset) { /* no more options */ if (argc - 1 == offset) { /* no more options */
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} }
/* use a table to look for the requested mode, to avoid code duplication */ /* use a table to look for the requested mode, to avoid code duplication */
for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
if (!strcmp (argv[offset + 1], modePtr->name)) if (!strcmp (argv[offset + 1], modePtr->name))
break; break;
if (!modePtr->name) if (!modePtr->name)
Usage (argv[0]); Usage (argv[0]);
if (argc - offset < modePtr->argmin) if (argc - offset < modePtr->argmin)
Usage (argv[0]); Usage (argv[0]);
if (modePtr->argmax && argc - offset > modePtr->argmax) if (modePtr->argmax && argc - offset > modePtr->argmax)
Usage (argv[0]); Usage (argv[0]);
init_dialog (); init_dialog ();
retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
if (clear_screen) { /* clear screen before exit */ if (clear_screen) { /* clear screen before exit */
attr_clear (stdscr, LINES, COLS, screen_attr); attr_clear (stdscr, LINES, COLS, screen_attr);
refresh (); refresh ();
} }
end_dialog(); end_dialog();
...@@ -173,21 +173,21 @@ int ...@@ -173,21 +173,21 @@ int
j_menu (const char *t, int ac, const char * const * av) j_menu (const char *t, int ac, const char * const * av)
{ {
return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), av[6], (ac - 6) / 2, av + 7); atoi (av[5]), av[6], (ac - 6) / 2, av + 7);
} }
int int
j_checklist (const char *t, int ac, const char * const * av) j_checklist (const char *t, int ac, const char * const * av)
{ {
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
} }
int int
j_radiolist (const char *t, int ac, const char * const * av) j_radiolist (const char *t, int ac, const char * const * av)
{ {
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
} }
int int
......
This diff is collapsed.
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
int int
dialog_msgbox (const char *title, const char *prompt, int height, int width, dialog_msgbox (const char *title, const char *prompt, int height, int width,
int pause) int pause)
{ {
int i, x, y, key = 0; int i, x, y, key = 0;
WINDOW *dialog; WINDOW *dialog;
...@@ -44,40 +44,40 @@ dialog_msgbox (const char *title, const char *prompt, int height, int width, ...@@ -44,40 +44,40 @@ dialog_msgbox (const char *title, const char *prompt, int height, int width,
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 2); print_autowrap (dialog, prompt, width - 2, 1, 2);
if (pause) { if (pause) {
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height - 3, 0, ACS_LTEE); mvwaddch (dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
print_button (dialog, " Ok ", print_button (dialog, " Ok ",
height - 2, width / 2 - 4, TRUE); height - 2, width / 2 - 4, TRUE);
wrefresh (dialog); wrefresh (dialog);
while (key != ESC && key != '\n' && key != ' ' && while (key != ESC && key != '\n' && key != ' ' &&
key != 'O' && key != 'o' && key != 'X' && key != 'x') key != 'O' && key != 'o' && key != 'X' && key != 'x')
key = wgetch (dialog); key = wgetch (dialog);
} else { } else {
key = '\n'; key = '\n';
wrefresh (dialog); wrefresh (dialog);
} }
delwin (dialog); delwin (dialog);
......
This diff is collapsed.
This diff is collapsed.
...@@ -59,23 +59,23 @@ dialog_yesno (const char *title, const char *prompt, int height, int width) ...@@ -59,23 +59,23 @@ dialog_yesno (const char *title, const char *prompt, int height, int width)
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE); mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
...@@ -84,35 +84,35 @@ dialog_yesno (const char *title, const char *prompt, int height, int width) ...@@ -84,35 +84,35 @@ dialog_yesno (const char *title, const char *prompt, int height, int width)
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
while (key != ESC) { while (key != ESC) {
key = wgetch (dialog); key = wgetch (dialog);
switch (key) { switch (key) {
case 'Y': case 'Y':
case 'y': case 'y':
delwin (dialog); delwin (dialog);
return 0; return 0;
case 'N': case 'N':
case 'n': case 'n':
delwin (dialog); delwin (dialog);
return 1; return 1;
case TAB: case TAB:
case KEY_LEFT: case KEY_LEFT:
case KEY_RIGHT: case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0) button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button); ? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button); print_buttons(dialog, height, width, button);
wrefresh (dialog); wrefresh (dialog);
break; break;
case ' ': case ' ':
case '\n': case '\n':
delwin (dialog); delwin (dialog);
return button; return button;
case ESC: case ESC:
break; break;
} }
} }
delwin (dialog); delwin (dialog);
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }
...@@ -81,15 +81,15 @@ static inline uint32_t arch_accel( void ) ...@@ -81,15 +81,15 @@ static inline uint32_t arch_accel( void )
AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65); AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
cpuid (0x00000001, eax, ebx, ecx, edx); cpuid (0x00000001, eax, ebx, ecx, edx);
if (! (edx & 0x00800000)) /* no MMX */ if (! (edx & 0x00800000)) /* no MMX */
return 0; return 0;
caps = MPEG2_ACCEL_X86_MMX; caps = MPEG2_ACCEL_X86_MMX;
if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */ if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT; caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
cpuid (0x80000000, eax, ebx, ecx, edx); cpuid (0x80000000, eax, ebx, ecx, edx);
if (eax < 0x80000001) /* no extended capabilities */ if (eax < 0x80000001) /* no extended capabilities */
return caps; return caps;
cpuid (0x80000001, eax, ebx, ecx, edx); cpuid (0x80000001, eax, ebx, ecx, edx);
...@@ -97,7 +97,7 @@ static inline uint32_t arch_accel( void ) ...@@ -97,7 +97,7 @@ static inline uint32_t arch_accel( void )
if (edx & 0x80000000) if (edx & 0x80000000)
caps |= MPEG2_ACCEL_X86_3DNOW; caps |= MPEG2_ACCEL_X86_3DNOW;
if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */ if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
caps |= MPEG2_ACCEL_X86_MMXEXT; caps |= MPEG2_ACCEL_X86_MMXEXT;
return caps; return caps;
......
...@@ -99,7 +99,7 @@ static inline int copy_chunk( mpeg2dec_t * mpeg2dec, int bytes ) ...@@ -99,7 +99,7 @@ static inline int copy_chunk( mpeg2dec_t * mpeg2dec, int bytes )
mpeg2dec->shift = 0xffffff00; mpeg2dec->shift = 0xffffff00;
mpeg2dec->chunk_size = chunk_ptr - mpeg2dec->chunk_start - 3; mpeg2dec->chunk_size = chunk_ptr - mpeg2dec->chunk_start - 3;
mpeg2dec->chunk_ptr = chunk_ptr + 1; mpeg2dec->chunk_ptr = chunk_ptr + 1;
copied = current - mpeg2dec->buf_start; copied = current - mpeg2dec->buf_start;
mpeg2dec->buf_start = current; mpeg2dec->buf_start = current;
return copied; return copied;
......
...@@ -108,7 +108,7 @@ void mpeg2_header_state_init( mpeg2dec_t *mpeg2dec ) ...@@ -108,7 +108,7 @@ void mpeg2_header_state_init( mpeg2dec_t *mpeg2dec )
} }
mpeg2dec->decoder.coding_type = I_TYPE; mpeg2dec->decoder.coding_type = I_TYPE;
mpeg2dec->decoder.convert = NULL; mpeg2dec->decoder.convert = NULL;
mpeg2dec->decoder.convert_id = NULL; mpeg2dec->decoder.convert_id = NULL;
mpeg2dec->decoder.load_intra_quantizer_matrix = 1; mpeg2dec->decoder.load_intra_quantizer_matrix = 1;
mpeg2dec->decoder.load_non_intra_quantizer_matrix = 1; mpeg2dec->decoder.load_non_intra_quantizer_matrix = 1;
mpeg2dec->picture = mpeg2dec->pictures; mpeg2dec->picture = mpeg2dec->pictures;
...@@ -249,11 +249,11 @@ static int sequence_ext( mpeg2dec_t * mpeg2dec ) ...@@ -249,11 +249,11 @@ static int sequence_ext( mpeg2dec_t * mpeg2dec )
switch( buffer[1] & 6 ) switch( buffer[1] & 6 )
{ {
case 0: /* invalid */ case 0: /* invalid */
return 1; return 1;
case 2: /* 4:2:0 */ case 2: /* 4:2:0 */
sequence->chroma_height >>= 1; sequence->chroma_height >>= 1;
case 4: /* 4:2:2 */ case 4: /* 4:2:2 */
sequence->chroma_width >>= 1; sequence->chroma_width >>= 1;
} }
...@@ -337,13 +337,13 @@ static inline void finalize_sequence( mpeg2_sequence_t * sequence ) ...@@ -337,13 +337,13 @@ static inline void finalize_sequence( mpeg2_sequence_t * sequence )
sequence->pixel_width = sequence->pixel_height = 1; sequence->pixel_width = sequence->pixel_height = 1;
return; return;
case 3: /* 720x576 16:9 */ case 3: /* 720x576 16:9 */
sequence->pixel_width = 64; sequence->pixel_height = 45; sequence->pixel_width = 64; sequence->pixel_height = 45;
return; return;
case 6: /* 720x480 16:9 */ case 6: /* 720x480 16:9 */
sequence->pixel_width = 32; sequence->pixel_height = 27; sequence->pixel_width = 32; sequence->pixel_height = 27;
return; return;
case 12: /* 720*480 4:3 */ case 12: /* 720*480 4:3 */
sequence->pixel_width = 8; sequence->pixel_height = 9; sequence->pixel_width = 8; sequence->pixel_height = 9;
return; return;
default: default:
height = 88 * sequence->pixel_width + 1171; height = 88 * sequence->pixel_width + 1171;
...@@ -577,7 +577,7 @@ int mpeg2_header_picture( mpeg2dec_t * mpeg2dec ) ...@@ -577,7 +577,7 @@ int mpeg2_header_picture( mpeg2dec_t * mpeg2dec )
decoder->concealment_motion_vectors = 0; decoder->concealment_motion_vectors = 0;
decoder->scan = mpeg2_scan_norm; decoder->scan = mpeg2_scan_norm;
decoder->picture_structure = FRAME_PICTURE; decoder->picture_structure = FRAME_PICTURE;
mpeg2dec->copy_matrix = 0; mpeg2dec->copy_matrix = 0;
return 0; return 0;
} }
...@@ -814,7 +814,7 @@ void mpeg2_header_picture_finalize( mpeg2dec_t * mpeg2dec, uint32_t accels ) ...@@ -814,7 +814,7 @@ void mpeg2_header_picture_finalize( mpeg2dec_t * mpeg2dec, uint32_t accels )
else else
{ {
/* decoder->second_field = 1; */ /* decoder->second_field = 1; */
mpeg2dec->picture++; /* second field picture */ mpeg2dec->picture++; /* second field picture */
*(mpeg2dec->picture) = mpeg2dec->new_picture; *(mpeg2dec->picture) = mpeg2dec->new_picture;
mpeg2dec->info.current_picture_2nd = mpeg2dec->picture; mpeg2dec->info.current_picture_2nd = mpeg2dec->picture;
if (low_delay || decoder->coding_type == B_TYPE) if (low_delay || decoder->coding_type == B_TYPE)
......
...@@ -50,53 +50,53 @@ void mpeg2_mc_init (uint32_t accel) ...@@ -50,53 +50,53 @@ void mpeg2_mc_init (uint32_t accel)
#define predict_x(i) (avg2 (ref[i], ref[i+1])) #define predict_x(i) (avg2 (ref[i], ref[i+1]))
#define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
#define predict_xy(i) (avg4 (ref[i], ref[i+1], \ #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
(ref+stride)[i], (ref+stride)[i+1])) (ref+stride)[i], (ref+stride)[i+1]))
#define put(predictor,i) dest[i] = predictor (i) #define put(predictor,i) dest[i] = predictor (i)
#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
/* mc function template */ /* mc function template */
#define MC_FUNC(op,xy) \ #define MC_FUNC(op,xy) \
static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \ const int stride, int height) \
{ \ { \
do { \ do { \
op (predict_##xy, 0); \ op (predict_##xy, 0); \
op (predict_##xy, 1); \ op (predict_##xy, 1); \
op (predict_##xy, 2); \ op (predict_##xy, 2); \
op (predict_##xy, 3); \ op (predict_##xy, 3); \
op (predict_##xy, 4); \ op (predict_##xy, 4); \
op (predict_##xy, 5); \ op (predict_##xy, 5); \
op (predict_##xy, 6); \ op (predict_##xy, 6); \
op (predict_##xy, 7); \ op (predict_##xy, 7); \
op (predict_##xy, 8); \ op (predict_##xy, 8); \
op (predict_##xy, 9); \ op (predict_##xy, 9); \
op (predict_##xy, 10); \ op (predict_##xy, 10); \
op (predict_##xy, 11); \ op (predict_##xy, 11); \
op (predict_##xy, 12); \ op (predict_##xy, 12); \
op (predict_##xy, 13); \ op (predict_##xy, 13); \
op (predict_##xy, 14); \ op (predict_##xy, 14); \
op (predict_##xy, 15); \ op (predict_##xy, 15); \
ref += stride; \ ref += stride; \
dest += stride; \ dest += stride; \
} while (--height); \ } while (--height); \
} \ } \
static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \ const int stride, int height) \
{ \ { \
do { \ do { \
op (predict_##xy, 0); \ op (predict_##xy, 0); \
op (predict_##xy, 1); \ op (predict_##xy, 1); \
op (predict_##xy, 2); \ op (predict_##xy, 2); \
op (predict_##xy, 3); \ op (predict_##xy, 3); \
op (predict_##xy, 4); \ op (predict_##xy, 4); \
op (predict_##xy, 5); \ op (predict_##xy, 5); \
op (predict_##xy, 6); \ op (predict_##xy, 6); \
op (predict_##xy, 7); \ op (predict_##xy, 7); \
ref += stride; \ ref += stride; \
dest += stride; \ dest += stride; \
} while (--height); \ } while (--height); \
} }
/* definitions of the actual mc functions */ /* definitions of the actual mc functions */
......
This diff is collapsed.
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define MPEG2_H #define MPEG2_H
#define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c)) #define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
#define MPEG2_RELEASE MPEG2_VERSION (0, 4, 0) /* 0.4.0 */ #define MPEG2_RELEASE MPEG2_VERSION (0, 4, 0) /* 0.4.0 */
#define SEQ_FLAG_MPEG2 1 #define SEQ_FLAG_MPEG2 1
#define SEQ_FLAG_CONSTRAINED_PARAMETERS 2 #define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
...@@ -154,9 +154,9 @@ typedef enum ...@@ -154,9 +154,9 @@ typedef enum
} mpeg2_convert_stage_t; } mpeg2_convert_stage_t;
typedef int mpeg2_convert_t (int stage, void * id, typedef int mpeg2_convert_t (int stage, void * id,
const mpeg2_sequence_t * sequence, int stride, const mpeg2_sequence_t * sequence, int stride,
uint32_t accel, void * arg, uint32_t accel, void * arg,
mpeg2_convert_init_t * result); mpeg2_convert_init_t * result);
int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
...@@ -188,7 +188,7 @@ void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); ...@@ -188,7 +188,7 @@ void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]); uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]);
typedef enum typedef enum
{ {
...@@ -202,6 +202,6 @@ typedef enum ...@@ -202,6 +202,6 @@ typedef enum
void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
void mpeg2_free (void * buf); void mpeg2_free (void * buf);
void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
int free (void *)); int free (void *));
#endif /* MPEG2_H */ #endif /* MPEG2_H */
...@@ -66,9 +66,9 @@ struct mpeg2_decoder_s ...@@ -66,9 +66,9 @@ struct mpeg2_decoder_s
/* next inside a slice, and is never used outside of mpeg2_slice() */ /* next inside a slice, and is never used outside of mpeg2_slice() */
/* bit parsing stuff */ /* bit parsing stuff */
uint32_t bitstream_buf; /* current 32 bit working set */ uint32_t bitstream_buf; /* current 32 bit working set */
int bitstream_bits; /* used bits in working set */ int bitstream_bits; /* used bits in working set */
const uint8_t * bitstream_ptr; /* buffer with stream data */ const uint8_t * bitstream_ptr; /* buffer with stream data */
uint8_t * dest[3]; uint8_t * dest[3];
...@@ -203,7 +203,7 @@ struct mpeg2dec_s ...@@ -203,7 +203,7 @@ struct mpeg2dec_s
mpeg2_picture_t new_picture; mpeg2_picture_t new_picture;
mpeg2_picture_t pictures[4]; mpeg2_picture_t pictures[4];
mpeg2_picture_t * picture; mpeg2_picture_t * picture;
/*const*/ mpeg2_fbuf_t * fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */ /*const*/ mpeg2_fbuf_t * fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
fbuf_alloc_t fbuf_alloc[3]; fbuf_alloc_t fbuf_alloc[3];
int custom_fbuf; int custom_fbuf;
...@@ -281,7 +281,7 @@ typedef struct { ...@@ -281,7 +281,7 @@ typedef struct {
mpeg2_mc_fct * avg [8]; mpeg2_mc_fct * avg [8];
} mpeg2_mc_t; } mpeg2_mc_t;
#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \ #define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
{MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \ {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \ MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
{MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \ {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
......
This diff is collapsed.
...@@ -105,7 +105,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture, ...@@ -105,7 +105,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture,
/* /*
* Check that first field went through OK. Otherwise, * Check that first field went through OK. Otherwise,
* indicate bad frame. * indicate bad frame.
*/ */
if (decoder->second_field) if (decoder->second_field)
{ {
mpeg2dec->xvmc_last_slice_code = (xxmc->decoded) ? 0 : -1; mpeg2dec->xvmc_last_slice_code = (xxmc->decoded) ? 0 : -1;
...@@ -238,7 +238,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture, ...@@ -238,7 +238,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture,
if (xxmc->result != 0) if (xxmc->result != 0)
{ {
//xxmc->proc_xxmc_flushsync( picture ); //xxmc->proc_xxmc_flushsync( picture );
xxmc->proc_xxmc_flush( picture ); xxmc->proc_xxmc_flush( picture );
mpeg2dec->xvmc_last_slice_code=-1; mpeg2dec->xvmc_last_slice_code=-1;
return; return;
} }
...@@ -276,7 +276,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture, ...@@ -276,7 +276,7 @@ void mpeg2_xxmc_slice( mpeg2dec_t *mpeg2dec, picture_t *picture,
} }
} }
void mpeg2_xxmc_vld_frame_complete(mpeg2dec_t *mpeg2dec, picture_t *picture, int code) void mpeg2_xxmc_vld_frame_complete(mpeg2dec_t *mpeg2dec, picture_t *picture, int code)
{ {
vlc_xxmc_t *xxmc = (vlc_xxmc_t *) picture->p_data; vlc_xxmc_t *xxmc = (vlc_xxmc_t *) picture->p_data;
vlc_vld_frame_t *vft = &xxmc->vld_frame; vlc_vld_frame_t *vft = &xxmc->vld_frame;
......
...@@ -21,35 +21,35 @@ ...@@ -21,35 +21,35 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define GETWORD(bit_buf,shift,bit_ptr) \ #define GETWORD(bit_buf,shift,bit_ptr) \
do { \ do { \
bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift); \ bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift); \
bit_ptr += 2; \ bit_ptr += 2; \
} while (0) } while (0)
static inline void bitstream_init (mpeg2_decoder_t * decoder, static inline void bitstream_init (mpeg2_decoder_t * decoder,
const uint8_t * start) const uint8_t * start)
{ {
decoder->bitstream_buf = decoder->bitstream_buf =
(start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3]; (start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3];
decoder->bitstream_ptr = start + 4; decoder->bitstream_ptr = start + 4;
decoder->bitstream_bits = -16; decoder->bitstream_bits = -16;
} }
/* make sure that there are at least 16 valid bits in bit_buf */ /* make sure that there are at least 16 valid bits in bit_buf */
#define NEEDBITS(bit_buf,bits,bit_ptr) \ #define NEEDBITS(bit_buf,bits,bit_ptr) \
do { \ do { \
if (unlikely (bits > 0)) { \ if (unlikely (bits > 0)) { \
GETWORD (bit_buf, bits, bit_ptr); \ GETWORD (bit_buf, bits, bit_ptr); \
bits -= 16; \ bits -= 16; \
} \ } \
} while (0) } while (0)
/* remove num valid bits from bit_buf */ /* remove num valid bits from bit_buf */
#define DUMPBITS(bit_buf,bits,num) \ #define DUMPBITS(bit_buf,bits,num) \
do { \ do { \
bit_buf <<= (num); \ bit_buf <<= (num); \
bits += (num); \ bits += (num); \
} while (0) } while (0)
/* take num bits from the high part of bit_buf and zero extend them */ /* take num bits from the high part of bit_buf and zero extend them */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* include/config.h.in. Generated from configure.in by autoheader. */ /* include/config.h.in. Generated from configure.in by autoheader. */
/* autodetect accelerations */ /* autodetect accelerations */
#define ACCEL_DETECT #define ACCEL_DETECT
/* alpha architecture */ /* alpha architecture */
/* #undef ARCH_ALPHA */ /* #undef ARCH_ALPHA */
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* #undef ARCH_SPARC */ /* #undef ARCH_SPARC */
/* x86 architecture */ /* x86 architecture */
#define ARCH_X86 #define ARCH_X86
/* maximum supported data alignment */ /* maximum supported data alignment */
#define ATTRIBUTE_ALIGNED_MAX 64 #define ATTRIBUTE_ALIGNED_MAX 64
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* #undef HAVE_ALTIVEC_H */ /* #undef HAVE_ALTIVEC_H */
/* Define if you have the `__builtin_expect' function. */ /* Define if you have the `__builtin_expect' function. */
#define HAVE_BUILTIN_EXPECT #define HAVE_BUILTIN_EXPECT
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1 #define HAVE_DLFCN_H 1
...@@ -86,10 +86,10 @@ ...@@ -86,10 +86,10 @@
/* #undef LIBVO_SDL */ /* #undef LIBVO_SDL */
/* libvo X11 support */ /* libvo X11 support */
#define LIBVO_X11 #define LIBVO_X11
/* libvo Xv support */ /* libvo Xv support */
#define LIBVO_XV #define LIBVO_XV
/* mpeg2dec profiling */ /* mpeg2dec profiling */
/* #undef MPEG2DEC_GPROF */ /* #undef MPEG2DEC_GPROF */
......
...@@ -110,7 +110,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -110,7 +110,7 @@ static int OpenDecoder( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = NULL; decoder_sys_t *p_sys = NULL;
uint32_t i_accel = 0; uint32_t i_accel = 0;
FILE *f_wd_dec; FILE *f_wd_dec;
msg_Dbg(p_dec, "OpenDecoder Entering"); msg_Dbg(p_dec, "OpenDecoder Entering");
mtrace(); mtrace();
...@@ -695,7 +695,7 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf ) ...@@ -695,7 +695,7 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf )
{ {
// fprintf(p_sys->f_wd_nb, "%d\n", mdate()); // fprintf(p_sys->f_wd_nb, "%d\n", mdate());
fprintf(p_sys->f_wd_nb, "%s\n", mdate()); fprintf(p_sys->f_wd_nb, "%s\n", mdate());
fflush(p_sys->f_wd_nb); fflush(p_sys->f_wd_nb);
} }
#endif #endif
p_pic = p_dec->pf_vout_buffer_new( p_dec ); p_pic = p_dec->pf_vout_buffer_new( p_dec );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment