blob: 45e2ca8c11fa2bb55b05b154cc3683ee2601960d [file] [log] [blame]
Pawin Vongmasa36653902018-11-15 00:10:25 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "C2SoftVpxDec"
19#include <log/log.h>
20
Wonsik Kimf61206f2019-05-18 16:52:46 -070021#include <algorithm>
22
Pawin Vongmasa36653902018-11-15 00:10:25 -080023#include <media/stagefright/foundation/AUtils.h>
24#include <media/stagefright/foundation/MediaDefs.h>
25
26#include <C2Debug.h>
27#include <C2PlatformSupport.h>
28#include <SimpleC2Interface.h>
29
30#include "C2SoftVpxDec.h"
31
32namespace android {
Harish Mahendrakare55c4712019-07-26 12:32:13 -070033constexpr size_t kMinInputBufferSize = 2 * 1024 * 1024;
Pawin Vongmasa36653902018-11-15 00:10:25 -080034#ifdef VP9
35constexpr char COMPONENT_NAME[] = "c2.android.vp9.decoder";
36#else
37constexpr char COMPONENT_NAME[] = "c2.android.vp8.decoder";
38#endif
39
40class C2SoftVpxDec::IntfImpl : public SimpleInterface<void>::BaseParams {
41public:
42 explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
43 : SimpleInterface<void>::BaseParams(
44 helper,
45 COMPONENT_NAME,
46 C2Component::KIND_DECODER,
47 C2Component::DOMAIN_VIDEO,
48#ifdef VP9
49 MEDIA_MIMETYPE_VIDEO_VP9
50#else
51 MEDIA_MIMETYPE_VIDEO_VP8
52#endif
53 ) {
54 noPrivateBuffers(); // TODO: account for our buffers here
55 noInputReferences();
56 noOutputReferences();
57 noInputLatency();
58 noTimeStretch();
59
60 // TODO: output latency and reordering
61
62 addParameter(
63 DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
64 .withConstValue(new C2ComponentAttributesSetting(C2Component::ATTRIB_IS_TEMPORAL))
65 .build());
66
67 addParameter(
68 DefineParam(mSize, C2_PARAMKEY_PICTURE_SIZE)
69 .withDefault(new C2StreamPictureSizeInfo::output(0u, 320, 240))
70 .withFields({
71 C2F(mSize, width).inRange(2, 2048, 2),
72 C2F(mSize, height).inRange(2, 2048, 2),
73 })
74 .withSetter(SizeSetter)
75 .build());
76
77#ifdef VP9
78 // TODO: Add C2Config::PROFILE_VP9_2HDR ??
79 addParameter(
80 DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
81 .withDefault(new C2StreamProfileLevelInfo::input(0u,
82 C2Config::PROFILE_VP9_0, C2Config::LEVEL_VP9_5))
83 .withFields({
84 C2F(mProfileLevel, profile).oneOf({
85 C2Config::PROFILE_VP9_0,
86 C2Config::PROFILE_VP9_2}),
87 C2F(mProfileLevel, level).oneOf({
88 C2Config::LEVEL_VP9_1,
89 C2Config::LEVEL_VP9_1_1,
90 C2Config::LEVEL_VP9_2,
91 C2Config::LEVEL_VP9_2_1,
92 C2Config::LEVEL_VP9_3,
93 C2Config::LEVEL_VP9_3_1,
94 C2Config::LEVEL_VP9_4,
95 C2Config::LEVEL_VP9_4_1,
96 C2Config::LEVEL_VP9_5,
97 })
98 })
99 .withSetter(ProfileLevelSetter, mSize)
100 .build());
101
Pawin Vongmasa8be93112018-12-11 14:01:42 -0800102 mHdr10PlusInfoInput = C2StreamHdr10PlusInfo::input::AllocShared(0);
103 addParameter(
104 DefineParam(mHdr10PlusInfoInput, C2_PARAMKEY_INPUT_HDR10_PLUS_INFO)
105 .withDefault(mHdr10PlusInfoInput)
106 .withFields({
107 C2F(mHdr10PlusInfoInput, m.value).any(),
108 })
109 .withSetter(Hdr10PlusInfoInputSetter)
110 .build());
111
112 mHdr10PlusInfoOutput = C2StreamHdr10PlusInfo::output::AllocShared(0);
113 addParameter(
114 DefineParam(mHdr10PlusInfoOutput, C2_PARAMKEY_OUTPUT_HDR10_PLUS_INFO)
115 .withDefault(mHdr10PlusInfoOutput)
116 .withFields({
117 C2F(mHdr10PlusInfoOutput, m.value).any(),
118 })
119 .withSetter(Hdr10PlusInfoOutputSetter)
120 .build());
121
Pawin Vongmasa36653902018-11-15 00:10:25 -0800122#if 0
123 // sample BT.2020 static info
124 mHdrStaticInfo = std::make_shared<C2StreamHdrStaticInfo::output>();
125 mHdrStaticInfo->mastering = {
126 .red = { .x = 0.708, .y = 0.292 },
127 .green = { .x = 0.170, .y = 0.797 },
128 .blue = { .x = 0.131, .y = 0.046 },
129 .white = { .x = 0.3127, .y = 0.3290 },
130 .maxLuminance = 1000,
131 .minLuminance = 0.1,
132 };
133 mHdrStaticInfo->maxCll = 1000;
134 mHdrStaticInfo->maxFall = 120;
135
136 mHdrStaticInfo->maxLuminance = 0; // disable static info
137
138 helper->addStructDescriptors<C2MasteringDisplayColorVolumeStruct, C2ColorXyStruct>();
139 addParameter(
140 DefineParam(mHdrStaticInfo, C2_PARAMKEY_HDR_STATIC_INFO)
141 .withDefault(mHdrStaticInfo)
142 .withFields({
143 C2F(mHdrStaticInfo, mastering.red.x).inRange(0, 1),
144 // TODO
145 })
146 .withSetter(HdrStaticInfoSetter)
147 .build());
148#endif
149#else
150 addParameter(
151 DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
Harish Mahendrakar22cb9d02021-08-26 16:35:48 -0700152 .withDefault(new C2StreamProfileLevelInfo::input(0u,
153 C2Config::PROFILE_VP8_0, C2Config::LEVEL_UNUSED))
154 .withFields({
155 C2F(mProfileLevel, profile).equalTo(
156 PROFILE_VP8_0
157 ),
158 C2F(mProfileLevel, level).equalTo(
159 LEVEL_UNUSED),
160 })
161 .withSetter(ProfileLevelSetter, mSize)
Pawin Vongmasa36653902018-11-15 00:10:25 -0800162 .build());
163#endif
164
165 addParameter(
166 DefineParam(mMaxSize, C2_PARAMKEY_MAX_PICTURE_SIZE)
167 .withDefault(new C2StreamMaxPictureSizeTuning::output(0u, 320, 240))
168 .withFields({
169 C2F(mSize, width).inRange(2, 2048, 2),
170 C2F(mSize, height).inRange(2, 2048, 2),
171 })
172 .withSetter(MaxPictureSizeSetter, mSize)
173 .build());
174
175 addParameter(
176 DefineParam(mMaxInputSize, C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE)
Harish Mahendrakare55c4712019-07-26 12:32:13 -0700177 .withDefault(new C2StreamMaxBufferSizeInfo::input(0u, kMinInputBufferSize))
Pawin Vongmasa36653902018-11-15 00:10:25 -0800178 .withFields({
179 C2F(mMaxInputSize, value).any(),
180 })
181 .calculatedAs(MaxInputSizeSetter, mMaxSize)
182 .build());
183
184 C2ChromaOffsetStruct locations[1] = { C2ChromaOffsetStruct::ITU_YUV_420_0() };
185 std::shared_ptr<C2StreamColorInfo::output> defaultColorInfo =
186 C2StreamColorInfo::output::AllocShared(
187 1u, 0u, 8u /* bitDepth */, C2Color::YUV_420);
188 memcpy(defaultColorInfo->m.locations, locations, sizeof(locations));
189
190 defaultColorInfo =
191 C2StreamColorInfo::output::AllocShared(
192 { C2ChromaOffsetStruct::ITU_YUV_420_0() },
193 0u, 8u /* bitDepth */, C2Color::YUV_420);
194 helper->addStructDescriptors<C2ChromaOffsetStruct>();
195
196 addParameter(
197 DefineParam(mColorInfo, C2_PARAMKEY_CODED_COLOR_INFO)
198 .withConstValue(defaultColorInfo)
199 .build());
200
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700201 addParameter(
202 DefineParam(mDefaultColorAspects, C2_PARAMKEY_DEFAULT_COLOR_ASPECTS)
203 .withDefault(new C2StreamColorAspectsTuning::output(
204 0u, C2Color::RANGE_UNSPECIFIED, C2Color::PRIMARIES_UNSPECIFIED,
205 C2Color::TRANSFER_UNSPECIFIED, C2Color::MATRIX_UNSPECIFIED))
206 .withFields({
207 C2F(mDefaultColorAspects, range).inRange(
208 C2Color::RANGE_UNSPECIFIED, C2Color::RANGE_OTHER),
209 C2F(mDefaultColorAspects, primaries).inRange(
210 C2Color::PRIMARIES_UNSPECIFIED, C2Color::PRIMARIES_OTHER),
211 C2F(mDefaultColorAspects, transfer).inRange(
212 C2Color::TRANSFER_UNSPECIFIED, C2Color::TRANSFER_OTHER),
213 C2F(mDefaultColorAspects, matrix).inRange(
214 C2Color::MATRIX_UNSPECIFIED, C2Color::MATRIX_OTHER)
215 })
216 .withSetter(DefaultColorAspectsSetter)
217 .build());
218
Pawin Vongmasa36653902018-11-15 00:10:25 -0800219 // TODO: support more formats?
220 addParameter(
221 DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
222 .withConstValue(new C2StreamPixelFormatInfo::output(
223 0u, HAL_PIXEL_FORMAT_YCBCR_420_888))
224 .build());
225 }
226
227 static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,
Lajos Molnar3bb81cd2019-02-20 15:10:30 -0800228 C2P<C2StreamPictureSizeInfo::output> &me) {
Pawin Vongmasa36653902018-11-15 00:10:25 -0800229 (void)mayBlock;
230 C2R res = C2R::Ok();
231 if (!me.F(me.v.width).supportsAtAll(me.v.width)) {
232 res = res.plus(C2SettingResultBuilder::BadValue(me.F(me.v.width)));
233 me.set().width = oldMe.v.width;
234 }
235 if (!me.F(me.v.height).supportsAtAll(me.v.height)) {
236 res = res.plus(C2SettingResultBuilder::BadValue(me.F(me.v.height)));
237 me.set().height = oldMe.v.height;
238 }
239 return res;
240 }
241
242 static C2R MaxPictureSizeSetter(bool mayBlock, C2P<C2StreamMaxPictureSizeTuning::output> &me,
243 const C2P<C2StreamPictureSizeInfo::output> &size) {
244 (void)mayBlock;
245 // TODO: get max width/height from the size's field helpers vs. hardcoding
246 me.set().width = c2_min(c2_max(me.v.width, size.v.width), 2048u);
247 me.set().height = c2_min(c2_max(me.v.height, size.v.height), 2048u);
248 return C2R::Ok();
249 }
250
251 static C2R MaxInputSizeSetter(bool mayBlock, C2P<C2StreamMaxBufferSizeInfo::input> &me,
252 const C2P<C2StreamMaxPictureSizeTuning::output> &maxSize) {
253 (void)mayBlock;
254 // assume compression ratio of 2
Harish Mahendrakare55c4712019-07-26 12:32:13 -0700255 me.set().value = c2_max((((maxSize.v.width + 63) / 64)
256 * ((maxSize.v.height + 63) / 64) * 3072), kMinInputBufferSize);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800257 return C2R::Ok();
258 }
259
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700260 static C2R DefaultColorAspectsSetter(bool mayBlock, C2P<C2StreamColorAspectsTuning::output> &me) {
261 (void)mayBlock;
262 if (me.v.range > C2Color::RANGE_OTHER) {
263 me.set().range = C2Color::RANGE_OTHER;
264 }
265 if (me.v.primaries > C2Color::PRIMARIES_OTHER) {
266 me.set().primaries = C2Color::PRIMARIES_OTHER;
267 }
268 if (me.v.transfer > C2Color::TRANSFER_OTHER) {
269 me.set().transfer = C2Color::TRANSFER_OTHER;
270 }
271 if (me.v.matrix > C2Color::MATRIX_OTHER) {
272 me.set().matrix = C2Color::MATRIX_OTHER;
273 }
274 return C2R::Ok();
275 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800276
277 static C2R ProfileLevelSetter(bool mayBlock, C2P<C2StreamProfileLevelInfo::input> &me,
278 const C2P<C2StreamPictureSizeInfo::output> &size) {
279 (void)mayBlock;
280 (void)size;
281 (void)me; // TODO: validate
282 return C2R::Ok();
283 }
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700284 std::shared_ptr<C2StreamColorAspectsTuning::output> getDefaultColorAspects_l() {
285 return mDefaultColorAspects;
286 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800287
Pawin Vongmasa8be93112018-12-11 14:01:42 -0800288 static C2R Hdr10PlusInfoInputSetter(bool mayBlock, C2P<C2StreamHdr10PlusInfo::input> &me) {
289 (void)mayBlock;
290 (void)me; // TODO: validate
291 return C2R::Ok();
292 }
293
294 static C2R Hdr10PlusInfoOutputSetter(bool mayBlock, C2P<C2StreamHdr10PlusInfo::output> &me) {
295 (void)mayBlock;
296 (void)me; // TODO: validate
297 return C2R::Ok();
298 }
299
Pawin Vongmasa36653902018-11-15 00:10:25 -0800300private:
301 std::shared_ptr<C2StreamProfileLevelInfo::input> mProfileLevel;
302 std::shared_ptr<C2StreamPictureSizeInfo::output> mSize;
303 std::shared_ptr<C2StreamMaxPictureSizeTuning::output> mMaxSize;
304 std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mMaxInputSize;
305 std::shared_ptr<C2StreamColorInfo::output> mColorInfo;
306 std::shared_ptr<C2StreamPixelFormatInfo::output> mPixelFormat;
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700307 std::shared_ptr<C2StreamColorAspectsTuning::output> mDefaultColorAspects;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800308#ifdef VP9
309#if 0
310 std::shared_ptr<C2StreamHdrStaticInfo::output> mHdrStaticInfo;
311#endif
Pawin Vongmasa8be93112018-12-11 14:01:42 -0800312 std::shared_ptr<C2StreamHdr10PlusInfo::input> mHdr10PlusInfoInput;
313 std::shared_ptr<C2StreamHdr10PlusInfo::output> mHdr10PlusInfoOutput;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800314#endif
315};
316
Wonsik Kimf61206f2019-05-18 16:52:46 -0700317C2SoftVpxDec::ConverterThread::ConverterThread(
318 const std::shared_ptr<Mutexed<ConversionQueue>> &queue)
319 : Thread(false), mQueue(queue) {}
320
321bool C2SoftVpxDec::ConverterThread::threadLoop() {
322 Mutexed<ConversionQueue>::Locked queue(*mQueue);
323 if (queue->entries.empty()) {
324 queue.waitForCondition(queue->cond);
325 if (queue->entries.empty()) {
326 return true;
327 }
328 }
329 std::function<void()> convert = queue->entries.front();
330 queue->entries.pop_front();
331 if (!queue->entries.empty()) {
332 queue->cond.signal();
333 }
334 queue.unlock();
335
336 convert();
337
338 queue.lock();
339 if (--queue->numPending == 0u) {
340 queue->cond.broadcast();
341 }
342 return true;
343}
344
Pawin Vongmasa36653902018-11-15 00:10:25 -0800345C2SoftVpxDec::C2SoftVpxDec(
346 const char *name,
347 c2_node_id_t id,
348 const std::shared_ptr<IntfImpl> &intfImpl)
349 : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)),
350 mIntf(intfImpl),
Wonsik Kimf61206f2019-05-18 16:52:46 -0700351 mCodecCtx(nullptr),
352 mCoreCount(1),
353 mQueue(new Mutexed<ConversionQueue>) {
Pawin Vongmasa36653902018-11-15 00:10:25 -0800354}
355
356C2SoftVpxDec::~C2SoftVpxDec() {
357 onRelease();
358}
359
360c2_status_t C2SoftVpxDec::onInit() {
361 status_t err = initDecoder();
362 return err == OK ? C2_OK : C2_CORRUPTED;
363}
364
365c2_status_t C2SoftVpxDec::onStop() {
366 mSignalledError = false;
367 mSignalledOutputEos = false;
368
369 return C2_OK;
370}
371
372void C2SoftVpxDec::onReset() {
373 (void)onStop();
374 c2_status_t err = onFlush_sm();
375 if (err != C2_OK)
376 {
377 ALOGW("Failed to flush decoder. Try to hard reset decoder");
378 destroyDecoder();
379 (void)initDecoder();
380 }
381}
382
383void C2SoftVpxDec::onRelease() {
384 destroyDecoder();
385}
386
387c2_status_t C2SoftVpxDec::onFlush_sm() {
388 if (mFrameParallelMode) {
389 // Flush decoder by passing nullptr data ptr and 0 size.
390 // Ideally, this should never fail.
391 if (vpx_codec_decode(mCodecCtx, nullptr, 0, nullptr, 0)) {
392 ALOGE("Failed to flush on2 decoder.");
393 return C2_CORRUPTED;
394 }
395 }
396
397 // Drop all the decoded frames in decoder.
398 vpx_codec_iter_t iter = nullptr;
399 while (vpx_codec_get_frame(mCodecCtx, &iter)) {
400 }
401
402 mSignalledError = false;
403 mSignalledOutputEos = false;
404 return C2_OK;
405}
406
407static int GetCPUCoreCount() {
408 int cpuCoreCount = 1;
409#if defined(_SC_NPROCESSORS_ONLN)
410 cpuCoreCount = sysconf(_SC_NPROCESSORS_ONLN);
411#else
412 // _SC_NPROC_ONLN must be defined...
413 cpuCoreCount = sysconf(_SC_NPROC_ONLN);
414#endif
415 CHECK(cpuCoreCount >= 1);
416 ALOGV("Number of CPU cores: %d", cpuCoreCount);
417 return cpuCoreCount;
418}
419
420status_t C2SoftVpxDec::initDecoder() {
421#ifdef VP9
422 mMode = MODE_VP9;
423#else
424 mMode = MODE_VP8;
425#endif
426
427 mWidth = 320;
428 mHeight = 240;
429 mFrameParallelMode = false;
430 mSignalledOutputEos = false;
431 mSignalledError = false;
432
433 if (!mCodecCtx) {
434 mCodecCtx = new vpx_codec_ctx_t;
435 }
436 if (!mCodecCtx) {
437 ALOGE("mCodecCtx is null");
438 return NO_MEMORY;
439 }
440
441 vpx_codec_dec_cfg_t cfg;
442 memset(&cfg, 0, sizeof(vpx_codec_dec_cfg_t));
Wonsik Kimf61206f2019-05-18 16:52:46 -0700443 cfg.threads = mCoreCount = GetCPUCoreCount();
Pawin Vongmasa36653902018-11-15 00:10:25 -0800444
445 vpx_codec_flags_t flags;
446 memset(&flags, 0, sizeof(vpx_codec_flags_t));
447 if (mFrameParallelMode) flags |= VPX_CODEC_USE_FRAME_THREADING;
448
449 vpx_codec_err_t vpx_err;
450 if ((vpx_err = vpx_codec_dec_init(
451 mCodecCtx, mMode == MODE_VP8 ? &vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo,
452 &cfg, flags))) {
453 ALOGE("on2 decoder failed to initialize. (%d)", vpx_err);
454 return UNKNOWN_ERROR;
455 }
456
Wonsik Kimf61206f2019-05-18 16:52:46 -0700457 if (mMode == MODE_VP9) {
458 using namespace std::string_literals;
459 for (int i = 0; i < mCoreCount; ++i) {
460 sp<ConverterThread> thread(new ConverterThread(mQueue));
461 mConverterThreads.push_back(thread);
462 if (thread->run(("vp9conv #"s + std::to_string(i)).c_str(),
463 ANDROID_PRIORITY_AUDIO) != OK) {
464 return UNKNOWN_ERROR;
465 }
466 }
467 }
468
Pawin Vongmasa36653902018-11-15 00:10:25 -0800469 return OK;
470}
471
472status_t C2SoftVpxDec::destroyDecoder() {
473 if (mCodecCtx) {
474 vpx_codec_destroy(mCodecCtx);
475 delete mCodecCtx;
476 mCodecCtx = nullptr;
477 }
Wonsik Kimf61206f2019-05-18 16:52:46 -0700478 bool running = true;
479 for (const sp<ConverterThread> &thread : mConverterThreads) {
480 thread->requestExit();
481 }
482 while (running) {
483 mQueue->lock()->cond.broadcast();
484 running = false;
485 for (const sp<ConverterThread> &thread : mConverterThreads) {
486 if (thread->isRunning()) {
487 running = true;
488 break;
489 }
490 }
491 }
492 mConverterThreads.clear();
Pawin Vongmasa36653902018-11-15 00:10:25 -0800493
494 return OK;
495}
496
497void fillEmptyWork(const std::unique_ptr<C2Work> &work) {
498 uint32_t flags = 0;
499 if (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) {
500 flags |= C2FrameData::FLAG_END_OF_STREAM;
501 ALOGV("signalling eos");
502 }
503 work->worklets.front()->output.flags = (C2FrameData::flags_t)flags;
504 work->worklets.front()->output.buffers.clear();
505 work->worklets.front()->output.ordinal = work->input.ordinal;
506 work->workletsProcessed = 1u;
507}
508
509void C2SoftVpxDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &work,
510 const std::shared_ptr<C2GraphicBlock> &block) {
511 std::shared_ptr<C2Buffer> buffer = createGraphicBuffer(block,
512 C2Rect(mWidth, mHeight));
Pawin Vongmasa8be93112018-12-11 14:01:42 -0800513 auto fillWork = [buffer, index, intf = this->mIntf](
514 const std::unique_ptr<C2Work> &work) {
Pawin Vongmasa36653902018-11-15 00:10:25 -0800515 uint32_t flags = 0;
516 if ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) &&
517 (c2_cntr64_t(index) == work->input.ordinal.frameIndex)) {
518 flags |= C2FrameData::FLAG_END_OF_STREAM;
519 ALOGV("signalling eos");
520 }
521 work->worklets.front()->output.flags = (C2FrameData::flags_t)flags;
522 work->worklets.front()->output.buffers.clear();
523 work->worklets.front()->output.buffers.push_back(buffer);
524 work->worklets.front()->output.ordinal = work->input.ordinal;
525 work->workletsProcessed = 1u;
Pawin Vongmasa8be93112018-12-11 14:01:42 -0800526
527 for (const std::unique_ptr<C2Param> &param: work->input.configUpdate) {
528 if (param) {
529 C2StreamHdr10PlusInfo::input *hdr10PlusInfo =
530 C2StreamHdr10PlusInfo::input::From(param.get());
531
532 if (hdr10PlusInfo != nullptr) {
533 std::vector<std::unique_ptr<C2SettingResult>> failures;
534 std::unique_ptr<C2Param> outParam = C2Param::CopyAsStream(
535 *param.get(), true /*output*/, param->stream());
536 c2_status_t err = intf->config(
537 { outParam.get() }, C2_MAY_BLOCK, &failures);
538 if (err == C2_OK) {
539 work->worklets.front()->output.configUpdate.push_back(
540 C2Param::Copy(*outParam.get()));
541 } else {
542 ALOGE("finishWork: Config update size failed");
543 }
544 break;
545 }
546 }
547 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800548 };
549 if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) {
550 fillWork(work);
551 } else {
552 finish(index, fillWork);
553 }
554}
555
556void C2SoftVpxDec::process(
557 const std::unique_ptr<C2Work> &work,
558 const std::shared_ptr<C2BlockPool> &pool) {
559 // Initialize output work
560 work->result = C2_OK;
561 work->workletsProcessed = 0u;
562 work->worklets.front()->output.configUpdate.clear();
563 work->worklets.front()->output.flags = work->input.flags;
564
565 if (mSignalledError || mSignalledOutputEos) {
566 work->result = C2_BAD_VALUE;
567 return;
568 }
569
570 size_t inOffset = 0u;
571 size_t inSize = 0u;
572 C2ReadView rView = mDummyReadView;
573 if (!work->input.buffers.empty()) {
574 rView = work->input.buffers[0]->data().linearBlocks().front().map().get();
575 inSize = rView.capacity();
576 if (inSize && rView.error()) {
577 ALOGE("read view map failed %d", rView.error());
578 work->result = C2_CORRUPTED;
579 return;
580 }
581 }
582
583 bool codecConfig = ((work->input.flags & C2FrameData::FLAG_CODEC_CONFIG) !=0);
584 bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0);
585
586 ALOGV("in buffer attr. size %zu timestamp %d frameindex %d, flags %x",
587 inSize, (int)work->input.ordinal.timestamp.peeku(),
588 (int)work->input.ordinal.frameIndex.peeku(), work->input.flags);
589
590 // Software VP9 Decoder does not need the Codec Specific Data (CSD)
591 // (specified in http://www.webmproject.org/vp9/profiles/). Ignore it if
592 // it was passed.
593 if (codecConfig) {
594 // Ignore CSD buffer for VP9.
595 if (mMode == MODE_VP9) {
596 fillEmptyWork(work);
597 return;
598 } else {
599 // Tolerate the CSD buffer for VP8. This is a workaround
600 // for b/28689536. continue
601 ALOGW("WARNING: Got CSD buffer for VP8. Continue");
602 }
603 }
604
Pawin Vongmasa36653902018-11-15 00:10:25 -0800605 if (inSize) {
606 uint8_t *bitstream = const_cast<uint8_t *>(rView.data() + inOffset);
607 vpx_codec_err_t err = vpx_codec_decode(
Wonsik Kim377eeab2019-11-03 19:05:59 -0800608 mCodecCtx, bitstream, inSize, &work->input.ordinal.frameIndex, 0);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800609 if (err != VPX_CODEC_OK) {
610 ALOGE("on2 decoder failed to decode frame. err: %d", err);
611 mSignalledError = true;
612 work->workletsProcessed = 1u;
613 work->result = C2_CORRUPTED;
614 return;
615 }
616 }
617
Wonsik Kim377eeab2019-11-03 19:05:59 -0800618 status_t err = outputBuffer(pool, work);
619 if (err == NOT_ENOUGH_DATA) {
620 if (inSize > 0) {
621 ALOGV("Maybe non-display frame at %lld.",
622 work->input.ordinal.frameIndex.peekll());
623 // send the work back with empty buffer.
624 inSize = 0;
625 }
626 } else if (err != OK) {
627 ALOGD("Error while getting the output frame out");
628 // work->result would be already filled; do fillEmptyWork() below to
629 // send the work back.
630 inSize = 0;
631 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800632
633 if (eos) {
634 drainInternal(DRAIN_COMPONENT_WITH_EOS, pool, work);
635 mSignalledOutputEos = true;
636 } else if (!inSize) {
637 fillEmptyWork(work);
638 }
639}
640
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700641static void copyOutputBufferToYuvPlanarFrame(
ming.zhouac19c3d2019-10-11 11:14:07 +0800642 uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
643 const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,
Pawin Vongmasa36653902018-11-15 00:10:25 -0800644 size_t srcYStride, size_t srcUStride, size_t srcVStride,
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700645 size_t dstYStride, size_t dstUVStride,
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700646 uint32_t width, uint32_t height) {
Pawin Vongmasa36653902018-11-15 00:10:25 -0800647
648 for (size_t i = 0; i < height; ++i) {
ming.zhouac19c3d2019-10-11 11:14:07 +0800649 memcpy(dstY, srcY, width);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800650 srcY += srcYStride;
ming.zhouac19c3d2019-10-11 11:14:07 +0800651 dstY += dstYStride;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800652 }
653
Pawin Vongmasa36653902018-11-15 00:10:25 -0800654 for (size_t i = 0; i < height / 2; ++i) {
ming.zhouac19c3d2019-10-11 11:14:07 +0800655 memcpy(dstV, srcV, width / 2);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800656 srcV += srcVStride;
ming.zhouac19c3d2019-10-11 11:14:07 +0800657 dstV += dstUVStride;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800658 }
659
Pawin Vongmasa36653902018-11-15 00:10:25 -0800660 for (size_t i = 0; i < height / 2; ++i) {
ming.zhouac19c3d2019-10-11 11:14:07 +0800661 memcpy(dstU, srcU, width / 2);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800662 srcU += srcUStride;
ming.zhouac19c3d2019-10-11 11:14:07 +0800663 dstU += dstUVStride;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800664 }
ming.zhouac19c3d2019-10-11 11:14:07 +0800665
Pawin Vongmasa36653902018-11-15 00:10:25 -0800666}
667
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700668static void convertYUV420Planar16ToY410(uint32_t *dst,
669 const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
670 size_t srcYStride, size_t srcUStride, size_t srcVStride,
671 size_t dstStride, size_t width, size_t height) {
672
673 // Converting two lines at a time, slightly faster
674 for (size_t y = 0; y < height; y += 2) {
675 uint32_t *dstTop = (uint32_t *) dst;
676 uint32_t *dstBot = (uint32_t *) (dst + dstStride);
677 uint16_t *ySrcTop = (uint16_t*) srcY;
678 uint16_t *ySrcBot = (uint16_t*) (srcY + srcYStride);
679 uint16_t *uSrc = (uint16_t*) srcU;
680 uint16_t *vSrc = (uint16_t*) srcV;
681
682 uint32_t u01, v01, y01, y23, y45, y67, uv0, uv1;
683 size_t x = 0;
684 for (; x < width - 3; x += 4) {
685
686 u01 = *((uint32_t*)uSrc); uSrc += 2;
687 v01 = *((uint32_t*)vSrc); vSrc += 2;
688
689 y01 = *((uint32_t*)ySrcTop); ySrcTop += 2;
690 y23 = *((uint32_t*)ySrcTop); ySrcTop += 2;
691 y45 = *((uint32_t*)ySrcBot); ySrcBot += 2;
692 y67 = *((uint32_t*)ySrcBot); ySrcBot += 2;
693
694 uv0 = (u01 & 0x3FF) | ((v01 & 0x3FF) << 20);
695 uv1 = (u01 >> 16) | ((v01 >> 16) << 20);
696
697 *dstTop++ = 3 << 30 | ((y01 & 0x3FF) << 10) | uv0;
698 *dstTop++ = 3 << 30 | ((y01 >> 16) << 10) | uv0;
699 *dstTop++ = 3 << 30 | ((y23 & 0x3FF) << 10) | uv1;
700 *dstTop++ = 3 << 30 | ((y23 >> 16) << 10) | uv1;
701
702 *dstBot++ = 3 << 30 | ((y45 & 0x3FF) << 10) | uv0;
703 *dstBot++ = 3 << 30 | ((y45 >> 16) << 10) | uv0;
704 *dstBot++ = 3 << 30 | ((y67 & 0x3FF) << 10) | uv1;
705 *dstBot++ = 3 << 30 | ((y67 >> 16) << 10) | uv1;
706 }
707
708 // There should be at most 2 more pixels to process. Note that we don't
709 // need to consider odd case as the buffer is always aligned to even.
710 if (x < width) {
711 u01 = *uSrc;
712 v01 = *vSrc;
713 y01 = *((uint32_t*)ySrcTop);
714 y45 = *((uint32_t*)ySrcBot);
715 uv0 = (u01 & 0x3FF) | ((v01 & 0x3FF) << 20);
716 *dstTop++ = ((y01 & 0x3FF) << 10) | uv0;
717 *dstTop++ = ((y01 >> 16) << 10) | uv0;
718 *dstBot++ = ((y45 & 0x3FF) << 10) | uv0;
719 *dstBot++ = ((y45 >> 16) << 10) | uv0;
720 }
721
722 srcY += srcYStride * 2;
723 srcU += srcUStride;
724 srcV += srcVStride;
725 dst += dstStride * 2;
726 }
727
728 return;
729}
730
ming.zhouac19c3d2019-10-11 11:14:07 +0800731static void convertYUV420Planar16ToYUV420Planar(
732 uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700733 const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
734 size_t srcYStride, size_t srcUStride, size_t srcVStride,
ming.zhouac19c3d2019-10-11 11:14:07 +0800735 size_t dstYStride, size_t dstUVStride,
736 size_t width, size_t height) {
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700737
738 for (size_t y = 0; y < height; ++y) {
739 for (size_t x = 0; x < width; ++x) {
740 dstY[x] = (uint8_t)(srcY[x] >> 2);
741 }
742
743 srcY += srcYStride;
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700744 dstY += dstYStride;
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700745 }
746
747 for (size_t y = 0; y < (height + 1) / 2; ++y) {
748 for (size_t x = 0; x < (width + 1) / 2; ++x) {
749 dstU[x] = (uint8_t)(srcU[x] >> 2);
750 dstV[x] = (uint8_t)(srcV[x] >> 2);
751 }
752
753 srcU += srcUStride;
754 srcV += srcVStride;
755 dstU += dstUVStride;
756 dstV += dstUVStride;
757 }
758 return;
759}
Wonsik Kim377eeab2019-11-03 19:05:59 -0800760status_t C2SoftVpxDec::outputBuffer(
Pawin Vongmasa36653902018-11-15 00:10:25 -0800761 const std::shared_ptr<C2BlockPool> &pool,
762 const std::unique_ptr<C2Work> &work)
763{
Wonsik Kim377eeab2019-11-03 19:05:59 -0800764 if (!(work && pool)) return BAD_VALUE;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800765
766 vpx_codec_iter_t iter = nullptr;
767 vpx_image_t *img = vpx_codec_get_frame(mCodecCtx, &iter);
768
Wonsik Kim377eeab2019-11-03 19:05:59 -0800769 if (!img) return NOT_ENOUGH_DATA;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800770
771 if (img->d_w != mWidth || img->d_h != mHeight) {
772 mWidth = img->d_w;
773 mHeight = img->d_h;
774
Lajos Molnar3bb81cd2019-02-20 15:10:30 -0800775 C2StreamPictureSizeInfo::output size(0u, mWidth, mHeight);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800776 std::vector<std::unique_ptr<C2SettingResult>> failures;
777 c2_status_t err = mIntf->config({&size}, C2_MAY_BLOCK, &failures);
778 if (err == C2_OK) {
779 work->worklets.front()->output.configUpdate.push_back(
780 C2Param::Copy(size));
781 } else {
782 ALOGE("Config update size failed");
783 mSignalledError = true;
784 work->workletsProcessed = 1u;
785 work->result = C2_CORRUPTED;
Wonsik Kim377eeab2019-11-03 19:05:59 -0800786 return UNKNOWN_ERROR;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800787 }
788
789 }
Harish Mahendrakar3fdfaa32019-08-02 15:44:30 -0700790 if(img->fmt != VPX_IMG_FMT_I420 && img->fmt != VPX_IMG_FMT_I42016) {
791 ALOGE("img->fmt %d not supported", img->fmt);
792 mSignalledError = true;
793 work->workletsProcessed = 1u;
794 work->result = C2_CORRUPTED;
795 return false;
796 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800797
798 std::shared_ptr<C2GraphicBlock> block;
799 uint32_t format = HAL_PIXEL_FORMAT_YV12;
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700800 if (img->fmt == VPX_IMG_FMT_I42016) {
801 IntfImpl::Lock lock = mIntf->lock();
802 std::shared_ptr<C2StreamColorAspectsTuning::output> defaultColorAspects = mIntf->getDefaultColorAspects_l();
803
804 if (defaultColorAspects->primaries == C2Color::PRIMARIES_BT2020 &&
805 defaultColorAspects->matrix == C2Color::MATRIX_BT2020 &&
806 defaultColorAspects->transfer == C2Color::TRANSFER_ST2084) {
807 format = HAL_PIXEL_FORMAT_RGBA_1010102;
808 }
809 }
Pawin Vongmasa36653902018-11-15 00:10:25 -0800810 C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700811 c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block);
Pawin Vongmasa36653902018-11-15 00:10:25 -0800812 if (err != C2_OK) {
813 ALOGE("fetchGraphicBlock for Output failed with status %d", err);
814 work->result = err;
Wonsik Kim377eeab2019-11-03 19:05:59 -0800815 return UNKNOWN_ERROR;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800816 }
817
818 C2GraphicView wView = block->map().get();
819 if (wView.error()) {
820 ALOGE("graphic view map failed %d", wView.error());
821 work->result = C2_CORRUPTED;
Wonsik Kim377eeab2019-11-03 19:05:59 -0800822 return UNKNOWN_ERROR;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800823 }
824
Wonsik Kim377eeab2019-11-03 19:05:59 -0800825 ALOGV("provided (%dx%d) required (%dx%d), out frameindex %lld",
826 block->width(), block->height(), mWidth, mHeight,
827 ((c2_cntr64_t *)img->user_priv)->peekll());
Pawin Vongmasa36653902018-11-15 00:10:25 -0800828
ming.zhouac19c3d2019-10-11 11:14:07 +0800829 uint8_t *dstY = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]);
830 uint8_t *dstU = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_U]);
831 uint8_t *dstV = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_V]);
832
Pawin Vongmasa36653902018-11-15 00:10:25 -0800833 size_t srcYStride = img->stride[VPX_PLANE_Y];
834 size_t srcUStride = img->stride[VPX_PLANE_U];
835 size_t srcVStride = img->stride[VPX_PLANE_V];
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700836 C2PlanarLayout layout = wView.layout();
837 size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
838 size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800839
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700840 if (img->fmt == VPX_IMG_FMT_I42016) {
841 const uint16_t *srcY = (const uint16_t *)img->planes[VPX_PLANE_Y];
842 const uint16_t *srcU = (const uint16_t *)img->planes[VPX_PLANE_U];
843 const uint16_t *srcV = (const uint16_t *)img->planes[VPX_PLANE_V];
844
845 if (format == HAL_PIXEL_FORMAT_RGBA_1010102) {
Wonsik Kimf61206f2019-05-18 16:52:46 -0700846 Mutexed<ConversionQueue>::Locked queue(*mQueue);
847 size_t i = 0;
848 constexpr size_t kHeight = 64;
849 for (; i < mHeight; i += kHeight) {
850 queue->entries.push_back(
ming.zhouac19c3d2019-10-11 11:14:07 +0800851 [dstY, srcY, srcU, srcV,
Wonsik Kimf61206f2019-05-18 16:52:46 -0700852 srcYStride, srcUStride, srcVStride, dstYStride,
853 width = mWidth, height = std::min(mHeight - i, kHeight)] {
854 convertYUV420Planar16ToY410(
ming.zhouac19c3d2019-10-11 11:14:07 +0800855 (uint32_t *)dstY, srcY, srcU, srcV, srcYStride / 2,
Wonsik Kimf61206f2019-05-18 16:52:46 -0700856 srcUStride / 2, srcVStride / 2, dstYStride / sizeof(uint32_t),
857 width, height);
858 });
859 srcY += srcYStride / 2 * kHeight;
860 srcU += srcUStride / 2 * (kHeight / 2);
861 srcV += srcVStride / 2 * (kHeight / 2);
ming.zhouac19c3d2019-10-11 11:14:07 +0800862 dstY += dstYStride * kHeight;
Wonsik Kimf61206f2019-05-18 16:52:46 -0700863 }
864 CHECK_EQ(0u, queue->numPending);
865 queue->numPending = queue->entries.size();
866 while (queue->numPending > 0) {
867 queue->cond.signal();
868 queue.waitForCondition(queue->cond);
869 }
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700870 } else {
ming.zhouac19c3d2019-10-11 11:14:07 +0800871 convertYUV420Planar16ToYUV420Planar(dstY, dstU, dstV,
872 srcY, srcU, srcV,
873 srcYStride / 2, srcUStride / 2, srcVStride / 2,
Wonsik Kimf61206f2019-05-18 16:52:46 -0700874 dstYStride, dstUVStride,
875 mWidth, mHeight);
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700876 }
877 } else {
878 const uint8_t *srcY = (const uint8_t *)img->planes[VPX_PLANE_Y];
879 const uint8_t *srcU = (const uint8_t *)img->planes[VPX_PLANE_U];
880 const uint8_t *srcV = (const uint8_t *)img->planes[VPX_PLANE_V];
ming.zhouac19c3d2019-10-11 11:14:07 +0800881
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700882 copyOutputBufferToYuvPlanarFrame(
ming.zhouac19c3d2019-10-11 11:14:07 +0800883 dstY, dstU, dstV,
884 srcY, srcU, srcV,
Harish Mahendrakardfa3f5a2019-05-02 12:10:24 -0700885 srcYStride, srcUStride, srcVStride,
886 dstYStride, dstUVStride,
887 mWidth, mHeight);
Harish Mahendrakared4e0cd2018-10-11 18:11:49 -0700888 }
Wonsik Kim377eeab2019-11-03 19:05:59 -0800889 finishWork(((c2_cntr64_t *)img->user_priv)->peekull(), work, std::move(block));
890 return OK;
Pawin Vongmasa36653902018-11-15 00:10:25 -0800891}
892
893c2_status_t C2SoftVpxDec::drainInternal(
894 uint32_t drainMode,
895 const std::shared_ptr<C2BlockPool> &pool,
896 const std::unique_ptr<C2Work> &work) {
897 if (drainMode == NO_DRAIN) {
898 ALOGW("drain with NO_DRAIN: no-op");
899 return C2_OK;
900 }
901 if (drainMode == DRAIN_CHAIN) {
902 ALOGW("DRAIN_CHAIN not supported");
903 return C2_OMITTED;
904 }
905
Wonsik Kim377eeab2019-11-03 19:05:59 -0800906 while (outputBuffer(pool, work) == OK) {
Pawin Vongmasa36653902018-11-15 00:10:25 -0800907 }
908
909 if (drainMode == DRAIN_COMPONENT_WITH_EOS &&
910 work && work->workletsProcessed == 0u) {
911 fillEmptyWork(work);
912 }
913
914 return C2_OK;
915}
916c2_status_t C2SoftVpxDec::drain(
917 uint32_t drainMode,
918 const std::shared_ptr<C2BlockPool> &pool) {
919 return drainInternal(drainMode, pool, nullptr);
920}
921
922class C2SoftVpxFactory : public C2ComponentFactory {
923public:
924 C2SoftVpxFactory() : mHelper(std::static_pointer_cast<C2ReflectorHelper>(
925 GetCodec2PlatformComponentStore()->getParamReflector())) {
926 }
927
928 virtual c2_status_t createComponent(
929 c2_node_id_t id,
930 std::shared_ptr<C2Component>* const component,
931 std::function<void(C2Component*)> deleter) override {
932 *component = std::shared_ptr<C2Component>(
933 new C2SoftVpxDec(COMPONENT_NAME, id,
934 std::make_shared<C2SoftVpxDec::IntfImpl>(mHelper)),
935 deleter);
936 return C2_OK;
937 }
938
939 virtual c2_status_t createInterface(
940 c2_node_id_t id,
941 std::shared_ptr<C2ComponentInterface>* const interface,
942 std::function<void(C2ComponentInterface*)> deleter) override {
943 *interface = std::shared_ptr<C2ComponentInterface>(
944 new SimpleInterface<C2SoftVpxDec::IntfImpl>(
945 COMPONENT_NAME, id,
946 std::make_shared<C2SoftVpxDec::IntfImpl>(mHelper)),
947 deleter);
948 return C2_OK;
949 }
950
951 virtual ~C2SoftVpxFactory() override = default;
952
953private:
954 std::shared_ptr<C2ReflectorHelper> mHelper;
955};
956
957} // namespace android
958
Cindy Zhouf6c0c3c2020-12-02 10:53:40 -0800959__attribute__((cfi_canonical_jump_table))
Pawin Vongmasa36653902018-11-15 00:10:25 -0800960extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
961 ALOGV("in %s", __func__);
962 return new ::android::C2SoftVpxFactory();
963}
964
Cindy Zhouf6c0c3c2020-12-02 10:53:40 -0800965__attribute__((cfi_canonical_jump_table))
Pawin Vongmasa36653902018-11-15 00:10:25 -0800966extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
967 ALOGV("in %s", __func__);
968 delete factory;
969}