Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd January 2016, 15:12   #1  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
Throw error on frame processing in C

The C++ API of Avisynth allows throwing errors with environment method ThrowError. The C API handles errors in another way: returning an AVS value of type error by filter call.

But what's with errors on frame processing (in get frame callback)? ThrowError works as expected, but how to raise an error in C?

Setting error in AVS_FilterInfo stops any processing, but the display size doesn't change and no error message is drawn (as normally expected).
Youka is offline   Reply With Quote
Old 2nd January 2016, 23:25   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Amazing that this information is not readily available. I will take a guess.

1. Don't throw errors outside your DLL at all. Read this advice:
http://avisynth.nl/index.php/AviSynt...n_Writing_Tips

2. I think you do the same as Avisynth does - in case of error, return a null pointer. It's the 'C' way.
Code:
/* 
* src\core\avisynth_c.cpp(173) 
*/
extern "C"
AVS_VideoFrame * AVSC_CC avs_get_frame(AVS_Clip * p, int n)
{
    p->error = 0;
    try {
        PVideoFrame f0 = p->clip->GetFrame(n,p->env);
        AVS_VideoFrame * f;
        new((PVideoFrame *)&f) PVideoFrame(f0);
        return f;
    } catch (AvisynthError err) {
        p->error = err.msg;
        return 0;
    } 
}
raffriff42 is offline   Reply With Quote
Old 3rd January 2016, 00:09   #3  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by raffriff42 View Post
Amazing that this information is not readily available. I will take a guess.

1. Don't throw errors outside your DLL at all. Read this advice:
http://avisynth.nl/index.php/AviSynt...n_Writing_Tips

2. I think you do the same as Avisynth does - in case of error, return a null pointer. It's the 'C' way.
Code:
/* 
* src\core\avisynth_c.cpp(173) 
*/
extern "C"
AVS_VideoFrame * AVSC_CC avs_get_frame(AVS_Clip * p, int n)
{
    p->error = 0;
    try {
        PVideoFrame f0 = p->clip->GetFrame(n,p->env);
        AVS_VideoFrame * f;
        new((PVideoFrame *)&f) PVideoFrame(f0);
        return f;
    } catch (AvisynthError err) {
        p->error = err.msg;
        return 0;
    } 
}
No.
C doesn't support exceptions or try/catch statements.
One might try something like this.
Groucho2004 is offline   Reply With Quote
Old 3rd January 2016, 01:55   #4  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
I speak not of try/catch or setjmp/longjmp, but of 'C' style error signaling (in the case of avs_get_frame: return pointer to frame, or null on error). The try/catch I quoted was internal to the function (in C++ land) and was not part of the Avisynth C interface.
raffriff42 is offline   Reply With Quote
Old 3rd January 2016, 11:34   #5  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by raffriff42 View Post
I speak not of try/catch or setjmp/longjmp, but of 'C' style error signaling (in the case of avs_get_frame: return pointer to frame, or null on error). The try/catch I quoted was internal to the function (in C++ land) and was not part of the Avisynth C interface.
I see what you mean. Worth a try, I guess.
Groucho2004 is offline   Reply With Quote
Old 3rd January 2016, 13:20   #6  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Worth a try, I guess.
I caught that.
raffriff42 is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:40.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.