if (!video_frame->HasGpuMemoryBuffer())
return {};
+ auto gpu_memory_buffer = video_frame->GetGpuMemoryBuffer()->CloneHandle();
+
+ // Hardware encoder platform library does not apply offset given in TBM
+ // surface. We cannot encode region indicated by visible rect, so we need
+ // to fallback to other methods.
+ if (video_frame->visible_rect().size() != video_frame->coded_size()) {
+ TIZEN_MEDIA_LOG_NO_INSTANCE(VERBOSE)
+ << "Visible rect size ("
+ << video_frame->visible_rect().size().ToString()
+ << ") is different than coded size "
+ << video_frame->coded_size().ToString() << ")";
+ return {};
+ }
+
+ for (const auto& plane : gpu_memory_buffer.native_pixmap_handle.planes) {
+ if (plane.offset != 0) {
+ TIZEN_MEDIA_LOG_NO_INSTANCE(VERBOSE) << "Offset is non-zero";
+ return {};
+ }
+ }
+
auto tbm_surface = gfx::TbmSurface::ImportTbmSurface(
- video_frame->GetGpuMemoryBuffer()->CloneHandle().native_pixmap_handle,
- video_frame->coded_size());
+ gpu_memory_buffer.native_pixmap_handle, video_frame->coded_size());
if (!tbm_surface)
return {};