MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / rkmpp_init_decoder

Function rkmpp_init_decoder

libavcodec/rkmppdec.c:153–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153static av_cold int rkmpp_init_decoder(AVCodecContext *avctx)
154{
155 RKMPPDecodeContext *rk_context = avctx->priv_data;
156 RKMPPDecoder *decoder = NULL;
157 MppCodingType codectype = MPP_VIDEO_CodingUnused;
158 int ret;
159 RK_S64 paramS64;
160 RK_S32 paramS32;
161
162 avctx->pix_fmt = AV_PIX_FMT_DRM_PRIME;
163
164 // create a decoder and a ref to it
165 decoder = av_refstruct_alloc_ext(sizeof(*decoder), 0,
166 NULL, rkmpp_release_decoder);
167 if (!decoder) {
168 ret = AVERROR(ENOMEM);
169 goto fail;
170 }
171 rk_context->decoder = decoder;
172
173 av_log(avctx, AV_LOG_DEBUG, "Initializing RKMPP decoder.\n");
174
175 codectype = rkmpp_get_codingtype(avctx);
176 if (codectype == MPP_VIDEO_CodingUnused) {
177 av_log(avctx, AV_LOG_ERROR, "Unknown codec type (%d).\n", avctx->codec_id);
178 ret = AVERROR_UNKNOWN;
179 goto fail;
180 }
181
182 ret = mpp_check_support_format(MPP_CTX_DEC, codectype);
183 if (ret != MPP_OK) {
184 av_log(avctx, AV_LOG_ERROR, "Codec type (%d) unsupported by MPP\n", avctx->codec_id);
185 ret = AVERROR_UNKNOWN;
186 goto fail;
187 }
188
189 // Create the MPP context
190 ret = mpp_create(&decoder->ctx, &decoder->mpi);
191 if (ret != MPP_OK) {
192 av_log(avctx, AV_LOG_ERROR, "Failed to create MPP context (code = %d).\n", ret);
193 ret = AVERROR_UNKNOWN;
194 goto fail;
195 }
196
197 // initialize mpp
198 ret = mpp_init(decoder->ctx, MPP_CTX_DEC, codectype);
199 if (ret != MPP_OK) {
200 av_log(avctx, AV_LOG_ERROR, "Failed to initialize MPP context (code = %d).\n", ret);
201 ret = AVERROR_UNKNOWN;
202 goto fail;
203 }
204
205 // make decode calls blocking with a timeout
206 paramS32 = MPP_POLL_BLOCK;
207 ret = decoder->mpi->control(decoder->ctx, MPP_SET_OUTPUT_BLOCK, &paramS32);
208 if (ret != MPP_OK) {
209 av_log(avctx, AV_LOG_ERROR, "Failed to set blocking mode on MPI (code = %d).\n", ret);
210 ret = AVERROR_UNKNOWN;

Callers

nothing calls this directly

Calls 5

av_refstruct_alloc_extFunction · 0.85
av_logFunction · 0.85
rkmpp_get_codingtypeFunction · 0.85
av_hwdevice_ctx_allocFunction · 0.85
av_hwdevice_ctx_initFunction · 0.85

Tested by

no test coverage detected