• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/av


Commit MetaInfo

Revision7a6b9e2eca7d20457ace3538c689640e5bfda4f3 (tree)
Time2009-09-03 08:05:36
AuthorAndreas Huber <andih@goog...>
CommiterAndreas Huber

Log Message

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.

Change Summary

Incremental Difference

--- a/cmds/stagefright/record.cpp
+++ b/cmds/stagefright/record.cpp
@@ -50,11 +50,6 @@ public:
5050 return meta;
5151 }
5252
53- virtual status_t getMaxSampleSize(size_t *max_size) {
54- *max_size = mSize;
55- return OK;
56- }
57-
5853 virtual status_t start(MetaData *params) {
5954 return OK;
6055 }
@@ -209,7 +204,7 @@ int main(int argc, char **argv) {
209204
210205 return 0;
211206 }
212-#endif
207+#else
213208
214209 int main(int argc, char **argv) {
215210 android::ProcessState::self()->startThreadPool();
@@ -265,4 +260,4 @@ int main(int argc, char **argv) {
265260
266261 return 0;
267262 }
268-
263+#endif
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -135,6 +135,8 @@ private:
135135 void addCodecSpecificData(const void *data, size_t size);
136136 void clearCodecSpecificData();
137137
138+ void setComponentRole();
139+
138140 void setAMRFormat();
139141 void setAACFormat(int32_t numChannels, int32_t sampleRate);
140142
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -77,6 +77,8 @@ static const CodecInfo kEncoderInfo[] = {
7777 { "video/avc", "OMX.PV.avcenc" },
7878 };
7979
80+#define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
81+
8082 struct OMXCodecObserver : public BnOMXObserver {
8183 OMXCodecObserver(const wp<OMXCodec> &target)
8284 : mTarget(target) {
@@ -150,6 +152,15 @@ static const char *AVCProfileToString(uint8_t profile) {
150152 }
151153 }
152154
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+
153164 // static
154165 sp<OMXCodec> OMXCodec::Create(
155166 const sp<IOMX> &omx,
@@ -180,6 +191,7 @@ sp<OMXCodec> OMXCodec::Create(
180191
181192 status_t err = omx->allocate_node(componentName, &node);
182193 if (err == OK) {
194+ LOGV("Successfully allocated OMX node '%s'", componentName);
183195 break;
184196 }
185197 }
@@ -360,9 +372,7 @@ sp<OMXCodec> OMXCodec::Create(
360372
361373 void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) {
362374 OMX_PARAM_PORTDEFINITIONTYPE def;
363- def.nSize = sizeof(def);
364- def.nVersion.s.nVersionMajor = 1;
365- def.nVersion.s.nVersionMinor = 1;
375+ InitOMXParams(&def);
366376 def.nPortIndex = portIndex;
367377
368378 status_t err = mOMX->get_parameter(
@@ -384,9 +394,7 @@ status_t OMXCodec::setVideoPortFormatType(
384394 OMX_VIDEO_CODINGTYPE compressionFormat,
385395 OMX_COLOR_FORMATTYPE colorFormat) {
386396 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);
390398 format.nPortIndex = portIndex;
391399 format.nIndex = 0;
392400 bool found = false;
@@ -478,13 +486,11 @@ void OMXCodec::setVideoInputFormat(
478486 kPortIndexOutput, compressionFormat, OMX_COLOR_FormatUnused);
479487
480488 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);
486490 def.nPortIndex = kPortIndexOutput;
487491
492+ OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
493+
488494 status_t err = mOMX->get_parameter(
489495 mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
490496
@@ -503,9 +509,7 @@ void OMXCodec::setVideoInputFormat(
503509
504510 ////////////////////////////////////////////////////////////////////////////
505511
506- def.nSize = sizeof(def);
507- def.nVersion.s.nVersionMajor = 1;
508- def.nVersion.s.nVersionMinor = 1;
512+ InitOMXParams(&def);
509513 def.nPortIndex = kPortIndexInput;
510514
511515 err = mOMX->get_parameter(
@@ -513,7 +517,7 @@ void OMXCodec::setVideoInputFormat(
513517 CHECK_EQ(err, OK);
514518
515519 def.nBufferSize = (width * height * 2); // (width * height * 3) / 2;
516- LOGI("setting nBufferSize = %ld", def.nBufferSize);
520+ LOGI("Setting nBufferSize = %ld", def.nBufferSize);
517521
518522 CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
519523
@@ -531,37 +535,6 @@ void OMXCodec::setVideoOutputFormat(
531535 const char *mime, OMX_U32 width, OMX_U32 height) {
532536 LOGI("setVideoOutputFormat width=%ld, height=%ld", width, height);
533537
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-
565538 OMX_VIDEO_CODINGTYPE compressionFormat = OMX_VIDEO_CodingUnused;
566539 if (!strcasecmp("video/avc", mime)) {
567540 compressionFormat = OMX_VIDEO_CodingAVC;
@@ -580,9 +553,7 @@ void OMXCodec::setVideoOutputFormat(
580553 #if 1
581554 {
582555 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);
586557 format.nPortIndex = kPortIndexOutput;
587558 format.nIndex = 0;
588559
@@ -607,13 +578,11 @@ void OMXCodec::setVideoOutputFormat(
607578 #endif
608579
609580 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);
615582 def.nPortIndex = kPortIndexInput;
616583
584+ OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
585+
617586 status_t err = mOMX->get_parameter(
618587 mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
619588
@@ -640,9 +609,7 @@ void OMXCodec::setVideoOutputFormat(
640609
641610 ////////////////////////////////////////////////////////////////////////////
642611
643- def.nSize = sizeof(def);
644- def.nVersion.s.nVersionMajor = 1;
645- def.nVersion.s.nVersionMinor = 1;
612+ InitOMXParams(&def);
646613 def.nPortIndex = kPortIndexOutput;
647614
648615 err = mOMX->get_parameter(
@@ -688,6 +655,63 @@ OMXCodec::OMXCodec(
688655
689656 mObserver = new OMXCodecObserver(this);
690657 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+ }
691715 }
692716
693717 OMXCodec::~OMXCodec() {
@@ -761,11 +785,7 @@ status_t OMXCodec::allocateBuffers() {
761785
762786 status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
763787 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);
769789 def.nPortIndex = portIndex;
770790
771791 status_t err = mOMX->get_parameter(
@@ -813,7 +833,7 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
813833
814834 mPortBuffers[portIndex].push(info);
815835
816- LOGV("allocated buffer %p on %s port", buffer,
836+ CODEC_LOGV("allocated buffer %p on %s port", buffer,
817837 portIndex == kPortIndexInput ? "input" : "output");
818838 }
819839
@@ -839,7 +859,7 @@ void OMXCodec::on_message(const omx_message &msg) {
839859 {
840860 IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer;
841861
842- LOGV("EMPTY_BUFFER_DONE(buffer: %p)", buffer);
862+ CODEC_LOGV("EMPTY_BUFFER_DONE(buffer: %p)", buffer);
843863
844864 Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput];
845865 size_t i = 0;
@@ -856,7 +876,7 @@ void OMXCodec::on_message(const omx_message &msg) {
856876 buffers->editItemAt(i).mOwnedByComponent = false;
857877
858878 if (mPortStatus[kPortIndexInput] == DISABLING) {
859- LOGV("Port is disabled, freeing buffer %p", buffer);
879+ CODEC_LOGV("Port is disabled, freeing buffer %p", buffer);
860880
861881 status_t err =
862882 mOMX->free_buffer(mNode, kPortIndexInput, buffer);
@@ -876,12 +896,12 @@ void OMXCodec::on_message(const omx_message &msg) {
876896 IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer;
877897 OMX_U32 flags = msg.u.extended_buffer_data.flags;
878898
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)",
880900 buffer,
881901 msg.u.extended_buffer_data.range_length,
882902 flags);
883903
884- LOGV("FILL_BUFFER_DONE(timestamp: %lld us (%.2f secs))",
904+ CODEC_LOGV("FILL_BUFFER_DONE(timestamp: %lld us (%.2f secs))",
885905 msg.u.extended_buffer_data.timestamp,
886906 msg.u.extended_buffer_data.timestamp / 1E6);
887907
@@ -902,7 +922,7 @@ void OMXCodec::on_message(const omx_message &msg) {
902922 info->mOwnedByComponent = false;
903923
904924 if (mPortStatus[kPortIndexOutput] == DISABLING) {
905- LOGV("Port is disabled, freeing buffer %p", buffer);
925+ CODEC_LOGV("Port is disabled, freeing buffer %p", buffer);
906926
907927 status_t err =
908928 mOMX->free_buffer(mNode, kPortIndexOutput, buffer);
@@ -911,7 +931,7 @@ void OMXCodec::on_message(const omx_message &msg) {
911931 buffers->removeAt(i);
912932 } else if (mPortStatus[kPortIndexOutput] == ENABLED
913933 && (flags & OMX_BUFFERFLAG_EOS)) {
914- LOGV("No more output data.");
934+ CODEC_LOGV("No more output data.");
915935 mNoMoreOutputData = true;
916936 mBufferFilled.signal();
917937 } else if (mPortStatus[kPortIndexOutput] != SHUTTING_DOWN) {
@@ -983,7 +1003,7 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
9831003
9841004 case OMX_EventBufferFlag:
9851005 {
986- LOGV("EVENT_BUFFER_FLAG(%ld)", data1);
1006+ CODEC_LOGV("EVENT_BUFFER_FLAG(%ld)", data1);
9871007
9881008 if (data1 == kPortIndexOutput) {
9891009 mNoMoreOutputData = true;
@@ -993,7 +1013,7 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
9931013
9941014 default:
9951015 {
996- LOGV("EVENT(%d, %ld, %ld)", event, data1, data2);
1016+ CODEC_LOGV("EVENT(%d, %ld, %ld)", event, data1, data2);
9971017 break;
9981018 }
9991019 }
@@ -1010,7 +1030,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10101030 case OMX_CommandPortDisable:
10111031 {
10121032 OMX_U32 portIndex = data;
1013- LOGV("PORT_DISABLED(%ld)", portIndex);
1033+ CODEC_LOGV("PORT_DISABLED(%ld)", portIndex);
10141034
10151035 CHECK(mState == EXECUTING || mState == RECONFIGURING);
10161036 CHECK_EQ(mPortStatus[portIndex], DISABLING);
@@ -1032,7 +1052,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10321052 case OMX_CommandPortEnable:
10331053 {
10341054 OMX_U32 portIndex = data;
1035- LOGV("PORT_ENABLED(%ld)", portIndex);
1055+ CODEC_LOGV("PORT_ENABLED(%ld)", portIndex);
10361056
10371057 CHECK(mState == EXECUTING || mState == RECONFIGURING);
10381058 CHECK_EQ(mPortStatus[portIndex], ENABLING);
@@ -1053,7 +1073,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10531073 {
10541074 OMX_U32 portIndex = data;
10551075
1056- LOGV("FLUSH_DONE(%ld)", portIndex);
1076+ CODEC_LOGV("FLUSH_DONE(%ld)", portIndex);
10571077
10581078 CHECK_EQ(mPortStatus[portIndex], SHUTTING_DOWN);
10591079 mPortStatus[portIndex] = ENABLED;
@@ -1068,7 +1088,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10681088 } else if (mState == EXECUTING_TO_IDLE) {
10691089 if (mPortStatus[kPortIndexInput] == ENABLED
10701090 && mPortStatus[kPortIndexOutput] == ENABLED) {
1071- LOGV("Finished flushing both ports, now completing "
1091+ CODEC_LOGV("Finished flushing both ports, now completing "
10721092 "transition from EXECUTING to IDLE.");
10731093
10741094 mPortStatus[kPortIndexInput] = SHUTTING_DOWN;
@@ -1083,7 +1103,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10831103
10841104 if (mPortStatus[kPortIndexInput] == ENABLED
10851105 && mPortStatus[kPortIndexOutput] == ENABLED) {
1086- LOGV("Finished flushing both ports, now continuing from"
1106+ CODEC_LOGV("Finished flushing both ports, now continuing from"
10871107 " seek-time.");
10881108
10891109 drainInputBuffers();
@@ -1096,7 +1116,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
10961116
10971117 default:
10981118 {
1099- LOGV("CMD_COMPLETE(%d, %ld)", cmd, data);
1119+ CODEC_LOGV("CMD_COMPLETE(%d, %ld)", cmd, data);
11001120 break;
11011121 }
11021122 }
@@ -1106,7 +1126,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
11061126 switch (newState) {
11071127 case OMX_StateIdle:
11081128 {
1109- LOGV("Now Idle.");
1129+ CODEC_LOGV("Now Idle.");
11101130 if (mState == LOADED_TO_IDLE) {
11111131 status_t err = mOMX->send_command(
11121132 mNode, OMX_CommandStateSet, OMX_StateExecuting);
@@ -1148,7 +1168,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
11481168 {
11491169 CHECK_EQ(mState, IDLE_TO_EXECUTING);
11501170
1151- LOGV("Now Executing.");
1171+ CODEC_LOGV("Now Executing.");
11521172
11531173 setState(EXECUTING);
11541174
@@ -1164,7 +1184,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
11641184 {
11651185 CHECK_EQ(mState, IDLE_TO_LOADED);
11661186
1167- LOGV("Now Loaded.");
1187+ CODEC_LOGV("Now Loaded.");
11681188
11691189 setState(LOADED);
11701190 break;
@@ -1230,7 +1250,7 @@ status_t OMXCodec::freeBuffersOnPort(
12301250 }
12311251
12321252 void OMXCodec::onPortSettingsChanged(OMX_U32 portIndex) {
1233- LOGV("PORT_SETTINGS_CHANGED(%ld)", portIndex);
1253+ CODEC_LOGV("PORT_SETTINGS_CHANGED(%ld)", portIndex);
12341254
12351255 CHECK_EQ(mState, EXECUTING);
12361256 CHECK_EQ(portIndex, kPortIndexOutput);
@@ -1249,7 +1269,7 @@ bool OMXCodec::flushPortAsync(OMX_U32 portIndex) {
12491269 CHECK(mState == EXECUTING || mState == RECONFIGURING
12501270 || mState == EXECUTING_TO_IDLE);
12511271
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.",
12531273 portIndex, countBuffersWeOwn(mPortBuffers[portIndex]),
12541274 mPortBuffers[portIndex].size());
12551275
@@ -1372,7 +1392,7 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
13721392 size_t srcLength = 0;
13731393
13741394 if (err != OK) {
1375- LOGV("signalling end of input stream.");
1395+ CODEC_LOGV("signalling end of input stream.");
13761396 flags |= OMX_BUFFERFLAG_EOS;
13771397
13781398 mSignalledEOS = true;
@@ -1393,9 +1413,9 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
13931413 && srcBuffer->meta_data()->findInt32(kKeyTimeScale, &scale)) {
13941414 timestamp = ((OMX_TICKS)units * 1000000) / scale;
13951415
1396- LOGV("Calling empty_buffer on buffer %p (length %d)",
1416+ CODEC_LOGV("Calling empty_buffer on buffer %p (length %d)",
13971417 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)",
13991419 timestamp, timestamp / 1E6);
14001420 }
14011421 }
@@ -1416,12 +1436,12 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) {
14161436 CHECK_EQ(info->mOwnedByComponent, false);
14171437
14181438 if (mNoMoreOutputData) {
1419- LOGV("There is no more output data available, not "
1439+ CODEC_LOGV("There is no more output data available, not "
14201440 "calling fillOutputBuffer");
14211441 return;
14221442 }
14231443
1424- LOGV("Calling fill_buffer on buffer %p", info->mBuffer);
1444+ CODEC_LOGV("Calling fill_buffer on buffer %p", info->mBuffer);
14251445 mOMX->fill_buffer(mNode, info->mBuffer);
14261446
14271447 info->mOwnedByComponent = true;
@@ -1463,9 +1483,7 @@ void OMXCodec::setState(State newState) {
14631483 void OMXCodec::setRawAudioFormat(
14641484 OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels) {
14651485 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);
14691487 pcmParams.nPortIndex = portIndex;
14701488
14711489 status_t err = mOMX->get_parameter(
@@ -1498,9 +1516,7 @@ void OMXCodec::setRawAudioFormat(
14981516 void OMXCodec::setAMRFormat() {
14991517 if (!mIsEncoder) {
15001518 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);
15041520 def.nPortIndex = kPortIndexInput;
15051521
15061522 status_t err =
@@ -1533,9 +1549,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) {
15331549 setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
15341550 } else {
15351551 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);
15391553 profile.nPortIndex = kPortIndexInput;
15401554
15411555 status_t err = mOMX->get_parameter(
@@ -1554,7 +1568,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) {
15541568
15551569 void OMXCodec::setImageOutputFormat(
15561570 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);
15581572
15591573 #if 0
15601574 OMX_INDEXTYPE index;
@@ -1567,9 +1581,7 @@ void OMXCodec::setImageOutputFormat(
15671581 #endif
15681582
15691583 OMX_PARAM_PORTDEFINITIONTYPE def;
1570- def.nSize = sizeof(def);
1571- def.nVersion.s.nVersionMajor = 1;
1572- def.nVersion.s.nVersionMinor = 1;
1584+ InitOMXParams(&def);
15731585 def.nPortIndex = kPortIndexOutput;
15741586
15751587 status_t err = mOMX->get_parameter(
@@ -1620,9 +1632,7 @@ void OMXCodec::setImageOutputFormat(
16201632 void OMXCodec::setJPEGInputFormat(
16211633 OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize) {
16221634 OMX_PARAM_PORTDEFINITIONTYPE def;
1623- def.nSize = sizeof(def);
1624- def.nVersion.s.nVersionMajor = 1;
1625- def.nVersion.s.nVersionMinor = 1;
1635+ InitOMXParams(&def);
16261636 def.nPortIndex = kPortIndexInput;
16271637
16281638 status_t err = mOMX->get_parameter(
@@ -1690,7 +1700,7 @@ status_t OMXCodec::start(MetaData *) {
16901700 }
16911701
16921702 status_t OMXCodec::stop() {
1693- LOGV("stop");
1703+ CODEC_LOGV("stop");
16941704
16951705 Mutex::Autolock autoLock(mLock);
16961706
@@ -1708,7 +1718,7 @@ status_t OMXCodec::stop() {
17081718 setState(EXECUTING_TO_IDLE);
17091719
17101720 if (mQuirks & kRequiresFlushBeforeShutdown) {
1711- LOGV("This component requires a flush before transitioning "
1721+ CODEC_LOGV("This component requires a flush before transitioning "
17121722 "from EXECUTING to IDLE...");
17131723
17141724 bool emulateInputFlushCompletion =
@@ -1780,7 +1790,7 @@ status_t OMXCodec::read(
17801790
17811791 int64_t seekTimeUs;
17821792 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);
17841794
17851795 mSignalledEOS = false;
17861796 mNoMoreOutputData = false;
@@ -2009,9 +2019,7 @@ static const char *audioPCMModeString(OMX_AUDIO_PCMMODETYPE type) {
20092019
20102020 void OMXCodec::dumpPortStatus(OMX_U32 portIndex) {
20112021 OMX_PARAM_PORTDEFINITIONTYPE def;
2012- def.nSize = sizeof(def);
2013- def.nVersion.s.nVersionMajor = 1;
2014- def.nVersion.s.nVersionMinor = 1;
2022+ InitOMXParams(&def);
20152023 def.nPortIndex = portIndex;
20162024
20172025 status_t err = mOMX->get_parameter(
@@ -2077,9 +2085,7 @@ void OMXCodec::dumpPortStatus(OMX_U32 portIndex) {
20772085
20782086 if (audioDef->eEncoding == OMX_AUDIO_CodingPCM) {
20792087 OMX_AUDIO_PARAM_PCMMODETYPE params;
2080- params.nSize = sizeof(params);
2081- params.nVersion.s.nVersionMajor = 1;
2082- params.nVersion.s.nVersionMinor = 1;
2088+ InitOMXParams(&params);
20832089 params.nPortIndex = portIndex;
20842090
20852091 err = mOMX->get_parameter(
@@ -2116,9 +2122,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
21162122 mOutputFormat->setCString(kKeyDecoderComponent, mComponentName);
21172123
21182124 OMX_PARAM_PORTDEFINITIONTYPE def;
2119- def.nSize = sizeof(def);
2120- def.nVersion.s.nVersionMajor = 1;
2121- def.nVersion.s.nVersionMinor = 1;
2125+ InitOMXParams(&def);
21222126 def.nPortIndex = kPortIndexOutput;
21232127
21242128 status_t err = mOMX->get_parameter(
@@ -2144,9 +2148,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
21442148
21452149 if (audio_def->eEncoding == OMX_AUDIO_CodingPCM) {
21462150 OMX_AUDIO_PARAM_PCMMODETYPE params;
2147- params.nSize = sizeof(params);
2148- params.nVersion.s.nVersionMajor = 1;
2149- params.nVersion.s.nVersionMinor = 1;
2151+ InitOMXParams(&params);
21502152 params.nPortIndex = kPortIndexOutput;
21512153
21522154 err = mOMX->get_parameter(