MVD Services

MVD Services

This is for using the MVD hardware video decoder(unknown whether MVD can do more than decoding) + hardware color-format converter. The New_3DS Internet Browser uses mvd:STD for video decoding + YUV2RGB for decoded MJPEG frames.

See here for the supported hardware decoder video codecs.

There can only be one service session open at a time for each individual MVD service.

MVD Service “mvd:STD” #

Command HeaderAvailable since system versionDescriptionUsed by SKATER
0x000100828.1.0-0_New3DSInitializeYes
0x000200008.1.0-0_New3DSShutdownYes
0x000303008.1.0-0_New3DSCalculateWorkBufSizeYes
0x000400C08.1.0-0_New3DSCalculateImageSizeNo
0x000501008.1.0-0_New3DS(s8 unk0, s8 unk1, s8 unk2, u32 unk3) SKATER uses hard-coded value 0 for all of these params. Using different input data for this doesn’t seem to affect video-processing output.Yes
0x000600008.1.0-0_New3DSUnknown.No
0x000700008.1.0-0_New3DSUsed during shutdown with video-processing.Yes
0x000801428.1.0-0_New3DSProcessNALUnitYes
0x000900428.1.0-0_New3DSControlFrameRenderingYes
0x000A00008.1.0-0_New3DSGetStatusYes
0x000B00008.1.0-0_New3DSGetStatusOther(unknown what this is used for). Same output size as GetStatus.No
0x000C01008.1.0-0_New3DS(u8 unk0, s8 unk1, u32 unk2, u32 unk3) Unknown.No
0x000D00008.1.0-0_New3DSUnknown.No
0x000E02028.1.0-0_New3DSUnknown. The code for this appears to be similar to ProcessNALUnit, this DMAs data from the input buffer as well.No
0x000F00428.1.0-0_New3DS(s8 unk, val0, handle) Unknown. Presumably the command 0x000E0202 version of MVDSTD:ControlFrameRendering.No
0x001000008.1.0-0_New3DSUnknown. This writes 0x28-bytes of output starting at cmdreply[2].No
0x001100008.1.0-0_New3DSUnknown.No
0x001200C08.1.0-0_New3DS(s8 unk0, u32 unk1, u32 unk2) Unknown.No
0x001300008.1.0-0_New3DSUnknown.No
0x001400C28.1.0-0_New3DSUnknown. The code for this appears to be similar to ProcessNALUnit, this DMAs data from the input buffer as well.No
0x001500428.1.0-0_New3DS(s8 unk, val0, handle) Unknown. Presumably the command 0x001400C2 version of MVDSTD:ControlFrameRendering.No
0x001600008.1.0-0_New3DSUnknown.No
0x001700008.1.0-0_New3DSUnknown.No
0x001800008.1.0-0_New3DSUnknown. Used during initialization regardless of the operation mode(color-conversion/video-processing).Yes
0x001900008.1.0-0_New3DSUnknown. Used during shutdown regardless of the operation mode(color-conversion/video-processing).Yes
0x001A00008.1.0-0_New3DSUsed when doing color-format conversion. This triggers writing to the output buffer specified via config.Yes
0x001B00408.1.0-0_New3DS(u8 inval) Used during video-processing initialization. SKATER uses hard-coded value 1 for this. MVD-sysmodule checks that the input value is not 0 or higher than 11. The input value must be one of the following: 1, 6, 9, or 10. Using any of these values instead of 1 results in no data being written to the output buffer with normal video processing, without any errors being thrown.Yes
0x001C00008.1.0-0_New3DSUsed during shutdown with video-processing.Yes
0x001D00428.1.0-0_New3DSGetConfigYes
0x001E00448.1.0-0_New3DSSetConfigYes
0x001F09028.1.0-0_New3DSSetupOutputBuffersNo
0x002000028.1.0-0_New3DS(val0, handle) Unknown. This loads data from the table entry which has a field matching a certain value. This is the global table used by SetupOutputBuffers.No
0x002101008.1.0-0_New3DSOverrideOutputBuffersNo

This one uses the I/O mapped @ 0x10207000.

This service is used by the New_3DS Internet Browser. SKATER runs the entire MVD initialization/shutdown each time the video player is entered/exited.

Linear-memory vaddrs passed to this service should be in the 0x30* region, MVD-sysmodule doesn’t support the 0x14* region.

By default MVD does(?) various post-processing with the output image, this is controlled by the configuration. This post-processing isn’t done at all in certain cases.

Initialization procedures:

  • Color-conversion: Use command MVDSTD:Initialize with bufsize=1, then command 0x00180000.
  • H.264: If needed, use MVDSTD:CalculateWorkBufSize. Then use MVDSTD:Initialize. Then use commands 0x00050100, 0x00180000, and 0x001B0040. Then use MVDSTD:ProcessNALUnit for each of the individual NAL-unit parameter sets(“Sequence Parameter Set” and “Picture Parameter Set”), with the main video processing starting afterwards.

