]> git.sesse.net Git - ffmpeg/blob - libavcodec/rkmppdec.c
vaapi_h264: Add named options for setting profile and level
[ffmpeg] / libavcodec / rkmppdec.c
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
22 #include <drm_fourcc.h>
23 #include <pthread.h>
24 #include <rockchip/mpp_buffer.h>
25 #include <rockchip/rk_mpi.h>
26 #include <time.h>
27 #include <unistd.h>
28
29 #include "avcodec.h"
30 #include "decode.h"
31 #include "hwaccel.h"
32 #include "internal.h"
33 #include "libavutil/buffer.h"
34 #include "libavutil/common.h"
35 #include "libavutil/frame.h"
36 #include "libavutil/hwcontext.h"
37 #include "libavutil/hwcontext_drm.h"
38 #include "libavutil/imgutils.h"
39 #include "libavutil/log.h"
40
41 #define RECEIVE_FRAME_TIMEOUT   100
42 #define FRAMEGROUP_MAX_FRAMES   16
43
44 typedef struct {
45     MppCtx ctx;
46     MppApi *mpi;
47     MppBufferGroup frame_group;
48
49     char first_frame;
50     char first_packet;
51     char eos_reached;
52
53     AVBufferRef *frames_ref;
54     AVBufferRef *device_ref;
55 } RKMPPDecoder;
56
57 typedef struct {
58     AVClass *av_class;
59     AVBufferRef *decoder_ref;
60 } RKMPPDecodeContext;
61
62 typedef struct {
63     MppFrame frame;
64     AVBufferRef *decoder_ref;
65 } RKMPPFrameContext;
66
67 static MppCodingType rkmpp_get_codingtype(AVCodecContext *avctx)
68 {
69     switch (avctx->codec_id) {
70     case AV_CODEC_ID_H264:          return MPP_VIDEO_CodingAVC;
71     case AV_CODEC_ID_HEVC:          return MPP_VIDEO_CodingHEVC;
72     case AV_CODEC_ID_VP8:           return MPP_VIDEO_CodingVP8;
73     case AV_CODEC_ID_VP9:           return MPP_VIDEO_CodingVP9;
74     default:                        return MPP_VIDEO_CodingUnused;
75     }
76 }
77
78 static uint32_t rkmpp_get_frameformat(MppFrameFormat mppformat)
79 {
80     switch (mppformat) {
81     case MPP_FMT_YUV420SP:          return DRM_FORMAT_NV12;
82 #ifdef DRM_FORMAT_NV12_10
83     case MPP_FMT_YUV420SP_10BIT:    return DRM_FORMAT_NV12_10;
84 #endif
85     default:                        return 0;
86     }
87 }
88
89 static int rkmpp_write_data(AVCodecContext *avctx, uint8_t *buffer, int size, int64_t pts)
90 {
91     RKMPPDecodeContext *rk_context = avctx->priv_data;
92     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
93     int ret;
94     MppPacket packet;
95
96     // create the MPP packet
97     ret = mpp_packet_init(&packet, buffer, size);
98     if (ret != MPP_OK) {
99         av_log(avctx, AV_LOG_ERROR, "Failed to init MPP packet (code = %d)\n", ret);
100         return AVERROR_UNKNOWN;
101     }
102
103     mpp_packet_set_pts(packet, pts);
104
105     if (!buffer)
106         mpp_packet_set_eos(packet);
107
108     ret = decoder->mpi->decode_put_packet(decoder->ctx, packet);
109     if (ret != MPP_OK) {
110         if (ret == MPP_ERR_BUFFER_FULL) {
111             av_log(avctx, AV_LOG_DEBUG, "Buffer full writing %d bytes to decoder\n", size);
112             ret = AVERROR(EAGAIN);
113         } else
114             ret = AVERROR_UNKNOWN;
115     }
116     else
117         av_log(avctx, AV_LOG_DEBUG, "Wrote %d bytes to decoder\n", size);
118
119     mpp_packet_deinit(&packet);
120
121     return ret;
122 }
123
124 static int rkmpp_close_decoder(AVCodecContext *avctx)
125 {
126     RKMPPDecodeContext *rk_context = avctx->priv_data;
127     av_buffer_unref(&rk_context->decoder_ref);
128     return 0;
129 }
130
131 static void rkmpp_release_decoder(void *opaque, uint8_t *data)
132 {
133     RKMPPDecoder *decoder = (RKMPPDecoder *)data;
134
135     if (decoder->mpi) {
136         decoder->mpi->reset(decoder->ctx);
137         mpp_destroy(decoder->ctx);
138         decoder->ctx = NULL;
139     }
140
141     if (decoder->frame_group) {
142         mpp_buffer_group_put(decoder->frame_group);
143         decoder->frame_group = NULL;
144     }
145
146     av_buffer_unref(&decoder->frames_ref);
147     av_buffer_unref(&decoder->device_ref);
148
149     av_free(decoder);
150 }
151
152 static int rkmpp_init_decoder(AVCodecContext *avctx)
153 {
154     RKMPPDecodeContext *rk_context = avctx->priv_data;
155     RKMPPDecoder *decoder = NULL;
156     MppCodingType codectype = MPP_VIDEO_CodingUnused;
157     int ret;
158     RK_S64 paramS64;
159     RK_S32 paramS32;
160
161     avctx->pix_fmt = AV_PIX_FMT_DRM_PRIME;
162
163     // create a decoder and a ref to it
164     decoder = av_mallocz(sizeof(RKMPPDecoder));
165     if (!decoder) {
166         ret = AVERROR(ENOMEM);
167         goto fail;
168     }
169
170     rk_context->decoder_ref = av_buffer_create((uint8_t *)decoder, sizeof(*decoder), rkmpp_release_decoder,
171                                                NULL, AV_BUFFER_FLAG_READONLY);
172     if (!rk_context->decoder_ref) {
173         av_free(decoder);
174         ret = AVERROR(ENOMEM);
175         goto fail;
176     }
177
178     av_log(avctx, AV_LOG_DEBUG, "Initializing RKMPP decoder.\n");
179
180     codectype = rkmpp_get_codingtype(avctx);
181     if (codectype == MPP_VIDEO_CodingUnused) {
182         av_log(avctx, AV_LOG_ERROR, "Unknown codec type (%d).\n", avctx->codec_id);
183         ret = AVERROR_UNKNOWN;
184         goto fail;
185     }
186
187     ret = mpp_check_support_format(MPP_CTX_DEC, codectype);
188     if (ret != MPP_OK) {
189         av_log(avctx, AV_LOG_ERROR, "Codec type (%d) unsupported by MPP\n", avctx->codec_id);
190         ret = AVERROR_UNKNOWN;
191         goto fail;
192     }
193
194     // Create the MPP context
195     ret = mpp_create(&decoder->ctx, &decoder->mpi);
196     if (ret != MPP_OK) {
197         av_log(avctx, AV_LOG_ERROR, "Failed to create MPP context (code = %d).\n", ret);
198         ret = AVERROR_UNKNOWN;
199         goto fail;
200     }
201
202     // initialize mpp
203     ret = mpp_init(decoder->ctx, MPP_CTX_DEC, codectype);
204     if (ret != MPP_OK) {
205         av_log(avctx, AV_LOG_ERROR, "Failed to initialize MPP context (code = %d).\n", ret);
206         ret = AVERROR_UNKNOWN;
207         goto fail;
208     }
209
210     // make decode calls blocking with a timeout
211     paramS32 = MPP_POLL_BLOCK;
212     ret = decoder->mpi->control(decoder->ctx, MPP_SET_OUTPUT_BLOCK, &paramS32);
213     if (ret != MPP_OK) {
214         av_log(avctx, AV_LOG_ERROR, "Failed to set blocking mode on MPI (code = %d).\n", ret);
215         ret = AVERROR_UNKNOWN;
216         goto fail;
217     }
218
219     paramS64 = RECEIVE_FRAME_TIMEOUT;
220     ret = decoder->mpi->control(decoder->ctx, MPP_SET_OUTPUT_BLOCK_TIMEOUT, &paramS64);
221     if (ret != MPP_OK) {
222         av_log(avctx, AV_LOG_ERROR, "Failed to set block timeout on MPI (code = %d).\n", ret);
223         ret = AVERROR_UNKNOWN;
224         goto fail;
225     }
226
227     ret = mpp_buffer_group_get_internal(&decoder->frame_group, MPP_BUFFER_TYPE_ION);
228     if (ret) {
229        av_log(avctx, AV_LOG_ERROR, "Failed to retrieve buffer group (code = %d)\n", ret);
230        ret = AVERROR_UNKNOWN;
231        goto fail;
232     }
233
234     ret = decoder->mpi->control(decoder->ctx, MPP_DEC_SET_EXT_BUF_GROUP, decoder->frame_group);
235     if (ret) {
236         av_log(avctx, AV_LOG_ERROR, "Failed to assign buffer group (code = %d)\n", ret);
237         ret = AVERROR_UNKNOWN;
238         goto fail;
239     }
240
241     ret = mpp_buffer_group_limit_config(decoder->frame_group, 0, FRAMEGROUP_MAX_FRAMES);
242     if (ret) {
243         av_log(avctx, AV_LOG_ERROR, "Failed to set buffer group limit (code = %d)\n", ret);
244         ret = AVERROR_UNKNOWN;
245         goto fail;
246     }
247
248     decoder->first_packet = 1;
249
250     av_log(avctx, AV_LOG_DEBUG, "RKMPP decoder initialized successfully.\n");
251
252     decoder->device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_DRM);
253     if (!decoder->device_ref) {
254         ret = AVERROR(ENOMEM);
255         goto fail;
256     }
257     ret = av_hwdevice_ctx_init(decoder->device_ref);
258     if (ret < 0)
259         goto fail;
260
261     return 0;
262
263 fail:
264     av_log(avctx, AV_LOG_ERROR, "Failed to initialize RKMPP decoder.\n");
265     rkmpp_close_decoder(avctx);
266     return ret;
267 }
268
269 static int rkmpp_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
270 {
271     RKMPPDecodeContext *rk_context = avctx->priv_data;
272     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
273     int ret;
274
275     // handle EOF
276     if (!avpkt->size) {
277         av_log(avctx, AV_LOG_DEBUG, "End of stream.\n");
278         decoder->eos_reached = 1;
279         ret = rkmpp_write_data(avctx, NULL, 0, 0);
280         if (ret)
281             av_log(avctx, AV_LOG_ERROR, "Failed to send EOS to decoder (code = %d)\n", ret);
282         return ret;
283     }
284
285     // on first packet, send extradata
286     if (decoder->first_packet) {
287         if (avctx->extradata_size) {
288             ret = rkmpp_write_data(avctx, avctx->extradata,
289                                             avctx->extradata_size,
290                                             avpkt->pts);
291             if (ret) {
292                 av_log(avctx, AV_LOG_ERROR, "Failed to write extradata to decoder (code = %d)\n", ret);
293                 return ret;
294             }
295         }
296         decoder->first_packet = 0;
297     }
298
299     // now send packet
300     ret = rkmpp_write_data(avctx, avpkt->data, avpkt->size, avpkt->pts);
301     if (ret && ret!=AVERROR(EAGAIN))
302         av_log(avctx, AV_LOG_ERROR, "Failed to write data to decoder (code = %d)\n", ret);
303
304     return ret;
305 }
306
307 static void rkmpp_release_frame(void *opaque, uint8_t *data)
308 {
309     AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor *)data;
310     AVBufferRef *framecontextref = (AVBufferRef *)opaque;
311     RKMPPFrameContext *framecontext = (RKMPPFrameContext *)framecontextref->data;
312
313     mpp_frame_deinit(&framecontext->frame);
314     av_buffer_unref(&framecontext->decoder_ref);
315     av_buffer_unref(&framecontextref);
316
317     av_free(desc);
318 }
319
320 static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
321 {
322     RKMPPDecodeContext *rk_context = avctx->priv_data;
323     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
324     RKMPPFrameContext *framecontext = NULL;
325     AVBufferRef *framecontextref = NULL;
326     int ret;
327     MppFrame mppframe = NULL;
328     MppBuffer buffer = NULL;
329     AVDRMFrameDescriptor *desc = NULL;
330     AVDRMLayerDescriptor *layer = NULL;
331     int retrycount = 0;
332     int mode;
333     MppFrameFormat mppformat;
334     uint32_t drmformat;
335
336     // on start of decoding, MPP can return -1, which is supposed to be expected
337     // this is due to some internal MPP init which is not completed, that will
338     // only happen in the first few frames queries, but should not be interpreted
339     // as an error, Therefore we need to retry a couple times when we get -1
340     // in order to let it time to complete it's init, then we sleep a bit between retries.
341 retry_get_frame:
342     ret = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
343     if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT && !decoder->first_frame) {
344         if (retrycount < 5) {
345             av_log(avctx, AV_LOG_DEBUG, "Failed to get a frame, retrying (code = %d, retrycount = %d)\n", ret, retrycount);
346             usleep(10000);
347             retrycount++;
348             goto retry_get_frame;
349         } else {
350             av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
351             goto fail;
352         }
353     }
354
355     if (mppframe) {
356         // Check whether we have a special frame or not
357         if (mpp_frame_get_info_change(mppframe)) {
358             AVHWFramesContext *hwframes;
359
360             av_log(avctx, AV_LOG_INFO, "Decoder noticed an info change (%dx%d), format=%d\n",
361                                         (int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),
362                                         (int)mpp_frame_get_fmt(mppframe));
363
364             avctx->width = mpp_frame_get_width(mppframe);
365             avctx->height = mpp_frame_get_height(mppframe);
366
367             decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
368             decoder->first_frame = 1;
369
370             av_buffer_unref(&decoder->frames_ref);
371
372             decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);
373             if (!decoder->frames_ref) {
374                 ret = AVERROR(ENOMEM);
375                 goto fail;
376             }
377
378             mppformat = mpp_frame_get_fmt(mppframe);
379             drmformat = rkmpp_get_frameformat(mppformat);
380
381             hwframes = (AVHWFramesContext*)decoder->frames_ref->data;
382             hwframes->format    = AV_PIX_FMT_DRM_PRIME;
383             hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;
384             hwframes->width     = avctx->width;
385             hwframes->height    = avctx->height;
386             ret = av_hwframe_ctx_init(decoder->frames_ref);
387             if (ret < 0)
388                 goto fail;
389
390             // here decoder is fully initialized, we need to feed it again with data
391             ret = AVERROR(EAGAIN);
392             goto fail;
393         } else if (mpp_frame_get_eos(mppframe)) {
394             av_log(avctx, AV_LOG_DEBUG, "Received a EOS frame.\n");
395             decoder->eos_reached = 1;
396             ret = AVERROR_EOF;
397             goto fail;
398         } else if (mpp_frame_get_discard(mppframe)) {
399             av_log(avctx, AV_LOG_DEBUG, "Received a discard frame.\n");
400             ret = AVERROR(EAGAIN);
401             goto fail;
402         } else if (mpp_frame_get_errinfo(mppframe)) {
403             av_log(avctx, AV_LOG_ERROR, "Received a errinfo frame.\n");
404             ret = AVERROR_UNKNOWN;
405             goto fail;
406         }
407
408         // here we should have a valid frame
409         av_log(avctx, AV_LOG_DEBUG, "Received a frame.\n");
410
411         // setup general frame fields
412         frame->format           = AV_PIX_FMT_DRM_PRIME;
413         frame->width            = mpp_frame_get_width(mppframe);
414         frame->height           = mpp_frame_get_height(mppframe);
415         frame->pts              = mpp_frame_get_pts(mppframe);
416         frame->color_range      = mpp_frame_get_color_range(mppframe);
417         frame->color_primaries  = mpp_frame_get_color_primaries(mppframe);
418         frame->color_trc        = mpp_frame_get_color_trc(mppframe);
419         frame->colorspace       = mpp_frame_get_colorspace(mppframe);
420
421         mode = mpp_frame_get_mode(mppframe);
422         frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
423         frame->top_field_first  = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
424
425         mppformat = mpp_frame_get_fmt(mppframe);
426         drmformat = rkmpp_get_frameformat(mppformat);
427
428         // now setup the frame buffer info
429         buffer = mpp_frame_get_buffer(mppframe);
430         if (buffer) {
431             desc = av_mallocz(sizeof(AVDRMFrameDescriptor));
432             if (!desc) {
433                 ret = AVERROR(ENOMEM);
434                 goto fail;
435             }
436
437             desc->nb_objects = 1;
438             desc->objects[0].fd = mpp_buffer_get_fd(buffer);
439             desc->objects[0].size = mpp_buffer_get_size(buffer);
440
441             desc->nb_layers = 1;
442             layer = &desc->layers[0];
443             layer->format = drmformat;
444             layer->nb_planes = 2;
445
446             layer->planes[0].object_index = 0;
447             layer->planes[0].offset = 0;
448             layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);
449
450             layer->planes[1].object_index = 0;
451             layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);
452             layer->planes[1].pitch = layer->planes[0].pitch;
453
454             // we also allocate a struct in buf[0] that will allow to hold additionnal information
455             // for releasing properly MPP frames and decoder
456             framecontextref = av_buffer_allocz(sizeof(*framecontext));
457             if (!framecontextref) {
458                 ret = AVERROR(ENOMEM);
459                 goto fail;
460             }
461
462             // MPP decoder needs to be closed only when all frames have been released.
463             framecontext = (RKMPPFrameContext *)framecontextref->data;
464             framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);
465             framecontext->frame = mppframe;
466
467             frame->data[0]  = (uint8_t *)desc;
468             frame->buf[0]   = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,
469                                                framecontextref, AV_BUFFER_FLAG_READONLY);
470
471             if (!frame->buf[0]) {
472                 ret = AVERROR(ENOMEM);
473                 goto fail;
474             }
475
476             frame->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
477             if (!frame->hw_frames_ctx) {
478                 ret = AVERROR(ENOMEM);
479                 goto fail;
480             }
481
482             decoder->first_frame = 0;
483             return 0;
484         } else {
485             av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
486             mpp_frame_deinit(&mppframe);
487         }
488     } else if (decoder->eos_reached) {
489         return AVERROR_EOF;
490     } else if (ret == MPP_ERR_TIMEOUT) {
491         av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
492     }
493
494     return AVERROR(EAGAIN);
495
496 fail:
497     if (mppframe)
498         mpp_frame_deinit(&mppframe);
499
500     if (framecontext)
501         av_buffer_unref(&framecontext->decoder_ref);
502
503     if (framecontextref)
504         av_buffer_unref(&framecontextref);
505
506     if (desc)
507         av_free(desc);
508
509     return ret;
510 }
511
512 static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
513 {
514     RKMPPDecodeContext *rk_context = avctx->priv_data;
515     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
516     int ret = MPP_NOK;
517     AVPacket pkt = {0};
518     RK_S32 freeslots;
519
520     if (!decoder->eos_reached) {
521         // we get the available slots in decoder
522         ret = decoder->mpi->control(decoder->ctx, MPP_DEC_GET_FREE_PACKET_SLOT_COUNT, &freeslots);
523         if (ret != MPP_OK) {
524             av_log(avctx, AV_LOG_ERROR, "Failed to get decoder free slots (code = %d).\n", ret);
525             return ret;
526         }
527
528         if (freeslots > 0) {
529             ret = ff_decode_get_packet(avctx, &pkt);
530             if (ret < 0 && ret != AVERROR_EOF) {
531                 return ret;
532             }
533
534             ret = rkmpp_send_packet(avctx, &pkt);
535             av_packet_unref(&pkt);
536
537             if (ret < 0) {
538                 av_log(avctx, AV_LOG_ERROR, "Failed to send packet to decoder (code = %d)\n", ret);
539                 return ret;
540             }
541         }
542
543         // make sure we keep decoder full
544         if (freeslots > 1 && decoder->first_frame)
545             return AVERROR(EAGAIN);
546     }
547
548     return rkmpp_retrieve_frame(avctx, frame);
549 }
550
551 static void rkmpp_flush(AVCodecContext *avctx)
552 {
553     RKMPPDecodeContext *rk_context = avctx->priv_data;
554     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
555     int ret = MPP_NOK;
556
557     av_log(avctx, AV_LOG_DEBUG, "Flush.\n");
558
559     ret = decoder->mpi->reset(decoder->ctx);
560     if (ret == MPP_OK) {
561         decoder->first_frame = 1;
562         decoder->first_packet = 1;
563     } else
564         av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret);
565 }
566
567 static const AVCodecHWConfigInternal *rkmpp_hw_configs[] = {
568     HW_CONFIG_INTERNAL(DRM_PRIME),
569     NULL
570 };
571
572 #define RKMPP_DEC_CLASS(NAME) \
573     static const AVClass rkmpp_##NAME##_dec_class = { \
574         .class_name = "rkmpp_" #NAME "_dec", \
575         .version    = LIBAVUTIL_VERSION_INT, \
576     };
577
578 #define RKMPP_DEC(NAME, ID, BSFS) \
579     RKMPP_DEC_CLASS(NAME) \
580     AVCodec ff_##NAME##_rkmpp_decoder = { \
581         .name           = #NAME "_rkmpp", \
582         .long_name      = NULL_IF_CONFIG_SMALL(#NAME " (rkmpp)"), \
583         .type           = AVMEDIA_TYPE_VIDEO, \
584         .id             = ID, \
585         .priv_data_size = sizeof(RKMPPDecodeContext), \
586         .init           = rkmpp_init_decoder, \
587         .close          = rkmpp_close_decoder, \
588         .receive_frame  = rkmpp_receive_frame, \
589         .flush          = rkmpp_flush, \
590         .priv_class     = &rkmpp_##NAME##_dec_class, \
591         .capabilities   = AV_CODEC_CAP_DELAY, \
592         .caps_internal  = AV_CODEC_CAP_AVOID_PROBING, \
593         .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
594                                                          AV_PIX_FMT_NONE}, \
595         .hw_configs     = rkmpp_hw_configs, \
596         .bsfs           = BSFS, \
597     };
598
599 RKMPP_DEC(h264,  AV_CODEC_ID_H264,          "h264_mp4toannexb")
600 RKMPP_DEC(hevc,  AV_CODEC_ID_HEVC,          "hevc_mp4toannexb")
601 RKMPP_DEC(vp8,   AV_CODEC_ID_VP8,           NULL)
602 RKMPP_DEC(vp9,   AV_CODEC_ID_VP9,           NULL)