This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

采用tvp5146m2处想图像上下抖动

Other Parts Discussed in Thread: TVP5146M2

我目前有个产品,CVBS信号输入,转成10位的YCbCr信号,电路设计是按照5146的demo资料设计的,但是图像出现上下抖动,请问是什么问题?

 

  • 除了抖动,有无其他问题,画面是否清晰,有无重影之类的?

    建议参考下面帖子中有关TVPxx使用中遇到的问题总结,希望对你有所帮助:

    http://www.deyisupport.com/question_answer/dsp_arm/davinci_digital_media_processors/f/39/t/52747.aspx

     

  • 图像很清晰,也没有重影,比如在显示文字的时候,文字有抖动,用相机对这个文字拍照的时候,文字的颜色会发生丢失,白色的文字会变成五颜六色。如图片所显示这样

  • 给你看看我以前的开发代码:给你呢参考下。我当时是没有任何问题的。。

    TVP5146M2所在的模块无法支持NTSC制式, 开发的时候用的摄像头默认是PAL制式,实际调试时采用的摄像头默认为NTSC制式

    static int initCapture(int *capture_fd, int *numbuffers, char *inputname,

                    char *stdname, struct v4l2_format *fmt)

    {

        int ret, i, j;

        struct v4l2_requestbuffers reqbuf;

        struct v4l2_buffer buf;

        struct v4l2_capability capability;

        struct v4l2_input input;

        v4l2_std_id std_id;

        struct v4l2_standard standard;

        int index;

     

        /* Open the capture device */

        *capture_fd  = open((const char *) CAPTURE_DEVICE, O_RDWR);

        if (*capture_fd  <= 0) {

            printf("Cannot open = %s device\n", CAPTURE_DEVICE);

            return -1;

        }

        printf("\n%s: Opened Channel\n", CAPTURE_NAME);

     

        /* Get any active input */

        if (ioctl(*capture_fd, VIDIOC_G_INPUT, &index) < 0) {

            perror("VIDIOC_G_INPUT");

            goto ERROR;

        }

     

        /* Enumerate input to get the name of the input detected */

        memset(&input, 0, sizeof(input));

        input.index = index;

        if (ioctl(*capture_fd, VIDIOC_ENUMINPUT, &input) < 0) {

            perror("VIDIOC_ENUMINPUT");

            goto ERROR;

        }

     

            printf("Get input oK\n");

        printf("%s: Current Input: %s\n", CAPTURE_NAME, input.name);

        /* Store the name of the output as per the input detected */

        strcpy(inputname, input.name);

     

            printf("start query\n");

        /* Detect the standard in the input detected */

        if (ioctl(*capture_fd, VIDIOC_QUERYSTD, &std_id) < 0) {

            perror("VIDIOC_QUERYSTD");

            //goto ERROR;

        }

     

    //查询支持的格式

    struct v4l2_fmtdesc fmt1;

    memset(&fmt1, 0, sizeof(fmt1));

    fmt1.index = 0;

    fmt1.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

     

    while ((ret = ioctl(*capture_fd, VIDIOC_ENUM_FMT, &fmt1)) == 0) {

     

    fmt1.index++;

     

    printf("{ pixelformat = '%c%c%c%c', description = '%s' ,fmt1.index = %d}\n",

     

    fmt1.pixelformat & 0xFF, (fmt1.pixelformat >> 8) & 0xFF,

     

    (fmt1.pixelformat >> 16) & 0xFF, (fmt1.pixelformat >> 24) & 0xFF,

     

    fmt1.description,fmt1.index);

     

    /*ret = enum_frame_sizes(*capture_fd, fmt1.pixelformat);

     

    if (ret != 0)

     

    printf("  Unable to enumerate frame sizes.\n");

     

    */

    }

    //

            printf("start get std\n");

        /* Get the standard*/

        if (ioctl(*capture_fd, VIDIOC_G_STD, &std_id) < 0) {

            /* Note when VIDIOC_ENUMSTD always returns EINVAL this

               is no video device or it falls under the USB exception,

               and VIDIOC_G_STD returning EINVAL is no error. */

            perror("VIDIOC_G_STD");

            goto ERROR;

        }

        //printf("std_id= %s", std_id.)

     

        memset(&standard, 0, sizeof(standard));

        standard.index = 0;

        while (1) {

            if (ioctl(*capture_fd, VIDIOC_ENUMSTD, &standard) < 0) {

                perror("VIDIOC_ENUMSTD");

                goto ERROR;

            }

     

            /* Store the name of the standard */

            if (standard.id & std_id) {

                strcpy(stdname, standard.name);

                printf("%s: Current standard: %s\n",

                       CAPTURE_NAME, standard.name);

                break;

            }

            standard.index++;

        }

     

        /* Check if the device is capable of streaming */

        if (ioctl(*capture_fd, VIDIOC_QUERYCAP, &capability) < 0) {

            perror("VIDIOC_QUERYCAP");

            goto ERROR;

        }

        if (capability.capabilities & V4L2_CAP_STREAMING)

            printf("%s: Capable of streaming\n", CAPTURE_NAME);

        else {

            printf("%s: Not capable of streaming\n", CAPTURE_NAME);

            goto ERROR;

        }

            fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

        ret = ioctl(*capture_fd, VIDIOC_G_FMT, fmt);

        if (ret < 0) {

            perror("VIDIOC_G_FMT");

            goto ERROR;

        }

     

        fmt->fmt.pix.pixelformat = DEF_PIX_FMT;

        //fmt->fmt.pix.height = HEIGHT;

        //fmt->fmt.pix.width = WIDTH;

        ret = ioctl(*capture_fd, VIDIOC_S_FMT, fmt);

        if (ret < 0) {

            perror("VIDIOC_S_FMT");

            goto ERROR;

        }

     

        ret = ioctl(*capture_fd, VIDIOC_G_FMT, fmt);

        if (ret < 0) {

            perror("VIDIOC_G_FMT");

            goto ERROR;

        }

     

        if (fmt->fmt.pix.pixelformat != DEF_PIX_FMT) {

            printf("%s: Requested pixel format not supported\n",

                   CAPTURE_NAME);

            goto ERROR;

        }

     

        /* Buffer allocation

         * Buffer can be allocated either from capture driver or

         * user pointer can be used

         */

        /* Request for MAX_BUFFER input buffers. As far as Physically contiguous

         * memory is available, driver can allocate as many buffers as

         * possible. If memory is not available, it returns number of

         * buffers it has allocated in count member of reqbuf.

         * HERE count = number of buffer to be allocated.

         * type = type of device for which buffers are to be allocated.

         * memory = type of the buffers requested i.e. driver allocated or

         * user pointer */

        reqbuf.count = *numbuffers;

        reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

        reqbuf.memory = V4L2_MEMORY_MMAP;

        ret = ioctl(*capture_fd, VIDIOC_REQBUFS, &reqbuf);

        if (ret < 0) {

            perror("Cannot allocate memory");

            goto ERROR;

        }

        /* Store the number of buffers actually allocated */

        *numbuffers = reqbuf.count;

        printf("%s: Number of requested buffers = %d\n", CAPTURE_NAME,

               *numbuffers);

     

        memset(&buf, 0, sizeof(buf));

     

        /* Mmap the buffers

         * To access driver allocated buffer in application space, they have

         * to be mmapped in the application space using mmap system call */

        for (i = 0; i < (*numbuffers); i++) {

            buf.type = reqbuf.type;

            buf.index = i;

            buf.memory = reqbuf.memory;

            ret = ioctl(*capture_fd, VIDIOC_QUERYBUF, &buf);

            if (ret < 0) {

                perror("VIDIOC_QUERYCAP");

                *numbuffers = i;

                goto ERROR1;

            }

     

     

            capture_buff_info[i].length = buf.length;

            capture_buff_info[i].index = i;

            capture_buff_info[i].start = mmap(NULL, buf.length,

                            PROT_READ |

                            PROT_WRITE,

                            MAP_SHARED,

                            *capture_fd,

                            buf.m.offset);

     

            if (capture_buff_info[i].start == MAP_FAILED) {

                printf("Cannot mmap = %d buffer\n", i);

                *numbuffers = i;

                goto ERROR1;

            }

     

            memset((void *) capture_buff_info[i].start, 0x80,

                capture_buff_info[i].length);

            /* Enqueue buffers

             * Before starting streaming, all the buffers needs to be

             * en-queued in the driver incoming queue. These buffers will

             * be used by thedrive for storing captured frames. */

            ret = ioctl(*capture_fd, VIDIOC_QBUF, &buf);

            if (ret < 0) {

                perror("VIDIOC_QBUF");

                *numbuffers = i + 1;

                goto ERROR1;

            }

        }

     

        printf("%s: Init done successfully\n\n", CAPTURE_NAME);

        return 0;

     

    ERROR1:

        for (j = 0; j < *numbuffers; j++)

            munmap(capture_buff_info[j].start,

                   capture_buff_info[j].length);

    ERROR:

        close(*capture_fd);

     

        return -1;

    }