Shutdown procedures:

  • Color-conversion: just use command 0x00190000, then MVDSTD:Shutdown.
  • H.264: Use command 0x00090042 in a loop, waiting for it to return a retval that isn’t 0x00017002. Then use commands 0x001C0000, 0x00190000, and 0x00070000. Then use MVDSTD:Shutdown.

MVDSTD configuration structure #

OffsetSizeDescription
0x00x4Input format type, see below.
0x40x4The default for this is 0x0. Must be <=5. When non-zero, the type value at offset 0x0 must be one of the following: 0x00020001, 0x00010001, 0x00010005, 0x00010006, or 0x00010007. Doesn’t seem to have any visible affect on the output for video processing.
0x80x4The default for this is 0x0. This must be <=1. Referred to as “H264 range” in SKATER. When 0x1 the output image is brighter than normal.
0x0C0x4Input video width. Must be >=width_min and <width_max. This must be aligned: the low <dimensions_alignment>-bits must be clear.
0x100x4Input video height. Must be >=height_min and <height_max. This must be aligned: the low <dimensions_alignment>-bits must be clear.
0x140x4Input data physical address, only set for color-conversion. This isn’t used when the value at offset 0x4 is 0x1 or 0x5.
0x180x4Physical data address, only used for color-conversion when the type value has bitmask 0x20000 set. This isn’t used when the value at offset 0x4 is 0x1 or 0x5.
0x1C0x4Physical data address, only used for color-conversion when the type value is 0x20000. This isn’t used when the value at offset 0x4 is 0x1 or 0x5.
0x200x4Physical data address, for color-conversion. This isn’t used when the value at offset 0x4 is 0x0 or 0x4.
0x240x4Physical data address, only used for color-conversion when the type value has bitmask 0x20000 set. This isn’t used when the value at offset 0x4 is 0x0 or 0x4.
0x280x4Unknown. Doesn’t seem to have any visible affect on the output.
0x2C0x4When non-zero this enables some sort of color adjustment for the output?
0x300x4Same affect as offset 0x2C? This must not be enabled at the same time as that field.
0x340x4Unknown, must be <8 for video-processing? Doesn’t seem to have any visible affect on the output.
0x380x4Unknown. Doesn’t seem to have any visible affect on the output.
0x3C0x4Unknown, must be <8 for video-processing? Doesn’t seem to have any visible affect on the output.
0x400x4When non-zero this enables usage of the 4 words starting at offset 0x44. SKATER sets this to 0x0 for color-conversion, and 0x1 for video processing(this flag isn’t mandatory for the latter).
0x440x4See offset 0x40. The default for this is 0x0. u32 input_crop_x_pos. Must be <=widthval. Where widthval = <width value from the field at offset 0xC>. The low 4-bits of this value must be clear.
0x480x4See offset 0x40. The default for this is 0x0. u32 input_crop_y_pos. Must be <=heightval. Where heightval = <height value from the field at offset 0x10>. The low 4-bits of this value must be clear.
0x4C0x4See offset 0x40. u32 input_crop_height. Must be >=16 and <=heightval. Where heightval = <height value from the field at offset 0x10>. The low 3-bits of this value must be clear.
0x500x4See offset 0x40. u32 input_crop_width. Must be >=width_min and <=widthval. Where widthval = <width value from the field at offset 0xC>. The low 3-bits of this value must be clear.
0x540x4The default for this is 0x0. Must be <=5. For video processing, and when this value is non-zero, the type value at offset 0x0 must not be any of the following: 0x00010004, 0x00010001, 0x0x00100001, or 0x00200001. For video processing, the type value at offset 0x0 must not be 0x80000 when this value at offset 0x54 is non-zero.
0x580x4Output format type, see below. SKATER writes value 0x40002 here.
0x5C0x4Output video width. Must be >=16, and must be <somewidth_statefield.
0x600x4Output video height. Must be >=16, and must be <someheight_statefield.
0x640x4Output data physical address.
0x680x4Additional output data physical address. This is only used when the output format type is value 0x00020001.
0x6C0x4Unknown, doesn’t seem to have a visible affect on the output. Must be <3 for video-processing?
0x700x4Unknown, doesn’t seem to have a visible affect on the output.
0x740x4Unknown, doesn’t seem to have a visible affect on the output.
0x780x4Unknown, doesn’t seem to have a visible affect on the output.
0x7C0x4Unknown, doesn’t seem to have a visible affect on the output.
0x800x4Unknown. Must be <=1 for video processing? Doesn’t seem to have a visible affect on the output.
0x840x4Unknown, doesn’t seem to have a visible affect on the output.
0x880x4Unknown, doesn’t seem to have a visible affect on the output.
0x8C0x4Unknown, doesn’t seem to have a visible affect on the output.
0x900x4Unknown, doesn’t seem to have a visible affect on the output.
0x940x4Unknown, doesn’t seem to have a visible affect on the output.
0x980x4Unknown, doesn’t seem to have a visible affect on the output.
0x9C0x4Unknown, doesn’t seem to have a visible affect on the output.
0xA00x4Unknown, doesn’t seem to have a visible affect on the output.
0xA40x4Unknown, doesn’t seem to have a visible affect on the output.
0xA80x4Unknown, doesn’t seem to have a visible affect on the output.
0xAC0x4Unknown, must be zero for video-processing.
0xB00x28Unknown, doesn’t seem to have a visible affect on the output.
0xD80x4Unknown, must be zero for video-processing.
0xDC0x28Unknown, doesn’t seem to have a visible affect on the output.
0x1040x4This flag enables using the following 4 words when non-zero.
0x1080x4u32 output_x_pos. Output X position in the output buffer.
0x10C0x4u32 output_y_pos. Same as above except for the Y pos.
0x1100x4u32 output_width_override. The low 2-bits must be clear. When the output width is less than this, this value is used to align the output image width to the specified value via value0-pixels. When this value is less than the output width, this value is used for the output width instead.
0x1140x4Same as the field at offset 0x110 except for the output height.
0x1180x4Unknown, when non-zero it seems the output buffer isn’t written any more?

