[vlc-commits] videotoolbox: Use NSNumber instead of NSString, simplify

David Fuhrmann git at videolan.org
Mon Oct 3 12:46:18 CEST 2016


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Mon Oct  3 12:45:03 2016 +0200| [68cd94267953ad93b77700b17e31e055e817d117] | committer: David Fuhrmann

videotoolbox: Use NSNumber instead of NSString, simplify

There is no need to do number --> string --> number conversions.
Also simplify code and deindent.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=68cd94267953ad93b77700b17e31e055e817d117
---

 modules/codec/videotoolbox.m | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index b21e0cc..1e90a5d 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1257,34 +1257,28 @@ static void DecoderCallback(void *decompressionOutputRefCon,
         return;
     }
 
-    if (imageBuffer == nil)
-        return;
-
     if (infoFlags & kVTDecodeInfo_FrameDropped) {
         msg_Dbg(p_dec, "decoder dropped frame");
-        if (imageBuffer != nil)
+        if (imageBuffer)
             CFRelease(imageBuffer);
-        imageBuffer = nil;
         return;
     }
 
-    NSString *timeStamp = nil;
+    if (!imageBuffer)
+        return;
 
-    if (CMTIME_IS_VALID(pts))
-        timeStamp = [[NSNumber numberWithLongLong:pts.value] stringValue];
-    else {
+    if (!CMTIME_IS_VALID(pts)) {
         msg_Dbg(p_dec, "invalid timestamp, dropping frame");
         CFRelease(imageBuffer);
         return;
     }
 
-    if (timeStamp) {
-        id imageBufferObject = (__bridge id)imageBuffer;
-        @synchronized(p_sys->outputTimeStamps) {
-            [p_sys->outputTimeStamps addObject:timeStamp];
-        }
-        @synchronized(p_sys->outputFrames) {
-            [p_sys->outputFrames setObject:imageBufferObject forKey:timeStamp];
-        }
+    NSNumber *timeStamp = [NSNumber numberWithLongLong:pts.value];
+    id imageBufferObject = (__bridge id)imageBuffer;
+    @synchronized(p_sys->outputTimeStamps) {
+        [p_sys->outputTimeStamps addObject:timeStamp];
+    }
+    @synchronized(p_sys->outputFrames) {
+        [p_sys->outputFrames setObject:imageBufferObject forKey:timeStamp];
     }
 }



More information about the vlc-commits mailing list