Alpha 0.10.24: fixed image alignment for ffmpeg, using ffmpeg 3.2.

This commit is contained in:
John Preston 2017-01-05 13:08:16 +04:00
parent d0a7e6be73
commit 9d66e88fc1
19 changed files with 82 additions and 33 deletions

View File

@ -379,6 +379,7 @@ historySendIconFg: windowBgActive;
historySendIconFgOver: windowBgActive;
historyPinnedBg: historyComposeAreaBg;
historyReplyBg: historyComposeAreaBg;
historyReplyIconFg: windowBgActive;
historyReplyCancelFg: cancelIconFg;
historyReplyCancelFgOver: cancelIconFgOver;
@ -394,6 +395,8 @@ overviewPhotoSelectOverlay: #40ace333;
// profile
profileStatusFgOver: #7c99b2;
profileVerifiedCheckBg: windowBgActive;
profileVerifiedCheckFg: windowFgActive;
// settings
notificationsBoxMonitorFg: windowFg;

View File

@ -325,6 +325,7 @@ historySendIconFg: windowBgActive;
historySendIconFgOver: windowBgActive;
historyPinnedBg: historyComposeAreaBg;
historyReplyBg: historyComposeAreaBg;
historyReplyIconFg: windowBgActive;
historyReplyCancelFg: cancelIconFg;
historyReplyCancelFgOver: cancelIconFgOver;
historyComposeButtonBg: historyComposeAreaBg;
@ -335,6 +336,8 @@ overviewCheckFg: windowBg;
overviewCheckFgActive: windowBg;
overviewPhotoSelectOverlay: #40ace333;
profileStatusFgOver: #7c99b2;
profileVerifiedCheckBg: windowBgActive;
profileVerifiedCheckFg: windowFgActive;
notificationsBoxMonitorFg: windowFg;
notificationsBoxScreenBg: dialogsBgActive;
notificationSampleUserpicFg: windowBgActive;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 490 B

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,23,0
PRODUCTVERSION 0,10,23,0
FILEVERSION 0,10,24,0
PRODUCTVERSION 0,10,24,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.10.23.0"
VALUE "FileVersion", "0.10.24.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.23.0"
VALUE "ProductVersion", "0.10.24.0"
END
END
BLOCK "VarFileInfo"

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,23,0
PRODUCTVERSION 0,10,23,0
FILEVERSION 0,10,24,0
PRODUCTVERSION 0,10,24,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Updater"
VALUE "FileVersion", "0.10.23.0"
VALUE "FileVersion", "0.10.24.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.23.0"
VALUE "ProductVersion", "0.10.24.0"
END
END
BLOCK "VarFileInfo"

View File

@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 10023;
constexpr str_const AppVersionStr = "0.10.23";
constexpr int AppVersion = 10024;
constexpr str_const AppVersionStr = "0.10.24";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View File

