summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorcehoyos <cehoyos@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-11-07 13:09:24 +0000
committercehoyos <cehoyos@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-11-07 13:09:24 +0000
commit241164f72c01b4e15e7afff36064a9217ebad77f (patch)
treedc1c456d5263e3fbb768ddd0eee0ec190ad43409 /libmpcodecs
parent419e4f684af2a885804f54f403b41d9761e1052f (diff)
downloadmpv-241164f72c01b4e15e7afff36064a9217ebad77f.tar.bz2
mpv-241164f72c01b4e15e7afff36064a9217ebad77f.tar.xz
Factorise vbi_decode().
Patch by Francesco Lavra, francescolavra interfree it git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29850 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/dec_teletext.c69
1 files changed, 39 insertions, 30 deletions
diff --git a/libmpcodecs/dec_teletext.c b/libmpcodecs/dec_teletext.c
index aa72dae72f..446f2ed0f6 100644
--- a/libmpcodecs/dec_teletext.c
+++ b/libmpcodecs/dec_teletext.c
@@ -1454,6 +1454,44 @@ static int decode_raw_line_sine(priv_vbi_t* priv,unsigned char* buf,unsigned cha
#endif
/**
+ * \brief decodes one vbi line from one video frame
+ * \param priv private data structure
+ * \param data buffer with raw vbi data in it
+ */
+static void vbi_decode_line(priv_vbi_t *priv, unsigned char *data) {
+ int d0,d1,magAddr,pkt;
+
+ d0= corrHamm48[ data[0] ];
+ d1= corrHamm48[ data[1] ];
+
+ if(d0&0x80 || d1&0x80){
+ pll_add(priv,2,4);
+ mp_msg(MSGT_TELETEXT,MSGL_V,"vbi_decode_line: HammErr\n");
+
+ return; //hamError
+ }
+ magAddr=d0 & 0x7;
+ pkt=(d0>>3)|(d1<<1);
+ mp_msg(MSGT_TELETEXT,MSGL_DBG3,"vbi_decode_line:%x %x (mag:%x, pkt:%d)\n",
+ d0,d1,magAddr,pkt);
+ if(!pkt){
+ decode_pkt0(priv,data+2,magAddr); //skip MRGA
+ }else if(pkt>0 && pkt<VBI_ROWS){
+ if(!priv->mag[magAddr].pt)
+ return;
+ decode_pkt_page(priv,data+2,magAddr,pkt);//skip MRGA
+ }else if(pkt==27) {
+ decode_pkt27(priv,data+2,magAddr);
+ }else if(pkt==28){
+ decode_pkt28(priv,data+2);
+ }else if(pkt==30){
+ decode_pkt30(priv,data+2,magAddr);
+ } else {
+ mp_msg(MSGT_TELETEXT,MSGL_DBG3,"unsupported packet:%d\n",pkt);
+ }
+}
+
+/**
* \brief decodes all vbi lines from one video frame
* \param priv private data structure
* \param buf buffer with raw vbi data in it
@@ -1461,11 +1499,8 @@ static int decode_raw_line_sine(priv_vbi_t* priv,unsigned char* buf,unsigned cha
* \note buffer size have to be at least priv->ptsp->bufsize bytes
*/
static void vbi_decode(priv_vbi_t* priv,unsigned char*buf){
- int magAddr;
- int pkt;
unsigned char data[64];
unsigned char* linep;
- int d0,d1;
int i=0;
mp_msg(MSGT_TELETEXT,MSGL_DBG3,"vbi: vbi_decode\n");
for(linep=buf; !priv->cache_reset && linep<buf+priv->ptsp->bufsize; linep+=priv->ptsp->samples_per_line,i++){
@@ -1480,33 +1515,7 @@ static void vbi_decode(priv_vbi_t* priv,unsigned char*buf){
if(decode_raw_line_runin(priv,linep,data)<=0){
continue; //this is not valid teletext line
}
- d0= corrHamm48[ data[0] ];
- d1= corrHamm48[ data[1] ];
-
- if(d0&0x80 || d1&0x80){
- pll_add(priv,2,4);
- mp_msg(MSGT_TELETEXT,MSGL_V,"vbi_decode(%d):HammErr after decode_raw_line\n",i);
-
- continue; //hamError
- }
- magAddr=d0 & 0x7;
- pkt=(d0>>3)|(d1<<1);
- mp_msg(MSGT_TELETEXT,MSGL_DBG3,"vbi_decode(%d):%x %x (mag:%x, pkt:%d)\n",
- i,d0,d1,magAddr,pkt);
- if(!pkt){
- decode_pkt0(priv,data+2,magAddr); //skip MRGA
- }else if(pkt>0 && pkt<VBI_ROWS){
- if(!priv->mag[magAddr].pt) continue;
- decode_pkt_page(priv,data+2,magAddr,pkt);//skip MRGA
- }else if(pkt==27) {
- decode_pkt27(priv,data+2,magAddr);
- }else if(pkt==28){
- decode_pkt28(priv,data+2);
- }else if(pkt==30){
- decode_pkt30(priv,data+2,magAddr);
- } else {
- mp_msg(MSGT_TELETEXT,MSGL_DBG3,"unsupported packet:%d\n",pkt);
- }
+ vbi_decode_line(priv, data);
}
if (priv->cache_reset){
pthread_mutex_lock(&(priv->buffer_mutex));