Support PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER and PIXEL_FORMAT_ENCODED.
Reference:
https://review.tizen.org/gerrit/#/c/279885
Change-Id: I30659a3c071b697ed06ff8eaf844ca82799d2b55
Signed-off-by: Suhaspoornachandra <s.poornachan@samsung.com>
CASE_RETURN_OTHER(PIXEL_FORMAT_P016LE);
CASE_RETURN_OTHER(PIXEL_FORMAT_XR30);
CASE_RETURN_OTHER(PIXEL_FORMAT_XB30);
+#if BUILDFLAG(IS_TIZEN)
+ CASE_RETURN_OTHER(PIXEL_FORMAT_ENCODED);
+#endif
#if defined(TIZEN_TBM_SUPPORT)
CASE_RETURN_OTHER(PIXEL_FORMAT_TBM_SURFACE);
#endif
case PIXEL_FORMAT_YUV420P12:
case PIXEL_FORMAT_P016LE:
case PIXEL_FORMAT_YUV420AP10:
+#if defined(TIZEN_TBM_SUPPORT)
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+#endif
return gfx::Size(2, 2);
case PIXEL_FORMAT_UYVY:
case PIXEL_FORMAT_XB30:
case PIXEL_FORMAT_BGRA:
case PIXEL_FORMAT_RGBAF16:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
#endif
case PIXEL_FORMAT_XB30:
case PIXEL_FORMAT_BGRA:
case PIXEL_FORMAT_RGBAF16:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
#endif
return false;
case PIXEL_FORMAT_NV12:
frame->buffer_handle_ = handle;
return frame;
}
+
+#if BUILDFLAG(IS_TIZEN_TV)
+scoped_refptr<VideoFrame> VideoFrame::WrapTBMInterProcessBuffer(
+ const gfx::Size& size,
+ base::TimeDelta timestamp,
+ gfx::TbmBufferHandle handle) {
+ const VideoPixelFormat format = PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER;
+#if defined(TIZEN_VIDEO_HOLE)
+ const StorageType storage = STORAGE_HOLE;
+#else
+ const StorageType storage = STORAGE_UNKNOWN;
+#endif
+ const gfx::Rect visible_rect = gfx::Rect(size);
+ if (!IsValidConfig(format, storage, size, visible_rect, size)) {
+ DLOG(ERROR) << __FUNCTION__ << " WrapTBMInterProcessBuffer Invalid config."
+ << ConfigToString(format, storage, size, visible_rect, size);
+ return nullptr;
+ }
+
+ auto layout = VideoFrameLayout::CreateWithStrides(
+ format, size, {handle.strides[0], handle.strides[1]});
+ if (!layout) {
+ DLOG(ERROR) << "Invalid layout.";
+ return nullptr;
+ }
+
+ scoped_refptr<VideoFrame> frame(
+ new VideoFrame(*layout, storage, gfx::Rect(size), size, timestamp));
+ frame->buffer_handle_ = handle;
+ return frame;
+}
+#endif
#endif
// static
frame = frame->wrapped_frame_;
}
+#if defined(TIZEN_TBM_SUPPORT)
+ if (frame->format() == PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER ||
+ frame->format() == PIXEL_FORMAT_TBM_SURFACE) {
+ wrapping_frame->buffer_handle_ = frame->buffer_handle_;
+ }
+#endif
+
wrapping_frame->wrapped_frame_ = std::move(frame);
return wrapping_frame;
}
case PIXEL_FORMAT_XBGR:
case PIXEL_FORMAT_XR30:
case PIXEL_FORMAT_XB30:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
return 4;
case PIXEL_FORMAT_RGB24:
return 3;
case PIXEL_FORMAT_YUV422AP10:
case PIXEL_FORMAT_YUV444AP10:
return 2;
+#if defined(TIZEN_TBM_SUPPORT)
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+#endif
case PIXEL_FORMAT_NV12:
case PIXEL_FORMAT_NV21: {
static const int bytes_per_element[] = {1, 2};
const gfx::Size subsample = SampleSize(format(), plane);
DCHECK(offset.x() % subsample.width() == 0);
DCHECK(offset.y() % subsample.height() == 0);
+
+#if defined(TIZEN_TBM_SUPPORT)
+ const VideoPixelFormat fmt = format();
+ if (PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER == fmt) {
+ if (!bufmgr_)
+ bufmgr_ = tbm_bufmgr_init(-1);
+ {
+ base::AutoLock autolock(tbm_map_lock_);
+ if (!vp_[plane]) {
+ bo_[plane] = tbm_bo_import(bufmgr_, buffer_handle_.key[plane]);
+ bo_handle_[plane] =
+ tbm_bo_map(bo_[plane], TBM_DEVICE_CPU, TBM_OPTION_READ);
+
+ vp_[plane] =
+ (uint8_t*)bo_handle_[plane].ptr +
+ stride(plane) * (offset.y() / subsample.height()) + // Row offset.
+ BytesPerElement(format(), plane) * // Column offset.
+ (offset.x() / subsample.width());
+ }
+ }
+ return vp_[plane];
+ }
+#endif
return data +
stride(plane) * (offset.y() / subsample.height()) + // Row offset.
BytesPerElement(format(), plane) * // Column offset.
<< coded_size().ToString();
memset(&mailbox_holders_, 0, sizeof(mailbox_holders_));
memset(&data_, 0, sizeof(data_));
+#if defined(TIZEN_TBM_SUPPORT)
+ memset(bo_handle_, 0, sizeof(tbm_bo_handle) * TBM_BO_NUM_MAX);
+#endif
}
VideoFrame::~VideoFrame() {
for (auto& callback : done_callbacks_)
std::move(callback).Run();
+
+#if defined(TIZEN_TBM_SUPPORT)
+ for (int i = 0; i < TBM_BO_NUM_MAX; i++) {
+ if (bo_handle_[i].ptr) {
+ if (!tbm_bo_unmap(bo_[i]))
+ LOG(WARNING) << "unmap bo failed!";
+ tbm_bo_unref(bo_[i]);
+ bo_handle_[i].ptr = nullptr;
+ }
+ }
+#endif
}
// static
namespace media {
+#if defined(TIZEN_TBM_SUPPORT)
constexpr auto TBM_BO_NUM_MAX = 4;
+#endif
class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
public:
const gfx::Size& natural_size);
#if defined(TIZEN_TBM_SUPPORT)
+#if BUILDFLAG(IS_TIZEN_TV)
+ static scoped_refptr<VideoFrame> WrapTBMInterProcessBuffer(
+ const gfx::Size& size,
+ base::TimeDelta timestamp,
+ gfx::TbmBufferHandle handle);
+#endif
// Needed when we have video-frame content in tbm surface.
static scoped_refptr<VideoFrame> WrapTBMSurface(const gfx::Size& size,
base::TimeDelta timestamp,
gpu::gles2::GLES2Interface* gl_;
unsigned image_id_;
scoped_refptr<viz::ContextProvider> context_provider_;
+
+ mutable tbm_bo bo_[TBM_BO_NUM_MAX] = {nullptr};
+ mutable tbm_bo_handle bo_handle_[TBM_BO_NUM_MAX] = {
+ {nullptr},
+ };
+ mutable tbm_key key_[TBM_BO_NUM_MAX] = {0};
+ mutable uint8_t* vp_[TBM_BO_NUM_MAX] = {nullptr};
+ mutable tbm_bufmgr bufmgr_ = {nullptr};
#endif
base::TimeDelta timestamp_;
case PIXEL_FORMAT_XR30:
case PIXEL_FORMAT_XB30:
case PIXEL_FORMAT_RGBAF16:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
return 1;
case PIXEL_FORMAT_NV12:
case PIXEL_FORMAT_NV21:
case PIXEL_FORMAT_P016LE:
+#if defined(TIZEN_TBM_SUPPORT)
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+#endif
return 2;
case PIXEL_FORMAT_I420:
case PIXEL_FORMAT_YV12:
return "PIXEL_FORMAT_YUV422AP10";
case PIXEL_FORMAT_YUV444AP10:
return "PIXEL_FORMAT_YUV444AP10";
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+ return "PIXEL_FORMAT_ENCODED";
+#endif
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
return "PIXEL_FORMAT_TBM_SURFACE";
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+ return "PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER";
#endif
}
NOTREACHED() << "Invalid VideoPixelFormat provided: " << format;
case PIXEL_FORMAT_YUV420AP10:
case PIXEL_FORMAT_YUV422AP10:
case PIXEL_FORMAT_YUV444AP10:
+#if defined(TIZEN_TBM_SUPPORT)
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+#endif
return true;
case PIXEL_FORMAT_UNKNOWN:
case PIXEL_FORMAT_XB30:
case PIXEL_FORMAT_BGRA:
case PIXEL_FORMAT_RGBAF16:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
#endif
case PIXEL_FORMAT_XB30:
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
#endif
return true;
case PIXEL_FORMAT_I420A:
case PIXEL_FORMAT_YUV420AP10:
case PIXEL_FORMAT_YUV422AP10:
case PIXEL_FORMAT_YUV444AP10:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
break;
}
return false;
case PIXEL_FORMAT_BGRA:
case PIXEL_FORMAT_I422A:
case PIXEL_FORMAT_I444A:
+#if defined(TIZEN_TBM_SUPPORT)
+ case PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+#endif
return 8;
case PIXEL_FORMAT_YUV420P9:
case PIXEL_FORMAT_YUV422P9:
PIXEL_FORMAT_YUV444AP10 = 38,
// Please update UMA histogram enumeration when adding new formats here.
+#if BUILDFLAG(IS_TIZEN)
+ PIXEL_FORMAT_ENCODED = 39, // encoded pixels, 1 plane
#if defined(TIZEN_TBM_SUPPORT)
- PIXEL_FORMAT_TBM_SURFACE = 39,
- PIXEL_FORMAT_MAX = PIXEL_FORMAT_TBM_SURFACE,
+ PIXEL_FORMAT_TBM_SURFACE = 40,
+ PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER = 41,
+ PIXEL_FORMAT_MAX = PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER,
+#else
+ PIXEL_FORMAT_MAX =
+ PIXEL_FORMAT_ENCODED, // Must always be equal to largest entry logged.
+#endif // defined(TIZEN_TBM_SUPPORT)
#else
PIXEL_FORMAT_MAX =
PIXEL_FORMAT_YUV444AP10, // Must always be equal to largest entry logged.
-#endif
+#endif // defined(OS_TIZEN)
};
// These values are persisted to logs. Entries should not be renumbered and
import("//media/gpu/args.gni")
import("//mojo/public/tools/bindings/mojom.gni")
+if (use_efl) {
+ import("//tizen_src/build/config/tizen_features.gni")
+}
mojom("stable_video_decoder") {
generate_java = true
if (is_linux || is_chromeos_ash) {
enabled_features += [ "is_linux_or_chromeos_ash" ]
}
+ if (is_tizen) {
+ enabled_features += [ "is_tizen" ]
+ }
+ if (tizen_tbm_support) {
+ enabled_features += [ "tizen_tbm_support" ]
+ }
public_deps = [
":native_pixmap_handle",
[MinVersion=1] kPixelFormatYUV420AP10 = 36,
[MinVersion=1] kPixelFormatYUV422AP10 = 37,
[MinVersion=1] kPixelFormatYUV444AP10 = 38,
+
+ [EnableIf=is_tizen] kPixelFormatEncoded = 39,
+
+ [EnableIf=tizen_tbm_support] kPixelFormatTbmSurface = 40,
+
+ [EnableIf=tizen_tbm_support] kPixelFormatTbmInterProcessBuffer=41,
+
};
// Based on |media.mojom.EosVideoFrameData|.
return media::stable::mojom::VideoPixelFormat::kPixelFormatYUV422AP10;
case ::media::VideoPixelFormat::PIXEL_FORMAT_YUV444AP10:
return media::stable::mojom::VideoPixelFormat::kPixelFormatYUV444AP10;
+#if BUILDFLAG(IS_TIZEN)
+ case ::media::VideoPixelFormat::PIXEL_FORMAT_ENCODED:
+ return media::stable::mojom::VideoPixelFormat::kPixelFormatEncoded;
+#if defined(TIZEN_TBM_SUPPORT)
+ case ::media::VideoPixelFormat::PIXEL_FORMAT_TBM_SURFACE:
+ return media::stable::mojom::VideoPixelFormat::kPixelFormatTbmSurface;
+ case ::media::VideoPixelFormat::PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER:
+ return media::stable::mojom::VideoPixelFormat::
+ kPixelFormatTbmInterProcessBuffer;
+#endif
+#endif
}
NOTREACHED();
case media::stable::mojom::VideoPixelFormat::kPixelFormatYUV444AP10:
*output = ::media::VideoPixelFormat::PIXEL_FORMAT_YUV444AP10;
return true;
+#if BUILDFLAG(IS_TIZEN)
+ case media::stable::mojom::VideoPixelFormat::kPixelFormatEncoded:
+ *output = ::media::VideoPixelFormat::PIXEL_FORMAT_ENCODED;
+ return true;
+#if defined(TIZEN_TBM_SUPPORT)
+ case media::stable::mojom::VideoPixelFormat::kPixelFormatTbmSurface:
+ *output = ::media::VideoPixelFormat::PIXEL_FORMAT_TBM_SURFACE;
+ return true;
+ case media::stable::mojom::VideoPixelFormat::
+ kPixelFormatTbmInterProcessBuffer:
+ *output =
+ ::media::VideoPixelFormat::PIXEL_FORMAT_TBM_INTER_PROCESS_BUFFER;
+ return true;
+#endif
+#endif
}
NOTREACHED();
case PIXEL_FORMAT_YUV422AP10:
case PIXEL_FORMAT_YUV444AP10:
case PIXEL_FORMAT_UNKNOWN:
+#if BUILDFLAG(IS_TIZEN)
+ case PIXEL_FORMAT_ENCODED:
+#endif
#if defined(TIZEN_TBM_SUPPORT)
case PIXEL_FORMAT_TBM_SURFACE:
#endif
PIXEL_FORMAT_XR30 = 30;
PIXEL_FORMAT_XB30 = 31;
PIXEL_FORMAT_TBM_SURFACE = 32;
+ PIXEL_FORMAT_ENCODED = 33;
};
// Proto version of Chrome's media::ColorSpace.