Mercurial > mplayer.hg
view osdep/getch2-win.c @ 27518:e54c9b7eb0d8
Revert bad changes to SSA/ASS subtitle packet format
The following commits are reverted partially or completely:
"a valid ASS line contains 9 ',' before actual text"
"demux_mkv: output correctly formated ASS packets"
"libass: add a new ass_process_data() to process demuxed subtitle packets"
These commits converted the internal representation of SSA/ASS
subtitle packets from the format used by Matroska to a custom format
where each packet has contents exactly matching one line in complete
SSA script files. AFAIK no files natively use such a format for muxed
subtitles. The stated reason for this change was to use a format that
could in principle be muxed into a maximal number of containers. SSA
subtitles do not have an implicit duration so both start time and
duration or end time need to be specified explicitly; the new format
moved timing information inside the codec packet data so it could be
muxed without modification into containers that can represent only
start time at the container level. However such a change is wrong from
the viewpoint of program architecture. Timing information belongs to
the demuxer level, but these commits moved not only the duration but
also the authoritative value of the start time to inside the codec
data. Additionally the new format lost the value of the Matroska
ReadOrder field which is used by MPlayer.
This commit changes the internal packet format back to that used by
Matroska and makes the internal Matroska demuxer output that format
again. Libavformat still outputs the "new" format; it could be
converted back to the Matroska format in demux_lavf.c, but I'm not
adding that code at least yet. The current lavf code has similar
problems as the reverted code in MPlayer, and it also currently fails
to provide any way to access the value of the ReadOrder field. I hope
that the lavf side will be improved; if it isn't conversion can be
added later. For now I'll make MPlayer default to the internal Matroska
demuxer instead of the lavf one in a separate commit.
author | uau |
---|---|
date | Mon, 08 Sep 2008 21:26:22 +0000 |
parents | 4876c89bafdd |
children | 8df85ad26746 |
line wrap: on
line source
/* windows TermIO for MPlayer (C) 2003 Sascha Sommer */ // See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp // for additional virtual keycodes #include "config.h" #include <stdio.h> #include <windows.h> #include "keycodes.h" #include "input/input.h" #include "mp_fifo.h" // HACK, stdin is used as something else below #undef stdin int mp_input_slave_cmd_func(int fd,char* dest,int size){ DWORD retval; HANDLE stdin = GetStdHandle(STD_INPUT_HANDLE); if(!PeekNamedPipe(stdin, NULL, size, &retval, NULL, NULL) || !retval){ return MP_INPUT_NOTHING; } if(retval>size)retval=size; ReadFile(stdin, dest, retval, &retval, NULL); if(retval)return retval; return MP_INPUT_NOTHING; } int screen_width=80; int screen_height=24; char * erase_to_end_of_line = NULL; void get_screen_size(){ } static HANDLE stdin; static int getch2_status=0; static int getch2_internal(void) { INPUT_RECORD eventbuffer[128]; DWORD retval; int i=0; if(!getch2_status)return -1; /*check if there are input events*/ if(!GetNumberOfConsoleInputEvents(stdin,&retval)) { printf("getch2: can't get number of input events: %i\n",GetLastError()); return -1; } if(retval<=0)return -1; /*read all events*/ if(!ReadConsoleInput(stdin,eventbuffer,128,&retval)) { printf("getch: can't read input events\n"); return -1; } /*filter out keyevents*/ for (i = 0; i < retval; i++) { switch(eventbuffer[i].EventType) { case KEY_EVENT: /*only a pressed key is interresting for us*/ if(eventbuffer[i].Event.KeyEvent.bKeyDown == TRUE) { /*check for special keys*/ switch(eventbuffer[i].Event.KeyEvent.wVirtualKeyCode) { case VK_HOME: return KEY_HOME; case VK_END: return KEY_END; case VK_DELETE: return KEY_DEL; case VK_INSERT: return KEY_INS; case VK_BACK: return KEY_BS; case VK_PRIOR: return KEY_PGUP; case VK_NEXT: return KEY_PGDWN; case VK_RETURN: return KEY_ENTER; case VK_ESCAPE: return KEY_ESC; case VK_LEFT: return KEY_LEFT; case VK_UP: return KEY_UP; case VK_RIGHT: return KEY_RIGHT; case VK_DOWN: return KEY_DOWN; case VK_SHIFT: continue; } /*check for function keys*/ if(0x87 >= eventbuffer[i].Event.KeyEvent.wVirtualKeyCode && eventbuffer[i].Event.KeyEvent.wVirtualKeyCode >= 0x70) return KEY_F + 1 + eventbuffer[i].Event.KeyEvent.wVirtualKeyCode - 0x70; /*only characters should be remaining*/ //printf("getch2: YOU PRESSED \"%c\" \n",eventbuffer[i].Event.KeyEvent.uChar.AsciiChar); return eventbuffer[i].Event.KeyEvent.uChar.AsciiChar; } break; case MOUSE_EVENT: case WINDOW_BUFFER_SIZE_EVENT: case FOCUS_EVENT: case MENU_EVENT: default: //printf("getch2: unsupported event type"); break; } } return -1; } void getch2(void) { int r = getch2_internal(); if (r >= 0) mplayer_put_key(r); } void getch2_enable(){ DWORD retval; stdin = GetStdHandle(STD_INPUT_HANDLE); if(!GetNumberOfConsoleInputEvents(stdin,&retval)) { printf("getch2: %i can't get number of input events [disabling console input]\n",GetLastError()); getch2_status = 0; } else getch2_status=1; } void getch2_disable(){ if(!getch2_status) return; // already disabled / never enabled getch2_status=0; } #ifdef CONFIG_ICONV static const struct { unsigned cp; char* alias; } cp_alias[] = { { 20127, "ASCII" }, { 20866, "KOI8-R" }, { 21866, "KOI8-RU" }, { 28591, "ISO-8859-1" }, { 28592, "ISO-8859-2" }, { 28593, "ISO-8859-3" }, { 28594, "ISO-8859-4" }, { 28595, "ISO-8859-5" }, { 28596, "ISO-8859-6" }, { 28597, "ISO-8859-7" }, { 28598, "ISO-8859-8" }, { 28599, "ISO-8859-9" }, { 28605, "ISO-8859-15" }, { 65001, "UTF-8" }, { 0, NULL } }; char* get_term_charset(void) { static char codepage[10]; unsigned i, cpno = GetConsoleOutputCP(); if (!cpno) cpno = GetACP(); if (!cpno) return NULL; for (i = 0; cp_alias[i].cp; i++) if (cpno == cp_alias[i].cp) return cp_alias[i].alias; snprintf(codepage, sizeof(codepage), "CP%u", cpno); return codepage; } #endif