CCodec: fix image data update handling

Formats should not be written after it's shared with the client. When
update is needed, duplicate the format to avoid race condition.

Bug: 122987730
Test: run MediaMetadataRetrieverTest#testGetFramesAtIndex for 1000 times
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: I6abb5526d8df1e57b70c96f5b32d132e4a5de389
3 files changed