[haiku-commits] haiku: hrev53249 - in src: kits/media add-ons/media/plugins/ffmpeg

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 13 Jul 2019 12:14:05 -0400 (EDT)

hrev53249 adds 3 changesets to branch 'master'
old head: e1b5172126dad9dca74caa934aa01a80e37266fc
new head: ca68cae76fa7d163336c06d703ff15934ed496c6
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=ca68cae76fa7+%5Ee1b5172126da

----------------------------------------------------------------------------

9b3aa126bad2: ffmpeg AVFormatReader: some cleanups.
  
  - Stop using deprecated APIs
  - Use BMediaFormat::Clear
  - Remove hack for Protracker MOD as we have since got a MIME sniffing rule
  - Clarify some comments and fix typos
  
  Change-Id: Id495188cc44dc5af2820fe2a5236a983605b53c4
  Reviewed-on: https://review.haiku-os.org/c/1586
  Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

727e49c611a2: Media Kit: remove MediaExtractor::Source
  
  The idea was that the Media Extractor could wrap the original source
  given by BMediaTrack, but all operations on the data go through
  MediaExtractor anyway.
  We could probably move ownership of the BDataIO completely into
  MediaExtractor instead.
  
  Change-Id: I846b34b543fb983e60f6adf86cb17e835303267b
  Reviewed-on: https://review.haiku-os.org/c/1587
  Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

ca68cae76fa7: PluginManager: remove unneeded buffering.
  
  The plugin manager was attempting to buffer the IOs. However, the ffmpeg
  plugin already handles this (it reads in 64K chunks, the same size as
  the buffer here, so this buffering was effectively useless), and the
  media extractor already runs the decoding in a separate thread thanks to
  the chunk cache. So, we do not need an extra level of buffering here.
  
  We should leave any extra buffering to the upper layers (BMediaTrack or
  Media Extractor), if it's needed, as they would have much more control
  on the creation of the data io object.
  
  Change-Id: I65b67919da107c8b910dd08f8cdb8e3745af92c7
  Reviewed-on: https://review.haiku-os.org/c/1588
  Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

5 files changed, 19 insertions(+), 54 deletions(-)
headers/private/media/MediaExtractor.h           |  2 --
.../media/plugins/ffmpeg/AVFormatReader.cpp      | 21 +++++------
src/kits/media/MediaExtractor.cpp                |  7 ----
src/kits/media/MediaFile.cpp                     |  5 ++-
src/kits/media/PluginManager.cpp                 | 38 +++++---------------

############################################################################

Commit:      9b3aa126bad2698223efd8bb5b5869cabee5e8de
URL:         https://git.haiku-os.org/haiku/commit/?id=9b3aa126bad2
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Jul 12 19:44:24 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Jul 13 16:14:01 2019 UTC

ffmpeg AVFormatReader: some cleanups.

- Stop using deprecated APIs
- Use BMediaFormat::Clear
- Remove hack for Protracker MOD as we have since got a MIME sniffing rule
- Clarify some comments and fix typos

Change-Id: Id495188cc44dc5af2820fe2a5236a983605b53c4
Reviewed-on: https://review.haiku-os.org/c/1586
Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

----------------------------------------------------------------------------

diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp 
b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
index 463272c2a3..f99c080520 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
@@ -206,14 +206,14 @@ StreamBase::StreamBase(BMediaIO* source, BLocker* 
sourceLock,
        // NOTE: Don't use streamLock here, it may not yet be initialized!
 
        av_new_packet(&fPacket, 0);
-       memset(&fFormat, 0, sizeof(media_format));
+       fFormat.Clear();
 }
 
 
 StreamBase::~StreamBase()
 {
        avformat_close_input(&fContext);
-       av_free_packet(&fPacket);
+       av_packet_unref(&fPacket);
        if (fIOContext != NULL)
                av_free(fIOContext->buffer);
        av_free(fIOContext);
@@ -232,8 +232,8 @@ StreamBase::Open()
                return B_NO_MEMORY;
 
        // First try to identify the file using the MIME database, as ffmpeg
-       // (especially old versions) is not very good at this and relies on us
-       // to give it the file extension as an hint.
+       // is not very good at this and relies on us to give it the file 
extension
+       // as an hint.
        // For this we need some valid data in the buffer, the first 512 bytes
        // should do because our MIME sniffing never uses more.
        const char* extension = NULL;
@@ -247,11 +247,6 @@ StreamBase::Open()
                }
        }
 
