int Transfer::do_process_plane (::VSFrameRef &dst, int n, int plane_index, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, const vsutl::NodeRefSPtr &src_node1_sptr, const vsutl::NodeRefSPtr &src_node2_sptr, const vsutl::NodeRefSPtr &src_node3_sptr) { assert (src_node1_sptr.get () != 0); int ret_val = 0; const vsutl::PlaneProcMode proc_mode = _plane_processor.get_mode (plane_index); if (proc_mode == vsutl::PlaneProcMode_PROCESS) { vsutl::FrameRefSPtr src_sptr ( _vsapi.getFrameFilter (n, src_node1_sptr.get (), &frame_ctx), _vsapi ); const ::VSFrameRef & src = *src_sptr; const int w = _vsapi.getFrameWidth (&src, plane_index); const int h = _vsapi.getFrameHeight (&src, plane_index); const uint8_t* data_src_ptr = _vsapi.getReadPtr (&src, plane_index); const int stride_src = _vsapi.getStride (&src, plane_index); uint8_t * data_dst_ptr = _vsapi.getWritePtr (&dst, plane_index); const int stride_dst = _vsapi.getStride (&dst, plane_index); _lut_uptr->process_plane ( data_dst_ptr, data_src_ptr, stride_dst, stride_src, w, h ); } return (ret_val); }
const ::VSFrameRef * Transfer::get_frame (int n, int activation_reason, void * &frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core) { assert (n >= 0); assert (&frame_data_ptr != 0); assert (&frame_ctx != 0); assert (&core != 0); ::VSFrameRef * dst_ptr = 0; ::VSNodeRef & node = *_clip_src_sptr; if (activation_reason == ::arInitial) { _vsapi.requestFrameFilter (n, &node, &frame_ctx); } else if (activation_reason == ::arAllFramesReady) { vsutl::FrameRefSPtr src_sptr ( _vsapi.getFrameFilter (n, &node, &frame_ctx), _vsapi ); const ::VSFrameRef & src = *src_sptr; const int w = _vsapi.getFrameWidth (&src, 0); const int h = _vsapi.getFrameHeight (&src, 0); dst_ptr = _vsapi.newVideoFrame (_vi_out.format, w, h, &src, &core); const int ret_val = _plane_processor.process_frame ( *dst_ptr, n, frame_data_ptr, frame_ctx, core, _clip_src_sptr ); if (ret_val == 0) { // Output frame properties ::VSMap & dst_prop = *(_vsapi.getFramePropsRW (dst_ptr)); const int cr_val = (_full_range_dst_flag) ? 0 : 1; _vsapi.propSetInt (&dst_prop, "_ColorRange", cr_val, ::paReplace); int transfer = fmtcl::TransCurve_UNSPECIFIED; if (_curve_d >= 0 && _curve_d <= fmtcl::TransCurve_ISO_RANGE_LAST) { transfer = _curve_d; } _vsapi.propSetInt (&dst_prop, "_Transfer", transfer, ::paReplace); } if (ret_val != 0) { _vsapi.freeFrame (dst_ptr); dst_ptr = 0; } } return (dst_ptr); }
// To be called in arAllFramesReady mode // In manual mode, all planes are called for processing. int PlaneProcessor::process_frame (::VSFrameRef &dst, int n, void *frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core, NodeRefSPtr src_node1_sptr, NodeRefSPtr src_node2_sptr, NodeRefSPtr src_node3_sptr) { assert (&dst != 0); assert (n >= 0); assert (&frame_ctx != 0); assert (&core != 0); assert (_input_flag); int ret_val = 0; for (int plane_index = 0 ; plane_index < _nbr_planes && ret_val == 0 ; ++plane_index) { const double mode = _proc_mode_arr [plane_index]; const int mode_i = fstb::round_int (mode); if (_manual_flag || mode_i == PlaneProcMode_PROCESS) { ret_val = _cb.process_plane ( dst, n, plane_index, frame_data_ptr, frame_ctx, core, src_node1_sptr, src_node2_sptr, src_node3_sptr ); } else if (mode_i >= PlaneProcMode_COPY1 && mode_i <= PlaneProcMode_COPY3) { NodeRefSPtr src_clip_sptr ( (mode_i == PlaneProcMode_COPY3) ? src_node3_sptr : (mode_i == PlaneProcMode_COPY2) ? src_node2_sptr : src_node1_sptr); if (src_clip_sptr.get () != 0) { FrameRefSPtr src_sptr ( _vsapi.getFrameFilter (n, src_clip_sptr.get (), &frame_ctx), _vsapi ); copy_plane (dst, *src_sptr, plane_index); } } else if (mode < PlaneProcMode_COPY1) { fill_plane (dst, -mode, plane_index); } } return (ret_val); }
const ::VSFrameRef * Matrix::get_frame (int n, int activation_reason, void * &frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core) { assert (n >= 0); assert (&frame_data_ptr != 0); assert (&frame_ctx != 0); assert (&core != 0); ::VSFrameRef * dst_ptr = 0; ::VSNodeRef & node = *_clip_src_sptr; if (activation_reason == ::arInitial) { _vsapi.requestFrameFilter (n, &node, &frame_ctx); } else if (activation_reason == ::arAllFramesReady) { vsutl::FrameRefSPtr src_sptr ( _vsapi.getFrameFilter (n, &node, &frame_ctx), _vsapi ); const ::VSFrameRef & src = *src_sptr; const int w = _vsapi.getFrameWidth (&src, 0); const int h = _vsapi.getFrameHeight (&src, 0); dst_ptr = _vsapi.newVideoFrame (_vi_out.format, w, h, &src, &core); uint8_t * const dst_ptr_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getWritePtr (dst_ptr, 0), (_plane_out >= 0) ? 0 : _vsapi.getWritePtr (dst_ptr, 1), (_plane_out >= 0) ? 0 : _vsapi.getWritePtr (dst_ptr, 2) }; const int dst_str_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getStride (dst_ptr, 0), (_plane_out >= 0) ? 0 : _vsapi.getStride (dst_ptr, 1), (_plane_out >= 0) ? 0 : _vsapi.getStride (dst_ptr, 2) }; const uint8_t * const src_ptr_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getReadPtr (&src, 0), _vsapi.getReadPtr (&src, 1), _vsapi.getReadPtr (&src, 2) }; const int src_str_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getStride (&src, 0), _vsapi.getStride (&src, 1), _vsapi.getStride (&src, 2) }; _proc_uptr->process ( dst_ptr_arr, dst_str_arr, src_ptr_arr, src_str_arr, w, h ); // Output frame properties if (_range_set_dst_flag || _csp_out != fmtcl::ColorSpaceH265_UNSPECIFIED) { ::VSMap & dst_prop = *(_vsapi.getFramePropsRW (dst_ptr)); if (_range_set_dst_flag) { const int cr_val = (_full_range_dst_flag) ? 0 : 1; _vsapi.propSetInt (&dst_prop, "_ColorRange", cr_val, ::paReplace); } if ( _csp_out != fmtcl::ColorSpaceH265_UNSPECIFIED && _csp_out <= fmtcl::ColorSpaceH265_ISO_RANGE_LAST) { _vsapi.propSetInt (&dst_prop, "_Matrix" , int (_csp_out), ::paReplace); _vsapi.propSetInt (&dst_prop, "_ColorSpace", int (_csp_out), ::paReplace); } } } return (dst_ptr); }
const ::VSFrameRef * Primaries::get_frame (int n, int activation_reason, void * &frame_data_ptr, ::VSFrameContext &frame_ctx, ::VSCore &core) { assert (n >= 0); ::VSFrameRef * dst_ptr = 0; ::VSNodeRef & node = *_clip_src_sptr; if (activation_reason == ::arInitial) { _vsapi.requestFrameFilter (n, &node, &frame_ctx); } else if (activation_reason == ::arAllFramesReady) { vsutl::FrameRefSPtr src_sptr ( _vsapi.getFrameFilter (n, &node, &frame_ctx), _vsapi ); const ::VSFrameRef & src = *src_sptr; const int w = _vsapi.getFrameWidth (&src, 0); const int h = _vsapi.getFrameHeight (&src, 0); dst_ptr = _vsapi.newVideoFrame (_vi_out.format, w, h, &src, &core); uint8_t * const dst_ptr_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getWritePtr (dst_ptr, 0), _vsapi.getWritePtr (dst_ptr, 1), _vsapi.getWritePtr (dst_ptr, 2) }; const int dst_str_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getStride (dst_ptr, 0), _vsapi.getStride (dst_ptr, 1), _vsapi.getStride (dst_ptr, 2) }; const uint8_t * const src_ptr_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getReadPtr (&src, 0), _vsapi.getReadPtr (&src, 1), _vsapi.getReadPtr (&src, 2) }; const int src_str_arr [fmtcl::MatrixProc::NBR_PLANES] = { _vsapi.getStride (&src, 0), _vsapi.getStride (&src, 1), _vsapi.getStride (&src, 2) }; _proc_uptr->process ( dst_ptr_arr, dst_str_arr, src_ptr_arr, src_str_arr, w, h ); // Output properties ::VSMap & dst_prop = *(_vsapi.getFramePropsRW (dst_ptr)); const fmtcl::PrimariesPreset preset_d = _prim_d._preset; if (preset_d >= 0 && preset_d < fmtcl::PrimariesPreset_NBR_ELT) { _vsapi.propSetInt (&dst_prop, "_Primaries", int (preset_d), ::paReplace); } else { _vsapi.propDeleteKey (&dst_prop, "_Primaries"); } } return (dst_ptr); }