diff --git a/media/formats/mp4/avc_unittest.cc b/media/formats/mp4/avc_unittest.cc
index 671b0695cb7b5..8f4574657579c 100644
--- a/media/formats/mp4/avc_unittest.cc
+++ b/media/formats/mp4/avc_unittest.cc
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
-#pragma allow_unsafe_buffers
-#endif
+#include "base/containers/auto_spanification_helper.h"
+#include "base/containers/span.h"
+
+
 
 #include "media/formats/mp4/avc.h"
 
@@ -143,10 +143,10 @@ class AVCConversionTest : public testing::TestWithParam<int> {
     buf->clear();
 
     WriteLength(length_size, sizeof(kNALU1), buf);
-    buf->insert(buf->end(), kNALU1, kNALU1 + sizeof(kNALU1));
+    buf->insert(buf->end(), std::begin(kNALU1), std::end(kNALU1));
 
     WriteLength(length_size, sizeof(kNALU2), buf);
-    buf->insert(buf->end(), kNALU2, kNALU2 + sizeof(kNALU2));
+    buf->insert(buf->end(), std::begin(kNALU2), std::end(kNALU2));
   }
 
 };
@@ -165,7 +165,7 @@ TEST_P(AVCConversionTest, ParseCorrectly) {
                expected);
 
   EXPECT_EQ(buf.size(), sizeof(kExpected));
-  EXPECT_EQ(0, memcmp(kExpected, &buf[0], sizeof(kExpected)));
+  EXPECT_TRUE(std::equal(std::begin(kExpected), std::end(kExpected), buf.begin()));
   EXPECT_EQ("P,SDC", AnnexBToString(buf, subsamples));
 }
 
