Switching to Av libs to handle cover pictures

This commit is contained in:
emeric
2014-03-13 13:52:16 +01:00
parent 7fb9b5bd1d
commit 507a3bdaae
11 changed files with 82 additions and 31 deletions
+5
View File
@@ -2,6 +2,9 @@
#include <boost/array.hpp>
namespace Av
{
std::string
AvError::to_str(void) const
{
@@ -27,3 +30,5 @@ void AvInit()
av_register_all();
std::cout << "AVCDOEC VERSION = " << avcodec_version() << std::endl;
}
} // namespace Av
+4
View File
@@ -17,6 +17,9 @@ extern "C" {
#include <string>
namespace Av
{
void AvInit();
@@ -40,5 +43,6 @@ class AvError
int _errnum;
};
} // namespace Av
#endif
+18
View File
@@ -96,4 +96,22 @@ InputFormatContext::getMetadata(void)
}
void
InputFormatContext::getPictures(std::vector< std::vector<unsigned char> >& pictures) const
{
for (std::size_t i = 0; i < native()->nb_streams; ++i)
{
if (native()->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)
{
std::cout << "Found album art..." << std::endl;
AVPacket pkt = native()->streams[i]->attached_pic;
std::vector<unsigned char> data;
std::copy(pkt.data, pkt.data + pkt.size, std::back_inserter(data));
pictures.push_back( data );
}
}
}
} //namespace Av
+7 -3
View File
@@ -25,11 +25,15 @@ class InputFormatContext : public FormatContext
// Scan file
void findStreamInfo();
std::vector<Stream> getStreams(void);
bool getBestStreamIdx(enum AVMediaType type, Stream::Idx& idx);
// Get attached pictures
void getPictures(std::vector< std::vector<unsigned char> >& pictures) const;
std::size_t getDurationSecs() const;
// Get the streams
std::vector<Stream> getStreams(void);
bool getBestStreamIdx(enum AVMediaType type, Stream::Idx& idx);
std::size_t getDurationSecs() const;
private:
boost::filesystem::path _path;
+6
View File
@@ -23,4 +23,10 @@ Stream::getMetadata(void)
return Dictionary(_stream->metadata);
}
bool
Stream::hasAttachedPic(void) const
{
return (_stream->disposition & AV_DISPOSITION_ATTACHED_PIC);
}
} // namespace Av
+1
View File
@@ -21,6 +21,7 @@ class Stream
// Idx getIdx() const { return _stream->index; }
bool hasAttachedPic(void) const;
Dictionary getMetadata(void);
CodecContext getCodecContext(void);