Fix compilation with older ffmpeg.

Fix compilation under 32bits.
This commit is contained in:
codestation
2013-09-02 14:38:07 -04:30
parent db576350ce
commit 7c83b86ca8
4 changed files with 23 additions and 14 deletions

View File

@@ -129,18 +129,24 @@ void AVDecoder::getPictureMetadata(metadata_t &metadata)
QByteArray AVDecoder::getAudioThumbnail(int width, int height)
{
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;
QBuffer imgbuffer(&data);
imgbuffer.open(QIODevice::WriteOnly);
QImage img = QImage::fromData(QByteArray((const char *)pkt.data, pkt.size));
QImage result = img.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
result.save(&imgbuffer, "JPEG");
break;
}
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);
imgbuffer.open(QIODevice::WriteOnly);
QImage img = QImage::fromData(QByteArray((const char *)pkt.data, pkt.size));
QImage result = img.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
result.save(&imgbuffer, "JPEG");
}
return data;
}

View File

@@ -27,6 +27,7 @@ extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/mathematics.h>
}
#include <vitamtp.h>

View File

@@ -20,6 +20,8 @@
#include "cmaevent.h"
#include "utils.h"
#include <inttypes.h>
#include <QDateTime>
#include <QDebug>
#include <QDir>
@@ -683,7 +685,7 @@ void CmaEvent::vitaEventSendPartOfObject(vita_event_t *event, int eventId)
} else {
file.seek(part_init.offset);
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) {
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;
}
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);
if(!file.open(QIODevice::ReadWrite)) {
@@ -820,7 +822,7 @@ void CmaEvent::vitaEventGetPartOfObject(vita_event_t *event, int eventId)
file.seek(part_init.offset);
file.write((const char *)data, 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);
}

View File

@@ -58,7 +58,7 @@ HEADERS += \
CONFIG += link_pkgconfig
PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale
QMAKE_CXXFLAGS += -Wno-write-strings -Wall
QMAKE_CXXFLAGS += -Wno-write-strings -Wall -D__STDC_CONSTANT_MACROS
RESOURCES += \
qcmares.qrc