The size of this structure is fixed to 0x11C-bytes. The user process does the LINEAR-mem vaddr->physaddr conversion for the above physaddrs, when modifying the config struct before using MVDSTD:SetConfig. For the above physaddrs that are checked/used, the physaddr must not be 0x0, and the physaddr must be 8-byte aligned(low 3-bits clear).

For color-conversion, the output frame is split into two images via the two output physaddrs.

For *_min/*_max/dimensions_alignment mentioned above: *_min = 16 for color-conversion, 48 for video processing. *_max = 2048 for color-conversion, 4672 for video processing. dimensions_alignment = 4 for color-conversion, 3 for video processing.

The configuration doesn’t seem to change at all while SKATER is running video processing(each MVDSTD:SetConfig input config appears to the same).

SKATER video processing config #

When processing video, SKATER gets the config, updates all of the fields listed below, then uses MVDSTD:SetConfig.

OffsetSizeDescriptionWritten value
0x00x4Input format type.0x00020001(H.264), hard-coded.
0x80x4Loaded from unique input state. This is the ‘range’ field in the following debug print: “H264 w=%d h=%d range=%d pics=%d multi=%d\n”.
0xC0x4Input video width.Loaded from unique input state.
0x100x4Input video height.Loaded from unique input state.
0x400x4Flag0x1, hard-coded.
0x440x4Loaded from unique input state.
0x480x4Loaded from unique input state.
0x4C0x4Loaded from unique input state.
0x500x4Loaded from unique input state.
0x540x40x0, hard-coded.
0x580x4Output format type.Loaded from unique input state.
0x5C0x4Output video width.Loaded from unique input state.
0x600x4Output video height.Loaded from unique input state.
0x640x4Output data physical address.
0x680x4Output data physical address, only set for color-conversion.0x0, hard-coded.
0xA80x40x1, hard-coded.
0xAC0x40x0, hard-coded.
0xD80x40x0, hard-coded.
0x1040x40x1, hard-coded.
0x1080x4Loaded from unique input state.
0x10C0x4Loaded from unique input state.
0x1100x4Loaded from unique input state.
0x1140x4Loaded from unique input state.
0x1180x40x0, hard-coded.

“Loaded from unique input state” refers to the field being loaded from state seperate from the other fields used for this configuration structure.

Input formats #

Type valueModeVideo processingColor conversion
0x00010001Color conversionN/AYUYV422
0x00010002Video processingH.264, but no output will be written to output buffer with error code 0xD961710AN/A
0x00010004Video processingH.264, but no output will be written to output buffer with error code 0xD961710AN/A
0x00010005Color conversion, Video processingH.264, but no output will be written to output buffer with error code 0xD961710AYVYU422
0x00010006Color conversion, Video processingH.264, but no output will be written to output buffer with error code 0xD961710AUYVY422
0x00010007Color conversion, Video processingH.264, but no output will be written to output buffer with error code 0xD961710AVYUY422?
0x00020000Video processingH.264, but no output will be written to output buffer with error code 0xD961710AN/A
0x00020001Video processingH.264N/A
0x00020002Video processingH.264, output will be corrupt a little??N/A
0x00080000Video processingH.264, output will be gray-scale.N/A
0x00080001Video processingH.264, but no output will be written to output buffer with error code 0xD961710AN/A
0x00180001Video processingH.264, but no output will be written to output buffer with error code 0xD961710AN/A

Output formats #

Type valueDescriptionNote
0x00010001YUYV422N/A
0x00010005YVYU422A certain MVD state field must not be set to 0x8170 in order to use this.
0x00010006UYVY422see 0x00010005 for the usage requirement.
0x00010007VYUY422see 0x00010005 for the usage requirement.
0x00010008YUYV422 with some align?A certain MVD-module state field must not be set to 0x8170 in order to use this. Whether this can actually be used is determined by another MVD-module state field. 16bit format.
0x00010009YVYU422 with some align?see 0x00010008 for the usage requirements. 16bit format.
0x0001000AUYVY422 with some align?see 0x00010008 for the usage requirements. 16bit format.
0x0001000BVYUY422 with some align?see 0x00010008 for the usage requirements. 16bit format.
0x00020001Some sort of YUV format?12bit format. The initial output is written to the normal output buffer, then the rest is written to the additional output buffer dedicated to this out-type.
0x00040000UnknownDoesn’t write anything to the out-buffer when doing color-conversion.
0x00040001ARGB1555?N/A
0x00040002RGB565N/A
0x00040003ABGR1555?N/A
0x00040004BGR565N/A
0x00041000UnknownDoesn’t write anything to the out-buffer when doing color-conversion.
0x00041001ARGB32N/A
0x00041002ABGR32N/A

MVD Service “l2b:u” #

This one uses the I/O mapped @ 0x10130000.

Command HeaderDescription
0x00010040SetInputFormat?
0x00020080GetInputFormat?
0x00030040SetOutputFormat
0x00040080GetOutputFormat
0x00050040SetTransferEndInterrupt
0x00060080GetTransferEndInterrupt
0x00070080GetL2BEndEvent
0x00080102?
0x00090080Waits on a DMA Handle
0x000A0102MaybeSetRecieving
0x000B0080isDoneRecieving
0x000C0040SetInputLineWidth
0x000D0080GetInputLineWidth
0x000E0040SetInputLines
0x000F0080GetInputLines
0x00100040MaybeSetAlpha
0x00110080MaybeGetAlpha
0x00120040StartConversion
0x00130040StopConversion
0x00140080isBusyConversion
0x00150040SetPackageParameter
0x00160080GetPackageParameter
0x00170080PingProcess

MVD Service “l2b2:u” #

This uses the same command-handler as “l2b:u”.

MVD Service “y2r2:u” #

This is a exact copy of y2r camera service and hence named y2r2.

MVD Result-codes #

Result-codeInternal MVD status-codeDescription
0xD961710FInvalid configuration, mainly when setting the config.
0xD96170CA-2(~1)
0xE16170C9-1(~0)
0xF96171C8-0xFB(~0xFA)
0x170000x0OK
0x170010x1Returned after processing NAL-unit parameter-sets.
0x170020x2Busy. When returned by command 0x00090042 during video processing, SKATER uses the { MVDSTD:GetConfig, MVDSTD:SetConfig, and 0x00090042} commands again(same config as before). The SKATER code for this includes this debug string: “H264 output %lld us corrected to %lld us\n”.
0x170030x3
0x170040x4Returned when not all of the input NAL-unit buffer was processed.
0x170050x5
0x170060x6
0x170070x7
0x17038

Supported H.264 Levels and Profiles #

LevelBaselineMainHighHigh 10 (High10, High10p, Hi10p or 10-bit H.264)High 4:2:2 (High422p or High422)High 4:4:4 Predictive (Hi444PP)
1YesYesYesYesUntestedUntested
1bYesYesYesYesUntestedUntested
1.1YesYesYesYesUntestedUntested
1.2YesYesYesYesUntestedUntested
1.3YesYesYesYesUntestedUntested
2YesYesYesYesUntestedUntested
2.1YesYesYesYesUntestedUntested
2.2YesYesYesYesUntestedUntested
3YesYesYesYesUntestedUntested
3.1YesYesYesYesUntestedUntested
3.2YesYesYesYesUntestedUntested
4No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)
4.1No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)
4.2No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)
5No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)
5.1No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)
5.2No (untested)No (untested)No (untested)No (untested)No (untested)No (untested)

created using the New 3DS Internet Browser, New 3DS Internet Browser Specs and the following test pages: ๐Ÿ”— Baseline Profile Test ๐Ÿ”— Main Profile Test ๐Ÿ”— High Profile Test ๐Ÿ”— High10 Profile Test