[theora-dev] Gray scale video output from theora

Shane Stephens shane.stephens at gmail.com
Sat Feb 16 22:54:58 PST 2008


Hi Janaka,

The type signature of memset is:
       void *memset(void *s, int c, size_t n);

Notice that the second parameter is an int, not an int *.  What your code
does is treat the pointer value (which points somewhere into your stack) as
if it were an integer, and then fill the memory with the value of the
pointer (actually the value of the least significant byte of the pointer).
So if you had an integer called temp at memory location 0xDEADBEEF, and you
said

memset(s, &temp, n)

then you would be setting n bytes of s to 0xEF, rather than the value of
temp.

In short: lose the '&' :)

Incidentally, this is why you should always compile with gcc's -Wall flag
and read the warnings that come out - they would have told you that you were
treating a pointer to an int as if it were an int.  In fact, if you can get
away with it, use -Werror too - that way this code would not compile at all.

Cheers,
    -Shane

On Feb 17, 2008 5:17 PM, janaka priyadarshana <rpjanaka at gmail.com> wrote:

> thanks very much for your help
>
> So I already tried to remove the U & V components from the stream..
>
> But unfortunately I was unable to do it successfully
>
> *what I did is.......*
>
> Changed some code segments in theora_encode_YUVin() which is in theencoder_toplevel.c
>
>
>   for ( i = 0; i < yuv->uv_height; i++ ){
>     memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
>     LocalDataPtr -= yuv->uv_width;
>     InputDataPtr += yuv->uv_stride;
>   }
>
>
> the above code segment is use to copy the U data into the LocalDataPtr
>
> So i just avoid this input U component (copy the value zero into the LocalDataPtr
> ) as follow
>
> int temp = 0;
>   for ( i = 0; i < yuv->uv_height; i++ ){
>     memset( LocalDataPtr, &temp, yuv->uv_width );
>     LocalDataPtr -= yuv->uv_width;
>     InputDataPtr += yuv->uv_stride;
>   }
>
> The same thing was done for the V component also
>
> But the result was differ from my expectations and at the same time the
> result was differ from each other when I get encoded the same stream at
> different time.
>
> These videos looks like it is lay over a colored mist on top of the video.
>
> I have attached two snapshots of the resulted video and the original
> video.
>
>
> *Please can I know that *
>
> what I have done is correct or not...?
>
> if this way is not the correct way, please help me to do this...
>
>
>
> On Feb 17, 2008 12:32 AM, Ralph Giles <giles at xiph.org> wrote:
>
> > On 16-Feb-08, at 5:33 AM, janaka priyadarshana wrote:
> >
> > *If the above is true.....(*theora use YUV color space*)*
> >
> >
> > Yes, Theora always encodes video in a YUV colour space.
> >
> > it is possible that get a gray scale video output by just considering
> > only the Y component of the video (ignore the U and V components)
> >
> >
> > Using just the Y plane is a reasonable way to convert a YUV image to a
> > monochrome one.
> >
> >  -r
> >
> >
>
>
> --
> -----------
> Regards,
> Janaka Priyadarshana
> _______________________________________________
> theora-dev mailing list
> theora-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/theora-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20080217/aec3b994/attachment.htm


More information about the theora-dev mailing list