summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaripriya Deshmukh <haripriya.deshmukh@ittiam.com>2023-08-14 16:12:37 +0530
committerCherrypicker Worker <android-build-cherrypicker-worker@google.com>2023-12-12 20:54:17 +0000
commit58d5debefe822f890b2ead71adfbfbb97b163b7e (patch)
tree8a19aff0c1fb2333d85304195aae73f0596a1390
parent3f2a54f23d55cc1132bbf1576f8b302a0c302e20 (diff)
downloadav-58d5debefe822f890b2ead71adfbfbb97b163b7e.tar.gz
C2SoftDav1dDec: Replace memcpy with dav1d_data_wrap
Bug: 286852962 Test: atest android.mediav2.cts.CodecDecoderTest (cherry picked from https://android-review.googlesource.com/q/commit:6c41740db9d5ccdba95885c8d56558e66ba7c418) Merged-In: Ifa5324e2b5f9e86bbb10dd1fe3cc60552e1236f0 Change-Id: Ifa5324e2b5f9e86bbb10dd1fe3cc60552e1236f0
-rw-r--r--media/codec2/components/dav1d/C2SoftDav1dDec.cpp38
1 files changed, 9 insertions, 29 deletions
diff --git a/media/codec2/components/dav1d/C2SoftDav1dDec.cpp b/media/codec2/components/dav1d/C2SoftDav1dDec.cpp
index f5112f0b6e..3f96cb3ad0 100644
--- a/media/codec2/components/dav1d/C2SoftDav1dDec.cpp
+++ b/media/codec2/components/dav1d/C2SoftDav1dDec.cpp
@@ -598,6 +598,10 @@ void C2SoftDav1dDec::finishWork(uint64_t index, const std::unique_ptr<C2Work>& w
}
}
+static void freeCallback(const uint8_t */*data*/, void */*cookie*/) {
+ return;
+}
+
void C2SoftDav1dDec::process(const std::unique_ptr<C2Work>& work,
const std::shared_ptr<C2BlockPool>& pool) {
work->result = C2_OK;
@@ -650,40 +654,17 @@ void C2SoftDav1dDec::process(const std::unique_ptr<C2Work>& work,
seq.max_height, (long)in_frameIndex);
}
- // insert OBU TD if it is not present.
- // TODO: b/286852962
- uint8_t obu_type = (bitstream[0] >> 3) & 0xf;
Dav1dData data;
- uint8_t* ptr = (obu_type == DAV1D_OBU_TD) ? dav1d_data_create(&data, inSize)
- : dav1d_data_create(&data, inSize + 2);
- if (ptr == nullptr) {
- ALOGE("dav1d_data_create failed!");
+ res = dav1d_data_wrap(&data, bitstream, inSize, freeCallback, nullptr);
+ if (res != 0) {
+ ALOGE("Decoder wrap error %s!", strerror(DAV1D_ERR(res)));
i_ret = -1;
-
} else {
data.m.timestamp = in_frameIndex;
+ // ALOGV("inSize=%ld, in_frameIndex=%ld, timestamp=%ld",
+ // inSize, frameIndex, data.m.timestamp);
- int new_Size;
- if (obu_type != DAV1D_OBU_TD) {
- new_Size = (int)(inSize + 2);
-
- // OBU TD
- ptr[0] = 0x12;
- ptr[1] = 0;
-
- memcpy(ptr + 2, bitstream, inSize);
- } else {
- new_Size = (int)(inSize);
- // TODO: b/277797541 - investigate how to wrap this pointer in Dav1dData to
- // avoid memcopy operations.
- memcpy(ptr, bitstream, new_Size);
- }
-
- // ALOGV("memcpy(ptr,bitstream,inSize=%ld,new_Size=%d,in_frameIndex=%ld,timestamp=%ld,"
- // "ptr[0,1,2,3,4]=%x,%x,%x,%x,%x)",
- // inSize, new_Size, frameIndex, data.m.timestamp, ptr[0], ptr[1], ptr[2],
- // ptr[3], ptr[4]);
// Dump the bitstream data (inputBuffer) if dumping is enabled.
#ifdef FILE_DUMP_ENABLE
@@ -691,7 +672,6 @@ void C2SoftDav1dDec::process(const std::unique_ptr<C2Work>& work,
#endif
bool b_draining = false;
- int res;
do {
res = dav1d_send_data(mDav1dCtx, &data);