Skip to content

Commit

Permalink
ImageConverter.outData() must shifted because of aligning. wang-bin#1046
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 8, 2018
1 parent 49ce5f8 commit e26096e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/ImageConverter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
ImageConverter: Base class for image resizing & color model convertion
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2018 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -45,7 45,8 @@ ImageConverter::~ImageConverter()

QByteArray ImageConverter::outData() const
{
return d_func().data_out;
DPTR_D(const ImageConverter);
return QByteArray::fromRawData(d.data_out.constData() d.out_offset, d.data_out.size() - d.out_offset);
}

bool ImageConverter::check() const
Expand Down Expand Up @@ -224,8 225,8 @@ bool ImageConverter::prepareData()
if (s < 0)
return false;
d.data_out.resize(s kAlign-1);
const int offset = (kAlign - ((uintptr_t)d.data_out.constData() & (kAlign-1))) & (kAlign-1);
AV_ENSURE(av_image_fill_pointers((uint8_t**)d.bits.constData(), d.fmt_out, d.h_out, (uint8_t*)d.data_out.constData() offset, d.pitchs.constData()), false);
d.out_offset = (kAlign - ((uintptr_t)d.data_out.constData() & (kAlign-1))) & (kAlign-1);
AV_ENSURE(av_image_fill_pointers((uint8_t**)d.bits.constData(), d.fmt_out, d.h_out, (uint8_t*)d.data_out.constData() d.out_offset, d.pitchs.constData()), false);
// TODO: special formats
//if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
// avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
Expand Down
4 changes: 3 additions & 1 deletion src/ImageConverter_p.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2018 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -43,6 43,7 @@ class ImageConverterPrivate : public DPtrPrivate<ImageConverter>
, contrast(0)
, saturation(0)
, update_data(true)
, out_offset(0)
{
bits.reserve(8);
pitchs.reserve(8);
Expand All @@ -57,6 58,7 @@ class ImageConverterPrivate : public DPtrPrivate<ImageConverter>
ColorRange range_in, range_out;
int brightness, contrast, saturation;
bool update_data;
int out_offset;
QByteArray data_out;
QVector<quint8*> bits;
QVector<int> pitchs;
Expand Down

0 comments on commit e26096e

Please sign in to comment.