summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/v4l2/v4l2_stateful_workaround.h
blob: d01e9c9b747c8b85a954e49d4af0db52646700fa (plain)
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
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_GPU_V4L2_V4L2_STATEFUL_WORKAROUND_H_
#define MEDIA_GPU_V4L2_V4L2_STATEFUL_WORKAROUND_H_

#include <memory>
#include <vector>

#include "media/base/video_types.h"
#include "media/gpu/v4l2/v4l2_device.h"

namespace media {

// TODO(hiroh): Remove this class once V4L2VideoDecodeAccelerator is removed.
class V4L2StatefulWorkaround {
 public:
  enum class Result {
    Success,      // The workaround is successfully applied.
    NotifyError,  // The caller must notify an error for Chrome. For example,
                  // VDA will call NotifyError() if this is returned.
  };

  V4L2StatefulWorkaround(const V4L2StatefulWorkaround&) = delete;
  V4L2StatefulWorkaround& operator=(const V4L2StatefulWorkaround&) = delete;

  virtual ~V4L2StatefulWorkaround() = default;

  // Apply the workaround.
  virtual Result Apply(const uint8_t* data, size_t size) = 0;

 protected:
  V4L2StatefulWorkaround() = default;
};

// Create necessary workarounds on the device for |device_type| and |profile|.
std::vector<std::unique_ptr<V4L2StatefulWorkaround>>
CreateV4L2StatefulWorkarounds(V4L2Device::Type device_type,
                              VideoCodecProfile profile);

// DecoderBuffer contains superframe in VP9 k-SVC stream but doesn't have
// superframe_index. If DecoderBuffer has side_data, it stands for sizes of
// frames in a superframe, this constructs superframe_index from them.
// |buffer| is replaced with a new DecoderBuffer, where superframe index is
// appended to |buffer| data. Besides, show_frame in the new DecoderBuffer is
// overwritten so that show_frame is one only in the top spatial layer.
// See go/VP9-k-SVC-Decoing-VAAPI for detail.
bool AppendVP9SuperFrameIndexIfNeeded(scoped_refptr<DecoderBuffer>& buffer);
}  // namespace media

#endif  // MEDIA_GPU_V4L2_V4L2_STATEFUL_WORKAROUND_H_