@ -267,9 +267,9 @@ historyReplyHeight: 49px;
historyReplyTop: 8px;
historyReplyBottom: 6px;
historyReplyIconPosition: point(13px, 13px);
historyReplyIcon: icon {{ "history_action_reply", windowBgActive }};
historyForwardIcon: icon {{ "history_action_forward", windowBgActive }};
historyEditIcon: icon {{ "history_action_edit", windowBgActive }};
historyReplyIcon: icon {{ "history_action_reply", historyReplyIconFg }};
historyForwardIcon: icon {{ "history_action_forward", historyReplyIconFg }};
historyEditIcon: icon {{ "history_action_edit", historyReplyIconFg }};
historyReplyCancel: IconButton {
width: 49px;
height: 49px;

View File

@ -234,6 +234,22 @@ void HistoryInner::enumerateItemsInHistory(History *history, int historytop, Met
// binary search should've skipped all the items that are above / below the visible area
if (TopToBottom) {
if (itembottom <= _visibleAreaTop && (cAlphaVersion() || cBetaVersion())) {
// Debugging a crash
auto fields = QStringList();
fields.append(QString::number(historytop));
fields.append(QString::number(history->height));
fields.append(QString::number(_visibleAreaTop));
fields.append(QString::number(_visibleAreaBottom));
fields.append(QString::number(blocktop));
fields.append(QString::number(block->height));
fields.append(QString::number(itemtop));
fields.append(QString::number(item->height()));
fields.append(QString::number(itembottom));
fields.append(QString::number(history->blocks.size()));
fields.append(QString::number(block->items.size()));
SignalHandlers::setCrashAnnotation("ItemInfo1", fields.join(','));
}
t_assert(itembottom > _visibleAreaTop);
} else {
t_assert(itemtop < _visibleAreaBottom);

View File

@ -1711,7 +1711,9 @@ void AudioCaptureInner::processFrame(int32 offset, int32 framesize) {
int res = 0;
char err[AV_ERROR_MAX_STRING_SIZE] = { 0 };
short *srcSamplesDataChannel = (short*)(_captured.data() + offset), **srcSamplesData = &srcSamplesDataChannel;
auto srcSamplesDataChannel = (short*)(_captured.data() + offset);
auto srcSamplesData = &srcSamplesDataChannel;
// memcpy(d->srcSamplesData[0], _captured.constData() + offset, framesize);
int32 skipSamples = AudioVoiceMsgSkip * AudioVoiceMsgFrequency / 1000, fadeSamples = AudioVoiceMsgFade * AudioVoiceMsgFrequency / 1000;
if (d->fullSamples < skipSamples + fadeSamples) {

View File

@ -30,6 +30,30 @@ namespace internal {
namespace {
constexpr int kSkipInvalidDataPackets = 10;
constexpr int kAlignImageBy = 16;
void alignedImageBufferCleanupHandler(void *data) {
auto buffer = static_cast<uchar*>(data);
delete[] buffer;
}
// Create a QImage of desired size where all the data is aligned to 16 bytes.
QImage createAlignedImage(QSize size) {
auto width = size.width();
auto height = size.height();
auto widthalign = kAlignImageBy / 4;
auto neededwidth = width + ((width % widthalign) ? (widthalign - (width % widthalign)) : 0);
auto bytesperline = neededwidth * 4;
auto buffer = new uchar[bytesperline * height + kAlignImageBy];
auto cleanupdata = static_cast<void*>(buffer);
auto bufferval = reinterpret_cast<uintptr_t>(buffer);
auto alignedbuffer = buffer + ((bufferval % kAlignImageBy) ? (bufferval - (bufferval % kAlignImageBy)) : 0);
return QImage(alignedbuffer, width, height, bytesperline, QImage::Format_ARGB32, alignedImageBufferCleanupHandler, cleanupdata);
}
bool isAlignedImage(const QImage &image) {
return !(reinterpret_cast<uintptr_t>(image.constBits()) % kAlignImageBy) && !(image.bytesPerLine() % kAlignImageBy);
}
} // namespace
@ -126,7 +150,7 @@ ReaderImplementation::ReadResult FFMpegReaderImplementation::readNextFrame() {
void FFMpegReaderImplementation::processReadFrame() {
int64 duration = av_frame_get_pkt_duration(_frame);
int64 framePts = (_frame->pkt_pts == AV_NOPTS_VALUE) ? _frame->pkt_dts : _frame->pkt_pts;
int64 framePts = _frame->pts;
TimeMs frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
_currentFrameDelay = _nextFrameDelay;
if (_frameMs + _currentFrameDelay < frameMs) {
@ -219,13 +243,12 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q
return false;
}
}
QSize toSize(size.isEmpty() ? QSize(_width, _height) : size);
if (!size.isEmpty() && rotationSwapWidthHeight()) {
toSize.transpose();
}
if (to.isNull() || to.size() != toSize) {
to = QImage(toSize, QImage::Format_ARGB32);
if (to.isNull() || to.size() != toSize || !to.isDetached() || !isAlignedImage(to)) {
to = createAlignedImage(toSize);
}
hasAlpha = (_frame->format == AV_PIX_FMT_BGRA || (_frame->format == -1 && _codecContext->pix_fmt == AV_PIX_FMT_BGRA));
if (_frame->width == toSize.width() && _frame->height == toSize.height() && hasAlpha) {
@ -239,8 +262,10 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q
_swsSize = toSize;
_swsContext = sws_getCachedContext(_swsContext, _frame->width, _frame->height, AVPixelFormat(_frame->format), toSize.width(), toSize.height(), AV_PIX_FMT_BGRA, 0, 0, 0, 0);
}
uint8_t * toData[1] = { to.bits() };
int toLinesize[1] = { to.bytesPerLine() }, res;
// AV_NUM_DATA_POINTERS defined in AVFrame struct
uint8_t *toData[AV_NUM_DATA_POINTERS] = { to.bits(), nullptr };
int toLinesize[AV_NUM_DATA_POINTERS] = { to.bytesPerLine(), 0 };
int res;
if ((res = sws_scale(_swsContext, _frame->data, _frame->linesize, 0, _frame->height, toData, toLinesize)) != _swsSize.height()) {
LOG(("Gif Error: Unable to sws_scale to good size %1, height %2, should be %3").arg(logData()).arg(res).arg(_swsSize.height()));
return false;

View File

@ -215,7 +215,7 @@ bool MediaView::gifShown() const {
_gif->pauseResumeVideo();
const_cast<MediaView*>(this)->_videoPaused = _gif->videoPaused();
}
_gif->start(_gif->width(), _gif->height(), _gif->width(), _gif->height(), ImageRoundRadius::None, ImageRoundCorner::None);
_gif->start(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None);
const_cast<MediaView*>(this)->_current = QPixmap();
}
return true;// _gif->state() != Media::Clip::State::Error;
@ -1531,7 +1531,7 @@ void MediaView::restartVideoAtSeekPosition(TimeMs positionMs) {
_autoplayVideoDocument = _doc;
if (_current.isNull()) {
_current = _gif->current(_gif->width(), _gif->height(), _gif->width(), _gif->height(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
_current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
}
_gif = std_::make_unique<Media::Clip::Reader>(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) {
clipCallback(notification);
@ -1672,7 +1672,7 @@ void MediaView::paintEvent(QPaintEvent *e) {
if (_photo || fileShown()) {
QRect imgRect(_x, _y, _w, _h);
if (imgRect.intersects(r)) {
QPixmap toDraw = _current.isNull() ? _gif->current(_gif->width(), _gif->height(), _gif->width(), _gif->height(), ImageRoundRadius::None, ImageRoundCorner::None, ms) : _current;
auto toDraw = _current.isNull() ? _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, ms) : _current;
if (!_gif && (!_doc || !_doc->sticker() || _doc->sticker()->img->isNull()) && toDraw.hasAlpha()) {
p.fillRect(imgRect, _transparentBrush);
}

View File

@ -148,8 +148,8 @@ profileReportReasonOther: InputField(defaultInputField) {
profileVerifiedCheckShift: -3px;
profileVerifiedCheck: icon {
{ "profile_verified_star", windowBgActive, point(0px, 7px) },
{ "profile_verified_check", windowFgActive, point(4px, 11px) }
{ "profile_verified_star", profileVerifiedCheckBg, point(0px, 7px) },
{ "profile_verified_check", profileVerifiedCheckFg, point(4px, 11px) }
};
profileCommonGroupsSkip: 24px;

View File

@ -1,6 +1,6 @@
AppVersion 10023
AppVersion 10024
AppVersionStrMajor 0.10
AppVersionStrSmall 0.10.23
AppVersionStr 0.10.23
AppVersionStrSmall 0.10.24
AppVersionStr 0.10.24
AlphaChannel 1
BetaVersion 0

View File

@ -66,7 +66,7 @@ In Terminal go to **/home/user/TBuild/Libraries** and run
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/3.1
git checkout release/3.2
sudo apt-get update
sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev

View File

@ -151,7 +151,7 @@ Go to **D:\\TBuild\\Libraries** and run
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/3.1
git checkout release/3.2
http://msys2.github.io/ > Download [msys2-x86_64-20150512.exe](http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20150512.exe/download) and install to **D:\\msys64**

View File

@ -69,7 +69,7 @@ In Terminal go to **/home/user/TBuild/Libraries** and run
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/3.1
git checkout release/3.2
sudo apt-get update
sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev

View File

@ -127,7 +127,7 @@ In Terminal go to **/Users/user/TBuild/Libraries** and run:
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/3.1
git checkout release/3.2
#####Building libraries

View File

@ -147,7 +147,7 @@ In Terminal go to **/Users/user/TBuild/Libraries** and run:
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/3.1
git checkout release/3.2
* Download [libiconv-1.14](http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz) from http://www.gnu.org/software/libiconv/#downloading
* Extract to **/Users/user/TBuild/Libraries** to have **/Users/user/TBuild/Libraries/ibiconv-1.14**