FFmpeg
mediacodec_wrapper.h
Go to the documentation of this file.
1 /*
2  * Android MediaCodec Wrapper
3  *
4  * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_MEDIACODEC_WRAPPER_H
24 #define AVCODEC_MEDIACODEC_WRAPPER_H
25 
26 #include <stdint.h>
27 #include <sys/types.h>
28 
29 #include "avcodec.h"
30 #include "mediacodec_surface.h"
31 
32 /**
33  * The following API around MediaCodec and MediaFormat is based on the
34  * NDK one provided by Google since Android 5.0.
35  *
36  * Differences from the NDK API:
37  *
38  * Buffers returned by ff_AMediaFormat_toString and ff_AMediaFormat_getString
39  * are newly allocated buffer and must be freed by the user after use.
40  *
41  * The MediaCrypto API is not implemented.
42  *
43  * ff_AMediaCodec_infoTryAgainLater, ff_AMediaCodec_infoOutputBuffersChanged,
44  * ff_AMediaCodec_infoOutputFormatChanged, ff_AMediaCodec_cleanOutputBuffers
45  * ff_AMediaCodec_getName and ff_AMediaCodec_getBufferFlagEndOfStream are not
46  * part of the original NDK API and are convenience functions to hide JNI
47  * implementation.
48  *
49  * The API around MediaCodecList is not part of the NDK (and is lacking as
50  * we still need to retrieve the codec name to work around faulty decoders
51  * and encoders).
52  *
53  * For documentation, please refers to NdkMediaCodec.h NdkMediaFormat.h and
54  * http://developer.android.com/reference/android/media/MediaCodec.html.
55  *
56  */
57 
59 
60 char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int encoder, void *log_ctx);
61 
62 typedef struct FFAMediaFormat FFAMediaFormat;
64  const AVClass *class;
65 
66  FFAMediaFormat *(*create)(void);
67  int (*delete)(FFAMediaFormat *);
68 
69  char* (*toString)(FFAMediaFormat* format);
70 
72  int (*getInt64)(FFAMediaFormat* format, const char *name, int64_t *out);
73  int (*getFloat)(FFAMediaFormat* format, const char *name, float *out);
74  int (*getBuffer)(FFAMediaFormat* format, const char *name, void** data, size_t *size);
75  int (*getString)(FFAMediaFormat* format, const char *name, const char **out);
76  // NDK only, introduced in API level 28
77  int (*getRect)(FFAMediaFormat *, const char *name,
78  int32_t *left, int32_t *top, int32_t *right, int32_t *bottom);
79 
80  void (*setInt32)(FFAMediaFormat* format, const char* name, int32_t value);
81  void (*setInt64)(FFAMediaFormat* format, const char* name, int64_t value);
82  void (*setFloat)(FFAMediaFormat* format, const char* name, float value);
83  void (*setString)(FFAMediaFormat* format, const char* name, const char* value);
84  void (*setBuffer)(FFAMediaFormat* format, const char* name, void* data, size_t size);
85  // NDK only, introduced in API level 28
86  void (*setRect)(FFAMediaFormat*, const char* name,
87  int32_t left, int32_t top, int32_t right, int32_t bottom);
88 };
89 
91 
93 {
94  return format->delete(format);
95 }
96 
98 {
99  return format->toString(format);
100 }
101 
102 static inline int ff_AMediaFormat_getInt32(FFAMediaFormat* format, const char *name, int32_t *out)
103 {
104  return format->getInt32(format, name, out);
105 }
106 
107 static inline int ff_AMediaFormat_getInt64(FFAMediaFormat* format, const char *name, int64_t *out)
108 {
109  return format->getInt64(format, name, out);
110 }
111 
112 static inline int ff_AMediaFormat_getFloat(FFAMediaFormat* format, const char *name, float *out)
113 {
114  return format->getFloat(format, name, out);
115 }
116 
117 static inline int ff_AMediaFormat_getBuffer(FFAMediaFormat* format, const char *name, void** data, size_t *size)
118 {
119  return format->getBuffer(format, name, data, size);
120 }
121 
122 static inline int ff_AMediaFormat_getString(FFAMediaFormat* format, const char *name, const char **out)
123 {
124  return format->getString(format, name, out);
125 }
126 
127 static inline int ff_AMediaFormat_getRect(FFAMediaFormat *format, const char *name,
128  int32_t *left, int32_t *top, int32_t *right, int32_t *bottom)
129 {
130  if (!format->getRect)
131  return AVERROR_EXTERNAL;
132  return format->getRect(format, name, left, top, right, bottom);
133 }
134 
136 {
137  format->setInt32(format, name, value);
138 }
139 
140 static inline void ff_AMediaFormat_setInt64(FFAMediaFormat* format, const char* name, int64_t value)
141 {
142  format->setInt64(format, name, value);
143 }
144 
145 static inline void ff_AMediaFormat_setFloat(FFAMediaFormat* format, const char* name, float value)
146 {
147  format->setFloat(format, name, value);
148 }
149 
150 static inline void ff_AMediaFormat_setString(FFAMediaFormat* format, const char* name, const char* value)
151 {
152  format->setString(format, name, value);
153 }
154 
155 static inline void ff_AMediaFormat_setBuffer(FFAMediaFormat* format, const char* name, void* data, size_t size)
156 {
157  format->setBuffer(format, name, data, size);
158 }
159 
160 static inline void ff_AMediaFormat_setRect(FFAMediaFormat* format, const char* name,
161  int32_t left, int32_t top, int32_t right, int32_t bottom)
162 {
163  if (!format->setRect) {
164  av_log(format, AV_LOG_WARNING, "Doesn't support setRect\n");
165  return;
166  }
167  format->setRect(format, name, left, top, right, bottom);
168 }
169 
171 
176  uint32_t flags;
177 };
179 
180 typedef struct FFAMediaCodec FFAMediaCodec;
182  const AVClass *class;
183 
184  char *(*getName)(FFAMediaCodec *codec);
185 
186  FFAMediaCodec* (*createCodecByName)(const char *name);
187  FFAMediaCodec* (*createDecoderByType)(const char *mime_type);
188  FFAMediaCodec* (*createEncoderByType)(const char *mime_type);
189  int (*delete)(FFAMediaCodec* codec);
190 
191  int (*configure)(FFAMediaCodec* codec, const FFAMediaFormat* format, FFANativeWindow* surface, void *crypto, uint32_t flags);
192  int (*start)(FFAMediaCodec* codec);
193  int (*stop)(FFAMediaCodec* codec);
194  int (*flush)(FFAMediaCodec* codec);
195 
196  uint8_t* (*getInputBuffer)(FFAMediaCodec* codec, size_t idx, size_t *out_size);
197  uint8_t* (*getOutputBuffer)(FFAMediaCodec* codec, size_t idx, size_t *out_size);
198 
199  ssize_t (*dequeueInputBuffer)(FFAMediaCodec* codec, int64_t timeoutUs);
200  int (*queueInputBuffer)(FFAMediaCodec* codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags);
201 
202  ssize_t (*dequeueOutputBuffer)(FFAMediaCodec* codec, FFAMediaCodecBufferInfo *info, int64_t timeoutUs);
203  FFAMediaFormat* (*getOutputFormat)(FFAMediaCodec* codec);
204 
205  int (*releaseOutputBuffer)(FFAMediaCodec* codec, size_t idx, int render);
206  int (*releaseOutputBufferAtTime)(FFAMediaCodec *codec, size_t idx, int64_t timestampNs);
207 
208  int (*infoTryAgainLater)(FFAMediaCodec *codec, ssize_t idx);
209  int (*infoOutputBuffersChanged)(FFAMediaCodec *codec, ssize_t idx);
210  int (*infoOutputFormatChanged)(FFAMediaCodec *codec, ssize_t indx);
211 
215 
217 
219 
220  // For encoder with FFANativeWindow as input.
222 };
223 
224 static inline char *ff_AMediaCodec_getName(FFAMediaCodec *codec)
225 {
226  return codec->getName(codec);
227 }
228 
230 FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime_type, int ndk);
231 FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime_type, int ndk);
232 
233 static inline int ff_AMediaCodec_configure(FFAMediaCodec *codec,
234  const FFAMediaFormat *format,
235  FFANativeWindow *surface,
236  void *crypto, uint32_t flags)
237 {
238  return codec->configure(codec, format, surface, crypto, flags);
239 }
240 
241 static inline int ff_AMediaCodec_start(FFAMediaCodec* codec)
242 {
243  return codec->start(codec);
244 }
245 
246 static inline int ff_AMediaCodec_stop(FFAMediaCodec* codec)
247 {
248  return codec->stop(codec);
249 }
250 
251 static inline int ff_AMediaCodec_flush(FFAMediaCodec* codec)
252 {
253  return codec->flush(codec);
254 }
255 
256 static inline int ff_AMediaCodec_delete(FFAMediaCodec* codec)
257 {
258  return codec->delete(codec);
259 }
260 
261 static inline uint8_t* ff_AMediaCodec_getInputBuffer(FFAMediaCodec* codec, size_t idx, size_t *out_size)
262 {
263  return codec->getInputBuffer(codec, idx, out_size);
264 }
265 
266 static inline uint8_t* ff_AMediaCodec_getOutputBuffer(FFAMediaCodec* codec, size_t idx, size_t *out_size)
267 {
268  return codec->getOutputBuffer(codec, idx, out_size);
269 }
270 
271 static inline ssize_t ff_AMediaCodec_dequeueInputBuffer(FFAMediaCodec* codec, int64_t timeoutUs)
272 {
273  return codec->dequeueInputBuffer(codec, timeoutUs);
274 }
275 
276 static inline int ff_AMediaCodec_queueInputBuffer(FFAMediaCodec *codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags)
277 {
278  return codec->queueInputBuffer(codec, idx, offset, size, time, flags);
279 }
280 
281 static inline ssize_t ff_AMediaCodec_dequeueOutputBuffer(FFAMediaCodec* codec, FFAMediaCodecBufferInfo *info, int64_t timeoutUs)
282 {
283  return codec->dequeueOutputBuffer(codec, info, timeoutUs);
284 }
285 
287 {
288  return codec->getOutputFormat(codec);
289 }
290 
291 static inline int ff_AMediaCodec_releaseOutputBuffer(FFAMediaCodec* codec, size_t idx, int render)
292 {
293  return codec->releaseOutputBuffer(codec, idx, render);
294 }
295 
296 static inline int ff_AMediaCodec_releaseOutputBufferAtTime(FFAMediaCodec *codec, size_t idx, int64_t timestampNs)
297 {
298  return codec->releaseOutputBufferAtTime(codec, idx, timestampNs);
299 }
300 
301 static inline int ff_AMediaCodec_infoTryAgainLater(FFAMediaCodec *codec, ssize_t idx)
302 {
303  return codec->infoTryAgainLater(codec, idx);
304 }
305 
306 static inline int ff_AMediaCodec_infoOutputBuffersChanged(FFAMediaCodec *codec, ssize_t idx)
307 {
308  return codec->infoOutputBuffersChanged(codec, idx);
309 }
310 
311 static inline int ff_AMediaCodec_infoOutputFormatChanged(FFAMediaCodec *codec, ssize_t idx)
312 {
313  return codec->infoOutputFormatChanged(codec, idx);
314 }
315 
317 {
318  return codec->getBufferFlagCodecConfig(codec);
319 }
320 
322 {
323  return codec->getBufferFlagEndOfStream(codec);
324 }
325 
327 {
328  return codec->getBufferFlagKeyFrame(codec);
329 }
330 
332 {
333  return codec->getConfigureFlagEncode(codec);
334 }
335 
337 {
338  return codec->cleanOutputBuffers(codec);
339 }
340 
342 {
343  return codec->signalEndOfInputStream(codec);
344 }
345 
346 int ff_Build_SDK_INT(AVCodecContext *avctx);
347 
348 #endif /* AVCODEC_MEDIACODEC_WRAPPER_H */
ff_AMediaCodec_getInputBuffer
static uint8_t * ff_AMediaCodec_getInputBuffer(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:261
ff_AMediaFormat_setRect
static void ff_AMediaFormat_setRect(FFAMediaFormat *format, const char *name, int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition: mediacodec_wrapper.h:160
ff_AMediaFormat_delete
static int ff_AMediaFormat_delete(FFAMediaFormat *format)
Definition: mediacodec_wrapper.h:92
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
FFAMediaCodec::getBufferFlagKeyFrame
int(* getBufferFlagKeyFrame)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:214
ff_Build_SDK_INT
int ff_Build_SDK_INT(AVCodecContext *avctx)
Definition: mediacodec_wrapper.c:2513
ff_AMediaCodec_delete
static int ff_AMediaCodec_delete(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:256
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
out
FILE * out
Definition: movenc.c:54
FFAMediaFormat::getInt64
int(* getInt64)(FFAMediaFormat *format, const char *name, int64_t *out)
Definition: mediacodec_wrapper.h:72
ff_AMediaCodec_start
static int ff_AMediaCodec_start(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:241
FFAMediaCodecBufferInfo::offset
int32_t offset
Definition: mediacodec_wrapper.h:173
ff_AMediaCodecList_getCodecNameByType
char * ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int encoder, void *log_ctx)
Definition: mediacodec_wrapper.c:365
mediacodec_surface.h
FFAMediaCodec::infoTryAgainLater
int(* infoTryAgainLater)(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:208
out_size
int out_size
Definition: movenc.c:55
ff_AMediaFormat_getRect
static int ff_AMediaFormat_getRect(FFAMediaFormat *format, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom)
Definition: mediacodec_wrapper.h:127
ff_AMediaCodec_signalEndOfInputStream
static int ff_AMediaCodec_signalEndOfInputStream(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:341
ff_AMediaFormat_setString
static void ff_AMediaFormat_setString(FFAMediaFormat *format, const char *name, const char *value)
Definition: mediacodec_wrapper.h:150
ff_AMediaCodec_infoOutputFormatChanged
static int ff_AMediaCodec_infoOutputFormatChanged(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:311
ff_AMediaCodec_infoOutputBuffersChanged
static int ff_AMediaCodec_infoOutputBuffersChanged(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:306
ff_AMediaCodec_releaseOutputBufferAtTime
static int ff_AMediaCodec_releaseOutputBufferAtTime(FFAMediaCodec *codec, size_t idx, int64_t timestampNs)
Definition: mediacodec_wrapper.h:296
data
const char data[16]
Definition: mxf.c:146
FFAMediaCodec::getInputBuffer
uint8_t *(* getInputBuffer)(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:196
FFAMediaCodec::getName
char *(* getName)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:184
ff_AMediaCodec_queueInputBuffer
static int ff_AMediaCodec_queueInputBuffer(FFAMediaCodec *codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags)
Definition: mediacodec_wrapper.h:276
FFAMediaCodecCryptoInfo
struct FFAMediaCodecCryptoInfo FFAMediaCodecCryptoInfo
Definition: mediacodec_wrapper.h:170
FFAMediaFormat::getFloat
int(* getFloat)(FFAMediaFormat *format, const char *name, float *out)
Definition: mediacodec_wrapper.h:73
ff_AMediaFormat_setInt32
static void ff_AMediaFormat_setInt32(FFAMediaFormat *format, const char *name, int32_t value)
Definition: mediacodec_wrapper.h:135
ff_AMediaCodec_configure
static int ff_AMediaCodec_configure(FFAMediaCodec *codec, const FFAMediaFormat *format, FFANativeWindow *surface, void *crypto, uint32_t flags)
Definition: mediacodec_wrapper.h:233
FFAMediaFormat::getBuffer
int(* getBuffer)(FFAMediaFormat *format, const char *name, void **data, size_t *size)
Definition: mediacodec_wrapper.h:74
ff_AMediaFormat_getBuffer
static int ff_AMediaFormat_getBuffer(FFAMediaFormat *format, const char *name, void **data, size_t *size)
Definition: mediacodec_wrapper.h:117
FFAMediaCodec::getOutputFormat
FFAMediaFormat *(* getOutputFormat)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:203
FFAMediaCodec::signalEndOfInputStream
int(* signalEndOfInputStream)(FFAMediaCodec *)
Definition: mediacodec_wrapper.h:221
FFAMediaCodec::dequeueInputBuffer
ssize_t(* dequeueInputBuffer)(FFAMediaCodec *codec, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:199
FFAMediaFormat::getRect
int(* getRect)(FFAMediaFormat *, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom)
Definition: mediacodec_wrapper.h:77
FFAMediaFormat::getInt32
int(* getInt32)(FFAMediaFormat *format, const char *name, int32_t *out)
Definition: mediacodec_wrapper.h:71
ff_AMediaCodec_getName
static char * ff_AMediaCodec_getName(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:224
ff_AMediaCodec_getBufferFlagEndOfStream
static int ff_AMediaCodec_getBufferFlagEndOfStream(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:321
ff_AMediaFormat_setBuffer
static void ff_AMediaFormat_setBuffer(FFAMediaFormat *format, const char *name, void *data, size_t size)
Definition: mediacodec_wrapper.h:155
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
info
MIPS optimizations info
Definition: mips.txt:2
FFAMediaCodec::infoOutputFormatChanged
int(* infoOutputFormatChanged)(FFAMediaCodec *codec, ssize_t indx)
Definition: mediacodec_wrapper.h:210
FFAMediaCodec::infoOutputBuffersChanged
int(* infoOutputBuffersChanged)(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:209
FFAMediaFormat::setBuffer
void(* setBuffer)(FFAMediaFormat *format, const char *name, void *data, size_t size)
Definition: mediacodec_wrapper.h:84
ff_AMediaCodec_createCodecByName
FFAMediaCodec * ff_AMediaCodec_createCodecByName(const char *name, int ndk)
Definition: mediacodec_wrapper.c:2492
ff_AMediaFormat_getInt64
static int ff_AMediaFormat_getInt64(FFAMediaFormat *format, const char *name, int64_t *out)
Definition: mediacodec_wrapper.h:107
ff_AMediaFormat_new
FFAMediaFormat * ff_AMediaFormat_new(int ndk)
Definition: mediacodec_wrapper.c:2485
ff_AMediaFormat_setFloat
static void ff_AMediaFormat_setFloat(FFAMediaFormat *format, const char *name, float value)
Definition: mediacodec_wrapper.h:145
ff_AMediaCodec_getOutputFormat
static FFAMediaFormat * ff_AMediaCodec_getOutputFormat(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:286
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_AMediaCodec_flush
static int ff_AMediaCodec_flush(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:251
FFAMediaCodecBufferInfo
Definition: mediacodec_wrapper.h:172
FFAMediaFormat::setRect
void(* setRect)(FFAMediaFormat *, const char *name, int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition: mediacodec_wrapper.h:86
FFAMediaFormat::getString
int(* getString)(FFAMediaFormat *format, const char *name, const char **out)
Definition: mediacodec_wrapper.h:75
FFAMediaCodecBufferInfo::size
int32_t size
Definition: mediacodec_wrapper.h:174
FFAMediaCodec::dequeueOutputBuffer
ssize_t(* dequeueOutputBuffer)(FFAMediaCodec *codec, FFAMediaCodecBufferInfo *info, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:202
ff_AMediaCodec_stop
static int ff_AMediaCodec_stop(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:246
ff_AMediaCodec_getBufferFlagKeyFrame
static int ff_AMediaCodec_getBufferFlagKeyFrame(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:326
FFAMediaFormat::setFloat
void(* setFloat)(FFAMediaFormat *format, const char *name, float value)
Definition: mediacodec_wrapper.h:82
FFAMediaFormat::setInt64
void(* setInt64)(FFAMediaFormat *format, const char *name, int64_t value)
Definition: mediacodec_wrapper.h:81
ff_AMediaFormat_toString
static char * ff_AMediaFormat_toString(FFAMediaFormat *format)
Definition: mediacodec_wrapper.h:97
ff_AMediaCodec_createEncoderByType
FFAMediaCodec * ff_AMediaCodec_createEncoderByType(const char *mime_type, int ndk)
Definition: mediacodec_wrapper.c:2506
ff_AMediaFormat_getFloat
static int ff_AMediaFormat_getFloat(FFAMediaFormat *format, const char *name, float *out)
Definition: mediacodec_wrapper.h:112
FFAMediaCodec::cleanOutputBuffers
int(* cleanOutputBuffers)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:218
FFAMediaFormat::setInt32
void(* setInt32)(FFAMediaFormat *format, const char *name, int32_t value)
Definition: mediacodec_wrapper.h:80
FFAMediaCodec::stop
int(* stop)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:193
FFAMediaFormat::setString
void(* setString)(FFAMediaFormat *format, const char *name, const char *value)
Definition: mediacodec_wrapper.h:83
size
int size
Definition: twinvq_data.h:10344
ff_AMediaCodec_createDecoderByType
FFAMediaCodec * ff_AMediaCodec_createDecoderByType(const char *mime_type, int ndk)
Definition: mediacodec_wrapper.c:2499
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
ff_AMediaFormat_getInt32
static int ff_AMediaFormat_getInt32(FFAMediaFormat *format, const char *name, int32_t *out)
Definition: mediacodec_wrapper.h:102
FFAMediaCodec::delete
int(* delete)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:189
ff_AMediaCodec_getConfigureFlagEncode
static int ff_AMediaCodec_getConfigureFlagEncode(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:331
FFANativeWindow
Definition: mediacodec_surface.h:28
FFAMediaCodec::releaseOutputBufferAtTime
int(* releaseOutputBufferAtTime)(FFAMediaCodec *codec, size_t idx, int64_t timestampNs)
Definition: mediacodec_wrapper.h:206
FFAMediaCodec
Definition: mediacodec_wrapper.h:181
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FFAMediaCodec::getConfigureFlagEncode
int(* getConfigureFlagEncode)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:216
FFAMediaCodecBufferInfo::flags
uint32_t flags
Definition: mediacodec_wrapper.h:176
profile
int profile
Definition: mxfenc.c:2006
FFAMediaCodec::configure
int(* configure)(FFAMediaCodec *codec, const FFAMediaFormat *format, FFANativeWindow *surface, void *crypto, uint32_t flags)
Definition: mediacodec_wrapper.h:191
ff_AMediaFormat_getString
static int ff_AMediaFormat_getString(FFAMediaFormat *format, const char *name, const char **out)
Definition: mediacodec_wrapper.h:122
FFAMediaCodecBufferInfo::presentationTimeUs
int64_t presentationTimeUs
Definition: mediacodec_wrapper.h:175
ff_AMediaCodec_dequeueInputBuffer
static ssize_t ff_AMediaCodec_dequeueInputBuffer(FFAMediaCodec *codec, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:271
avcodec.h
ff_AMediaCodecProfile_getProfileFromAVCodecContext
int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
The following API around MediaCodec and MediaFormat is based on the NDK one provided by Google since ...
Definition: mediacodec_wrapper.c:303
FFAMediaCodec::queueInputBuffer
int(* queueInputBuffer)(FFAMediaCodec *codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags)
Definition: mediacodec_wrapper.h:200
left
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
Definition: snow.txt:386
AVCodecContext
main external API structure.
Definition: avcodec.h:431
FFAMediaCodec::releaseOutputBuffer
int(* releaseOutputBuffer)(FFAMediaCodec *codec, size_t idx, int render)
Definition: mediacodec_wrapper.h:205
FFAMediaCodec::getBufferFlagCodecConfig
int(* getBufferFlagCodecConfig)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:212
FFAMediaCodec::getBufferFlagEndOfStream
int(* getBufferFlagEndOfStream)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:213
FFAMediaCodec::getOutputBuffer
uint8_t *(* getOutputBuffer)(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:197
ff_AMediaCodec_getBufferFlagCodecConfig
static int ff_AMediaCodec_getBufferFlagCodecConfig(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:316
ff_AMediaCodec_getOutputBuffer
static uint8_t * ff_AMediaCodec_getOutputBuffer(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:266
ff_AMediaCodec_cleanOutputBuffers
static int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:336
ff_AMediaCodec_infoTryAgainLater
static int ff_AMediaCodec_infoTryAgainLater(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:301
int32_t
int32_t
Definition: audioconvert.c:56
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ff_AMediaCodec_releaseOutputBuffer
static int ff_AMediaCodec_releaseOutputBuffer(FFAMediaCodec *codec, size_t idx, int render)
Definition: mediacodec_wrapper.h:291
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_AMediaFormat_setInt64
static void ff_AMediaFormat_setInt64(FFAMediaFormat *format, const char *name, int64_t value)
Definition: mediacodec_wrapper.h:140
int
int
Definition: ffmpeg_filter.c:156
FFAMediaFormat
Definition: mediacodec_wrapper.h:63
FFAMediaCodec::flush
int(* flush)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:194
ff_AMediaCodec_dequeueOutputBuffer
static ssize_t ff_AMediaCodec_dequeueOutputBuffer(FFAMediaCodec *codec, FFAMediaCodecBufferInfo *info, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:281
FFAMediaCodec::start
int(* start)(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:192