-       // If the format is not identified, try Amiga MOD-files, because these 
do
-       // not currently have a sniffing rule.
-       if (extension == NULL)
-               extension = ".mod";
-
        // Allocate I/O context with buffer and hook functions, pass ourself as
        // cookie.
        memset(buffer, 0, bufferSize);
@@ -432,7 +427,7 @@ StreamBase::Duration() const
        fSource->GetFlags(&flags);
 
        // "Mutable Size" (ie http streams) means we can't realistically compute
-       // a duration. So don't let ffmpeg giva (wrong) estimate in this case.
+       // a duration. So don't let ffmpeg give a (wrong) estimate in this case.
        if ((flags & B_MEDIA_MUTABLE_SIZE) != 0)
                return 0;
 
@@ -841,7 +836,7 @@ StreamBase::_NextPacket(bool reuse)
                return B_OK;
        }
 
-       av_free_packet(&fPacket);
+       av_packet_unref(&fPacket);
 
        while (true) {
                if (av_read_frame(fContext, &fPacket) < 0) {
@@ -856,7 +851,7 @@ StreamBase::_NextPacket(bool reuse)
                        break;
 
                // This is a packet from another stream, ignore it.
-               av_free_packet(&fPacket);
+               av_packet_unref(&fPacket);
        }
 
        // Mark this packet with the new reuse flag.
@@ -962,7 +957,7 @@ AVFormatReader::Stream::Init(int32 virtualIndex)
 
        // initialize the media_format for this stream
        media_format* format = &fFormat;
-       memset(format, 0, sizeof(media_format));
+       format->Clear();
 
        media_format_description description;
 

############################################################################

Commit:      727e49c611a2682cca39783a687efcdad22b913e
URL:         https://git.haiku-os.org/haiku/commit/?id=727e49c611a2
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Jul 12 19:46:31 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Jul 13 16:14:01 2019 UTC

Media Kit: remove MediaExtractor::Source

The idea was that the Media Extractor could wrap the original source
given by BMediaTrack, but all operations on the data go through
MediaExtractor anyway.
We could probably move ownership of the BDataIO completely into
MediaExtractor instead.

Change-Id: I846b34b543fb983e60f6adf86cb17e835303267b
Reviewed-on: https://review.haiku-os.org/c/1587
Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

----------------------------------------------------------------------------

diff --git a/headers/private/media/MediaExtractor.h 
b/headers/private/media/MediaExtractor.h
index eeefca70bb..5f58b02d40 100644
--- a/headers/private/media/MediaExtractor.h
+++ b/headers/private/media/MediaExtractor.h
@@ -42,8 +42,6 @@ public:
 
                        status_t                        InitCheck();
 
-                       BDataIO*                        Source() const;
-
                        void                            GetFileFormatInfo(
                                                                        
media_file_format* fileFormat) const;
                        status_t                        GetMetaData(BMessage* 
_data) const;
diff --git a/src/kits/media/MediaExtractor.cpp 
b/src/kits/media/MediaExtractor.cpp
index 1241e76152..058f6afeb0 100644
--- a/src/kits/media/MediaExtractor.cpp
+++ b/src/kits/media/MediaExtractor.cpp
@@ -173,13 +173,6 @@ MediaExtractor::InitCheck()
 }
 
 
