Fix compilation with older ffmpeg.
Fix compilation under 32bits.
This commit is contained in:
@@ -129,18 +129,24 @@ void AVDecoder::getPictureMetadata(metadata_t &metadata)
|
|||||||
QByteArray AVDecoder::getAudioThumbnail(int width, int height)
|
QByteArray AVDecoder::getAudioThumbnail(int width, int height)
|
||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
for (uint i = 0; i < pFormatCtx->nb_streams; i++) {
|
|
||||||
if(pFormatCtx->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
|
|
||||||
AVPacket pkt = pFormatCtx->streams[i]->attached_pic;
|
|
||||||
|
|
||||||
|
int stream_index;
|
||||||
|
AVCodec *codec = NULL;
|
||||||
|
if((stream_index = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0)) < 0) {
|
||||||
|
// no thumbnail
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVPacket pkt;
|
||||||
|
if(av_read_frame(pFormatCtx, &pkt) >= 0) {
|
||||||
|
// first frame == first thumbnail (hopefully)
|
||||||
QBuffer imgbuffer(&data);
|
QBuffer imgbuffer(&data);
|
||||||
imgbuffer.open(QIODevice::WriteOnly);
|
imgbuffer.open(QIODevice::WriteOnly);
|
||||||
QImage img = QImage::fromData(QByteArray((const char *)pkt.data, pkt.size));
|
QImage img = QImage::fromData(QByteArray((const char *)pkt.data, pkt.size));
|
||||||
QImage result = img.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QImage result = img.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
result.save(&imgbuffer, "JPEG");
|
result.save(&imgbuffer, "JPEG");
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ extern "C" {
|
|||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
|
#include <libavutil/mathematics.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <vitamtp.h>
|
#include <vitamtp.h>
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
#include "cmaevent.h"
|
#include "cmaevent.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -683,7 +685,7 @@ void CmaEvent::vitaEventSendPartOfObject(vita_event_t *event, int eventId)
|
|||||||
} else {
|
} else {
|
||||||
file.seek(part_init.offset);
|
file.seek(part_init.offset);
|
||||||
QByteArray data = file.read(part_init.size);
|
QByteArray data = file.read(part_init.size);
|
||||||
qDebug("Sending %s at file offset %zu for %zu bytes", object->metadata.path, part_init.offset, part_init.size);
|
qDebug("Sending %s at file offset %"PRIu64" for %"PRIu64" bytes", object->metadata.path, part_init.offset, part_init.size);
|
||||||
|
|
||||||
if(VitaMTP_SendPartOfObject(device, eventId, (unsigned char *)data.data(), data.size()) != PTP_RC_OK) {
|
if(VitaMTP_SendPartOfObject(device, eventId, (unsigned char *)data.data(), data.size()) != PTP_RC_OK) {
|
||||||
qWarning("Failed to send part of object OHFI %d", part_init.ohfi);
|
qWarning("Failed to send part of object OHFI %d", part_init.ohfi);
|
||||||
@@ -810,7 +812,7 @@ void CmaEvent::vitaEventGetPartOfObject(vita_event_t *event, int eventId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Receiving %s at offset %zu for %zu bytes", object->metadata.path, part_init.offset, part_init.size);
|
qDebug("Receiving %s at offset %"PRIu64" for %"PRIu64" bytes", object->metadata.path, part_init.offset, part_init.size);
|
||||||
|
|
||||||
QFile file(object->path);
|
QFile file(object->path);
|
||||||
if(!file.open(QIODevice::ReadWrite)) {
|
if(!file.open(QIODevice::ReadWrite)) {
|
||||||
@@ -820,7 +822,7 @@ void CmaEvent::vitaEventGetPartOfObject(vita_event_t *event, int eventId)
|
|||||||
file.seek(part_init.offset);
|
file.seek(part_init.offset);
|
||||||
file.write((const char *)data, part_init.size);
|
file.write((const char *)data, part_init.size);
|
||||||
object->updateObjectSize(part_init.size);
|
object->updateObjectSize(part_init.size);
|
||||||
qDebug("Written %zu bytes to %s at offset %zu.", part_init.size, object->path.toStdString().c_str(), part_init.offset);
|
qDebug("Written %zu bytes to %s at offset %"PRIu64, part_init.size, object->path.toStdString().c_str(), part_init.offset);
|
||||||
VitaMTP_ReportResult(device, eventId, PTP_RC_OK);
|
VitaMTP_ReportResult(device, eventId, PTP_RC_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
qcma.pro
2
qcma.pro
@@ -58,7 +58,7 @@ HEADERS += \
|
|||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale
|
PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -Wno-write-strings -Wall
|
QMAKE_CXXFLAGS += -Wno-write-strings -Wall -D__STDC_CONSTANT_MACROS
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
qcmares.qrc
|
qcmares.qrc
|
||||||
|
Reference in New Issue
Block a user