]> Chaos Git - corbenik/ctrulib.git/commitdiff
Moved rendering code from mvdstdProcessVideoFrame() into a seperate function.
authoryellows8 <yellows8@users.noreply.github.com>
Fri, 22 Apr 2016 16:12:32 +0000 (12:12 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Fri, 22 Apr 2016 16:12:32 +0000 (12:12 -0400)
libctru/include/3ds/services/mvd.h
libctru/source/services/mvd.c

index 530fa98e8bd326bb8344d256f76017034aa346cc..54bb1c8593857a872adb3c8603eb81ba0d0e4ef8 100644 (file)
@@ -36,7 +36,11 @@ typedef struct {
        u32 inwidth;                     ///< Input width.
        u32 inheight;                    ///< Input height.
        u32 physaddr_colorconv_indata;   ///< Physical address of color conversion input data.
-       u32 unk_x18[0x28>>2];            ///< Unknown.
+       u32 physaddr_colorconv_unk0;     ///< Physical address used with color conversion.
+       u32 physaddr_colorconv_unk1;     ///< Physical address used with color conversion.
+       u32 physaddr_colorconv_unk2;     ///< Physical address used with color conversion.
+       u32 physaddr_colorconv_unk3;     ///< Physical address used with color conversion.
+       u32 unk_x28[0x18>>2];            ///< Unknown.
        u32 flag_x40;                    ///< Unknown. 0x0 for colorconv, 0x1 for H.264
        u32 unk_x44;                     ///< Unknown.
        u32 unk_x48;                     ///< Unknown.
@@ -87,12 +91,17 @@ Result mvdstdConvertImage(MVDSTD_Config* config);
 
 /**
  * @brief Processes a video frame(specifically a NAL-unit).
- * @param config Pointer to the configuration to use.
- * @parameter_set Must be true for the initial NAL-unit parameter sets("Sequence Parameter Set" and "Picture Parameter Set"), false otherwise.
  * @param inbuf_vaddr Input NAL-unit starting with the 3-byte "00 00 01" prefix. Must be located in linearmem.
  * @param size Size of the input buffer.
  */
-Result mvdstdProcessVideoFrame(MVDSTD_Config* config, bool parameter_set, void* inbuf_vaddr, size_t size);
+Result mvdstdProcessVideoFrame(void* inbuf_vaddr, size_t size);
+
+/**
+ * @brief Renders the video frame.
+ * @param config Optional pointer to the configuration to use. When NULL, MVDSTD_SetConfig() should have been used previously for this video.
+ * @param wait When true, wait for rendering to finish. When false, you can manually call this function repeatedly until it stops returning MVD_STATUS_BUSY.
+ */
+Result mvdstdRenderVideoFrame(MVDSTD_Config* config, bool wait);
 
 /**
  * @brief Sets the current configuration of MVDSTD.
index 1c6415764a6a1e0c87a393e107195cdd461d77e1..f25c482df3862f257d8e3e612e668276e85b40f1 100644 (file)
@@ -319,26 +319,40 @@ Result mvdstdConvertImage(MVDSTD_Config* config)
        return MVDSTD_cmd1a();
 }
 
-Result mvdstdProcessVideoFrame(MVDSTD_Config* config, bool parameter_set, void* inbuf_vaddr, size_t size)
+Result mvdstdProcessVideoFrame(void* inbuf_vaddr, size_t size)
 {
        Result ret;
 
        if(mvdstdRefCount==0)return -3;
-       if(config==NULL)return -1;
        if(mvdstd_mode!=MVDMODE_VIDEOPROCESSING)return -2;
 
        ret = MVDSTD_ProcessNALUnit((u32)inbuf_vaddr, (u32)osConvertVirtToPhys(inbuf_vaddr), size, mvdstd_videoproc_frameid);
        mvdstd_videoproc_frameid++;
        if(mvdstd_videoproc_frameid>=0x12)mvdstd_videoproc_frameid = 0;
-       //if(ret!=MVD_STATUS_OK)return ret;
 
-       if(parameter_set)return ret;
+       return ret;
+}
 
-       ret = MVDSTD_SetConfig(config);
-       if(ret!=MVD_STATUS_OK)return ret;
+Result mvdstdRenderVideoFrame(MVDSTD_Config* config, bool wait)
+{
+       Result ret;
+
+       if(mvdstdRefCount==0)return -3;
+       if(config==NULL)return -1;
+       if(mvdstd_mode!=MVDMODE_VIDEOPROCESSING)return -2;
+
+       if(config)
+       {
+               ret = MVDSTD_SetConfig(config);
+               if(ret!=MVD_STATUS_OK)return ret;
+       }
 
        ret = MVD_STATUS_BUSY;
-       while(ret==MVD_STATUS_BUSY)ret = MVDSTD_ControlFrameRendering(0);
+       while(ret==MVD_STATUS_BUSY)
+       {
+               ret = MVDSTD_ControlFrameRendering(0);
+               if(!wait)break;
+       }
 
        return ret;
 }