diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-08-23 11:17:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-08-23 11:17:03 +0100 |
| commit | d6be9f27147113dc6355ed0de7c99d1312aaeebd (patch) | |
| tree | 5df043ccf1a56938f256976cc1f5ce7f2fea6057 /src/lib/image.cc | |
| parent | 57796599a3acc10feebcbc87da70daf4d0af04f6 (diff) | |
Tidy up duplicated code.
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index bdf7fd173..5c04f70e6 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -79,7 +79,7 @@ Image::components () const } shared_ptr<Image> -Image::scale (libdcp::Size out_size, Scaler const * scaler, bool result_aligned) const +Image::scale (libdcp::Size out_size, Scaler const * scaler, AVPixelFormat result_format, bool result_aligned) const { assert (scaler); /* Empirical testing suggests that sws_scale() will crash if @@ -87,11 +87,11 @@ Image::scale (libdcp::Size out_size, Scaler const * scaler, bool result_aligned) */ assert (aligned ()); - shared_ptr<Image> scaled (new Image (pixel_format(), out_size, result_aligned)); + shared_ptr<Image> scaled (new Image (result_format, out_size, result_aligned)); struct SwsContext* scale_context = sws_getContext ( size().width, size().height, pixel_format(), - out_size.width, out_size.height, pixel_format(), + out_size.width, out_size.height, result_format, scaler->ffmpeg_id (), 0, 0, 0 ); @@ -107,40 +107,6 @@ Image::scale (libdcp::Size out_size, Scaler const * scaler, bool result_aligned) return scaled; } -/** Scale this image to a given size and convert it to RGB. - * @param out_size Output image size in pixels. - * @param scaler Scaler to use. - */ -shared_ptr<Image> -Image::scale_and_convert_to_rgb (libdcp::Size out_size, Scaler const * scaler, bool result_aligned) const -{ - assert (scaler); - /* Empirical testing suggests that sws_scale() will crash if - the input image is not aligned. - */ - assert (aligned ()); - - shared_ptr<Image> rgb (new Image (PIX_FMT_RGB24, out_size, result_aligned)); - - struct SwsContext* scale_context = sws_getContext ( - size().width, size().height, pixel_format(), - out_size.width, out_size.height, PIX_FMT_RGB24, - scaler->ffmpeg_id (), 0, 0, 0 - ); - - /* Scale and convert to RGB from whatever its currently in (which may be RGB) */ - sws_scale ( - scale_context, - data(), stride(), - 0, size().height, - rgb->data(), rgb->stride() - ); - - sws_freeContext (scale_context); - - return rgb; -} - /** Run a FFmpeg post-process on this image and return the processed version. * @param pp Flags for the required set of post processes. * @return Post-processed image. |
