diff options
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index de57ee877..0810fbbea 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -286,7 +286,7 @@ Image::crop_scale_window( round_height_for_subsampling((out_size.height - inter_size.height) / 2, out_desc) ); - uint8_t* scale_out_data[out->planes()]; + std::vector<uint8_t*> scale_out_data(out->planes()); for (int c = 0; c < out->planes(); ++c) { int const x = lrintf(out->bytes_per_pixel(c) * corner.x); scale_out_data[c] = out->data()[c] + x + out->stride()[c] * (corner.y / out->vertical_factor(c)); @@ -296,7 +296,7 @@ Image::crop_scale_window( scale_context, scale_in_data.data(), stride(), 0, cropped_size.height, - scale_out_data, out->stride() + scale_out_data.data(), out->stride() ); sws_freeContext(scale_context); @@ -1219,6 +1219,17 @@ Image::bytes_per_pixel(int component) const } #endif + if ( + _pixel_format == AV_PIX_FMT_0RGB || + _pixel_format == AV_PIX_FMT_RGB0 || + _pixel_format == AV_PIX_FMT_0BGR || + _pixel_format == AV_PIX_FMT_BGR0) { + /* Each pixel has an empty byte which we need to account for when allocating, + * otherwise we'll corrupt the image. + */ + bpp[3] = bpp[0]; + } + if ((d->flags & AV_PIX_FMT_FLAG_PLANAR) == 0) { /* Not planar; sum them up */ return bpp[0] + bpp[1] + bpp[2] + bpp[3]; @@ -1573,17 +1584,18 @@ Image::fade(float f) case AV_PIX_FMT_RGB48LE: /* 16-bit little-endian */ for (int c = 0; c < 3; ++c) { - int const stride_pixels = stride()[c] / 2; - int const line_size_pixels = line_size()[c] / 2; + /* Number of R, G, B values */ + int const stride_values = stride()[c] / 2; + int const line_size_values = line_size()[c] / 2; uint16_t* p = reinterpret_cast<uint16_t*>(data()[c]); int const lines = sample_size(c).height; for (int y = 0; y < lines; ++y) { uint16_t* q = p; - for (int x = 0; x < line_size_pixels; ++x) { - *q = int(float(*q) * f); + for (int x = 0; x < line_size_values; ++x) { + *q = int(*q * f); ++q; } - p += stride_pixels; + p += stride_values; } } break; |
