[mythtv] RTjpeg problems

xavier nikoxan at mixmail.com
Thu Jul 29 23:05:51 EDT 2004


Hi people,

I'm trying to use the RTjpeg class to create an MJPEG stream from YUV420P images to test
some of my Mythtv tunning ideas. The idea is to stream them to videolan using live.com's
lib. I'm using mythtv_0.14 (due to an amount of problems that appeared when using my code
with mythtv_0.15.) 

>From the mail archives I understand RTjpeg firstly  was a part of the NuppelVideo stuff,
but it has evolved inside the Mythtv project. So, I decided to post my doubts in this
list. My live.com's framer needs a MJPEG byte stream delivered for each raw frame. I
thought that the output of RTjpeg::Compress() (as seen in the NuppelVideoRecorder) would
do it ok. But, for some reason I don't understant, the result of the RTjpeg class
compression is erronious. At the first moment, I thought I got a memory misuse, but I
cannot find it;

For testing purposal, I generate 160x160 YUV420P dummy raw frames and encode them using Q=3D255.
Is there any error in my code?
Is there any major RTjpeg bug in Mythtv 0.14 solved in Mythtv 0.15?

Thank you very much for your time and  help
	Xavier

The code is:

RTjpeg *rtjc;
AVFrame *picture;
int8_t *strm;
int M1,M2;
int size,len;
  	
	M1=3DM2=3D0;
        picture=3Davcodec_alloc_frame();
	  

       //dummy image  160*160
     	int height=3D160;
	int width=3D160;
	int w2=3Dwidth/2;
	int h2=3Dheight/2;
        
	size=3D(int)(height*width*1.5);
	 
	//ini  picture linesize
	picture->linesize[0]=3Dwidth;
	picture->linesize[1]=3Dw2;
	picture->linesize[2]=3Dw2;

	//ini  picture data
        picture->data[0]=3D(uint8_t *)malloc(size*sizeof(uint8_t));
	picture->data[1]=3Dpicture->data[0]+(width*height);
	picture->data[2]=3Dpicture->data[1]+(w2*h2);
	
	//fill dummy image
	
	// Y  
	int x,y;
        for(y=3D0;y<height;y++) {
            for(x=3D0;x<width;x++) {
                    
                picture->data[0][y * width + x] =3D 120;
            }
        }
	
	 
        //Cb and Cr  
        for(y=3D0;y<height/2;y++) {
            for(x=3D0;x<width/2;x++) {
                picture->data[1][y * w2 + x] =3D 180;
                picture->data[2][y * w2 + x] =3D 30;
            }
        }
  

	//ini  RTjpeg

	int quality_factor=3D255; //75%
	 
    	strm =3D (int8_t*)malloc(size*sizeof(int8_t));
    	int setval;
    	rtjc =3D new RTjpeg();
    	setval =3D RTJ_YUV420;
    	rtjc->SetFormat(&setval);
    	setval =3D (int)(height * 1.0);
    	rtjc->SetSize(&widh, &setval);
    	rtjc->SetQuality(&quality_factor);
	setval =3D 2;
        rtjc->SetIntra(&setval, &M1, &M2);

 	//compress
	len =3D rtjc->Compress(strm, picture->data);

---------------------------------------------------------

Busques lo que busques, lo encontrarás en http://buscador.ya.com
Ya.com ADSL Router Wi-Fi: Sólo 29,90 €/mes + IVA*. Router + Antivirus y firewall ˇGratis! http://acceso.ya.com/adsl/256router


More information about the mythtv-dev mailing list