From 241164f72c01b4e15e7afff36064a9217ebad77f Mon Sep 17 00:00:00 2001 From: cehoyos Date: Sat, 7 Nov 2009 13:09:24 +0000 Subject: 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 --- libmpcodecs/dec_teletext.c | 69 ++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'libmpcodecs/dec_teletext.c') 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 @@ -1453,6 +1453,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 && pktmag[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 @@ -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 && linepptsp->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 && pktmag[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)); -- cgit v1.2.3