Skip to content
Snippets Groups Projects
  1. May 16, 2022
  2. Nov 12, 2021
  3. Nov 08, 2021
    • Chih-Yu Huang's avatar
      plugin_store: split getDmabufId() function to dedicated file · 981081c7
      Chih-Yu Huang authored
      Currently, getDmabufId() is placed at C2VdqBqBlockPool.h. However,
      the header file already has many dependencies. The caller of
      getDmabufId() would need to add many unnecessary dependency libraries.
      
      This CL splits the method to a dedicated file to reduce this issue.
      
      Bug: 205501954
      Test: m -j32
      
      Change-Id: Ie7e366ddf77ceec105cbacf6d16e6b6dc3a58198
      981081c7
    • Chih-Yu Huang's avatar
      plugin_store: split getDmabufId() function to dedicated file · 9e9a9133
      Chih-Yu Huang authored
      Currently, getDmabufId() is placed at C2VdqBqBlockPool.h. However,
      the header file already has many dependencies. The caller of
      getDmabufId() would need to add many unnecessary dependency libraries.
      
      This CL splits the method to a dedicated file to reduce this issue.
      
      Bug: 205501954
      Test: m -j32
      
      Change-Id: Ie7e366ddf77ceec105cbacf6d16e6b6dc3a58198
      9e9a9133
  4. Nov 05, 2021
  5. Mar 24, 2021
  6. Mar 15, 2021
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: close handle from C2AllocatorGralloc · 075db78d
      Chih-Yu Huang authored
      At ag/13824423 we fixed the description of
      WrapNativeCodec2GrallocHandle() that the returned handle should be
      closed. This CL closes the handle if the ownership is not transfered
      to C2GrallocAllocation via priorGraphicAllocation() call.
      
      Bug: 181541291
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ifbe842f715977f4f6f79dfd2b33efbee9c0d1191
      075db78d
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: wait fence just before returing the buffer · ffd260c6
      Chih-Yu Huang authored
      Currently we wait the fence of the buffer with timeout. To reduce the
      chance of timeout, we move the waiting call to the last point, just
      before returning the buffer.
      
      Bug: 178770649
      Test: android.media.cts.AdaptivePlaybackTest
      Change-Id: Idf2b4a40397a6632120e6d04c1b95b97933de457
      ffd260c6
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: store registered C2GraphicAllocation instead of GraphicBuffer · 64758f02
      Chih-Yu Huang authored
      C2ArcProtectedGraphicAllocator allocates the protected buffer when
      priorGraphicAllocation() is called, and releases the protected buffer
      if all the corrresponding C2GraphicAllocations are released.
      
      Originally, we store the the registered graphic buffers with
      GraphicBuffer. Each time when fetchGraphicBlock() is called, we
      call priorGraphicAllocation() to convert GraphicBuffer to
      C2GraphicAllocation. The component releases the C2GraphicAllocation
      after decoding a frame and passing it to framework. So at the end we
      continue allocating and releasing protected buffers during decoding.
      
      This CL changes to store C2GraphicAllocation directly. We don't call
      priorGraphicAllocation() when recycling the buffer, and the registered
      C2GraphicAllocations are released when resolution change or component
      is destroyed.
      
      Bug: 181541291
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ib0cf9fe9d4609f3a566c514429d281c1c54b458d
      64758f02
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: do nothing if requesting the same format of buffers · 371a1dde
      Chih-Yu Huang authored
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      Change-Id: Ie8a18e7f47469ae940fac0ca91fa68826006f13d
      371a1dde
  7. Mar 01, 2021
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: remove unnecessary data · ef98c748
      Chih-Yu Huang authored
      |mComponentOwnedUniquedIds| was used to prevent the issue that buffers
      might be attached twice to new surface. But ag/13490974 change the way
      to switch surface. This issue doesn't exist anymore. This CL removes
      the unnecessary mComponentOwnedUniquedIds data.
      
      Also, because the extra field |mUniqueId| of C2VdaBqBlockPoolData is
      used to update |mComponentOwnedUniquedIds|, it's not needed as well.
      This CL removes C2VdaBqBlockPoolData class and uses its parent class
      directly.
      
      Bug: 174188958
      Test: android.media.cts.AdaptivePlaybackTest
      Test: android.media.cts.MediaCodecPlayerTest#testPlaybackSwitchViews
      
      Change-Id: I588f3896a8ad6cceb90c844981e7ab95defe2092
      ef98c748
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: re-design flow of surface switching · 576a7239
      Chih-Yu Huang authored
      During decoding, graphic buffers are owned by component (i.e. local
      buffers) or CCodec framework (i.e. remote buffers).  When switching
      surface, the CCodec framework migrates remote buffers to the new
      surfaces, then call C2BufferQueueBlockPool::configureProducer().
      C2BufferQueueBlockPool implementation then migrates local buffers.
      However, the CCodec and C2BufferQueueBlockPool implementation don't
      guaratee to migrate all the existing buffers, and might allocate new
      buffers. This violates the V4L2 stateful API's requirement.
      
      Originally, C2VdaBqBlockPool migrates all the buffers again, and tries
      to detach the slot of buffers migrated by CCodec framework. we assume
      there should be only at most N buffers at BufferQueue, where N is the
      number passed via setMaxDequeuedBufferCount(). However, this
      assumption is wrong, so we failed to detach all buffers migrated by
      CCodec framework.
      
      In this CL, C2VdaBqBlockPool migrates local buffers when switching
      surface, similar to C2BufferQueueBlockPool. After we dequeue
      NUM_BUFFER_SLOTS buffers, all the migrated buffers should be dequeued
      at least once. Then we could detect the lost buffers, and attach them
      to the new surface.
      
      Bug: 174188958
      Test: android.media.cts.AdaptivePlaybackTest
      Test: android.media.cts.MediaCodecPlayerTest#testPlaybackSwitchViews
      
      Change-Id: Ifc30b62e69608be4ebc24ce1ea1a97be11f25a37
      576a7239
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: C2VdaBqBlockPoolData inherits C2BufferQueueBlockPoolData · 472814e1
      Chih-Yu Huang authored
      Originally, the definition of C2BufferQueueBlockPoolData is hidden at
      cpp file. C2VdaBqBlockPoolData has to handle the ownership transition
      itself with extra workaround.
      
      At ag/13473071, we expose C2BufferQueueBlockPoolData at header file.
      This CL makes C2VdaBqBlockPoolData inherit C2BufferQueueBlockPoolData
      directly. With this CL, C2VdaBqBlockPoolData could share the same
      logic of the ownership transition.
      
      Bug: 174188958
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ib73b2f8bc36bbd9724523624415551a7efadda73
      472814e1
    • Chih-Yu Huang's avatar
      plugin_store: Split H2BGraphicBufferProducer to a dedicated file · 428f40f0
      Chih-Yu Huang authored
      Although H2BGraphicBufferProducer is only used by C2VdaBqBlockPool,
      the logic of H2BGraphicBufferProducer is not highly coupled. This CL
      splits the class to a dedicated file.
      
      Bug: 160110407
      Test: mmm external/v4l2_codec2
      Change-Id: Icec2d189fe9df832d71aeb7b0f25ec22df8cc2d0
      428f40f0
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: remove unnecessary namespace prefix for status_t · 51645f68
      Chih-Yu Huang authored
      This CL removes the unnecessary "android" namespace prefix for
      status_t constant. Also it replaces "NO_ERROR" to "OK", which is the
      preferred constant.
      
      Bug: 160110407
      Test: m -j32
      
      Change-Id: Ia93e82d6425812b169b85ee96b5d3db0d1c23214
      51645f68
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: avoid unnecessary function call at surface switch · 8b3480e2
      Chih-Yu Huang authored
      This CL changes the order of the function call at configuring producer
      to avoid unnecessary call when any error occurs or the producer is not
      changed.
      
      Bug: 160110407
      Test: android.media.cts.MediaCodecPlayerTest#testPlaybackSwitchViews
      
      Change-Id: I194f929ab7dbdaa10ab55dd3a11ca4a1c9a0d40a
      8b3480e2
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: support surface switch at protected playback · 626efac1
      Chih-Yu Huang authored
      Originally, protected buffer allocator has restriction that we can
      only call priorGraphicAllocation() method once for each buffer. But we
      have to call priorGraphicAllocation() again when switching surface. So
      surface switching is not supported at protected playback.
      
      However, the restriction is relaxed at ag/13461483. This CL removes
      the protected playback check at surface switching.
      
      Bug: 160110407
      Test: m -j32
      
      Change-Id: I21154fa9a9f69db1e2eee89f296daae8932239d1
      626efac1
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: set a constant maximum dequeued buffer count · 3262a621
      Chih-Yu Huang authored
      Originally, we use IGBP's maximum dequeued buffer count to restrict
      the total allocated buffer count. However, the maximum dequeued buffer
      count only affects the free BufferQueue slot count, not related to
      allocated buffer count. Also, we already track the allocated buffer
      count by TrackedGraphicBuffers class.
      
      This CL sets a big enough maximum dequeued buffer count when
      configuring the producer. It simplifies the logic in general.
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ibd8859395732c85521b2e609b46af4b203d969c0
      3262a621
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Polish queryGenerationAndUsage method · 233c1559
      Chih-Yu Huang authored
      This CL polishes queryGenerationAndUsage method, including:
      
      - change the return type to status_t to reduce type mapping
      - rename to queryGenerationAndUsageLocked to indicate the method
        should be called during locked
      - remove unnecessary fence waiting
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ie85acde8bdfdc5b6e2620e590aed9dd606e1b507
      233c1559
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: avoid unnecessary allowAllocation call · 5efc8f18
      Chih-Yu Huang authored
      This CL tracks the current status of allowAllocation(). If the target
      status is the same as the expected status, then we skip the call.
      Also, this CL disables allocation when we dequeue more buffers then
      requested.
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: I860db3be92b06f18c7f5a0e7b6a391ccd26bb6f6
      5efc8f18
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: add unique_id_t and slot_t type alias · 2ff3089a
      Chih-Yu Huang authored
      This CL adds the type alias for the unique identifier of graphic
      buffers, and the BufferQueue slot index for readability.
      
      Bug: 160110407
      Test: m -j32
      
      Change-Id: I778956f909b8df3a226beb5b657493f10a7cf7f1
      2ff3089a
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: avoid reusing status variable · 0b2af139
      Chih-Yu Huang authored
      This CL avoids reusing the status variable to prevent the potential
      bug that the value is misused.
      
      Bug: 160110407
      Test: android.media.cts.MediaSyncTest
      
      Change-Id: I8c0a3a45657603bc800923da31b7fa00d59fa13e
      0b2af139
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: track graphic buffer by identifier · c82fffd8
      Chih-Yu Huang authored
      Originally we assumed the buffers at BufferQueue is not moved to
      different slot, so we tracked the graphic buffers by storing tuple of
      (slot index, unique ID, C2Allocation). However, the slot index of the
      buffer might be changed.
      
      In this CL, we change to store two maps instead:
      - unique ID to C2Allocation
      - slot index to GraphicBuffer
      
      The map from unique ID to C2Allocation is for tracking the fixed
      buffer set. The map from slot index to GraphicBuffer is updated when
      IGBP::dequeueBuffer() returns BUFFER_NEEDS_REALLOCATION, no matter if
      the buffers is tracked or not. With these two maps, we can handle the
      case that the consumer move graphic buffers to different BufferQueue
      slot.
      
      Bug: 177484971
      Test: android.media.cts.AdaptivePlaybackTest
      Test: android.media.cts.MediaSyncTest
      
      Change-Id: Iee99e8d0b00dae463cf6483ca8c971cc84f9ea49
      c82fffd8
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Use GEM handle as the identifier of graphic buffers. · 7791a051
      Chih-Yu Huang authored
      Originally we assume the buffers at BufferQueue are not moved to
      different slot. Then we could track the buffers by the slot index.
      However, MediaSync implementation detach buffers and attach back to
      BufferQueue. The slot index might be changed.
      
      This CL changes to use GEM handle as the identifier of graphic
      buffers. Because all the graphic buffers are allocated by gralloc, we
      could get the GEM handle by DRM. V4L2GraphicAllocator is not used
      anymore.
      
      Bug: 177484971
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: I6b7f3f9a6c1d6b97d0e44aa2a19bc71ad3bab880
      7791a051
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: change Fence::waitForever() to Fence::wait() · d54b5a54
      Chih-Yu Huang authored
      When running MediaSyncTest, Fence::waitForever() is stuck for few
      seconds, and it blocks other methods due to the mutex. This CL changes
      waitForever() method to wait() with timeout. Also we enlarge the
      timeout to 32 ms.
      
      Bug: 177484971
      Test: android.media.cts.AdaptivePlaybackTest
      Test: android.media.cts.MediaSyncTest#testPlayVideo
      
      Change-Id: I6d8d2c3befed35e17e16f322edfaa4245797254c
      d54b5a54
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: do not support byte-buffer mode · 856f88a7
      Chih-Yu Huang authored
      Currenlty C2VdaBqBlockPool is highly coupled with IGBP.
      V4L2DecodeComponent cannot work with the buffers not received from the
      IGBP. This CL removes the fallback when the IGBP is not configured.
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      Change-Id: I61e3ad01fb85a7b8003c948a5b3cbba341888d3c
      856f88a7
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: polish queryGenerationAndUsage() method · a7de7629
      Chih-Yu Huang authored
      queryGenerationAndUsage() could access |mProducer| member, so we don't
      need to pass the argument into the method.
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest#testH264_*
      
      Change-Id: I40cad58b5ff9cfbff03f172ec119d530b5248b63
      a7de7629
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: make callback members hold weak_ptr of C2VdaBqBlockPool · 11115e20
      Chih-Yu Huang authored
      BufferReleasedNotifier and C2VdaBqBlockPoolData notify
      C2VdaBqBlockPool when some event happens. Originally these two classes
      hold shared_ptr of C2VdaBqBlockPool. However they should not hold the
      ownership of C2VdaBqBlockPool. This CL changes these two classes to
      hold weak_ptr of C2VdaBqBlockPool.
      
      Bug: 160110407
      Test: android.media.cts.AdaptivePlaybackTest
      
      Change-Id: Ibc8c960dabc16542f83f5e6ff082dec70edf2481
      11115e20
  8. Jan 12, 2021
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: remove unnecessary log · 0d87376c
      Chih-Yu Huang authored
      Bug: 160110407
      Test: m -j32
      Change-Id: Icb1e50296610388df945ed00d6eca685c3a27944
      0d87376c
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: adjust log level of H2BGraphicBufferProducer · f2de3710
      Chih-Yu Huang authored
      This CL changes some non-fatal or non-error log from ALOGE to ALOGD.
      
      Bug: 175489166
      Test: m -j32
      
      Change-Id: I0b9a60138cf4f3405fdf958f6a093086272c4c13
      f2de3710
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Polish the retry logic · b001b34f
      Chih-Yu Huang authored
      After fetching new IGBP slot times out, we should retry the fetching
      when buffer released at IGBP. We use a flag
      |mBufferReleasedAfterTimedOut| to catch the case that the buffer is
      released between fetching timed out and setting the retry callback.
      If the flag is set, then we should execute the callback immediately,
      instead of waiting for the next buffer released event.
      
      However, we forgot to reset the flag when executing the callback. It
      caused we continuously retry the buffer fetching until the next buffer
      released event. This CL fixes this issue.
      
      Bug: 175489166
      Test: run com.google.android.exoplayer.gts.DashTest#testH264Adaptive
            and check setMaxDequeuedBufferCount() only retry when buffer
            released
      Change-Id: I8f7a36af50e5eebfcbecedc0f126c86f9427fa95
      b001b34f
    • Chih-Yu Huang's avatar
      V4L2Decoder: destroy previous VideoFramePool before getting new one · 62a9e438
      Chih-Yu Huang authored
      VideoFramePool is used to wrap C2BlockPool and request buffers for
      V4L2Decoder. When resolution changes, V4L2Decoder creates a new
      VideoFramePool instance to request buffers with new resolution.
      Also, C2VdaBqBlockPool is designed to provide buffers with the same
      resolution. So there only one VideoFramePool could exist at the same
      time.
      
      This CL destroys the previous VideoFramePool before getting the new
      one, and checks the buffer format passed to
      C2VdaBqBlockPool::fetchGraphicBlock() is the same as the format
      requested by requestNewBufferSet().
      
      Also, this CL simplifies the signature of the callback of getting
      VideoFramePool. Originally we put the returned value at output
      argument because Chromium callback with WeakPtr doesn't support
      returned value. But we actually could avoid WeakPtr here because
      V4L2Decoder is always destroyed before V4L2DecodeComponent. It's safe
      to use ::base::Unretained(this).
      
      Bug: 174287571
      Test: android.media.cts.AdaptivePlaybackTest#test{H264,Vp8,Vp9}_*
      
      Change-Id: Ib06855e7ccc3db5508a4a3f6403bceedb9b5f59d
      62a9e438
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: reply error at fetchGraphicBlock() if configureProducer() fails · 876c5114
      Chih-Yu Huang authored
      configureProducer() doesn't return any status. When this method fails,
      the component should stop working immediately. In this CL,
      C2VdaBqBlockPool replies error at fetchGraphicBlock(), which is the
      main method called by the component, if any error occurs at the
      previous configureProducer().
      
      Bug: 162902320
      Test: android.media.cts.MediaCodecPlayerTest#testPlaybackSwitchViews
      Change-Id: I4a9537b7657fef604ba2e020bcaeb0398ae2a5d0
      876c5114
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Rewrite configureProducer · 6e9279c4
      Chih-Yu Huang authored
      C2VdaBqBlockPool::configureProducer() is used to switch surface.
      Originally the flow of changing surface is for C2VDAComponent.
      This CL rewrites the flow of configureProducer for
      V4L2DecodeComponent/V4L2Decoder/VideoFramePool structure.
      
      1. During surface switching, we restrict the maximum dequeued buffer
      count to the count of the current tracking buffers. Because the codec2
      framework would migrate some buffers to the new surface. restricting
      the dequeued buffer count can guarantee any buffer is attached to
      multiple slots.
      
      2. Due to 1., there might be not enough slots to migrate all the
      buffers at the time of switching surface. We defer the migration
      process to fetchGraphicBlock(), because the client would call this
      method when a slot is released.
      
      3. After all buffers are attached to the new surface, these attached
      buffers are considered dequeued. We store the slots indices in
      |mDequeuedSlots| and return them to fetchGraphicBlock() from
      getFreeSlotLocked().
      
      Bug: 162902320
      Test: android.media.cts.MediaCodecPlayerTest#testPlaybackSwitchViews
      Test: android.media.cts.AdaptivePlaybackTest#testH264_*
      Change-Id: I457d3b5cb44afcfa022ba4902570126b81a06c4f
      6e9279c4
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Track the buffers owned by V4L2DecodeComponent · d3edc9b2
      Chih-Yu Huang authored
      This CL adds |mComponentOwnedUniqueIds| set to track the buffers owned
      by V4L2DecodeComponent. This will be used by the following CL.
      
      Bug: 162902320
      Test: android.media.cts.AdaptivePlaybackTest#testH264_*
      Change-Id: I6231c9af5d08bddd7f148cae5b5153d3b1d98fb4
      d3edc9b2
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: add TrackedGraphicBuffers to track graphic buffers · 62908bc9
      Chih-Yu Huang authored
      Originally, we use a mapping from IGBP slot index to C2Allocation to
      track the graphic buffers requested from IGBP. Now we need to track
      one more field "unique ID" of the buffer. The unique ID is not changed
      during surface switching.
      
      This CL adds TrackedGraphicBuffers class used to keep the
      bidirectional mapping between IGBP slot and the unique ID, and the
      mapping from IGBP slot to C2Allocation.
      
      Bug: 162902320
      Test: android.media.cts.AdaptivePlaybackTest#testH264_*
      Change-Id: I00d7585f2c752a2e121c660c1f9c869ed5a47ba9
      62908bc9
    • Chih-Yu Huang's avatar
      C2VdaBpBlockPool: call cancelBuffer when the buffer is not shared · 6443e39b
      Chih-Yu Huang authored
      Originally C2VdaBpBlockPool detaches buffer from IGBP if the component
      doesn't pass the buffer to the client. However, the buffer might be
      still used afterward. This CL changes to use cancelBuffer() instead of
      detachBuffer().
      
      Bug: 162902320
      Test: android.media.cts.AdaptivePlaybackTest#testH264_*
      Change-Id: Ieadd0058877bcf8be0917420e1f11edc2ff14a91
      6443e39b
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: Extract getFreeSlotLocked method. · 4c398083
      Chih-Yu Huang authored
      This CL extracts the part of dequeuing a free IGBP slot to a
      separated method only, not changing the logic.
      
      Bug: 162902320
      Test: pass android.media.cts.AdaptivePlaybackTest#testH264_*
      Change-Id: Ifb32cbe866c1bcfab4671fe671350bedb7acd202
      4c398083
    • Chih-Yu Huang's avatar
      C2VdaBqBlockPool: log IGBP ID in hex format · 9f063740
      Chih-Yu Huang authored
      In BufferQueue{Core,Producer,Consumer}.cpp, IGBP ID is logged in hex
      format. This CL changes C2VdaBqBlockPool to log the IGBP ID to hex
      format for easier debugging.
      
      Bug: 160110407
      Test: m -j32
      Change-Id: I94db18477e0c626d14ab4ad58203a7d2e71d8924
      9f063740
Loading