On Monday 20 February 2006 14:50, Marius Schrecker wrote:
> Hi,
>
> I posted a bit earlier about difficulties using the YUV (UYUV) stream
> in mp4live from /dev/video32, 33 (pvr-500).
>
> The original post was about EINVAL errors trying to request buffers.
> The background for this can be found in these threads on the mpeg4ip
> forum:
>
> http://sourceforge.net/forum/forum.php?thread_id=1357887
> <http://sourceforge.net/forum/forum.php?thread_id=1357887&forum_id=59
>136
>
> > &forum_id=59136
>
> http://sourceforge.net/forum/forum.php?thread_id=1440213
> <http://sourceforge.net/forum/forum.php?thread_id=1440213&forum_id=59
>136
>
> > &forum_id=59136
>
> As I have had no responses tio this I'm guessing it's difficult to
> trace the code that could help us fix mpeg4ip.
>
> Is there any code in the driver that could be used to produce a
> standard YUV stream from these
> Cards so that we can capture using the standard methods in mpeg4ip?
>
> Any other suggestions of where to look / where to ask?

Many applications supporting YUV use the V4L2 buffering API. However, 
this is not implemented in ivtv. It probably will be added in the 
future, but not anytime soon. It is a non-trivial thing to do and is 
not terribly high on the todo list.

The format used by video32 (YUV in) and video48 (YUV out) is specific to 
the card. mplayer has support for it (rawvideo format hm12).

You can test the raw YUV in and out by running 'cat /dev/video32 
>/dev/video48'.

The driver does not support 'normal' YUV (the yuv-fixup code is broken).

A simple program to transform HM12 to YV12 is attached.

Hope this helps.

        Hans
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static unsigned char frame[576*720*3/2];
static unsigned char framey[576*720];
static unsigned char frameu[576*720 / 4];
static unsigned char framev[576*720 / 4];

static void de_macro_y(unsigned char* dst, unsigned char *src, int dstride, int w, int h)
{
    unsigned int y, x, i;

    // descramble Y plane
    // dstride = 720 = w
    // The Y plane is divided into blocks of 16x16 pixels
    // Each block in transmitted in turn, line-by-line.
    for (y = 0; y < h; y += 16) {
        for (x = 0; x < w; x += 16) {
            for (i = 0; i < 16; i++) {
                memcpy(dst + x + (y + i) * dstride, src, 16);
                src += 16;
            }
        }
    }
}

static void de_macro_uv(unsigned char *dstu, unsigned char *dstv, unsigned char *src, int dstride, int w, int h)
{
    unsigned int y, x, i;

    // descramble U/V plane
    // dstride = 720 / 2 = w
    // The U/V values are interlaced (UVUV...).
    // Again, the UV plane is divided into blocks of 16x16 UV values.
    // Each block in transmitted in turn, line-by-line.
    for (y = 0; y < h; y += 16) {
        for (x = 0; x < w; x += 8) {
            for (i = 0; i < 16; i++) {
		int idx = x + (y + i) * dstride;

		dstu[idx+0] = src[0];  dstv[idx+0] = src[1];
		dstu[idx+1] = src[2];  dstv[idx+1] = src[3];
		dstu[idx+2] = src[4];  dstv[idx+2] = src[5];
		dstu[idx+3] = src[6];  dstv[idx+3] = src[7];
		dstu[idx+4] = src[8];  dstv[idx+4] = src[9];
		dstu[idx+5] = src[10]; dstv[idx+5] = src[11];
		dstu[idx+6] = src[12]; dstv[idx+6] = src[13];
		dstu[idx+7] = src[14]; dstv[idx+7] = src[15];
                src += 16;
            }
        }
    }
}

/*************************************************************************/
int main(int argc, char **argv)
{
    FILE *fin;
    int i;

    if (argc == 1) fin = stdin;
    else fin = fopen(argv[1], "r");

    if (fin == NULL) {
        fprintf(stderr, "cannot open input\n");
        exit(-1);
    }
    while (fread(frame, sizeof(frame), 1, fin) == 1) {
	de_macro_y(framey, frame, 720, 720, 576);
	de_macro_uv(frameu, framev, frame + 720 * 576, 720 / 2, 720 / 2, 576 / 2);
        fwrite(framey, sizeof(framey), 1, stdout);
        fwrite(framev, sizeof(framev), 1, stdout);
        fwrite(frameu, sizeof(frameu), 1, stdout);
    }
    fclose(fin);
    return 0;
}
_______________________________________________
ivtv-devel mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-devel

Reply via email to