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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// Copyright (c) 2010 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_OMX_OMX_CONFIGURATOR_H_
#define MEDIA_OMX_OMX_CONFIGURATOR_H_
#include <string>
#include "base/basictypes.h"
#include "third_party/openmax/il/OMX_Component.h"
#include "third_party/openmax/il/OMX_Core.h"
#include "third_party/openmax/il/OMX_Video.h"
namespace media {
class OmxConfigurator {
public:
enum Codec {
kCodecNone,
kCodecH264,
kCodecMpeg4,
kCodecH263,
kCodecVc1,
kCodecRaw,
};
// TODO(jiesun): figure out what other surface formats are.
enum SurfaceFormat {
kSurfaceFormatNV21,
kSurfaceFormatNV21Tiled,
kSurfaceFormatNV12,
};
struct MediaFormatVideoHeader {
int width;
int height;
int stride; // n/a to compressed stream.
int frame_rate;
int bit_rate; // n/a to raw stream.
int profile; // n/a to raw stream.
int level; // n/a to raw stream.
int i_dist; // i frame distance; >0 if p frame is enabled.
int p_dist; // p frame distance; >0 if b frame is enabled.
};
struct MediaFormatVideoRaw {
SurfaceFormat color_space;
};
struct MediaFormatVideoH264 {
int slice_enable;
int max_ref_frames;
int num_ref_l0, num_ref_l1;
int cabac_enable;
int cabac_init_idc;
int deblock_enable;
int frame_mbs_only_flags;
int mbaff_enable;
int bdirect_spatial_temporal;
};
struct MediaFormatVideoMPEG4 {
int ac_pred_enable;
int time_inc_res;
int slice_enable;
};
struct MediaFormat {
// TODO(jiesun): instead of codec type, we should have media format.
Codec codec;
MediaFormatVideoHeader video_header;
union {
MediaFormatVideoRaw raw;
MediaFormatVideoH264 h264;
MediaFormatVideoMPEG4 mpeg4;
};
};
OmxConfigurator(const MediaFormat& input,
const MediaFormat& output)
: input_format_(input),
output_format_(output) {
}
virtual ~OmxConfigurator() {}
// Returns the role name for this configuration.
virtual std::string GetRoleName() const = 0;
// Called by OmxCodec on the message loop given to it during
// transition to idle state.
// OmxCodec reads the current IO port definitions and pass it to this
// method.
// Returns true if configuration has completed successfully.
virtual bool ConfigureIOPorts(
OMX_COMPONENTTYPE* component,
OMX_PARAM_PORTDEFINITIONTYPE* input_port_def,
OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const = 0;
const MediaFormat& input_format() const { return input_format_; }
const MediaFormat& output_format() const { return output_format_; }
private:
MediaFormat input_format_;
MediaFormat output_format_;
private:
DISALLOW_COPY_AND_ASSIGN(OmxConfigurator);
};
class OmxDecoderConfigurator : public OmxConfigurator {
public:
OmxDecoderConfigurator(const MediaFormat& input,
const MediaFormat& output)
: OmxConfigurator(input, output) {
}
virtual ~OmxDecoderConfigurator() {}
virtual std::string GetRoleName() const;
virtual bool ConfigureIOPorts(
OMX_COMPONENTTYPE* component,
OMX_PARAM_PORTDEFINITIONTYPE* input_port_def,
OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const;
private:
DISALLOW_COPY_AND_ASSIGN(OmxDecoderConfigurator);
};
class OmxEncoderConfigurator : public OmxConfigurator {
public:
OmxEncoderConfigurator(const MediaFormat& input,
const MediaFormat& output)
: OmxConfigurator(input, output) {
}
virtual ~OmxEncoderConfigurator() {}
virtual std::string GetRoleName() const;
virtual bool ConfigureIOPorts(
OMX_COMPONENTTYPE* component,
OMX_PARAM_PORTDEFINITIONTYPE* input_port_def,
OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const;
private:
DISALLOW_COPY_AND_ASSIGN(OmxEncoderConfigurator);
};
} // namespace media
#endif // MEDIA_OMX_OMX_CONFIGURATOR_H_
|