24 #include <sys/types.h> 84 #define INPUT_DEQUEUE_TIMEOUT_US 8000 85 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 86 #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000 100 static const struct {
139 color_format, color_format);
177 AVMediaCodecBuffer *
buffer = opaque;
184 "Releasing output buffer %zd (%p) ts=%"PRId64
" on free() [%d pending]\n",
224 buffer =
av_mallocz(
sizeof(AVMediaCodecBuffer));
238 if (!frame->
buf[0]) {
249 buffer->index =
index;
256 "Wrapping output buffer %zd (%p) ts=%"PRId64
" [%d pending]\n",
314 "Frame: width=%d stride=%d height=%d slice-height=%d " 315 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s\n" 316 "destination linesizes=%d,%d,%d\n" ,
355 #define AMEDIAFORMAT_GET_INT32(name, key, mandatory) do { \ 357 if (ff_AMediaFormat_getInt32(s->format, key, &value)) { \ 359 } else if (mandatory) { \ 360 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", key, format); \ 361 ret = AVERROR_EXTERNAL; \ 396 }
else if (strstr(s->
codec_name,
"OMX.SEC.avc.dec")) {
429 "Output crop parameters top=%d bottom=%d left=%d right=%d, " 430 "resulting dimensions width=%d height=%d\n",
488 if (device_ctx->
hwctx) {
525 "Failed to configure codec (status = %d) with format %s\n",
537 "Failed to start codec (status = %d) with format %s\n",
548 "Failed to configure context\n");
567 int need_draining = 0;
577 "until all output buffers have been released\n");
581 if (pkt->
size == 0) {
589 while (offset < pkt->size || (need_draining && !s->
draining)) {
620 av_log(avctx,
AV_LOG_ERROR,
"Failed to queue input empty buffer (status = %d)\n", status);
625 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n", index, size, pts);
633 memcpy(data, pkt->
data + offset, size);
647 "Queued input buffer %zd size=%zd ts=%"PRIi64
"\n", index, size, pts);
680 output_dequeue_timeout_us = 0;
686 " offset=%" PRIi32
" size=%" PRIi32
" ts=%" PRIi64
687 " flags=%" PRIu32
"\n", index, info.
offset, info.
size,
754 "while draining remaining frames, output will probably lack frames\n",
755 output_dequeue_timeout_us / 1000);
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
This structure holds a reference to a android/view/Surface object that will be used as output by the ...
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
static const char * format[]
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
Memory handling functions.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * hwaccel_context
Hardware accelerator context.
timestamp utils, mostly useful for debugging/logging purposes
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
atomic_int hw_buffer_count
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
void * surface
android/view/Surface handle, to be filled by the user.
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define AVERROR_EOF
End of file.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define atomic_load(object)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
uint64_t output_buffer_count
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define atomic_fetch_sub(object, operand)
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
static const uint8_t offset[127][2]
int width
picture width / height.
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define atomic_fetch_add(object, operand)
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static AVRational av_make_q(int num, int den)
Create an AVRational.
main external API structure.
uint8_t * data
The data buffer.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Rational number (pair of numerator and denominator).
static enum AVPixelFormat pix_fmts[]
hardware decoding through MediaCodec
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
common internal and external API header
#define FF_ENABLE_DEPRECATION_WARNINGS
void * surface
android/view/Surface object reference.
#define atomic_init(obj, value)
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.