{"id":13435580,"url":"https://github.com/rockchip-linux/mpp","last_synced_at":"2025-03-18T11:31:37.555Z","repository":{"id":37742993,"uuid":"61082656","full_name":"rockchip-linux/mpp","owner":"rockchip-linux","description":"Media Process Platform (MPP) module","archived":false,"fork":false,"pushed_at":"2024-05-08T08:04:28.000Z","size":16075,"stargazers_count":419,"open_issues_count":217,"forks_count":146,"subscribers_count":14,"default_branch":"develop","last_synced_at":"2024-05-11T10:00:32.249Z","etag":null,"topics":["hardware-acceleration","media-library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rockchip-linux.png","metadata":{"files":{"readme":"readme.txt","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/Apache-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-14T01:44:53.000Z","updated_at":"2024-05-22T03:26:46.856Z","dependencies_parsed_at":"2024-05-22T03:26:45.744Z","dependency_job_id":"2a4e9f29-d61e-4c23-8832-e99f847b2c90","html_url":"https://github.com/rockchip-linux/mpp","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockchip-linux%2Fmpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockchip-linux%2Fmpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockchip-linux%2Fmpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockchip-linux%2Fmpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rockchip-linux","download_url":"https://codeload.github.com/rockchip-linux/mpp/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244211036,"owners_count":20416572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hardware-acceleration","media-library"],"created_at":"2024-07-31T03:00:37.058Z","updated_at":"2025-03-18T11:31:32.545Z","avatar_url":"https://github.com/rockchip-linux.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"Media Process Platform (MPP) module directory description:\n\nMPP    : Media Process Platform\nMPI    : Media Process Interface\nHAL    : Hardware Abstract Layer\nOSAL   : Operation System Abstract Layer\n\nRules:\n1. header file arrange rule\na. inc directory in each module folder is for external module usage.\nb. module internal header file should be put along with the implement file.\nc. header file should not contain any relative path or absolute path, all\n   include path should be keep in Makefile.\n2. compiling system rule\na. for cross platform compiling use cmake as the compiling management system.\nb. use cmake out-of-source build, final binary and library will be install to\n   out/ directory.\n3. header file include order\na. MODULE_TAG\nb. system header\nc. osal header\nd. module header\n\nNOTE:\n1. Windows support is NOT maintained any more.\n2. Mpp support all rockchip chipset now including:\n   RK29XX/RK30XX/RK31XX\n   RK3288/RK3368/RK3399\n   RK3228/RK3229/RK3228H/RK3328\n   RK3528/RK3528A\n   RK3562\n   RK3566/RK3568\n   RK3588\n   RV1108/RV1107\n   RV1109/RV1126\n3. Mpp support all format hardware can support except VC1.\n4. you can get demo about mpp applied to linux and android.\n     Liunx : https://github.com/WainDing/mpp_linux_cpp\n             https://github.com/MUZLATAN/ffmpeg_rtsp_mpp\n             https://github.com/nyanmisaka/ffmpeg-rockchip\n     Android : https://github.com/c-xh/RKMediaCodecDemo\n5. offical github: https://github.com/rockchip-linux/mpp\n   develop github: https://github.com/HermanChen/mpp\n   develop gitee : https://gitee.com/hermanchen82/mpp\n6. Commit message format should base on https://keepachangelog.com/en/1.0.0/\n\nMore document can be found at http://opensource.rock-chips.com/wiki_Mpp\n\n----                             top\n   |\n   |----- build                  CMake out-of-source build directory\n   |  |\n   |  |----- cmake               cmake script directory\n   |  |\n   |  |----- android             android build directory\n   |  |\n   |  |----- linux               linux build directory\n   |  |\n   |  |----- vc10-x86_64         visual studio 2010 on x86_64 build directory\n   |  |\n   |  |----- vc12-x86_64         visual studio 2013 on x86_64 build directory\n   |\n   |----- doc                    design documents of mpp\n   |\n   |----- inc                    header file for external usage, including\n   |                             platform header and mpi header\n   |\n   |----- mpp                    Media Process Platform : mpi function private\n   |  |                          implement and mpp infrastructure (vpu_api\n   |  |                          private layer)\n   |  |\n   |  |----- base                base components including MppBuffer, MppFrame,\n   |  |                          MppPacket, MppTask, MppMeta, etc.\n   |  |\n   |  |----- common              video codec protocol syntax interface for both\n   |  |                          codec parser and hal\n   |  |\n   |  |----- codec               all video codec parser, convert stream to\n   |  |  |                       protocol structure\n   |  |  |\n   |  |  |----- inc              header files provided by codec module for\n   |  |  |                       external usage\n   |  |  |\n   |  |  |----- dec\n   |  |  |  |\n   |  |  |  |----- dummy         decoder parser work flow sample\n   |  |  |  |\n   |  |  |  |----- h263\n   |  |  |  |\n   |  |  |  |----- h264\n   |  |  |  |\n   |  |  |  |----- h265\n   |  |  |  |\n   |  |  |  |----- m2v           mpeg2 parser\n   |  |  |  |\n   |  |  |  |----- mpg4          mpeg4 parser\n   |  |  |  |\n   |  |  |  |----- vp8\n   |  |  |  |\n   |  |  |  |----- vp9\n   |  |  |  |\n   |  |  |  |----- jpeg\n   |  |  |\n   |  |  |----- enc\n   |  |     |\n   |  |     |----- dummy         encoder controllor work flow sample\n   |  |     |\n   |  |     |----- h264\n   |  |     |\n   |  |     |----- h265\n   |  |     |\n   |  |     |----- jpeg\n   |  |\n   |  |----- hal                 Hardware Abstract Layer (HAL): modules used in mpi\n   |  |  |\n   |  |  |----- inc              header files provided by hal for external usage\n   |  |  |\n   |  |  |----- iep              iep user library\n   |  |  |\n   |  |  |----- pp               post-processor user library\n   |  |  |\n   |  |  |----- rga              rga user library\n   |  |  |\n   |  |  |----- deinter          deinterlace function module including pp/iep/rga\n   |  |  |\n   |  |  |----- rkdec            rockchip hardware decoder register generation\n   |  |  |  |\n   |  |  |  |----- h264d         generate register file from H.264 syntax info\n   |  |  |  |\n   |  |  |  |----- h265d         generate register file from H.265 syntax info\n   |  |  |  |\n   |  |  |  |----- vp9d          generate register file from vp9 syntax info\n   |  |  |\n   |  |  |----- vpu              vpu register generation library\n   |  |     |\n   |  |     |----- h263d         generate register file from H.263 syntax info\n   |  |     |\n   |  |     |----- h264d         generate register file from H.264 syntax info\n   |  |     |\n   |  |     |----- h265d         generate register file from H.265 syntax info\n   |  |     |\n   |  |     |----- jpegd         generate register file from jpeg syntax info\n   |  |     |\n   |  |     |----- jpege         generate register file from jpeg syntax info\n   |  |     |\n   |  |     |----- m2vd          generate register file from mpeg2 syntax info\n   |  |     |\n   |  |     |----- mpg4d         generate register file from mpeg4 syntax info\n   |  |     |\n   |  |     |----- vp8d          generate register file from vp8 syntax info\n   |  |\n   |  |----- legacy              generate new libvpu to include old vpuapi path\n   |  |                          and new mpp path\n   |  |\n   |  |----- test                mpp internal video protocol unit test and demo\n   |\n   |----- test                   mpp buffer/packet component unit test and\n   |                             mpp/mpi/vpu_api demo\n   |\n   |----- out                    final release binary output directory\n   |  |\n   |  |----- bin                 executable binary file output directory\n   |  |\n   |  |----- inc                 header file output directory\n   |  |\n   |  |----- lib                 library file output directory\n   |\n   |----- osal                   Operation System Abstract Layer: abstract layer\n   |  |                          for different operation system\n   |  |\n   |  |----- allocator           supported allocator including Android ion and\n   |  |                          Linux drm\n   |  |\n   |  |----- android             google's android\n   |  |\n   |  |----- inc                 osal header file for mpp modules\n   |  |\n   |  |----- linux               mainline linux kernel\n   |  |\n   |  |----- windows             microsoft's windows\n   |  |\n   |  |----- test                OASL unit test\n   |\n   |----- tools                  coding style format tools\n   |\n   |----- utils                  small util functions\n\n\nHere is the mpp implement overall framework:\n\n                +---------------------------------------+\n                |                                       |\n                | ffmpeg / OpenMax / gstreamer / libva  |\n                |                                       |\n                +---------------------------------------+\n\n            +-------------------- MPP ----------------------+\n            |                                               |\n            |   +-------------------------+    +--------+   |\n            |   |                         |    |        |   |\n            |   |        MPI / MPP        |    |        |   |\n            |   |   buffer queue manage   |    |        |   |\n            |   |                         |    |        |   |\n            |   +-------------------------+    |        |   |\n            |                                  |        |   |\n            |   +-------------------------+    |        |   |\n            |   |                         |    |        |   |\n            |   |          codec          |    |  OSAL  |   |\n            |   |    decoder / encoder    |    |        |   |\n            |   |                         |    |        |   |\n            |   +-------------------------+    |        |   |\n            |                                  |        |   |\n            |   +-----------+ +-----------+    |        |   |\n            |   |           | |           |    |        |   |\n            |   |  parser   | |    HAL    |    |        |   |\n            |   |  recoder  | |  reg_gen  |    |        |   |\n            |   |           | |           |    |        |   |\n            |   +-----------+ +-----------+    +--------|   |\n            |                                               |\n            +-------------------- MPP ----------------------+\n\n                +---------------------------------------+\n                |                                       |\n                |                kernel                 |\n                |       RK vcodec_service / v4l2        |\n                |                                       |\n                +---------------------------------------+\n\n\n\nHere is the Media Process Interface hierarchical structure\nMpiPacket and MpiFrame is the stream I/O data structure.\nAnd MpiBuffer encapsulates different buffer implement like Linux's dma-buf and\nAndroid's ion.\nThis part is learned from ffmpeg.\n\n                +-------------------+\n                |                   |\n                |        MPI        |\n                |                   |\n                +---------+---------+\n                          |\n                          |\n                          v\n                +---------+---------+\n                |                   |\n            +---+        ctx        +---+\n            |   |                   |   |\n            |   +-------------------+   |\n            |                           |\n            v                           v\n    +-------+-------+           +-------+-------+\n    |               |           |               |\n    |     packet    |           |     frame     |\n    |               |           |               |\n    +---------------+           +-------+-------+\n            |                           |\n            |                           |\n            |                           |\n            |     +---------------+     |\n            |     |               |     |\n            +----\u003e+     buffer    +\u003c----+\n                  |               |\n                  +---------------+\n\n\n\nTake H.264 deocder for example. Video stream will first queued by MPI/MPP layer,\nMPP will send the stream to codec layer, codec layer parses the stream header\nand generates a protocol standard output. This output will be send to HAL to\ngenerate register file set and communicate with hardware. Hardware will complete\nthe task and resend information back. MPP notify codec by hardware result, codec\noutput decoded frame by display order.\n\nMPI                MPP              decoder             parser              HAL\n\n +                  +                  +                  +                  +\n |                  |                  |                  |                  |\n |   open context   |                  |                  |                  |\n +----------------\u003e |                  |                  |                  |\n |                  |                  |                  |                  |\n |       init       |                  |                  |                  |\n +----------------\u003e |                  |                  |                  |\n |                  |                  |                  |                  |\n |                  |       init       |                  |                  |\n |                  +----------------\u003e |                  |                  |\n |                  |                  |                  |                  |\n |                  |                  |       init       |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |                  |                  |                  |       open       |\n |                  |                  +-----------------------------------\u003e |\n |                  |                  |                  |                  |\n |      decode      |                  |                  |                  |\n +----------------\u003e |                  |                  |                  |\n |                  |                  |                  |                  |\n |                  |   send_stream    |                  |                  |\n |                  +----------------\u003e |                  |                  |\n |                  |                  |                  |                  |\n |                  |                  |   parse_stream   |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |                  |                  |                  |  reg generation  |\n |                  |                  +-----------------------------------\u003e |\n |                  |                  |                  |                  |\n |                  |                  |                  |    send_regs     |\n |                  |                  +-----------------------------------\u003e |\n |                  |                  |                  |                  |\n |                  |                  |                  |    wait_regs     |\n |                  |                  +-----------------------------------\u003e |\n |                  |                  |                  |                  |\n |                  |                  |  notify_hw_end   |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |                  |   get_picture    |                  |                  |\n |                  +----------------\u003e |                  |                  |\n |                  |                  |                  |                  |\n |                  |                  |   get_picture    |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |      flush       |                  |                  |                  |\n +----------------\u003e |                  |                  |                  |\n |                  |                  |                  |                  |\n |                  |      flush       |                  |                  |\n |                  +----------------\u003e |                  |                  |\n |                  |                  |                  |                  |\n |                  |                  |      reset       |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |      close       |                  |                  |                  |\n +----------------\u003e |                  |                  |                  |\n |                  |                  |                  |                  |\n |                  |      close       |                  |                  |\n |                  +----------------\u003e |                  |                  |\n |                  |                  |                  |                  |\n |                  |                  |      close       |                  |\n |                  |                  +----------------\u003e |                  |\n |                  |                  |                  |                  |\n |                  |                  |                  |      close       |\n |                  |                  +-----------------------------------\u003e |\n +                  +                  +                  +                  +\n\nThere are three memory usage modes that decoder can support:\n\nMode 1: Pure internal mode\nIn the mode user will NOT call MPP_DEC_SET_EXT_BUF_GROUP control to decoder.\nOnly call MPP_DEC_SET_INFO_CHANGE_READY to let decoder go on. Then decoder will\nuse create buffer internally and user need to release each frame they get.\n\nAdvantage:\nEasy to use and get a demo quickly\nDisadvantage:\n1. The buffer from decoder may not be return before decoder is close.\n   So memory leak or crash may happen.\n2. The decoder memory usage can not be control. Decoder is on a free-to-run\n   status and consume all memory it can get.\n3. Difficult to implement zero-copy display path.\n\nMode 2: Half internal mode\nThis is the mode current mpi_dec_test code using. User need to create\nMppBufferGroup according to the returned info change MppFrame.\nUser can use mpp_buffer_group_limit_config to limit decoder memory usage.\n\nAdvantage:\n1. Easy to use\n2. User can release MppBufferGroup after decoder is closed.\n   So memory can stay longer safely.\n3. Can limit the memory usage by mpp_buffer_group_limit_config\nDisadvantage:\n1. The buffer limitation is still not accurate. Memory usage is 100% fixed.\n2. Also difficult to implement zero-copy display path.\n\nMode 3: Pure external mode\nIn this mode use need to create empty MppBufferGroup and import memory from\nexternal allocator by file handle.\nOn Android surfaceflinger will create buffer. Then mediaserver get file handle\nfrom surfaceflinger and commit to decoder's MppBufferGroup.\n\nAdvantage:\n1. Most efficient way for zero-copy display\nDisadvantage:\n1. Difficult to learn and use.\n2. Player work flow may limit this usage.\n3. May need external parser to get the correct buffer size for the external\n   allocator.\n\nThe required buffer size caculation:\nhor_stride * ver_stride * 3 / 2 for pixel data\nhor_stride * ver_stride / 2 for extra info\nTotal hor_stride * ver_stride * 2 will be enough.\n\nFor H.264/H.265 20+ buffers will be enough.\nFor other codec 10 buffers will be enough.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockchip-linux%2Fmpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frockchip-linux%2Fmpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockchip-linux%2Fmpp/lists"}