瀏覽代碼

thumbnailer: update for libvlc 3.0 vmem

(cherry picked from commit 838f2598df0f827caca4e02ac726f580c5d32099)
Felix Paul Kühne 9 年之前
父節點
當前提交
44a7ffd454
共有 1 個文件被更改,包括 15 次插入11 次删除
  1. 15 11
      Sources/VLCMediaThumbnailer.m

+ 15 - 11
Sources/VLCMediaThumbnailer.m

@@ -68,11 +68,15 @@ static const long long kStandardStartTime = 150000;
 
 void unlock(void *opaque, void *picture, void *const *p_pixels)
 {
+    (void)picture;
+    (void)p_pixels;
+}
+
+static void display(void *opaque, void *picture)
+{
     VLCMediaThumbnailer *thumbnailer = (__bridge VLCMediaThumbnailer *)(opaque);
     assert(!picture);
 
-    assert([thumbnailer dataPointer] == *p_pixels);
-
     // We may already have a thumbnail if we are receiving picture after the first one.
     // Just ignore.
     if ([thumbnailer thumbnail] || [thumbnailer shouldRejectFrames])
@@ -141,7 +145,7 @@ void unlock(void *opaque, void *picture, void *const *p_pixels)
 
     if (![_media isParsed]) {
         [_media addObserver:self forKeyPath:@"parsed" options:0 context:NULL];
-        [_media synchronousParse];
+        [_media parseWithOptions:VLCMediaParseLocal];
         NSAssert(!_parsingTimeoutTimer, @"We already have a timer around");
         _parsingTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(mediaParsingTimedOut) userInfo:nil repeats:NO];
         return;
@@ -168,13 +172,8 @@ void unlock(void *opaque, void *picture, void *const *p_pixels)
     unsigned imageHeight = _thumbnailHeight > 0 ? _thumbnailHeight : kDefaultImageHeight;
     float snapshotPosition = _snapshotPosition > 0 ? _snapshotPosition : kSnapshotPosition;
 
-    if (!videoTrack) {
-        VKLog(@"WARNING: Can't find video track info, skipping file");
-        [_parsingTimeoutTimer invalidate];
-        _parsingTimeoutTimer = nil;
-        [self mediaThumbnailingTimedOut];
-        return;
-    } else {
+    /* optimize rendering if we know what's ahead, if not, well not too bad either */
+    if (videoTrack) {
         int videoHeight = [videoTrack[VLCMediaTracksInformationVideoHeight] intValue];
         int videoWidth = [videoTrack[VLCMediaTracksInformationVideoWidth] intValue];
 
@@ -206,10 +205,15 @@ void unlock(void *opaque, void *picture, void *const *p_pixels)
 
     libvlc_media_add_option([_media libVLCMediaDescriptor], "no-audio");
     libvlc_media_add_option([_media libVLCMediaDescriptor], "no-videotoolbox-zero-copy");
+    libvlc_media_add_option([_media libVLCMediaDescriptor], "avcodec-threads=1");
+    libvlc_media_add_option([_media libVLCMediaDescriptor], "avcodec-skip-idct=4");
+    libvlc_media_add_option([_media libVLCMediaDescriptor], "avcodec-skiploopfilter=3");
+    libvlc_media_add_option([_media libVLCMediaDescriptor], "deinterlace=-1");
+    libvlc_media_add_option([_media libVLCMediaDescriptor], "avi-index=3");
 
     libvlc_media_player_set_media(_mp, [_media libVLCMediaDescriptor]);
     libvlc_video_set_format(_mp, "RGBA", imageWidth, imageHeight, 4 * imageWidth);
-    libvlc_video_set_callbacks(_mp, lock, unlock, NULL, (__bridge void *)(self));
+    libvlc_video_set_callbacks(_mp, lock, unlock, display, (__bridge void *)(self));
     if (snapshotPosition == kSnapshotPosition) {
         int length = _media.length.intValue;
         if (length < kStandardStartTime) {