Show
Ignore:
Timestamp:
02/21/10 23:22:58 (2 years ago)
Author:
Robin Gareus <rgareus@…>
Parents:
9759199714df0cd85f695766c4c5c5d712570365
Children:
6e49c3474539a6c60ade3911897032696b324db7
git-committer:
Robin Gareus <rgareus@priroda.local> / 2010-02-22T00:22:58Z+0100
Message:

sending to TAC! works again...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • oggzcap/src/videoout/encoder_example.c

    r9fd2977 r66e0a72  
    5353int keyframe_frequency=1; 
    5454 
    55 int yuv_copy__422_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst); 
     55int yuv_copy__bgra_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst); 
    5656//// InOut conversion (from theoraEncoder (xiph)) 
    57 int yuv_copy__422_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst) 
     57int yuv_copy__bgra_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst) 
    5858{ 
    59         return 1; 
     59#if 0 // 422 -> 420 
    6060    UInt8 *base = b_2vuy; 
    6161    size_t off_x = offset_x & ~0x01, off_y = offset_y & ~0x01; 
     
    8686        cr_base += dst->uv_stride; 
    8787    } 
    88          
     88#else // RGBA -> 420 
     89         
     90#define _CR ((bptr[(4*i)+2])&0xff) 
     91#define _CG ((bptr[(4*i)+1])&0xff) 
     92#define _CB ((bptr[(4*i)+0])&0xff) 
     93         
     94        uint8_t *bptr = (uint8_t*) b_2vuy; 
     95        int i; int c=0; 
     96        for (i=0;i<width*height;i++) { 
     97                double Y  = (0.257 * _CR) + (0.504 * _CG) + (0.098 * _CB) + 16; 
     98                if (Y<0) dst->y[i]=0; 
     99                else if (Y>255) dst->y[i]=255; 
     100                else dst->y[i]=(uint8_t) floor(Y+.5); 
     101#if 1 
     102                if (i%2==0 && ((i/width)%2)==0) { // TODO average 4 pixels 
     103            double V =  (0.439 * _CR) - (0.368 * _CG) - (0.071 * _CB) + 128; 
     104            double U = -(0.148 * _CR) - (0.291 * _CG) + (0.439 * _CB) + 128; 
     105                         
     106            if (U<0) dst->u[c]=0; 
     107            else if (U>255) dst->u[c]=255; 
     108            else dst->u[c]=(uint8_t) floor(U+.5); 
     109                         
     110            if (V<0) dst->v[c]=0; 
     111            else if (V>255) dst->v[c]=255; 
     112            else dst->v[c]=(uint8_t) floor(V+.5); 
     113            c++; 
     114                } 
     115#endif 
     116                 
     117                 
     118    } 
     119#endif   
    89120    return 1; 
    90121} 
     
    185216                //printf("going to yuv CONVERT\n") ; 
    186217                                                 
    187                 // Transfer the source frame into glob->currentFrame, converting it from chunky YUV422 to planar YUV420. 
    188                 int err = yuv_copy__422_to_420(CVPixelBufferGetBaseAddress(theBuffer), 
     218                int err = yuv_copy__bgra_to_420(CVPixelBufferGetBaseAddress(theBuffer), 
    189219                                                                           CVPixelBufferGetBytesPerRow(theBuffer), 
    190220                                                                           pxwidth, pxheight, 
     
    242272        unsigned short  port = outIcePort ; 
    243273         
    244         if ((myShout = shout_new()) == NULL) printf("oggfwd - Error - allocate pb%s\n") ; 
     274        if ((myShout = shout_new()) == NULL) printf("oggfwd - Error - allocate pb\n") ; 
    245275        if (shout_set_host(myShout, outIceIp) != SHOUTERR_SUCCESS) printf("oggfwd - Error - set host pb...%s\n",shout_get_error(myShout)) ; 
    246276        if (shout_set_port(myShout, port) != SHOUTERR_SUCCESS) printf("oggfwd - Error - look at the code to know...\n") ; 
     
    386416        // S2 - InOut - sending header to icecast 
    387417        int fwdResH1 = myOggfwd_process(myGlob_og) ; 
    388         //printf("HEADER /////// Forwarded to Icecast : success ? %d\n", fwdResH1) ; 
     418        printf("HEADER /////// Forwarded to Icecast : success ? %d\n", fwdResH1) ; 
    389419         
    390420        ////////////////////////////////////////////////////////////