How to drop video frame in video capture driver?

Discussion in 'Windows Vista Drivers' started by Jackal Huang, Jan 4, 2005.

  1. Jackal Huang

    Jackal Huang Guest

    I develop video capture driver for PC camera.
    Sometimes, the driver found that the captured frame is not correct and
    would drop this bad frame.
    The driver sets the frame data length to 0 and report success status.
    However, the bad frame is still displayed.
    If the driver report error status, error message box is displayed in capture
    application (Amcap).

    What's the correct way to drop frame in video capture driver?

    Best Regards

    Jackal Huang
     
    Jackal Huang, Jan 4, 2005
    #1
    1. Advertisements

  2. Jackal Huang

    Max Paklin Guest

    Setting data size to 0 has got to work. I think I did it successfully in the
    past.
    How exactly do you set 0 size on the sample?

    -- Max.
     
    Max Paklin, Jan 4, 2005
    #2
    1. Advertisements

  3. Jackal Huang

    Jackal Huang Guest

    I modify my driver from USBCAMD miniport sample code.
    Therefore, it follows the USBCAMD model to drop bad frame.
    In USBCAMD miniport, it just set a error flag for bad frame.
    USBCAMD library set srb->CommandData.DataBufferArray->DataUsed
    to 0 if the error flag is set.

    However, the bad frame is still displayed.
    I found bad frame cannot be dropped on RGB mode.
    Bad frames can be dropped on YUV mode.
    After several checks, I found AVI decompressor is insert in filter graph for
    YUV.
    For RGB mode, AVI decompressor is not inserted.
    Therefore, I think AVI decompressor filter drops bad frame.
    If my guess is wrong, there is one question in my mind.
    Which component is responsible for dropping bad frame in filter graph?

    USBCAMD model has been tested for many developers. I don't know what happen
    to this problem. My friend also met the same problem.

    Best Regards

    Jackal Huang
     
    Jackal Huang, Jan 4, 2005
    #3
  4. Jackal Huang

    Max Paklin Guest

    Hmm... interesting.
    I am sure that I used 0-length frames to discard garbage, but maybe it was
    YUV. I couldn't say now as I don't rememeber.

    Nobody in the graph is really responsible for throwing out corrupted frames.
    Any filter should discard a sample of zero length. The fact that it doesn't
    get discarded is a bug in Video Renderer or VMR.

    I can't really suggest a good approach to fix it except for a brute force.
    Have a copy of the last good frame and overwrite a bad one with it once you
    detect that a frame got corrupted. So you will end up shipping a frame out,
    but it will look exactly as a previous one, so no one should notice.

    The downside is an extra cycles spent on creating a copy of every frame.
    Obviously you can optimize it a little and do it only for RGB as you know
    that YUV works fine. However if it is indeed a bug in Video Renderer (or
    VMR) then you are better do it for YUV as well because it is possible that
    your driver get connected to the Video Renderer directly and not through AVI
    Decompressor.

    If I were you I'd write a simple filter that shipped out a zero length
    samples to Video Renderer to verify that it is indeed a problem with it and
    submitted a bug to MS.

    -- Max.
     
    Max Paklin, Jan 4, 2005
    #4
  5. Jackal Huang

    Jackal Huang Guest

    I will write a filter to that shipped out a zero length samples if no other
    solution.
    I just wonder whether other developers suffer the same problem.
    Make a copy of previous frame takes a lot of time.
    I am afraid of performance issue.

    By the way, I use your sample code for KS proxy plug in filter.
    It is built by vc.net 2003 and msvcr71.dll is needed for filter.
    Usually, msvcr71.dll is not found in OS except vc.net is installed
    Can I get rid of this requirement?

    Best Regards

    Jackal Huang
     
    Jackal Huang, Jan 5, 2005
    #5
  6. Jackal Huang

    Max Paklin Guest

    Sure, you can get rid of msvcr71.dll dependency. Simply change the project
    file for the plugin to use static link to runtime library (buried somewhere
    in code generation page of project settings) instead of dynamic link and the
    runtime will be staticly linked into your .ax.

    -- Max.
     
    Max Paklin, Jan 5, 2005
    #6
  7. Jackal Huang

    Jackal Huang Guest

    Do you mean change project properties->General->use of MFC?
    Originally, the setting is "Use standard windows library".
    I change the setting to "Use MFC in a static library".
    Many strange linking errors occur such as
    error LNK2019: unresolved external symbol __chkstk or
    error LNK2001: unresolved external symbol "void __cdecl operator delete
    (void *)" ([email protected]@Z)

    I don't know how to solve.

    Best Regards

    Jackal Huang
     
    Jackal Huang, Jan 11, 2005
    #7
  8. Jackal Huang

    Max Paklin Guest

    No.
    Go to Project Settings -> C/C++ -> Code Generation and change Runtime
    Library setting on the right from Multi-threaded Debug DLL to Multi-threaded
    Debug for debug mode or from Multi-threaded DLL to Multi-threaded for
    release mode.

    -- Max.
     
    Max Paklin, Jan 11, 2005
    #8
  9. Jackal Huang

    Jackal Huang Guest

    I change the setting as you said.
    The same linking errors occur.

    Jackal Huang
     
    Jackal Huang, Jan 12, 2005
    #9
  10. Jackal Huang

    Max Paklin Guest

    What version of Developer Studio?
    Were you ever able to successfully build it? Were you able to build using an
    original project file?

    -- Max.
     
    Max Paklin, Jan 12, 2005
    #10
  11. Jackal Huang

    Jackal Huang Guest

    Yes, I can bulid successfully by using the original project file.
    If I change the runtime library setting to Multi-threaded, linking errors
    occur.
    If I change the runtime library setting back Multi-threaded DLL, build
    successfully.
    I use vc.net 2003 to build the project.

    Jackal Huang
     
    Jackal Huang, Jan 12, 2005
    #11
  12. Jackal Huang

    Max Paklin Guest

    Made the change to Multi-threaded and also remove everything from Project
    Properties -> Linker -> Input -> Ignore Specific Library.

    -- Max.
     
    Max Paklin, Jan 12, 2005
    #12
  13. Jackal Huang

    Jackal Huang Guest

    Thanks for your patient reply.
    After do so, one linking error left.

    LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
    referenced in function _mainCRTStartup.

    In fact, I have no idea about how to solve these errors.
    What's the best way to solve this kind of errors?

    By the way, can I redistribute msvcr71.dll with my filter?

    Jackal Huang
     
    Jackal Huang, Jan 13, 2005
    #13
  14. Jackal Huang

    Max Paklin Guest

    The best way to solve these problems is to acquire a good basic knowledge of
    software development methods and then gain a lot of experience in particular
    technology. After that you will be able to resolve problem related to that
    particular technology in no time. Pretty common suggestion, huh? But that's
    the only one I got for you.

    OK, I just built the project using static C runtime libraries.
    You will have to put back under Project Properties -> Linker -> Input ->
    Ignore Specific Library libcmt.lib for release mode and libcmtd.lib for
    debug mode.

    Yes, you can redistribute the runtime DLLs.

    -- Max.
     
    Max Paklin, Jan 14, 2005
    #14
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.