diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-23 21:35:44 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-23 21:35:44 +0000 |
| commit | 2e5b4effbc5e7f7ac74cae541a05d3401c9170b0 (patch) | |
| tree | 814347d5267d397f5bac86b34abda6523549ea53 /src/lib | |
| parent | 7913cba90bccb9501b63a0518c58abbd5a6b330d (diff) | |
Throw an exception rather than asserting when unable to handle a pixel format (#65).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/exceptions.h | 13 | ||||
| -rw-r--r-- | src/lib/image.cc | 6 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 6de8806e4..277355117 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -28,6 +28,9 @@ #include <cstring> #include <boost/exception/all.hpp> #include <boost/thread.hpp> +extern "C" { +#include <libavutil/pixfmt.h> +} #include "compose.hpp" /** @class StringError @@ -220,6 +223,14 @@ public: {} }; +class PixelFormatError : public StringError +{ +public: + PixelFormatError (std::string o, AVPixelFormat f) + : StringError (String::compose ("Cannot handle pixel format %1 during %2", f, o)) + {} +}; + class ExceptionStore { public: @@ -245,4 +256,6 @@ private: mutable boost::mutex _mutex; }; + + #endif diff --git a/src/lib/image.cc b/src/lib/image.cc index 73d499fe8..ae87304c2 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -70,7 +70,7 @@ Image::lines (int n) const case PIX_FMT_YUV422P: return size().height; default: - assert (false); + throw PixelFormatError ("lines()", _pixel_format); } return 0; @@ -89,7 +89,7 @@ Image::components () const case PIX_FMT_RGBA: return 1; default: - assert (false); + throw PixelFormatError ("components()", _pixel_format); } return 0; @@ -202,7 +202,7 @@ Image::post_process (string pp, bool aligned) const pp_format = PP_FORMAT_422; break; default: - assert (false); + throw PixelFormatError ("post_process", pixel_format()); } pp_mode* mode = pp_get_mode_by_name_and_quality (pp.c_str (), PP_QUALITY_MAX); |
