Commit 44a7ffd4 authored by Felix Paul Kühne's avatar Felix Paul Kühne

thumbnailer: update for libvlc 3.0 vmem

(cherry picked from commit 838f2598)
parent 605f2689
......@@ -67,12 +67,16 @@ static const float kSnapshotPosition = 0.3;
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment