summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2002-10-21 15:43:19 +0000
committerHolger Waechtler <devnull@localhost>2002-10-21 15:43:19 +0000
commit95b4bd29c909c908e087f2dc634016c68e96e74c (patch)
tree145ff70c7ae64addefa24d14b0d3d0b5b98d458f /linux/drivers/media/dvb
parent1096a80245bcce87cbd7719b0188d30bd9b8c00a (diff)
downloadmediapointer-dvb-s2-95b4bd29c909c908e087f2dc634016c68e96e74c.tar.gz
mediapointer-dvb-s2-95b4bd29c909c908e087f2dc634016c68e96e74c.tar.bz2
#if 0'ed unused code
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_filter.c912
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_filter.h6
2 files changed, 473 insertions, 445 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_filter.c b/linux/drivers/media/dvb/dvb-core/dvb_filter.c
index c52d1462f..c25b91b08 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_filter.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_filter.c
@@ -24,443 +24,7 @@ uint32_t ac3_frames[3][32] =
-void dvb_filter_pes2ts_init(dvb_filter_pes2ts_t *p2ts, unsigned short pid,
- dvb_filter_pes2ts_cb_t *cb, void *priv)
-{
- unsigned char *buf=p2ts->buf;
-
- buf[0]=0x47;
- buf[1]=(pid>>8);
- buf[2]=pid&0xff;
- p2ts->cc=0;
- p2ts->cb=cb;
- p2ts->priv=priv;
-}
-
-int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len)
-{
- unsigned char *buf=p2ts->buf;
- int ret=0, rest;
-
- //len=6+((pes[4]<<8)|pes[5]);
-
- buf[1]|=0x40;
- while (len>=184) {
- buf[3]=0x10|((p2ts->cc++)&0x0f);
- memcpy(buf+4, pes, 184);
- if ((ret=p2ts->cb(p2ts->priv, buf)))
- return ret;
- len-=184; pes+=184;
- buf[1]&=~0x40;
- }
- if (!len)
- return 0;
- buf[3]=0x30|((p2ts->cc++)&0x0f);
- rest=183-len;
- if (rest) {
- buf[5]=0x00;
- if (rest-1)
- memset(buf+6, 0xff, rest-1);
- }
- buf[4]=rest;
- memcpy(buf+5+rest, pes, len);
- return p2ts->cb(p2ts->priv, buf);
-}
-
-void dvb_filter_ipack_reset(ipack *p)
-{
- p->found = 0;
- p->cid = 0;
- p->plength = 0;
- p->flag1 = 0;
- p->flag2 = 0;
- p->hlength = 0;
- p->mpeg = 0;
- p->check = 0;
- p->which = 0;
- p->done = 0;
- p->count = 0;
-}
-
-void dvb_filter_ipack_init(ipack *p, int size,
- void (*func)(u8 *buf, int size, void *priv))
-{
- if ( !(p->buf = vmalloc(size*sizeof(u8))) ){
- printk ("Couldn't allocate memory for ipack\n");
- }
- p->size = size;
- p->func = func;
- p->repack_subids = 0;
- dvb_filter_ipack_reset(p);
-}
-
-void dvb_filter_ipack_free(ipack * p)
-{
- if (p->buf) vfree(p->buf);
-}
-
-static
-void send_ipack(ipack *p)
-{
- int off;
- AudioInfo ai;
- int ac3_off = 0;
- int streamid=0;
- int nframes= 0;
- int f=0;
-
- switch ( p->mpeg ){
- case 2:
- if (p->count < 10) return;
- p->buf[3] = p->cid;
-
- p->buf[4] = (u8)(((p->count-6) & 0xFF00) >> 8);
- p->buf[5] = (u8)((p->count-6) & 0x00FF);
- if (p->repack_subids && p->cid == PRIVATE_STREAM1){
-
- off = 9+p->buf[8];
- streamid = p->buf[off];
- if ((streamid & 0xF8) == 0x80){
- ai.off = 0;
- ac3_off = ((p->buf[off+2] << 8)|
- p->buf[off+3]);
- if (ac3_off < p->count)
- f=get_ac3info(p->buf+off+3+ac3_off,
- p->count-ac3_off, &ai,0);
- if ( !f ){
- nframes = (p->count-off-3-ac3_off)/
- ai.framesize + 1;
- p->buf[off+2] = (ac3_off >> 8)& 0xFF;
- p->buf[off+3] = (ac3_off)& 0xFF;
- p->buf[off+1] = nframes;
-
- ac3_off += nframes * ai.framesize -
- p->count;
- }
- }
- }
- p->func(p->buf, p->count, p->data);
-
- p->buf[6] = 0x80;
- p->buf[7] = 0x00;
- p->buf[8] = 0x00;
- p->count = 9;
- if (p->repack_subids && p->cid == PRIVATE_STREAM1
- && (streamid & 0xF8)==0x80 ){
- p->count += 4;
- p->buf[9] = streamid;
- p->buf[10] = (ac3_off >> 8)& 0xFF;
- p->buf[11] = (ac3_off)& 0xFF;
- p->buf[12] = 0;
- }
-
- break;
- case 1:
- if (p->count < 8) return;
- p->buf[3] = p->cid;
-
- p->buf[4] = (u8)(((p->count-6) & 0xFF00) >> 8);
- p->buf[5] = (u8)((p->count-6) & 0x00FF);
- p->func(p->buf, p->count, p->data);
-
- p->buf[6] = 0x0F;
- p->count = 7;
- break;
- }
-}
-
-void dvb_filter_ipack_flush(ipack *p)
-{
- if (p->plength != MMAX_PLENGTH-6 || p->found<=6)
- return;
- p->plength = p->found-6;
- p->found = 0;
- send_ipack(p);
- dvb_filter_ipack_reset(p);
-}
-
-static
-void write_ipack(ipack *p, u8 *data, int count)
-{
- u8 headr[3] = { 0x00, 0x00, 0x01} ;
-
- if (p->count < 6){
- memcpy(p->buf, headr, 3);
- p->count = 6;
- }
-
- if (p->count + count < p->size){
- memcpy(p->buf+p->count, data, count);
- p->count += count;
- } else {
- int rest = p->size - p->count;
- memcpy(p->buf+p->count, data, rest);
- p->count += rest;
- send_ipack(p);
- if (count - rest > 0)
- write_ipack(p, data+rest, count-rest);
- }
-}
-
-int dvb_filter_instant_repack(u8 *buf, int count, ipack *p)
-{
- int l;
- int c=0;
-
- while (c < count && (p->mpeg == 0 ||
- (p->mpeg == 1 && p->found < 7) ||
- (p->mpeg == 2 && p->found < 9))
- && (p->found < 5 || !p->done)){
- switch ( p->found ){
- case 0:
- case 1:
- if (buf[c] == 0x00) p->found++;
- else p->found = 0;
- c++;
- break;
- case 2:
- if (buf[c] == 0x01) p->found++;
- else if (buf[c] == 0) {
- p->found = 2;
- } else p->found = 0;
- c++;
- break;
- case 3:
- p->cid = 0;
- switch (buf[c]){
- case PROG_STREAM_MAP:
- case PRIVATE_STREAM2:
- case PROG_STREAM_DIR:
- case ECM_STREAM :
- case EMM_STREAM :
- case PADDING_STREAM :
- case DSM_CC_STREAM :
- case ISO13522_STREAM:
- p->done = 1;
- case PRIVATE_STREAM1:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- p->found++;
- p->cid = buf[c];
- c++;
- break;
- default:
- p->found = 0;
- break;
- }
- break;
-
- case 4:
- if (count-c > 1){
- p->plen[0] = buf[c];
- c++;
- p->plen[1] = buf[c];
- c++;
- p->found+=2;
- p->plength=(p->plen[0]<<8)|p->plen[1];
- } else {
- p->plen[0] = buf[c];
- p->found++;
- return count;
- }
- break;
- case 5:
- p->plen[1] = buf[c];
- c++;
- p->found++;
- p->plength=(p->plen[0]<<8)|p->plen[1];
- break;
- case 6:
- if (!p->done){
- p->flag1 = buf[c];
- c++;
- p->found++;
- if ( (p->flag1 & 0xC0) == 0x80 ) p->mpeg = 2;
- else {
- p->hlength = 0;
- p->which = 0;
- p->mpeg = 1;
- p->flag2 = 0;
- }
- }
- break;
-
- case 7:
- if ( !p->done && p->mpeg == 2) {
- p->flag2 = buf[c];
- c++;
- p->found++;
- }
- break;
-
- case 8:
- if ( !p->done && p->mpeg == 2) {
- p->hlength = buf[c];
- c++;
- p->found++;
- }
- break;
-
- default:
-
- break;
- }
- }
-
- if (c == count) return count;
-
- if (!p->plength) p->plength = MMAX_PLENGTH-6;
-
- if ( p->done || ((p->mpeg == 2 && p->found >= 9) ||
- (p->mpeg == 1 && p->found >= 7)) ){
- switch (p->cid){
-
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- case PRIVATE_STREAM1:
-
- if (p->mpeg == 2 && p->found == 9) {
- write_ipack(p, &p->flag1, 1);
- write_ipack(p, &p->flag2, 1);
- write_ipack(p, &p->hlength, 1);
- }
-
- if (p->mpeg == 1 && p->found == 7)
- write_ipack(p, &p->flag1, 1);
-
- if (p->mpeg == 2 && (p->flag2 & PTS_ONLY) &&
- p->found < 14) {
- while (c < count && p->found < 14) {
- p->pts[p->found-9] = buf[c];
- write_ipack(p, buf+c, 1);
- c++;
- p->found++;
- }
- if (c == count) return count;
- }
-
- if (p->mpeg == 1 && p->which < 2000) {
-
- if (p->found == 7) {
- p->check = p->flag1;
- p->hlength = 1;
- }
-
- while (!p->which && c < count &&
- p->check == 0xFF){
- p->check = buf[c];
- write_ipack(p, buf+c, 1);
- c++;
- p->found++;
- p->hlength++;
- }
-
- if ( c == count) return count;
-
- if ( (p->check & 0xC0) == 0x40 && !p->which){
- p->check = buf[c];
- write_ipack(p, buf+c, 1);
- c++;
- p->found++;
- p->hlength++;
-
- p->which = 1;
- if ( c == count) return count;
- p->check = buf[c];
- write_ipack(p, buf+c, 1);
- c++;
- p->found++;
- p->hlength++;
- p->which = 2;
- if ( c == count) return count;
- }
-
- if (p->which == 1){
- p->check = buf[c];
- write_ipack(p, buf+c, 1);
- c++;
- p->found++;
- p->hlength++;
- p->which = 2;
- if ( c == count) return count;
- }
-
- if ( (p->check & 0x30) && p->check != 0xFF){
- p->flag2 = (p->check & 0xF0) << 2;
- p->pts[0] = p->check;
- p->which = 3;
- }
-
- if ( c == count) return count;
- if (p->which > 2){
- if ((p->flag2 & PTS_DTS_FLAGS)
- == PTS_ONLY){
- while (c < count &&
- p->which < 7){
- p->pts[p->which-2] =
- buf[c];
- write_ipack(p,buf+c,1);
- c++;
- p->found++;
- p->which++;
- p->hlength++;
- }
- if ( c == count) return count;
- } else if ((p->flag2 & PTS_DTS_FLAGS)
- == PTS_DTS){
- while (c < count &&
- p->which< 12){
- if (p->which< 7)
- p->pts[p->which
- -2] =
- buf[c];
- write_ipack(p,buf+c,1);
- c++;
- p->found++;
- p->which++;
- p->hlength++;
- }
- if ( c == count) return count;
- }
- p->which = 2000;
- }
-
- }
-
- while (c < count && p->found < p->plength+6){
- l = count -c;
- if (l+p->found > p->plength+6)
- l = p->plength+6-p->found;
- write_ipack(p, buf+c, l);
- p->found += l;
- c += l;
- }
-
- break;
- }
-
-
- if ( p->done ){
- if( p->found + count - c < p->plength+6){
- p->found += count-c;
- c = count;
- } else {
- c += p->plength+6 - p->found;
- p->found = p->plength+6;
- }
- }
-
- if (p->plength && p->found == p->plength+6) {
- send_ipack(p);
- dvb_filter_ipack_reset(p);
- if (c < count)
- dvb_filter_instant_repack(buf+c, count-c, p);
- }
- }
- return count;
-}
-
-
+#if 0
static
void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
void (*pes_write)(u8 *buf, int count, void *data),
@@ -473,7 +37,9 @@ void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
pa->data = priv;
pv->data = priv;
}
+#endif
+#if 0
static
void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
{
@@ -497,7 +63,9 @@ void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
}
dvb_filter_instant_repack(buf+4+off, TS_SIZE-4-off, p);
}
+#endif
+#if 0
/* needs 5 byte input, returns picture coding type*/
static
int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr)
@@ -542,8 +110,9 @@ int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr)
return pct;
}
+#endif
-
+#if 0
/* needs 4 byte input */
static
int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr)
@@ -573,7 +142,9 @@ int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr)
return 0;
}
+#endif
+#if 0
/* needs 8 byte input */
static
int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr)
@@ -686,7 +257,10 @@ int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr)
return 0;
}
+#endif
+
+#if 0
static
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr)
{
@@ -713,7 +287,10 @@ int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr)
vi->off = c-4;
return 0;
}
+#endif
+
+#if 0
static
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
{
@@ -767,6 +344,7 @@ int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
ai->off = c;
return 0;
}
+#endif
static
int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
@@ -819,6 +397,7 @@ int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
}
+#if 0
static
uint8_t *skip_pes_header(uint8_t **bufp)
{
@@ -827,10 +406,10 @@ uint8_t *skip_pes_header(uint8_t **bufp)
uint8_t *pts = NULL;
int skip = 0;
-static const int mpeg1_skip_table[16] = {
- 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
-};
+ static const int mpeg1_skip_table[16] = {
+ 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
+ 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
+ };
if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */
@@ -855,8 +434,9 @@ static const int mpeg1_skip_table[16] = {
*bufp = buf;
return pts;
}
+#endif
-
+#if 0
static
void initialize_quant_matrix( uint32_t *matrix )
{
@@ -882,7 +462,9 @@ void initialize_quant_matrix( uint32_t *matrix )
for ( i = 16 ; i < 32 ; i++ )
matrix[i] = 0x10101010;
}
+#endif
+#if 0
static
void initialize_mpg_picture(mpg_picture *pic)
{
@@ -908,8 +490,9 @@ void initialize_mpg_picture(mpg_picture *pic)
pic->gop_flag = 0;
pic->sequence_end_flag = 0;
}
+#endif
-
+#if 0
static
void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic )
{
@@ -946,7 +529,9 @@ void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic )
pic->frame_centre_vertical_offset[3] = last_v_offset;
}
}
+#endif
+#if 0
static
void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type)
{
@@ -975,3 +560,442 @@ void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type)
pic->last_frame_centre_vertical_offset = 0;
pic->channel = chan;
}
+#endif
+
+void dvb_filter_pes2ts_init(dvb_filter_pes2ts_t *p2ts, unsigned short pid,
+ dvb_filter_pes2ts_cb_t *cb, void *priv)
+{
+ unsigned char *buf=p2ts->buf;
+
+ buf[0]=0x47;
+ buf[1]=(pid>>8);
+ buf[2]=pid&0xff;
+ p2ts->cc=0;
+ p2ts->cb=cb;
+ p2ts->priv=priv;
+}
+
+int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len)
+{
+ unsigned char *buf=p2ts->buf;
+ int ret=0, rest;
+
+ //len=6+((pes[4]<<8)|pes[5]);
+
+ buf[1]|=0x40;
+ while (len>=184) {
+ buf[3]=0x10|((p2ts->cc++)&0x0f);
+ memcpy(buf+4, pes, 184);
+ if ((ret=p2ts->cb(p2ts->priv, buf)))
+ return ret;
+ len-=184; pes+=184;
+ buf[1]&=~0x40;
+ }
+ if (!len)
+ return 0;
+ buf[3]=0x30|((p2ts->cc++)&0x0f);
+ rest=183-len;
+ if (rest) {
+ buf[5]=0x00;
+ if (rest-1)
+ memset(buf+6, 0xff, rest-1);
+ }
+ buf[4]=rest;
+ memcpy(buf+5+rest, pes, len);
+ return p2ts->cb(p2ts->priv, buf);
+}
+
+void dvb_filter_ipack_reset(ipack *p)
+{
+ p->found = 0;
+ p->cid = 0;
+ p->plength = 0;
+ p->flag1 = 0;
+ p->flag2 = 0;
+ p->hlength = 0;
+ p->mpeg = 0;
+ p->check = 0;
+ p->which = 0;
+ p->done = 0;
+ p->count = 0;
+}
+
+void dvb_filter_ipack_init(ipack *p, int size,
+ void (*func)(u8 *buf, int size, void *priv))
+{
+ if ( !(p->buf = vmalloc(size*sizeof(u8))) ){
+ printk ("Couldn't allocate memory for ipack\n");
+ }
+ p->size = size;
+ p->func = func;
+ p->repack_subids = 0;
+ dvb_filter_ipack_reset(p);
+}
+
+void dvb_filter_ipack_free(ipack * p)
+{
+ if (p->buf) vfree(p->buf);
+}
+
+static
+void send_ipack(ipack *p)
+{
+ int off;
+ AudioInfo ai;
+ int ac3_off = 0;
+ int streamid=0;
+ int nframes= 0;
+ int f=0;
+
+ switch ( p->mpeg ){
+ case 2:
+ if (p->count < 10) return;
+ p->buf[3] = p->cid;
+
+ p->buf[4] = (u8)(((p->count-6) & 0xFF00) >> 8);
+ p->buf[5] = (u8)((p->count-6) & 0x00FF);
+ if (p->repack_subids && p->cid == PRIVATE_STREAM1){
+
+ off = 9+p->buf[8];
+ streamid = p->buf[off];
+ if ((streamid & 0xF8) == 0x80){
+ ai.off = 0;
+ ac3_off = ((p->buf[off+2] << 8)|
+ p->buf[off+3]);
+ if (ac3_off < p->count)
+ f=get_ac3info(p->buf+off+3+ac3_off,
+ p->count-ac3_off, &ai,0);
+ if ( !f ){
+ nframes = (p->count-off-3-ac3_off)/
+ ai.framesize + 1;
+ p->buf[off+2] = (ac3_off >> 8)& 0xFF;
+ p->buf[off+3] = (ac3_off)& 0xFF;
+ p->buf[off+1] = nframes;
+
+ ac3_off += nframes * ai.framesize -
+ p->count;
+ }
+ }
+ }
+ p->func(p->buf, p->count, p->data);
+
+ p->buf[6] = 0x80;
+ p->buf[7] = 0x00;
+ p->buf[8] = 0x00;
+ p->count = 9;
+ if (p->repack_subids && p->cid == PRIVATE_STREAM1
+ && (streamid & 0xF8)==0x80 ){
+ p->count += 4;
+ p->buf[9] = streamid;
+ p->buf[10] = (ac3_off >> 8)& 0xFF;
+ p->buf[11] = (ac3_off)& 0xFF;
+ p->buf[12] = 0;
+ }
+
+ break;
+ case 1:
+ if (p->count < 8) return;
+ p->buf[3] = p->cid;
+
+ p->buf[4] = (u8)(((p->count-6) & 0xFF00) >> 8);
+ p->buf[5] = (u8)((p->count-6) & 0x00FF);
+ p->func(p->buf, p->count, p->data);
+
+ p->buf[6] = 0x0F;
+ p->count = 7;
+ break;
+ }
+}
+
+void dvb_filter_ipack_flush(ipack *p)
+{
+ if (p->plength != MMAX_PLENGTH-6 || p->found<=6)
+ return;
+ p->plength = p->found-6;
+ p->found = 0;
+ send_ipack(p);
+ dvb_filter_ipack_reset(p);
+}
+
+static
+void write_ipack(ipack *p, u8 *data, int count)
+{
+ u8 headr[3] = { 0x00, 0x00, 0x01} ;
+
+ if (p->count < 6){
+ memcpy(p->buf, headr, 3);
+ p->count = 6;
+ }
+
+ if (p->count + count < p->size){
+ memcpy(p->buf+p->count, data, count);
+ p->count += count;
+ } else {
+ int rest = p->size - p->count;
+ memcpy(p->buf+p->count, data, rest);
+ p->count += rest;
+ send_ipack(p);
+ if (count - rest > 0)
+ write_ipack(p, data+rest, count-rest);
+ }
+}
+
+
+int dvb_filter_instant_repack(u8 *buf, int count, ipack *p)
+{
+ int l;
+ int c=0;
+
+ while (c < count && (p->mpeg == 0 ||
+ (p->mpeg == 1 && p->found < 7) ||
+ (p->mpeg == 2 && p->found < 9))
+ && (p->found < 5 || !p->done)){
+ switch ( p->found ){
+ case 0:
+ case 1:
+ if (buf[c] == 0x00) p->found++;
+ else p->found = 0;
+ c++;
+ break;
+ case 2:
+ if (buf[c] == 0x01) p->found++;
+ else if (buf[c] == 0) {
+ p->found = 2;
+ } else p->found = 0;
+ c++;
+ break;
+ case 3:
+ p->cid = 0;
+ switch (buf[c]){
+ case PROG_STREAM_MAP:
+ case PRIVATE_STREAM2:
+ case PROG_STREAM_DIR:
+ case ECM_STREAM :
+ case EMM_STREAM :
+ case PADDING_STREAM :
+ case DSM_CC_STREAM :
+ case ISO13522_STREAM:
+ p->done = 1;
+ case PRIVATE_STREAM1:
+ case VIDEO_STREAM_S ... VIDEO_STREAM_E:
+ case AUDIO_STREAM_S ... AUDIO_STREAM_E:
+ p->found++;
+ p->cid = buf[c];
+ c++;
+ break;
+ default:
+ p->found = 0;
+ break;
+ }
+ break;
+
+ case 4:
+ if (count-c > 1){
+ p->plen[0] = buf[c];
+ c++;
+ p->plen[1] = buf[c];
+ c++;
+ p->found+=2;
+ p->plength=(p->plen[0]<<8)|p->plen[1];
+ } else {
+ p->plen[0] = buf[c];
+ p->found++;
+ return count;
+ }
+ break;
+ case 5:
+ p->plen[1] = buf[c];
+ c++;
+ p->found++;
+ p->plength=(p->plen[0]<<8)|p->plen[1];
+ break;
+ case 6:
+ if (!p->done){
+ p->flag1 = buf[c];
+ c++;
+ p->found++;
+ if ( (p->flag1 & 0xC0) == 0x80 ) p->mpeg = 2;
+ else {
+ p->hlength = 0;
+ p->which = 0;
+ p->mpeg = 1;
+ p->flag2 = 0;
+ }
+ }
+ break;
+
+ case 7:
+ if ( !p->done && p->mpeg == 2) {
+ p->flag2 = buf[c];
+ c++;
+ p->found++;
+ }
+ break;
+
+ case 8:
+ if ( !p->done && p->mpeg == 2) {
+ p->hlength = buf[c];
+ c++;
+ p->found++;
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+
+ if (c == count) return count;
+
+ if (!p->plength) p->plength = MMAX_PLENGTH-6;
+
+ if ( p->done || ((p->mpeg == 2 && p->found >= 9) ||
+ (p->mpeg == 1 && p->found >= 7)) ){
+ switch (p->cid){
+
+ case AUDIO_STREAM_S ... AUDIO_STREAM_E:
+ case VIDEO_STREAM_S ... VIDEO_STREAM_E:
+ case PRIVATE_STREAM1:
+
+ if (p->mpeg == 2 && p->found == 9) {
+ write_ipack(p, &p->flag1, 1);
+ write_ipack(p, &p->flag2, 1);
+ write_ipack(p, &p->hlength, 1);
+ }
+
+ if (p->mpeg == 1 && p->found == 7)
+ write_ipack(p, &p->flag1, 1);
+
+ if (p->mpeg == 2 && (p->flag2 & PTS_ONLY) &&
+ p->found < 14) {
+ while (c < count && p->found < 14) {
+ p->pts[p->found-9] = buf[c];
+ write_ipack(p, buf+c, 1);
+ c++;
+ p->found++;
+ }
+ if (c == count) return count;
+ }
+
+ if (p->mpeg == 1 && p->which < 2000) {
+
+ if (p->found == 7) {
+ p->check = p->flag1;
+ p->hlength = 1;
+ }
+
+ while (!p->which && c < count &&
+ p->check == 0xFF){
+ p->check = buf[c];
+ write_ipack(p, buf+c, 1);
+ c++;
+ p->found++;
+ p->hlength++;
+ }
+
+ if ( c == count) return count;
+
+ if ( (p->check & 0xC0) == 0x40 && !p->which){
+ p->check = buf[c];
+ write_ipack(p, buf+c, 1);
+ c++;
+ p->found++;
+ p->hlength++;
+
+ p->which = 1;
+ if ( c == count) return count;
+ p->check = buf[c];
+ write_ipack(p, buf+c, 1);
+ c++;
+ p->found++;
+ p->hlength++;
+ p->which = 2;
+ if ( c == count) return count;
+ }
+
+ if (p->which == 1){
+ p->check = buf[c];
+ write_ipack(p, buf+c, 1);
+ c++;
+ p->found++;
+ p->hlength++;
+ p->which = 2;
+ if ( c == count) return count;
+ }
+
+ if ( (p->check & 0x30) && p->check != 0xFF){
+ p->flag2 = (p->check & 0xF0) << 2;
+ p->pts[0] = p->check;
+ p->which = 3;
+ }
+
+ if ( c == count) return count;
+ if (p->which > 2){
+ if ((p->flag2 & PTS_DTS_FLAGS)
+ == PTS_ONLY){
+ while (c < count &&
+ p->which < 7){
+ p->pts[p->which-2] =
+ buf[c];
+ write_ipack(p,buf+c,1);
+ c++;
+ p->found++;
+ p->which++;
+ p->hlength++;
+ }
+ if ( c == count) return count;
+ } else if ((p->flag2 & PTS_DTS_FLAGS)
+ == PTS_DTS){
+ while (c < count &&
+ p->which< 12){
+ if (p->which< 7)
+ p->pts[p->which
+ -2] =
+ buf[c];
+ write_ipack(p,buf+c,1);
+ c++;
+ p->found++;
+ p->which++;
+ p->hlength++;
+ }
+ if ( c == count) return count;
+ }
+ p->which = 2000;
+ }
+
+ }
+
+ while (c < count && p->found < p->plength+6){
+ l = count -c;
+ if (l+p->found > p->plength+6)
+ l = p->plength+6-p->found;
+ write_ipack(p, buf+c, l);
+ p->found += l;
+ c += l;
+ }
+
+ break;
+ }
+
+
+ if ( p->done ){
+ if( p->found + count - c < p->plength+6){
+ p->found += count-c;
+ c = count;
+ } else {
+ c += p->plength+6 - p->found;
+ p->found = p->plength+6;
+ }
+ }
+
+ if (p->plength && p->found == p->plength+6) {
+ send_ipack(p);
+ dvb_filter_ipack_reset(p);
+ if (c < count)
+ dvb_filter_instant_repack(buf+c, count-c, p);
+ }
+ }
+ return count;
+}
+
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_filter.h b/linux/drivers/media/dvb/dvb-core/dvb_filter.h
index b084112fa..7a0b702b0 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_filter.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_filter.h
@@ -229,12 +229,14 @@ int dvb_filter_instant_repack(u8 *buf, int count, ipack *p);
void dvb_filter_ipack_init(ipack *p, int size,
void (*func)(u8 *buf, int size, void *priv));
void dvb_filter_ipack_free(ipack * p);
+void dvb_filter_ipack_flush(ipack *p);
+
+#if 0
void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
void (*pes_write)(u8 *buf, int count, void *data),
void *priv);
void ts_to_pes(ipack *p, u8 *buf);
void send_ipack(ipack *p);
-void dvb_filter_ipack_flush(ipack *p);
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr);
@@ -247,3 +249,5 @@ int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr);
int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr);
int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr);
#endif
+
+#endif