@@ -173,7 +173,7 @@ TEST_P(AVCConversionTest, ParseCorrectly) {
 TEST_P(AVCConversionTest, NALUSizeTooLarge) {
   std::vector<uint8_t> buf;
   WriteLength(GetParam(), 10 * sizeof(kNALU1), &buf);
-  buf.insert(buf.end(), kNALU1, kNALU1 + sizeof(kNALU1));
+  buf.insert(buf.end(), std::begin(kNALU1), std::end(kNALU1));
   EXPECT_FALSE(AVC::ConvertFrameToAnnexB(GetParam(), &buf, nullptr));
 }
 
@@ -182,12 +182,12 @@ TEST_P(AVCConversionTest, NALUSizeIsZero) {
   WriteLength(GetParam(), 0, &buf);
 
   WriteLength(GetParam(), sizeof(kNALU1), &buf);
-  buf.insert(buf.end(), kNALU1, kNALU1 + sizeof(kNALU1));
+  buf.insert(buf.end(), std::begin(kNALU1), std::end(kNALU1));
 
   WriteLength(GetParam(), 0, &buf);
 
   WriteLength(GetParam(), sizeof(kNALU2), &buf);
-  buf.insert(buf.end(), kNALU2, kNALU2 + sizeof(kNALU2));
+  buf.insert(buf.end(), std::begin(kNALU2), std::end(kNALU2));
 
   EXPECT_FALSE(AVC::ConvertFrameToAnnexB(GetParam(), &buf, nullptr));
 }
@@ -199,7 +199,7 @@ TEST_P(AVCConversionTest, SubsampleSizesUpdatedAfterAnnexBConversion) {
 
   // Write the first subsample, consisting of only one NALU
   WriteLength(GetParam(), sizeof(kNALU1), &buf);
-  buf.insert(buf.end(), kNALU1, kNALU1 + sizeof(kNALU1));
+  buf.insert(buf.end(), std::begin(kNALU1), std::end(kNALU1));
 
   subsample.clear_bytes = GetParam() + sizeof(kNALU1);
   subsample.cypher_bytes = 0;
@@ -207,9 +207,9 @@ TEST_P(AVCConversionTest, SubsampleSizesUpdatedAfterAnnexBConversion) {
 
   // Write the second subsample, containing two NALUs
   WriteLength(GetParam(), sizeof(kNALU1), &buf);
-  buf.insert(buf.end(), kNALU1, kNALU1 + sizeof(kNALU1));
+  buf.insert(buf.end(), std::begin(kNALU1), std::end(kNALU1));
   WriteLength(GetParam(), sizeof(kNALU2), &buf);
-  buf.insert(buf.end(), kNALU2, kNALU2 + sizeof(kNALU2));
+  buf.insert(buf.end(), std::begin(kNALU2), std::end(kNALU2));
 
   subsample.clear_bytes = 2*GetParam() + sizeof(kNALU1) + sizeof(kNALU2);
   subsample.cypher_bytes = 0;
@@ -271,8 +271,8 @@ TEST_F(AVCConversionTest, ConvertConfigToAnnexB) {
   std::vector<uint8_t> buf;
   std::vector<SubsampleEntry> subsamples;
   EXPECT_TRUE(AVC::ConvertConfigToAnnexB(avc_config, &buf));
-  EXPECT_EQ(0, memcmp(kExpectedParamSets, &buf[0],
-                      sizeof(kExpectedParamSets)));
+  EXPECT_TRUE(std::equal(std::begin(kExpectedParamSets),
+                      std::end(kExpectedParamSets), buf.begin()));
   EXPECT_EQ("SPS,SPS,PPS", AnnexBToString(buf, subsamples));
 }
 
@@ -299,7 +299,7 @@ TEST_F(AVCConversionTest, ValidAnnexBConstructs) {
     const char* case_string;
     const bool is_keyframe;
   };
-  auto test_cases = std::to_array<TestCases>({
+  static const TestCases test_cases[] = {
       {"I", true},
       {"I I I I", true},
       {"AUD I", true},
@@ -326,20 +326,20 @@ TEST_F(AVCConversionTest, ValidAnnexBConstructs) {
       {"SDA I", false},
       {"SDB I", false},
       {"SDC I", false},
-  });
+  };
 
-  for (size_t i = 0; i < std::size(test_cases); ++i) {
+  for (const auto& test_case : test_cases) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
-    AvcStringToAnnexB(test_cases[i].case_string, &buf, nullptr);
+    AvcStringToAnnexB(test_case.case_string, &buf, nullptr);
 
     BitstreamConverter::AnalysisResult expected;
     expected.is_conformant = true;
-    expected.is_keyframe = test_cases[i].is_keyframe;
+    expected.is_keyframe = test_case.is_keyframe;
     EXPECT_PRED2(AnalysesMatch,
                  AVC::AnalyzeAnnexB(buf.data(), buf.size(), subsamples),
                  expected)
-        << "'" << test_cases[i].case_string << "' failed";
+        << "'" << test_case.case_string << "' failed";
   }
 }
 
@@ -356,7 +356,7 @@ TEST_F(AVCConversionTest, InvalidAnnexBConstructs) {
     const char* case_string;
     const std::optional<bool> is_keyframe;
   };
-  auto test_cases = std::to_array<TestCases>({
+  static const TestCases test_cases[] = {
       // For these cases, lack of conformance is determined before detecting any
       // IDR or non-IDR slices, so the non-conformant frames' keyframe analysis
       // reports std::nullopt (which means undetermined analysis result).
@@ -380,20 +380,20 @@ TEST_F(AVCConversionTest, InvalidAnnexBConstructs) {
       // failure, so the non-conformant frame is reported as a non-keyframe.
       {"P SPS P",
        false},  // SPS after first VCL would indicate a new access unit.
-  });
+  };
 
   BitstreamConverter::AnalysisResult expected;
   expected.is_conformant = false;
 
-  for (size_t i = 0; i < std::size(test_cases); ++i) {
+  for (const auto& test_case : test_cases) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
-    AvcStringToAnnexB(test_cases[i].case_string, &buf, nullptr);
-    expected.is_keyframe = test_cases[i].is_keyframe;
+    AvcStringToAnnexB(test_case.case_string, &buf, nullptr);
+    expected.is_keyframe = test_case.is_keyframe;
     EXPECT_PRED2(AnalysesMatch,
                  AVC::AnalyzeAnnexB(buf.data(), buf.size(), subsamples),
                  expected)
-        << "'" << test_cases[i].case_string << "' failed";
+        << "'" << test_case.case_string << "' failed";
   }
 }
 
@@ -433,20 +433,20 @@ TEST_F(AVCConversionTest, InsertParamSetsAnnexB) {
   expected.is_conformant = true;
   expected.is_keyframe = true;
 
-  for (size_t i = 0; i < std::size(test_cases); ++i) {
+  for (const auto& test_case : test_cases) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
 
-    AvcStringToAnnexB(test_cases[i].input, &buf, &subsamples);
+    AvcStringToAnnexB(test_case.input, &buf, &subsamples);
 
     EXPECT_TRUE(AVC::InsertParamSetsAnnexB(avc_config, &buf, &subsamples))
-        << "'" << test_cases[i].input << "' insert failed.";
+        << "'" << test_case.input << "' insert failed.";
     EXPECT_PRED2(AnalysesMatch,
                  AVC::AnalyzeAnnexB(buf.data(), buf.size(), subsamples),
                  expected)
-        << "'" << test_cases[i].input << "' created invalid AnnexB.";
-    EXPECT_EQ(test_cases[i].expected, AnnexBToString(buf, subsamples))
-        << "'" << test_cases[i].input << "' generated unexpected output.";
+        << "'" << test_case.input << "' created invalid AnnexB.";
+    EXPECT_EQ(test_case.expected, AnnexBToString(buf, subsamples))
+        << "'" << test_case.input << "' generated unexpected output.";
   }
 }
 
