Add file based decoder, which decodes an encoded video file to a Y4M file.
This is a preparation to be able to use FFmpeg and hence, the hardware encoder and decoders.
Bug: webrtc:358039777
Change-Id: I07c832b80fd5ce98a5871f36357ea87b1352c100
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398101
Reviewed-by: Fanny Linderborg <linderborg@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Fanny Linderborg <linderborg@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45125}
diff --git a/video/corruption_detection/evaluation/BUILD.gn b/video/corruption_detection/evaluation/BUILD.gn
index 76b3117..c0a1277 100644
--- a/video/corruption_detection/evaluation/BUILD.gn
+++ b/video/corruption_detection/evaluation/BUILD.gn
@@ -8,6 +8,12 @@
import("../../../webrtc.gni")
+rtc_library("file_based_decoder") {
+ testonly = true
+ sources = [ "file_based_decoder.h" ]
+ deps = [ "//third_party/abseil-cpp/absl/strings:string_view" ]
+}
+
rtc_library("file_based_encoder") {
testonly = true
sources = [ "file_based_encoder.h" ]
diff --git a/video/corruption_detection/evaluation/file_based_decoder.h b/video/corruption_detection/evaluation/file_based_decoder.h
new file mode 100644
index 0000000..2a7dab5
--- /dev/null
+++ b/video/corruption_detection/evaluation/file_based_decoder.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2025 The WebRTC project authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_
+#define VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+
+namespace webrtc {
+
+// Decodes the video given in `encoded_file_path` if possible. The user cannot
+// reach the individual frames. However, the user should be able to reach the
+// decoded file from the decoded file path returned by `Decode` if successful.
+// The decoded file is in Y4M format.
+class FileBasedDecoder {
+ public:
+ FileBasedDecoder() = default;
+ virtual ~FileBasedDecoder() = default;
+
+ // Decodes the encoded file at `encoded_file_path` to a Y4M file. Returns the
+ // path to the decoded file if successful.
+ virtual std::string Decode(absl::string_view encoded_file_path) = 0;
+};
+
+} // namespace webrtc
+
+#endif // VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_