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. |
2nd January 2016, 15:12 | #1 | Link |
Registered User
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). |
2nd January 2016, 23:25 | #2 | Link |
Retried Guesser
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; } } |
3rd January 2016, 00:09 | #3 | Link | |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
Quote:
C doesn't support exceptions or try/catch statements. One might try something like this. |
|
3rd January 2016, 01:55 | #4 | Link |
Retried Guesser
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.
|
3rd January 2016, 11:34 | #5 | Link | |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
Quote:
|
|
|
|