frameworks/av
Revision | 7a6b9e2eca7d20457ace3538c689640e5bfda4f3 (tree) |
---|---|
Time | 2009-09-03 08:05:36 |
Author | Andreas Huber <andih@goog...> |
Commiter | Andreas Huber |
Setting the component role appears to be mandatory now for all mime types.
Also using CODEC_LOGV instead of vanilla LOGV to include the component name the message related to.
@@ -50,11 +50,6 @@ public: | ||
50 | 50 | return meta; |
51 | 51 | } |
52 | 52 | |
53 | - virtual status_t getMaxSampleSize(size_t *max_size) { | |
54 | - *max_size = mSize; | |
55 | - return OK; | |
56 | - } | |
57 | - | |
58 | 53 | virtual status_t start(MetaData *params) { |
59 | 54 | return OK; |
60 | 55 | } |
@@ -209,7 +204,7 @@ int main(int argc, char **argv) { | ||
209 | 204 | |
210 | 205 | return 0; |
211 | 206 | } |
212 | -#endif | |
207 | +#else | |
213 | 208 | |
214 | 209 | int main(int argc, char **argv) { |
215 | 210 | android::ProcessState::self()->startThreadPool(); |
@@ -265,4 +260,4 @@ int main(int argc, char **argv) { | ||
265 | 260 | |
266 | 261 | return 0; |
267 | 262 | } |
268 | - | |
263 | +#endif |
@@ -135,6 +135,8 @@ private: | ||
135 | 135 | void addCodecSpecificData(const void *data, size_t size); |
136 | 136 | void clearCodecSpecificData(); |
137 | 137 | |
138 | + void setComponentRole(); | |
139 | + | |
138 | 140 | void setAMRFormat(); |
139 | 141 | void setAACFormat(int32_t numChannels, int32_t sampleRate); |
140 | 142 |
@@ -77,6 +77,8 @@ static const CodecInfo kEncoderInfo[] = { | ||
77 | 77 | { "video/avc", "OMX.PV.avcenc" }, |
78 | 78 | }; |
79 | 79 | |
80 | +#define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__) | |
81 | + | |
80 | 82 | struct OMXCodecObserver : public BnOMXObserver { |
81 | 83 | OMXCodecObserver(const wp<OMXCodec> &target) |
82 | 84 | : mTarget(target) { |
@@ -150,6 +152,15 @@ static const char *AVCProfileToString(uint8_t profile) { | ||
150 | 152 | } |
151 | 153 | } |
152 | 154 | |
155 | +template<class T> | |
156 | +static void InitOMXParams(T *params) { | |
157 | + params->nSize = sizeof(T); | |
158 | + params->nVersion.s.nVersionMajor = 1; | |
159 | + params->nVersion.s.nVersionMinor = 0; | |
160 | + params->nVersion.s.nRevision = 0; | |
161 | + params->nVersion.s.nStep = 0; | |
162 | +} | |
163 | + | |
153 | 164 | // static |
154 | 165 | sp<OMXCodec> OMXCodec::Create( |
155 | 166 | const sp<IOMX> &omx, |
@@ -180,6 +191,7 @@ sp<OMXCodec> OMXCodec::Create( | ||
180 | 191 | |
181 | 192 | status_t err = omx->allocate_node(componentName, &node); |
182 | 193 | if (err == OK) { |
194 | + LOGV("Successfully allocated OMX node '%s'", componentName); | |
183 | 195 | break; |
184 | 196 | } |
185 | 197 | } |
@@ -360,9 +372,7 @@ sp<OMXCodec> OMXCodec::Create( | ||
360 | 372 | |
361 | 373 | void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) { |
362 | 374 | OMX_PARAM_PORTDEFINITIONTYPE def; |
363 | - def.nSize = sizeof(def); | |
364 | - def.nVersion.s.nVersionMajor = 1; | |
365 | - def.nVersion.s.nVersionMinor = 1; | |
375 | + InitOMXParams(&def); | |
366 | 376 | def.nPortIndex = portIndex; |
367 | 377 | |
368 | 378 | status_t err = mOMX->get_parameter( |
@@ -384,9 +394,7 @@ status_t OMXCodec::setVideoPortFormatType( | ||
384 | 394 | OMX_VIDEO_CODINGTYPE compressionFormat, |
385 | 395 | OMX_COLOR_FORMATTYPE colorFormat) { |
386 | 396 | OMX_VIDEO_PARAM_PORTFORMATTYPE format; |
387 | - format.nSize = sizeof(format); | |
388 | - format.nVersion.s.nVersionMajor = 1; | |
389 | - format.nVersion.s.nVersionMinor = 1; | |
397 | + InitOMXParams(&format); | |
390 | 398 | format.nPortIndex = portIndex; |
391 | 399 | format.nIndex = 0; |
392 | 400 | bool found = false; |
@@ -478,13 +486,11 @@ void OMXCodec::setVideoInputFormat( | ||
478 | 486 | kPortIndexOutput, compressionFormat, OMX_COLOR_FormatUnused); |
479 | 487 | |
480 | 488 | OMX_PARAM_PORTDEFINITIONTYPE def; |
481 | - OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; | |
482 | - | |
483 | - def.nSize = sizeof(def); | |
484 | - def.nVersion.s.nVersionMajor = 1; | |
485 | - def.nVersion.s.nVersionMinor = 1; | |
489 | + InitOMXParams(&def); | |
486 | 490 | def.nPortIndex = kPortIndexOutput; |
487 | 491 | |
492 | + OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; | |
493 | + | |
488 | 494 | status_t err = mOMX->get_parameter( |
489 | 495 | mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); |
490 | 496 |
@@ -503,9 +509,7 @@ void OMXCodec::setVideoInputFormat( | ||
503 | 509 | |
504 | 510 | //////////////////////////////////////////////////////////////////////////// |
505 | 511 | |
506 | - def.nSize = sizeof(def); | |
507 | - def.nVersion.s.nVersionMajor = 1; | |
508 | - def.nVersion.s.nVersionMinor = 1; | |
512 | + InitOMXParams(&def); | |
509 | 513 | def.nPortIndex = kPortIndexInput; |
510 | 514 | |
511 | 515 | err = mOMX->get_parameter( |
@@ -513,7 +517,7 @@ void OMXCodec::setVideoInputFormat( | ||
513 | 517 | CHECK_EQ(err, OK); |
514 | 518 | |
515 | 519 | def.nBufferSize = (width * height * 2); // (width * height * 3) / 2; |
516 | - LOGI("setting nBufferSize = %ld", def.nBufferSize); | |
520 | + LOGI("Setting nBufferSize = %ld", def.nBufferSize); | |
517 | 521 | |
518 | 522 | CHECK_EQ(def.eDomain, OMX_PortDomainVideo); |
519 | 523 |
@@ -531,37 +535,6 @@ void OMXCodec::setVideoOutputFormat( | ||
531 | 535 | const char *mime, OMX_U32 width, OMX_U32 height) { |
532 | 536 | LOGI("setVideoOutputFormat width=%ld, height=%ld", width, height); |
533 | 537 | |
534 | - // Enabling this code appears to be the right thing(tm), but,... | |
535 | - // the TI decoder then loses the ability to output YUV420 and only outputs | |
536 | - // YCbYCr (16bit) | |
537 | - | |
538 | -#if 1 | |
539 | - if (!strcmp("OMX.TI.Video.Decoder", mComponentName)) { | |
540 | - OMX_PARAM_COMPONENTROLETYPE role; | |
541 | - role.nSize = sizeof(role); | |
542 | - role.nVersion.s.nVersionMajor = 1; | |
543 | - role.nVersion.s.nVersionMinor = 1; | |
544 | - | |
545 | - if (!strcasecmp("video/avc", mime)) { | |
546 | - strncpy((char *)role.cRole, "video_decoder.avc", | |
547 | - OMX_MAX_STRINGNAME_SIZE - 1); | |
548 | - } else if (!strcasecmp("video/mp4v-es", mime)) { | |
549 | - strncpy((char *)role.cRole, "video_decoder.mpeg4", | |
550 | - OMX_MAX_STRINGNAME_SIZE - 1); | |
551 | - } else if (!strcasecmp("video/3gpp", mime)) { | |
552 | - strncpy((char *)role.cRole, "video_decoder.h263", | |
553 | - OMX_MAX_STRINGNAME_SIZE - 1); | |
554 | - } | |
555 | - | |
556 | - role.cRole[OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; | |
557 | - | |
558 | - status_t err = mOMX->set_parameter( | |
559 | - mNode, OMX_IndexParamStandardComponentRole, | |
560 | - &role, sizeof(role)); | |
561 | - CHECK_EQ(err, OK); | |
562 | - } | |
563 | -#endif | |
564 | - | |
565 | 538 | OMX_VIDEO_CODINGTYPE compressionFormat = OMX_VIDEO_CodingUnused; |
566 | 539 | if (!strcasecmp("video/avc", mime)) { |
567 | 540 | compressionFormat = OMX_VIDEO_CodingAVC; |
@@ -580,9 +553,7 @@ void OMXCodec::setVideoOutputFormat( | ||
580 | 553 | #if 1 |
581 | 554 | { |
582 | 555 | OMX_VIDEO_PARAM_PORTFORMATTYPE format; |
583 | - format.nSize = sizeof(format); | |
584 | - format.nVersion.s.nVersionMajor = 1; | |
585 | - format.nVersion.s.nVersionMinor = 1; | |
556 | + InitOMXParams(&format); | |
586 | 557 | format.nPortIndex = kPortIndexOutput; |
587 | 558 | format.nIndex = 0; |
588 | 559 |
@@ -607,13 +578,11 @@ void OMXCodec::setVideoOutputFormat( | ||
607 | 578 | #endif |
608 | 579 | |
609 | 580 | OMX_PARAM_PORTDEFINITIONTYPE def; |
610 | - OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; | |
611 | - | |
612 | - def.nSize = sizeof(def); | |
613 | - def.nVersion.s.nVersionMajor = 1; | |
614 | - def.nVersion.s.nVersionMinor = 1; | |
581 | + InitOMXParams(&def); | |
615 | 582 | def.nPortIndex = kPortIndexInput; |
616 | 583 | |
584 | + OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; | |
585 | + | |
617 | 586 | status_t err = mOMX->get_parameter( |
618 | 587 | mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); |
619 | 588 |
@@ -640,9 +609,7 @@ void OMXCodec::setVideoOutputFormat( | ||
640 | 609 | |
641 | 610 | //////////////////////////////////////////////////////////////////////////// |
642 | 611 | |
643 | - def.nSize = sizeof(def); | |
644 | - def.nVersion.s.nVersionMajor = 1; | |
645 | - def.nVersion.s.nVersionMinor = 1; | |
612 | + InitOMXParams(&def); | |
646 | 613 | def.nPortIndex = kPortIndexOutput; |
647 | 614 | |
648 | 615 | err = mOMX->get_parameter( |
@@ -688,6 +655,63 @@ OMXCodec::OMXCodec( | ||
688 | 655 | |
689 | 656 | mObserver = new OMXCodecObserver(this); |
690 | 657 | mOMX->observe_node(mNode, mObserver); |
658 | + | |
659 | + setComponentRole(); | |
660 | +} | |
661 | + | |
662 | +void OMXCodec::setComponentRole() { | |
663 | + struct MimeToRole { | |
664 | + const char *mime; | |
665 | + const char *decoderRole; | |
666 | + const char *encoderRole; | |
667 | + }; | |
668 | + | |
669 | + static const MimeToRole kMimeToRole[] = { | |
670 | + { "audio/mpeg", "audio_decoder.mp3", "audio_encoder.mp3" }, | |
671 | + { "audio/3gpp", "audio_decoder.amrnb", "audio_encoder.amrnb" }, | |
672 | + { "audio/mp4a-latm", "audio_decoder.aac", "audio_encoder.aac" }, | |
673 | + { "video/avc", "video_decoder.avc", "video_encoder.avc" }, | |
674 | + { "video/mp4v-es", "video_decoder.mpeg4", "video_encoder.mpeg4" }, | |
675 | + { "video/3gpp", "video_decoder.h263", "video_encoder.h263" }, | |
676 | + }; | |
677 | + | |
678 | + static const size_t kNumMimeToRole = | |
679 | + sizeof(kMimeToRole) / sizeof(kMimeToRole[0]); | |
680 | + | |
681 | + size_t i; | |
682 | + for (i = 0; i < kNumMimeToRole; ++i) { | |
683 | + if (!strcasecmp(mMIME, kMimeToRole[i].mime)) { | |
684 | + break; | |
685 | + } | |
686 | + } | |
687 | + | |
688 | + if (i == kNumMimeToRole) { | |
689 | + return; | |
690 | + } | |
691 | + | |
692 | + const char *role = | |
693 | + mIsEncoder ? kMimeToRole[i].encoderRole | |
694 | + : kMimeToRole[i].decoderRole; | |
695 | + | |
696 | + if (role != NULL) { | |
697 | + CODEC_LOGV("Setting component role '%s'.", role); | |
698 | + | |
699 | + OMX_PARAM_COMPONENTROLETYPE roleParams; | |
700 | + InitOMXParams(&roleParams); | |
701 | + | |
702 | + strncpy((char *)roleParams.cRole, | |
703 | + role, OMX_MAX_STRINGNAME_SIZE - 1); | |
704 | + | |
705 | + roleParams.cRole[OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; | |
706 | + | |
707 | + status_t err = mOMX->set_parameter( | |
708 | + mNode, OMX_IndexParamStandardComponentRole, | |
709 | + &roleParams, sizeof(roleParams)); | |
710 | + | |
711 | + if (err != OK) { | |
712 | + LOGW("Failed to set standard component role '%s'.", role); | |
713 | + } | |
714 | + } | |
691 | 715 | } |
692 | 716 | |
693 | 717 | OMXCodec::~OMXCodec() { |
@@ -761,11 +785,7 @@ status_t OMXCodec::allocateBuffers() { | ||
761 | 785 | |
762 | 786 | status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { |
763 | 787 | OMX_PARAM_PORTDEFINITIONTYPE def; |
764 | - def.nSize = sizeof(def); | |
765 | - def.nVersion.s.nVersionMajor = 1; | |
766 | - def.nVersion.s.nVersionMinor = 1; | |
767 | - def.nVersion.s.nRevision = 0; | |
768 | - def.nVersion.s.nStep = 0; | |
788 | + InitOMXParams(&def); | |
769 | 789 | def.nPortIndex = portIndex; |
770 | 790 | |
771 | 791 | status_t err = mOMX->get_parameter( |
@@ -813,7 +833,7 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { | ||
813 | 833 | |
814 | 834 | mPortBuffers[portIndex].push(info); |
815 | 835 | |
816 | - LOGV("allocated buffer %p on %s port", buffer, | |
836 | + CODEC_LOGV("allocated buffer %p on %s port", buffer, | |
817 | 837 | portIndex == kPortIndexInput ? "input" : "output"); |
818 | 838 | } |
819 | 839 |
@@ -839,7 +859,7 @@ void OMXCodec::on_message(const omx_message &msg) { | ||
839 | 859 | { |
840 | 860 | IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer; |
841 | 861 | |
842 | - LOGV("EMPTY_BUFFER_DONE(buffer: %p)", buffer); | |
862 | + CODEC_LOGV("EMPTY_BUFFER_DONE(buffer: %p)", buffer); | |
843 | 863 | |
844 | 864 | Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput]; |
845 | 865 | size_t i = 0; |
@@ -856,7 +876,7 @@ void OMXCodec::on_message(const omx_message &msg) { | ||
856 | 876 | buffers->editItemAt(i).mOwnedByComponent = false; |
857 | 877 | |
858 | 878 | if (mPortStatus[kPortIndexInput] == DISABLING) { |
859 | - LOGV("Port is disabled, freeing buffer %p", buffer); | |
879 | + CODEC_LOGV("Port is disabled, freeing buffer %p", buffer); | |
860 | 880 | |
861 | 881 | status_t err = |
862 | 882 | mOMX->free_buffer(mNode, kPortIndexInput, buffer); |
@@ -876,12 +896,12 @@ void OMXCodec::on_message(const omx_message &msg) { | ||
876 | 896 | IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer; |
877 | 897 | OMX_U32 flags = msg.u.extended_buffer_data.flags; |
878 | 898 | |
879 | - LOGV("FILL_BUFFER_DONE(buffer: %p, size: %ld, flags: 0x%08lx)", | |
899 | + CODEC_LOGV("FILL_BUFFER_DONE(buffer: %p, size: %ld, flags: 0x%08lx)", | |
880 | 900 | buffer, |
881 | 901 | msg.u.extended_buffer_data.range_length, |
882 | 902 | flags); |
883 | 903 | |
884 | - LOGV("FILL_BUFFER_DONE(timestamp: %lld us (%.2f secs))", | |
904 | + CODEC_LOGV("FILL_BUFFER_DONE(timestamp: %lld us (%.2f secs))", | |
885 | 905 | msg.u.extended_buffer_data.timestamp, |
886 | 906 | msg.u.extended_buffer_data.timestamp / 1E6); |
887 | 907 |
@@ -902,7 +922,7 @@ void OMXCodec::on_message(const omx_message &msg) { | ||
902 | 922 | info->mOwnedByComponent = false; |
903 | 923 | |
904 | 924 | if (mPortStatus[kPortIndexOutput] == DISABLING) { |
905 | - LOGV("Port is disabled, freeing buffer %p", buffer); | |
925 | + CODEC_LOGV("Port is disabled, freeing buffer %p", buffer); | |
906 | 926 | |
907 | 927 | status_t err = |
908 | 928 | mOMX->free_buffer(mNode, kPortIndexOutput, buffer); |
@@ -911,7 +931,7 @@ void OMXCodec::on_message(const omx_message &msg) { | ||
911 | 931 | buffers->removeAt(i); |
912 | 932 | } else if (mPortStatus[kPortIndexOutput] == ENABLED |
913 | 933 | && (flags & OMX_BUFFERFLAG_EOS)) { |
914 | - LOGV("No more output data."); | |
934 | + CODEC_LOGV("No more output data."); | |
915 | 935 | mNoMoreOutputData = true; |
916 | 936 | mBufferFilled.signal(); |
917 | 937 | } else if (mPortStatus[kPortIndexOutput] != SHUTTING_DOWN) { |
@@ -983,7 +1003,7 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { | ||
983 | 1003 | |
984 | 1004 | case OMX_EventBufferFlag: |
985 | 1005 | { |
986 | - LOGV("EVENT_BUFFER_FLAG(%ld)", data1); | |
1006 | + CODEC_LOGV("EVENT_BUFFER_FLAG(%ld)", data1); | |
987 | 1007 | |
988 | 1008 | if (data1 == kPortIndexOutput) { |
989 | 1009 | mNoMoreOutputData = true; |
@@ -993,7 +1013,7 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { | ||
993 | 1013 | |
994 | 1014 | default: |
995 | 1015 | { |
996 | - LOGV("EVENT(%d, %ld, %ld)", event, data1, data2); | |
1016 | + CODEC_LOGV("EVENT(%d, %ld, %ld)", event, data1, data2); | |
997 | 1017 | break; |
998 | 1018 | } |
999 | 1019 | } |
@@ -1010,7 +1030,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1010 | 1030 | case OMX_CommandPortDisable: |
1011 | 1031 | { |
1012 | 1032 | OMX_U32 portIndex = data; |
1013 | - LOGV("PORT_DISABLED(%ld)", portIndex); | |
1033 | + CODEC_LOGV("PORT_DISABLED(%ld)", portIndex); | |
1014 | 1034 | |
1015 | 1035 | CHECK(mState == EXECUTING || mState == RECONFIGURING); |
1016 | 1036 | CHECK_EQ(mPortStatus[portIndex], DISABLING); |
@@ -1032,7 +1052,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1032 | 1052 | case OMX_CommandPortEnable: |
1033 | 1053 | { |
1034 | 1054 | OMX_U32 portIndex = data; |
1035 | - LOGV("PORT_ENABLED(%ld)", portIndex); | |
1055 | + CODEC_LOGV("PORT_ENABLED(%ld)", portIndex); | |
1036 | 1056 | |
1037 | 1057 | CHECK(mState == EXECUTING || mState == RECONFIGURING); |
1038 | 1058 | CHECK_EQ(mPortStatus[portIndex], ENABLING); |
@@ -1053,7 +1073,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1053 | 1073 | { |
1054 | 1074 | OMX_U32 portIndex = data; |
1055 | 1075 | |
1056 | - LOGV("FLUSH_DONE(%ld)", portIndex); | |
1076 | + CODEC_LOGV("FLUSH_DONE(%ld)", portIndex); | |
1057 | 1077 | |
1058 | 1078 | CHECK_EQ(mPortStatus[portIndex], SHUTTING_DOWN); |
1059 | 1079 | mPortStatus[portIndex] = ENABLED; |
@@ -1068,7 +1088,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1068 | 1088 | } else if (mState == EXECUTING_TO_IDLE) { |
1069 | 1089 | if (mPortStatus[kPortIndexInput] == ENABLED |
1070 | 1090 | && mPortStatus[kPortIndexOutput] == ENABLED) { |
1071 | - LOGV("Finished flushing both ports, now completing " | |
1091 | + CODEC_LOGV("Finished flushing both ports, now completing " | |
1072 | 1092 | "transition from EXECUTING to IDLE."); |
1073 | 1093 | |
1074 | 1094 | mPortStatus[kPortIndexInput] = SHUTTING_DOWN; |
@@ -1083,7 +1103,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1083 | 1103 | |
1084 | 1104 | if (mPortStatus[kPortIndexInput] == ENABLED |
1085 | 1105 | && mPortStatus[kPortIndexOutput] == ENABLED) { |
1086 | - LOGV("Finished flushing both ports, now continuing from" | |
1106 | + CODEC_LOGV("Finished flushing both ports, now continuing from" | |
1087 | 1107 | " seek-time."); |
1088 | 1108 | |
1089 | 1109 | drainInputBuffers(); |
@@ -1096,7 +1116,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { | ||
1096 | 1116 | |
1097 | 1117 | default: |
1098 | 1118 | { |
1099 | - LOGV("CMD_COMPLETE(%d, %ld)", cmd, data); | |
1119 | + CODEC_LOGV("CMD_COMPLETE(%d, %ld)", cmd, data); | |
1100 | 1120 | break; |
1101 | 1121 | } |
1102 | 1122 | } |
@@ -1106,7 +1126,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { | ||
1106 | 1126 | switch (newState) { |
1107 | 1127 | case OMX_StateIdle: |
1108 | 1128 | { |
1109 | - LOGV("Now Idle."); | |
1129 | + CODEC_LOGV("Now Idle."); | |
1110 | 1130 | if (mState == LOADED_TO_IDLE) { |
1111 | 1131 | status_t err = mOMX->send_command( |
1112 | 1132 | mNode, OMX_CommandStateSet, OMX_StateExecuting); |
@@ -1148,7 +1168,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { | ||
1148 | 1168 | { |
1149 | 1169 | CHECK_EQ(mState, IDLE_TO_EXECUTING); |
1150 | 1170 | |
1151 | - LOGV("Now Executing."); | |
1171 | + CODEC_LOGV("Now Executing."); | |
1152 | 1172 | |
1153 | 1173 | setState(EXECUTING); |
1154 | 1174 |
@@ -1164,7 +1184,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { | ||
1164 | 1184 | { |
1165 | 1185 | CHECK_EQ(mState, IDLE_TO_LOADED); |
1166 | 1186 | |
1167 | - LOGV("Now Loaded."); | |
1187 | + CODEC_LOGV("Now Loaded."); | |
1168 | 1188 | |
1169 | 1189 | setState(LOADED); |
1170 | 1190 | break; |
@@ -1230,7 +1250,7 @@ status_t OMXCodec::freeBuffersOnPort( | ||
1230 | 1250 | } |
1231 | 1251 | |
1232 | 1252 | void OMXCodec::onPortSettingsChanged(OMX_U32 portIndex) { |
1233 | - LOGV("PORT_SETTINGS_CHANGED(%ld)", portIndex); | |
1253 | + CODEC_LOGV("PORT_SETTINGS_CHANGED(%ld)", portIndex); | |
1234 | 1254 | |
1235 | 1255 | CHECK_EQ(mState, EXECUTING); |
1236 | 1256 | CHECK_EQ(portIndex, kPortIndexOutput); |
@@ -1249,7 +1269,7 @@ bool OMXCodec::flushPortAsync(OMX_U32 portIndex) { | ||
1249 | 1269 | CHECK(mState == EXECUTING || mState == RECONFIGURING |
1250 | 1270 | || mState == EXECUTING_TO_IDLE); |
1251 | 1271 | |
1252 | - LOGV("flushPortAsync(%ld): we own %d out of %d buffers already.", | |
1272 | + CODEC_LOGV("flushPortAsync(%ld): we own %d out of %d buffers already.", | |
1253 | 1273 | portIndex, countBuffersWeOwn(mPortBuffers[portIndex]), |
1254 | 1274 | mPortBuffers[portIndex].size()); |
1255 | 1275 |
@@ -1372,7 +1392,7 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { | ||
1372 | 1392 | size_t srcLength = 0; |
1373 | 1393 | |
1374 | 1394 | if (err != OK) { |
1375 | - LOGV("signalling end of input stream."); | |
1395 | + CODEC_LOGV("signalling end of input stream."); | |
1376 | 1396 | flags |= OMX_BUFFERFLAG_EOS; |
1377 | 1397 | |
1378 | 1398 | mSignalledEOS = true; |
@@ -1393,9 +1413,9 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { | ||
1393 | 1413 | && srcBuffer->meta_data()->findInt32(kKeyTimeScale, &scale)) { |
1394 | 1414 | timestamp = ((OMX_TICKS)units * 1000000) / scale; |
1395 | 1415 | |
1396 | - LOGV("Calling empty_buffer on buffer %p (length %d)", | |
1416 | + CODEC_LOGV("Calling empty_buffer on buffer %p (length %d)", | |
1397 | 1417 | info->mBuffer, srcLength); |
1398 | - LOGV("Calling empty_buffer with timestamp %lld us (%.2f secs)", | |
1418 | + CODEC_LOGV("Calling empty_buffer with timestamp %lld us (%.2f secs)", | |
1399 | 1419 | timestamp, timestamp / 1E6); |
1400 | 1420 | } |
1401 | 1421 | } |
@@ -1416,12 +1436,12 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) { | ||
1416 | 1436 | CHECK_EQ(info->mOwnedByComponent, false); |
1417 | 1437 | |
1418 | 1438 | if (mNoMoreOutputData) { |
1419 | - LOGV("There is no more output data available, not " | |
1439 | + CODEC_LOGV("There is no more output data available, not " | |
1420 | 1440 | "calling fillOutputBuffer"); |
1421 | 1441 | return; |
1422 | 1442 | } |
1423 | 1443 | |
1424 | - LOGV("Calling fill_buffer on buffer %p", info->mBuffer); | |
1444 | + CODEC_LOGV("Calling fill_buffer on buffer %p", info->mBuffer); | |
1425 | 1445 | mOMX->fill_buffer(mNode, info->mBuffer); |
1426 | 1446 | |
1427 | 1447 | info->mOwnedByComponent = true; |
@@ -1463,9 +1483,7 @@ void OMXCodec::setState(State newState) { | ||
1463 | 1483 | void OMXCodec::setRawAudioFormat( |
1464 | 1484 | OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels) { |
1465 | 1485 | OMX_AUDIO_PARAM_PCMMODETYPE pcmParams; |
1466 | - pcmParams.nSize = sizeof(pcmParams); | |
1467 | - pcmParams.nVersion.s.nVersionMajor = 1; | |
1468 | - pcmParams.nVersion.s.nVersionMinor = 1; | |
1486 | + InitOMXParams(&pcmParams); | |
1469 | 1487 | pcmParams.nPortIndex = portIndex; |
1470 | 1488 | |
1471 | 1489 | status_t err = mOMX->get_parameter( |
@@ -1498,9 +1516,7 @@ void OMXCodec::setRawAudioFormat( | ||
1498 | 1516 | void OMXCodec::setAMRFormat() { |
1499 | 1517 | if (!mIsEncoder) { |
1500 | 1518 | OMX_AUDIO_PARAM_AMRTYPE def; |
1501 | - def.nSize = sizeof(def); | |
1502 | - def.nVersion.s.nVersionMajor = 1; | |
1503 | - def.nVersion.s.nVersionMinor = 1; | |
1519 | + InitOMXParams(&def); | |
1504 | 1520 | def.nPortIndex = kPortIndexInput; |
1505 | 1521 | |
1506 | 1522 | status_t err = |
@@ -1533,9 +1549,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) { | ||
1533 | 1549 | setRawAudioFormat(kPortIndexInput, sampleRate, numChannels); |
1534 | 1550 | } else { |
1535 | 1551 | OMX_AUDIO_PARAM_AACPROFILETYPE profile; |
1536 | - profile.nSize = sizeof(profile); | |
1537 | - profile.nVersion.s.nVersionMajor = 1; | |
1538 | - profile.nVersion.s.nVersionMinor = 1; | |
1552 | + InitOMXParams(&profile); | |
1539 | 1553 | profile.nPortIndex = kPortIndexInput; |
1540 | 1554 | |
1541 | 1555 | status_t err = mOMX->get_parameter( |
@@ -1554,7 +1568,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) { | ||
1554 | 1568 | |
1555 | 1569 | void OMXCodec::setImageOutputFormat( |
1556 | 1570 | OMX_COLOR_FORMATTYPE format, OMX_U32 width, OMX_U32 height) { |
1557 | - LOGV("setImageOutputFormat(%ld, %ld)", width, height); | |
1571 | + CODEC_LOGV("setImageOutputFormat(%ld, %ld)", width, height); | |
1558 | 1572 | |
1559 | 1573 | #if 0 |
1560 | 1574 | OMX_INDEXTYPE index; |
@@ -1567,9 +1581,7 @@ void OMXCodec::setImageOutputFormat( | ||
1567 | 1581 | #endif |
1568 | 1582 | |
1569 | 1583 | OMX_PARAM_PORTDEFINITIONTYPE def; |
1570 | - def.nSize = sizeof(def); | |
1571 | - def.nVersion.s.nVersionMajor = 1; | |
1572 | - def.nVersion.s.nVersionMinor = 1; | |
1584 | + InitOMXParams(&def); | |
1573 | 1585 | def.nPortIndex = kPortIndexOutput; |
1574 | 1586 | |
1575 | 1587 | status_t err = mOMX->get_parameter( |
@@ -1620,9 +1632,7 @@ void OMXCodec::setImageOutputFormat( | ||
1620 | 1632 | void OMXCodec::setJPEGInputFormat( |
1621 | 1633 | OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize) { |
1622 | 1634 | OMX_PARAM_PORTDEFINITIONTYPE def; |
1623 | - def.nSize = sizeof(def); | |
1624 | - def.nVersion.s.nVersionMajor = 1; | |
1625 | - def.nVersion.s.nVersionMinor = 1; | |
1635 | + InitOMXParams(&def); | |
1626 | 1636 | def.nPortIndex = kPortIndexInput; |
1627 | 1637 | |
1628 | 1638 | status_t err = mOMX->get_parameter( |
@@ -1690,7 +1700,7 @@ status_t OMXCodec::start(MetaData *) { | ||
1690 | 1700 | } |
1691 | 1701 | |
1692 | 1702 | status_t OMXCodec::stop() { |
1693 | - LOGV("stop"); | |
1703 | + CODEC_LOGV("stop"); | |
1694 | 1704 | |
1695 | 1705 | Mutex::Autolock autoLock(mLock); |
1696 | 1706 |
@@ -1708,7 +1718,7 @@ status_t OMXCodec::stop() { | ||
1708 | 1718 | setState(EXECUTING_TO_IDLE); |
1709 | 1719 | |
1710 | 1720 | if (mQuirks & kRequiresFlushBeforeShutdown) { |
1711 | - LOGV("This component requires a flush before transitioning " | |
1721 | + CODEC_LOGV("This component requires a flush before transitioning " | |
1712 | 1722 | "from EXECUTING to IDLE..."); |
1713 | 1723 | |
1714 | 1724 | bool emulateInputFlushCompletion = |
@@ -1780,7 +1790,7 @@ status_t OMXCodec::read( | ||
1780 | 1790 | |
1781 | 1791 | int64_t seekTimeUs; |
1782 | 1792 | if (options && options->getSeekTo(&seekTimeUs)) { |
1783 | - LOGV("seeking to %lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6); | |
1793 | + CODEC_LOGV("seeking to %lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6); | |
1784 | 1794 | |
1785 | 1795 | mSignalledEOS = false; |
1786 | 1796 | mNoMoreOutputData = false; |
@@ -2009,9 +2019,7 @@ static const char *audioPCMModeString(OMX_AUDIO_PCMMODETYPE type) { | ||
2009 | 2019 | |
2010 | 2020 | void OMXCodec::dumpPortStatus(OMX_U32 portIndex) { |
2011 | 2021 | OMX_PARAM_PORTDEFINITIONTYPE def; |
2012 | - def.nSize = sizeof(def); | |
2013 | - def.nVersion.s.nVersionMajor = 1; | |
2014 | - def.nVersion.s.nVersionMinor = 1; | |
2022 | + InitOMXParams(&def); | |
2015 | 2023 | def.nPortIndex = portIndex; |
2016 | 2024 | |
2017 | 2025 | status_t err = mOMX->get_parameter( |
@@ -2077,9 +2085,7 @@ void OMXCodec::dumpPortStatus(OMX_U32 portIndex) { | ||
2077 | 2085 | |
2078 | 2086 | if (audioDef->eEncoding == OMX_AUDIO_CodingPCM) { |
2079 | 2087 | OMX_AUDIO_PARAM_PCMMODETYPE params; |
2080 | - params.nSize = sizeof(params); | |
2081 | - params.nVersion.s.nVersionMajor = 1; | |
2082 | - params.nVersion.s.nVersionMinor = 1; | |
2088 | + InitOMXParams(¶ms); | |
2083 | 2089 | params.nPortIndex = portIndex; |
2084 | 2090 | |
2085 | 2091 | err = mOMX->get_parameter( |
@@ -2116,9 +2122,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { | ||
2116 | 2122 | mOutputFormat->setCString(kKeyDecoderComponent, mComponentName); |
2117 | 2123 | |
2118 | 2124 | OMX_PARAM_PORTDEFINITIONTYPE def; |
2119 | - def.nSize = sizeof(def); | |
2120 | - def.nVersion.s.nVersionMajor = 1; | |
2121 | - def.nVersion.s.nVersionMinor = 1; | |
2125 | + InitOMXParams(&def); | |
2122 | 2126 | def.nPortIndex = kPortIndexOutput; |
2123 | 2127 | |
2124 | 2128 | status_t err = mOMX->get_parameter( |
@@ -2144,9 +2148,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { | ||
2144 | 2148 | |
2145 | 2149 | if (audio_def->eEncoding == OMX_AUDIO_CodingPCM) { |
2146 | 2150 | OMX_AUDIO_PARAM_PCMMODETYPE params; |
2147 | - params.nSize = sizeof(params); | |
2148 | - params.nVersion.s.nVersionMajor = 1; | |
2149 | - params.nVersion.s.nVersionMinor = 1; | |
2151 | + InitOMXParams(¶ms); | |
2150 | 2152 | params.nPortIndex = kPortIndexOutput; |
2151 | 2153 | |
2152 | 2154 | err = mOMX->get_parameter( |