/*
* Teletext support
* Copyright (C) 2007 Vladimir Voroshilov <voroshil@gmail.com>
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Based on Attila Otvos' teletext patch, Michael Niedermayer's
* proof-of-concept teletext capture utility and some parts
* (decode_raw_line_runin,pll_add,pll_reset) of MythTV project.
* Code for calculating [soc:eoc] is based on aletv of Edgar Toernig.
*
* Teletext system is described in
* ETS 300 706 "Enhanced Teletext specification" : May 1997
* http://www.themm.net/~mihu/linux/saa7146/specs/ets_300706e01p.pdf
*
* Some implementation details:
* How to port teletext to another tvi_* driver (see tvi_v4l2.c for example):
*
* 1. Implement TVI_CONTROL_VBI_INIT (initialize driver-related vbi subsystem,
* start grabbing thread)
* input data: vbi device name.
* (driver should also call TV_VBI_CONTROL_START for common vbi subsystem initialization
* with pointer to initialized tt_stream_properties structure.
* After ioctl call variable will contain pointer to initialized priv_vbi_t structure.
*
* 2. After receiving next chunk of raw vbi data call TV_VBI_CONTROL_DECODE_PAGE
* ioctl with pointer to data buffer
* 3. pass all other VBI related ioctl cmds to teletext_control routine
*
* Page displaying process consist of following stages:
*
* ---grabbing stage---
* 0. stream/tvi_*.c: vbi_grabber(...)
* getting vbi data from video device
* ---decoding stage---
* 1. stream/tvi_vbi.c: decode_raw_line_runin(...) or decode_raw_line_sine(...)
* decode raw vbi data into sliced 45(?) bytes long packets
* 2. stream/tvi_vbi.c: decode_pkt0(...), decode_pkt_page(...)
* packets processing (header analyzing, storing complete page in cache,
* only raw member of tt_char is filled at this stage)
* 3. stream/tvi_vbi.c: decode_page(...)
* page decoding. filling unicode,gfx,ctl,etc members of tt_char structure
* with appropriate values according to teletext control chars, converting
* text to utf8.
* ---rendering stage---
* 4. stream/tvi_vbi.c: prepare_visible_page(...)
* processing page. adding number of just received by background process
* teletext page, adding current time,etc.
* 5. libvo/sub.c: vo_update_text_teletext(...)
* rendering displayable osd with text and graphics
*
* TODO:
* v4lv1,bktr support
* spu rendering
* is better quality on poor signal possible ?
* link support
* font autoscale
* greyscale osd
* slave command for dumping pages
* fix bcd<->dec as suggested my Michael
*
* BUGS:
* wrong colors in debug dump
* blinking when visible page was just updated
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <pthread.h>
#include "tv.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "libmpcodecs/img_forma
|