2 * Copyright 2012 Michael Chen <omxcodec@gmail.com>
3 * Copyright 2015 The CyanogenMod Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #define LOG_TAG "SoftFFmpegVideo"
19 #include <utils/Log.h>
21 #include "SoftFFmpegVideo.h"
22 #include "FFmpegComponents.h"
24 #include <media/stagefright/foundation/ADebug.h>
25 #include <media/stagefright/foundation/AUtils.h>
26 #include <media/stagefright/foundation/hexdump.h>
27 #include <media/stagefright/MediaDefs.h>
31 #define DEBUG_EXTRADATA 0
33 static int decoder_reorder_pts = -1;
37 static const CodecProfileLevel kM4VProfileLevels[] = {
38 { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5 },
39 { OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5 },
42 SoftFFmpegVideo::SoftFFmpegVideo(
44 const char *componentRole,
45 OMX_VIDEO_CODINGTYPE codingType,
46 const CodecProfileLevel *profileLevels,
47 size_t numProfileLevels,
48 const OMX_CALLBACKTYPE *callbacks,
50 OMX_COMPONENTTYPE **component,
51 enum AVCodecID codecID)
52 : SoftVideoDecoderOMXComponent(name, componentRole, codingType,
53 profileLevels, numProfileLevels, 352, 288, callbacks, appData, component),
54 mCodingType(codingType),
55 mFFmpegAlreadyInited(false),
56 mCodecAlreadyOpened(false),
60 mEOSStatus(INPUT_DATA_AVAILABLE),
61 mExtradataReady(false),
62 mIgnoreExtradata(false),
64 mSignalledError(false) {
66 ALOGD("SoftFFmpegVideo component: %s codingType=%d appData: %p", name, codingType, appData);
70 1024 * 1024 /* inputBufferSize */,
74 CHECK_EQ(initDecoder(codecID), (status_t)OK);
77 SoftFFmpegVideo::~SoftFFmpegVideo() {
78 ALOGV("~SoftFFmpegVideo");
80 if (mFFmpegAlreadyInited) {
85 void SoftFFmpegVideo::setDefaultCtx(AVCodecContext *avctx, const AVCodec *codec) {
88 avctx->workaround_bugs = 1;
90 avctx->skip_frame = AVDISCARD_DEFAULT;
91 avctx->skip_idct = AVDISCARD_DEFAULT;
92 avctx->skip_loop_filter = AVDISCARD_ALL;
93 avctx->error_concealment = 3;
94 avctx->thread_count = 0;
96 if (fast) avctx->flags2 |= AV_CODEC_FLAG2_FAST;
97 #ifdef CODEC_FLAG_EMU_EDGE
98 if (codec->capabilities & AV_CODEC_CAP_DR1)
99 avctx->flags |= CODEC_FLAG_EMU_EDGE;
103 status_t SoftFFmpegVideo::initDecoder(enum AVCodecID codecID) {
106 status = initFFmpeg();
110 mFFmpegAlreadyInited = true;
112 mCtx = avcodec_alloc_context3(NULL);
115 ALOGE("avcodec_alloc_context failed.");
119 mCtx->codec_type = AVMEDIA_TYPE_VIDEO;
120 mCtx->codec_id = codecID;
121 mCtx->extradata_size = 0;
122 mCtx->extradata = NULL;
123 mCtx->width = mWidth;
124 mCtx->height = mHeight;
128 void SoftFFmpegVideo::deInitDecoder() {
130 if (avcodec_is_open(mCtx)) {
131 avcodec_flush_buffers(mCtx);
133 if (mCtx->extradata) {
134 av_free(mCtx->extradata);
135 mCtx->extradata = NULL;
136 mCtx->extradata_size = 0;
138 if (mCodecAlreadyOpened) {
140 mCodecAlreadyOpened = false;
146 av_frame_free(&mFrame);
149 if (mImgConvertCtx) {
150 sws_freeContext(mImgConvertCtx);
151 mImgConvertCtx = NULL;
155 OMX_ERRORTYPE SoftFFmpegVideo::internalGetParameter(
156 OMX_INDEXTYPE index, OMX_PTR params) {
157 //ALOGV("internalGetParameter index:0x%x", index);
159 case OMX_IndexParamVideoWmv:
161 OMX_VIDEO_PARAM_WMVTYPE *profile =
162 (OMX_VIDEO_PARAM_WMVTYPE *)params;
164 if (profile->nPortIndex != kInputPortIndex) {
165 return OMX_ErrorUndefined;
168 profile->eFormat = OMX_VIDEO_WMVFormatUnused;
170 return OMX_ErrorNone;
173 case OMX_IndexParamVideoRv:
175 OMX_VIDEO_PARAM_RVTYPE *profile =
176 (OMX_VIDEO_PARAM_RVTYPE *)params;
178 if (profile->nPortIndex != kInputPortIndex) {
179 return OMX_ErrorUndefined;
182 profile->eFormat = OMX_VIDEO_RVFormatUnused;
184 return OMX_ErrorNone;
189 if (index != (OMX_INDEXTYPE)OMX_IndexParamVideoFFmpeg) {
190 return SoftVideoDecoderOMXComponent::internalGetParameter(index, params);
193 OMX_VIDEO_PARAM_FFMPEGTYPE *profile =
194 (OMX_VIDEO_PARAM_FFMPEGTYPE *)params;
196 if (profile->nPortIndex != kInputPortIndex) {
197 return OMX_ErrorUndefined;
200 profile->eCodecId = AV_CODEC_ID_NONE;
202 profile->nHeight = 0;
204 return OMX_ErrorNone;
209 OMX_ERRORTYPE SoftFFmpegVideo::isRoleSupported(
210 const OMX_PARAM_COMPONENTROLETYPE *roleParams) {
212 i < sizeof(kVideoComponents) / sizeof(kVideoComponents[0]);
214 if (strncmp((const char *)roleParams->cRole,
215 kVideoComponents[i].mRole, OMX_MAX_STRINGNAME_SIZE - 1) == 0) {
216 return OMX_ErrorNone;
219 ALOGE("unsupported role: %s", (const char *)roleParams->cRole);
220 return OMX_ErrorUndefined;
223 OMX_ERRORTYPE SoftFFmpegVideo::internalSetParameter(
224 OMX_INDEXTYPE index, const OMX_PTR params) {
225 //ALOGV("internalSetParameter index:0x%x", index);
227 case OMX_IndexParamStandardComponentRole:
229 const OMX_PARAM_COMPONENTROLETYPE *roleParams =
230 (const OMX_PARAM_COMPONENTROLETYPE *)params;
231 return isRoleSupported(roleParams);
234 case OMX_IndexParamPortDefinition:
236 OMX_PARAM_PORTDEFINITIONTYPE *newParams =
237 (OMX_PARAM_PORTDEFINITIONTYPE *)params;
238 OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &newParams->format.video;
239 OMX_PARAM_PORTDEFINITIONTYPE *def = &editPortInfo(newParams->nPortIndex)->mDef;
241 uint32_t oldWidth = def->format.video.nFrameWidth;
242 uint32_t oldHeight = def->format.video.nFrameHeight;
243 uint32_t newWidth = video_def->nFrameWidth;
244 uint32_t newHeight = video_def->nFrameHeight;
245 if (newWidth != oldWidth || newHeight != oldHeight) {
246 bool outputPort = (newParams->nPortIndex == kOutputPortIndex);
248 ALOGV("OMX_IndexParamPortDefinition (output) width=%d height=%d", newWidth, newHeight);
250 // only update (essentially crop) if size changes
254 updatePortDefinitions(true, true);
255 // reset buffer size based on frame size
256 newParams->nBufferSize = def->nBufferSize;
258 // For input port, we only set nFrameWidth and nFrameHeight. Buffer size
259 // is updated when configuring the output port using the max-frame-size,
260 // though client can still request a larger size.
261 ALOGV("OMX_IndexParamPortDefinition (input) width=%d height=%d", newWidth, newHeight);
262 def->format.video.nFrameWidth = newWidth;
263 def->format.video.nFrameHeight = newHeight;
264 mCtx->width = newWidth;
265 mCtx->height = newHeight;
268 return SoftVideoDecoderOMXComponent::internalSetParameter(index, params);
271 case OMX_IndexParamVideoWmv:
273 OMX_VIDEO_PARAM_WMVTYPE *profile =
274 (OMX_VIDEO_PARAM_WMVTYPE *)params;
276 if (profile->nPortIndex != kInputPortIndex) {
277 return OMX_ErrorUndefined;
280 if (profile->eFormat == OMX_VIDEO_WMVFormat7) {
281 mCtx->codec_id = AV_CODEC_ID_WMV1;
282 } else if (profile->eFormat == OMX_VIDEO_WMVFormat8) {
283 mCtx->codec_id = AV_CODEC_ID_WMV2;
284 } else if (profile->eFormat == OMX_VIDEO_WMVFormat9) {
285 mCtx->codec_id = AV_CODEC_ID_WMV3;
287 mCtx->codec_id = AV_CODEC_ID_VC1;
290 return OMX_ErrorNone;
293 case OMX_IndexParamVideoRv:
295 OMX_VIDEO_PARAM_RVTYPE *profile =
296 (OMX_VIDEO_PARAM_RVTYPE *)params;
298 if (profile->nPortIndex != kInputPortIndex) {
299 return OMX_ErrorUndefined;
302 if (profile->eFormat == OMX_VIDEO_RVFormatG2) {
303 mCtx->codec_id = AV_CODEC_ID_RV20;
304 } else if (profile->eFormat == OMX_VIDEO_RVFormat8) {
305 mCtx->codec_id = AV_CODEC_ID_RV30;
306 } else if (profile->eFormat == OMX_VIDEO_RVFormat9) {
307 mCtx->codec_id = AV_CODEC_ID_RV40;
309 ALOGE("unsupported rv codec: 0x%x", profile->eFormat);
310 return OMX_ErrorUndefined;
313 return OMX_ErrorNone;
318 if (index != (OMX_INDEXTYPE)OMX_IndexParamVideoFFmpeg) {
319 return SoftVideoDecoderOMXComponent::internalSetParameter(index, params);
322 OMX_VIDEO_PARAM_FFMPEGTYPE *profile =
323 (OMX_VIDEO_PARAM_FFMPEGTYPE *)params;
325 if (profile->nPortIndex != kInputPortIndex) {
326 return OMX_ErrorUndefined;
329 mCtx->codec_id = (enum AVCodecID)profile->eCodecId;
330 mCtx->width = profile->nWidth;
331 mCtx->height = profile->nHeight;
333 ALOGD("got OMX_IndexParamVideoFFmpeg, "
334 "eCodecId:%d(%s), width:%u, height:%u",
336 avcodec_get_name(mCtx->codec_id),
340 return OMX_ErrorNone;
345 int32_t SoftFFmpegVideo::handleExtradata() {
346 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
347 BufferInfo *inInfo = *inQueue.begin();
348 OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
351 ALOGI("got extradata, ignore: %d, size: %u",
352 mIgnoreExtradata, inHeader->nFilledLen);
353 hexdump(inHeader->pBuffer + inHeader->nOffset, inHeader->nFilledLen);
356 if (mIgnoreExtradata) {
357 ALOGI("got extradata, size: %u, but ignore it", inHeader->nFilledLen);
359 if (!mExtradataReady) {
360 //if (mMode == MODE_H264)
361 //it is possible to receive multiple input buffer with OMX_BUFFERFLAG_CODECCONFIG flag.
362 //for example, H264, the first input buffer is SPS, and another is PPS!
363 int orig_extradata_size = mCtx->extradata_size;
364 mCtx->extradata_size += inHeader->nFilledLen;
365 mCtx->extradata = (uint8_t *)realloc(mCtx->extradata,
366 mCtx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
367 if (!mCtx->extradata) {
368 ALOGE("ffmpeg video decoder failed to alloc extradata memory.");
372 memcpy(mCtx->extradata + orig_extradata_size,
373 inHeader->pBuffer + inHeader->nOffset,
374 inHeader->nFilledLen);
375 memset(mCtx->extradata + mCtx->extradata_size, 0,
376 AV_INPUT_BUFFER_PADDING_SIZE);
380 inQueue.erase(inQueue.begin());
381 inInfo->mOwnedByUs = false;
382 notifyEmptyBufferDone(inHeader);
387 int32_t SoftFFmpegVideo::openDecoder() {
388 if (mCodecAlreadyOpened) {
392 if (!mExtradataReady) {
394 ALOGI("extradata is ready, size: %d", mCtx->extradata_size);
395 hexdump(mCtx->extradata, mCtx->extradata_size);
397 mExtradataReady = true;
400 //find decoder again as codec_id may have changed
401 mCtx->codec = avcodec_find_decoder(mCtx->codec_id);
403 ALOGE("ffmpeg video decoder failed to find codec");
404 return ERR_CODEC_NOT_FOUND;
407 setDefaultCtx(mCtx, mCtx->codec);
409 ALOGD("begin to open ffmpeg decoder(%s) now",
410 avcodec_get_name(mCtx->codec_id));
412 int err = avcodec_open2(mCtx, mCtx->codec, NULL);
414 ALOGE("ffmpeg video decoder failed to initialize. (%s)", av_err2str(err));
415 return ERR_DECODER_OPEN_FAILED;
417 mCodecAlreadyOpened = true;
419 ALOGD("open ffmpeg video decoder(%s) success",
420 avcodec_get_name(mCtx->codec_id));
422 mFrame = av_frame_alloc();
424 ALOGE("oom for video frame");
431 void SoftFFmpegVideo::initPacket(AVPacket *pkt,
432 OMX_BUFFERHEADERTYPE *inHeader) {
433 memset(pkt, 0, sizeof(AVPacket));
437 pkt->data = (uint8_t *)inHeader->pBuffer + inHeader->nOffset;
438 pkt->size = inHeader->nFilledLen;
439 pkt->pts = inHeader->nTimeStamp;
440 pkt->dts = inHeader->nTimeStamp;
444 pkt->pts = AV_NOPTS_VALUE;
448 if (pkt->pts != AV_NOPTS_VALUE)
450 ALOGV("pkt size:%d, pts:%lld", pkt->size, pkt->pts);
452 ALOGV("pkt size:%d, pts:N/A", pkt->size);
457 int32_t SoftFFmpegVideo::decodeVideo() {
458 int len = 0, err = 0;
460 int32_t ret = ERR_OK;
461 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
462 BufferInfo *inInfo = NULL;
463 OMX_BUFFERHEADERTYPE *inHeader = NULL;
465 if (!inQueue.empty()) {
466 inInfo = *inQueue.begin();
467 if (inInfo != NULL) {
468 inHeader = inInfo->mHeader;
472 if (mEOSStatus == INPUT_EOS_SEEN && (!inHeader || inHeader->nFilledLen == 0)
473 && !(mCtx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
478 initPacket(&pkt, inHeader);
480 err = avcodec_decode_video2(mCtx, mFrame, &gotPic, &pkt);
481 av_packet_unref(&pkt);
484 ALOGE("ffmpeg video decoder failed to decode frame. (%d)", err);
485 //don't send error to OMXCodec, skip!
489 ALOGI("ffmpeg video decoder failed to get frame.");
490 //stop sending empty packets if the decoder is finished
491 if ((mEOSStatus != INPUT_DATA_AVAILABLE && (mCtx->codec->capabilities & AV_CODEC_CAP_DELAY) &&
492 !inHeader) || inHeader->nFilledLen == 0) {
502 if (!inQueue.empty()) {
503 inQueue.erase(inQueue.begin());
505 inInfo->mOwnedByUs = false;
506 notifyEmptyBufferDone(inHeader);
513 int32_t SoftFFmpegVideo::drainOneOutputBuffer() {
514 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
515 BufferInfo *outInfo = *outQueue.begin();
516 OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
521 int64_t pts = AV_NOPTS_VALUE;
522 uint8_t *dst = outHeader->pBuffer;
524 uint32_t width = outputBufferWidth();
525 uint32_t height = outputBufferHeight();
528 data[1] = dst + width * height;
529 data[2] = data[1] + (width / 2 * height / 2);
531 linesize[1] = width / 2;
532 linesize[2] = width / 2;
534 ALOGV("drainOneOutputBuffer: frame_width=%d frame_height=%d width=%d height=%d ctx_width=%d ctx_height=%d", mFrame->width, mFrame->height, width, height, mCtx->width, mCtx->height);
536 int sws_flags = SWS_BICUBIC;
537 mImgConvertCtx = sws_getCachedContext(mImgConvertCtx,
538 mFrame->width, mFrame->height, (AVPixelFormat)mFrame->format, width, height,
539 AV_PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
540 if (mImgConvertCtx == NULL) {
541 ALOGE("Cannot initialize the conversion context");
542 return ERR_SWS_FAILED;
544 sws_scale(mImgConvertCtx, mFrame->data, mFrame->linesize,
545 0, height, data, linesize);
547 outHeader->nOffset = 0;
548 outHeader->nFilledLen = (outputBufferWidth() * outputBufferHeight() * 3) / 2;
549 outHeader->nFlags = 0;
550 if (mFrame->key_frame) {
551 outHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
555 #ifndef LIBAV_CONFIG_H
556 if (decoder_reorder_pts == -1) {
557 pts = av_frame_get_best_effort_timestamp(mFrame);
560 if (decoder_reorder_pts) {
561 pts = mFrame->pkt_pts;
563 pts = mFrame->pkt_dts;
566 if (pts == AV_NOPTS_VALUE) {
569 outHeader->nTimeStamp = pts; //FIXME pts is right???
572 ALOGV("mFrame pkt_pts: %lld pkt_dts: %lld used %lld", mFrame->pkt_pts, mFrame->pkt_dts, pts);
575 outQueue.erase(outQueue.begin());
576 outInfo->mOwnedByUs = false;
577 notifyFillBufferDone(outHeader);
582 void SoftFFmpegVideo::drainEOSOutputBuffer() {
583 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
584 BufferInfo *outInfo = *outQueue.begin();
585 CHECK(outInfo != NULL);
586 outQueue.erase(outQueue.begin());
587 OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
589 ALOGD("ffmpeg video decoder fill eos outbuf");
591 outHeader->nTimeStamp = 0;
592 outHeader->nFilledLen = 0;
593 outHeader->nFlags = OMX_BUFFERFLAG_EOS;
595 outInfo->mOwnedByUs = false;
596 notifyFillBufferDone(outHeader);
598 mEOSStatus = OUTPUT_FRAMES_FLUSHED;
601 void SoftFFmpegVideo::drainAllOutputBuffers() {
602 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
603 if (!mCodecAlreadyOpened) {
604 drainEOSOutputBuffer();
605 mEOSStatus = OUTPUT_FRAMES_FLUSHED;
609 while (!outQueue.empty()) {
610 int32_t err = decodeVideo();
612 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
613 mSignalledError = true;
615 } else if (err == ERR_FLUSHED) {
616 drainEOSOutputBuffer();
618 } else if (err == ERR_NO_FRM) {
621 CHECK_EQ(err, ERR_OK);
623 if (drainOneOutputBuffer() != ERR_OK) {
624 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
625 mSignalledError = true;
631 bool SoftFFmpegVideo::handlePortSettingsChange() {
632 CropSettingsMode crop = kCropUnSet;
633 uint32_t width = outputBufferWidth();
634 uint32_t height = outputBufferHeight();
635 if (width != (uint32_t)mCtx->width || height != (uint32_t)mCtx->height) {
637 if (mCropWidth != width || mCropHeight != height) {
641 mCropHeight = height;
646 bool portWillReset = false;
647 SoftVideoDecoderOMXComponent::handlePortSettingsChange(
648 &portWillReset, mCtx->width, mCtx->height, crop);
649 return portWillReset;
652 void SoftFFmpegVideo::onQueueFilled(OMX_U32 portIndex __unused) {
653 if (mSignalledError || mOutputPortSettingsChange != NONE) {
657 if (mEOSStatus == OUTPUT_FRAMES_FLUSHED) {
661 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
662 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
664 while (((mEOSStatus != INPUT_DATA_AVAILABLE) || !inQueue.empty())
665 && !outQueue.empty()) {
667 if (mEOSStatus == INPUT_EOS_SEEN) {
668 drainAllOutputBuffers();
672 BufferInfo *inInfo = *inQueue.begin();
673 if (inInfo == NULL) {
676 OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
677 if (inHeader == NULL) {
681 if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
682 mEOSStatus = INPUT_EOS_SEEN;
686 if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
687 ALOGD("ffmpeg got codecconfig buffer");
688 if (handleExtradata() != ERR_OK) {
689 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
690 mSignalledError = true;
695 if (!mCodecAlreadyOpened) {
696 if (openDecoder() != ERR_OK) {
697 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
698 mSignalledError = true;
703 int32_t err = decodeVideo();
705 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
706 mSignalledError = true;
708 } else if (err == ERR_FLUSHED) {
709 drainEOSOutputBuffer();
711 } else if (err == ERR_NO_FRM) {
714 CHECK_EQ(err, ERR_OK);
717 if (handlePortSettingsChange()) {
718 ALOGV("PORT RESET w=%d h=%d", mCtx->width, mCtx->height);
722 if (drainOneOutputBuffer() != ERR_OK) {
723 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
724 mSignalledError = true;
730 void SoftFFmpegVideo::onPortFlushCompleted(OMX_U32 portIndex) {
731 ALOGV("ffmpeg video decoder flush port(%u)", portIndex);
732 if (portIndex == kInputPortIndex) {
733 if (mCtx && avcodec_is_open(mCtx)) {
734 //Make sure that the next buffer output does not still
735 //depend on fragments from the last one decoded.
736 avcodec_flush_buffers(mCtx);
738 mEOSStatus = INPUT_DATA_AVAILABLE;
742 void SoftFFmpegVideo::onReset() {
744 enum AVCodecID codecID = mCtx->codec_id;
746 initDecoder(codecID);
747 SoftVideoDecoderOMXComponent::onReset();
748 mSignalledError = false;
749 mExtradataReady = false;
750 mEOSStatus = INPUT_DATA_AVAILABLE;
753 SoftOMXComponent* SoftFFmpegVideo::createSoftOMXComponent(
754 const char *name, const OMX_CALLBACKTYPE *callbacks,
755 OMX_PTR appData, OMX_COMPONENTTYPE **component) {
757 OMX_VIDEO_CODINGTYPE codingType = OMX_VIDEO_CodingAutoDetect;
758 char *componentRole = NULL;
759 enum AVCodecID codecID = AV_CODEC_ID_NONE;
761 for (size_t i = 0; i < kNumVideoComponents; ++i) {
762 if (!strcasecmp(name, kVideoComponents[i].mName)) {
763 componentRole = strdup(kVideoComponents[i].mRole);
764 codingType = kVideoComponents[i].mVideoCodingType;
765 codecID = kVideoComponents[i].mCodecID;
770 if (componentRole == NULL) {
774 if (!strcmp(name, "OMX.ffmpeg.mpeg4.decoder")) {
775 return new SoftFFmpegVideo(name, componentRole, codingType,
776 kM4VProfileLevels, ARRAY_SIZE(kM4VProfileLevels),
777 callbacks, appData, component, codecID);
780 return new SoftFFmpegVideo(name, componentRole, codingType,
782 callbacks, appData, component, codecID);
785 } // namespace android