You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

587 lines
19KB

  1. /*
  2. * RockChip MPP Video Decoder
  3. * Copyright (c) 2017 Lionel CHAZALLON
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <drm_fourcc.h>
  22. #include <pthread.h>
  23. #include <rockchip/mpp_buffer.h>
  24. #include <rockchip/rk_mpi.h>
  25. #include <time.h>
  26. #include <unistd.h>
  27. #include "avcodec.h"
  28. #include "decode.h"
  29. #include "hwconfig.h"
  30. #include "internal.h"
  31. #include "libavutil/buffer.h"
  32. #include "libavutil/common.h"
  33. #include "libavutil/frame.h"
  34. #include "libavutil/hwcontext.h"
  35. #include "libavutil/hwcontext_drm.h"
  36. #include "libavutil/imgutils.h"
  37. #include "libavutil/log.h"
  38. #define RECEIVE_FRAME_TIMEOUT 100
  39. #define FRAMEGROUP_MAX_FRAMES 16
  40. #define INPUT_MAX_PACKETS 4
  41. typedef struct {
  42. MppCtx ctx;
  43. MppApi *mpi;
  44. MppBufferGroup frame_group;
  45. char first_packet;
  46. char eos_reached;
  47. AVBufferRef *frames_ref;
  48. AVBufferRef *device_ref;
  49. } RKMPPDecoder;
  50. typedef struct {
  51. AVClass *av_class;
  52. AVBufferRef *decoder_ref;
  53. } RKMPPDecodeContext;
  54. typedef struct {
  55. MppFrame frame;
  56. AVBufferRef *decoder_ref;
  57. } RKMPPFrameContext;
  58. static MppCodingType rkmpp_get_codingtype(AVCodecContext *avctx)
  59. {
  60. switch (avctx->codec_id) {
  61. case AV_CODEC_ID_H264: return MPP_VIDEO_CodingAVC;
  62. case AV_CODEC_ID_HEVC: return MPP_VIDEO_CodingHEVC;
  63. case AV_CODEC_ID_VP8: return MPP_VIDEO_CodingVP8;
  64. case AV_CODEC_ID_VP9: return MPP_VIDEO_CodingVP9;
  65. default: return MPP_VIDEO_CodingUnused;
  66. }
  67. }
  68. static uint32_t rkmpp_get_frameformat(MppFrameFormat mppformat)
  69. {
  70. switch (mppformat) {
  71. case MPP_FMT_YUV420SP: return DRM_FORMAT_NV12;
  72. #ifdef DRM_FORMAT_NV12_10
  73. case MPP_FMT_YUV420SP_10BIT: return DRM_FORMAT_NV12_10;
  74. #endif
  75. default: return 0;
  76. }
  77. }
  78. static int rkmpp_write_data(AVCodecContext *avctx, uint8_t *buffer, int size, int64_t pts)
  79. {
  80. RKMPPDecodeContext *rk_context = avctx->priv_data;
  81. RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
  82. int ret;
  83. MppPacket packet;
  84. // create the MPP packet
  85. ret = mpp_packet_init(&packet, buffer, size);
  86. if (ret != MPP_OK) {
  87. av_log(avctx, AV_LOG_ERROR, "Failed to init MPP packet (code = %d)\n", ret);
  88. return AVERROR_UNKNOWN;
  89. }
  90. mpp_packet_set_pts(packet, pts);
  91. if (!buffer)
  92. mpp_packet_set_eos(packet);
  93. ret = decoder->mpi->decode_put_packet(decoder->ctx, packet);
  94. if (ret != MPP_OK) {
  95. if (ret == MPP_ERR_BUFFER_FULL) {
  96. av_log(avctx, AV_LOG_DEBUG, "Buffer full writing %d bytes to decoder\n", size);
  97. ret = AVERROR(EAGAIN);
  98. } else
  99. ret = AVERROR_UNKNOWN;
  100. }
  101. else
  102. av_log(avctx, AV_LOG_DEBUG, "Wrote %d bytes to decoder\n", size);
  103. mpp_packet_deinit(&packet);
  104. return ret;
  105. }
  106. static int rkmpp_close_decoder(AVCodecContext *avctx)
  107. {
  108. RKMPPDecodeContext *rk_context = avctx->priv_data;
  109. av_buffer_unref(&rk_context->decoder_ref);
  110. return 0;
  111. }
  112. static void rkmpp_release_decoder(void *opaque, uint8_t *data)
  113. {
  114. RKMPPDecoder *decoder = (RKMPPDecoder *)data;
  115. if (decoder->mpi) {
  116. decoder->mpi->reset(decoder->ctx);
  117. mpp_destroy(decoder->ctx);
  118. decoder->ctx = NULL;
  119. }
  120. if (decoder->frame_group) {
  121. mpp_buffer_group_put(decoder->frame_group);
  122. decoder->frame_group = NULL;
  123. }
  124. av_buffer_unref(&decoder->frames_ref);
  125. av_buffer_unref(&decoder->device_ref);
  126. av_free(decoder);
  127. }
  128. static int rkmpp_init_decoder(AVCodecContext *avctx)
  129. {
  130. RKMPPDecodeContext *rk_context = avctx->priv_data;
  131. RKMPPDecoder *decoder = NULL;
  132. MppCodingType codectype = MPP_VIDEO_CodingUnused;
  133. int ret;
  134. RK_S64 paramS64;
  135. RK_S32 paramS32;
  136. avctx->pix_fmt = AV_PIX_FMT_DRM_PRIME;
  137. // create a decoder and a ref to it
  138. decoder = av_mallocz(sizeof(RKMPPDecoder));
  139. if (!decoder) {
  140. ret = AVERROR(ENOMEM);
  141. goto fail;
  142. }
  143. rk_context->decoder_ref = av_buffer_create((uint8_t *)decoder, sizeof(*decoder), rkmpp_release_decoder,
  144. NULL, AV_BUFFER_FLAG_READONLY);
  145. if (!rk_context->decoder_ref) {
  146. av_free(decoder);
  147. ret = AVERROR(ENOMEM);
  148. goto fail;
  149. }
  150. av_log(avctx, AV_LOG_DEBUG, "Initializing RKMPP decoder.\n");
  151. codectype = rkmpp_get_codingtype(avctx);
  152. if (codectype == MPP_VIDEO_CodingUnused) {
  153. av_log(avctx, AV_LOG_ERROR, "Unknown codec type (%d).\n", avctx->codec_id);
  154. ret = AVERROR_UNKNOWN;
  155. goto fail;
  156. }
  157. ret = mpp_check_support_format(MPP_CTX_DEC, codectype);
  158. if (ret != MPP_OK) {
  159. av_log(avctx, AV_LOG_ERROR, "Codec type (%d) unsupported by MPP\n", avctx->codec_id);
  160. ret = AVERROR_UNKNOWN;
  161. goto fail;
  162. }
  163. // Create the MPP context
  164. ret = mpp_create(&decoder->ctx, &decoder->mpi);
  165. if (ret != MPP_OK) {
  166. av_log(avctx, AV_LOG_ERROR, "Failed to create MPP context (code = %d).\n", ret);
  167. ret = AVERROR_UNKNOWN;
  168. goto fail;
  169. }
  170. // initialize mpp
  171. ret = mpp_init(decoder->ctx, MPP_CTX_DEC, codectype);
  172. if (ret != MPP_OK) {
  173. av_log(avctx, AV_LOG_ERROR, "Failed to initialize MPP context (code = %d).\n", ret);
  174. ret = AVERROR_UNKNOWN;
  175. goto fail;
  176. }
  177. // make decode calls blocking with a timeout
  178. paramS32 = MPP_POLL_BLOCK;
  179. ret = decoder->mpi->control(decoder->ctx, MPP_SET_OUTPUT_BLOCK, &paramS32);
  180. if (ret != MPP_OK) {
  181. av_log(avctx, AV_LOG_ERROR, "Failed to set blocking mode on MPI (code = %d).\n", ret);
  182. ret = AVERROR_UNKNOWN;
  183. goto fail;
  184. }
  185. paramS64 = RECEIVE_FRAME_TIMEOUT;
  186. ret = decoder->mpi->control(decoder->ctx, MPP_SET_OUTPUT_BLOCK_TIMEOUT, &paramS64);
  187. if (ret != MPP_OK) {
  188. av_log(avctx, AV_LOG_ERROR, "Failed to set block timeout on MPI (code = %d).\n", ret);
  189. ret = AVERROR_UNKNOWN;
  190. goto fail;
  191. }
  192. ret = mpp_buffer_group_get_internal(&decoder->frame_group, MPP_BUFFER_TYPE_ION);
  193. if (ret) {
  194. av_log(avctx, AV_LOG_ERROR, "Failed to retrieve buffer group (code = %d)\n", ret);
  195. ret = AVERROR_UNKNOWN;
  196. goto fail;
  197. }
  198. ret = decoder->mpi->control(decoder->ctx, MPP_DEC_SET_EXT_BUF_GROUP, decoder->frame_group);
  199. if (ret) {
  200. av_log(avctx, AV_LOG_ERROR, "Failed to assign buffer group (code = %d)\n", ret);
  201. ret = AVERROR_UNKNOWN;
  202. goto fail;
  203. }
  204. ret = mpp_buffer_group_limit_config(decoder->frame_group, 0, FRAMEGROUP_MAX_FRAMES);
  205. if (ret) {
  206. av_log(avctx, AV_LOG_ERROR, "Failed to set buffer group limit (code = %d)\n", ret);
  207. ret = AVERROR_UNKNOWN;
  208. goto fail;
  209. }
  210. decoder->first_packet = 1;
  211. av_log(avctx, AV_LOG_DEBUG, "RKMPP decoder initialized successfully.\n");
  212. decoder->device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_DRM);
  213. if (!decoder->device_ref) {
  214. ret = AVERROR(ENOMEM);
  215. goto fail;
  216. }
  217. ret = av_hwdevice_ctx_init(decoder->device_ref);
  218. if (ret < 0)
  219. goto fail;
  220. return 0;
  221. fail:
  222. av_log(avctx, AV_LOG_ERROR, "Failed to initialize RKMPP decoder.\n");
  223. rkmpp_close_decoder(avctx);
  224. return ret;
  225. }
  226. static int rkmpp_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
  227. {
  228. RKMPPDecodeContext *rk_context = avctx->priv_data;
  229. RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
  230. int ret;
  231. // handle EOF
  232. if (!avpkt->size) {
  233. av_log(avctx, AV_LOG_DEBUG, "End of stream.\n");
  234. decoder->eos_reached = 1;
  235. ret = rkmpp_write_data(avctx, NULL, 0, 0);
  236. if (ret)
  237. av_log(avctx, AV_LOG_ERROR, "Failed to send EOS to decoder (code = %d)\n", ret);
  238. return ret;
  239. }
  240. // on first packet, send extradata
  241. if (decoder->first_packet) {
  242. if (avctx->extradata_size) {
  243. ret = rkmpp_write_data(avctx, avctx->extradata,
  244. avctx->extradata_size,
  245. avpkt->pts);
  246. if (ret) {
  247. av_log(avctx, AV_LOG_ERROR, "Failed to write extradata to decoder (code = %d)\n", ret);
  248. return ret;
  249. }
  250. }
  251. decoder->first_packet = 0;
  252. }
  253. // now send packet
  254. ret = rkmpp_write_data(avctx, avpkt->data, avpkt->size, avpkt->pts);
  255. if (ret && ret!=AVERROR(EAGAIN))
  256. av_log(avctx, AV_LOG_ERROR, "Failed to write data to decoder (code = %d)\n", ret);
  257. return ret;
  258. }
  259. static void rkmpp_release_frame(void *opaque, uint8_t *data)
  260. {
  261. AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)data;
  262. AVBufferRef *framecontextref = (AVBufferRef *)opaque;
  263. RKMPPFrameContext *framecontext = (RKMPPFrameContext *)framecontextref->data;
  264. mpp_frame_deinit(&framecontext->frame);
  265. av_buffer_unref(&framecontext->decoder_ref);
  266. av_buffer_unref(&framecontextref);
  267. av_free(desc);
  268. }
  269. static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
  270. {
  271. RKMPPDecodeContext *rk_context = avctx->priv_data;
  272. RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
  273. RKMPPFrameContext *framecontext = NULL;
  274. AVBufferRef *framecontextref = NULL;
  275. int ret;
  276. MppFrame mppframe = NULL;
  277. MppBuffer buffer = NULL;
  278. AVDRMFrameDescriptor *desc = NULL;
  279. AVDRMLayerDescriptor *layer = NULL;
  280. int mode;
  281. MppFrameFormat mppformat;
  282. uint32_t drmformat;
  283. ret = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
  284. if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT) {
  285. av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
  286. goto fail;
  287. }
  288. if (mppframe) {
  289. // Check whether we have a special frame or not
  290. if (mpp_frame_get_info_change(mppframe)) {
  291. AVHWFramesContext *hwframes;
  292. av_log(avctx, AV_LOG_INFO, "Decoder noticed an info change (%dx%d), format=%d\n",
  293. (int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),
  294. (int)mpp_frame_get_fmt(mppframe));
  295. avctx->width = mpp_frame_get_width(mppframe);
  296. avctx->height = mpp_frame_get_height(mppframe);
  297. decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
  298. av_buffer_unref(&decoder->frames_ref);
  299. decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);
  300. if (!decoder->frames_ref) {
  301. ret = AVERROR(ENOMEM);
  302. goto fail;
  303. }
  304. mppformat = mpp_frame_get_fmt(mppframe);
  305. drmformat = rkmpp_get_frameformat(mppformat);
  306. hwframes = (AVHWFramesContext*)decoder->frames_ref->data;
  307. hwframes->format = AV_PIX_FMT_DRM_PRIME;
  308. hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;
  309. hwframes->width = avctx->width;
  310. hwframes->height = avctx->height;
  311. ret = av_hwframe_ctx_init(decoder->frames_ref);
  312. if (ret < 0)
  313. goto fail;
  314. // here decoder is fully initialized, we need to feed it again with data
  315. ret = AVERROR(EAGAIN);
  316. goto fail;
  317. } else if (mpp_frame_get_eos(mppframe)) {
  318. av_log(avctx, AV_LOG_DEBUG, "Received a EOS frame.\n");
  319. decoder->eos_reached = 1;
  320. ret = AVERROR_EOF;
  321. goto fail;
  322. } else if (mpp_frame_get_discard(mppframe)) {
  323. av_log(avctx, AV_LOG_DEBUG, "Received a discard frame.\n");
  324. ret = AVERROR(EAGAIN);
  325. goto fail;
  326. } else if (mpp_frame_get_errinfo(mppframe)) {
  327. av_log(avctx, AV_LOG_ERROR, "Received a errinfo frame.\n");
  328. ret = AVERROR_UNKNOWN;
  329. goto fail;
  330. }
  331. // here we should have a valid frame
  332. av_log(avctx, AV_LOG_DEBUG, "Received a frame.\n");
  333. // setup general frame fields
  334. frame->format = AV_PIX_FMT_DRM_PRIME;
  335. frame->width = mpp_frame_get_width(mppframe);
  336. frame->height = mpp_frame_get_height(mppframe);
  337. frame->pts = mpp_frame_get_pts(mppframe);
  338. frame->color_range = mpp_frame_get_color_range(mppframe);
  339. frame->color_primaries = mpp_frame_get_color_primaries(mppframe);
  340. frame->color_trc = mpp_frame_get_color_trc(mppframe);
  341. frame->colorspace = mpp_frame_get_colorspace(mppframe);
  342. mode = mpp_frame_get_mode(mppframe);
  343. frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
  344. frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
  345. mppformat = mpp_frame_get_fmt(mppframe);
  346. drmformat = rkmpp_get_frameformat(mppformat);
  347. // now setup the frame buffer info
  348. buffer = mpp_frame_get_buffer(mppframe);
  349. if (buffer) {
  350. desc = av_mallocz(sizeof(AVDRMFrameDescriptor));
  351. if (!desc) {
  352. ret = AVERROR(ENOMEM);
  353. goto fail;
  354. }
  355. desc->nb_objects = 1;
  356. desc->objects[0].fd = mpp_buffer_get_fd(buffer);
  357. desc->objects[0].size = mpp_buffer_get_size(buffer);
  358. desc->nb_layers = 1;
  359. layer = &desc->layers[0];
  360. layer->format = drmformat;
  361. layer->nb_planes = 2;
  362. layer->planes[0].object_index = 0;
  363. layer->planes[0].offset = 0;
  364. layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);
  365. layer->planes[1].object_index = 0;
  366. layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);
  367. layer->planes[1].pitch = layer->planes[0].pitch;
  368. // we also allocate a struct in buf[0] that will allow to hold additionnal information
  369. // for releasing properly MPP frames and decoder
  370. framecontextref = av_buffer_allocz(sizeof(*framecontext));
  371. if (!framecontextref) {
  372. ret = AVERROR(ENOMEM);
  373. goto fail;
  374. }
  375. // MPP decoder needs to be closed only when all frames have been released.
  376. framecontext = (RKMPPFrameContext *)framecontextref->data;
  377. framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);
  378. framecontext->frame = mppframe;
  379. frame->data[0] = (uint8_t *)desc;
  380. frame->buf[0] = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,
  381. framecontextref, AV_BUFFER_FLAG_READONLY);
  382. if (!frame->buf[0]) {
  383. ret = AVERROR(ENOMEM);
  384. goto fail;
  385. }
  386. frame->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
  387. if (!frame->hw_frames_ctx) {
  388. ret = AVERROR(ENOMEM);
  389. goto fail;
  390. }
  391. return 0;
  392. } else {
  393. av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
  394. mpp_frame_deinit(&mppframe);
  395. }
  396. } else if (decoder->eos_reached) {
  397. return AVERROR_EOF;
  398. } else if (ret == MPP_ERR_TIMEOUT) {
  399. av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
  400. }
  401. return AVERROR(EAGAIN);
  402. fail:
  403. if (mppframe)
  404. mpp_frame_deinit(&mppframe);
  405. if (framecontext)
  406. av_buffer_unref(&framecontext->decoder_ref);
  407. if (framecontextref)
  408. av_buffer_unref(&framecontextref);
  409. if (desc)
  410. av_free(desc);
  411. return ret;
  412. }
  413. static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
  414. {
  415. RKMPPDecodeContext *rk_context = avctx->priv_data;
  416. RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
  417. int ret = MPP_NOK;
  418. AVPacket pkt = {0};
  419. RK_S32 usedslots, freeslots;
  420. if (!decoder->eos_reached) {
  421. // we get the available slots in decoder
  422. ret = decoder->mpi->control(decoder->ctx, MPP_DEC_GET_STREAM_COUNT, &usedslots);
  423. if (ret != MPP_OK) {
  424. av_log(avctx, AV_LOG_ERROR, "Failed to get decoder used slots (code = %d).\n", ret);
  425. return ret;
  426. }
  427. freeslots = INPUT_MAX_PACKETS - usedslots;
  428. if (freeslots > 0) {
  429. ret = ff_decode_get_packet(avctx, &pkt);
  430. if (ret < 0 && ret != AVERROR_EOF) {
  431. return ret;
  432. }
  433. ret = rkmpp_send_packet(avctx, &pkt);
  434. av_packet_unref(&pkt);
  435. if (ret < 0) {
  436. av_log(avctx, AV_LOG_ERROR, "Failed to send packet to decoder (code = %d)\n", ret);
  437. return ret;
  438. }
  439. }
  440. // make sure we keep decoder full
  441. if (freeslots > 1)
  442. return AVERROR(EAGAIN);
  443. }
  444. return rkmpp_retrieve_frame(avctx, frame);
  445. }
  446. static void rkmpp_flush(AVCodecContext *avctx)
  447. {
  448. RKMPPDecodeContext *rk_context = avctx->priv_data;
  449. RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
  450. int ret = MPP_NOK;
  451. av_log(avctx, AV_LOG_DEBUG, "Flush.\n");
  452. ret = decoder->mpi->reset(decoder->ctx);
  453. if (ret == MPP_OK) {
  454. decoder->first_packet = 1;
  455. } else
  456. av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret);
  457. }
  458. static const AVCodecHWConfigInternal *const rkmpp_hw_configs[] = {
  459. HW_CONFIG_INTERNAL(DRM_PRIME),
  460. NULL
  461. };
  462. #define RKMPP_DEC_CLASS(NAME) \
  463. static const AVClass rkmpp_##NAME##_dec_class = { \
  464. .class_name = "rkmpp_" #NAME "_dec", \
  465. .version = LIBAVUTIL_VERSION_INT, \
  466. };
  467. #define RKMPP_DEC(NAME, ID, BSFS) \
  468. RKMPP_DEC_CLASS(NAME) \
  469. AVCodec ff_##NAME##_rkmpp_decoder = { \
  470. .name = #NAME "_rkmpp", \
  471. .long_name = NULL_IF_CONFIG_SMALL(#NAME " (rkmpp)"), \
  472. .type = AVMEDIA_TYPE_VIDEO, \
  473. .id = ID, \
  474. .priv_data_size = sizeof(RKMPPDecodeContext), \
  475. .init = rkmpp_init_decoder, \
  476. .close = rkmpp_close_decoder, \
  477. .receive_frame = rkmpp_receive_frame, \
  478. .flush = rkmpp_flush, \
  479. .priv_class = &rkmpp_##NAME##_dec_class, \
  480. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
  481. .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
  482. AV_PIX_FMT_NONE}, \
  483. .hw_configs = rkmpp_hw_configs, \
  484. .bsfs = BSFS, \
  485. .wrapper_name = "rkmpp", \
  486. };
  487. RKMPP_DEC(h264, AV_CODEC_ID_H264, "h264_mp4toannexb")
  488. RKMPP_DEC(hevc, AV_CODEC_ID_HEVC, "hevc_mp4toannexb")
  489. RKMPP_DEC(vp8, AV_CODEC_ID_VP8, NULL)
  490. RKMPP_DEC(vp9, AV_CODEC_ID_VP9, NULL)