CRI Sofdec2  Last Updated: 2022-11-21 16:25 p
Video Frame Management

This section explains how to get and draw video frames using Sofdec2.

Getting Video Frames and Isolating the Drawing

The Sofdec2 library does not perform any video frame drawing whatsoever.
It only decodes video frames that should be displayed and sends it to the main memory.
This allows the application to draw freely, such as by displaying movies in full screen and mapping texture.

In order to play the movie back smoothly, the application will need to regularly (once every Vsync interval) get a video frame from the main loop and immediately display the video frames on time for display.
As long as the main loop is regularly working, there is no need for the application to adjust the drawing timing due to differences in PAL/NTSC screen refresh cycles or movie frame rates.

Getting Video Frames and Determining Time

Perform the following steps to get a video frame using Sofdec2.

Steps for Getting Video Frames Using Sofdec2
Step Description
(1) Decode Results Ref.
criManaPlayer_ReferFrame
It will successfully reference the frame independently of the display time if there are new decoding results.
(2) Determining Time for Display
criManaPlayer_IsFrameOnTime
Specify the frame information that was successfully referenced and confirm whether that frame is on time for display.
If it is on time for display, immediately display it.
(3) Copy/Convert Decoding Results
criManaPlayer_CopyFrame*****
Convert the decoding results into the format you wish to draw in. When using a pixel shader, the results will be copied to the various YUV texture regions. Hold these conversion results so that you can continue drawing until the next frame can be gotten.
(4) Discard Converted Video Frames
criManaPlayer_DiscardFrame
Discard the frame that was converted for drawing. You cannot get the next new frame until the frame is discarded.
CriManaFrameInfo frame_info;
/* (1) Are there any decoded frames? */
if (criManaPlayer_ReferFrame(mana, &frame_info) == CRI_TRUE) {
/* (2) Is the frame on time for display? */
if (criManaPlayer_ReferFrame(mana, &frame_info) == CRI_TRUE) {
/* (3) Convert decoding results into a texture format */
criManaPlayer_CopyFrameToBufferARGB32(mana, &frame_info, &texbuf);
/* (4) Discard the converted frame */
criManaPlayer_DiscardFrame(mana, &frame_info);
}
}
void criManaPlayer_CopyFrameToBufferARGB32(CriManaPlayerHn player, const CriManaFrameInfo *frame_info, CriManaTextureBuffer *frame_buf)
Get decoding results (32bit ARGB format)
void criManaPlayer_DiscardFrame(CriManaPlayerHn player, const CriManaFrameInfo *frame_info)
Release frame.
CriBool criManaPlayer_ReferFrame(CriManaPlayerHn player, CriManaFrameInfo *frame_info)
Refer to decoded frame information.
Video frame information.
Definition: cri_mana.h:850

If the application is controlling display timing then there is no need to call for (2) determination.
If for some reason you want to discard the gotten frame without displaying it, then omit (3) and immediately discard the frame.

Video Output Format

The Sofdec2 library decoding results are held in a unique YUV420 format.
In order to draw the decoding results, you will need to convert or copy them into a texture format or an ideal format for shader input.

The output formats that are supported vary by platform.
The following are main examples.

  • 32bit ARGB texture format
  • Individual YUV buffer format (for PixelShader)

Refer to the specific platform manual for more information on output formats that can actually be used.