-BDataIO*
-MediaExtractor::Source() const
-{
-       return fSource;
-}
-
-
 void
 MediaExtractor::GetFileFormatInfo(media_file_format* fileFormat) const
 {
diff --git a/src/kits/media/MediaFile.cpp b/src/kits/media/MediaFile.cpp
index ffde93f9d2..0a6ba56b06 100644
--- a/src/kits/media/MediaFile.cpp
+++ b/src/kits/media/MediaFile.cpp
@@ -479,9 +479,9 @@ BMediaFile::_UnInit()
 
        if (fDeleteSource) {
                delete fSource;
-               fSource = NULL;
                fDeleteSource = false;
        }
+       fSource = NULL;
 
        // Deleting the extractor or writer can cause unloading of the plugins.
        // The source must be deleted before that, because it can come from a
@@ -523,8 +523,7 @@ BMediaFile::_InitReader(BDataIO* source, const BUrl* url, 
int32 flags)
        if (fErr != B_OK)
                return;
 
-       // Get the actual source from the extractor
-       fSource = fExtractor->Source();
+       fSource = source;
 
        fExtractor->GetFileFormatInfo(&fMFI);
        fTrackNum = fExtractor->StreamCount();

############################################################################

Revision:    hrev53249
Commit:      ca68cae76fa7d163336c06d703ff15934ed496c6
URL:         https://git.haiku-os.org/haiku/commit/?id=ca68cae76fa7
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Jul 12 19:49:19 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Jul 13 16:14:01 2019 UTC

PluginManager: remove unneeded buffering.

The plugin manager was attempting to buffer the IOs. However, the ffmpeg
plugin already handles this (it reads in 64K chunks, the same size as
the buffer here, so this buffering was effectively useless), and the
media extractor already runs the decoding in a separate thread thanks to
the chunk cache. So, we do not need an extra level of buffering here.

We should leave any extra buffering to the upper layers (BMediaTrack or
Media Extractor), if it's needed, as they would have much more control
on the creation of the data io object.

Change-Id: I65b67919da107c8b910dd08f8cdb8e3745af92c7
Reviewed-on: https://review.haiku-os.org/c/1588
Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

----------------------------------------------------------------------------

diff --git a/src/kits/media/PluginManager.cpp b/src/kits/media/PluginManager.cpp
index a6828eefae..89f786e5c6 100644
--- a/src/kits/media/PluginManager.cpp
+++ b/src/kits/media/PluginManager.cpp
@@ -86,7 +86,6 @@ public:
                fData(NULL),
                fPosition(NULL),
                fMedia(NULL),
-               fBufferIO(NULL),
                fDataIOAdapter(NULL),
                fErr(B_NO_ERROR)
        {
@@ -94,32 +93,17 @@ public:
 
                fPosition = dynamic_cast<BPositionIO*>(source);
                fMedia = dynamic_cast<BMediaIO*>(source);
-               fBufferIO = dynamic_cast<BBufferIO *>(source);
                fData = source;
 
-               // No need to do additional buffering if we have
-               // a BBufferIO or a BMediaIO.
-               if (!IsMedia() && fBufferIO == NULL) {
-                       // Source needs to be at least a BPositionIO to wrap 
with a BBufferIO
-                       if (IsPosition()) {
-                               fBufferIO = new(std::nothrow) 
BBufferIO(fPosition, 65536, false);
-                               if (fBufferIO == NULL) {
-                                       fErr = B_NO_MEMORY;
-                                       return;
-                               }
-                               // We have to reset our parents reference too
-                               fPosition = 
dynamic_cast<BPositionIO*>(fBufferIO);
-                               fData = dynamic_cast<BDataIO*>(fPosition);
-                       } else {
-                               // In this case we have to supply our own form
-                               // of pseudo-seekable object from a non-seekable
-                               // BDataIO.
-                               fDataIOAdapter = new DataIOAdapter(source);
-                               fMedia = 
dynamic_cast<BMediaIO*>(fDataIOAdapter);
-                               fPosition = 
dynamic_cast<BPositionIO*>(fDataIOAdapter);
-                               fData = dynamic_cast<BDataIO*>(fDataIOAdapter);
-                               TRACE("Unable to improve performance with a 
BufferIO\n");
-                       }
+               if (!IsPosition()) {
+                       // In this case we have to supply our own form
+                       // of pseudo-seekable object from a non-seekable
+                       // BDataIO.
+                       fDataIOAdapter = new DataIOAdapter(source);
+                       fMedia = dynamic_cast<BMediaIO*>(fDataIOAdapter);
+                       fPosition = dynamic_cast<BPositionIO*>(fDataIOAdapter);
+                       fData = dynamic_cast<BDataIO*>(fDataIOAdapter);
+                       TRACE("Unable to improve performance with a 
BufferIO\n");
                }
 
                if (IsMedia())
@@ -130,9 +114,6 @@ public:
 
        virtual ~BMediaIOWrapper()
        {
-               if (fBufferIO != NULL)
-                       delete fBufferIO;
-
                if (fDataIOAdapter != NULL)
                        delete fDataIOAdapter;
        }
@@ -212,7 +193,6 @@ private:
        BDataIO*                        fData;
        BPositionIO*            fPosition;
        BMediaIO*                       fMedia;
-       BBufferIO*                      fBufferIO;
        DataIOAdapter*          fDataIOAdapter;
 
        int32                           fFlags;


Other related posts:

  • » [haiku-commits] haiku: hrev53249 - in src: kits/media add-ons/media/plugins/ffmpeg - waddlesplash