C2SoftDav1dDec: Fix performance issues in frame parallel multi-threading

- dav1d_get_picture() was called more than necessary and that
 was leading to some performance issues. This is now cleaned up
 and this exposed few issues in how hdr metadata was being signalled
 in the current implementation.

- The HDR metadata was not getting associated to the picture being
 returned and was instead associated to the picture that was decoded.
 In case of frame parallel design, these two aren't necessarily the
 same. This is now fixed by associating metadata to the appropriate
 picture.

- Set max_frame_delay to 4 instead of letting the decoder pick a
 value. This is done to ensure max_frame_delay remains same across
 different device configurations, irrespective of number of cores.

Bug: 315828433
Test: atest CtsMediaDecoderTestCases:VideoDecoderPerfTest#testPerf \
-- --module-arg CtsMediaDecoderTestCases:instrumentation-arg:\
codec-prefix:=c2.android.av1
Test: atest CtsMediaV2TestCases -- --module-arg CtsMediaV2TestCases:\
instrumentation-arg:codec-prefix:=c2.android.av1

Change-Id: Ic2b0e15fb9aab31d293edcdd641f446d59480ab6
diff --git a/media/codec2/components/dav1d/C2SoftDav1dDec.h b/media/codec2/components/dav1d/C2SoftDav1dDec.h
index e3d2a93..5d2a725 100644
--- a/media/codec2/components/dav1d/C2SoftDav1dDec.h
+++ b/media/codec2/components/dav1d/C2SoftDav1dDec.h
@@ -58,7 +58,6 @@
     int mOutputBufferIndex = 0;
 
     Dav1dContext* mDav1dCtx = nullptr;
-    std::deque<Dav1dPicture> mDecodedPictures;
 
     // configurations used by component in process
     // (TODO: keep this in intf but make them internal only)
@@ -101,12 +100,13 @@
     nsecs_t mTimeEnd = 0;    // Time at the end of decode()
 
     bool initDecoder();
-    void getHDRStaticParams(Dav1dPicture* picture, const std::unique_ptr<C2Work>& work);
-    void getHDR10PlusInfoData(Dav1dPicture* picture, const std::unique_ptr<C2Work>& work);
-    void getVuiParams(Dav1dPicture* picture);
+    void getHDRStaticParams(const Dav1dPicture* picture, const std::unique_ptr<C2Work>& work);
+    void getHDR10PlusInfoData(const Dav1dPicture* picture, const std::unique_ptr<C2Work>& work);
+    void getVuiParams(const Dav1dPicture* picture);
     void destroyDecoder();
     void finishWork(uint64_t index, const std::unique_ptr<C2Work>& work,
-                    const std::shared_ptr<C2GraphicBlock>& block);
+                    const std::shared_ptr<C2GraphicBlock>& block,
+                    const Dav1dPicture &img);
     // Sets |work->result| and mSignalledError. Returns false.
     void setError(const std::unique_ptr<C2Work>& work, c2_status_t error);
     bool allocTmpFrameBuffer(size_t size);