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.

657 lines
19KB

  1. /*
  2. * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
  3. *
  4. * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <stdint.h>
  23. #include <string.h>
  24. #include "libavutil/avassert.h"
  25. #include "libavutil/common.h"
  26. #include "libavutil/fifo.h"
  27. #include "libavutil/opt.h"
  28. #include "libavutil/intreadwrite.h"
  29. #include "libavutil/pixfmt.h"
  30. #include "avcodec.h"
  31. #include "decode.h"
  32. #include "h264_parse.h"
  33. #include "hevc_parse.h"
  34. #include "hwaccel.h"
  35. #include "internal.h"
  36. #include "mediacodec_wrapper.h"
  37. #include "mediacodecdec_common.h"
  38. typedef struct MediaCodecH264DecContext {
  39. MediaCodecDecContext *ctx;
  40. AVFifoBuffer *fifo;
  41. AVPacket buffered_pkt;
  42. } MediaCodecH264DecContext;
  43. static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
  44. {
  45. MediaCodecH264DecContext *s = avctx->priv_data;
  46. ff_mediacodec_dec_close(avctx, s->ctx);
  47. s->ctx = NULL;
  48. av_fifo_free(s->fifo);
  49. av_packet_unref(&s->buffered_pkt);
  50. return 0;
  51. }
  52. #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER
  53. static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
  54. {
  55. int i;
  56. int ret = 0;
  57. uint8_t *p = NULL;
  58. static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
  59. if (!out || !out_size) {
  60. return AVERROR(EINVAL);
  61. }
  62. p = av_malloc(sizeof(nalu_header) + src_size);
  63. if (!p) {
  64. return AVERROR(ENOMEM);
  65. }
  66. *out = p;
  67. *out_size = sizeof(nalu_header) + src_size;
  68. memcpy(p, nalu_header, sizeof(nalu_header));
  69. memcpy(p + sizeof(nalu_header), src, src_size);
  70. /* Escape 0x00, 0x00, 0x0{0-3} pattern */
  71. for (i = 4; i < *out_size; i++) {
  72. if (i < *out_size - 3 &&
  73. p[i + 0] == 0 &&
  74. p[i + 1] == 0 &&
  75. p[i + 2] <= 3) {
  76. uint8_t *new;
  77. *out_size += 1;
  78. new = av_realloc(*out, *out_size);
  79. if (!new) {
  80. ret = AVERROR(ENOMEM);
  81. goto done;
  82. }
  83. *out = p = new;
  84. i = i + 2;
  85. memmove(p + i + 1, p + i, *out_size - (i + 1));
  86. p[i] = 0x03;
  87. }
  88. }
  89. done:
  90. if (ret < 0) {
  91. av_freep(out);
  92. *out_size = 0;
  93. }
  94. return ret;
  95. }
  96. #endif
  97. #if CONFIG_H264_MEDIACODEC_DECODER
  98. static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
  99. {
  100. int i;
  101. int ret;
  102. H264ParamSets ps;
  103. const PPS *pps = NULL;
  104. const SPS *sps = NULL;
  105. int is_avc = 0;
  106. int nal_length_size = 0;
  107. memset(&ps, 0, sizeof(ps));
  108. ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
  109. &ps, &is_avc, &nal_length_size, 0, avctx);
  110. if (ret < 0) {
  111. goto done;
  112. }
  113. for (i = 0; i < MAX_PPS_COUNT; i++) {
  114. if (ps.pps_list[i]) {
  115. pps = (const PPS*)ps.pps_list[i]->data;
  116. break;
  117. }
  118. }
  119. if (pps) {
  120. if (ps.sps_list[pps->sps_id]) {
  121. sps = (const SPS*)ps.sps_list[pps->sps_id]->data;
  122. }
  123. }
  124. if (pps && sps) {
  125. uint8_t *data = NULL;
  126. int data_size = 0;
  127. if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
  128. goto done;
  129. }
  130. ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
  131. av_freep(&data);
  132. if ((ret = h2645_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
  133. goto done;
  134. }
  135. ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
  136. av_freep(&data);
  137. } else {
  138. av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
  139. ret = AVERROR_INVALIDDATA;
  140. }
  141. done:
  142. ff_h264_ps_uninit(&ps);
  143. return ret;
  144. }
  145. #endif
  146. #if CONFIG_HEVC_MEDIACODEC_DECODER
  147. static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
  148. {
  149. int i;
  150. int ret;
  151. HEVCParamSets ps;
  152. HEVCSEI sei;
  153. const HEVCVPS *vps = NULL;
  154. const HEVCPPS *pps = NULL;
  155. const HEVCSPS *sps = NULL;
  156. int is_nalff = 0;
  157. int nal_length_size = 0;
  158. uint8_t *vps_data = NULL;
  159. uint8_t *sps_data = NULL;
  160. uint8_t *pps_data = NULL;
  161. int vps_data_size = 0;
  162. int sps_data_size = 0;
  163. int pps_data_size = 0;
  164. memset(&ps, 0, sizeof(ps));
  165. memset(&sei, 0, sizeof(sei));
  166. ret = ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size,
  167. &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
  168. if (ret < 0) {
  169. goto done;
  170. }
  171. for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) {
  172. if (ps.vps_list[i]) {
  173. vps = (const HEVCVPS*)ps.vps_list[i]->data;
  174. break;
  175. }
  176. }
  177. for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
  178. if (ps.pps_list[i]) {
  179. pps = (const HEVCPPS*)ps.pps_list[i]->data;
  180. break;
  181. }
  182. }
  183. if (pps) {
  184. if (ps.sps_list[pps->sps_id]) {
  185. sps = (const HEVCSPS*)ps.sps_list[pps->sps_id]->data;
  186. }
  187. }
  188. if (vps && pps && sps) {
  189. uint8_t *data;
  190. int data_size;
  191. if ((ret = h2645_ps_to_nalu(vps->data, vps->data_size, &vps_data, &vps_data_size)) < 0 ||
  192. (ret = h2645_ps_to_nalu(sps->data, sps->data_size, &sps_data, &sps_data_size)) < 0 ||
  193. (ret = h2645_ps_to_nalu(pps->data, pps->data_size, &pps_data, &pps_data_size)) < 0) {
  194. goto done;
  195. }
  196. data_size = vps_data_size + sps_data_size + pps_data_size;
  197. data = av_mallocz(data_size);
  198. if (!data) {
  199. ret = AVERROR(ENOMEM);
  200. goto done;
  201. }
  202. memcpy(data , vps_data, vps_data_size);
  203. memcpy(data + vps_data_size , sps_data, sps_data_size);
  204. memcpy(data + vps_data_size + sps_data_size, pps_data, pps_data_size);
  205. ff_AMediaFormat_setBuffer(format, "csd-0", data, data_size);
  206. av_freep(&data);
  207. } else {
  208. av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from extradata");
  209. ret = AVERROR_INVALIDDATA;
  210. }
  211. done:
  212. av_freep(&vps_data);
  213. av_freep(&sps_data);
  214. av_freep(&pps_data);
  215. return ret;
  216. }
  217. #endif
  218. #if CONFIG_MPEG2_MEDIACODEC_DECODER
  219. static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
  220. {
  221. int ret = 0;
  222. if (avctx->extradata) {
  223. ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
  224. }
  225. return ret;
  226. }
  227. #endif
  228. #if CONFIG_MPEG4_MEDIACODEC_DECODER
  229. static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
  230. {
  231. int ret = 0;
  232. if (avctx->extradata) {
  233. ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
  234. }
  235. return ret;
  236. }
  237. #endif
  238. #if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
  239. static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
  240. {
  241. int ret = 0;
  242. if (avctx->extradata) {
  243. ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
  244. }
  245. return ret;
  246. }
  247. #endif
  248. static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
  249. {
  250. int ret;
  251. const char *codec_mime = NULL;
  252. FFAMediaFormat *format = NULL;
  253. MediaCodecH264DecContext *s = avctx->priv_data;
  254. format = ff_AMediaFormat_new();
  255. if (!format) {
  256. av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
  257. ret = AVERROR_EXTERNAL;
  258. goto done;
  259. }
  260. switch (avctx->codec_id) {
  261. #if CONFIG_H264_MEDIACODEC_DECODER
  262. case AV_CODEC_ID_H264:
  263. codec_mime = "video/avc";
  264. ret = h264_set_extradata(avctx, format);
  265. if (ret < 0)
  266. goto done;
  267. break;
  268. #endif
  269. #if CONFIG_HEVC_MEDIACODEC_DECODER
  270. case AV_CODEC_ID_HEVC:
  271. codec_mime = "video/hevc";
  272. ret = hevc_set_extradata(avctx, format);
  273. if (ret < 0)
  274. goto done;
  275. break;
  276. #endif
  277. #if CONFIG_MPEG2_MEDIACODEC_DECODER
  278. case AV_CODEC_ID_MPEG2VIDEO:
  279. codec_mime = "video/mpeg2";
  280. ret = mpeg2_set_extradata(avctx, format);
  281. if (ret < 0)
  282. goto done;
  283. break;
  284. #endif
  285. #if CONFIG_MPEG4_MEDIACODEC_DECODER
  286. case AV_CODEC_ID_MPEG4:
  287. codec_mime = "video/mp4v-es",
  288. ret = mpeg4_set_extradata(avctx, format);
  289. if (ret < 0)
  290. goto done;
  291. break;
  292. #endif
  293. #if CONFIG_VP8_MEDIACODEC_DECODER
  294. case AV_CODEC_ID_VP8:
  295. codec_mime = "video/x-vnd.on2.vp8";
  296. ret = vpx_set_extradata(avctx, format);
  297. if (ret < 0)
  298. goto done;
  299. break;
  300. #endif
  301. #if CONFIG_VP9_MEDIACODEC_DECODER
  302. case AV_CODEC_ID_VP9:
  303. codec_mime = "video/x-vnd.on2.vp9";
  304. ret = vpx_set_extradata(avctx, format);
  305. if (ret < 0)
  306. goto done;
  307. break;
  308. #endif
  309. default:
  310. av_assert0(0);
  311. }
  312. ff_AMediaFormat_setString(format, "mime", codec_mime);
  313. ff_AMediaFormat_setInt32(format, "width", avctx->width);
  314. ff_AMediaFormat_setInt32(format, "height", avctx->height);
  315. s->ctx = av_mallocz(sizeof(*s->ctx));
  316. if (!s->ctx) {
  317. av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
  318. ret = AVERROR(ENOMEM);
  319. goto done;
  320. }
  321. if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
  322. s->ctx = NULL;
  323. goto done;
  324. }
  325. av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
  326. s->fifo = av_fifo_alloc(sizeof(AVPacket));
  327. if (!s->fifo) {
  328. ret = AVERROR(ENOMEM);
  329. goto done;
  330. }
  331. done:
  332. if (format) {
  333. ff_AMediaFormat_delete(format);
  334. }
  335. if (ret < 0) {
  336. mediacodec_decode_close(avctx);
  337. }
  338. return ret;
  339. }
  340. static int mediacodec_process_data(AVCodecContext *avctx, AVFrame *frame,
  341. int *got_frame, AVPacket *pkt)
  342. {
  343. MediaCodecH264DecContext *s = avctx->priv_data;
  344. return ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, pkt);
  345. }
  346. static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
  347. {
  348. MediaCodecH264DecContext *s = avctx->priv_data;
  349. int ret;
  350. int got_frame = 0;
  351. int is_eof = 0;
  352. AVPacket pkt = { 0 };
  353. /*
  354. * MediaCodec.flush() discards both input and output buffers, thus we
  355. * need to delay the call to this function until the user has released or
  356. * renderered the frames he retains.
  357. *
  358. * After we have buffered an input packet, check if the codec is in the
  359. * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
  360. *
  361. * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
  362. * the codec (because the user retains frames). The codec stays in the
  363. * flushing state.
  364. *
  365. * ff_mediacodec_dec_flush returns 1 if the flush can actually be
  366. * performed on the codec. The codec leaves the flushing state and can
  367. * process again packets.
  368. *
  369. * ff_mediacodec_dec_flush returns a negative value if an error has
  370. * occurred.
  371. *
  372. */
  373. if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
  374. if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
  375. return AVERROR(EAGAIN);
  376. }
  377. }
  378. ret = ff_decode_get_packet(avctx, &pkt);
  379. if (ret == AVERROR_EOF)
  380. is_eof = 1;
  381. else if (ret == AVERROR(EAGAIN))
  382. ; /* no input packet, but fallthrough to check for pending frames */
  383. else if (ret < 0)
  384. return ret;
  385. /* buffer the input packet */
  386. if (pkt.size) {
  387. if (av_fifo_space(s->fifo) < sizeof(pkt)) {
  388. ret = av_fifo_realloc2(s->fifo,
  389. av_fifo_size(s->fifo) + sizeof(pkt));
  390. if (ret < 0) {
  391. av_packet_unref(&pkt);
  392. return ret;
  393. }
  394. }
  395. av_fifo_generic_write(s->fifo, &pkt, sizeof(pkt), NULL);
  396. }
  397. /* process buffered data */
  398. while (!got_frame) {
  399. /* prepare the input data */
  400. if (s->buffered_pkt.size <= 0) {
  401. av_packet_unref(&s->buffered_pkt);
  402. /* no more data */
  403. if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
  404. AVPacket null_pkt = { 0 };
  405. if (is_eof) {
  406. ret = ff_mediacodec_dec_decode(avctx, s->ctx, frame,
  407. &got_frame, &null_pkt);
  408. if (ret < 0)
  409. return ret;
  410. else if (got_frame)
  411. return 0;
  412. else
  413. return AVERROR_EOF;
  414. }
  415. return AVERROR(EAGAIN);
  416. }
  417. av_fifo_generic_read(s->fifo, &s->buffered_pkt, sizeof(s->buffered_pkt), NULL);
  418. }
  419. ret = mediacodec_process_data(avctx, frame, &got_frame, &s->buffered_pkt);
  420. if (ret < 0)
  421. return ret;
  422. s->buffered_pkt.size -= ret;
  423. s->buffered_pkt.data += ret;
  424. }
  425. return 0;
  426. }
  427. static void mediacodec_decode_flush(AVCodecContext *avctx)
  428. {
  429. MediaCodecH264DecContext *s = avctx->priv_data;
  430. while (av_fifo_size(s->fifo)) {
  431. AVPacket pkt;
  432. av_fifo_generic_read(s->fifo, &pkt, sizeof(pkt), NULL);
  433. av_packet_unref(&pkt);
  434. }
  435. av_fifo_reset(s->fifo);
  436. av_packet_unref(&s->buffered_pkt);
  437. ff_mediacodec_dec_flush(avctx, s->ctx);
  438. }
  439. static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = {
  440. &(const AVCodecHWConfigInternal) {
  441. .public = {
  442. .pix_fmt = AV_PIX_FMT_MEDIACODEC,
  443. .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |
  444. AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
  445. .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
  446. },
  447. .hwaccel = NULL,
  448. },
  449. NULL
  450. };
  451. #if CONFIG_H264_MEDIACODEC_DECODER
  452. AVCodec ff_h264_mediacodec_decoder = {
  453. .name = "h264_mediacodec",
  454. .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
  455. .type = AVMEDIA_TYPE_VIDEO,
  456. .id = AV_CODEC_ID_H264,
  457. .priv_data_size = sizeof(MediaCodecH264DecContext),
  458. .init = mediacodec_decode_init,
  459. .receive_frame = mediacodec_receive_frame,
  460. .flush = mediacodec_decode_flush,
  461. .close = mediacodec_decode_close,
  462. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  463. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  464. .bsfs = "h264_mp4toannexb",
  465. .hw_configs = mediacodec_hw_configs,
  466. .wrapper_name = "mediacodec",
  467. };
  468. #endif
  469. #if CONFIG_HEVC_MEDIACODEC_DECODER
  470. AVCodec ff_hevc_mediacodec_decoder = {
  471. .name = "hevc_mediacodec",
  472. .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
  473. .type = AVMEDIA_TYPE_VIDEO,
  474. .id = AV_CODEC_ID_HEVC,
  475. .priv_data_size = sizeof(MediaCodecH264DecContext),
  476. .init = mediacodec_decode_init,
  477. .receive_frame = mediacodec_receive_frame,
  478. .flush = mediacodec_decode_flush,
  479. .close = mediacodec_decode_close,
  480. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  481. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  482. .bsfs = "hevc_mp4toannexb",
  483. .hw_configs = mediacodec_hw_configs,
  484. .wrapper_name = "mediacodec",
  485. };
  486. #endif
  487. #if CONFIG_MPEG2_MEDIACODEC_DECODER
  488. AVCodec ff_mpeg2_mediacodec_decoder = {
  489. .name = "mpeg2_mediacodec",
  490. .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
  491. .type = AVMEDIA_TYPE_VIDEO,
  492. .id = AV_CODEC_ID_MPEG2VIDEO,
  493. .priv_data_size = sizeof(MediaCodecH264DecContext),
  494. .init = mediacodec_decode_init,
  495. .receive_frame = mediacodec_receive_frame,
  496. .flush = mediacodec_decode_flush,
  497. .close = mediacodec_decode_close,
  498. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  499. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  500. .hw_configs = mediacodec_hw_configs,
  501. .wrapper_name = "mediacodec",
  502. };
  503. #endif
  504. #if CONFIG_MPEG4_MEDIACODEC_DECODER
  505. AVCodec ff_mpeg4_mediacodec_decoder = {
  506. .name = "mpeg4_mediacodec",
  507. .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"),
  508. .type = AVMEDIA_TYPE_VIDEO,
  509. .id = AV_CODEC_ID_MPEG4,
  510. .priv_data_size = sizeof(MediaCodecH264DecContext),
  511. .init = mediacodec_decode_init,
  512. .receive_frame = mediacodec_receive_frame,
  513. .flush = mediacodec_decode_flush,
  514. .close = mediacodec_decode_close,
  515. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  516. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  517. .hw_configs = mediacodec_hw_configs,
  518. .wrapper_name = "mediacodec",
  519. };
  520. #endif
  521. #if CONFIG_VP8_MEDIACODEC_DECODER
  522. AVCodec ff_vp8_mediacodec_decoder = {
  523. .name = "vp8_mediacodec",
  524. .long_name = NULL_IF_CONFIG_SMALL("VP8 Android MediaCodec decoder"),
  525. .type = AVMEDIA_TYPE_VIDEO,
  526. .id = AV_CODEC_ID_VP8,
  527. .priv_data_size = sizeof(MediaCodecH264DecContext),
  528. .init = mediacodec_decode_init,
  529. .receive_frame = mediacodec_receive_frame,
  530. .flush = mediacodec_decode_flush,
  531. .close = mediacodec_decode_close,
  532. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  533. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  534. .hw_configs = mediacodec_hw_configs,
  535. .wrapper_name = "mediacodec",
  536. };
  537. #endif
  538. #if CONFIG_VP9_MEDIACODEC_DECODER
  539. AVCodec ff_vp9_mediacodec_decoder = {
  540. .name = "vp9_mediacodec",
  541. .long_name = NULL_IF_CONFIG_SMALL("VP9 Android MediaCodec decoder"),
  542. .type = AVMEDIA_TYPE_VIDEO,
  543. .id = AV_CODEC_ID_VP9,
  544. .priv_data_size = sizeof(MediaCodecH264DecContext),
  545. .init = mediacodec_decode_init,
  546. .receive_frame = mediacodec_receive_frame,
  547. .flush = mediacodec_decode_flush,
  548. .close = mediacodec_decode_close,
  549. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
  550. .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
  551. .hw_configs = mediacodec_hw_configs,
  552. .wrapper_name = "mediacodec",
  553. };
  554. #endif