File: frame_dumping_decoder.cc

package info (click to toggle)
qtwebengine-opensource-src 5.15.19%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,115,148 kB
  • sloc: cpp: 13,170,464; ansic: 4,254,581; javascript: 1,917,440; python: 554,859; asm: 532,901; xml: 496,623; java: 151,702; objc: 80,776; perl: 73,361; sh: 71,244; cs: 30,383; makefile: 21,992; yacc: 9,125; tcl: 8,500; php: 5,896; sql: 5,518; pascal: 4,510; lex: 2,884; lisp: 2,727; ruby: 559; awk: 200; sed: 40
file content (93 lines) | stat: -rw-r--r-- 3,141 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 *  Copyright (c) 2018 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.
 */

#include "video/frame_dumping_decoder.h"

#include <memory>
#include <utility>

#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/utility/ivf_file_writer.h"

namespace webrtc {
namespace {

class FrameDumpingDecoder : public VideoDecoder {
 public:
  FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, FileWrapper file);
  ~FrameDumpingDecoder() override;

  int32_t InitDecode(const VideoCodec* codec_settings,
                     int32_t number_of_cores) override;
  int32_t Decode(const EncodedImage& input_image,
                 bool missing_frames,
                 int64_t render_time_ms) override;
  int32_t RegisterDecodeCompleteCallback(
      DecodedImageCallback* callback) override;
  int32_t Release() override;
  bool PrefersLateDecoding() const override;
  const char* ImplementationName() const override;

 private:
  std::unique_ptr<VideoDecoder> decoder_;
  VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
  std::unique_ptr<IvfFileWriter> writer_;
};

FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder,
                                         FileWrapper file)
    : decoder_(std::move(decoder)),
      writer_(IvfFileWriter::Wrap(std::move(file),
                                  /* byte_limit= */ 100000000)) {}

FrameDumpingDecoder::~FrameDumpingDecoder() = default;

int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings,
                                        int32_t number_of_cores) {
  codec_type_ = codec_settings->codecType;
  return decoder_->InitDecode(codec_settings, number_of_cores);
}

int32_t FrameDumpingDecoder::Decode(const EncodedImage& input_image,
                                    bool missing_frames,
                                    int64_t render_time_ms) {
  int32_t ret = decoder_->Decode(input_image, missing_frames, render_time_ms);
  writer_->WriteFrame(input_image, codec_type_);

  return ret;
}

int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback(
    DecodedImageCallback* callback) {
  return decoder_->RegisterDecodeCompleteCallback(callback);
}

int32_t FrameDumpingDecoder::Release() {
  return decoder_->Release();
}

bool FrameDumpingDecoder::PrefersLateDecoding() const {
  return decoder_->PrefersLateDecoding();
}

const char* FrameDumpingDecoder::ImplementationName() const {
  return decoder_->ImplementationName();
}

}  // namespace

std::unique_ptr<VideoDecoder> CreateFrameDumpingDecoderWrapper(
    std::unique_ptr<VideoDecoder> decoder,
    FileWrapper file) {
  return std::make_unique<FrameDumpingDecoder>(std::move(decoder),
                                               std::move(file));
}

}  // namespace webrtc