forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dec: remove deprecated AVDecoder.decode(QByteArray)
- Loading branch information
Showing
6 changed files
with
13 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -40,18 +40,17 @@ class AudioDecoderFFmpeg : public AudioDecoder | |
Q_PROPERTY(QString codecName READ codecName WRITE setCodecName NOTIFY codecNameChanged) | ||
public: | ||
AudioDecoderFFmpeg(); | ||
AudioDecoderId id() const Q_DECL_FINAL; | ||
virtual QString description() const Q_DECL_FINAL { | ||
AudioDecoderId id() const Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
virtual QString description() const Q_DECL_OVERRIDE Q_DECL_FINAL { | ||
const int patch = QTAV_VERSION_PATCH(avcodec_version()); | ||
return QStringLiteral("%1 avcodec %2.%3.%4") | ||
.arg(patch>=100?QStringLiteral("FFmpeg"):QStringLiteral("Libav")) | ||
.arg(QTAV_VERSION_MAJOR(avcodec_version())).arg(QTAV_VERSION_MINOR(avcodec_version())).arg(patch); | ||
} | ||
bool decode(const QByteArray &encoded) Q_DECL_FINAL; | ||
bool decode(const Packet& packet) Q_DECL_FINAL; | ||
AudioFrame frame() Q_DECL_FINAL; | ||
bool decode(const Packet& packet) Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
AudioFrame frame() Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
Q_SIGNALS: | ||
void codecNameChanged(); | ||
void codecNameChanged() Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
}; | ||
|
||
AudioDecoderId AudioDecoderId_FFmpeg = mkid::id32base36_6<'F','F','m','p','e','g'>::value; | ||
|
@@ -128,54 +127,6 @@ bool AudioDecoderFFmpeg::decode(const Packet &packet) | |
return !d.decoded.isEmpty(); | ||
} | ||
|
||
// | ||
bool AudioDecoderFFmpeg::decode(const QByteArray &encoded) | ||
{ | ||
if (!isAvailable()) | ||
return false; | ||
DPTR_D(AudioDecoderFFmpeg); | ||
d.decoded.clear(); | ||
AVPacket packet; | ||
#if NO_PADDING_DATA | ||
/*! | ||
larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end. | ||
The end of the input buffer avpkt->data should be set to 0 to ensure that no overreading happens for damaged MPEG streams | ||
*/ | ||
// auto released by av_buffer_default_free | ||
av_new_packet(&packet, encoded.size()); | ||
memcpy(packet.data, encoded.data(), encoded.size()); | ||
#else | ||
av_init_packet(&packet); | ||
packet.size = encoded.size(); | ||
packet.data = (uint8_t*)encoded.constData(); | ||
#endif //NO_PADDING_DATA | ||
int got_frame_ptr = 0; | ||
int ret = avcodec_decode_audio4(d.codec_ctx, d.frame, &got_frame_ptr, &packet); | ||
d.undecoded_size = qMin(encoded.size() - ret, encoded.size()); | ||
av_free_packet(&packet); | ||
if (ret == AVERROR(EAGAIN)) { | ||
return false; | ||
} | ||
if (ret < 0) { | ||
qWarning("[AudioDecoder] %s", av_err2str(ret)); | ||
return false; | ||
} | ||
if (!got_frame_ptr) { | ||
qWarning("[AudioDecoder] got_frame_ptr=false. decoded: %d, un: %d", ret, d.undecoded_size); | ||
return true; | ||
} | ||
#if USE_AUDIO_FRAME | ||
return true; | ||
#endif | ||
d.resampler->setInSampesPerChannel(d.frame->nb_samples); | ||
if (!d.resampler->convert((const quint8**)d.frame->extended_data)) { | ||
return false; | ||
} | ||
d.decoded = d.resampler->outData(); | ||
return true; | ||
return !d.decoded.isEmpty(); | ||
} | ||
|
||
AudioFrame AudioDecoderFFmpeg::frame() | ||
{ | ||
DPTR_D(AudioDecoderFFmpeg); | ||
|
@@ -187,6 +138,7 @@ AudioFrame AudioDecoderFFmpeg::frame() | |
return AudioFrame(); | ||
} | ||
AudioFrame f(fmt); | ||
//av_frame_get_pkt_duration ffmpeg | ||
f.setBits(d.frame->extended_data); // TODO: ref | ||
f.setBytesPerLine(d.frame->linesize[0], 0); // for correct alignment | ||
f.setSamplesPerChannel(d.frame->nb_samples); | ||
|
@@ -197,5 +149,4 @@ AudioFrame AudioDecoderFFmpeg::frame() | |
} | ||
|
||
} //namespace QtAV | ||
|
||
#include "AudioDecoderFFmpeg.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2013-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
Miroslav Bendik <[email protected]> | ||
* This file is part of QtAV | ||
* This file is part of QtAV (from 2013) | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
|
@@ -65,7 +65,6 @@ class VideoDecoderCedarv : public VideoDecoder | |
QString description() const Q_DECL_OVERRIDE Q_DECL_FINAL{ | ||
return QStringLiteral("Allwinner A10 CedarX video hardware acceleration"); | ||
} | ||
bool decode(const QByteArray &encoded) Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
bool decode(const Packet& packet) Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
VideoFrame frame() Q_DECL_OVERRIDE Q_DECL_FINAL; | ||
|
||
|
@@ -384,47 +383,6 @@ bool VideoDecoderCedarvPrivate::open() | |
return true; | ||
} | ||
|
||
bool VideoDecoderCedarv::decode(const QByteArray &encoded) | ||
{ | ||
DPTR_D(VideoDecoderCedarv); | ||
if (encoded.isEmpty()) | ||
return true; | ||
//d.cedarv->ioctrl(d.cedarv, CEDARV_COMMAND_JUMP, 0); | ||
u32 bufsize0, bufsize1; | ||
u8 *buf0, *buf1; | ||
int ret = d.cedarv->request_write(d.cedarv, encoded.size(), &buf0, &bufsize0, &buf1, &bufsize1); | ||
if (ret < 0) { | ||
qWarning("CedarV: request_write failed (%d)", ret); | ||
return false; | ||
} | ||
memcpy(buf0, encoded.constData(), bufsize0); | ||
if ((u32)encoded.size() > bufsize0) | ||
memcpy(buf1, encoded.constData() + bufsize0, bufsize1); | ||
cedarv_stream_data_info_t stream_data_info; | ||
stream_data_info.type = 0; | ||
stream_data_info.lengh = encoded.size(); | ||
stream_data_info.pts = 0; //packet.pts; | ||
stream_data_info.flags = CEDARV_FLAG_FIRST_PART | CEDARV_FLAG_LAST_PART | CEDARV_FLAG_PTS_VALID; | ||
if ((ret = d.cedarv->update_data(d.cedarv, &stream_data_info)) < 0) { | ||
qWarning("CedarV: update_data failed (%d)", ret); | ||
return false; | ||
} | ||
if ((ret = d.cedarv->decode(d.cedarv)) < 0) { | ||
qWarning("CedarV: decode failed (%d)", ret); | ||
return false; | ||
} | ||
ret = d.cedarv->display_request(d.cedarv, &d.cedarPicture); | ||
if (ret > 3 || ret < 0) { | ||
qWarning("CedarV: display_request failed (%d)", ret); | ||
if (d.cedarPicture.id) { | ||
d.cedarv->display_release(d.cedarv, d.cedarPicture.id); | ||
d.cedarPicture.id = 0; | ||
} | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool VideoDecoderCedarv::decode(const Packet &packet) | ||
{ | ||
DPTR_D(VideoDecoderCedarv); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2014-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
* This file is part of QtAV (from 2014) | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
|
@@ -34,7 +34,6 @@ class VideoDecoderFFmpegBase : public VideoDecoder | |
Q_DISABLE_COPY(VideoDecoderFFmpegBase) | ||
DPTR_DECLARE_PRIVATE(VideoDecoderFFmpegBase) | ||
public: | ||
QTAV_DEPRECATED virtual bool decode(const QByteArray &encoded) Q_DECL_OVERRIDE; | ||
virtual bool decode(const Packet& packet) Q_DECL_OVERRIDE; | ||
protected: | ||
VideoDecoderFFmpegBase(VideoDecoderFFmpegBasePrivate &d); | ||
|