Upgrade to Pro — share decks privately, control downloads, hide ads and more …

配信アプリのためのリアルタイムプッシュ通知ぼかしの夢

naru-jpn
September 02, 2023

 配信アプリのためのリアルタイムプッシュ通知ぼかしの夢

naru-jpn

September 02, 2023
Tweet

More Decks by naru-jpn

Other Decks in Programming

Transcript

  1. ഑৴ΞϓϦͷͨΊͷ
    ϦΞϧλΠϜϓογϡ௨஌΅͔͠ͷເ
    ʙ௿ෛՙͰߴ଎ͳϓϥΠόγʔอޢΛ໨ࢦͯ͠ʙ
    🌟
    🌟

    View full-size slide

  2. /BSVLJ$IJHJSB
    גࣜձࣾϛϥςΟϒ
    !@OBSV@KQO
    OBSVKQO

    View full-size slide

  3. ϛϥςΟϒ͸ϞόΠϧ୺຤͚ͩͰखܰʹ഑৴͕Ͱ͖ΔΞϓϦ🌟
    ୺຤ͷը໘ͷө૾͕
    ͦͷ··ࢹௌऀʹಧ͘ʂ
    📱
    ഑৴ऀ
    📱
    ࢹௌऀ

    View full-size slide

  4. ͔͠͠ɺϓογϡ௨஌ʹΑͬͯ
    ೔ৗͷ΍ΓͱΓͳͲ͕өΓࠐΜͰ͠·͏৔߹΋͋Δ
    ϝʔϧ΍ϦϚΠϯμͳͲͷ಺༰͕
    ഑৴ʹөΓࠐΜͰ͠·͏
    📱
    ഑৴ऀ
    📱
    ࢹௌऀ

    View full-size slide

  5. ࠓճ͓࿩͢͠ΔϦΞϧλΠϜϓογϡ௨஌΅͔͠ͱ͸
    📱
    ഑৴ऀ
    📱
    ࢹௌऀ
    ഑৴αʔόʔ
    􀪹
    ഑৴ऀͷ୺຤Ͱө૾Λௐ΂ɺϓογϡ௨஌Λݕग़͠
    ө૾ΛՃ޻͔ͯ͠Β഑৴αʔόʔʹૹΔ

    View full-size slide

  6. աڈ
    ʹ΋ಉ༷ͷ௅ઓ͕͋Γ·ͨ͠
    .JSSBUJW5FDI#MPH
    .JSSBUJWʹ͓͚Δϓογϡ௨஌΅͔͠΁ͷ௅ઓ
    ɾॲཧͷύϑΥʔϚϯεʹ՝୊͕͋ͬͨ
    ɾ04ͷΞοϓσʔτͰ௨஌ͷΞχϝʔγϣϯ͸มΘΓɺγϟυ
    ΢΋ബ͘ͳΓ೉қ౓্͕͕͍ͬͯΔ

    View full-size slide

  7. αʔόʔαΠυͰݱࡏՔಇ͍ͯ͠ΔγεςϜ΋͋Γ·͢
    ઌ೔ͷ(P$POGFSFODFͰ΋(P$HPͰө૾ɾԻ੠ͷϦΞϧλΠ
    ϜॲཧΛ΍Δ·ͰͷಓͷΓͱ͍͏λΠτϧͰ͓࿩͠͞Ε͍ͯ·͢
    .JSSBUJW5FDI#MPH
    NTҎԼͷϦΞϧλΠϜΦϒδΣΫτݕग़ը૾ॲཧΛ໨ࢦͯ͠
    (Pͷ഑৴αʔόαΠυͰ௨஌΅͔͠Λ࣮૷ͯ͠Έͨ͜ͱ

    View full-size slide

  8. ࠓճͷϦΞϧλΠϜϓογϡ௨஌΅͔͠ͷओࢫ
    ΫϥΠΞϯτͰݕग़ͱՃ޻Λߦͬͨ৔߹ʹ
    ࣮༻ʹ଍Δਫ਼౓ͱύϑΥʔϚϯεΛୡ੒Ͱ͖Δ͔
    ٕज़తʹݕূΛ͠ɺՄೳੑΛ୳Δ
    ΞϓϦΞΠίϯͷൺֱͳͲɺΫϥΠΞϯτͰͳ͍ͱ࣮ݱ͕೉͍͠ॲཧ΋͋Δ

    View full-size slide

  9. ࣮ࡍͷಈ͖

    View full-size slide

  10. ഑৴ऀ
    ࢹௌऀ

    View full-size slide

  11. ഑৴ऀ
    ࢹௌऀ

    View full-size slide

  12. ௨஌΅͔͠ͷཁ݅
    ɾϓογϡ௨஌ͷܗঢ়Λݕग़ͨ͠Βɺ഑৴୺຤ଆͰө૾ΛՃ޻͢Δ
    ɹɾͨͩ͠ɺϛϥςΟϒ͔Βͷ௨஌͸Ճ޻͠ͳ͍
    ɹɾ୺຤ͷճసʹରԠ͢Δ
    ɹɾμʔΫϞʔυʹରԠ͢Δ
    ɾϦΞϧλΠϜͷॲཧʹ଱͑ΔύϑΥʔϚϯεΛग़͢

    View full-size slide

  13. ௨஌΅͔͠ͷཁ݅
    ɾϓογϡ௨஌ͷܗঢ়Λݕग़ͨ͠Βɺ഑৴୺຤ଆͰө૾ΛՃ޻͢Δ
    ɹɾͨͩ͠ɺϛϥςΟϒ͔Βͷ௨஌͸Ճ޻͠ͳ͍
    ɹɾ୺຤ͷճసʹରԠ͢Δ
    ɹɾμʔΫϞʔυʹରԠ͢Δ
    ɾϦΞϧλΠϜͷॲཧʹ଱͑ΔύϑΥʔϚϯε < 33ms
    Λग़͢

    View full-size slide

  14. J04ʹ͓͚Δը໘࿥ըͱө૾ͷܗࣜΛ஌Δ
    "DDFMFSBUFGSBNFXPSLΛ஌Δ

    View full-size slide

  15. J04ʹ͓͚Δը໘࿥ըͱө૾ͷܗࣜΛ஌Δ
    "DDFMFSBUFGSBNFXPSLΛ஌Δ

    View full-size slide

  16. #SPBEDBTU6QMPBE&YUFOTJPO

    View full-size slide

  17. override func processSampleBuffer(
    _ sampleBuffer: CMSampleBuffer,
    with sampleBufferType: RPSampleBufferType
    ) {
    switch sampleBufferType {
    case RPSampleBufferType.video:
    break
    case RPSampleBufferType.audioApp:
    break
    case RPSampleBufferType.audioMic:
    break
    @unknown default:
    fatalError("Unknown type of sample buffer")
    }
    }
    4BNQMF)BOEMFSTXJGU

    View full-size slide

  18. override func processSampleBuffer(
    _ sampleBuffer: CMSampleBuffer,
    with sampleBufferType: RPSampleBufferType
    ) {
    switch sampleBufferType {
    case RPSampleBufferType.video:
    break
    case RPSampleBufferType.audioApp:
    break
    case RPSampleBufferType.audioMic:
    break
    @unknown default:
    fatalError("Unknown type of sample buffer")
    }
    }
    4BNQMF)BOEMFSTXJGU

    View full-size slide

  19. override func processSampleBuffer(
    _ sampleBuffer: CMSampleBuffer,
    with sampleBufferType: RPSampleBufferType
    ) {
    switch sampleBufferType {
    case RPSampleBufferType.video:
    break
    ॲཧ࣌ؒͱ࢖༻ϝϞϦͷ੍໿
    ͜ͷؔ਺͸ܧଓతʹݺ͹Εɺಈը΍Ի੠ʹରԠ͢ΔTBNQMF#VGGFS͕ڙڅ͞ΕΔ
    ಈը͕'14ͱ͢Δͱɺඵؒʹճݺ͹ΕΔʢ໿NTִؒʣ
    ϝϞϦ࢖༻ྔ͸؂ࢹ͞Ε͍ͯͯɺ.#Λ௒͑Δͱϓϩηε͕ऴྃ͢Δ

    View full-size slide

  20. case RPSampleBufferType.video:
    let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!
    let pixelFormatType = CVPixelBufferGetPixelFormatType(imageBuffer)
    // pixelFormatType == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
    TBNQMF#VGGFS͔ΒಈըͷϑϨʔϜʹ૬౰͢ΔJNBHF#VGGFSΛऔಘͯ͠
    ϑΥʔϚοτΛௐ΂Δ
    L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHF

    View full-size slide

  21. ·ͣ͸਌͠Έͷ͋ΔL$71JYFM'PSNBU5ZQF@"3(#ͷߏ଄Λ஌Δ

    View full-size slide

  22. 0 1 2
    3 4 5
    6 7 8

    View full-size slide

  23. L$71JYFM'PSNBU5ZQF@"3(#͸
    6*OUͷ஋͕" 3 ( #ͷॱʹฒΜͰ͍Δ
    6*OU
    [

    A0, R0, G0, B0, A1, R1, G1, B1, A2, R2, G2, B2, …
    A3, R3, G3, B3, A4, R4, G4, B4, A5, R5, G5, B5, …
    A6, R6, G6, B6, A7, R7, G7, B7, A8, R8, G8, B8, …

    ]
    0 1 2
    3 4 5
    6 7 8

    View full-size slide

  24. // (0,0) Λࢦ͢ΞυϨε
    let address = CVPixelBufferGetBaseAddress(imageBuffer)
    // ઌ಄ͷϐΫηϧ͔Β ARGB ͷॱͰ৭৘ใ͕֨ೲ͞Ε͍ͯΔ
    let arbg = address!.assumingMemoryBound(to: UInt8.self)
    let a_0_0 = arbg[0] // A
    let r_0_0 = arbg[1] // R
    let g_0_0 = arbg[2] // G
    let b_0_0 = arbg[3] // B
    let a_1_0 = arbg[4] // A
    L$71JYFM'PSNBU5ZQF@"3(#ܗࣜͷ
    ը૾σʔλͷઌ಄ΞυϨεΛऔಘͯ͠ɺըૉʹΞΫηε͢Δ

    View full-size slide

  25. L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHFͷߏ଄Λ஌Δ

    View full-size slide

  26. L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHF͸
    ً౓ :
    ɾ৭ࠩ $C$S
    ͷͭͷฏ໘͔Βߏ੒͞Ε͍ͯΔ
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘
    ը໘දࣔ

    View full-size slide

  27. ً౓ :
    ฏ໘͸ϐΫηϧͷً౓ʹରԠ͢Δ
    6*OUͷ஋ d
    ͕ॱʹฒΜͰ͍Δ
    6*OU
    […
    Y0, Y1, Y2, Y3,…
    Y4, Y5, Y6, Y7,…
    Y8, Y9, Y10, Y11,…
    Y12, Y13, Y14, Y15,…
    …]
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15

    View full-size slide

  28. ৭ࠩ $C$S
    ฏ໘Ͱ͸ɺ$Cͱ$Sͷ૊Έ߹ΘͤͰ৭Λදݱ͢Δ
    ˞ը૾͸IUUQTKBXJLJQFEJBPSHXJLJ:67ΑΓҾ༻
    ࣅͨߏ੒ͷ67৭ฏ໘ͷྫʢ:ͷ৔߹ʣ

    View full-size slide

  29. ৭ࠩ $C$S
    ฏ໘͸6*OUͷ஋ d
    ͕$C $SͷॱʹฒΜͰ͍Δ
    0 1
    2 3
    6*OU
    […
    Cb0, Cr0, Cb1, Cr1,…
    Cb2, Cr2, Cb3, Cr3,…
    …]

    View full-size slide

  30. L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHFͰ͸
    ৭ࠩ $C$S
    ฏ໘ͷղ૾౓͸ɺً౓ :
    ฏ໘ͷ൒෼Ͱ͋Δ
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘
    ը໘දࣔ

    View full-size slide

  31. ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘

    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    0 1
    2 3
    L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHFͰ͸
    ৭ࠩ $C$S
    ฏ໘ͷղ૾౓͸ɺً౓ :
    ฏ໘ͷ൒෼Ͱ͋Δ
    ը໘දࣔ

    View full-size slide

  32. ը໘දࣔ
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘

    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    0 1
    2 3
    ը໘දࣔ : $C $S

    View full-size slide

  33. ը໘දࣔ
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘

    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    0 1
    2 3
    ը໘දࣔ : $C $S

    View full-size slide

  34. ը໘දࣔ
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘

    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
    0 1
    2 3
    ը໘දࣔ : $C $S

    View full-size slide

  35. L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHFܗࣜͷ
    ֤ฏ໘ͷઌ಄ΞυϨεΛऔಘ͢Δ
    // ً౓(Y)ฏ໘ͷઌ಄Λࢦ͢ΞυϨε
    let address0 = CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0)
    // ৭ࠩ(CbCr)ฏ໘ͷઌ಄Λࢦ͢ΞυϨε
    let address1 = CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1)

    View full-size slide

  36. ɾ"3(#ܗࣜͷํ͕௚ײతͰѻ͍΍͍͢
    ɾ3FQMBZ,JU͔Β໯͑Δͷ͸:Q$C$S#J1MBOBS'VMM3BOHFܗࣜ
    ɾ:Q$C$S#J1MBOBS'VMM3BOHFܗࣜ͸"3(#ܗࣜʹม׵͢Δ͜ͱ͕Ͱ͖Δ
    ɹɾ͔͠͠ɺม׵ʹ͸ϝϞϦͱܭࢉͷίετ͕͔͔Δʜ
    ɹɹɾϝϞϦɿը໘ճస΋ߟྀ͢Δͱɺݩσʔλͱಉ͚ͩ͡ͷ༰ྔ͕ඞཁ
    ɹɹɾܭࢉɿݩσʔλͷ͢΂ͯͷըૉͷม׵͕ඞཁ
    ɹɾม׵͠ͳ͚Ε͹ɺܭࢉʹඞཁͳϕΫτϧ෼͚ͩͷϝϞϦΛ֬อ͢Ε͹े෼
    ˠ:Q$C$S#J1MBOBS'VMM3BOHFܗࣜͷ··ܭࢉ͢ΔಓΛબΜͩ

    View full-size slide

  37. J04ʹ͓͚Δը໘࿥ըͱө૾ͷܗࣜΛ஌Δ
    "DDFMFSBUFGSBNFXPSLΛ஌Δ

    View full-size slide

  38. "DDFMFSBUFGSBNFXPSLʹؚ·Ε͍ͯΔϥΠϒϥϦ
    ɾ#//4ɿχϡʔϥϧωοτϫʔΫ
    ɾW%41ɿσδλϧ৴߸ॲཧ
    ɾW*NBHFɿը૾Ճ޻
    ɾW'PSDFɿߦྻͱ௒ӽؔ਺
    ɾ4QBSTF4PMWFST #-"4 BOE-"1"$,ɿߦྻܭࢉ

    View full-size slide

  39. ɾ#//4ɿχϡʔϥϧωοτϫʔΫ
    ɾW%41ɿσδλϧ৴߸ॲཧ
    ɾW*NBHFɿը૾Ճ޻
    ɾW'PSDFɿߦྻͱ௒ӽؔ਺
    ɾ4QBSTF4PMWFST #-"4 BOE-"1"$,ɿߦྻܭࢉ
    "DDFMFSBUFGSBNFXPSLʹؚ·Ε͍ͯΔϥΠϒϥϦ

    View full-size slide

  40. ॲཧͷྫͱܭଌ͔ΒW%41Λ஌Δ
    IUUQTHJUIVCDPNOBSVKQO.FBTVSF"DDFMFSBUFT
    9$5FTUͷNFBTVSFΛ༻͍ͯॲཧ࣌ؒΛܭଌͯ͠ൺֱ͢Δ
    .FBTVSF"DDFMFSBUFT

    View full-size slide

  41. let length = 1_000_000
    let v1 = UnsafeMutablePointer.allocate(capacity: length)
    let v2 = UnsafeMutablePointer.allocate(capacity: length)
    v1.initialize(repeating: 10, count: length)
    v2.initialize(repeating: 20, count: length)
    ௕͞ສͷߦྻʹର͢Δॲཧ଎౓Λൺֱ͢Δ

    View full-size slide

  42. // Others
    for i in 0..out[i] = v1[i] + v2[i]
    }
    // Accelerate
    vDSP_vadd(v1, 1, v2, 1, out, 1, vDSP_Length(length))
    0UIFST "DDFMFSBUF

    ߦྻͷཁૉͷ଍͠ࢉ

    View full-size slide

  43. // Others
    for i in 0..out[i] = v1[i] * v2[i]
    }
    // Accelerate
    vDSP_vmul(v1, 1, v2, 1, out, 1, vDSP_Length(length))
    0UIFST "DDFMFSBUF

    ߦྻͷཁૉͷֻ͚ࢉ

    View full-size slide

  44. ۮ਺ΠϯσοΫε
    ͷཁૉʹͷΈΛ଍͢
    // Others (whole loop)
    for i in 0..if i % 2 == 0 {
    v[i] = v[i] + 1
    }
    }
    // Others (loop with stride)
    for i in stride(from: 0, to: length, by: 2) {
    v[i] = v[i] + 1
    }
    // Accelerate
    var value: Float = 1
    vDSP_vsadd(v, 2, &value, v, 2, vDSP_Length(length / 2))
    0UIFST XIPMFMPPQ
    0UIFST MPPQXJUITUSJEF
    "DDFMFSBUF

    View full-size slide

  45. ΑΓେ͖͍TUSJEFΛࢦఆͯ͠
    ҰఆͷִؒΛۭ͚ͨϕΫτϧ্ͷܭࢉ͕Ͱ͖Δ
    // Accelerate
    var value: Float = 1
    vDSP_vsadd(v, 2, &value, v, 2, vDSP_Length(length / 2))
    // Others (loop with stride)
    for i in stride(from: 0, to: length, by: 2) {
    v[i] = v[i] + 1
    }
    " 3 # (΍$C $SͷΑ͏ʹ
    ౳ִؒͰಉ͡छྨͷ৘ใ͕ฒΜͰ͍Δ৔߹ͳͲʹศར

    View full-size slide

  46. TUSJEFͱΞΫηεͰ͖Δըૉͷؔ܎
    TUSJEF TUSJEF
    TUSJEF TUSJEF

    View full-size slide

  47. W*NBHF
    https://developer.apple.com/documentation/accelerate/vimage
    vImage is particularly suited for:
    • Ef
    fi
    ciently processing large images
    • Real-time video processing software
    • Scienti
    fi
    c applications that require high-accuracy numerical calculations
    ެࣜΑΓҾ༻

    View full-size slide

  48. W*NBHF
    $71JYF#VGGFS
    QMBOF
    let data = UnsafeMutableRawPointer(addressOfPlane)
    let buffer = vImage_Buffer(
    data: data,
    height: height,
    width: width,
    rowBytes: rowBytes
    )
    W*NBHF@#VGGFS

    View full-size slide

  49. W*NBHF
    https://developer.apple.com/documentation/accelerate/convolution
    ৭ʑͳϑΥʔϚοτͷσʔλͷՃ޻ʹରԠ͍ͯ͠Δ
    ྫɿW*NBHF$POWPMWF@"3(#
    W*NBHF$POWPMWF@1MBOBS W*NBHF$POWPMWF@1MBOBS'
    W*NBHF$POWPMWF@1MBOBS' W*NBHF$POWPMWF@"3(#'
    W*NBHF$POWPMWF@"3(#''''

    View full-size slide

  50. W*NBHF
    "QQMZJOHW*NBHFPQFSBUJPOTUPSFHJPOTPGJOUFSFTU
    https://developer.apple.com/documentation/accelerate/applying_vimage_operations_to_regions_of_interest

    View full-size slide

  51. ௨஌΅͔͠ͷཁ݅Λࢥ͍ग़͢
    ɾϓογϡ௨஌ͷܗঢ়Λݕग़ͨ͠Βɺ഑৴୺຤ଆͰө૾ΛՃ޻͢Δ
    ɹɾͨͩ͠ɺϛϥςΟϒ͔Βͷ௨஌͸Ճ޻͠ͳ͍
    ɹɾ୺຤ͷճసʹରԠ͢Δ
    ɹɾμʔΫϞʔυʹରԠ͢Δ
    ɾϦΞϧλΠϜͷॲཧʹ଱͑ΔύϑΥʔϚϯεΛग़͢

    View full-size slide

  52. ϓογϡ௨஌΅͔࣮͠ݱ΁ͷεςοϓ
    ϓογϡ௨஌ྖҬΛݕग़͢Δ
    ΞΠίϯྖҬΛൺֱ͢Δ
    ө૾ΛՃ޻͢Δ

    View full-size slide

  53. ϓογϡ௨஌΅͔࣮͠ݱ΁ͷεςοϓ
    ϓογϡ௨஌ྖҬΛݕग़͢Δ
    ΞΠίϯྖҬΛൺֱ͢Δ
    ө૾ΛՃ޻͢Δ

    View full-size slide

  54. ݕग़͍ۣͨ͠ܗ

    View full-size slide

  55. ݕग़͍ۣͨ͠ܗ
    ଆ໘Λݟ͚ͭΔˠఈΛݟ͚ͭΔˠશମͷۣܗΛܾΊΔ

    View full-size slide

  56. ϓογϡ௨஌ͷࠨӈͷϚʔδϯ͸୺຤αΠζຖʹҰఆ

    View full-size slide

  57. ୺຤ͷը໘αΠζ͝ͱʹϓογϡ௨஌ͷࠨӈͷϚʔδϯΛܭଌͯ͠
    ݕग़ͷࡍͷܭࢉʹ࢖༻͍ͯ͠Δ

    // iPhone 12,13,14 iPhone Pro 12,13
    "1170x2532": .init(width: 1170, height: 2532, x: 24),
    "2532x1170": .init(width: 2532, height: 1170, x: 432),
    // iPhone Pro Max 14
    "1290x2796": .init(width: 1290, height: 2796, x: 24),
    "2796x1290": .init(width: 2796, height: 1290, x: 564),
    // iPad 3rd,4th,5th,6th / iPad mini 2nd,3rd,4th,5th / iPad Air 1st,2nd
    "1536x2048": .init(width: 1536, height: 2048, x: 212),
    "2048x1536": .init(width: 2048, height: 1536, x: 468),

    View full-size slide

  58. ϓογϡ௨஌ͷଆ໘Λ؍࡯͢Δ

    View full-size slide

  59. ϓογϡ௨஌ͷଆ໘ʹ͸ڥք͕͋Γɺ಺ଆͷྖҬ͸৭ͷมԽ͕খ͍͞
    ڥք
    ಺ଆ
    ϕΫτϧܭࢉͷ໰୊ʹ຋༁ͯ͠ɺ"DDFMFSBUFͰܭࢉ͍ͨ͠

    View full-size slide

  60. ৭ ً౓
    ͷมԽ
    : :
    c::c

    View full-size slide

  61. : :
    c::c
    : :
    c::c

    ৭ ً౓
    ͷมԽͷେখ
    େ খ

    View full-size slide

  62. ৭ ً౓৭ࠩ
    ͷมԽ
    : $C $S : $C $S
    c::cc$C$Ccc$S$Sc

    View full-size slide

  63. ৭ ً౓৭ࠩ
    ͷมԽ
    : $C $S
    c::cc$C$Ccc$S$Sc
    : $C $S
    ˞Ҏ߱Ͱ͸ɺ؆୯ͷͨΊʹً౓ͷΈͷܭࢉͱݟཱͯͯߟ͑·͢

    View full-size slide

  64. ڥքˠ৭ͷมԽ͕େ͖͍
    ಺ଆͷྖҬˠ৭ͷมԽ͕খ͍͞
    ڥք
    ಺ଆ

    View full-size slide

  65. W W
    ڥքˠ৭ͷมԽ͕େ͖͍
    vDSP_vsub(v1, 1, v2, 1, boundary, 1, length)
    vDSP_vabs(boundary, 1, boundary, 1, length)
    CPVOEBSZcWWc
    ڥքͷϕΫτϧͷཁૉͷࠩͷઈର஋͸ɺҰఆΑΓେ͖͍
    CPVOEBSZDPOTU

    View full-size slide

  66. W W
    ಺ଆͷྖҬˠ৭ͷมԽ͕খ͍͞
    vDSP_vsub(v2, 1, v3, 1, inner, 1, length)
    vDSP_vabs(inner, 1, inner, 1, length)
    JOOFScWWc
    ಺ଆͷϕΫτϧͷཁૉͷࠩͷઈର஋͸ɺҰఆΑΓখ͍͞
    JOOFSDPOTU

    View full-size slide

  67. JOOFS
    ಺ଆͷྖҬʹରͯ͠ɺڥքͷํ͕৭ͷมԽ͕େ͖͍
    vDSP_vdiv(boundary, 1, inner, 1, out, 1, length)
    PVUCPVOEBSZJOOFS
    ϓογϡ௨஌ͷଆ໘Ͱ͸ɺ৭ͷมԽͷൺ͕ҰఆΑΓେ͖͍
    CPVOEBSZ
    PVUCPVOEBSZJOOFSDPOTU
    େ খ

    View full-size slide

  68. // ڥք
    vDSP_vsub(v1, 1, v2, 1, boundary, 1, length)
    vDSP_vabs(boundary, 1, boundary, 1, length)
    // ಺ଆ
    vDSP_vsub(v2, 1, v3, 1, inner, 1, length)
    vDSP_vabs(inner, 1, inner, 1, length)
    // ڥք / ಺ଆ
    vDSP_vdiv(boundary, 1, inner, 1, out, 1, length)
    ϓογϡ௨஌͕௨ա͢Δ۠ؒʹ౉ͬͯܭࢉΛ͢Δ

    View full-size slide

  69. ࠨӈͰಉ࣌ʹ৚݅Λຬͨ͢Α͏ͳɺҰఆҎ্ͷ௕͞ͷ͋ΔྖҬΛ୳͠
    ϓογϡ௨஌ͷଆ໘Ͱ͋ΔͱΈͳ͢

    View full-size slide

  70. ϓογϡ௨஌ͷଆ໘͕ݕग़Ͱ͖ͨ

    View full-size slide

  71. ϓογϡ௨஌ͷఈΛ؍࡯͢Δ

    View full-size slide

  72. ϓογϡ௨஌ͷ಺ଆ͸৭ͷมԽ͕খ͘͞ɺڥքͰ৭ͷมԽ͕͋Δ
    ڥք
    ಺ଆ
    ϕΫτϧܭࢉͷ໰୊ʹ຋༁ͯ͠ɺ"DDFMFSBUFͰܭࢉ͍ͨ͠

    View full-size slide

  73. ϕΫτϧΛͣΒͯ͠Ҿ͖ࢉ͢ΔͱɺมԽ͕Θ͔Δ
    [100, 100, 100, 10, 10, 10, 10, …]

    View full-size slide

  74. [100, 100, 100, 10, 10, 10, 10, …]
    [100, 100, 100, 10, 10, 10, 10, …]
    ϕΫτϧΛͣΒͯ͠Ҿ͖ࢉ͢ΔͱɺมԽ͕Θ͔Δ

    View full-size slide

  75. [100, 100, 100, 10, 10, 10, 10, …]
    [100, 100, 100, 10, 10, 10, 10, …]
    -
    [ 0, 0, 90, 0, 0, 0, …]
    ϕΫτϧΛͣΒͯ͠Ҿ͖ࢉ͢ΔͱɺมԽ͕Θ͔Δ

    View full-size slide

  76. BEWBODFEͰͣΒͨ͠ϕΫτϧͷࠩΛܭࢉ͠ɺ৭ͷมԽ఺Λ୳Δ
    vDSP_vsub(v, 1, v.advanced(by: 1), 1, out, 1, length-1)
    vDSP_vabs(out, 1, out, 1, length)
    PVUcWWBEWBODFE
    c
    PVU͕ҰఆΑΓେ͖͍৔ॴ͕ϓογϡ௨஌ͷఈͷީิʹͳΔ
    W
    WBEWBODFE

    View full-size slide

  77. ఈͷީิ͕ܾ·ͬͨΒɺఈ͔Ͳ͏͔ݕࠪΛ͢Δ

    View full-size slide

  78. JOOFS
    CPVOEBSZ
    ଆ໘ͷݕग़ͱಉ༷ʹɺ಺෦ͱڥքͷ৭ͷࠩͷେ͖͞Λܭࢉͯ͠
    ൣғ಺Ͱ಺෦ͷมԽ͕খ͘͞ɺڥքͷมԽ͕େ͖͍͜ͱΛ֬ೝ͢Δ

    View full-size slide

  79. ϓογϡ௨஌ͷଆ໘ͱఈ͕ݕग़Ͱ͖ͨ

    View full-size slide

  80. ϓογϡ௨஌ͷఱҪ͸ఈͷ൓ରʹ͋ΔͷͰ͙͢Θ͔Δ

    View full-size slide

  81. ݕग़Ͱ͖·ͨ͠ʂ🎉
    ۣܗͷݕग़ʶ J1IPOF1SP

    View full-size slide

  82. ϓογϡ௨஌΅͔࣮͠ݱ΁ͷεςοϓ
    ϓογϡ௨஌ྖҬΛݕग़͢Δ
    ΞΠίϯྖҬΛൺֱ͢Δ
    ө૾ΛՃ޻͢Δ

    View full-size slide

  83. ϛϥςΟϒ͔Βͷ௨஌͸಺༰ΛӅ͢ඞཁ͸ͳ͍
    ΞΠίϯͷൺֱʹΑͬͯϛϥςΟϒ͔Βͷ௨஌͔ΛͲ͏͔ௐ΂Δ

    View full-size slide

  84. ΞΠίϯྖҬͷൺֱ
    ΞΠίϯྖҬͷ୳ࡧ
    ΞΠίϯը૾ͷൺֱ

    View full-size slide

  85. ϓογϡ௨஌ͷۣܗ͸෼͔͍ͬͯΔͷͰେମͷ৔ॴ͸෼͔Δ
    ఈͷਪఆͱಉ͡Α͏ʹɺࠨଆͱ্Լ͔ΒΞΠίϯͷڥ໨Λ୳͢

    View full-size slide

  86. ΞΠίϯྖҬͷൺֱ
    ΞΠίϯྖҬͷ୳ࡧ
    ΞΠίϯը૾ͷൺֱ

    View full-size slide

  87. .JSSBUJW
    􀈕
    "QQ(SPVQT
    􀅈
    #SPBEDBTU6QMPBE
    &YUFOTJPO
    ΞΠίϯը૾
    "QQ(SPVQTΛհͯ͠ɺ࠷৽ͷΞϓϦΞΠίϯΛڞ༗͢Δ

    View full-size slide

  88. ݕग़ͨ͠ΞΠίϯը૾ͷҐஔ͸dQYͣΕͨΓ
    എܠ৭ͷӨڹ΋ड͚ΔͷͰɺͦͷ··ͷεέʔϧͰ׬શҰக͸೉͍͠

    View full-size slide

  89. ɾը૾Λ੾Γൈ͖ɺ͋Β͔͡ΊܾΊͨେ͖͞ Y
    ʹॖখ͢Δ
    ɾϐΫηϧຖʹൺֱΛͯ͠ɺҰக౓Λܭࢉ͢Δ
    ΞϓϦΞΠίϯ ௨஌ .JSSBUJW
    ௨஌ λΠϚʔ

    View full-size slide

  90. ΞϓϦΞΠίϯ ௨஌ .JSSBUJW
    ௨஌ λΠϚʔ

    ΞΠίϯͷൺֱʶ J1IPOF1SP

    View full-size slide

  91. ϓογϡ௨஌΅͔࣮͠ݱ΁ͷεςοϓ
    ϓογϡ௨஌ྖҬΛݕग़͢Δ
    ΞΠίϯྖҬΛൺֱ͢Δ
    ө૾ΛՃ޻͢Δ

    View full-size slide

  92. ੩ࢭըͷൺֱ

    View full-size slide

  93. L$71JYFM'PSNBU5ZQF@:Q$C$S#J1MBOBS'VMM3BOHF͸
    ً౓ :
    ɾ৭ࠩ $C$S
    ͷͭͷฏ໘͔Βߏ੒͞Ε͍ͯΔ
    ً౓ :
    ฏ໘ ৭ࠩ $C$S
    ฏ໘
    ը໘දࣔ

    View full-size slide

  94. // ً౓(Y)ฏ໘ͷઌ಄Λࢦ͢ΞυϨε
    let address0 = CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0)
    // ৭ࠩ(CbCr)ฏ໘ͷઌ಄Λࢦ͢ΞυϨε
    let address1 = CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1)
    ً౓ :
    ฏ໘ͱ৭ࠩ $C$S
    ฏ໘͸ผʑʹՃ޻͢Δඞཁ͕͋Δ

    View full-size slide

  95. W*NBHFΛ׆༻ͨ͠ө૾ͷՃ޻
    ً౓ :
    ฏ໘ͷՃ޻
    ৭ࠩ $C$S
    ฏ໘ͷՃ޻

    View full-size slide

  96. ً౓ :
    ฏ໘͸ϐΫηϧͷً౓ʹରԠ͢Δ
    6*OUͷ஋ d
    ͕ॱʹฒΜͰ͍Δ
    6*OU
    […
    Y0, Y1, Y2, Y3,…
    Y4, Y5, Y6, Y7,…
    Y8, Y9, Y10, Y11,…
    Y12, Y13, Y14, Y15,…
    …]
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15

    View full-size slide

  97. W*NBHF#PY$POWPMWF@1MBOBSͳͲΛ࢖༻͢Δͱ
    ΅͔͠ͷ൒ܘΛࢦఆͨ͠΅͔͠ॲཧΛద༻Ͱ͖Δ
    ͕ɺॲཧʹ͕͔͔࣌ؒΔʜ😢
    ΅͔͠ॲཧΛॎํ޲ͱԣํ޲Ͱ෼ׂͯ͠ߴ଎Խ͢ΔςΫχοΫΛ
    ࢖ͬͨͱͯ͠΋͕͔͔࣌ؒΔ NTऑ

    View full-size slide

  98. W*NBHF.BY@1MBOBS
    पғͷࢦఆൣғ಺ͷϐΫηϧͷ࠷େ஋Λ࠾༻͢Δ
    W*NBHF#PY$POWPMWF@1MBOBSΑΓஅવૣ͍
    ً౓ :
    ฏ໘ͷΈՃ޻ͨ͠ྫ
    ˞μʔΫϞʔυͷ৔߹ʹ͸W*NBHF.JO@1MBOBSΛ࢖༻

    View full-size slide

  99. W*NBHFΛ׆༻ͨ͠ө૾ͷՃ޻
    ً౓ :
    ฏ໘ͷՃ޻
    ৭ࠩ $C$S
    ฏ໘ͷՃ޻

    View full-size slide

  100. W*NBHF#VGGFS'JMM@$C$S
    ࢦఆൣғΛಛఆͷ$C $Sͷ஋ͰృΓ௵͢
    ৭ࠩ $C$S
    ฏ໘ͷΈՃ޻ͨ͠ྫനͰృΓ௵͢
    ˞৭ͷՃ޻͸Өڹ͕େ͖͍ͷͰɺ௨஌ͷྖҬ಺ͷΈՃ޻͍ͯ͠Δ

    View full-size slide

  101. ө૾ͷՃ޻ʶ J1IPOF1SP

    ً౓ :
    ฏ໘ɺ৭ࠩ $C$S
    ฏ໘ͷ྆ํΛՃ޻ͯ͠৘ใΛӅณ͢Δ

    View full-size slide

  102. ۣܗͷݕग़
    ΞΠίϯͷൺֱ
    ө૾ͷՃ޻ ʶ
    ʶ
    ʶ
    ʶ J1IPOF1SP

    ݕग़ͱՃ޻

    View full-size slide

  103. ഑৴ऀ
    ࢹௌऀ

    View full-size slide

  104. ·ͱΊ
    ɾ:$C$Sͷߏ଄Λৄ͘͠஌Γɺॲཧ΍ϝϞϦͷ࡟ݮΛͨ͠
    ɾ"DDFMFSBUFΛՄೳͳݶΓ׆༻͠ɺܭࢉΛߴ଎ʹͨ͠
    ɾݕग़ͱՃ޻ॲཧΛ߹ΘͤͯɺϦΞϧλΠϜͷॲཧʹ଱͑ΔύϑΥ
    ʔϚϯεΛग़ͤΔ͜ͱΛࣔͨ͠

    View full-size slide

  105. ࠓޙͷల๬
    ɾ044ԽΛࢹ໺ʹೖΕͨίʔυͷ੔උ
    ɹɾ͢Ͱʹ௨஌΅͔͠ͷػೳ͸ύοέʔδʹ෼ׂ͍ͯͯ͠ɺΞϓ
    Ϧຊମͱ͸෼཭͞Ε͍ͯΔ
    ɹɾεΫϦʔϯγϣοτΛ༻͍ͨςετͷॆ࣮
    ɹɹɾIUUQTHJUIVCDPNOBSVKQO'SBNF.JOU
    ɾ࣮ӡ༻্ͷ໰୊ͷ೺ѲͱରԠ
    ɾΫϥΠΞϯτͳΒͰ͸ͷॲཧͷݕ౼

    View full-size slide

  106. ͋Γ͕ͱ͏͍͟͝·ͨ͠
    🌟
    🌟

    View full-size slide