Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

what's wrong with createVideoClip()?

2013-06-11
2014-04-07
  • Hi, I'm stuck with the part that I want to create clip out of a file. I've compiled the library from source for msvc10 and I still have problems. With version msvc10 when I try to use createVideoClip() it throws a std::bad_alloc exception and with further debugging I realized that It's having problem with one of "new" keywords that you're using for creating object in that method. For msvc9 I'd get another problems such as Run-time check failure #0 and reading access violation. Is there any bug with this method?

    Thanks.

     
  • Hi Mahan,

    Hmm, really weird, I'm using the library on a daily basis and have no such problems on all the supported platforms.

    are you able to compile and run one of the demos? do you have some custom alocators?

    Also, I only tested the library on 32 bit systems, 64 bit support hasn't been tested yet but is planned, are you compiling a 64 bit version?

     
  • Thanks for reply.

    Yeah I'm able to run all of the demos and they're all OK. I simply write it the way you coded the demos and the one in the Tutorial page and, it's on a 32 bit system. By the way, is there any specific configuration that I have to apply on my project's settings? I'm using DirectX for graphical display, would this affect the library?

     
  • If you're able to run the demos then there's probably something wrong with your code. the most frequent problems I get are with file paths. the stock file loader uses fopen() to load files, so make sure you pass along a path that fopen can find.

    as for DirectX, the library is coded in a way that it doesn't care where and how you use the video data it provides. you can use it in any way and anywhere.
    I use it in OpenGL, OpenGL ES, DirectX9 and DirectX11.

     
  • I mistakenly answered for compiled demos not the source demos. I haven't compiled demos from source yet because I don't have OpenGL's dependencies on my machine. Anyway, thanks for your reply, I'll try to fix my issue. This is a cool library dude :)

     
  • Ok, then the best course of action would be to compile the demos. as for OpenGL, you need the platform sdk from microsoft and you should be good to go. every other dependency I've already included in the project's svn.

    Glad you like the library :) It makes me very glad when I see people finding it useful :)

     
  • Ifeanyi Nmoye
    Ifeanyi Nmoye
    2013-06-23

    Im having exactly the same problem as Mahan. For msvc9, I get a reading access violation when I call createVideoClip.

    mgr=new TheoraVideoManager();
    TheoraVideoClip *clip=mgr->createVideoClip("bunny.ogg");
    

    Is there something I am not initializing properly within the TheoraVideoManager(mgr) object?

     
  • hmm, should be ok, depends on where you put bunny.ogg? That's the most common problem.

    try a try catch block arround createVideoClip and see what happens. because the library throws a TheoraGenericException if the file isn't found

     
    • Ifeanyi Nmoye
      Ifeanyi Nmoye
      2013-06-28

      Thanks for the reply. will try that.

       
  • I finally found the solution! Actually it doesn't sound like a solution but this is what I did to get it working. I tried to compile for msvc10 from source and I set "Basic Runtime Checks" for all of projects in msvc10 solution to "Default". You can find this under "Project Properties -> Configuration Properties -> C/C++ -> Code Generation". And remember to ensure what configuration is been selected as there are 4 kinds for each project. Like Debug, Debug_Static, etc. I recommend to choose "All Configurations" from Configuration ComboBox when you want to commit this change.

    By the way, why is this change made library to work? I'm sure having that option selected is a good thing for output but I'm not aware what's wrong with the architecture.

    Hope this help somebody in the future.

    Regards.

     
  • Hi Mahan,

    Hmm, I'm beginning to believe that my 1.0 sdk is wrongly compiled on win32, I had some complaints before :/

    Can you please do the following:

    1) try other versions in 1.0 sdk, visual studio 2008, 2010 and 2012 are provided
    2) if those don't work, please try 1.0RC2 sdk

    that'll help me diagnose the issue better! :)

     
  • Hi Krešimir,

    I don't have vs2012 right now, but I can test it under 2008 and 2010. I'll answer it here.

    BTW, do you have any hint/example for using "frame->getBuffer()" in DirectX 9? I'm struggling with it right now :D

    Thanks.

     
  • Here's our code for writing image data in DirectX9, we use this function directly on TheoraPlayer's frame data, hope it helps! :)

    PS: dataBpp here is bytes per pixel, so 3 or 4 in this case.


    void DirectX9_Texture::write(int x, int y, unsigned char* data, int dataWidth, int dataHeight, int dataBpp)
    {
        x = hclamp(x, 0, this->width - 1);
        y = hclamp(y, 0, this->height - 1);
        D3DLOCKED_RECT lockRect;
        _CREATE_RECT(rect, x, y, dataWidth, dataHeight);
        IDirect3DSurface9* buffer = NULL;
        LOCK_RESULT result = this->_tryLock(&buffer, &lockRect, &rect);
        if (result == LR_FAILED)
        {
            return;
        }
        if (dataWidth == this->width)
        {
            memcpy(lockRect.pBits, data, dataWidth * dataHeight * dataBpp);         
        }
        else
        {
            unsigned char *dst = (unsigned char*) lockRect.pBits, *src = data;
            unsigned char *dstEnd = dst + this->width * dataHeight * dataBpp;
            int rowLen = dataWidth * dataBpp;
            int dstInc = this->width * dataBpp, srcInc = rowLen;
    
            for (; dst != dstEnd; dst += dstInc, src += srcInc)
            {
                memcpy(dst, src, rowLen);
            }
        }
        this->_unlock(buffer, result, true);
    }
    

     
    Last edit: Krešimir Špes 2013-06-28
  • Thanks for code.

    I built library from version 1.0.0 and this is the result:

    vs2008 is fine with the default build
    vs2010 is fine with the default build

    I'm confused :|

    I don't know if is it vs2008 that has made any change to my SDKs or something else after I installed it earlier. Back at the first time when I was trying to use vs2010 version, It was throwing a std::bad_alloc for me at createVideoClip(). After setting Basic Runtime Checks to Default it was running fine. Now, without any change it's just working normal. I don't know what exactly is happening. I think it's better for others to test it too, I'm not sure that this is acting normal.

    Would you post _tryLock and _unlock from your code too? I'm sorry to ask, but I haven't worked with LockRect().

    PS: Thanks :D

     
  • mumin16
    mumin16
    2014-04-06

    This problem is still continues in vs2012 x64 build. Please , can you work on this poblem!?.

     
    Last edit: mumin16 2014-04-06
  • hmm, can you give me some more info? Are you compiling the library from source code or using the binary version from the sdk? If it's the source, are you using the latest svn version?